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

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


    compiler.doCompile(builders);
    return processor.getResults();
  }

  public static CompilerOptions getCompilerOptions() {
    CompilerOptions options = new CompilerOptions();
    options.complianceLevel = options.sourceLevel = options.targetJDK = ClassFileConstants.JDK1_6;

    // Generate debug info for debugging the output.
    options.produceDebugAttributes = ClassFileConstants.ATTR_VARS
        | ClassFileConstants.ATTR_LINES | ClassFileConstants.ATTR_SOURCE;
View Full Code Here


    // If modified, also modify the method JavaModelManager#getDefaultOptionsNoInitialization()
    // Get options names set
    HashSet optionNames = JavaModelManager.getJavaModelManager().optionNames;

    // Compiler settings
    Map defaultOptionsMap = new CompilerOptions().getMap(); // compiler defaults

    // Override some compiler defaults
    defaultOptionsMap.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
    defaultOptionsMap.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE);
    defaultOptionsMap.put(JavaCore.COMPILER_TASK_TAGS, JavaCore.DEFAULT_TASK_TAGS);
View Full Code Here

    }
  }

  // Do not modify without modifying getDefaultOptions()
  private Hashtable getDefaultOptionsNoInitialization() {
    Map defaultOptionsMap = new CompilerOptions().getMap(); // compiler defaults

    // Override some compiler defaults
    defaultOptionsMap.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE);
    defaultOptionsMap.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE);
    defaultOptionsMap.put(JavaCore.COMPILER_TASK_TAGS, JavaCore.DEFAULT_TASK_TAGS);
