JCDiagnostic getDiagnostic(DiagnosticType dkind,
DiagnosticPosition pos,
Symbol location,
Type site,
Name name,
List<Type> argtypes,
List<Type> typeargtypes) {
argtypes = argtypes == null ? List.< Type >nil() : argtypes;
typeargtypes = typeargtypes == null ? List.< Type >nil() : typeargtypes;
if (name == names.error)
return null;
if (isOperator(name)) {
boolean isUnaryOp = argtypes.size() == 1;
String key = argtypes.size() == 1 ?
"operator.cant.be.applied" :
"operator.cant.be.applied.1";
Type first = argtypes.head;
Type second = !isUnaryOp ? argtypes.tail.head : null;
return diags.create(dkind, log.currentSource(), pos,
key, name, first, second);
}
boolean hasLocation = false;
if (location == null) {
location = site.tsym;
}
if (!location.name.isEmpty()) {
if (location.kind == PCK && !site.tsym.exists()) {
return diags.create(dkind, log.currentSource(), pos,
"doesnt.exist", location);
}
hasLocation = !location.name.equals(names._this) &&
!location.name.equals(names._super);
}
boolean isConstructor = kind == ABSENT_MTH &&
name == names.table.names.init;
KindName kindname = isConstructor ? KindName.CONSTRUCTOR : absentKind(kind);
Name idname = isConstructor ? site.tsym.name : name;
String errKey = getErrorKey(kindname, typeargtypes.nonEmpty(), hasLocation);
if (hasLocation) {
return diags.create(dkind, log.currentSource(), pos,
errKey, kindname, idname, //symbol kindname, name
typeargtypes, argtypes, //type parameters and arguments (if any)
getLocationDiag(location, site)); //location kindname, type
}
else {
return diags.create(dkind, log.currentSource(), pos,
errKey, kindname, idname, //symbol kindname, name
typeargtypes, argtypes); //type parameters and arguments (if any)
}
}
|