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

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


    this.scribe.space();
    /*
     * Print the method return type
     */
    final TypeReference returnType = annotationTypeMemberDeclaration.returnType;
    final MethodScope annotationTypeMemberDeclarationScope = annotationTypeMemberDeclaration.scope;

    if (returnType != null) {
      returnType.traverse(this, annotationTypeMemberDeclarationScope);
    }
    /*
 
View Full Code Here


        Alignment.R_INNERMOST,
        3,
        this.scribe.scanner.currentPosition);
    this.scribe.enterAlignment(methodDeclAlignment);
    boolean ok = false;
    final MethodScope methodDeclarationScope = methodDeclaration.scope;
    do {
      try {

        this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_METHOD);
        int fragmentIndex = 0;
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
          && (sourceType == declaringClass || 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;
    }
  }

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

  if ((this.bits & ASTNode.IsStrictlyAssigned) == 0
      && 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) {
      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

        && 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
          && (sourceType == declaringClass || sourceType.superclass == declaringClass) // enum constant body
          && methodScope.isInsideInitializerOrConstructor()) {
        scope.problemReporter().enumStaticFieldUsedDuringInitialization(this.binding, this);
      }
    }
  }
  TypeBinding fieldType = fieldBinding.type;
View Full Code Here

          type, true, enclosingMethod);
      return param;
    }

    private JMethod findEnclosingMethod(BlockScope scope) {
      MethodScope methodScope = scope.methodScope();
      if (methodScope.isInsideInitializer()) {
        JReferenceType enclosingType = (JReferenceType) typeMap.get(scope.classScope().referenceContext.binding);
        if (methodScope.isStatic) {
          // clinit
          return (JMethod) enclosingType.methods.get(0);
        } else {
          // init
          assert (enclosingType instanceof JClassType);
          return (JMethod) enclosingType.methods.get(1);
        }
      }

      AbstractMethodDeclaration referenceMethod = methodScope.referenceMethod();
      return (JMethod) typeMap.get(referenceMethod.binding);
    }
View Full Code Here

      return synthetic;
    }

    private JMethodBody findEnclosingMethod(BlockScope scope) {
      JMethod method;
      MethodScope methodScope = scope.methodScope();
      if (methodScope.isInsideInitializer()) {
        JReferenceType enclosingType = (JReferenceType) typeMap.get(scope.classScope().referenceContext.binding);
        if (methodScope.isStatic) {
          // clinit
          method = enclosingType.methods.get(0);
        } else {
          // init
          assert (enclosingType instanceof JClassType);
          method = enclosingType.methods.get(1);
        }
      } else {
        AbstractMethodDeclaration referenceMethod = methodScope.referenceMethod();
        method = (JMethod) typeMap.get(referenceMethod.binding);
      }
      assert !method.isNative() && !method.isAbstract();
      return (JMethodBody) method.getBody();
    }
View Full Code Here

    LookupEnvironment lookupEnvironment = createMockLookupEnvironment();
    cud.scope = new CompilationUnitScope(cud, lookupEnvironment);

    TypeDeclaration typeDeclaration = new TypeDeclaration(compilationResult);
    typeDeclaration.scope = new ClassScope(cud.scope, null);
    typeDeclaration.staticInitializerScope = new MethodScope(
        typeDeclaration.scope, null, false);
    cud.types = new TypeDeclaration[] {typeDeclaration};

    BinaryTypeBinding binaryTypeBinding = new BinaryTypeBinding(null,
        new MockBinaryType(BINARY_TYPE_NAME), lookupEnvironment);
    typeDeclaration.superclass = createMockBinaryTypeReference(binaryTypeBinding);

    MethodDeclaration methodDeclaration = new MethodDeclaration(
        compilationResult);
    methodDeclaration.scope = new MethodScope(typeDeclaration.scope, null,
        false);
    methodDeclaration.returnType = createMockBinaryTypeReference(binaryTypeBinding);

    LocalDeclaration localDeclaration = new LocalDeclaration(null, 0, 0);
    localDeclaration.type = createMockBinaryTypeReference(binaryTypeBinding);
View Full Code Here

      return field;
    }

    private JMethodBody findEnclosingMethod(BlockScope scope) {
      JMethod method;
      MethodScope methodScope = scope.methodScope();
      if (methodScope.isInsideInitializer()) {
        JDeclaredType enclosingType = (JDeclaredType) getType(
            scope.classScope().referenceContext.binding);
        if (methodScope.isStatic) {
          // clinit
          method = enclosingType.getMethods().get(0);
        } else {
          // init
          assert (enclosingType instanceof JClassType);
          method = enclosingType.getMethods().get(1);
        }
      } else {
        AbstractMethodDeclaration referenceMethod = methodScope.referenceMethod();
        method = (JMethod) typeMap.get(referenceMethod.binding);
      }
      assert !method.isNative() && !method.isAbstract();
      return (JMethodBody) (method.getEnclosingType().isExternal() ? null :
          method.getBody());
View Full Code Here

    this.scribe.space();
    /*
     * Print the method return type
     */
    final TypeReference returnType = annotationTypeMemberDeclaration.returnType;
    final MethodScope annotationTypeMemberDeclarationScope = annotationTypeMemberDeclaration.scope;

    if (returnType != null) {
      returnType.traverse(this, annotationTypeMemberDeclarationScope);
    }
    /*
 
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.