import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class CompilerAdapter {
-
+
+ private static final Set DEFAULT__AJDE_WARNINGS;
+
+ static {
+ DEFAULT__AJDE_WARNINGS = new HashSet();
+ DEFAULT__AJDE_WARNINGS.add(BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER);
+ DEFAULT__AJDE_WARNINGS.add(BuildOptionsAdapter.WARN_CONSTRUCTOR_NAME);
+ DEFAULT__AJDE_WARNINGS.add(BuildOptionsAdapter.WARN_DEPRECATION);
+ DEFAULT__AJDE_WARNINGS.add(BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS);
+ DEFAULT__AJDE_WARNINGS.add(BuildOptionsAdapter.WARN_PACKAGE_DEFAULT_METHOD);
+ DEFAULT__AJDE_WARNINGS.add(BuildOptionsAdapter.WARN_UNUSED_IMPORTS);
+// DEFAULT__AJDE_WARNINGS.put(BuildOptionsAdapter.WARN_);
+// DEFAULT__AJDE_WARNINGS.put(BuildOptionsAdapter.WARN_);
+ }
+
// private Map optionsMap;
private AjBuildManager buildManager = null;
private MessageHandlerAdapter messageHandler = null;
= CountingMessageHandler.makeCountingMessageHandler(messageHandler);
BuildArgParser parser = new BuildArgParser(handler);
- AjBuildConfig config = parser.genBuildConfig(args, false, configFile);
+ AjBuildConfig config = new AjBuildConfig();
+ parser.populateBuildConfig(config, args, false, configFile);
+ configureBuildOptions(config,Ajde.getDefault().getBuildManager().getBuildOptions(),handler);
configureProjectOptions(config, Ajde.getDefault().getProjectProperties()); // !!! not what the API intended
- // -- get globals, treat as defaults used if no local values
- AjBuildConfig global = new AjBuildConfig();
- // AMC refactored into two methods to populate buildConfig from buildOptions and
- // project properties - bugzilla 29769.
- BuildOptionsAdapter buildOptions
- = Ajde.getDefault().getBuildManager().getBuildOptions();
- if (!configureBuildOptions(global, buildOptions, handler)) {
- return null;
- }
- ProjectPropertiesAdapter projectOptions =
- Ajde.getDefault().getProjectProperties();
- configureProjectOptions(global, projectOptions);
- config.installGlobals(global);
+// // -- get globals, treat as defaults used if no local values
+// AjBuildConfig global = new AjBuildConfig();
+// // AMC refactored into two methods to populate buildConfig from buildOptions and
+// // project properties - bugzilla 29769.
+// BuildOptionsAdapter buildOptions
+// = Ajde.getDefault().getBuildManager().getBuildOptions();
+// if (!configureBuildOptions(/* global */ config, buildOptions, handler)) {
+// return null;
+// }
+// ProjectPropertiesAdapter projectOptions =
+// Ajde.getDefault().getProjectProperties();
+// configureProjectOptions(global, projectOptions);
+// config.installGlobals(global);
ISourceLocation location = null;
if (config.getConfigFile() != null) {
// always force model generation in AJDE
config.setGenerateModelMode(true);
if (Ajde.getDefault().getBuildManager().getBuildOptions().getJavaOptionsMap() != null) {
- config.getJavaOptions().putAll(Ajde.getDefault().getBuildManager().getBuildOptions().getJavaOptionsMap());
+ config.getOptions().set(Ajde.getDefault().getBuildManager().getBuildOptions().getJavaOptionsMap());
}
return config;
// return fixupBuildConfig(config);
private static boolean configureBuildOptions( AjBuildConfig config, BuildOptionsAdapter options, IMessageHandler handler) {
LangUtil.throwIaxIfNull(options, "options");
LangUtil.throwIaxIfNull(config, "config");
- Map javaOptions = config.getJavaOptions();
- LangUtil.throwIaxIfNull(javaOptions, "javaOptions");
+ Map optionsToSet = new HashMap();
+ LangUtil.throwIaxIfNull(optionsToSet, "javaOptions");
if (options.getSourceOnePointFourMode()) {
- javaOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
- javaOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
+ optionsToSet.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
+ optionsToSet.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
}
String enc = options.getCharacterEncoding();
if (!LangUtil.isEmpty(enc)) {
- javaOptions.put(CompilerOptions.OPTION_Encoding, enc );
+ optionsToSet.put(CompilerOptions.OPTION_Encoding, enc );
}
String compliance = options.getComplianceLevel();
if ( compliance.equals( BuildOptionsAdapter.VERSION_13 ) ) {
version = CompilerOptions.VERSION_1_3;
}
- javaOptions.put(CompilerOptions.OPTION_Compliance, version );
- javaOptions.put(CompilerOptions.OPTION_Source, version );
+ optionsToSet.put(CompilerOptions.OPTION_Compliance, version );
+ optionsToSet.put(CompilerOptions.OPTION_Source, version );
}
String sourceLevel = options.getSourceCompatibilityLevel();
slVersion = CompilerOptions.VERSION_1_3;
}
// never set a lower source level than compliance level
- String setCompliance = (String) javaOptions.get( CompilerOptions.OPTION_Compliance);
+ String setCompliance = (String) optionsToSet.get( CompilerOptions.OPTION_Compliance);
if ( ! (setCompliance.equals( CompilerOptions.VERSION_1_4 )
&& slVersion.equals(CompilerOptions.VERSION_1_3)) ) {
- javaOptions.put(CompilerOptions.OPTION_Source, slVersion);
+ optionsToSet.put(CompilerOptions.OPTION_Source, slVersion);
}
}
Set warnings = options.getWarnings();
if (!LangUtil.isEmpty(warnings)) {
// turn off all warnings
- disableWarnings( javaOptions );
+ disableWarnings( optionsToSet );
// then selectively enable those in the set
- enableWarnings( javaOptions, warnings );
+ enableWarnings( optionsToSet, warnings );
+ } else if (warnings == null) {
+ // set default warnings on...
+ enableWarnings( optionsToSet, DEFAULT__AJDE_WARNINGS);
}
Set debugOptions = options.getDebugLevel();
varAttr = true;
}
}
- if (sourceLine) javaOptions.put(CompilerOptions.OPTION_SourceFileAttribute,
+ if (sourceLine) optionsToSet.put(CompilerOptions.OPTION_SourceFileAttribute,
CompilerOptions.GENERATE);
- if (varAttr) javaOptions.put(CompilerOptions.OPTION_LocalVariableAttribute,
+ if (varAttr) optionsToSet.put(CompilerOptions.OPTION_LocalVariableAttribute,
CompilerOptions.GENERATE);
- if (lineNo) javaOptions.put(CompilerOptions.OPTION_LineNumberAttribute,
+ if (lineNo) optionsToSet.put(CompilerOptions.OPTION_LineNumberAttribute,
CompilerOptions.GENERATE);
}
//XXX we can't turn off import errors in 3.0 stream
// }
if ( options.getPreserveAllLocals() ) {
- javaOptions.put( CompilerOptions.OPTION_PreserveUnusedLocal,
+ optionsToSet.put( CompilerOptions.OPTION_PreserveUnusedLocal,
CompilerOptions.PRESERVE);
}
if ( !config.isIncrementalMode()
config.setIncrementalMode(true);
}
- config.setJavaOptions( javaOptions );
+ config.getOptions().set(optionsToSet);
String toAdd = options.getNonStandardOptions();
return LangUtil.isEmpty(toAdd)
? true