ITypeDefinition superclassDefinition = classDefinition.resolveType(
baseClassReference, project, DependencyType.INHERITANCE);
if (superclassDefinition == null)
{
IASNode problemNode = getBaseClassProblemNode(classNode, classDefinition);
String baseClassReferenceName = baseClassReference.getName();
// The base class reference might be ambiguous.
IDefinition foundDefinition = baseClassReference.resolve(project, (ASScope)classDefinition.getContainingScope(), DependencyType.INHERITANCE, true);
if ( AmbiguousDefinition.isAmbiguous(foundDefinition))
problems.add(new AmbiguousReferenceProblem(problemNode, baseClassReferenceName));
else
problems.add(new UnknownSuperclassProblem(problemNode, baseClassReferenceName));
// Repair by making the class extend Object.
superclassDefinition = getObjectDefinition(project);
}
else if (superclassDefinition instanceof IInterfaceDefinition)
{
IASNode problemNode = getBaseClassProblemNode(classNode, classDefinition);
problems.add(new CannotExtendInterfaceProblem(problemNode));
// Repair by making the class extend Object.
superclassDefinition = getObjectDefinition(project);
}
else if (superclassDefinition.isFinal())
{
IASNode problemNode = getBaseClassProblemNode(classNode, classDefinition);
problems.add(new BaseClassIsFinalProblem(problemNode));
// Repair by making the class extend Object.
superclassDefinition = getObjectDefinition(project);
}
else if (superclassDefinition == classDefinition)
{
problems.add(new CircularTypeReferenceProblem(classDefinition, classDefinition.getQualifiedName()));
// Repair by making the class extend Object.
superclassDefinition = getObjectDefinition(project);
}
// Report a problem if the superclass is deprecated
// and the reference to it is not within a deprecated API.
if (superclassDefinition != null && superclassDefinition.isDeprecated())
{
IASNode problemNode = getBaseClassProblemNode(classNode, classDefinition);
if (!SemanticUtils.hasDeprecatedAncestor(problemNode))
{
ICompilerProblem problem = SemanticUtils.createDeprecationProblem(superclassDefinition, problemNode);
problems.add(problem);
}