.getValue().equals("true");
}
@Override
public void analyze(AnalysisHistory history) {
CodeReviewResource resource = getCurrentResource(history);
List<?> list = resource.getTypedNodeList(resource.getResourceCompUnit(),
ASTNode.TYPE_DECLARATION, true);
// Go through all classes, look to which component they belong, and
// look for referenced components
for (Object obj : list) {
ASTNode node = (ASTNode) obj;
if (node.getNodeType() == ASTNode.TYPE_DECLARATION) {
ITypeBinding mainTypeBinding = ((TypeDeclaration) node).resolveBinding();
String compName = mappingHelper.getComponentName(mainTypeBinding);
if (compName == null) {
// If the class does not belong to a component,
// we can say nothing about it
continue;
}
// now we can look for referenced classes. If one of these classes
// belongs to a component, we can check if there is a connection in
// the architecture, too.
MyTypeReferenceList allReferences = new MyTypeReferenceList();
Map<ITypeBinding, IMethodBinding> methodCalls = new HashMap<ITypeBinding, IMethodBinding>();
List<?> fields = resource.getTypedNodeList(node, ASTNode.FIELD_DECLARATION, true);
for (Object fieldObj : fields) {
FieldDeclaration field = (FieldDeclaration) fieldObj;
Type type = field.getType();
addAllIncludedTypes(type, allReferences);
}
fields = resource.getTypedNodeList(node, ASTNode.METHOD_INVOCATION, true);
for (Object methodInvObj : fields) {
MethodInvocation methInv = (MethodInvocation) methodInvObj;
IMethodBinding binding = (IMethodBinding) methInv.getName().resolveBinding();
if (methInv.getExpression() != null) {
ITypeBinding typeBinding = methInv.getExpression().resolveTypeBinding();
if (binding != null && typeBinding != null) {
allReferences.addTypeReference(typeBinding, methInv);
methodCalls.put(typeBinding, binding);
ITypeBinding returnType = binding.getReturnType();
if (returnType != null) {
if (!returnType.isPrimitive()) {
allReferences.addTypeReference(returnType, methInv);
}
}
}
}
}
fields = resource.getTypedNodeList(node, ASTNode.VARIABLE_DECLARATION_STATEMENT, true);
for (Object varObj: fields) {
VariableDeclarationStatement varDecl = (VariableDeclarationStatement) varObj;
Type type = varDecl.getType();
addAllIncludedTypes(type, allReferences);
}
fields = resource.getTypedNodeList(node, ASTNode.METHOD_DECLARATION, true);
for (Object methDeclObj : fields) {
MethodDeclaration methDecl = (MethodDeclaration) methDeclObj;
Type returnType = methDecl.getReturnType2();
if (returnType != null) {
addAllIncludedTypes(returnType, allReferences);
}
// look at all parameters...
for (Object varObj : methDecl.parameters()) {
SingleVariableDeclaration var = (SingleVariableDeclaration) varObj;
addAllIncludedTypes(var.getType(), allReferences);
}
}
fields = resource.getTypedNodeList(node, ASTNode.CLASS_INSTANCE_CREATION, true);
for (Object classCreationObj : fields) {
ClassInstanceCreation classCreation = (ClassInstanceCreation) classCreationObj;
if (classCreation.getType() != null) {
addAllIncludedTypes(classCreation.getType(), allReferences);
}