Package org.eclipse.jdt.core.dom

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


  }

  private IMethodBinding findParentConstructor(
      CompilationUnit cu, ITypeBinding typeBinding, IVariableBinding[] variables)
  {
    IMethodBinding constructor = null;
    if (typeBinding.isEnum() || variables.length != 0) {
      ITypeBinding binding = cu.getAST().resolveWellKnownType("java.lang.Object");
      constructor = Bindings.findMethodInType(
          binding, "Object", new ITypeBinding[0]);
    } else {
View Full Code Here


    if (tb.isArray() || tb.isInterface() || tb.isAnnotation()) {
      return false;
    }

    if (tb.isLocal()) {
      IMethodBinding mb = tb.getDeclaringMethod();
      if (mb == null) {
        // Could be https://bugs.eclipse.org/bugs/show_bug.cgi?id=383486
        IJavaElement je = tb.getJavaElement();

        try {
View Full Code Here

    }
  }

  @Override
  public boolean visit(MethodDeclaration node) {
    IMethodBinding mb = node.resolveBinding();
    if (TransformUtil.baseDeclared(ctx, type, mb)) {
      return false;
    }

    impl.method(mb);
View Full Code Here

    }
  }

  @Override
  public boolean visit(MethodInvocation node) {
    IMethodBinding b = node.resolveMethodBinding();
    ITypeBinding rtb = b.getMethodDeclaration().getReturnType();
    boolean erased = (rtb.isTypeVariable() || rtb.isArray()
        && rtb.getElementType().isTypeVariable())
        && !(node.getParent() instanceof ExpressionStatement);

    if (erased) {
      javaCast(rtb.getErasure(), b.getReturnType());
    } else {
      ITypeBinding actualRt = TransformUtil.returnType(b
          .getMethodDeclaration().getDeclaringClass(), b
          .getMethodDeclaration());
      if (!actualRt.isEqualTo(rtb.getErasure())) {
        javaCast(actualRt, rtb);
        erased = true;
      }
    }

    Expression expr = node.getExpression();
    if (expr != null) {
      ITypeBinding etb = expr.resolveTypeBinding().getErasure();
      boolean isType = expr instanceof Name
          && ((Name) expr).resolveBinding() instanceof ITypeBinding;

      int parens = 0;

      if (!isType && hidden(etb, b)) {
        // Method hidden by method in subclass
        assert (!TransformUtil.isStatic(b));
        staticCast(etb, b.getDeclaringClass());
        parens++;
      }

      if (TransformUtil.needsJavaCast(etb, b.getDeclaringClass())) {
        javaCast(etb, b.getDeclaringClass());
        parens++;
      }

      if (!isType) {
        npcAccept(expr);
      } else {
        expr.accept(this);
      }

      for (int i = 0; i < parens; ++i) {
        print(")");
      }

      if (isType) {
        print("::");
      } else {
        print("->");
      }

      hardDep(etb);
    } else {
      String bname = CName.of(b);
      boolean found = localInScope(bname);

      if (!b.getDeclaringClass().isEqualTo(type)) {
        for (IVariableBinding vb : type.getDeclaredFields()) {
          if (bname.equals(CName.of(vb))) {
            found = true;
          }
        }
      }

      // If the name is already qualified, there won't be a clash
      if (found
          && !needsQualification(node.getName(),
              b.getDeclaringClass())) {
        if (TransformUtil.isStatic(b)) {
          print(CName.of(b.getDeclaringClass()) + "::");
        } else {
          boolean cast = !b.getDeclaringClass().isEqualTo(type);
          if (cast) {
            staticCast(type, b.getDeclaringClass());
          }

          print("this");

          if (cast) {
View Full Code Here

    return false;
  }

  @Override
  public boolean visit(SuperMethodInvocation node) {
    IMethodBinding b = node.resolveMethodBinding();
    boolean erased = TransformUtil.returnErased(b);

    if (erased) {
      javaCast(b.getMethodDeclaration().getReturnType().getErasure(),
          b.getReturnType());
    }

    // Qualification is handled in TransformWriter.visit(SimpleName)
    print(TransformUtil.typeArguments(node.typeArguments()));
View Full Code Here

  public boolean visit(MethodDeclaration node) {
    if (node.getJavadoc() != null) {
      node.getJavadoc().accept(this);
    }

    IMethodBinding mb = node.resolveBinding();
    if (TransformUtil.baseDeclared(ctx, type, mb)) {
      // Defining once more will lead to virtual inheritance issues
      printi("/*");
      TransformUtil.printSignature(ctx, out, type, mb, deps, false);
      println("; (already declared) */");
 
View Full Code Here

    // private methods mess up using statements that import methods
    // from base classes
    name = CName.keywords(mb.getName());

    IMethodBinding lastOverride = couldOverrideDefault(mb);
    if (lastOverride != null) {
      name = of(lastOverride.getDeclaringClass()) + "_" + name;
    }

    // Methods can have the same name as the constructor without being a
    // constructor!
    while (!mb.isConstructor() && hasName(mb.getDeclaringClass(), name)) {
View Full Code Here

   * nothing of the sort so we have to rename the non-overriding method
   */
  private static IMethodBinding couldOverrideDefault(IMethodBinding mb) {
    ITypeBinding tb = mb.getDeclaringClass();
    if (tb != null) {
      IMethodBinding last = mb;
      for (ITypeBinding tbx = tb.getSuperclass(); tbx != null; tbx = tbx
          .getSuperclass()) {
        boolean samePackage = samePackage(tb, tbx);

        for (IMethodBinding mbx : tbx.getDeclaredMethods()) {
          if (!samePackage
              && TransformUtil.isDefault(mbx.getModifiers())
              && mbx.getName().equals(mb.getName())
              && TransformUtil.sameParameters(mb, mbx, true)) {
            return last;
          }

          if (last.overrides(mbx)) {
            // This will give the final name of the method
            last = mbx;
          }
        }
      }
View Full Code Here

    if (node.arguments().size() != 1
        || !(node.arguments().get(0) instanceof TypeLiteral)) {
      return false;
    }

    IMethodBinding mb = node.resolveMethodBinding();
    if (!mb.getDeclaringClass().getQualifiedName()
        .equals("sun.misc.Unsafe")) {
      return false;
    }

    TypeLiteral tl = (TypeLiteral) node.arguments().get(0);
View Full Code Here

      return;
    }

    List<IMethodBinding> missing = Header.baseCallMethods(type);
    for (IMethodBinding decl : missing) {
      IMethodBinding impl = Header.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

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.