Examples of ProblemFieldBinding


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

    return null;
  if (receiverType.isArrayType()) {
    TypeBinding leafType = receiverType.leafComponentType();
    if (leafType instanceof ReferenceBinding)
    if (!((ReferenceBinding)leafType).canBeSeenBy(this)) {
      return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
    }
    if (CharOperation.equals(fieldName, LENGTH))
      return ArrayBinding.ArrayLength;
    return null;
  }

  ReferenceBinding currentType = (ReferenceBinding) receiverType;
  if (!currentType.canBeSeenBy(this))
    return new ProblemFieldBinding(currentType, fieldName, ProblemReasons.ReceiverTypeNotVisible);

  FieldBinding field = currentType.getField(fieldName, true /*resolve*/);
  if (field != null) {
    if (canBeSeenByForCodeSnippet(field, currentType, invocationSite, this))
      return field;
    else
      return new ProblemFieldBinding(field /* closest match*/, field.declaringClass, fieldName, ProblemReasons.NotVisible);
  }

  // collect all superinterfaces of receiverType until the field is found in a supertype
  ReferenceBinding[][] interfacesToVisit = null;
  int lastPosition = -1;
  FieldBinding visibleField = null;
  boolean keepLooking = true;
  boolean notVisible = false; // we could hold onto the not visible field for extra error reporting
  while (keepLooking) {
    ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
    if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
      if (interfacesToVisit == null)
        interfacesToVisit = new ReferenceBinding[5][];
      if (++lastPosition == interfacesToVisit.length)
        System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
      interfacesToVisit[lastPosition] = itsInterfaces;
    }
    if ((currentType = currentType.superclass()) == null)
      break;

    if ((field = currentType.getField(fieldName, true /*resolve*/)) != null) {
      keepLooking = false;
      if (canBeSeenByForCodeSnippet(field, receiverType, invocationSite, this)) {
        if (visibleField == null)
          visibleField = field;
        else
          return new ProblemFieldBinding(visibleField, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous);
      } else {
        notVisible = true;
      }
    }
  }

  // walk all visible interfaces to find ambiguous references
  if (interfacesToVisit != null) {
    ProblemFieldBinding ambiguous = null;
    org.aspectj.org.eclipse.jdt.internal.compiler.util.SimpleSet interfacesSeen = new org.aspectj.org.eclipse.jdt.internal.compiler.util.SimpleSet(lastPosition * 2);
    done : for (int i = 0; i <= lastPosition; i++) {
      ReferenceBinding[] interfaces = interfacesToVisit[i];
      for (int j = 0, length = interfaces.length; j < length; j++) {
        ReferenceBinding anInterface = interfaces[j];
        if (interfacesSeen.addIfNotIncluded(anInterface) == anInterface) {
          // if interface as not already been visited
          if ((field = anInterface.getField(fieldName, true /*resolve*/)) != null) {
            if (visibleField == null) {
              visibleField = field;
            } else {
              ambiguous = new ProblemFieldBinding(visibleField, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous);
              break done;
            }
          } else {
            ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
            if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
              if (++lastPosition == interfacesToVisit.length)
                System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
              interfacesToVisit[lastPosition] = itsInterfaces;
            }
          }
        }
      }
    }
    if (ambiguous != null) return ambiguous;
  }

  if (visibleField != null)
    return visibleField;
  if (notVisible)
    return new ProblemFieldBinding(currentType, fieldName, ProblemReasons.NotVisible);
  return null;
}
View Full Code Here

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

    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()) {
      return new ProblemFieldBinding(
          field,
          field.declaringClass,
          CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'),
          ProblemReasons.NonStaticReferenceInStaticContext);
    }
View Full Code Here

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

*/

