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

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


}
public void unusedPrivateType(TypeDeclaration typeDecl) {
  int severity = computeSeverity(IProblem.UnusedPrivateType);
  if (severity == ProblemSeverities.Ignore) return;

  ReferenceBinding type = typeDecl.binding;
  this.handle(
      IProblem.UnusedPrivateType,
    new String[] {
      new String(type.readableName()),
     },
    new String[] {
      new String(type.shortReadableName()),
     },
    severity,
    typeDecl.sourceStart,
    typeDecl.sourceEnd);
}
View Full Code Here


      if ((caughtExceptions = exceptionContext.handledExceptions) != Binding.NO_EXCEPTIONS) {
        boolean definitelyCaught = false;
        for (int caughtIndex = 0, caughtCount = caughtExceptions.length;
          caughtIndex < caughtCount;
          caughtIndex++) {
          ReferenceBinding caughtException = caughtExceptions[caughtIndex];
            int state = caughtException == null
              ? Scope.EQUAL_OR_MORE_SPECIFIC /* any exception */
                : Scope.compareTypes(raisedException, caughtException);
            if (abruptlyExitedLoops != null && caughtException != null && state != Scope.NOT_RELATED) {
              for (int i = 0, abruptlyExitedLoopsCount = abruptlyExitedLoops.size(); i < abruptlyExitedLoopsCount; i++) {
View Full Code Here

      if ((caughtExceptions = exceptionContext.handledExceptions) != Binding.NO_EXCEPTIONS) {
        int caughtCount = caughtExceptions.length;
        boolean[] locallyCaught = new boolean[raisedCount]; // at most

        for (int caughtIndex = 0; caughtIndex < caughtCount; caughtIndex++) {
          ReferenceBinding caughtException = caughtExceptions[caughtIndex];
          for (int raisedIndex = 0; raisedIndex < raisedCount; raisedIndex++) {
            TypeBinding raisedException;
            if ((raisedException = raisedExceptions[raisedIndex]) != null) {
                int state = caughtException == null
                  ? Scope.EQUAL_OR_MORE_SPECIFIC /* any exception */
 
View Full Code Here

    } else {
      // case of method not in the created AST, or a binary method
      org.eclipse.jdt.internal.compiler.lookup.MethodBinding original = methodBinding.original();
      String selector = original.isConstructor() ? declaringType.getElementName() : new String(original.selector);
      boolean isBinary = declaringType.isBinary();
      ReferenceBinding enclosingType = original.declaringClass.enclosingType();
      boolean isInnerBinaryTypeConstructor = isBinary && original.isConstructor() && enclosingType != null;
      TypeBinding[] parameters = original.parameters;
      int length = parameters == null ? 0 : parameters.length;
      int declaringIndex = isInnerBinaryTypeConstructor ? 1 : 0;
      String[] parameterSignatures = new String[declaringIndex + length];
      if (isInnerBinaryTypeConstructor)
        parameterSignatures[0] = new String(enclosingType.genericTypeSignature()).replace('/', '.');
      for (int i = 0;  i < length; i++) {
        char[] signature = parameters[i].genericTypeSignature();
        if (isBinary) {
          signature = CharOperation.replaceOnCopy(signature, '/', '.');
        } else {
View Full Code Here

        return null;
      default :
        if (typeBinding.isCapture())
          return null;
    }
    ReferenceBinding referenceBinding;
    if (typeBinding.isParameterizedType() || typeBinding.isRawType())
      referenceBinding = (ReferenceBinding) typeBinding.erasure();
    else
      referenceBinding = (ReferenceBinding) typeBinding;
    char[] fileName = referenceBinding.getFileName();
    if (referenceBinding.isLocalType() || referenceBinding.isAnonymousType()) {
      // local or anonymous type
      if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(fileName)) {
        int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName);
        int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive
        if (pkgEnd == -1)
          pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName);
        if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator
          pkgEnd = jarSeparator;
        if (pkgEnd == -1)
          return null;
        IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator);
        char[] constantPoolName = referenceBinding.constantPoolName();
        if (constantPoolName == null) {
          ClassFile classFile = (ClassFile) getClassFile(fileName);
          return classFile == null ? null : (JavaElement) classFile.getType();
        }
        pkgEnd = CharOperation.lastIndexOf('/', constantPoolName);
        char[] classFileName = CharOperation.subarray(constantPoolName, pkgEnd+1, constantPoolName.length);
        ClassFile classFile = (ClassFile) pkg.getClassFile(new String(classFileName) + SuffixConstants.SUFFIX_STRING_class);
        return (JavaElement) classFile.getType();
      }
      ICompilationUnit cu = getCompilationUnit(fileName, workingCopyOwner);
      if (cu == null) return null;
      // must use getElementAt(...) as there is no back pointer to the defining method (scope is null after resolution has ended)
      try {
        int sourceStart = ((org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding) referenceBinding).sourceStart;
        return (JavaElement) cu.getElementAt(sourceStart);
      } catch (JavaModelException e) {
        // does not exist
        return null;
      }
    } else if (referenceBinding.isTypeVariable()) {
      // type parameter
      final String typeVariableName = new String(referenceBinding.sourceName());
      org.eclipse.jdt.internal.compiler.lookup.Binding declaringElement = ((org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding) referenceBinding).declaringElement;
      if (declaringElement instanceof MethodBinding) {
        IMethod declaringMethod = (IMethod) getUnresolvedJavaElement((MethodBinding) declaringElement, workingCopyOwner, bindingsToNodes);
        return (JavaElement) declaringMethod.getTypeParameter(typeVariableName);
      } else {
        IType declaringType = (IType) getUnresolvedJavaElement((TypeBinding) declaringElement, workingCopyOwner, bindingsToNodes);
        return (JavaElement) declaringType.getTypeParameter(typeVariableName);
      }
    } else {
      if (fileName == null) return null; // case of a WilCardBinding that doesn't have a corresponding Java element
      // member or top level type
      TypeBinding declaringTypeBinding = typeBinding.enclosingType();
      if (declaringTypeBinding == null) {
        // top level type
        if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(fileName)) {
          ClassFile classFile = (ClassFile) getClassFile(fileName);
          if (classFile == null) return null;
          return (JavaElement) classFile.getType();
        }
        ICompilationUnit cu = getCompilationUnit(fileName, workingCopyOwner);
        if (cu == null) return null;
        return (JavaElement) cu.getType(new String(referenceBinding.sourceName()));
      } else {
        // member type
        IType declaringType = (IType) getUnresolvedJavaElement(declaringTypeBinding, workingCopyOwner, bindingsToNodes);
        if (declaringType == null) return null;
        return (JavaElement) declaringType.getType(new String(referenceBinding.sourceName()));
      }
    }
  }
View Full Code Here

      ? compileTimeType  // unboxing: checkcast before conversion
          : runtimeTimeType;
      TypeBinding typeCast = originalType.genericCast(targetType);
      setGenericCast(length, typeCast);
      if (typeCast instanceof ReferenceBinding) {
        ReferenceBinding referenceCast = (ReferenceBinding) typeCast;
        if (!referenceCast.canBeSeenBy(scope)) {
          scope.problemReporter().invalidType(this,
              new ProblemReferenceBinding(
                  CharOperation.splitOn('.', referenceCast.shortReadableName()),
                  referenceCast,
                  ProblemReasons.NotVisible));
        }
      }
    }
View Full Code Here

        break;
      }
      if ((needValue && !lastFieldBinding.isStatic()) || lastGenericCast != null) {
        int pc = codeStream.position;
        if ((this.bits & ASTNode.DepthMASK) != 0) {
          ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT);
          Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
          codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
        } else {
          generateReceiver(codeStream);
        }
View Full Code Here

        this.constant = field.constant();
      }

      if (field.isStatic()) {
        if ((field.modifiers & ClassFileConstants.AccEnum) != 0) { // enum constants are checked even when qualified)
          ReferenceBinding declaringClass = field.original().declaringClass;
          MethodScope methodScope = scope.methodScope();
          SourceTypeBinding sourceType = methodScope.enclosingSourceType();
          if ((this.bits & ASTNode.IsStrictlyAssigned) == 0
              && sourceType == declaringClass
              && methodScope.lastVisibleFieldID >= 0
View Full Code Here

  if (fieldBinding.constant() != Constant.NotAConstant)
    return;

  if (fieldBinding.isPrivate()) { // private access
      FieldBinding codegenField = getCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index);
      ReferenceBinding declaringClass = codegenField.declaringClass;
    if (declaringClass != currentScope.enclosingSourceType()) {
        setSyntheticAccessor(fieldBinding, index, ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenField, index >= 0 /*read-access?*/, false /*not super access*/));
      currentScope.problemReporter().needToEmulateFieldAccess(codegenField, this, index >= 0 /*read-access?*/);
      return;
    }
 
View Full Code Here

        if (this.binding instanceof FieldBinding) {
          this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
          this.bits |= Binding.FIELD;
          FieldBinding fieldBinding = (FieldBinding) this.binding;
          MethodScope methodScope = scope.methodScope();
          ReferenceBinding declaringClass = fieldBinding.original().declaringClass;
          SourceTypeBinding sourceType = methodScope.enclosingSourceType();
          // check for forward references
          if ((this.indexOfFirstFieldBinding == 1 || (fieldBinding.modifiers & ClassFileConstants.AccEnum) != 0 || (!fieldBinding.isFinal() && declaringClass.isEnum())) // enum constants are checked even when qualified
              && sourceType == declaringClass
              && methodScope.lastVisibleFieldID >= 0
              && fieldBinding.id >= methodScope.lastVisibleFieldID
              && (!fieldBinding.isStatic() || methodScope.isStatic)) {
            scope.problemReporter().forwardReference(this, this.indexOfFirstFieldBinding-1, fieldBinding);
          }
          if (isFieldUseDeprecated(fieldBinding, scope, this.indexOfFirstFieldBinding == this.tokens.length ? this.bits : 0)) {
            scope.problemReporter().deprecatedField(fieldBinding, this)
          }
          if (fieldBinding.isStatic()) {
            // only last field is actually a write access if any
            // check if accessing enum static field in initializer
            if (declaringClass.isEnum()) {
              if ((sourceType == declaringClass || sourceType.superclass == declaringClass) // enum constant body
                  && fieldBinding.constant() == Constant.NotAConstant
                  && !methodScope.isStatic
                  && methodScope.isInsideInitializerOrConstructor()) {
                scope.problemReporter().enumStaticFieldUsedDuringInitialization(fieldBinding, this);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding

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.