Package org.eclipse.jdt.core.dom

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


      printSuperCall(decl, impl);
    }
  }

  private void printSuperCall(IMethodBinding decl, IMethodBinding impl) {
    IMethodBinding md = decl.getMethodDeclaration();
    TransformUtil.printSignature(ctx, out, type, md, impl.getReturnType(),
        deps, true);
    println();
    println("{");

    boolean erased = TransformUtil.returnErased(impl);
    method(decl);

    if (TransformUtil.isVoid(impl.getReturnType())) {
      out.format(i1 + "%s::%s(", CName.of(impl.getDeclaringClass()),
          CName.of(impl));
    } else {
      print(i1 + "return ");
      if (erased) {
        javaCast(impl.getMethodDeclaration().getReturnType()
            .getErasure(), impl.getReturnType());
      }

      out.format("%s::%s(", CName.of(impl.getDeclaringClass()),
          CName.of(impl));
    }

    String sep = "";
    for (int i = 0; i < impl.getParameterTypes().length; ++i) {
      print(sep);
      sep = ", ";

      boolean cast = !md.getParameterTypes()[i].getErasure()
          .isAssignmentCompatible(
              impl.getParameterTypes()[i].getErasure());
      if (cast) {
        javaCast(md.getParameterTypes()[i], impl.getParameterTypes()[i]);
      }
      print(TransformUtil.paramName(md, i));
      if (cast) {
        print(")");
      }
View Full Code Here


          ITypeBinding tb = (ITypeBinding) t;
          return tb.getName().equals(name);
        }

        if (t instanceof IMethodBinding) {
          IMethodBinding mb = (IMethodBinding) t;
          return mb.getName().equals(name);
        }

        if (t instanceof IVariableBinding) {
          IVariableBinding vb = (IVariableBinding) t;
          return vb.getName().equals(name);
View Full Code Here

      Transformer ctx, Map<String, List<IMethodBinding>> methods) {
    List<IMethodBinding> superMethods = TypeUtil.methods(TypeUtil.allBases(
        type, ctx.resolve(Object.class)));
    outer: for (Iterator<IMethodBinding> i = superMethods.iterator(); i
        .hasNext();) {
      IMethodBinding supermethod = i.next();

      if (Modifier.isPrivate(supermethod.getModifiers())
          || supermethod.isConstructor()) {
        i.remove();
        continue;
      }

      Collection<IMethodBinding> declared = methods.get(supermethod
          .getName());

      if (declared == null) {
        i.remove();
        continue;
      }

      for (IMethodBinding d : declared) {
        if (TransformUtil.sameParameters(supermethod, d, false)) {
          i.remove();
          continue outer;
        }
      }
    }

    List<IMethodBinding> copy = new ArrayList<IMethodBinding>(superMethods);
    for (IMethodBinding a : copy) {
      for (Iterator<IMethodBinding> i = superMethods.iterator(); i
          .hasNext();) {
        IMethodBinding b = i.next();
        if (a.overrides(b)) {
          i.remove();
          continue;
        }
      }
    }

    copy = new ArrayList<IMethodBinding>(superMethods);
    for (IMethodBinding a : copy) {
      boolean dupe = false;
      for (Iterator<IMethodBinding> i = superMethods.iterator(); i
          .hasNext();) {
        IMethodBinding b = i.next();
        if (TransformUtil.isSubsignature(a, b)) {
          if (dupe) {
            i.remove();
          } else {
            dupe = true;
View Full Code Here

      return;
    }

    List<IMethodBinding> missing = baseCallMethods(type);
    for (IMethodBinding decl : missing) {
      IMethodBinding impl = findImpl(type, decl);
      if (impl == null) {
        // Only print super call if an implementation actually
        // exists
        continue;
      }

      if (Modifier.isAbstract(impl.getModifiers())) {
        continue;
      }

      printSuperCall(decl, impl);
    }
View Full Code Here

        for (IMethodBinding m0 : b0.getDeclaredMethods()) {
          for (IMethodBinding m1 : b1.getDeclaredMethods()) {
            if (m0.getName().equals(m1.getName())) {
              boolean found = false;
              for (int i = 0; i < ret.size(); ++i) {
                IMethodBinding m2 = ret.get(i);
                if (TransformUtil.isSubsignature(m2, m0)) {
                  found = true;

                  // If two methods have different return
                  // type, use the method with the most
                  // derived return type for return covariance
                  // to work properly
                  if (m0.getReturnType()
                      .getErasure()
                      .isSubTypeCompatible(
                          m2.getReturnType()
                              .getErasure())) {
                    hardDep(m0.getReturnType());
                    m2 = ret.set(i, m0);
                  }
                }
View Full Code Here

    if (!Modifier.isFinal(vb.getModifiers())) {
      return false;
    }
    VariableDeclarationFragment vdf = initializer(node);
    if (vdf == null && vb.getDeclaringMethod() != null) {
      IMethodBinding pmb = parentMethod(node);
      if (pmb.isEqualTo(vb.getDeclaringMethod())) {
        // Final local variable
        return false;
      }
    }
    return true;
View Full Code Here

      }
    } else if (b instanceof ITypeBinding) {
      print(CName.relative((ITypeBinding) b, type, true));
      softDep((ITypeBinding) b);
    } else if (b instanceof IMethodBinding) {
      IMethodBinding mb = (IMethodBinding) b;

      if (needsQualification(node, mb.getDeclaringClass())) {
        qualify(mb.getDeclaringClass().getErasure(),
            TransformUtil.isStatic(mb));
      }

      if (node.getParent() instanceof SuperMethodInvocation) {
        print("super::");
View Full Code Here

   */
  private void addPopInstructionIfNeeded(Expression expression) {
    boolean pop = true;

    if (expression instanceof MethodInvocation) {
      IMethodBinding methodBinding = (IMethodBinding) ((MethodInvocation) expression)
          .getName().resolveBinding();
      if (methodBinding != null
          && "void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$
        pop = false;
      }
    } else if (expression instanceof SuperMethodInvocation) {
      IMethodBinding methodBinding = (IMethodBinding) ((SuperMethodInvocation) expression)
          .getName().resolveBinding();
      if (methodBinding != null
          && "void".equals(methodBinding.getReturnType().getName())) { //$NON-NLS-1$
        pop = false;
      }
    } else if (expression instanceof VariableDeclarationExpression) {
      pop = false;
    }
View Full Code Here

    if (node.getAnonymousClassDeclaration() != null) {
      setHasError(true);
      addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Anonymous_type_declaration_cannot_be_used_in_an_evaluation_expression_7);
    }

    IMethodBinding methodBinding = node.resolveConstructorBinding();
    if (methodBinding == null) {
      setHasError(true);
      addErrorMessage(MessageFormat.format(
          EvaluationEngineMessages.ASTInstructionCompiler_1,
          new Object[] { node.toString() }));
      return false;
    }
    ITypeBinding typeBinding = methodBinding.getDeclaringClass();

    boolean isInstanceMemberType = typeBinding.isMember()
        && !Modifier.isStatic(typeBinding.getModifiers());

    if (isALocalType(typeBinding)) {
      setHasError(true);
      addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Constructor_of_a_local_type_cannot_be_used_in_an_evaluation_expression_8);
    }

    if (containsALocalType(methodBinding)) {
      setHasError(true);
      addErrorMessage(EvaluationEngineMessages.ASTInstructionCompiler_Constructor_which_contains_a_local_type_as_parameter_cannot_be_used_in_an_evaluation_expression_30);
    }

    if (hasErrors()) {
      return false;
    }

    int paramCount = methodBinding.getParameterTypes().length;

    String enclosingTypeSignature = null;
    ITypeBinding enclosingTypeBinding = null;
    if (isInstanceMemberType) {
      enclosingTypeBinding = typeBinding.getDeclaringClass();
View Full Code Here

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

    IMethodBinding methodBinding = (IMethodBinding) node.getName().resolveBinding();
    if (methodBinding == null) {
      // could be the receiver is not visible - for example a private
      // field access from super class
      ASTNode root = node.getRoot();
      if (root instanceof CompilationUnit) {
        CompilationUnit cu = (CompilationUnit) root;
        IProblem[] problems = cu.getProblems();
        for (IProblem problem : problems) {
          setHasError(true);
          addErrorMessage(problem.getMessage());
        }
      }
    }

    if (hasErrors()) {
      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;
    }

    int paramCount = methodBinding.getParameterTypes().length;
    String selector = methodBinding.getName();

    String signature = getMethodSignature(methodBinding, null).replace('.',
        '/');

    boolean isStatic = Flags.isStatic(methodBinding.getModifiers());
    Expression expression = node.getExpression();

    if (isStatic) {
      String typeName = getTypeName(methodBinding.getDeclaringClass());
      push(new SendStaticMessage(typeName, selector, signature,
          paramCount, fCounter));
      if (expression != null) {
        node.getExpression().accept(this);
        addPopInstruction();
      }
    } else {
      push(new SendMessage(selector, signature, paramCount, null,
          fCounter));
      if (expression == null) {
        push(new PushThis(getEnclosingLevel(node,
            methodBinding.getDeclaringClass())));
        storeInstruction();
      } else {
        node.getExpression().accept(this);
      }
    }
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.