Example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions toString

List of usage examples for org.eclipse.jdt.internal.compiler.impl CompilerOptions toString

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.ant4eclipse.ant.jdt.ecj.CompilerOptionsProvider.java

License:Open Source License

/**
 * <p>/*from w  w w  . j a v  a 2  s  .co m*/
 * Creates the compiler options for the JDT compiler.
 * </p>
 * <p>
 * The compiler options are defined here:
 * <ul>
 * <li><a href="http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.isv/guide/jdt_api_options.htm">JDT Core
 * options</a></li>
 * <li><a href=
 * "http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.user/reference/preferences/java/ref-preferences-compiler.htm"
 * >Java Compiler Preferences </a></li>
 * <li><a href="http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.user/reference/preferences/java/compiler/ref-preferences-errors-warnings.htm"
 * >Java Compiler Errors/Warnings Preferences</a></li>
 * </ul>
 * </p>
 * 
 * @param javac
 *          the javac task
 * @param projectCompilerOptionsFile
 *          the project specific compiler options file.
 * @param globalCompilerOptionsFile
 *          the global compiler options file.
 * 
 * @return the map with the merged compiler options.
 */
@SuppressWarnings("unchecked")
public static final StringMap getCompilerOptions(Javac javac, String projectCompilerOptionsFile,
        String globalCompilerOptionsFile) {
    Assure.notNull("javac", javac);

    // get the project options
    StringMap projectOptions = getFileCompilerOptions(projectCompilerOptionsFile);
    if (A4ELogging.isTraceingEnabled()) {
        A4ELogging.trace("Read projectOptions from '%s': '%s'.", projectCompilerOptionsFile, projectOptions);
    }
    // get the default options
    StringMap defaultOptions = getFileCompilerOptions(globalCompilerOptionsFile);
    if (A4ELogging.isTraceingEnabled()) {
        A4ELogging.trace("Read defaultOptions from '%s': '%s'.", globalCompilerOptionsFile, defaultOptions);
    }
    // get the javac options
    StringMap javacOptions = getJavacCompilerOptions(javac);
    if (A4ELogging.isTraceingEnabled()) {
        A4ELogging.trace("javacOptions: '%s'.", javacOptions);
    }
    // merge the map
    StringMap mergedMap = mergeCompilerOptions(projectOptions, defaultOptions, javacOptions);
    if (A4ELogging.isTraceingEnabled()) {
        A4ELogging.trace("mergedMap: '%s'.", mergedMap);
    }

    // [AE-201] If not enabled/disabled explicitly, enable ECJ javadoc parsing support
    // to find references inside javadoc
    if (!mergedMap.containsKey(ENABLE_JAVADOC_SUPPORT)) {
        mergedMap.put(ENABLE_JAVADOC_SUPPORT, "enabled");
    }

    // If not enabled/disabled explicitly, set ECJ forbidden reference to 'error
    if (!mergedMap.containsKey(FORBIDDEN_REFERENCE)) {
        mergedMap.put(FORBIDDEN_REFERENCE, "error");
    }

    // create result
    CompilerOptions compilerOptions = new CompilerOptions(mergedMap);

    // verbose option
    compilerOptions.verbose = javac.getVerbose();

    // debug the compiler options
    if (A4ELogging.isDebuggingEnabled()) {
        A4ELogging.debug("Using the following compile options:\n %s", compilerOptions.toString());
    }

    // return the compiler options
    StringMap result = new StringMap();
    result.putAll(compilerOptions.getMap());
    return result;
}

From source file:org.thiesen.ecj4ant.EcjTask.java

License:Open Source License

@Override
public void execute() {
    final long startTime = System.currentTimeMillis();

    final List<String> sourceFilenames = getSourceFilenames();
    final List<String> classPathEntries = getClassPathEntries();

    final FileSystem environment = getLibraryAccess(sourceFilenames, classPathEntries);

    log("Checking " + sourceFilenames.size() + " source files");

    final CompilerOptions compilerOptions = makeCompilerOptions();

    log(compilerOptions.toString(), Project.MSG_VERBOSE);

    final BatchRequestor requestor = getBatchRequestor();

    final Compiler batchCompiler = new Compiler(environment, getHandlingPolicy(), compilerOptions, requestor,
            getProblemFactory(), getOutputWrapper(), null);

    compilerOptions.verbose = false;// w  ww.  j  av a2s  .co  m

    batchCompiler.compile(getCompilationUnits(sourceFilenames));

    // cleanup
    environment.cleanup();

    final long endTime = System.currentTimeMillis() - startTime;

    log("Compile finished after " + endTime + "ms with " + requestor.getErrors() + " errors, "
            + requestor.getWarnings() + " warnings and " + requestor.getInfos() + " info messages");

    checkFailErrors(requestor.getErrors());
    checkFailWarnings(requestor.getWarnings());
}