Package org.aspectj.org.eclipse.jdt.internal.compiler.lookup

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding


        break;
      case RAW_ITERABLE :
      case GENERIC_ITERABLE :
        collection.generateCode(scope, codeStream, true);
        // declaringClass.iterator();
        MethodBinding iteratorMethodBinding =
          new MethodBinding(
              ClassFileConstants.AccPublic,
              "iterator".toCharArray(),//$NON-NLS-1$
              scope.getJavaUtilIterator(),
              Binding.NO_PARAMETERS,
              Binding.NO_EXCEPTIONS,
View Full Code Here


public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) {
  if (runtimeTimeType == null || compileTimeType == null)
    return;
  // set the generic cast after the fact, once the type expectation is fully known (no need for strict cast)
  if (this.binding != null && this.binding.isValidBinding()) {
    MethodBinding originalBinding = this.binding.original();
    TypeBinding originalType = originalBinding.returnType;
      // extra cast needed if method return type is type variable
    if (originalBinding != this.binding
        && originalType != this.binding.returnType
        && runtimeTimeType.id != TypeIds.T_JavaLangObject
View Full Code Here

    IPrivilegedHandler iph = Scope.findPrivilegedHandler(currentScope.invocationType());
    if (iph != null) {
      // ??? Should getPriviligedAccessMethod() provide a flag to indicate
      // if you *want* to build a new accessor or if you just want to see if
      // one already exists?
      MethodBinding privAccessor = iph.getPrivilegedAccessMethod(binding,null);
      syntheticAccessor = privAccessor;
      return;
    }
    // End AspectJ extension
   
View Full Code Here

        this.binding =
          this.receiver.isImplicitThis()
            ? scope.getImplicitMethod(this.selector, pseudoArgs, this)
            : scope.findMethod((ReferenceBinding) this.actualReceiverType, this.selector, pseudoArgs, this);
        if (this.binding != null && !this.binding.isValidBinding()) {
          MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
          // record the closest match, for clients who may still need hint about possible method match
          if (closestMatch != null) {
            if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method
              // shouldn't return generic method outside its context, rather convert it to raw method (175409)
              closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding)null);
            }
            this.binding = closestMatch;
            MethodBinding closestMatchOriginal = closestMatch.original();
            if ((closestMatchOriginal.isPrivate() || closestMatchOriginal.declaringClass.isLocalType()) && !scope.isDefinedInMethod(closestMatchOriginal)) {
              // ignore cases where method is used from within inside itself (e.g. direct recursions)
              closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
            }
          }
        }
      }
      return null;
    }
  }
  if (this.actualReceiverType == null) {
    return null;
  }
  // base type cannot receive any message
  if (this.actualReceiverType.isBaseType()) {
    scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, argumentTypes);
    return null;
  }
 
  resolveMethodBinding(scope, argumentTypes); // AspectJ Extension - moved to helper method
   
  if (!this.binding.isValidBinding()) {
    if (this.binding.declaringClass == null) {
      if (this.actualReceiverType instanceof ReferenceBinding) {
        this.binding.declaringClass = (ReferenceBinding) this.actualReceiverType;
      } else {
        scope.problemReporter().errorNoMethodFor(this, this.actualReceiverType, argumentTypes);
        return null;
      }
    }
    scope.problemReporter().invalidMethod(this, this.binding);
    MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
    switch (this.binding.problemId()) {
      case ProblemReasons.Ambiguous :
        break; // no resilience on ambiguous
      case ProblemReasons.NotVisible :
      case ProblemReasons.NonStaticReferenceInConstructorInvocation :
      case ProblemReasons.NonStaticReferenceInStaticContext :
      case ProblemReasons.ReceiverTypeNotVisible :
      case ProblemReasons.ParameterBoundMismatch :
        // only steal returnType in cases listed above
        if (closestMatch != null) this.resolvedType = closestMatch.returnType;
      default :
    }
    // record the closest match, for clients who may still need hint about possible method match
    if (closestMatch != null) {
      this.binding = closestMatch;
      MethodBinding closestMatchOriginal = closestMatch.original();     
      if ((closestMatchOriginal.isPrivate() || closestMatchOriginal.declaringClass.isLocalType()) && !scope.isDefinedInMethod(closestMatchOriginal)) {
        // ignore cases where method is used from within inside itself (e.g. direct recursions)
        closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
      }
    }
    return this.resolvedType;
  }
  final CompilerOptions compilerOptions = scope.compilerOptions();
  if (!this.binding.isStatic()) {
    // the "receiver" must not be a type, in other words, a NameReference that the TC has bound to a Type
    if (receiverIsType) {
      scope.problemReporter().mustUseAStaticMethod(this, this.binding);
      if (this.actualReceiverType.isRawType()
          && (this.receiver.bits & ASTNode.IgnoreRawTypeCheck) == 0
          && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
        scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType);
      }
    } else {
      this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
      // compute generic cast if necessary
      TypeBinding receiverErasure = this.actualReceiverType.erasure();
      if (receiverErasure instanceof ReferenceBinding) {
        if (receiverErasure.findSuperTypeWithSameErasure(this.binding.declaringClass) == null) {
          this.receiverGenericCast = this.binding.declaringClass; // handle indirect inheritance thru variable secondary bound
        }
      }
    }
  } else {
    // static message invoked through receiver? legal but unoptimal (optional warning).
    if (!(this.receiver.isImplicitThis() || this.receiver.isSuper() || receiverIsType)) {
      scope.problemReporter().nonStaticAccessToStaticMethod(this, this.binding);
    }
    if (!this.receiver.isImplicitThis() && this.binding.declaringClass != this.actualReceiverType) {
      scope.problemReporter().indirectAccessToStaticMethod(this, this.binding);
    }   
  }
  checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this);

  //-------message send that are known to fail at compile time-----------
  if (this.binding.isAbstract()) {
    if (this.receiver.isSuper()) {
      scope.problemReporter().cannotDireclyInvokeAbstractMethod(this, this.binding);
    }
    // abstract private methods cannot occur nor abstract static............
  }
  if (isMethodUseDeprecated(this.binding, scope, true))
    scope.problemReporter().deprecatedMethod(this.binding, this);

  // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
  if (this.actualReceiverType.isArrayType()
      && this.binding.parameters == Binding.NO_PARAMETERS
      && compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5
      && CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) {
    this.resolvedType = this.actualReceiverType;
  } else {
    TypeBinding returnType = this.binding.returnType;
    if (returnType != null) returnType = returnType.capture(scope, this.sourceEnd);
    this.resolvedType = returnType;
  }
  if (this.receiver.isSuper() && compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) {
    final ReferenceContext referenceContext = scope.methodScope().referenceContext;
    if (referenceContext instanceof AbstractMethodDeclaration) {
      final AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) referenceContext;
      MethodBinding enclosingMethodBinding = abstractMethodDeclaration.binding;
      if (enclosingMethodBinding.isOverriding()
          && CharOperation.equals(this.binding.selector, enclosingMethodBinding.selector)
          && this.binding.areParametersEqual(enclosingMethodBinding)) {
        abstractMethodDeclaration.bits |= ASTNode.OverridingMethodWithSupercall;
      }
    }