public FieldBinding getFieldForCodeSnippet(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) {
  FieldBinding field = findFieldForCodeSnippet(receiverType, fieldName, invocationSite);
  if (field == null)
    return new ProblemFieldBinding(receiverType instanceof ReferenceBinding ? (ReferenceBinding) receiverType : null, fieldName, ProblemReasons.NotFound);
  else
    return field;
}
View Full Code Here

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

        } else {
          /*
           * http://dev.eclipse.org/bugs/show_bug.cgi?id=24449
           */
          if (variableBinding instanceof ProblemFieldBinding) {
            ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) variableBinding;
            switch(problemFieldBinding.problemId()) {
              case ProblemReasons.NotVisible :
              case ProblemReasons.NonStaticReferenceInStaticContext :
              case ProblemReasons.NonStaticReferenceInConstructorInvocation :
                ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
                FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.name, true /*resolve*/);
 
View Full Code Here

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

       } else {
        /*
         * http://dev.eclipse.org/bugs/show_bug.cgi?id=24449
         */
        if (variableBinding instanceof ProblemFieldBinding) {
          ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) variableBinding;
          switch(problemFieldBinding.problemId()) {
            case ProblemReasons.NotVisible :
            case ProblemReasons.NonStaticReferenceInStaticContext :
            case ProblemReasons.NonStaticReferenceInConstructorInvocation :
              ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
              FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.name, true /*resolve*/);
 
View Full Code Here

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

          Binding binding = qualifiedNameReference.binding;
          if (binding != null) {
            if (binding.isValidBinding()) {
              return this.getVariableBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.VariableBinding) binding);
            } else  if (binding instanceof ProblemFieldBinding) {
              ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) binding;
              switch(problemFieldBinding.problemId()) {
                case ProblemReasons.NotVisible :
                case ProblemReasons.NonStaticReferenceInStaticContext :
                  ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
                  if (declaringClass != null) {
                    FieldBinding exactBinding = declaringClass.getField(tokens[tokens.length - 1], true /*resolve*/);
                    if (exactBinding != null) {
                      if (exactBinding.type != null) {
                        IVariableBinding variableBinding = (IVariableBinding) this.bindingTables.compilerBindingsToASTBindings.get(exactBinding);
                        if (variableBinding != null) {
                          return variableBinding;
                        }
                        variableBinding = new VariableBinding(this, exactBinding);
                        this.bindingTables.compilerBindingsToASTBindings.put(exactBinding, variableBinding);
                        return variableBinding;
                      }
                    }
                  }
                  break;
              }
            }
          }
        }
      } else {
        /* This is the case for a name which is part of a qualified name that
         * cannot be resolved. See PR 13063.
         */
        if (qualifiedNameReference.otherBindings == null || (index - indexOfFirstFieldBinding - 1) < 0) {
          return null;
        } else {
          return this.getVariableBinding(qualifiedNameReference.otherBindings[index - indexOfFirstFieldBinding - 1]);
        }
      }
    } else if (node instanceof QualifiedTypeReference) {
      QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) node;
      if (qualifiedTypeReference.resolvedType == null) {
        return null;
      }
      if (index == qualifiedTypeReference.tokens.length) {
        if (!qualifiedTypeReference.resolvedType.isValidBinding() && qualifiedTypeReference instanceof JavadocQualifiedTypeReference) {
          JavadocQualifiedTypeReference typeRef = (JavadocQualifiedTypeReference) node;
          if (typeRef.packageBinding != null) {
            return getPackageBinding(typeRef.packageBinding);
          }
        }
        return this.getTypeBinding(qualifiedTypeReference.resolvedType.leafComponentType());
      } else {
        if (index >= 0) {
          BlockScope internalScope = (BlockScope) this.astNodesToBlockScope.get(name);
          Binding binding = null;
          try {
            if (internalScope == null) {
              if (this.scope == null) return null;
              binding = this.scope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, index));
            } else {
              binding = internalScope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, index));
            }
          } catch (AbortCompilation e) {
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
          }
          if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
            return this.getPackageBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
          } else if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
            // it is a type
            return this.getTypeBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
          } else {
            return null;
          }
        }
      }
    } else if (node instanceof ImportReference) {
      ImportReference importReference = (ImportReference) node;
      int importReferenceLength = importReference.tokens.length;
      if (index >= 0) {
        Binding binding = null;
        if (this.scope == null) return null;
        if (importReferenceLength == index) {
          try {
            binding = this.scope.getImport(CharOperation.subarray(importReference.tokens, 0, index), (importReference.bits & org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode.OnDemand) != 0, importReference.isStatic());
          } catch (AbortCompilation e) {
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
          }
        } else {
          try {
            binding = this.scope.getImport(CharOperation.subarray(importReference.tokens, 0, index), true, importReference.isStatic());
          } catch (AbortCompilation e) {
            // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
          }
        }
        if (binding != null) {
          if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
            return this.getPackageBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
          } else if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
            // it is a type
            return this.getTypeBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
          } else if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding) {
            // it is a type
            return this.getVariableBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding)binding);
          } else if (binding instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding) {
            // it is a type
            return this.getMethodBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding)binding);
          } else {
            return null;
          }
        }
      }
    } else if (node instanceof CompilationUnitDeclaration) {
      CompilationUnitDeclaration compilationUnitDeclaration = (CompilationUnitDeclaration) node;
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
      if (types == null || types.length == 0) {
        return null;
      }
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration type = types[0];
      if (type != null) {
        ITypeBinding typeBinding = this.getTypeBinding(type.binding);
        if (typeBinding != null) {
          return typeBinding.getPackage();
        }
      }
    } else if (node instanceof AbstractMethodDeclaration) {
      AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) node;
      IMethodBinding methodBinding = this.getMethodBinding(methodDeclaration.binding);
      if (methodBinding != null) {
        return methodBinding;
      }
    } else if (node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node;
      ITypeBinding typeBinding = this.getTypeBinding(typeDeclaration.binding);
      if (typeBinding != null) {
        return typeBinding;
      }
    } if (node instanceof SingleNameReference) {
      SingleNameReference singleNameReference = (SingleNameReference) node;
      if (singleNameReference.isTypeReference()) {
        return this.getTypeBinding(singleNameReference.resolvedType);
      } else {
        // this is a variable or a field
        Binding binding = singleNameReference.binding;
        if (binding != null) {
          if (binding.isValidBinding()) {
            return this.getVariableBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.VariableBinding) binding);
          } else {
            /*
             * http://dev.eclipse.org/bugs/show_bug.cgi?id=24449
             */
            if (binding instanceof ProblemFieldBinding) {
              ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) binding;
              switch(problemFieldBinding.problemId()) {
                case ProblemReasons.NotVisible :
                case ProblemReasons.NonStaticReferenceInStaticContext :
                case ProblemReasons.NonStaticReferenceInConstructorInvocation :
                  ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
                  FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.name, true /*resolve*/);
 
View Full Code Here

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

      if (!retField.canBeSeenBy(sourceTypeBinding, site, scope)) {
        return field;
      }
    }
    // XXX need dominates check on aspects
    return new ProblemFieldBinding(retField.declaringClass, retField.name, IProblem.AmbiguousField);// ProblemReporter.Ambiguous);
  }
