Package org.eclipse.jdt.core.dom

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


  public boolean visit(SuperMethodInvocation node) {
    if (!isActive()) {
      return false;
    }

    IMethodBinding methodBinding = (IMethodBinding) resolveBinding(node
        .getName());
    if (methodBinding == null) {
      return false;
    }

    if (containsALocalType(methodBinding)) {
      setHasError(true);
      addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Method_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_32);
      return false;
    }

    ITypeBinding[] parameterTypes = methodBinding.getParameterTypes();
    int paramCount = parameterTypes.length;
    String selector = methodBinding.getName();
    String signature = getMethodSignature(methodBinding, null);

    Name qualifier = node.getQualifier();
    if (Modifier.isStatic(methodBinding.getModifiers())) {
      push(new SendStaticMessage(
          getTypeName(methodBinding.getDeclaringClass()), selector,
          signature, paramCount, fCounter));
    } else {
      push(new SendMessage(selector, signature, paramCount,
          getTypeSignature(methodBinding.getDeclaringClass()),
          fCounter));
      int enclosingLevel = 0;
      if (qualifier != null) {
        ITypeBinding typeBinding = (ITypeBinding) resolveBinding(qualifier);
        if (typeBinding == null) {
          return false;
        }
        enclosingLevel = getEnclosingLevel(node, typeBinding);
      }
      push(new PushThis(enclosingLevel));
      storeInstruction();
    }

    List<Expression> arguments = node.arguments();
    int argCount = arguments.size();
    ITypeBinding lastArgBinding = null;
    if (methodBinding.isVarargs()) {
      lastArgBinding = resolveTypeBinding(arguments.get(argCount - 1));
      if (lastArgBinding == null) {
        return false;
      }
    }
    if (methodBinding.isVarargs() &&
        !(paramCount == argCount &&
        parameterTypes[paramCount - 1].getDimensions() == lastArgBinding.getDimensions())) {
      // if this method is a varargs, and if the method is invoked using
      // the varargs syntax
      // (multiple arguments) and not an array
View Full Code Here


   * MethodDeclaration)
   */
  @Override
  public boolean visit(MethodDeclaration node) {
    if (node.getName().getIdentifier().equals(fName)) {
      IMethodBinding methodBinding = node.resolveBinding();
      if (methodBinding != null) {
        ITypeBinding[] typeBindings = methodBinding.getParameterTypes();
        if (typeBindings.length == fParameterTypes.length) {
          for (int i = 0; i < typeBindings.length; i++) {
            ITypeBinding typeBinding = typeBindings[i];
            String typeSignature = Signature.createTypeSignature(
                typeBinding.getQualifiedName(), true);
View Full Code Here

      throw new RuntimeException("unsupported expression: " + javaExpression);
    }
  }

  private IASTExpression convertSuperMethodInvocation(final SuperMethodInvocation superMethodInvocation) {
    final IMethodBinding methodBinding = superMethodInvocation.resolveMethodBinding();
    final ICPPASTQualifiedName qualifiedName = f.newQualifiedName();
    qualifiedName.addName(f.newName(methodBinding.getDeclaringClass().getName().toCharArray()));
    qualifiedName.addName(new NameInfo(superMethodInvocation.getName()).getName());
    final IASTExpression call = f.newIdExpression(qualifiedName);
    final List<IASTInitializerClause> initializerClauses = new ArrayList<IASTInitializerClause>();
    for (final Object argumentObject : superMethodInvocation.arguments()) {
      final ExpressionInfo argument = new ExpressionInfo((Expression) argumentObject, typeDeclaration, compilationUnitInfo);
View Full Code Here

  }

  private IASTExpression convertMethodInvocation(final MethodInvocation methodInvocation) {
    IASTExpression call;
    if (methodInvocation.getExpression() != null) {
      final IMethodBinding methodBinding = methodInvocation.resolveMethodBinding();
      if ((methodBinding != null) && ((methodBinding.getModifiers() & Modifier.STATIC) != 0)) {
        final ICPPASTQualifiedName qualifiedName = f.newQualifiedName();
        qualifiedName.addName(f.newName(methodBinding.getDeclaringClass().getName().toCharArray()));
        qualifiedName.addName(new NameInfo(methodInvocation.getName()).getName());
        call = f.newIdExpression(qualifiedName);
      } else {
        final Expression qualifier = methodInvocation.getExpression();
        final ICPPASTFieldReference fieldReference = f.newFieldReference(new NameInfo(methodInvocation.getName()).getName(), new ExpressionInfo(qualifier, typeDeclaration, compilationUnitInfo).getExpression());
View Full Code Here

        candidateValueType = stripGeneric(candidateValueType);
        return Constants.BUILT_IN_VALUE_TYPES.containsKey(candidateValueType);
    }

    public static boolean isBuiltInValueType(MethodDeclaration methodDeclaration) {
        IMethodBinding methodBinding = methodDeclaration.resolveBinding();
        if (methodBinding == null) {
            return false;
        }
       
        ITypeBinding returnType = methodBinding.getReturnType();
        if (returnType == null) {
            return false;
        }
       
        return isBuiltInValueType(returnType.getQualifiedName());
View Full Code Here

    }

    private static boolean hasAnnotationOnReturnType(
            MethodDeclaration methodDeclaration,
            String annotationTypeName) {
        IMethodBinding methodBinding = methodDeclaration.resolveBinding();
        if (methodBinding == null) {
            return false;
        }
       
        return TypeUtils.hasAnnotation(methodBinding.getReturnType(), annotationTypeName);
    }
View Full Code Here

        return TypeUtils.hasAnnotation(methodBinding.getReturnType(), annotationTypeName);
    }


    public static boolean isStringValueType(MethodDeclaration methodDeclaration) {
        IMethodBinding methodBinding = methodDeclaration.resolveBinding();
        if (methodBinding == null) {
            return false;
        }
       
        ITypeBinding returnType = methodBinding.getReturnType();
        if (returnType == null) {
            return false;
        }
       
        return "java.lang.String".equals(returnType.getQualifiedName());
View Full Code Here

     * @param methodDeclaration
     * @return
     */
    public static String asCollectionName(MethodDeclaration methodDeclaration) {
     
      IMethodBinding methodBinding = methodDeclaration.resolveBinding();
      if (methodBinding == null) {
        return "";
      }
      String methodName = methodBinding.getName();
   
      // determine if accessor for a property or collection
      String candidateCollectionName = MethodUtils.unprefixed(methodName, Constants.PREFIX_GET);
      if (candidateCollectionName == null) {
        return null;
      }
   
        // check is public
        if (!MethodUtils.isPublic(methodDeclaration)) {
            return null;
        }
   
        // check has no parameters
        if (methodDeclaration.parameters().size() > 0) {
            return null;
        }
   
      // check the return type is a collection...
      ITypeBinding returnType = methodBinding.getReturnType();
      ITypeBinding accessorReturnCollectionType = returnType.getTypeDeclaration();
      String qualifiedName = accessorReturnCollectionType.getQualifiedName();
        if (!MethodUtils.isCollectionType(qualifiedName)) {
        return null;
      }
View Full Code Here

      return methodName;
    }
   
    public static boolean isLog4jLogger(MethodDeclaration methodDeclaration) {
       
        IMethodBinding methodBinding = methodDeclaration.resolveBinding();
        if (methodBinding == null) {
            return false;
        }

        // check the return type
        ITypeBinding returnType = methodBinding.getReturnType();
        String qualifiedName = returnType.getQualifiedName();
       
        return "org.apache.log4j.Logger".equals(qualifiedName);
    }
View Full Code Here

        parameterTypes.append(", ");   
      parameterTypes.append(((SingleVariableDeclaration)obj).getType().toString());
    }
    parameterTypes.append(")");

    IMethodBinding binding = md.resolveBinding();
    if (binding == null) {
//      log.error("Binding not resolved, probably project path is invalid: " + node);
      if (generatedNames.containsKey(md))
        return generatedNames.get(md);
      String name = "Dummy_method_location_" + methodIdxGen++ + ":" + md.getName() + parameterTypes;
      generatedNames.put(md, name);
      return name;
    }
    return binding.getDeclaringClass().getBinaryName() + ":" + md.getName()+ parameterTypes;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.IMethodBinding

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.