View Full Code Here

        }
        scope.problemReporter().invalidConstructor(this, this.binding);
        return this.resolvedType;
      }
      CodeSnippetScope localScope = new CodeSnippetScope(scope);     
      MethodBinding privateBinding = localScope.getConstructor((ReferenceBinding)this.delegateThis.type, argumentTypes, this);
      if (!privateBinding.isValidBinding()) {
        if (this.binding.declaringClass == null) {
          this.binding.declaringClass = allocatedType;
        }
        scope.problemReporter().invalidConstructor(this, this.binding);
        return this.resolvedType;
View Full Code Here

      // we cannot create problem methods for an interface. So we have to generate a clinit
      // which should contain all the problem
      classFile.addProblemClinit(problemsCopy);
      for (int i = 0, length = methodDecls.length; i < length; i++) {
        AbstractMethodDeclaration methodDecl = methodDecls[i];
        MethodBinding method = methodDecl.binding;
        if (method == null || method.isConstructor()) continue;
        classFile.addAbstractMethod(methodDecl, method);
      }   
    } else {
      for (int i = 0, length = methodDecls.length; i < length; i++) {
        AbstractMethodDeclaration methodDecl = methodDecls[i];
        MethodBinding method = methodDecl.binding;
        if (method == null) continue;
        if (method.isConstructor()) {
          classFile.addProblemConstructor(methodDecl, method, problemsCopy);
        } else {
          classFile.addProblemMethod(methodDecl, method, problemsCopy);
        }
      }
View Full Code Here

  // isDefault()
  return receiverType.fPackage == referenceBinding.fPackage;
}
// Internal use only
public MethodBinding findExactMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
  MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, null);
  if (exactMethod != null){
    if (receiverType.isInterface() || canBeSeenByForCodeSnippet(exactMethod, receiverType, invocationSite, this))
      return exactMethod;
  }
  return null;
