Examples of AbstractMethodDeclaration


Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

    for (int i = 0, length = this.methods.length; i < length; i++) {
      MethodBinding method = resolvedMethods[i];
      if (method == null)
        continue;
      char[] selector = method.selector;
      AbstractMethodDeclaration methodDecl = null;
      nextSibling: for (int j = i + 1; j < length; j++) {
        MethodBinding method2 = resolvedMethods[j];
        if (method2 == null)
          continue nextSibling;
        if (!CharOperation.equals(selector, method2.selector))
          break nextSibling; // methods with same selector are contiguous

        if (complyTo15 && method.returnType != null && method2.returnType != null) {
          // 8.4.2, for collision to be detected between m1 and m2:
          // signature(m1) == signature(m2) i.e. same arity, same type parameter count, can be substituted
          // signature(m1) == erasure(signature(m2)) or erasure(signature(m1)) == signature(m2)
          TypeBinding[] params1 = method.parameters;
          TypeBinding[] params2 = method2.parameters;
          int pLength = params1.length;
          if (pLength != params2.length)
            continue nextSibling;

          TypeVariableBinding[] vars = method.typeVariables;
          TypeVariableBinding[] vars2 = method2.typeVariables;
          boolean equalTypeVars = vars == vars2;
          MethodBinding subMethod = method2;
          if (!equalTypeVars) {
            MethodBinding temp = method.computeSubstitutedMethod(method2, this.scope.environment());
            if (temp != null) {
              equalTypeVars = true;
              subMethod = temp;
            }
          }
          boolean equalParams = method.areParametersEqual(subMethod);
          if (equalParams && equalTypeVars) {
            // duplicates regardless of return types
          } else if (method.returnType.erasure() == subMethod.returnType.erasure() && (equalParams || method.areParameterErasuresEqual(method2))) {
            // name clash for sure if not duplicates, report as duplicates
          } else if (!equalTypeVars && vars != Binding.NO_TYPE_VARIABLES && vars2 != Binding.NO_TYPE_VARIABLES) {
            // type variables are different so we can distinguish between methods
            continue nextSibling;
          } else if (pLength > 0) {
            // check to see if the erasure of either method is equal to the other
            int index = pLength;
            for (; --index >= 0;) {
              if (params1[index] != params2[index].erasure())
                break;
              if (params1[index] == params2[index]) {
                TypeBinding type = params1[index].leafComponentType();
                if (type instanceof SourceTypeBinding && type.typeVariables() != Binding.NO_TYPE_VARIABLES) {
                  index = pLength; // handle comparing identical source types like X<T>... its erasure is itself BUT we need to answer false
                  break;
                }
              }
            }
            if (index >= 0 && index < pLength) {
              for (index = pLength; --index >= 0;)
                if (params1[index].erasure() != params2[index])
                  break;
            }
            if (index >= 0)
              continue nextSibling;
          }
        } else if (!method.areParametersEqual(method2)) { // prior to 1.5, parameter identity meant a collision case
          continue nextSibling;
        }
        boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector,TypeConstants.VALUEOF) || CharOperation.equals(selector,TypeConstants.VALUES));
        // report duplicate
        if (methodDecl == null) {
          methodDecl = method.sourceMethod(); // cannot be retrieved after binding is lost & may still be null if method is special
          if (methodDecl != null && methodDecl.binding != null) { // ensure its a valid user defined method
            if (isEnumSpecialMethod) {
              this.scope.problemReporter().duplicateEnumSpecialMethod(this, methodDecl);
            } else {
              this.scope.problemReporter().duplicateMethodInType(this, methodDecl, method.areParametersEqual(method2));
            }
            methodDecl.binding = null;
            // do not alter original method array until resolution is over, due to reentrance (143259)
            if (resolvedMethods == this.methods) {
              System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length);
            }              
            resolvedMethods[i] = null;
            failed++;
          }
        }
        AbstractMethodDeclaration method2Decl = method2.sourceMethod();
        if (method2Decl != null && method2Decl.binding != null) { // ensure its a valid user defined method
          if (isEnumSpecialMethod) {
            this.scope.problemReporter().duplicateEnumSpecialMethod(this, method2Decl);
          } else {
            this.scope.problemReporter().duplicateMethodInType(this, method2Decl, method.areParametersEqual(method2));
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

  if (isViewedAsDeprecated() && !method.isDeprecated())
    method.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly;
  if (hasRestrictedAccess())
    method.modifiers |= ExtraCompilerModifiers.AccRestrictedAccess;

  AbstractMethodDeclaration methodDecl = method.sourceMethod();
  if (methodDecl == null) return null; // method could not be resolved in previous iteration

  TypeParameter[] typeParameters = methodDecl.typeParameters();
  if (typeParameters != null) {
    methodDecl.scope.connectTypeVariables(typeParameters, true);
    // Perform deferred bound checks for type variables (only done after type variable hierarchy is connected)
    for (int i = 0, paramLength = typeParameters.length; i < paramLength; i++)
      typeParameters[i].checkBounds(methodDecl.scope);
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

    TypeDeclaration jdtType = findType(cud, type.getQualifiedBinaryName());
    if (jdtType == null) {
      // TODO(jat): any thing else to do here?
      return null;
    }
    AbstractMethodDeclaration jdtMethod = findMethod(jdtType, method);
    if (jdtMethod == null) {
      // TODO(jat): any thing else to do here?
      return null;
    }
    int n = jdtMethod.arguments.length;
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

          // init
          assert (enclosingType instanceof JClassType);
          method = enclosingType.getMethods().get(1);
        }
      } else {
        AbstractMethodDeclaration referenceMethod = methodScope.referenceMethod();
        method = (JMethod) typeMap.get(referenceMethod.binding);
      }
      assert !method.isNative() && !method.isAbstract();
      return (JMethodBody) method.getBody();
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

  private boolean resolveMethods(TreeLogger logger, JClassType type,
      AbstractMethodDeclaration[] jmethods) {
    if (jmethods != null) {
      for (int i = 0; i < jmethods.length; i++) {
        AbstractMethodDeclaration jmethod = jmethods[i];
        if (!resolveMethod(logger, type, jmethod)) {
          return false;
        }
      }
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

          // init
          assert (enclosingType instanceof JClassType);
          method = enclosingType.getMethods().get(1);
        }
      } else {
        AbstractMethodDeclaration referenceMethod = methodScope.referenceMethod();
        method = (JMethod) typeMap.get(referenceMethod.binding);
      }
      assert !method.isNative() && !method.isAbstract();
      return (JMethodBody) method.getBody();
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

    priority += P_ERROR;
  }
  ReferenceContext context = this.problemsMap == null ? null : (ReferenceContext) this.problemsMap.get(problem);
  if (context != null){
    if (context instanceof AbstractMethodDeclaration){
      AbstractMethodDeclaration method = (AbstractMethodDeclaration) context;
      if (method.isStatic()) {
        priority += P_STATIC;
      }
    } else {
      priority += P_OUTSIDE_METHOD;
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

    TypeBinding assignableTypeBinding = null;

    TypeVariableBinding[] typeVariables = Binding.NO_TYPE_VARIABLES;
    ReferenceContext referenceContext = scope.referenceContext();
    if (referenceContext instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) referenceContext;
      TypeParameter[] typeParameters = methodDeclaration.typeParameters();
      if (typeParameters != null && typeParameters.length > 0) {
        int length = typeParameters.length;
        int count = 0;
        typeVariables = new TypeVariableBinding[length];
        for (int i = 0; i < length; i++) {
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

      && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
    id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
  } else {
    id = IProblem.IncompatibleReturnType;
  }
  AbstractMethodDeclaration method = currentMethod.sourceMethod();
  int sourceStart = 0;
  int sourceEnd = 0;
  if (method == null) {
    if (declaringClass instanceof SourceTypeBinding) {
      SourceTypeBinding sourceTypeBinding = (SourceTypeBinding) declaringClass;
      sourceStart = sourceTypeBinding.sourceStart();
      sourceEnd = sourceTypeBinding.sourceEnd();
    }
  } else if (method.isConstructor()){
    sourceStart = method.sourceStart;
    sourceEnd = method.sourceEnd;
  } else {
    TypeReference returnType = ((MethodDeclaration) method).returnType;
    sourceStart = returnType.sourceStart;
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration

   * @see org.eclipse.jdt.core.dom.BindingResolver#resolveMember(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration)
   */
  IMethodBinding resolveMember(AnnotationTypeMemberDeclaration declaration) {
    Object oldNode = this.newAstToOldAst.get(declaration);
    if (oldNode instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) oldNode;
      IMethodBinding methodBinding = getMethodBinding(methodDeclaration.binding);
      if (methodBinding == null) {
        return null;
      }
      this.bindingsToAstNodes.put(methodBinding, declaration);
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.