View Full Code Here

  public void setOptions(Hashtable newOptions) {
   
    if (DEBUG_302850) {
      System.out.println("Entering in JavaModelManager.setOptions():"); //$NON-NLS-1$
      System.out.println(new CompilerOptions(newOptions).toString());
      System.out.println("  - Call stack:"); //$NON-NLS-1$
      StackTraceElement[] elements = new Exception().getStackTrace();
      for (int i=0,n=elements.length; i<n; i++) {
        System.out.println("    + "+elements[i]); //$NON-NLS-1$
      }
View Full Code Here

  }

  public ClassFile(SourceTypeBinding typeBinding) {
    // default constructor for subclasses
    this.constantPool = new ConstantPool(this);
    final CompilerOptions options = typeBinding.scope.compilerOptions();
    this.targetJDK = options.targetJDK;
    this.produceAttributes = options.produceDebugAttributes;
    this.referenceBinding = typeBinding;
    this.isNestedType = typeBinding.isNestedType();
    if (this.targetJDK >= ClassFileConstants.JDK1_6) {
View Full Code Here

    }
  }

  public void reset(SourceTypeBinding typeBinding) {
    // the code stream is reinitialized for each method
    final CompilerOptions options = typeBinding.scope.compilerOptions();
    this.referenceBinding = typeBinding;
    this.isNestedType = typeBinding.isNestedType();
    this.targetJDK = options.targetJDK;
    this.produceAttributes = options.produceDebugAttributes;
    if (this.targetJDK >= ClassFileConstants.JDK1_6) {
View Full Code Here

  if (this.suppressWarningsCount == 0) return;
  int removed = 0;
  CategorizedProblem[] problems = this.compilationResult.problems;
  int problemCount = this.compilationResult.problemCount;
  IrritantSet[] foundIrritants = new IrritantSet[this.suppressWarningsCount];
  CompilerOptions options = this.scope.compilerOptions();
  boolean hasMandatoryErrors = false;
  nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) {
    CategorizedProblem problem = problems[iProblem];
    int problemID = problem.getID();
    int irritant = ProblemReporter.getIrritant(problemID);
    boolean isError = problem.isError();
    if (isError) {
      if (irritant == 0) {
        // tolerate unused warning tokens when mandatory errors
        hasMandatoryErrors = true;
        continue;
      }
      if (!options.suppressOptionalErrors) {
        continue;
      }
    }
    int start = problem.getSourceStart();
    int end = problem.getSourceEnd();
    nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
      long position = this.suppressWarningScopePositions[iSuppress];
      int startSuppress = (int) (position >>> 32);
      int endSuppress = (int) position;
      if (start < startSuppress) continue nextSuppress;
      if (end > endSuppress) continue nextSuppress;
      if (!this.suppressWarningIrritants[iSuppress].isSet(irritant))
        continue nextSuppress;
      // discard suppressed warning
      removed++;
      problems[iProblem] = null;
      this.compilationResult.removeProblem(problem);
      if (foundIrritants[iSuppress] == null){
        foundIrritants[iSuppress] = new IrritantSet(irritant);
      } else {
        foundIrritants[iSuppress].set(irritant);
      }
      continue nextProblem;
    }
  }
  // compact remaining problems
  if (removed > 0) {
    for (int i = 0, index = 0; i < problemCount; i++) {
      CategorizedProblem problem;
      if ((problem = problems[i]) != null) {
        if (i > index) {
          problems[index++] = problem;
        } else {
          index++;
        }
      }
    }
  }
  // flag SuppressWarnings which had no effect (only if no (mandatory) error got detected within unit
  if (!hasMandatoryErrors) {
    int severity = options.getSeverity(CompilerOptions.UnusedWarningToken);
    if (severity != ProblemSeverities.Ignore) {
      boolean unusedWarningTokenIsWarning = (severity & ProblemSeverities.Error) == 0;
      for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
        Annotation annotation = this.suppressWarningAnnotations[iSuppress];
        if (annotation == null) continue; // implicit annotation
        IrritantSet irritants = this.suppressWarningIrritants[iSuppress];
        if (unusedWarningTokenIsWarning && irritants.areAllSet()) continue; // @SuppressWarnings("all") also suppresses unused warning token
        if (irritants != foundIrritants[iSuppress]) { // mismatch, some warning tokens were unused
          MemberValuePair[] pairs = annotation.memberValuePairs();
          pairLoop: for (int iPair = 0, pairCount = pairs.length; iPair < pairCount; iPair++) {
            MemberValuePair pair = pairs[iPair];
            if (CharOperation.equals(pair.name, TypeConstants.VALUE)) {
              Expression value = pair.value;
              if (value instanceof ArrayInitializer) {
                ArrayInitializer initializer = (ArrayInitializer) value;
                Expression[] inits = initializer.expressions;
                if (inits != null) {
                  for (int iToken = 0, tokenCount = inits.length; iToken < tokenCount; iToken++) {
                    Constant cst = inits[iToken].constant;
                    if (cst != Constant.NotAConstant && cst.typeID() == TypeIds.T_JavaLangString) {
                      IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
                      if (tokenIrritants != null
                          && !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
                          && options.isAnyEnabled(tokenIrritants) // if irritant is effectively enabled
                          && (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
                        if (unusedWarningTokenIsWarning) {
                          int start = value.sourceStart, end = value.sourceEnd;
                          nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
                            long position = this.suppressWarningScopePositions[jSuppress];
                            int startSuppress = (int) (position >>> 32);
                            int endSuppress = (int) position;
                            if (start < startSuppress) continue nextSuppress;
                            if (end > endSuppress) continue nextSuppress;
                            if (this.suppressWarningIrritants[jSuppress].areAllSet()) break pairLoop; // suppress all?
                          }
                        }
                        this.scope.problemReporter().unusedWarningToken(inits[iToken]);
                      }
                    }
                  }
                }
              } else {
                Constant cst = value.constant;
                if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
                  IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
                  if (tokenIrritants != null
                      && !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
                      && options.isAnyEnabled(tokenIrritants) // if irritant is effectively enabled
                      && (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
                    if (unusedWarningTokenIsWarning) {
                      int start = value.sourceStart, end = value.sourceEnd;
                      nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
                        long position = this.suppressWarningScopePositions[jSuppress];
View Full Code Here

protected abstract char[] getClassName();
/**
* Creates and returns a compiler for this evaluator.
*/
Compiler getCompiler(ICompilerRequestor compilerRequestor) {
  CompilerOptions compilerOptions = new CompilerOptions(this.options);
  compilerOptions.performMethodsFullRecovery = true;
  compilerOptions.performStatementsRecovery = true;
  return new Compiler(
    this.environment,
    DefaultErrorHandlingPolicies.exitAfterAllProblems(),
View Full Code Here

    ast.setOriginalModificationCount(ast.modificationCount());
    return compilationUnit;
  }

  protected static CompilerOptions getCompilerOptions(Map options, boolean statementsRecovery) {
    CompilerOptions compilerOptions = new CompilerOptions(options);
    compilerOptions.performMethodsFullRecovery = statementsRecovery;
    compilerOptions.performStatementsRecovery = statementsRecovery;
    compilerOptions.parseLiteralExpressionsAsConstants = false;
    compilerOptions.storeAnnotations = true /*store annotations in the bindings*/;
    return compilerOptions;
View Full Code Here

    this.hasCompilationAborted = true;
  }

  public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, 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

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.