Package org.eclipse.tptp.platform.analysis.codereview.java

Examples of org.eclipse.tptp.platform.analysis.codereview.java.CodeReviewResource


public class NoComputationInModelRule extends AbstractArchitectureConformanceRule {
 
  @Override
  public void analyze(AnalysisHistory history) {
    CodeReviewResource resource = getCurrentResource(history);
    List<?> list = resource.getTypedNodeList(resource.getResourceCompUnit(),
        ASTNode.TYPE_DECLARATION, true);
   
    for (Object obj : list) {
      TypeDeclaration typeDec = (TypeDeclaration) obj;
      ITypeBinding binding = typeDec.resolveBinding();
     
      String compName = mappingHelper.getComponentName(binding);
      if (compName != null) {
        Component comp = arch.getComponentByName(compName);
        if (comp != null && MODEL_COMPONENT_TYPE.equals(comp.getStyleType())) {
          // look at the methods...
         
          List<?> methods = resource.getTypedNodeList(typeDec, ASTNode.METHOD_DECLARATION, false);
          for (Object methObj : methods) {
            MethodDeclaration meth = (MethodDeclaration) methObj;
            IMethodBinding methBinding = meth.resolveBinding();
           
            // The name must begin with get or set
View Full Code Here


public class NoStaticMethodsRule extends AbstractArchitectureConformanceRule {

  @Override
  public void analyze(AnalysisHistory history) {
    CodeReviewResource res = getCurrentResource(history);
   
    List<?> nodes = res.getTypedNodeList(res.getResourceCompUnit(), ASTNode.METHOD_DECLARATION, true);
   
    for (Object obj : nodes) {
      MethodDeclaration decl = (MethodDeclaration) obj;
      for (Object modObj : decl.modifiers()) {
        IExtendedModifier mod = (IExtendedModifier) modObj;
View Full Code Here

public class NoCreationOfModelClassesInViewRule extends AbstractArchitectureConformanceRule {

  @Override
  public void analyze(AnalysisHistory history) {
    CodeReviewResource resource = getCurrentResource(history);
    List<?> list = resource.getTypedNodeList(resource.getResourceCompUnit(),
        ASTNode.TYPE_DECLARATION, true);
   
    for (Object obj : list) {
      TypeDeclaration typeDec = (TypeDeclaration) obj;
      ITypeBinding binding = typeDec.resolveBinding();
     
      String compName = mappingHelper.getComponentName(binding);
      if (compName != null) {
        Component comp = arch.getComponentByName(compName);
        if (comp != null && VIEW_COMPONENT_TYPE.equals(comp.getStyleType())) {
          List<?> constructions = resource.getTypedNodeList(typeDec, ASTNode.CLASS_INSTANCE_CREATION, true);
         
          for (Object constrObj : constructions) {
            ClassInstanceCreation constrInv = (ClassInstanceCreation) constrObj;
            Type type = constrInv.getType();
            ITypeBinding classBinding = type.resolveBinding();
View Full Code Here

public class NoCreationOfSingletonsRule extends
    AbstractArchitectureConformanceRule {

  @Override
  public void analyze(AnalysisHistory history) {
    CodeReviewResource resource = getCurrentResource(history);
    List<?> list = resource.getTypedNodeList(resource.getResourceCompUnit(),
        ASTNode.CLASS_INSTANCE_CREATION, true);
   
    for (Object obj : list) {
      ClassInstanceCreation creation = (ClassInstanceCreation) obj;
      Type type = creation.getType();
View Full Code Here

              .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);
          }
View Full Code Here

public class ClassesWithoutMappingRule extends
    AbstractArchitectureConformanceRule {

  @Override
  public void analyze(AnalysisHistory history) {
    CodeReviewResource resource = getCurrentResource(history);
    List<?> classes = resource.getTypedNodeList(resource
        .getResourceCompUnit(), ASTNode.TYPE_DECLARATION, false);
   
    for (Object typeObj : classes) {
      TypeDeclaration type = (TypeDeclaration) typeObj;
      ITypeBinding binding = type.resolveBinding();
View Full Code Here



  @Override
  public void analyze(AnalysisHistory history) {
    CodeReviewResource resource = getCurrentResource(history);
    List list = resource.getTypedNodeList(resource
        .getResourceCompUnit(), ASTNode.TYPE_DECLARATION);
   
    for (Object obj : list) {
      TypeDeclaration type = (TypeDeclaration) obj;
      ITypeBinding binding = type.resolveBinding();
View Full Code Here

    }
  }
 
  @Override
  public void analyze(AnalysisHistory history) {
    CodeReviewResource resource = null;
    List<?> list = null;
   
   
    try {
      resource = getCurrentResource(history);

      list = resource.getTypedNodeList(resource
          .getResourceCompUnit(), ASTNode.TYPE_DECLARATION);

      ASTHelper.satisfy(list,
          new ComponentRuleFilter(mappingHelper, null, true));
View Full Code Here

TOP

Related Classes of org.eclipse.tptp.platform.analysis.codereview.java.CodeReviewResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.