import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import org.aspectj.ajdt.internal.compiler.CompilationResultDestinationManager;
import org.aspectj.util.FileUtil;
private File configFile;
private String lintMode = AJLINT_DEFAULT;
+ private Map<String,String> lintOptionsMap = null;
private File lintSpecFile = null;
private int changes = EVERYTHING; // bitflags, see CompilerConfigurationChangeFlags
public String getLintMode() {
return lintMode;
}
+
+ public Map<String,String> getLintOptionsMap() {
+ return lintOptionsMap;
+ }
// options...
public void setLintMode(String lintMode) {
- this.lintMode = lintMode;
String lintValue = null;
+ this.lintMode = lintMode;
if (AJLINT_IGNORE.equals(lintMode)) {
lintValue = AjCompilerOptions.IGNORE;
} else if (AJLINT_WARN.equals(lintMode)) {
lintValue = AjCompilerOptions.WARNING;
} else if (AJLINT_ERROR.equals(lintMode)) {
lintValue = AjCompilerOptions.ERROR;
+ } else {
+ // Possibly a name=value comma separated list of configurations
+ if (lintMode.indexOf("=")!=-1) {
+ this.lintMode = AJLINT_DEFAULT;
+ lintOptionsMap = new HashMap<String,String>();
+ StringTokenizer tokenizer = new StringTokenizer(lintMode,",");
+ while (tokenizer.hasMoreElements()) {
+ String option = tokenizer.nextToken();
+ int equals = option.indexOf("=");
+ if (equals!=-1) {
+ String key = option.substring(0,equals);
+ String value = option.substring(equals+1);
+ lintOptionsMap.put(key,value);
+ }
+ }
+ }
}
- if (lintValue != null) {
+ if (lintValue != null || lintOptionsMap != null ) {
Map<String, String> lintOptions = new HashMap<String, String>();
- lintOptions.put(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName, lintValue);
- lintOptions.put(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName, lintValue);
- lintOptions.put(AjCompilerOptions.OPTION_ReportUnresolvableMember, lintValue);
- lintOptions.put(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver, lintValue);
- lintOptions.put(AjCompilerOptions.OPTION_ReportShadowNotInStructure, lintValue);
- lintOptions.put(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall, lintValue);
- lintOptions.put(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP, lintValue);
- lintOptions.put(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField, lintValue);
- lintOptions.put(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion, lintValue);
+ setOption(AjCompilerOptions.OPTION_ReportInvalidAbsoluteTypeName, lintValue, lintOptions);
+ setOption(AjCompilerOptions.OPTION_ReportInvalidWildcardTypeName, lintValue, lintOptions);
+ setOption(AjCompilerOptions.OPTION_ReportUnresolvableMember, lintValue, lintOptions);
+ setOption(AjCompilerOptions.OPTION_ReportTypeNotExposedToWeaver, lintValue, lintOptions);
+ setOption(AjCompilerOptions.OPTION_ReportShadowNotInStructure, lintValue, lintOptions);
+ setOption(AjCompilerOptions.OPTION_ReportUnmatchedSuperTypeInCall, lintValue, lintOptions);
+ setOption(AjCompilerOptions.OPTION_ReportCannotImplementLazyTJP, lintValue, lintOptions);
+ setOption(AjCompilerOptions.OPTION_ReportNeedSerialVersionUIDField, lintValue, lintOptions);
+ setOption(AjCompilerOptions.OPTION_ReportIncompatibleSerialVersion, lintValue, lintOptions);
options.set(lintOptions);
}
}
+ private void setOption(String optionKey, String lintValue, Map<String,String> lintOptionsAccumulator) {
+ if (lintOptionsMap!=null && lintOptionsMap.containsKey(optionKey)) {
+ String v = lintOptionsMap.get(lintOptionsMap);
+ if (AJLINT_IGNORE.equals(v)) {
+ lintValue = AjCompilerOptions.IGNORE;
+ } else if (AJLINT_WARN.equals(v)) {
+ lintValue = AjCompilerOptions.WARNING;
+ } else if (AJLINT_ERROR.equals(v)) {
+ lintValue = AjCompilerOptions.ERROR;
+ }
+ }
+ if (lintValue != null) {
+ lintOptionsAccumulator.put(optionKey,lintValue);
+ }
+ }
+
public boolean isTerminateAfterCompilation() {
return options.terminateAfterCompilation;
}
<suite>
+ <ajc-test dir="bugs174/pr419279" title="more configurable lint">
+ <compile files="Code.java" options="-1.5">
+ <message kind="warning" text="advice defined in Code has not been applied [Xlint:adviceDidNotMatch]"/>
+ </compile>
+ <compile files="Code.java" options="-1.5 -Xlint:adviceDidNotMatch=ignore">
+ </compile>
+ <compile files="Code.java" options="-1.5 -Xlint:adviceDidNotMatch=error">
+ <message kind="error" text="advice defined in Code has not been applied [Xlint:adviceDidNotMatch]"/>
+ </compile>
+ <compile files="Code.java" options="-1.5 -Xlint:foo=bar">
+ <message kind="error" text="invalid Xlint key: foo"/>
+ </compile>
+ <compile files="Code.java" options="-1.5 -Xlint:adviceDidNotMatch=wibble">
+ <message kind="error" text="invalid Xlint message kind (must be one of ignore, warning, error): wibble"/>
+ </compile>
+ <compile files="Code.java" options="-1.5 -Xlint:adviceDidNotMatch=ignore{adviceDidNotMatch=error">
+ <message kind="error" text="advice defined in Code has not been applied [Xlint:adviceDidNotMatch]"/>
+ </compile>
+ <compile files="Code.java" options="-1.5 -Xlint:adviceDidNotMatch=error{noGuardForLazyTjp=error">
+ <message kind="error" text="advice defined in Code has not been applied [Xlint:adviceDidNotMatch]"/>
+ <message kind="error" text="can not build thisJoinPoint lazily for this advice since it has no suitable guard [Xlint:noGuardForLazyTjp]"/>
+ </compile>
+ </ajc-test>
+
<ajc-test dir="bugs174/pr418129" title="annotated itd">
<compile files="Target.java" options="-1.5 -showWeaveInfo">
<message kind="weave" text="Type 'Behavior' (Target.java) has intertyped method from 'Trait' (Target.java:'java.lang.String Behavior.hello()')"/>