Browse Source

set default warning values correctly when passed in 'null'

tags/for_ajdt1_1_12
acolyer 20 years ago
parent
commit
b2e2422ea5
1 changed files with 51 additions and 32 deletions
  1. 51
    32
      ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java

+ 51
- 32
ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java View File

@@ -28,7 +28,21 @@ import org.aspectj.util.LangUtil;
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;
@@ -151,22 +165,24 @@ public class CompilerAdapter {
= 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) {
@@ -182,7 +198,7 @@ public class CompilerAdapter {
// 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);
@@ -238,17 +254,17 @@ public class CompilerAdapter {
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();
@@ -257,8 +273,8 @@ public class CompilerAdapter {
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();
@@ -268,19 +284,22 @@ public class CompilerAdapter {
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();
@@ -305,11 +324,11 @@ public class CompilerAdapter {
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
@@ -319,7 +338,7 @@ public class CompilerAdapter {
// }
if ( options.getPreserveAllLocals() ) {
javaOptions.put( CompilerOptions.OPTION_PreserveUnusedLocal,
optionsToSet.put( CompilerOptions.OPTION_PreserveUnusedLocal,
CompilerOptions.PRESERVE);
}
if ( !config.isIncrementalMode()
@@ -327,7 +346,7 @@ public class CompilerAdapter {
config.setIncrementalMode(true);
}
config.setJavaOptions( javaOptions );
config.getOptions().set(optionsToSet);
String toAdd = options.getNonStandardOptions();
return LangUtil.isEmpty(toAdd)
? true

Loading…
Cancel
Save