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

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


    }
    return (this.resolvedType != null && (this.resolvedType.tagBits & TagBits.HasMissingType) == 0)
            ? this.resolvedType
            : null;
  }
  final CompilerOptions compilerOptions = scope.compilerOptions();
  if (compilerOptions.complianceLevel <= ClassFileConstants.JDK1_6
      && this.binding.isPolymorphic()) {
    scope.problemReporter().polymorphicMethodNotBelow17(this);
    return null;
  }

  if (((this.bits & ASTNode.InsideExpressionStatement) != 0)
      && this.binding.isPolymorphic()) {
    // we only set the return type to be void if this method invocation is used inside an expression statement
    this.binding = scope.environment().updatePolymorphicMethodReturnType((PolymorphicMethodBinding) this.binding, TypeBinding.VOID);
  }
  if ((this.binding.tagBits & TagBits.HasMissingType) != 0) {
    scope.problemReporter().missingTypeInMethod(this, this.binding);
  }
  if (!this.binding.isStatic()) {
    // the "receiver" must not be a type
    if (receiverIsType) {
      scope.problemReporter().mustUseAStaticMethod(this, this.binding);
      if (this.actualReceiverType.isRawType()
          && (this.receiver.bits & ASTNode.IgnoreRawTypeCheck) == 0
          && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore) {
        scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType);
      }
    } else {
      // handle indirect inheritance thru variable secondary bound
      // receiver may receive generic cast, as part of implicit conversion
      TypeBinding oldReceiverType = this.actualReceiverType;
      this.actualReceiverType = this.actualReceiverType.getErasureCompatibleType(this.binding.declaringClass);
      this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
      if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it
        this.bits |= NeedReceiverGenericCast;
      }
    }
  } else {
    // static message invoked through receiver? legal but unoptimal (optional warning).
    if (!(this.receiver.isImplicitThis() || this.receiver.isSuper() || receiverIsType)) {
      scope.problemReporter().nonStaticAccessToStaticMethod(this, this.binding);
    }
    if (!this.receiver.isImplicitThis() && this.binding.declaringClass != this.actualReceiverType) {
      scope.problemReporter().indirectAccessToStaticMethod(this, this.binding);
    }
  }
  if (checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this)) {
    this.bits |= ASTNode.Unchecked;
  }

  //-------message send that are known to fail at compile time-----------
  if (this.binding.isAbstract()) {
    if (this.receiver.isSuper()) {
      scope.problemReporter().cannotDireclyInvokeAbstractMethod(this, this.binding);
    }
    // abstract private methods cannot occur nor abstract static............
  }
  if (isMethodUseDeprecated(this.binding, scope, true))
    scope.problemReporter().deprecatedMethod(this.binding, this);

  // from 1.5 source level on, array#clone() returns the array type (but binding still shows Object)
  if (this.binding == scope.environment().arrayClone && compilerOptions.sourceLevel >= ClassFileConstants.JDK1_5) {
    this.resolvedType = this.actualReceiverType;
  } else {
    TypeBinding returnType;
    if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) {
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=277643, align with javac on JLS 15.12.2.6
      returnType = this.binding.returnType;
      if (returnType != null) {
        returnType = scope.environment().convertToRawType(returnType.erasure(), true);
      }
    } else {
      returnType = this.binding.returnType;
      if (returnType != null) {
        returnType = returnType.capture(scope, this.sourceEnd);
      }
    }
    this.resolvedType = returnType;
  }
  if (this.receiver.isSuper() && compilerOptions.getSeverity(CompilerOptions.OverridingMethodWithoutSuperInvocation) != ProblemSeverities.Ignore) {
    final ReferenceContext referenceContext = scope.methodScope().referenceContext;
    if (referenceContext instanceof AbstractMethodDeclaration) {
      final AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) referenceContext;
      MethodBinding enclosingMethodBinding = abstractMethodDeclaration.binding;
      if (enclosingMethodBinding.isOverriding()
View Full Code Here


    FakeUnit = new CompilationUnitDeclaration(problemReporter, result, 0);
  }

public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) {
  // create a problem handler with the 'exit after all problems' handling policy
  this.options = new CompilerOptions(settings);
  IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems();
  ProblemReporter problemReporter = new ProblemReporter(policy, this.options, problemFactory);

  setEnvironment(
    new LookupEnvironment(this, this.options, problemReporter, nameEnvironment),
View Full Code Here

      int apiLevel,
      Map options,
      int flags,
      IProgressMonitor monitor) {
    try {
      CompilerOptions compilerOptions = new CompilerOptions(options);
      compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
      Parser parser = new CommentRecorderParser(
        new ProblemReporter(
            DefaultErrorHandlingPolicies.proceedWithAllProblems(),
            compilerOptions,
View Full Code Here

      Map settings,
      int flags) {
    if (sourceUnit == null) {
      throw new IllegalStateException();
    }
    CompilerOptions compilerOptions = new CompilerOptions(settings);
    boolean statementsRecovery = (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0;
    compilerOptions.performMethodsFullRecovery = statementsRecovery;
    compilerOptions.performStatementsRecovery = statementsRecovery;
    compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
    Parser parser = new CommentRecorderParser(
View Full Code Here

        int amountOfWork = (compilationUnits.length + bindingKeys.length) * 2; // 1 for beginToCompile, 1 for resolve
        monitor.beginTask("", amountOfWork); //$NON-NLS-1$
      }
      environment = new CancelableNameEnvironment(((JavaProject) javaProject), owner, monitor);
      problemFactory = new CancelableProblemFactory(monitor);
      CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
      compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
      CompilationUnitResolver resolver =
        new CompilationUnitResolver(
          environment,
          getHandlingPolicy(),
View Full Code Here

        }
        Classpath[] allEntries = new Classpath[classpaths.size()];
        classpaths.toArray(allEntries);
        environment = new NameEnvironmentWithProgress(allEntries, null, monitor);
        problemFactory = new CancelableProblemFactory(monitor);
        CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
        compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
        CompilationUnitResolver resolver =
          new CompilationUnitResolver(
            environment,
            getHandlingPolicy(),
View Full Code Here

        environment = new NameEnvironmentWithProgress(allEntries, null, monitor);
      } else {
        environment = new CancelableNameEnvironment((JavaProject) javaProject, owner, monitor);
      }
      problemFactory = new CancelableProblemFactory(monitor);
      CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
      boolean ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
      compilerOptions.ignoreMethodBodies = ignoreMethodBodies;
      resolver =
        new CompilationUnitResolver(
          environment,
View Full Code Here

      this.options.sourceLevel = savedSourceLevel;
    }
  }

  protected static CompilerOptions getCompilerOptions(Map settings, boolean creatingAST, boolean statementsRecovery) {
    CompilerOptions compilerOptions = new CompilerOptions(settings);
    compilerOptions.performMethodsFullRecovery = statementsRecovery;
    compilerOptions.performStatementsRecovery = statementsRecovery;
    compilerOptions.parseLiteralExpressionsAsConstants = !creatingAST; /*parse literal expressions as constants only if not creating a DOM AST*/
    compilerOptions.storeAnnotations = creatingAST; /*store annotations in the bindings if creating a DOM AST*/
    return compilerOptions;
View Full Code Here

    CompilationUnitProblemFinder problemFinder = null;
    CompilationUnitDeclaration unit = null;
    try {
      environment = new CancelableNameEnvironment(project, workingCopyOwner, monitor);
      problemFactory = new CancelableProblemFactory(monitor);
      CompilerOptions compilerOptions = getCompilerOptions(project.getOptions(true), creatingAST, ((reconcileFlags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0));
      boolean ignoreMethodBodies = (reconcileFlags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
      compilerOptions.ignoreMethodBodies = ignoreMethodBodies;
      problemFinder = new CompilationUnitProblemFinder(
        environment,
        getHandlingPolicy(),
View Full Code Here

  return false;
}

void reportRawReferences() {
  CompilerOptions compilerOptions = this.type.scope.compilerOptions();
  if (compilerOptions.sourceLevel < ClassFileConstants.JDK1_5 // shouldn't whine at all
      || compilerOptions.reportUnavoidableGenericTypeProblems) { // must have already whined
    return;
  }
  /* Code below is only for a method that does not override/implement a super type method. If it were to,
     it would have been handled in checkAgainstInheritedMethods.
  */
  Object [] methodArray = this.currentMethods.valueTable;
  for (int s = methodArray.length; --s >= 0;) {
    if (methodArray[s] == null) continue;
    MethodBinding[] current = (MethodBinding[]) methodArray[s];
    for (int i = 0, length = current.length; i < length; i++) {
      MethodBinding currentMethod = current[i];
      if ((currentMethod.modifiers & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) == 0) {
        AbstractMethodDeclaration methodDecl = currentMethod.sourceMethod();
        if (methodDecl == null) return;
        TypeBinding [] parameterTypes = currentMethod.parameters;
        Argument[] arguments = methodDecl.arguments;
        for (int j = 0, size = currentMethod.parameters.length; j < size; j++) {
          TypeBinding parameterType = parameterTypes[j];
          Argument arg = arguments[j];
          if (parameterType.leafComponentType().isRawType()
            && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
                && (arg.type.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
            methodDecl.scope.problemReporter().rawTypeReference(arg.type, parameterType);
            }
        }
        if (!methodDecl.isConstructor() && methodDecl instanceof MethodDeclaration) {
          TypeReference returnType = ((MethodDeclaration) methodDecl).returnType;
          TypeBinding methodType = currentMethod.returnType;
          if (returnType != null) {
            if (methodType.leafComponentType().isRawType()
                && compilerOptions.getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore
                && (returnType.bits & ASTNode.IgnoreRawTypeCheck) == 0) {
              methodDecl.scope.problemReporter().rawTypeReference(returnType, methodType);
            }
          }
        }
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.