ITypeBinding binding = type.resolveBinding();
if (binding == null) {
continue;
}
ImplementationArtifactDefinition artifactDef = qualifiedNames.
get(binding.getQualifiedName());
if (artifactDef == null) {
// The information could also be contained in
// annotations or classNamePatterns
artifactDef = mappingHelper.getClassInformation(binding);
}
if (artifactDef != null) {
// We have found the artifact
artifactsNotPresent.remove(artifactDef);
if (artifactDef instanceof InterfaceDefinition &&
!binding.isInterface()) {
generateResultsForASTNode(history, type, resource,
"The type "+ binding.getQualifiedName() + " is a class"+
", but should be an interface according to the definition in "+
artifactDef.getParent().getName());
continue;
}
if (artifactDef instanceof ClassDefinition &&
binding.isInterface()) {
generateResultsForASTNode(history, type, resource,
"The type "+ binding.getQualifiedName() + " is "+
"an interface, but should be a class according to the definition in "+
artifactDef.getParent().getName());
continue;
}
if (binding.getSuperclass() != null &&
binding.getSuperclass() != type.getAST().resolveWellKnownType("java.lang.Object")) {
// Check Restriction.noSuperClass
ImplementationArtifactType artifactType = mappingHelper.getTypeOf(artifactDef);
if (artifactType != null && artifactType instanceof ClassType) {
ClassType classType = (ClassType) artifactType;
if (classType.getRestrictions().contains(ClassTypeRestriction.noSuperclass)) {
generateResultsForASTNode(history, type, resource,
"The type "+ binding.getQualifiedName() + " should "+
"not have a superclass according to the style mapping.");
}
}
}
// Now we have to check if all superclasses and interfaces
// are ok
List<String> interfaces = mappingHelper.getSuperInterfaces(artifactDef);
String superClass = mappingHelper.getSuperClass(artifactDef);
if (superClass != null &&
!hasSuperclass(binding, superClass)) {
generateResultsForASTNode(history, type, resource,
"The type "+ binding.getQualifiedName() + " should "+
"have the superclass " + superClass + " according to the definition in "+
artifactDef.getParent().getName());
}
List<String> actualInterfaces = getAllInterfaces(binding);
for (String iface : interfaces) {
if (!actualInterfaces.contains(iface)) {
generateResultsForASTNode(history, type, resource,
"The type "+ binding.getQualifiedName() + " should "+
"implement the interface " + iface + " according to the definition in "+
artifactDef.getParent().getName());
}
}
}