Examples of IMethodBinding


Examples of org.eclipse.jdt.core.dom.IMethodBinding

   
    return encodedParentTypeQualifier + '/' + encode(sb.toString());
  }

  static String resolveAndEncodeCallee(MethodInvocation node) {
    IMethodBinding resolvedBinding = node.resolveMethodBinding();
    IMethodBinding callee = resolvedBinding.getMethodDeclaration();
   
    return resolveAndEncode(callee);
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

   
    return resolveAndEncode(callee);
  }

  static String resolveAndEncodeCallee(ConstructorInvocation node) {
    IMethodBinding resolvedBinding = node.resolveConstructorBinding();
    IMethodBinding callee = resolvedBinding.getMethodDeclaration();
   
    return resolveAndEncode(callee);
  }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

    return super.visit(node);
  }
 
  @Override
  public boolean visit(MethodInvocation node) {
    IMethodBinding binding = node.resolveMethodBinding();
    if(binding.getDeclaringClass() != null &&
       binding.getDeclaringClass().isTopLevel() /* hack, resolve */) {
     
      // A constructor/method can only invoke other methods - no need to check for constructors here.
      MethodHandle methodHandle = model.getMethodHandleFor(VisitorUtil.resolveAndEncodeCallee(node), VisitorUtil.identifierFor(node));

      currentCallable().addMethodInvocation(methodHandle, new SourceCodeLocationHelper(cu, node));
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

    return super.visit(node);
  }
 
  @Override
  public boolean visit(ConstructorInvocation node) {
    IMethodBinding binding = node.resolveConstructorBinding();
    if (binding.getDeclaringClass() != null &&
      binding.getDeclaringClass().isTopLevel() /* hack, resolve */) {

      ConstructorHandle constructorHandle = model.getConstructorHandleFor(VisitorUtil.resolveAndEncodeCallee(node), VisitorUtil.identifierFor(node));

      currentCallable().addMethodInvocation(constructorHandle, new SourceCodeLocationHelper(cu, node));
    }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

          // 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
            if (!methBinding.getName().startsWith("set") &&
                !methBinding.getName().startsWith("get") &&
                !methBinding.getName().startsWith("is") &&
                !methBinding.isConstructor()) {
              generateResultsForASTNode(history, meth, resource, "The method "+
                  methBinding.getName() + " in the Model class "+
                  binding.getName() + " is not a getter or setter");
              continue;
            }
           
            if (methBinding.getName().startsWith("set")) {
              if (!methBinding.getReturnType().getName().equals("void")) {
                generateResultsForASTNode(history, meth, resource, "The setter "+
                    methBinding.getName() + " in the Model class "+
                    binding.getName() + " does not return void");
              }
              if (methBinding.getParameterTypes().length != 1) {
                generateResultsForASTNode(history, meth, resource, "The setter "+
                    methBinding.getName() + " in the Model class "+
                    binding.getName() + " must have exactly one parameter");
              }
            } else if (methBinding.getName().startsWith("get") ||
                methBinding.getName().startsWith("is")) {
              if (methBinding.getParameterTypes().length != 0) {
                generateResultsForASTNode(history, meth, resource, "The getter "+
                    methBinding.getName() + " in the Model class "+
                    binding.getName() + " may not have any parameters");
              }
            }
           
            if (!methBinding.isConstructor()) {
              // Method is a getter or setter. Check if there is only
              // one statement in the method so that there can be no
              // computations.
              Block body = meth.getBody();
              if (body != null) {
                if (body.statements().size() != 1) {
                  generateResultsForASTNode(history, meth, resource, "The getter "+
                      methBinding.getName() + " in the Model class "+
                      binding.getName() + " must include exactly one statement.");
                }
              }
            }
          }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

        }
       
        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);
          }
        }
       
       
        for (ITypeBinding binding : allReferences.getTypeReferences()) {
          String className = binding.getQualifiedName();
         
          if (className == null || className.equals("")) {
            continue;
          }
         
          String refCompName = mappingHelper.getComponentName(binding);
          if (refCompName != null) {
            // look if that class may be known to this class
            if (!mappingHelper.mayClassReferenceOtherClass(mainTypeBinding.getQualifiedName(),
                compName, className, refCompName)) {
              for (ASTNode refNode : allReferences.getOccurrencesOfTypeReference(binding)) {
                StyleCheckResult.generateResultsForASTNode(this, history.getHistoryId(), refNode, resource,
                    "The class '"+ binding.getName()
                    +"' belongs to the component '"+ refCompName+
                    "' and may not be referenced from this class");
              }
            }
           
          } else {
            boolean unchecked = false;
           
            for (String pkg : UNCHECKED_PACKAGES) {
              if (className.startsWith(pkg)) {
                unchecked = true;
              }
            }
           
            if (!unchecked && warningsForUnmappedClasses) {
              // non-standard classes must belong to a component!
              for (ASTNode refNode : allReferences.getOccurrencesOfTypeReference(binding)) {
                StyleCheckResult.generateResultsForASTNode(this, history.getHistoryId(),
                    refNode, resource, "The referenced class "+ binding.getName()
                    +"  does not belong to a component");
              }
            }
          }
        }
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

    classDependencies = myClassDependencies;
    iCompUnit = iComp;
  }

  public boolean visit(ClassInstanceCreation node) {
    IMethodBinding binding = node.resolveConstructorBinding();
    if (binding != null) {
      List<String> nodesID;
      String handleID = iCompUnit.getHandleIdentifier();

      ITypeBinding[] params = binding.getParameterTypes();
      String paramString = "(";
      for (int i = 0; i < params.length; i++) {
        paramString += params[i].getName();
        if (i < params.length - 1)
          paramString += ",";
      }
      paramString += ")";
      String key = binding.getDeclaringClass().getName() + "." + binding.getName() + paramString;

      if (usedMethods.containsKey(key)) {
        nodesID = usedMethods.get(key);
        nodesID.add(handleID);
      } else {
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

    }
    return true;
  }

  public boolean visit(MethodInvocation node) {
    IMethodBinding binding = node.resolveMethodBinding();
    if (binding != null) {
      List<String> nodesID;
      String handleID = iCompUnit.getHandleIdentifier();

      ITypeBinding[] params = binding.getParameterTypes();
      String paramString = "(";
      for (int i = 0; i < params.length; i++) {
        paramString += params[i].getName();
        if (i < params.length - 1)
          paramString += ",";
      }
      paramString += ")";
      String key = binding.getDeclaringClass().getName() + "." + binding.getName() + paramString;

      if (usedMethods.containsKey(key)) {
        nodesID = usedMethods.get(key);
        nodesID.add(handleID);
      } else {
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

    }
    return true;
  }

  public boolean visit(MethodDeclaration node) {
    IMethodBinding binding = node.resolveBinding();
    if (binding != null) {
      ITypeBinding[] params = binding.getParameterTypes();
      String paramString = "(";
      for (int i = 0; i < params.length; i++) {
        paramString += params[i].getName();
        if (i < params.length - 1)
          paramString += ",";
      }
      paramString += ")";
      String key = binding.getDeclaringClass().getName() + "." + binding.getName() + paramString;
      ITypeBinding declaredClassBinding = binding.getDeclaringClass();

      // overrides super method
      ITypeBinding superClassBinding = declaredClassBinding.getSuperclass();
      boolean skip = checkSuperClass(binding, superClassBinding);

      // is implementation of interface
      ITypeBinding[] interfaceBindings = declaredClassBinding.getInterfaces();
      skip = skip || checkInterfaces(binding, interfaceBindings);

      if (superClassBinding != null) {
        // classDependencies
        classDependencies.put(declaredClassBinding.getName(), superClassBinding.getName());

        // WOComponent && title()
        boolean isWOComponent = superClassBinding.getName().equals("WOComponent");
        skip = skip || (isWOComponent && binding.getName().equals("title"));
      }

      // DirectAction.Action()
      boolean isDirectAction = declaredClassBinding.getName().equals("DirectAction");
      skip = skip || (isDirectAction && (binding.getName().endsWith("Action") || binding.getName().equals("performActionNamed")));

      // app || logic && Constructor
      IPackageBinding packageBinding = declaredClassBinding.getPackage();
      String[] comps = packageBinding.getNameComponents();
      if (comps.length > 0) {
        String comp = comps[comps.length - 1];
        skip = skip || ((comp.equals("app") || comp.equals("logic")) && binding.isConstructor());
      }

      if (!usedMethods.containsKey(key)) {
        List<String> value = new ArrayList<String>();
        value.add(iCompUnit.getHandleIdentifier());
        value.add(binding.getName());
        value.add(binding.getReturnType().getName());
        value.add(skip + "");
        declaredMethods.put(key, value);
      }
    }
    return true;
View Full Code Here

Examples of org.eclipse.jdt.core.dom.IMethodBinding

      "public void bar(sharpen.ui.tests.BindingTestCaseSubject.Baz b) { b.bar(); }" +
      "}";
    CompilationUnit ast = createAST(source);
    MethodDeclaration method = getType(ast, "Gazonk").getMethods()[0];
    MethodInvocation invocation = getFirstMethodInvocation(method);
    IMethodBinding definition = BindingUtils.findMethodDefininition(invocation.resolveMethodBinding(), null);
    assertEquals("sharpen.ui.tests.BindingTestCaseSubject.Foo.bar", BindingUtils.qualifiedName(definition));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.