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

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


public void aboutToResolve(Scope scope) {
  getTypeBinding(scope.parent); // step up from the ClassScope
}
protected TypeBinding getTypeBinding(Scope scope) {
  // it can be a package, type or member type
  Binding binding = scope.getTypeOrPackage(tokens);
  if (!binding.isValidBinding()) {
      // tolerate some error cases
      if (binding.problemId() == ProblemReasons.NotVisible){
        throw new SelectionNodeFound(binding);
      }
    scope.problemReporter().invalidType(this, (TypeBinding) binding);
    throw new SelectionNodeFound();
  }
View Full Code Here


public void aboutToResolve(Scope scope) {
  getTypeBinding(scope.parent); // step up from the ClassScope
}
protected TypeBinding getTypeBinding(Scope scope) {
  // it can be a package, type or member type
  Binding binding = scope.getTypeOrPackage(new char[][] {token});
  if (!binding.isValidBinding()) {
    scope.problemReporter().invalidType(this, (TypeBinding) binding);
    throw new SelectionNodeFound();
  }
  throw new SelectionNodeFound(binding);
}
View Full Code Here

   
    for (int i = 0; i < length; i++) {
      TypeReference substituedType = substituedTypeNodes[i];
      if (substituedType.resolvedType == null) return false;
      ReferenceBinding erasure = (ReferenceBinding)substituedType.resolvedType.leafComponentType().erasure();
      Binding missingElement;
      int depthToRemove = originalTypeNames[i].length - 1 ;
      if (depthToRemove == 0) {
        missingElement = erasure;
      } else {
        int depth = erasure.depth() + 1;
View Full Code Here

  }
 
  public TypeBinding resolveType(BlockScope scope) {
    if(type instanceof QualifiedTypeReference) {
      QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) type;
      Binding binding = scope.parent.getTypeOrPackage(qualifiedTypeReference.tokens); // step up from the ClassScope
      if (!binding.isValidBinding()) {
        scope.problemReporter().invalidType(this, (TypeBinding) binding);
        throw new CompletionNodeFound();
      }
      throw new CompletionNodeFound(this, binding, scope);
    }
View Full Code Here

  IMPORTANT NOTE: This method is written under the assumption that compoundName is longer than length 1.
*/

public Binding getBinding(char[][] compoundName, int mask, InvocationSite invocationSite, ReferenceBinding receiverType) {
  Binding binding = getBinding(compoundName[0], mask | Binding.TYPE | Binding.PACKAGE, invocationSite, true /*resolve*/);
  invocationSite.setFieldIndex(1);
  if (!binding.isValidBinding() || binding instanceof VariableBinding)
    return binding;

  int length = compoundName.length;
  int currentIndex = 1;
  foundType: if (binding instanceof PackageBinding) {
    PackageBinding packageBinding = (PackageBinding) binding;

    while (currentIndex < length) {
      binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]);
      invocationSite.setFieldIndex(currentIndex);
       if (binding == null) {
         if (currentIndex == length) // must be a type if its the last name, otherwise we have no idea if its a package or type
          return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), null, ProblemReasons.NotFound);
        else
          return new ProblemBinding(CharOperation.subarray(compoundName, 0, currentIndex), ProblemReasons.NotFound);
       }
       if (binding instanceof ReferenceBinding) {
         if (!binding.isValidBinding())
          return new ProblemReferenceBinding(
                  CharOperation.subarray(compoundName, 0, currentIndex),
                  ((ReferenceBinding)binding).closestMatch(),
                  binding.problemId());
         if (!this.canBeSeenByForCodeSnippet((ReferenceBinding) binding, receiverType))
          return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), (ReferenceBinding) binding, ProblemReasons.NotVisible);
         break foundType;
       }
       packageBinding = (PackageBinding) binding;
    }

    // It is illegal to request a PACKAGE from this method.
    return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, currentIndex), null, ProblemReasons.NotFound);
  }

  // know binding is now a ReferenceBinding
  while (currentIndex < length) {
    ReferenceBinding typeBinding = (ReferenceBinding) binding;
    char[] nextName = compoundName[currentIndex++];
    invocationSite.setFieldIndex(currentIndex);
    if ((binding = findFieldForCodeSnippet(typeBinding, nextName, invocationSite)) != null) {
      if (!binding.isValidBinding()) {
        return new ProblemFieldBinding(
            (FieldBinding)binding,
            ((FieldBinding)binding).declaringClass,
            CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'),
            binding.problemId());
      }
      break; // binding is now a field
    }
    if ((binding = findMemberType(nextName, typeBinding)) == null)
      return new ProblemBinding(CharOperation.subarray(compoundName, 0, currentIndex), typeBinding, ProblemReasons.NotFound);
     if (!binding.isValidBinding())
      return new ProblemReferenceBinding(
                CharOperation.subarray(compoundName, 0, currentIndex),
                ((ReferenceBinding)binding).closestMatch(),
                binding.problemId());
  }

  if ((mask & Binding.FIELD) != 0 && (binding instanceof FieldBinding)) { // was looking for a field and found a field
    FieldBinding field = (FieldBinding) binding;
    if (!field.isStatic()) {
View Full Code Here

  }
 
  private void internalResolve(Scope scope, boolean staticContext) {
      // detect variable/type name collisions
    if (this.binding != null) {
      Binding existingType = scope.parent.getBinding(this.name, Binding.TYPE, this, false/*do not resolve hidden field*/);
      if (existingType != null
          && this.binding != existingType
          && existingType.isValidBinding()
          && (existingType.kind() != Binding.TYPE_PARAMETER || !staticContext)) {
        scope.problemReporter().typeHiding(this, existingType);
      }
    }
  }
View Full Code Here

      return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error

    this.resolvedType = getTypeBinding(scope);
    if (!this.resolvedType.isValidBinding()) {
      char[][] tokens = { this.token };
      Binding binding = scope.getTypeOrPackage(tokens);
      if (binding instanceof PackageBinding) {
        this.packageBinding = (PackageBinding) binding;
      } else {
        if (this.resolvedType.problemId() == ProblemReasons.NonStaticReferenceInStaticContext) {
          ReferenceBinding closestMatch = ((ProblemReferenceBinding)this.resolvedType).closestMatch();
View Full Code Here

              Expression currentExpression = expressions[i];
              if (currentExpression instanceof NullLiteral) {
                scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression, true);
              } else if (currentExpression instanceof NameReference) {
                NameReference nameReference = (NameReference) currentExpression;
                final Binding nameReferenceBinding = nameReference.binding;
                if (nameReferenceBinding.kind() == Binding.FIELD) {
                  FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding;
                  if (!fieldBinding.declaringClass.isEnum()) {
                    scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression, true);
                  }
                }
              }
            }
          }
        } else if (this.value instanceof NameReference) {
          NameReference nameReference = (NameReference) this.value;
          final Binding nameReferenceBinding = nameReference.binding;
          if (nameReferenceBinding.kind() == Binding.FIELD) {
            FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding;
            if (!fieldBinding.declaringClass.isEnum()) {
              if (!fieldBinding.type.isArrayType()) {
                scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value, true);
              } else {
View Full Code Here

        Expression expr = ans[i].memberValuePairs()[0].value;
        if (expr instanceof StringLiteral) {
          StringLiteral sLit = ((StringLiteral) expr);
          return new String(sLit.source());
        } else if (expr instanceof NameReference && (((NameReference) expr).binding instanceof FieldBinding)) {
          Binding b = ((NameReference) expr).binding;
          Constant c = ((FieldBinding) b).constant;
          return c.stringValue();
        } else {
          throw new BCException("Do not know how to recover pointcut definition from " + expr + " (type "
              + expr.getClass().getName() + ")");
View Full Code Here

  IBinding createBinding(String key) {
    if (this.bindingTables == null)
      throw new RuntimeException("Cannot be called outside ASTParser#createASTs(...)"); //$NON-NLS-1$
    BindingKeyResolver keyResolver = new BindingKeyResolver(key, this, this.lookupEnvironment);
    Binding compilerBinding = keyResolver.getCompilerBinding();
    if (compilerBinding == null) return null;
    DefaultBindingResolver resolver = new DefaultBindingResolver(this.lookupEnvironment, null/*no owner*/, this.bindingTables, false);
    return resolver.getBinding(compilerBinding);
  }
View Full Code Here

TOP

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

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.