List of usage examples for org.eclipse.jdt.internal.compiler.impl CompilerOptions DO_NOT_GENERATE
String DO_NOT_GENERATE
To view the source code for org.eclipse.jdt.internal.compiler.impl CompilerOptions DO_NOT_GENERATE.
Click Source Link
From source file:dacapo.eclipse.EclipseBuildTests.java
License:Open Source License
protected static Hashtable warningOptions(int kind) { // Values/*from ww w .j a v a2s. c o m*/ Hashtable optionsMap = null; switch (kind) { case 0: optionsMap = JavaCore.getDefaultOptions(); break; default: optionsMap = new Hashtable(350); break; } if (kind == 0) { // Default set since 3.1 optionsMap.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.IGNORE); } else { boolean all = kind == 1; String generate = all ? CompilerOptions.GENERATE : CompilerOptions.DO_NOT_GENERATE; String warning = all ? CompilerOptions.WARNING : CompilerOptions.IGNORE; String enabled = all ? CompilerOptions.ENABLED : CompilerOptions.DISABLED; String preserve = all ? CompilerOptions.OPTIMIZE_OUT : CompilerOptions.PRESERVE; // Set options values optionsMap.put(CompilerOptions.OPTION_LocalVariableAttribute, generate); optionsMap.put(CompilerOptions.OPTION_LineNumberAttribute, generate); optionsMap.put(CompilerOptions.OPTION_SourceFileAttribute, generate); optionsMap.put(CompilerOptions.OPTION_PreserveUnusedLocal, preserve); optionsMap.put(CompilerOptions.OPTION_DocCommentSupport, enabled); optionsMap.put(CompilerOptions.OPTION_ReportMethodWithConstructorName, warning); optionsMap.put(CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, warning); optionsMap.put(CompilerOptions.OPTION_ReportDeprecation, warning); optionsMap.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, enabled); optionsMap.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, enabled); optionsMap.put(CompilerOptions.OPTION_ReportHiddenCatchBlock, warning); optionsMap.put(CompilerOptions.OPTION_ReportUnusedLocal, warning); optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameter, warning); optionsMap.put(CompilerOptions.OPTION_ReportUnusedImport, warning); optionsMap.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, warning); optionsMap.put(CompilerOptions.OPTION_ReportNoEffectAssignment, warning); optionsMap.put(CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, warning); optionsMap.put(CompilerOptions.OPTION_ReportNoImplicitStringConversion, warning); optionsMap.put(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, warning); optionsMap.put(CompilerOptions.OPTION_ReportIndirectStaticAccess, warning); optionsMap.put(CompilerOptions.OPTION_ReportIncompatibleNonInheritedInterfaceMethod, warning); optionsMap.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, warning); optionsMap.put(CompilerOptions.OPTION_ReportLocalVariableHiding, warning); optionsMap.put(CompilerOptions.OPTION_ReportFieldHiding, warning); optionsMap.put(CompilerOptions.OPTION_ReportPossibleAccidentalBooleanAssignment, warning); optionsMap.put(CompilerOptions.OPTION_ReportEmptyStatement, warning); optionsMap.put(CompilerOptions.OPTION_ReportAssertIdentifier, warning); optionsMap.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, warning); optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, warning); optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryElse, warning); optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadoc, warning); optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, enabled); optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocTags, warning); optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadocComments, warning); optionsMap.put(CompilerOptions.OPTION_ReportFinallyBlockNotCompletingNormally, warning); optionsMap.put(CompilerOptions.OPTION_ReportUnusedDeclaredThrownException, warning); optionsMap.put(CompilerOptions.OPTION_ReportUnqualifiedFieldAccess, warning); optionsMap.put(CompilerOptions.OPTION_TaskTags, all ? JavaCore.DEFAULT_TASK_TAGS : ""); optionsMap.put(CompilerOptions.OPTION_TaskPriorities, all ? JavaCore.DEFAULT_TASK_PRIORITIES : ""); optionsMap.put(CompilerOptions.OPTION_TaskCaseSensitive, enabled); optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, enabled); optionsMap.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, enabled); optionsMap.put(CompilerOptions.OPTION_ReportSpecialParameterHidingField, enabled); optionsMap.put(CompilerOptions.OPTION_InlineJsr, enabled); } // Ignore 3.1 options optionsMap.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.IGNORE); optionsMap.put(CompilerOptions.OPTION_ReportEnumIdentifier, CompilerOptions.IGNORE); // Return created options map return optionsMap; }
From source file:io.takari.maven.plugins.compile.jdt.CompilerJdt.java
License:Open Source License
@Override public int compile() throws MojoExecutionException, IOException { Map<String, String> args = new HashMap<String, String>(); // XXX figure out how to reuse source/target check from jdt // org.eclipse.jdt.internal.compiler.batch.Main.validateOptions(boolean) args.put(CompilerOptions.OPTION_TargetPlatform, getTarget()); // support 5/6/7 aliases args.put(CompilerOptions.OPTION_Compliance, getTarget()); // support 5/6/7 aliases args.put(CompilerOptions.OPTION_Source, getSource()); // support 5/6/7 aliases args.put(CompilerOptions.OPTION_ReportForbiddenReference, CompilerOptions.ERROR); Set<Debug> debug = getDebug(); if (debug == null || debug.contains(Debug.all)) { args.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); args.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); args.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); } else if (debug.contains(Debug.none)) { args.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); args.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); args.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE); } else {/*from w w w .ja va 2s . c o m*/ args.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); args.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); args.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE); for (Debug keyword : debug) { switch (keyword) { case lines: args.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); break; case source: args.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); break; case vars: args.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); break; default: throw new IllegalArgumentException(); } } } class _CompilerOptions extends CompilerOptions { public void setShowWarnings(boolean showWarnings) { if (showWarnings) { warningThreshold = IrritantSet.COMPILER_DEFAULT_WARNINGS; } else { warningThreshold = new IrritantSet(0); } } } _CompilerOptions compilerOptions = new _CompilerOptions(); compilerOptions.set(args); compilerOptions.performMethodsFullRecovery = false; compilerOptions.performStatementsRecovery = false; compilerOptions.verbose = isVerbose(); compilerOptions.suppressWarnings = true; compilerOptions.setShowWarnings(isShowWarnings()); compilerOptions.docCommentSupport = true; if (isProcEscalate() && strategy instanceof IncrementalCompilationStrategy) { strategy.enqueueAllSources(); strategy = new FullCompilationStrategy(); } Classpath namingEnvironment = strategy.createClasspath(); IErrorHandlingPolicy errorHandlingPolicy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); IProblemFactory problemFactory = ProblemFactory.getProblemFactory(Locale.getDefault()); Compiler compiler = new Compiler(namingEnvironment, errorHandlingPolicy, compilerOptions, this, problemFactory); compiler.options.produceReferenceInfo = true; EclipseFileManager fileManager = null; try { if (!isProcNone()) { fileManager = new EclipseFileManager(null, getSourceEncoding()); fileManager.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, dependencies); fileManager.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(getOutputDirectory())); fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(getGeneratedSourcesDirectory())); ProcessingEnvImpl processingEnv = new ProcessingEnvImpl(context, fileManager, getAnnotationProcessorOptions(), compiler, this); compiler.annotationProcessorManager = new AnnotationProcessorManager(processingEnv, fileManager, getAnnotationProcessors()); compiler.options.storeAnnotations = true; } return strategy.compile(namingEnvironment, compiler); } finally { if (fileManager != null) { fileManager.flush(); fileManager.close(); } } }
From source file:org.ant4eclipse.ant.jdt.ecj.CompilerOptionsProvider.java
License:Open Source License
/** * <p>//from www. ja v a 2s. c o m * Returns the compiler options specified in the javac task. * </p> * * @param javac * the javac task * @return the compiler options specified in the javac task. */ @SuppressWarnings("unchecked") private static final StringMap getJavacCompilerOptions(Javac javac) { StringMap result = new StringMap(); /* * set the source option */ if (Utilities.hasText(javac.getSource())) { // get the source String source = javac.getSource(); // set the source if (source.equals("1.3")) { result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3); } else if (source.equals("1.4")) { result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); } else if (source.equals("1.5") || source.equals("5") || source.equals("5.0")) { result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); } else if (source.equals("1.6") || source.equals("6") || source.equals("6.0")) { result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); } else if (source.equals("1.7") || source.equals("7") || source.equals("7.0")) { result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); } else if (source.equals("1.8") || source.equals("8") || source.equals("8.0")) { result.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_8); } else { throw new Ant4EclipseException(EcjExceptionCodes.UNKNOWN_JAVA_SOURCE_OPTION_EXCEPTION, source); } } /* * set the target option */ if (Utilities.hasText(javac.getTarget())) { // get the target String target = javac.getTarget(); // set the target if (target.equals("1.3")) { result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_3); result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3); } else if (target.equals("1.4")) { result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4); result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); } else if (target.equals("1.5") || target.equals("5") || target.equals("5.0")) { result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); } else if (target.equals("1.6") || target.equals("6") || target.equals("6.0")) { result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); } else if (target.equals("1.7") || target.equals("7") || target.equals("7.0")) { result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); } else if (target.equals("1.8") || target.equals("8") || target.equals("8.0")) { result.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_8); result.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_8); } else { throw new Ant4EclipseException(EcjExceptionCodes.UNKNOWN_JAVA_TARGET_OPTION_EXCEPTION, target); } } /* * set the debug options */ if (javac.getDebug()) { String debugLevel = javac.getDebugLevel(); if (debugLevel != null) { result.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); result.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); result.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE); if (debugLevel.length() != 0) { if (debugLevel.indexOf("vars") != -1) { result.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); } if (debugLevel.indexOf("lines") != -1) { result.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); } if (debugLevel.indexOf("source") != -1) { result.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); } } } else { result.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE); result.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); result.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.GENERATE); } } else { result.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE); result.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE); result.put(CompilerOptions.OPTION_SourceFileAttribute, CompilerOptions.DO_NOT_GENERATE); } /* * Handle the nowarn option. If none, then we generate all warnings. */ if (javac.getNowarn()) { // disable all warnings Map.Entry<String, String>[] entries = result.entrySet().toArray(new Map.Entry[result.size()]); for (Entry<String, String> entrie : entries) { Map.Entry<String, String> entry = entrie; if (entry.getValue().equals(CompilerOptions.WARNING)) { result.put(entry.getKey(), CompilerOptions.IGNORE); } } result.put(CompilerOptions.OPTION_TaskTags, Util.EMPTY_STRING); if (javac.getDeprecation()) { result.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING); result.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED); result.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.ENABLED); } } else if (javac.getDeprecation()) { result.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING); result.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED); result.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.ENABLED); } else { result.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE); result.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED); result.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED); } /* * set the encoding option */ if (javac.getEncoding() != null) { result.put(CompilerOptions.OPTION_Encoding, javac.getEncoding()); } // return result return result; }
From source file:org.apache.commons.jci.compilers.EclipseJavaCompilerSettings.java
License:Apache License
Map<String, String> toNativeSettings() {
final Map<String, String> map = new HashMap<String, String>(defaultEclipseSettings);
map.put(CompilerOptions.OPTION_SuppressWarnings,
isWarnings() ? CompilerOptions.GENERATE : CompilerOptions.DO_NOT_GENERATE);
map.put(CompilerOptions.OPTION_ReportDeprecation,
isDeprecations() ? CompilerOptions.GENERATE : CompilerOptions.DO_NOT_GENERATE);
map.put(CompilerOptions.OPTION_TargetPlatform, toNativeVersion(getTargetVersion()));
map.put(CompilerOptions.OPTION_Source, toNativeVersion(getSourceVersion()));
map.put(CompilerOptions.OPTION_Encoding, getSourceEncoding());
return map;//from w ww. jav a 2 s . c om
}
From source file:org.apache.commons.jci.compilers.EclipseJavaCompilerSettingsTestCase.java
License:Apache License
public void testDefaultSettings() { final Map<String, String> m = new EclipseJavaCompilerSettings().toNativeSettings(); assertEquals(CompilerOptions.DO_NOT_GENERATE, m.get(CompilerOptions.OPTION_SuppressWarnings)); assertEquals(CompilerOptions.DO_NOT_GENERATE, m.get(CompilerOptions.OPTION_ReportDeprecation)); assertEquals(CompilerOptions.VERSION_1_4, m.get(CompilerOptions.OPTION_TargetPlatform)); assertEquals(CompilerOptions.VERSION_1_4, m.get(CompilerOptions.OPTION_Source)); assertEquals("UTF-8", m.get(CompilerOptions.OPTION_Encoding)); }
From source file:org.apache.commons.jci.compilers.EclipseJavaCompilerSettingsTestCase.java
License:Apache License
public void testWarnings() { final EclipseJavaCompilerSettings s = new EclipseJavaCompilerSettings(); s.setWarnings(true);//from w ww .j a va 2 s .co m assertEquals(CompilerOptions.GENERATE, s.toNativeSettings().get(CompilerOptions.OPTION_SuppressWarnings)); s.setWarnings(false); assertEquals(CompilerOptions.DO_NOT_GENERATE, s.toNativeSettings().get(CompilerOptions.OPTION_SuppressWarnings)); }
From source file:org.apache.commons.jci.compilers.EclipseJavaCompilerSettingsTestCase.java
License:Apache License
public void testDeprecations() { final EclipseJavaCompilerSettings s = new EclipseJavaCompilerSettings(); s.setDeprecations(true);/*w w w . j a va 2s .c o m*/ assertEquals(CompilerOptions.GENERATE, s.toNativeSettings().get(CompilerOptions.OPTION_ReportDeprecation)); s.setDeprecations(false); assertEquals(CompilerOptions.DO_NOT_GENERATE, s.toNativeSettings().get(CompilerOptions.OPTION_ReportDeprecation)); }