View Full Code Here

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

    if (site != null) {
      if (!field.canBeSeenBy(sourceTypeBinding, site, scope)) return retField;
      if (!retField.canBeSeenBy(sourceTypeBinding, site, scope)) return field;
    }
    //XXX need dominates check on aspects
    return new ProblemFieldBinding(retField.declaringClass, retField.name, ProblemReporter.Ambiguous);
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding

    return null;
  if (receiverType.isArrayType()) {
    TypeBinding leafType = receiverType.leafComponentType();
    if (leafType instanceof ReferenceBinding)
    if (!((ReferenceBinding)leafType).canBeSeenBy(this)) {
      return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
    }
    if (CharOperation.equals(fieldName, TypeConstants.LENGTH))
      return ArrayBinding.ArrayLength;
    return null;
  }

  ReferenceBinding currentType = (ReferenceBinding) receiverType;
  if (!currentType.canBeSeenBy(this))
    return new ProblemFieldBinding(currentType, fieldName, ProblemReasons.ReceiverTypeNotVisible);

  FieldBinding field = currentType.getField(fieldName, true /*resolve*/);
  if (field != null) {
    if (canBeSeenByForCodeSnippet(field, currentType, invocationSite, this))
      return field;
    else
      return new ProblemFieldBinding(field /* closest match*/, field.declaringClass, fieldName, ProblemReasons.NotVisible);
  }

  // collect all superinterfaces of receiverType until the field is found in a supertype
  ReferenceBinding[][] interfacesToVisit = null;
  int lastPosition = -1;
  FieldBinding visibleField = null;
  boolean keepLooking = true;
  boolean notVisible = false; // we could hold onto the not visible field for extra error reporting
  while (keepLooking) {
    ReferenceBinding[] itsInterfaces = currentType.superInterfaces();
    if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
      if (interfacesToVisit == null)
        interfacesToVisit = new ReferenceBinding[5][];
      if (++lastPosition == interfacesToVisit.length)
        System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
      interfacesToVisit[lastPosition] = itsInterfaces;
    }
    if ((currentType = currentType.superclass()) == null)
      break;

    if ((field = currentType.getField(fieldName, true /*resolve*/)) != null) {
      keepLooking = false;
      if (canBeSeenByForCodeSnippet(field, receiverType, invocationSite, this)) {
        if (visibleField == null)
          visibleField = field;
        else
          return new ProblemFieldBinding(visibleField, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous);
      } else {
        notVisible = true;
      }
    }
  }

  // walk all visible interfaces to find ambiguous references
  if (interfacesToVisit != null) {
    ProblemFieldBinding ambiguous = null;
    org.eclipse.jdt.internal.compiler.util.SimpleSet interfacesSeen = new org.eclipse.jdt.internal.compiler.util.SimpleSet(lastPosition * 2);
    done : for (int i = 0; i <= lastPosition; i++) {
      ReferenceBinding[] interfaces = interfacesToVisit[i];
      for (int j = 0, length = interfaces.length; j < length; j++) {
        ReferenceBinding anInterface = interfaces[j];
        if (interfacesSeen.addIfNotIncluded(anInterface) == anInterface) {
          // if interface as not already been visited
          if ((field = anInterface.getField(fieldName, true /*resolve*/)) != null) {
            if (visibleField == null) {
              visibleField = field;
            } else {
              ambiguous = new ProblemFieldBinding(visibleField, visibleField.declaringClass, fieldName, ProblemReasons.Ambiguous);
              break done;
            }
          } else {
            ReferenceBinding[] itsInterfaces = anInterface.superInterfaces();
            if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
              if (++lastPosition == interfacesToVisit.length)
                System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[lastPosition * 2][], 0, lastPosition);
              interfacesToVisit[lastPosition] = itsInterfaces;
            }
          }
        }
      }
    }
    if (ambiguous != null) return ambiguous;
  }

  if (visibleField != null)
    return visibleField;
  if (notVisible)
    return new ProblemFieldBinding(currentType, fieldName, ProblemReasons.NotVisible);
  return null;
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding

    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)((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()) {
      return new ProblemFieldBinding(
          field,
          field.declaringClass,
          CharOperation.concatWith(CharOperation.subarray(compoundName, 0, currentIndex), '.'),
          ProblemReasons.NonStaticReferenceInStaticContext);
    }
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.