Package org.eclipse.jdt.internal.compiler.impl

Examples of org.eclipse.jdt.internal.compiler.impl.CompilerOptions


      }
    }
  }
}
public void reportRawReferences(MethodBinding currentMethod, MethodBinding inheritedMethod) {
  CompilerOptions compilerOptions = this.type.scope.compilerOptions();
  if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all
      || compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined
    return;
  }
  AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
  if (methodDecl == null) return;
  TypeBinding [] parameterTypes = currentMethod.parameters;
  TypeBinding [] inheritedParameterTypes = inheritedMethod.parameters;
  Argument[] arguments = methodDecl.arguments;
  for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
    TypeBinding parameterType = parameterTypes[j];
    TypeBinding inheritedParameterType = inheritedParameterTypes[j];
    Argument arg = arguments[j];
    if (parameterType.leafComponentType().isRawType()) {
      if (inheritedParameterType.leafComponentType().isRawType()) {
        arg.binding.tagBits |= TagBits.ForcedToBeRawType;
      } else {
        if (compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
            && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
          methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
        }
      }
      }
    }
  TypeReference returnType = null;
  if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration && (returnType = ((MethodDeclaration) methodDecl).returnType) != null) {
    final TypeBinding inheritedMethodType = inheritedMethod.returnType;
    final TypeBinding methodType = currentMethod.returnType;
    if (methodType.leafComponentType().isRawType()) {
      if (inheritedMethodType.leafComponentType().isRawType()) {
        //
      } else {
        if ((returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0
            && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
          methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType);
        }
      }
    }
  }
View Full Code Here


    : (INameEnvironment) new JavaSearchNameEnvironment(project, this.workingCopies);

  // create lookup environment
  Map map = project.getOptions(true);
  map.put(CompilerOptions.OPTION_TaskTags, org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING);
  this.options = new CompilerOptions(map);
  ProblemReporter problemReporter =
    new ProblemReporter(
      DefaultErrorHandlingPolicies.proceedWithAllProblems(),
      this.options,
      new DefaultProblemFactory());
View Full Code Here

  options.put(JavaCore.COMPILER_TASK_TAGS, ""); //$NON-NLS-1$

  SourceElementParser parser = new IndexingParser(
    requestor,
    new DefaultProblemFactory(Locale.getDefault()),
    new CompilerOptions(options),
    true, // index local declarations
    true, // optimize string literals
    false); // do not use source javadoc parser to speed up parsing
  parser.reportOnlyOneSyntaxError = true;
View Full Code Here

    MethodBinding foundProblem = null;
    boolean foundProblemVisible = false;
    Scope scope = this;
    int depth = 0;
    // in 1.4 mode (inherited visible shadows enclosing)
    CompilerOptions options;
    boolean inheritedHasPrecedence = (options = compilerOptions()).complianceLevel >= ClassFileConstants.JDK1_4;

    done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
      switch (scope.kind) {
        case METHOD_SCOPE :
View Full Code Here

        } catch(NumberFormatException e) {
          // ignore
        }
      }
      boolean doFullParse = hasToRetrieveSourceRangesForLocalClass(fullName);
      parser = new SourceElementParser(this, factory, new CompilerOptions(this.options), doFullParse, true/*optimize string literals*/);
      parser.javadocParser.checkDocComment = false; // disable javadoc parsing
      IJavaElement javaElement = this.binaryType.getCompilationUnit();
      if (javaElement == null) javaElement = this.binaryType.getParent();
      parser.parseCompilationUnit(
        new BasicCompilationUnit(contents, null, this.binaryType.sourceFileName(info), javaElement),
View Full Code Here

      }
    }
  }

  // called once when the builder is initialized... can override if needed
  CompilerOptions compilerOptions = new CompilerOptions(projectOptions);
  compilerOptions.performMethodsFullRecovery = true;
  compilerOptions.performStatementsRecovery = true;
  Compiler newCompiler = new Compiler(
    this.nameEnvironment,
    DefaultErrorHandlingPolicies.proceedWithAllProblems(),
    compilerOptions,
    this,
    ProblemFactory.getProblemFactory(Locale.getDefault()));
  CompilerOptions options = newCompiler.options;
  // temporary code to allow the compiler to revert to a single thread
  String setting = System.getProperty("jdt.compiler.useSingleThread"); //$NON-NLS-1$
  newCompiler.useSingleThread = setting != null && setting.equals("true"); //$NON-NLS-1$

  // enable the compiler reference info support
