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

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


    arguments,
    nodeSourceStart(binding, location),
    nodeSourceEnd(binding, location));
}
private boolean methodHasMissingSwitchDefault() {
  MethodScope methodScope = null;
  if (this.referenceContext instanceof Block) {
    methodScope = ((Block)this.referenceContext).scope.methodScope();
  } else if (this.referenceContext instanceof AbstractMethodDeclaration) {
    methodScope = ((AbstractMethodDeclaration)this.referenceContext).scope;
  }
View Full Code Here


  this.initsOnReturn = FlowInfo.DEAD_END;
  this.initializationParent = initializationParent;
}

public void complainIfUnusedExceptionHandlers(AbstractMethodDeclaration method) {
  MethodScope scope = method.scope;
  // can optionally skip overriding methods
  if ((method.binding.modifiers & (ExtraCompilerModifiers.AccOverriding | ExtraCompilerModifiers.AccImplementing)) != 0
          && !scope.compilerOptions().reportUnusedDeclaredThrownExceptionWhenOverriding) {
      return;
  }

  // report errors for unreachable exception handlers
  TypeBinding[] docCommentReferences = null;
  int docCommentReferencesLength = 0;
  if (scope.compilerOptions().
        reportUnusedDeclaredThrownExceptionIncludeDocCommentReference &&
      method.javadoc != null &&
      method.javadoc.exceptionReferences != null &&
      (docCommentReferencesLength = method.javadoc.exceptionReferences.length) > 0) {
    docCommentReferences = new TypeBinding[docCommentReferencesLength];
    for (int i = 0; i < docCommentReferencesLength; i++) {
      docCommentReferences[i] = method.javadoc.exceptionReferences[i].resolvedType;
    }
  }
  nextHandledException: for (int i = 0, count = this.handledExceptions.length; i < count; i++) {
    int index = this.indexes.get(this.handledExceptions[i]);
    if ((this.isReached[index / ExceptionHandlingFlowContext.BitCacheSize] & 1 << (index % ExceptionHandlingFlowContext.BitCacheSize)) == 0) {
      for (int j = 0; j < docCommentReferencesLength; j++) {
        if (TypeBinding.equalsEquals(docCommentReferences[j], this.handledExceptions[i])) {
          continue nextHandledException;
        }
      }
      scope.problemReporter().unusedDeclaredThrownException(
        this.handledExceptions[index],
        method,
        method.thrownExceptions[index]);
    }
  }
View Full Code Here

  FieldBinding fieldBinding = (FieldBinding) this.binding;
  this.constant = fieldBinding.constant();

  this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
  this.bits |= Binding.FIELD;
  MethodScope methodScope = scope.methodScope();
  if (fieldBinding.isStatic()) {
    // check if accessing enum static field in initializer
    ReferenceBinding declaringClass = fieldBinding.declaringClass;
    if (declaringClass.isEnum()) {
      SourceTypeBinding sourceType = scope.enclosingSourceType();
      if (this.constant == Constant.NotAConstant
          && !methodScope.isStatic
          && (TypeBinding.equalsEquals(sourceType, declaringClass) || TypeBinding.equalsEquals(sourceType.superclass, declaringClass)) // enum constant body
          && methodScope.isInsideInitializerOrConstructor()) {
        scope.problemReporter().enumStaticFieldUsedDuringInitialization(fieldBinding, this);
      }
    }
  } else {
    if (scope.compilerOptions().getSeverity(CompilerOptions.UnqualifiedFieldAccess) != ProblemSeverities.Ignore) {
      scope.problemReporter().unqualifiedFieldAccess(this, fieldBinding);
    }
    // must check for the static status....
    if (methodScope.isStatic) {
      scope.problemReporter().staticFieldAccessToNonStaticVariable(this, fieldBinding);
      return fieldBinding.type;
    } else {
      scope.tagAsAccessingEnclosingInstanceStateOf(fieldBinding.declaringClass, false /* type variable access */);
    }
  }

  if (isFieldUseDeprecated(fieldBinding, scope, this.bits))
    scope.problemReporter().deprecatedField(fieldBinding, this);

  if ((this.bits & ASTNode.IsStrictlyAssigned) == 0
      && TypeBinding.equalsEquals(methodScope.enclosingSourceType(), fieldBinding.original().declaringClass)
      && methodScope.lastVisibleFieldID >= 0
      && fieldBinding.id >= methodScope.lastVisibleFieldID
      && (!fieldBinding.isStatic() || methodScope.isStatic)) {
    scope.problemReporter().forwardReference(this, 0, fieldBinding);
    this.bits |= ASTNode.IgnoreNoEffectAssignCheck;
View Full Code Here

      return; // still waiting to see more usages of this kind
  }
  // at this point we know we have something to report
  if (localBinding.declaration instanceof Argument) {
    // check compiler options to report against unused arguments
    MethodScope methodScope = currentScope.methodScope();
    if (methodScope != null && !methodScope.isLambdaScope()) { // lambda must be congruent with the descriptor.
      MethodBinding method = ((AbstractMethodDeclaration)methodScope.referenceContext()).binding;
     
      boolean shouldReport = !method.isMain();
      if (method.isImplementing()) {
        shouldReport &= currentScope.compilerOptions().reportUnusedParameterWhenImplementingAbstract;
      } else if (method.isOverriding()) {
View Full Code Here

    }
    if (this.expectedType == null && this.expressionContext == INVOCATION_CONTEXT) {
      return new PolyTypeBinding(this);
    }
   
    MethodScope methodScope = blockScope.methodScope();
    this.scope = new MethodScope(blockScope, this, methodScope.isStatic, methodScope.lastVisibleFieldID);
    this.scope.isConstructorCall = methodScope.isConstructorCall;

    super.resolveType(blockScope); // compute & capture interface function descriptor in singleAbstractMethod.
   
    final boolean haveDescriptor = this.descriptor != null;
View Full Code Here

      case IProblem.MultipleFunctionalInterfaces:
      case IProblem.NoGenericLambda:
        return;
      default:
        this.original.hasIgnoredMandatoryErrors = true;
        MethodScope enclosingLambdaScope = this.scope == null ? null : this.scope.enclosingLambdaScope();
        while (enclosingLambdaScope != null) {
          LambdaExpression enclosingLambda = (LambdaExpression) enclosingLambdaScope.referenceContext;
          if (enclosingLambda.original != enclosingLambda)
            enclosingLambda.original.hasIgnoredMandatoryErrors = true;
          enclosingLambdaScope = enclosingLambdaScope.enclosingLambdaScope();
        }
        return;
    }
  }
View Full Code Here

    codeStream.reset(this, classFile);
    TypeDeclaration declaringType = classScope.referenceContext;

    // initialize local positions - including initializer scope.
    MethodScope staticInitializerScope = declaringType.staticInitializerScope;
    staticInitializerScope.computeLocalVariablePositions(0, codeStream);

    // 1.4 feature
    // This has to be done before any other initialization
    if (this.assertionSyntheticFieldBinding != null) {
      // generate code related to the activation of assertion for this class
View Full Code Here

    return output;
  }

  public void resolve(ClassScope classScope) {

    this.scope = new MethodScope(classScope, classScope.referenceContext, true);
  }
View Full Code Here

        && declaringClass.canBeSeenBy(scope)) {
      scope.problemReporter().indirectAccessToStaticField(this, fieldBinding);
    }
    // check if accessing enum static field in initializer
    if (declaringClass.isEnum()) {
      MethodScope methodScope = scope.methodScope();
      SourceTypeBinding sourceType = scope.enclosingSourceType();
      if (this.constant == Constant.NotAConstant
          && !methodScope.isStatic
          && (TypeBinding.equalsEquals(sourceType, declaringClass) || TypeBinding.equalsEquals(sourceType.superclass, declaringClass)) // enum constant body
          && methodScope.isInsideInitializerOrConstructor()) {
        scope.problemReporter().enumStaticFieldUsedDuringInitialization(this.binding, this);
      }
    }
  }
  TypeBinding fieldType = fieldBinding.type;
View Full Code Here

      }

      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
              && TypeBinding.equalsEquals(sourceType, declaringClass)
              && methodScope.lastVisibleFieldID >= 0
              && field.id >= methodScope.lastVisibleFieldID
              && (!field.isStatic() || methodScope.isStatic)) {
            scope.problemReporter().forwardReference(this, index, field);
          }         
          // check if accessing enum static field in initializer
          if ((TypeBinding.equalsEquals(sourceType, declaringClass) || TypeBinding.equalsEquals(sourceType.superclass, declaringClass)) // enum constant body
              && field.constant() == Constant.NotAConstant
              && !methodScope.isStatic
              && methodScope.isInsideInitializerOrConstructor()) {
            scope.problemReporter().enumStaticFieldUsedDuringInitialization(field, this);
          }
        }
        // static field accessed through receiver? legal but unoptimal (optional warning)
        scope.problemReporter().nonStaticAccessToStaticField(this, field, index);
View Full Code Here

TOP

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

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.