Examples of BlockScope


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

            return this.getTypeBinding(literal.literalType(null));
          }
          break;
        case ASTNode.THIS_EXPRESSION :
          ThisReference thisReference = (ThisReference) this.newAstToOldAst.get(expression);
          BlockScope blockScope = (BlockScope) this.astNodesToBlockScope.get(expression);
          if (blockScope != null) {
            return this.getTypeBinding(thisReference.resolveType(blockScope));
          }
          break;
        case ASTNode.PARENTHESIZED_EXPRESSION :
View Full Code Here

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

        return this.getTypeBinding(qualifiedNameReference.resolvedType);
      }
      int indexOfFirstFieldBinding = qualifiedNameReference.indexOfFirstFieldBinding; // one-based
      if (index < indexOfFirstFieldBinding) {
        // an extra lookup is required
        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(tokens, 0, index));
          } else {
            binding = internalScope.getTypeOrPackage(CharOperation.subarray(tokens, 0, index));
          }
        } catch (AbortCompilation e) {
          // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
          // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550
          // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299
        }
        if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
          return null;
        } else if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
          // it is a type
          return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
        }
      } else if (index == indexOfFirstFieldBinding) {
        if (qualifiedNameReference.isTypeReference()) {
          return this.getTypeBinding(qualifiedNameReference.resolvedType);
        } else {
          // in this case we want to get the next field declaring's class
          if (qualifiedNameReference.otherBindings == null) {
            return null;
          }
          FieldBinding fieldBinding = qualifiedNameReference.otherBindings[0];
          if (fieldBinding == null) return null;
          org.eclipse.jdt.internal.compiler.lookup.TypeBinding type = fieldBinding.declaringClass;
          if (type == null) { // array length scenario
            // use type from first binding (no capture needed for array type)
            switch (qualifiedNameReference.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.RestrictiveFlagMASK) {
              case Binding.FIELD:
                type = ((FieldBinding) qualifiedNameReference.binding).type;
                break;
              case Binding.LOCAL:
                type = ((LocalVariableBinding) qualifiedNameReference.binding).type;
                break;
            }
          }
          return this.getTypeBinding(type);
        }
      } 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) return null;
        final int otherBindingsLength = qualifiedNameReference.otherBindings.length;
        if (otherBindingsLength == (index - indexOfFirstFieldBinding)) {
          return this.getTypeBinding(qualifiedNameReference.resolvedType);
        }
        FieldBinding fieldBinding = qualifiedNameReference.otherBindings[index - indexOfFirstFieldBinding];
        if (fieldBinding == null) return null;
        org.eclipse.jdt.internal.compiler.lookup.TypeBinding type = fieldBinding.declaringClass;
        if (type == null) { // array length scenario
          // use type from previous binding (no capture needed for array type)
          fieldBinding = qualifiedNameReference.otherBindings[index - indexOfFirstFieldBinding - 1];
          if (fieldBinding == null) return null;
          type = fieldBinding.type;
        }
        return this.getTypeBinding(type);
      }
    } 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 null;
          }
        }
        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.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
View Full Code Here

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

      QualifiedNameReference qualifiedNameReference = (QualifiedNameReference) node;
      final char[][] tokens = qualifiedNameReference.tokens;
      int indexOfFirstFieldBinding = qualifiedNameReference.indexOfFirstFieldBinding; // one-based
      if (index < indexOfFirstFieldBinding) {
        // an extra lookup is required
        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(tokens, 0, index));
          } else {
            binding = internalScope.getTypeOrPackage(CharOperation.subarray(tokens, 0, index));
          }
        } catch (AbortCompilation e) {
          // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
          // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550
          // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299
        }
        if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
          return getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
        } else if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
          // it is a type
          return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
        }
      } else if (index == indexOfFirstFieldBinding) {
        if (qualifiedNameReference.isTypeReference()) {
          return this.getTypeBinding(qualifiedNameReference.resolvedType);
        } else {
          Binding binding = qualifiedNameReference.binding;
          if (binding != null) {
            if (binding.isValidBinding()) {
              return this.getVariableBinding((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.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
View Full Code Here

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

    return output;
  }

  public void resolve(BlockScope upperScope) {
    // use the scope that will hold the init declarations
    this.scope = new BlockScope(upperScope);
    this.elementVariable.resolve(this.scope); // collection expression can see itemVariable
    TypeBinding elementType = this.elementVariable.type.resolvedType;
    TypeBinding collectionType = this.collection == null ? null : this.collection.resolveType(this.scope);

    TypeBinding expectedCollectionType = null;
View Full Code Here

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

        trackingVar = trackingVar.outerTracker;
      } else if (atExit) {
        // at an exit point we report against inner despite a wrapper that may/may not be closed later
        break;
      } else {
        BlockScope outerTrackerScope = trackingVar.outerTracker.binding.declaringScope;
        if (outerTrackerScope == scope) {
          // outerTracker is from same scope and already processed -> pick trackingVar now
          break;
        } else {
          // outer resource is from other (outer?) scope
View Full Code Here

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

    }
    return false;
  }

  public boolean isClosedInFinallyOfEnclosing(BlockScope scope) {
    BlockScope currentScope = scope;
    while (true) {     
      if (currentScope.finallyInfo != null
          && currentScope.finallyInfo.isDefinitelyNonNull(this.binding)) {
        return true; // closed in enclosing finally
      }
View Full Code Here

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

  public void resolve(ClassScope scope) {
    internalResolve(scope, scope.enclosingSourceType().isStatic());
  }

  public void resolveAnnotations(Scope scope) {
    BlockScope resolutionScope = Scope.typeAnnotationsResolutionScope(scope);
    if (resolutionScope != null) {
      AnnotationBinding [] annotationBindings = resolveAnnotations(resolutionScope, this.annotations, this.binding, false);
      if (annotationBindings != null && annotationBindings.length > 0) {
        this.binding.setTypeAnnotations(annotationBindings, scope.environment().globalOptions.isAnnotationBasedNullAnalysisEnabled);
        scope.referenceCompilationUnit().compilationResult.hasAnnotations = true;
View Full Code Here

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

public abstract void traverse(ASTVisitor visitor, ClassScope scope);

protected void resolveAnnotations(Scope scope, int location) {
  Annotation[][] annotationsOnDimensions = getAnnotationsOnDimensions();
  if (this.annotations != null || annotationsOnDimensions != null) {
    BlockScope resolutionScope = Scope.typeAnnotationsResolutionScope(scope);
    if (resolutionScope != null) {
      int dimensions = this.dimensions();
      if (this.annotations != null) {
        TypeBinding leafComponentType = this.resolvedType.leafComponentType();
        leafComponentType = resolveAnnotations(resolutionScope, this.annotations, leafComponentType);
View Full Code Here

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

        trackingVar = trackingVar.outerTracker;
      } else if (atExit) {
        // at an exit point we report against inner despite a wrapper that may/may not be closed later
        break;
      } else {
        BlockScope outerTrackerScope = trackingVar.outerTracker.binding.declaringScope;
        if (outerTrackerScope == scope) {
          // outerTracker is from same scope and already processed -> pick trackingVar now
          break;
        } else {
          // outer resource is from other (outer?) scope
View Full Code Here

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

    }
    return false;
  }

  public boolean isClosedInFinallyOfEnclosing(BlockScope scope) {
    BlockScope currentScope = scope;
    while (true) {     
      if (currentScope.finallyInfo != null
          && currentScope.finallyInfo.isDefinitelyNonNull(this.binding)) {
        return true; // closed in enclosing finally
      }
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.