View Full Code Here

    this.recoveryScannerData = recoveryScannerData;
  }

  final TokenScanner getScanner() {
    if (this.tokenScanner == null) {
      CompilerOptions compilerOptions = new CompilerOptions(this.options);
      Scanner scanner;
      if (this.recoveryScannerData == null) {
        scanner =
          new Scanner(
              true,/*tokenizeComments*/
 
View Full Code Here

  // and not from Object or implicit static field access.
  if (constantPoolDeclaringClass != actualReceiverType.erasure()
      && !actualReceiverType.isArrayType()
      && constantPoolDeclaringClass != null // array.length
      && codegenBinding.constant() == Constant.NotAConstant) {
    CompilerOptions options = currentScope.compilerOptions();
    if ((options.targetJDK >= ClassFileConstants.JDK1_2
          && (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(isImplicitThisReceiver && codegenBinding.isStatic()))
          && constantPoolDeclaringClass.id != TypeIds.T_JavaLangObject) // no change for Object fields
        || !constantPoolDeclaringClass.canBeSeenBy(currentScope)) {
View Full Code Here

public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, MethodBinding codegenBinding, TypeBinding actualReceiverType, boolean isImplicitThisReceiver) {
  TypeBinding constantPoolDeclaringClass = codegenBinding.declaringClass;
  // Post 1.4.0 target, array clone() invocations are qualified with array type
  // This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding)
  if (codegenBinding == currentScope.environment().arrayClone) {
    CompilerOptions options = currentScope.compilerOptions();
    if (options.sourceLevel > ClassFileConstants.JDK1_4 ) {
      constantPoolDeclaringClass = actualReceiverType.erasure();
    }
  } else {
    // if the binding declaring class is not visible, need special action
    // for runtime compatibility on 1.2 VMs : change the declaring class of the binding
    // NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
    // and not from Object or implicit static method call.
    if (constantPoolDeclaringClass != actualReceiverType.erasure() && !actualReceiverType.isArrayType()) {
      CompilerOptions options = currentScope.compilerOptions();
      if ((options.targetJDK >= ClassFileConstants.JDK1_2
            && (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(isImplicitThisReceiver && codegenBinding.isStatic()))
            && codegenBinding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods
          || !codegenBinding.declaringClass.canBeSeenBy(currentScope)) {
        constantPoolDeclaringClass = actualReceiverType.erasure();
View Full Code Here

        }
      }
    }

    // check @Override annotation
    final CompilerOptions compilerOptions = this.scope.compilerOptions();
    checkOverride: {
      if (this.binding == null) break checkOverride;
      long complianceLevel = compilerOptions.complianceLevel;
      if (complianceLevel < ClassFileConstants.JDK1_5) break checkOverride;
      int bindingModifiers = this.binding.modifiers;
      boolean hasOverrideAnnotation = (this.binding.tagBits & TagBits.AnnotationOverride) != 0;
      boolean hasUnresolvedArguments = (this.binding.tagBits & TagBits.HasUnresolvedArguments) != 0;
      if (hasOverrideAnnotation  && !hasUnresolvedArguments) {
        // no static method is considered overriding
        if ((bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding)
          break checkOverride;
        //  in 1.5, strictly for overriding superclass method
        //  in 1.6 and above, also tolerate implementing interface method
        if (complianceLevel >= ClassFileConstants.JDK1_6
            && ((bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccImplementing)) == ExtraCompilerModifiers.AccImplementing))
          break checkOverride;
        // claims to override, and doesn't actually do so
        this.scope.problemReporter().methodMustOverride(this, complianceLevel);
      } else {
        //In case of  a concrete class method, we have to check if it overrides(in 1.5 and above) OR implements a method(1.6 and above).
        //Also check if the method has a signature that is override-equivalent to that of any public method declared in Object.
        if (!this.binding.declaringClass.isInterface()){
            if((bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding) {
              this.scope.problemReporter().missingOverrideAnnotation(this);
            } else {
              if(complianceLevel >= ClassFileConstants.JDK1_6
                && compilerOptions.reportMissingOverrideAnnotationForInterfaceMethodImplementation
                && this.binding.isImplementing()) {
                  // actually overrides, but did not claim to do so
                  this.scope.problemReporter().missingOverrideAnnotationForInterfaceMethodImplementation(this);
              }
             
            }
        }
        else //For 1.6 and above only
          //In case of a interface class method, we have to check if it overrides a method (isImplementing returns true in case it overrides)
          //Also check if the method has a signature that is override-equivalent to that of any public method declared in Object.
          if(complianceLevel >= ClassFileConstants.JDK1_6
              && compilerOptions.reportMissingOverrideAnnotationForInterfaceMethodImplementation
              && (((bindingModifiers & (ClassFileConstants.AccStatic|ExtraCompilerModifiers.AccOverriding)) == ExtraCompilerModifiers.AccOverriding) || this.binding.isImplementing())){
            // actually overrides, but did not claim to do so
            this.scope.problemReporter().missingOverrideAnnotationForInterfaceMethodImplementation(this);
          }
        }
      }
    }

    // by grammatical construction, interface methods are always abstract
    switch (TypeDeclaration.kind(this.scope.referenceType().modifiers)) {
      case TypeDeclaration.ENUM_DECL :
        if (this.selector == TypeConstants.VALUES) break;
        if (this.selector == TypeConstants.VALUEOF) break;
        //$FALL-THROUGH$
      case TypeDeclaration.CLASS_DECL :
        // if a method has an semicolon body and is not declared as abstract==>error
        // native methods may have a semicolon body
        if ((this.modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0) {
          if ((this.modifiers & ClassFileConstants.AccNative) == 0)
            if ((this.modifiers & ClassFileConstants.AccAbstract) == 0)
              this.scope.problemReporter().methodNeedBody(this);
        } else {
          // the method HAS a body --> abstract native modifiers are forbiden
          if (((this.modifiers & ClassFileConstants.AccNative) != 0) || ((this.modifiers & ClassFileConstants.AccAbstract) != 0))
            this.scope.problemReporter().methodNeedingNoBody(this);
          else if (this.binding != null && !this.binding.isStatic() && !(this.binding.declaringClass instanceof LocalTypeBinding) && !returnsUndeclTypeVar) {
            // Not a method of local type - can be static
            this.bits |= ASTNode.CanBeStatic;
          }
        }
    }
    super.resolveStatements();

    // TagBits.OverridingMethodWithSupercall is set during the resolveStatements() call
    if (compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) {
      if (this.binding != null) {
            int bindingModifiers = this.binding.modifiers;
            if ((bindingModifiers & (ExtraCompilerModifiers.AccOverriding|ExtraCompilerModifiers.AccImplementing)) == ExtraCompilerModifiers.AccOverriding
                && (this.bits & ASTNode.OverridingMethodWithSupercall) == 0) {
              this.scope.problemReporter().overridesMethodWithoutSuperInvocation(this.binding);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.impl.CompilerOptions

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.