View Full Code Here

    return new ProblemFieldBinding(currentType, fieldName, ProblemReasons.NotVisible);
  return null;
}
// Internal use only
public MethodBinding findMethod(ReferenceBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
  MethodBinding methodBinding = super.findMethod(receiverType, selector, argumentTypes, invocationSite);
  if (methodBinding != null && methodBinding.isValidBinding())
    if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
      return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotVisible);
  return methodBinding;
}
View Full Code Here

}

// Internal use only
public MethodBinding findMethodForArray(ArrayBinding receiverType, char[] selector, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
  ReferenceBinding object = getJavaLangObject();
  MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
  if (methodBinding != null) {
    // handle the method clone() specially... cannot be protected or throw exceptions
    if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, CLONE))
      return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, CLONE, methodBinding.returnType, argumentTypes, null, object);
    if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
      return methodBinding;
  }

  // answers closest approximation, may not check argumentTypes or visibility
  methodBinding = findMethod(object, selector, argumentTypes, invocationSite);
  if (methodBinding == null)
    return new ProblemMethodBinding(selector, argumentTypes, ProblemReasons.NotFound);
  if (methodBinding.isValidBinding()) {
      MethodBinding compatibleMethod = computeCompatibleMethod(methodBinding, argumentTypes, invocationSite);
      if (compatibleMethod == null)
      return new ProblemMethodBinding(methodBinding, selector, argumentTypes, ProblemReasons.NotFound);
      methodBinding = compatibleMethod;
    if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
      return new ProblemMethodBinding(methodBinding, selector, methodBinding.parameters, ProblemReasons.NotVisible);
View Full Code Here

  If no visible constructor is discovered, an error binding is answered.
*/

public MethodBinding getConstructor(ReferenceBinding receiverType, TypeBinding[] argumentTypes, InvocationSite invocationSite) {
  MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
  if (methodBinding != null) {
    if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this)) {
      return methodBinding;
    }
  }
  MethodBinding[] methods = receiverType.getMethods(TypeConstants.INIT);
  if (methods == Binding.NO_METHODS) {
    return new ProblemMethodBinding(TypeConstants.INIT, argumentTypes, ProblemReasons.NotFound);
  }
  MethodBinding[] compatible = new MethodBinding[methods.length];
  int compatibleIndex = 0;
  for (int i = 0, length = methods.length; i < length; i++) {
      MethodBinding compatibleMethod = computeCompatibleMethod(methods[i], argumentTypes, invocationSite);
    if (compatibleMethod != null)
      compatible[compatibleIndex++] = compatibleMethod;
  }
  if (compatibleIndex == 0)
    return new ProblemMethodBinding(TypeConstants.INIT, argumentTypes, ProblemReasons.NotFound); // need a more descriptive error... cannot convert from X to Y

  MethodBinding[] visible = new MethodBinding[compatibleIndex];
  int visibleIndex = 0;
  for (int i = 0; i < compatibleIndex; i++) {
    MethodBinding method = compatible[i];
    if (canBeSeenByForCodeSnippet(method, receiverType, invocationSite, this)) {
      visible[visibleIndex++] = method;
    }
  }
  if (visibleIndex == 1) {
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding

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.