public void invalidType(ASTNode location, TypeBinding type) {
if (type instanceof ReferenceBinding) {
if (isRecoveredName(((ReferenceBinding)type).compoundName)) return;
}
else if (type instanceof ArrayBinding) {
TypeBinding leafType = ((ArrayBinding)type).leafComponentType;
if (leafType instanceof ReferenceBinding) {
if (isRecoveredName(((ReferenceBinding)leafType).compoundName)) return;
}
}
if (type.isParameterizedType()) {
List missingTypes = type.collectMissingTypes(null);
if (missingTypes != null) {
ReferenceContext savedContext = this.referenceContext;
for (Iterator iterator = missingTypes.iterator(); iterator.hasNext(); ) {
try {
invalidType(location, (TypeBinding) iterator.next());
} finally {
this.referenceContext = savedContext;
}
}
return;
}
}
int id = IProblem.UndefinedType; // default
switch (type.problemId()) {
case ProblemReasons.NotFound :
id = IProblem.UndefinedType;
break;
case ProblemReasons.NotVisible :
id = IProblem.NotVisibleType;
break;
case ProblemReasons.Ambiguous :
id = IProblem.AmbiguousType;
break;
case ProblemReasons.InternalNameProvided :
id = IProblem.InternalTypeNameProvided;
break;
case ProblemReasons.InheritedNameHidesEnclosingName :
id = IProblem.InheritedTypeHidesEnclosingName;
break;
case ProblemReasons.NonStaticReferenceInStaticContext :
id = IProblem.NonStaticTypeFromStaticInvocation;
break;
case ProblemReasons.IllegalSuperTypeVariable :
id = IProblem.IllegalTypeVariableSuperReference;
break;
case ProblemReasons.NoError : // 0
default :
needImplementation(location); // want to fail to see why we were here...
break;
}
int end = location.sourceEnd;
if (location instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference) location;
if (isRecoveredName(ref.tokens)) return;
if (ref.indexOfFirstFieldBinding >= 1)
end = (int) ref.sourcePositions[ref.indexOfFirstFieldBinding - 1];
} else if (location instanceof ParameterizedQualifiedTypeReference) {
// must be before instanceof ArrayQualifiedTypeReference
ParameterizedQualifiedTypeReference ref = (ParameterizedQualifiedTypeReference) location;
if (isRecoveredName(ref.tokens)) return;
if (type instanceof ReferenceBinding) {
char[][] name = ((ReferenceBinding) type).compoundName;
end = (int) ref.sourcePositions[name.length - 1];
}
} else if (location instanceof ArrayQualifiedTypeReference) {
ArrayQualifiedTypeReference arrayQualifiedTypeReference = (ArrayQualifiedTypeReference) location;
if (isRecoveredName(arrayQualifiedTypeReference.tokens)) return;
TypeBinding leafType = type.leafComponentType();
if (leafType instanceof ReferenceBinding) {
char[][] name = ((ReferenceBinding) leafType).compoundName; // problem type will tell how much got resolved
end = (int) arrayQualifiedTypeReference.sourcePositions[name.length-1];
} else {
long[] positions = arrayQualifiedTypeReference.sourcePositions;