http://bugs.eclipse.org/bugs/show_bug.cgi?id=29769tags/V_1_1_b5
@@ -9,6 +9,7 @@ | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* AMC 01.20.2003 extended for new AspectJ 1.1 project options | |||
* ******************************************************************/ | |||
@@ -143,4 +144,21 @@ public class BrowserProperties implements ProjectPropertiesAdapter { | |||
public void setAjcWorkingDir(String path) { | |||
preferencesAdapter.setProjectPreference("build.workingdir", path); | |||
} | |||
// 1.1 options | |||
public Set getInJars( ) { | |||
return null; | |||
} | |||
public String getOutJar( ) { | |||
return null; | |||
} | |||
public Set getSourceRoots( ) { | |||
return null; | |||
} | |||
public Set getAspectPath( ) { | |||
return null; | |||
} | |||
} |
@@ -8,61 +8,100 @@ | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* Xerox/PARC initial implementation | |||
* AMC 01.20.2003 extended for AspectJ 1.1 compiler options | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.Set; | |||
/** | |||
* When a particular option is not set its documented default is used. | |||
*/ | |||
public interface BuildOptionsAdapter { | |||
// Version constants | |||
public static final String VERSION_13 = "1.3"; | |||
public static final String VERSION_14 = "1.4"; | |||
// Warning constants | |||
public static final String WARN_CONSTRUCTOR_NAME = "constructorName"; | |||
public static final String WARN_PACKAGE_DEFAULT_METHOD = "packageDefaultMethod"; | |||
public static final String WARN_DEPRECATION = "deprecation"; | |||
public static final String WARN_MASKED_CATCH_BLOCKS = "maskedCatchBlocks"; | |||
public static final String WARN_UNUSED_LOCALS = "unusedLocals"; | |||
public static final String WARN_UNUSED_ARGUMENTS = "unusedArguments"; | |||
public static final String WARN_UNUSED_IMPORTS = "unusedImports"; | |||
public static final String WARN_SYNTHETIC_ACCESS = "syntheticAccess"; | |||
public static final String WARN_ASSERT_IDENITIFIER = "assertIdentifier"; | |||
public static final String WARN_NLS = "nonExternalisedString"; | |||
// Debug constants | |||
public static final String DEBUG_SOURCE = "source"; | |||
public static final String DEBUG_LINES = "lines"; | |||
public static final String DEBUG_VARS = "vars"; | |||
public static final String DEBUG_ALL = "all"; | |||
/** | |||
* Use javac to generate .class files. The default is "false". | |||
* From -usejavac | |||
* @deprecated Not supported from AspectJ 1.1 onwards | |||
*/ | |||
public boolean getUseJavacMode(); | |||
/** | |||
* Only relevant with Use Javac or Preprocess modes. Specify where to place | |||
* intermediate .java files. The default is "workingdir". | |||
* From -workingdir | |||
* @deprecated Not supported from AspectJ 1.1 onwards | |||
*/ | |||
public String getWorkingOutputPath(); | |||
/** | |||
* Generate regular Java code into the Working OutputPath. Don't try to generate | |||
* any .class files. The default is "false". | |||
* From -source | |||
* @deprecated Not supported from AspectJ 1.1 onwards | |||
*/ | |||
public boolean getPreprocessMode(); | |||
/** | |||
* Specify character encoding used by source files. The default is the current | |||
* JVM's default. | |||
* From -encoding | |||
*/ | |||
public String getCharacterEncoding(); | |||
/** | |||
* Support assertions as defined in JLS-1.4. The default is "false". | |||
* @deprecated Use getComplianceLevel instead | |||
*/ | |||
public boolean getSourceOnePointFourMode(); | |||
/** | |||
* Be extra-lenient in interpreting the Java specification. The default is "false", | |||
* i.e. "regular" mode. | |||
* From -lenient | |||
* @deprecated Not supported from AspectJ 1.1 onwards | |||
*/ | |||
public boolean getLenientSpecMode(); | |||
/** | |||
* Be extra-strict in interpreting the Java specification. The default is "false", | |||
* i.e. "regular" mode. | |||
* From -strict | |||
* @deprecated Not supported from AspectJ 1.1 onwards | |||
*/ | |||
public boolean getStrictSpecMode(); | |||
/** | |||
* Make the use of some features from pre-1.0 versions of AspectJ be warnings to ease | |||
* porting of old code. The default is "false". | |||
* From -porting | |||
* @deprecated Not supported from AspectJ 1.1 onwards | |||
*/ | |||
public boolean getPortingMode(); | |||
@@ -71,4 +110,48 @@ public interface BuildOptionsAdapter { | |||
* The default is no non-standard options. | |||
*/ | |||
public String getNonStandardOptions(); | |||
// ---------------------------------- | |||
// New options added for AspectJ 1.1 from this point onwards | |||
/** | |||
* JDK Compliance level to be used by the compiler, either | |||
* VERSION_13 or VERSION_14. | |||
* From -1.3 / -1.4 | |||
*/ | |||
public String getComplianceLevel(); | |||
/** | |||
* Source compatibility level, either VERSION_13 or VERSION_14. | |||
* From -source (eclipse option) | |||
*/ | |||
public String getSourceCompatibilityLevel(); | |||
/** | |||
* Optional warnings, empty List is equivalent to -warn:none, | |||
* returning null uses eclipse compiler default settings | |||
* From -warn:xxx,yyy | |||
*/ | |||
public Set getWarnings(); | |||
/** | |||
* Debug level. DEBUG_ALL == {SOURCE, LINES, VARS}. | |||
* Empty list is equivalent to -g:none, returning | |||
* non uses eclipse compiler default settings | |||
* From -g:xxx | |||
*/ | |||
public Set getDebugLevel(); | |||
/** | |||
* No errors generated for unresolved imports | |||
* From -noImportError | |||
*/ | |||
public boolean getNoImportError(); | |||
/** | |||
* Preserve all unused local variables (for debug) | |||
* From -preserveAllLocals | |||
*/ | |||
public boolean getPreserveAllLocals(); | |||
} |
@@ -8,13 +8,15 @@ | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* Xerox/PARC initial implementation | |||
* AMC 01.20.2003 extended for AspectJ 1.1 compiler options | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.Set; | |||
import java.util.List; | |||
/** | |||
@@ -55,4 +57,38 @@ public interface ProjectPropertiesAdapter { | |||
public String getExecutionArgs(); | |||
public String getVmArgs(); | |||
// following methods added for AspectJ 1.1 | |||
//----------------------------------------- | |||
/** | |||
* Get the set of input jar files for this compilation. | |||
* Set members should be of type java.io.File. | |||
* An empty set or null is acceptable for this option. | |||
* From -injars. | |||
*/ | |||
public Set getInJars(); | |||
/** | |||
* Get the output jar file for the compilation results. | |||
* Return null to leave classfiles unjar'd in output directory | |||
* From -outjar | |||
*/ | |||
public String getOutJar(); | |||
/** | |||
* Get a set of root source directories for the compilation. | |||
* Set members should be of type java.io.File | |||
* Returning null or an empty set disables the option. | |||
* From -sourceroots | |||
*/ | |||
public Set getSourceRoots(); | |||
/** | |||
* Get the set of aspect jar files to be used for the compilation. | |||
* Returning null or an empty set disables this option. Set members | |||
* should be of type java.io.File. | |||
* From -aspectpath | |||
*/ | |||
public Set getAspectPath(); | |||
} |
@@ -238,19 +238,49 @@ public class AspectJBuildManager implements BuildManager { | |||
notifyCompileFinished(configFile, lastCompileTime, succeeded, warnings); | |||
} | |||
// AMC - updated for AspectJ 1.1 options | |||
private String getFormattedOptionsString(BuildOptionsAdapter buildOptions, ProjectPropertiesAdapter properties) { | |||
return "Building with settings: " | |||
+ "\n-> output path: " + properties.getOutputPath() | |||
+ "\n-> classpath: " + properties.getClasspath() | |||
+ "\n-> bootclasspath: " + properties.getBootClasspath() | |||
+ "\n-> -injars " + formatSet(properties.getInJars()) | |||
+ "\n-> -outjar " + formatOptionalString(properties.getOutJar()) | |||
+ "\n-> -sourceroots " + formatSet(properties.getSourceRoots()) | |||
+ "\n-> -aspectpath " + formatSet(properties.getAspectPath()) | |||
+ "\n-> -" + buildOptions.getComplianceLevel() | |||
+ "\n-> -source " + buildOptions.getSourceCompatibilityLevel() | |||
+ "\n-> -g:" + formatSet(buildOptions.getDebugLevel()) | |||
+ "\n-> -warn:" + formatSet(buildOptions.getWarnings()) | |||
+ "\n-> noImportError: " + buildOptions.getNoImportError() | |||
+ "\n-> preserveAllLocals:" + buildOptions.getPreserveAllLocals() | |||
+ "\n-> non-standard options: " + buildOptions.getNonStandardOptions() | |||
+ "\n-> porting mode: " + buildOptions.getPortingMode() | |||
+ "\n-> source 1.4 mode: " + buildOptions.getSourceOnePointFourMode() | |||
+ "\n-> strict spec mode: " + buildOptions.getStrictSpecMode() | |||
+ "\n-> lenient spec mode: " + buildOptions.getLenientSpecMode() | |||
+ "\n-> use javac mode: " + buildOptions.getUseJavacMode() | |||
+ "\n-> preprocess mode: " + buildOptions.getPreprocessMode() | |||
+ "\n-> working dir: " + buildOptions.getWorkingOutputPath(); | |||
+ "\n-> [ignored-deprecated in AspectJ1.1] porting mode: " + buildOptions.getPortingMode() | |||
+ "\n-> [ignored-deprecated in AspectJ1.1] source 1.4 mode: " + buildOptions.getSourceOnePointFourMode() | |||
+ "\n-> [ignored-deprecated in AspectJ1.1] strict spec mode: " + buildOptions.getStrictSpecMode() | |||
+ "\n-> [ignored-deprecated in AspectJ1.1] lenient spec mode: " + buildOptions.getLenientSpecMode() | |||
+ "\n-> [ignored-deprecated in AspectJ1.1] use javac mode: " + buildOptions.getUseJavacMode() | |||
+ "\n-> [ignored-deprecated in AspectJ1.1] preprocess mode: " + buildOptions.getPreprocessMode() | |||
+ "\n-> [ignored-deprecated in AspectJ1.1] working dir: " + buildOptions.getWorkingOutputPath(); | |||
} | |||
private String formatSet( Set options ) { | |||
if ( options == null ) return "<default>"; | |||
if ( options.isEmpty() ) return "none"; | |||
StringBuffer formattedOptions = new StringBuffer(); | |||
Iterator it = options.iterator(); | |||
while (it.hasNext()) { | |||
String o = it.next().toString(); | |||
if (formattedOptions.length() > 0) formattedOptions.append(", "); | |||
formattedOptions.append( o ); | |||
} | |||
return formattedOptions.toString(); | |||
} | |||
private String formatOptionalString( String s ) { | |||
if ( s == null ) { return "" ; } | |||
else { return s; } | |||
} | |||
} | |||
@@ -7,7 +7,9 @@ | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* Xerox/PARC initial implementation | |||
* AMC 01.20.2003 extended to support new AspectJ 1.1 options, | |||
* bugzilla #29769 | |||
* ******************************************************************/ | |||
@@ -17,10 +19,12 @@ import java.io.File; | |||
import java.util.*; | |||
import org.aspectj.ajde.*; | |||
import org.aspectj.ajdt.ajc.BuildArgParser; | |||
import org.aspectj.ajdt.internal.core.builder.AjBuildConfig; | |||
import org.aspectj.ajdt.internal.core.builder.AjBuildManager; | |||
import org.aspectj.bridge.*; | |||
import org.aspectj.util.ConfigParser; | |||
import org.aspectj.util.LangUtil; | |||
import org.eclipse.core.runtime.OperationCanceledException; | |||
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; | |||
@@ -99,36 +103,263 @@ public class CompilerAdapter { | |||
buildConfig.setConfigFile(config); | |||
} | |||
// AMC refactored into two methods to populate buildConfig from buildOptions and | |||
// project properties - bugzilla 29769. | |||
configureBuildOptions(buildConfig, Ajde.getDefault().getBuildManager().getBuildOptions()); | |||
configureProjectOptions(buildConfig, Ajde.getDefault().getProjectProperties()); | |||
buildConfig.setGenerateModelMode(true); | |||
return buildConfig; | |||
} | |||
/** | |||
* Populate options in a build configuration, using the Ajde BuildOptionsAdapter. | |||
* Added by AMC 01.20.2003, bugzilla #29769 | |||
*/ | |||
private void configureBuildOptions( AjBuildConfig config, BuildOptionsAdapter options ) { | |||
Map javaOptions = config.getJavaOptions(); | |||
if (options.getSourceOnePointFourMode()) { | |||
javaOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); | |||
javaOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); | |||
} | |||
String enc = options.getCharacterEncoding(); | |||
if ( enc != null & (enc.length() > 0)) { | |||
javaOptions.put(CompilerOptions.OPTION_Encoding, enc ); | |||
} | |||
String compliance = options.getComplianceLevel(); | |||
if ( compliance != null && (compliance.length() > 0) ) { | |||
String version = CompilerOptions.VERSION_1_4; | |||
if ( compliance.equals( BuildOptionsAdapter.VERSION_13 ) ) { | |||
version = CompilerOptions.VERSION_1_3; | |||
} | |||
javaOptions.put(CompilerOptions.OPTION_Compliance, version ); | |||
javaOptions.put(CompilerOptions.OPTION_Source, version ); | |||
} | |||
String sourceLevel = options.getSourceCompatibilityLevel(); | |||
if ( null != sourceLevel && ( sourceLevel.length() > 0 )) { | |||
String slVersion = CompilerOptions.VERSION_1_4; | |||
if ( sourceLevel.equals( BuildOptionsAdapter.VERSION_13 ) ) { | |||
slVersion = CompilerOptions.VERSION_1_3; | |||
} | |||
// never set a lower source level than compliance level | |||
String setCompliance = (String) javaOptions.get( CompilerOptions.OPTION_Compliance); | |||
if ( ! (setCompliance.equals( CompilerOptions.VERSION_1_4 ) | |||
&& slVersion.equals(CompilerOptions.VERSION_1_3)) ) { | |||
javaOptions.put(CompilerOptions.OPTION_Source, slVersion); | |||
} | |||
} | |||
Set warnings = options.getWarnings(); | |||
if ( warnings != null ) { | |||
// turn off all warnings | |||
disableWarnings( javaOptions ); | |||
// then selectively enable those in the set | |||
enableWarnings( javaOptions, warnings ); | |||
} | |||
Set debugOptions = options.getDebugLevel(); | |||
if ( debugOptions != null ) { | |||
// default is all options off, so just need to selectively | |||
// enable | |||
Iterator it = debugOptions.iterator(); | |||
while (it.hasNext()){ | |||
String debug = (String) it.next(); | |||
if ( debug.equals( BuildOptionsAdapter.DEBUG_ALL )) { | |||
javaOptions.put( CompilerOptions.OPTION_LineNumberAttribute, | |||
CompilerOptions.GENERATE); | |||
javaOptions.put( CompilerOptions.OPTION_SourceFileAttribute, | |||
CompilerOptions.GENERATE); | |||
javaOptions.put( CompilerOptions.OPTION_LocalVariableAttribute, | |||
CompilerOptions.GENERATE); | |||
} else if ( debug.equals( BuildOptionsAdapter.DEBUG_LINES )) { | |||
javaOptions.put( CompilerOptions.OPTION_LineNumberAttribute, | |||
CompilerOptions.GENERATE); | |||
} else if ( debug.equals( BuildOptionsAdapter.DEBUG_SOURCE )) { | |||
javaOptions.put( CompilerOptions.OPTION_SourceFileAttribute, | |||
CompilerOptions.GENERATE); | |||
} else if ( debug.equals( BuildOptionsAdapter.DEBUG_VARS)) { | |||
javaOptions.put( CompilerOptions.OPTION_LocalVariableAttribute, | |||
CompilerOptions.GENERATE); | |||
} | |||
} | |||
} | |||
if ( options.getNoImportError() ) { | |||
javaOptions.put( CompilerOptions.OPTION_ReportInvalidImport, | |||
CompilerOptions.WARNING); | |||
} | |||
if ( options.getPreserveAllLocals() ) { | |||
javaOptions.put( CompilerOptions.OPTION_PreserveUnusedLocal, | |||
CompilerOptions.PRESERVE); | |||
} | |||
config.setJavaOptions( javaOptions ); | |||
configureNonStandardOptions( config, options ); | |||
} | |||
/** | |||
* Helper method for configureBuildOptions | |||
*/ | |||
private void disableWarnings( Map options ) { | |||
options.put( | |||
CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportMethodWithConstructorName, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportDeprecation, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportHiddenCatchBlock, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportUnusedLocal, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportUnusedParameter, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportSyntheticAccessEmulation, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportAssertIdentifier, | |||
CompilerOptions.IGNORE); | |||
options.put( | |||
CompilerOptions.OPTION_ReportUnusedImport, | |||
CompilerOptions.IGNORE); | |||
} | |||
/** | |||
* Helper method for configureBuildOptions | |||
*/ | |||
private void enableWarnings( Map options, Set warnings ) { | |||
Iterator it = warnings.iterator(); | |||
while (it.hasNext() ) { | |||
String thisWarning = (String) it.next(); | |||
if ( thisWarning.equals( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER )) { | |||
options.put( CompilerOptions.OPTION_ReportAssertIdentifier, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_CONSTRUCTOR_NAME )) { | |||
options.put( CompilerOptions.OPTION_ReportMethodWithConstructorName, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_DEPRECATION )) { | |||
options.put( CompilerOptions.OPTION_ReportDeprecation, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS )) { | |||
options.put( CompilerOptions.OPTION_ReportHiddenCatchBlock, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_PACKAGE_DEFAULT_METHOD )) { | |||
options.put( CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_SYNTHETIC_ACCESS )) { | |||
options.put( CompilerOptions.OPTION_ReportSyntheticAccessEmulation, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_UNUSED_ARGUMENTS )) { | |||
options.put( CompilerOptions.OPTION_ReportUnusedParameter, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_UNUSED_IMPORTS )) { | |||
options.put( CompilerOptions.OPTION_ReportUnusedImport, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_UNUSED_LOCALS )) { | |||
options.put( CompilerOptions.OPTION_ReportUnusedLocal, | |||
CompilerOptions.WARNING ); | |||
} else if ( thisWarning.equals( BuildOptionsAdapter.WARN_NLS )) { | |||
options.put( CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, | |||
CompilerOptions.WARNING ); | |||
} | |||
} | |||
} | |||
/** | |||
* Helper method for configure build options | |||
*/ | |||
private void configureNonStandardOptions( AjBuildConfig config, BuildOptionsAdapter options ) { | |||
String nonStdOptions = options.getNonStandardOptions(); | |||
if ( null == nonStdOptions || (nonStdOptions.length() == 0)) return; | |||
StringTokenizer tok = new StringTokenizer( nonStdOptions ); | |||
String[] args = new String[ tok.countTokens() ]; | |||
int argCount = 0; | |||
while ( tok.hasMoreTokens() ) { | |||
args[argCount++] = tok.nextToken(); | |||
} | |||
// set the non-standard options in an alternate build config | |||
// (we don't want to lose the settings we already have) | |||
BuildArgParser argParser = new BuildArgParser(); | |||
AjBuildConfig altConfig = argParser.genBuildConfig( args, messageHandler ); | |||
// copy the answers across | |||
config.setNoWeave( altConfig.isNoWeave() ); | |||
config.setXnoInline( altConfig.isXnoInline() ); | |||
config.setXserializableAspects( altConfig.isXserializableAspects()); | |||
config.setLintMode( altConfig.getLintMode() ); | |||
config.setLintSpecFile( altConfig.getLintSpecFile() ); | |||
} | |||
/** | |||
* Populate options in a build configuration, using the ProjectPropertiesAdapter. | |||
* Added by AMC 01.20.2003, bugzilla #29769 | |||
*/ | |||
private void configureProjectOptions( AjBuildConfig config, ProjectPropertiesAdapter properties ) { | |||
// set the classpath | |||
String classpathString = | |||
Ajde.getDefault().getProjectProperties().getBootClasspath() | |||
properties.getBootClasspath() | |||
+ File.pathSeparator | |||
+ Ajde.getDefault().getProjectProperties().getClasspath(); | |||
+ properties.getClasspath(); | |||
StringTokenizer st = new StringTokenizer( | |||
classpathString, | |||
File.pathSeparator | |||
); | |||
List classpath = new ArrayList(); | |||
while (st.hasMoreTokens()) classpath.add(st.nextToken()); | |||
buildConfig.setClasspath(classpath); | |||
config.setClasspath(classpath); | |||
Ajde.getDefault().logEvent("building with classpath: " + classpath); | |||
if (Ajde.getDefault().getBuildManager().getBuildOptions().getSourceOnePointFourMode()) { | |||
buildConfig.getJavaOptions().put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4); | |||
} | |||
config.setOutputDir( | |||
new File(properties.getOutputPath()) | |||
); | |||
// XXX problematic restriction, support multiple source roots | |||
List sourceRoots = new ArrayList(); | |||
sourceRoots.add(new File(configFile).getParentFile()); | |||
buildConfig.setSourceRoots(sourceRoots); | |||
// new 1.1 options added by AMC | |||
buildConfig.setOutputDir( | |||
new File(Ajde.getDefault().getProjectProperties().getOutputPath()) | |||
); | |||
Set roots = properties.getSourceRoots(); | |||
if ( null != roots && !roots.isEmpty() ) { | |||
List sourceRoots = new ArrayList( roots ); | |||
config.setSourceRoots(sourceRoots); | |||
} | |||
buildConfig.setGenerateModelMode(true); | |||
Set jars = properties.getInJars(); | |||
if ( null != jars && !jars.isEmpty() ) { | |||
List inJars = new ArrayList( jars ); | |||
config.setInJars(inJars); | |||
} | |||
return buildConfig; | |||
String outJar = properties.getOutJar(); | |||
if ( null != outJar && (outJar.length() > 0) ) { | |||
config.setOutputJar( new File( outJar ) ); | |||
} | |||
Set aspects = properties.getAspectPath(); | |||
if ( null != aspects && !aspects.isEmpty() ) { | |||
List aPath = new ArrayList( aspects ); | |||
config.setAspectpath( aPath); | |||
} | |||
} | |||
private void init() { |
@@ -9,12 +9,19 @@ | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* AMC 01.20.2003 extended to support AspectJ 1.1 options, | |||
* bugzilla #29769 | |||
* ******************************************************************/ | |||
package org.aspectj.ajde.ui.internal; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.Set; | |||
import java.util.StringTokenizer; | |||
import org.aspectj.ajde.*; | |||
import org.aspectj.ajde.ui.*; | |||
@@ -33,31 +40,46 @@ public class AjcBuildOptions implements BuildOptionsAdapter { | |||
private static final String PORTING_MODE = AJC + ".portingMode"; | |||
private static final String VERBOSE_MODE = AJC + ".verboseMode"; | |||
private static final String NONSTANDARD_OPTIONS = AJC + ".nonStandardOptions"; | |||
// 1.1 constants added by AMC | |||
private static final String COMPLIANCE_LEVEL = AJC + ".complianceLevel"; | |||
private static final String SOURCE_LEVEL = AJC + ".sourceLevel"; | |||
private static final String WARNINGS = AJC + ".warnings"; | |||
private static final String DEBUG_OPTIONS = AJC + ".debugOptions"; | |||
private static final String NO_IMPORT_ERROR = AJC + ".noImportError"; | |||
private static final String PRESERVE_LOCALS = AJC + ".preserveLocals"; | |||
private static final String DEFAULT = "default"; | |||
public AjcBuildOptions(UserPreferencesAdapter userPreferencesAdapter) { | |||
this.preferencesAdapter = userPreferencesAdapter; | |||
} | |||
/** @deprecated */ | |||
public boolean getUseJavacMode() { | |||
return getBooleanOptionVal(USE_JAVAC_MODE); | |||
} | |||
/** @deprecated */ | |||
public void setUseJavacMode(boolean value) { | |||
setBooleanOptionVal(USE_JAVAC_MODE, value); | |||
} | |||
/** @deprecated */ | |||
public String getWorkingOutputPath() { | |||
return preferencesAdapter.getProjectPreference(WORKING_DIR); | |||
} | |||
/** @deprecated */ | |||
public void setWorkingDir(String path) { | |||
preferencesAdapter.setProjectPreference(WORKING_DIR, path); | |||
} | |||
/** @deprecated */ | |||
public boolean getPreprocessMode() { | |||
return getBooleanOptionVal(PREPROCESS_MODE); | |||
} | |||
/** @deprecated */ | |||
public void setPreprocessMode(boolean value) { | |||
setBooleanOptionVal(PREPROCESS_MODE, value); | |||
} | |||
@@ -70,34 +92,42 @@ public class AjcBuildOptions implements BuildOptionsAdapter { | |||
preferencesAdapter.setProjectPreference(CHARACTER_ENCODING, value); | |||
} | |||
/** @deprecated */ | |||
public boolean getSourceOnePointFourMode() { | |||
return getBooleanOptionVal(SOURCE_ONE_POINT_FOUR_MODE); | |||
} | |||
/** @deprecated */ | |||
public void setSourceOnePointFourMode(boolean value) { | |||
setBooleanOptionVal(SOURCE_ONE_POINT_FOUR_MODE, value); | |||
} | |||
/** @deprecated */ | |||
public boolean getLenientSpecMode() { | |||
return getBooleanOptionVal(LENIENT_MODE); | |||
} | |||
/** @deprecated */ | |||
public void setLenientSpecMode(boolean value) { | |||
setBooleanOptionVal(LENIENT_MODE, value); | |||
} | |||
/** @deprecated */ | |||
public boolean getStrictSpecMode() { | |||
return getBooleanOptionVal(STRICT_MODE); | |||
} | |||
/** @deprecated */ | |||
public void setStrictSpecMode(boolean value) { | |||
setBooleanOptionVal(STRICT_MODE, value); | |||
} | |||
/** @deprecated */ | |||
public boolean getPortingMode() { | |||
return getBooleanOptionVal(PORTING_MODE); | |||
} | |||
/** @deprecated */ | |||
public void setPortingMode(boolean value) { | |||
setBooleanOptionVal(PORTING_MODE, value); | |||
} | |||
@@ -117,6 +147,89 @@ public class AjcBuildOptions implements BuildOptionsAdapter { | |||
public void setNonStandardOptions(String value) { | |||
preferencesAdapter.setProjectPreference(NONSTANDARD_OPTIONS, value); | |||
} | |||
// ------------- | |||
// new 1.1 compiler options start here... | |||
/** | |||
* JDK Compliance level to be used by the compiler, either | |||
* VERSION_13 or VERSION_14. | |||
* From -1.3 / -1.4 | |||
*/ | |||
public String getComplianceLevel() { | |||
return preferencesAdapter.getProjectPreference(COMPLIANCE_LEVEL); | |||
} | |||
public void setComplianceLevel( String value ) { | |||
preferencesAdapter.setProjectPreference(COMPLIANCE_LEVEL,value); | |||
} | |||
/** | |||
* Source compatibility level, either VERSION_13 or VERSION_14. | |||
* From -source (eclipse option) | |||
*/ | |||
public String getSourceCompatibilityLevel() { | |||
return preferencesAdapter.getProjectPreference(SOURCE_LEVEL); | |||
} | |||
public void setSourceCompatibilityLevel(String value) { | |||
preferencesAdapter.setProjectPreference(SOURCE_LEVEL, value); | |||
} | |||
/** | |||
* Optional warnings, empty List is equivalent to -warn:none, | |||
* returning null uses eclipse compiler default settings | |||
* From -warn:xxx,yyy | |||
*/ | |||
public Set getWarnings() { | |||
String warnings = preferencesAdapter.getProjectPreference(WARNINGS); | |||
return toWarningSet( warnings ); | |||
} | |||
public void setWarnings( Set warningSet ) { | |||
String warnings = fromWarningSet( warningSet ); | |||
preferencesAdapter.setProjectPreference(WARNINGS, warnings); | |||
} | |||
/** | |||
* Debug level. DEBUG_ALL == {SOURCE, LINES, VARS}. | |||
* Empty list is equivalent to -g:none, returning | |||
* non uses eclipse compiler default settings | |||
* From -g:xxx | |||
*/ | |||
public Set getDebugLevel() { | |||
String debug = preferencesAdapter.getProjectPreference(DEBUG_OPTIONS); | |||
return toDebugSet( debug ); | |||
} | |||
public void setDebugLevel( Set debugSet ) { | |||
String debug = fromDebugSet( debugSet ); | |||
preferencesAdapter.setProjectPreference(DEBUG_OPTIONS, debug); | |||
} | |||
/** | |||
* No errors generated for unresolved imports | |||
* From -noImportError | |||
*/ | |||
public boolean getNoImportError() { | |||
return getBooleanOptionVal(NO_IMPORT_ERROR); | |||
} | |||
public void setNoImportError(boolean value) { | |||
setBooleanOptionVal(NO_IMPORT_ERROR, value); | |||
} | |||
/** | |||
* Preserve all unused local variables (for debug) | |||
* From -preserveAllLocals | |||
*/ | |||
public boolean getPreserveAllLocals() { | |||
return getBooleanOptionVal(PRESERVE_LOCALS); | |||
} | |||
public void setPreserveAllLocals(boolean value) { | |||
setBooleanOptionVal(PRESERVE_LOCALS, value); | |||
} | |||
private boolean getBooleanOptionVal(String name) { | |||
if (preferencesAdapter.getProjectPreference(name) != null) { | |||
@@ -133,4 +246,56 @@ public class AjcBuildOptions implements BuildOptionsAdapter { | |||
preferencesAdapter.setProjectPreference(name, "false"); | |||
} | |||
} | |||
private Set toWarningSet( String warnings ) { | |||
if ( null == warnings ) return null; | |||
if ( warnings.equals(DEFAULT) ) return null; | |||
Set warningSet = new HashSet(); | |||
StringTokenizer tok = new StringTokenizer( warnings, "," ); | |||
while ( tok.hasMoreTokens() ) { | |||
String warning = tok.nextToken(); | |||
warningSet.add( warning ); | |||
} | |||
return warningSet; | |||
} | |||
private String fromWarningSet( Set warningSet ) { | |||
if ( warningSet == null ) return DEFAULT; | |||
StringBuffer warnings = new StringBuffer(); | |||
Iterator it = warningSet.iterator(); | |||
while ( it.hasNext() ) { | |||
String w = (String) it.next(); | |||
if (warnings.length() > 0 ) warnings.append(','); | |||
warnings.append( w ); | |||
} | |||
return warnings.toString(); | |||
} | |||
private Set toDebugSet( String debugOptions ) { | |||
if ( null == debugOptions ) return null; | |||
if ( debugOptions.equals(DEFAULT) ) return null; | |||
Set debugSet = new HashSet(); | |||
StringTokenizer tok = new StringTokenizer( debugOptions, "," ); | |||
while ( tok.hasMoreTokens() ) { | |||
String debug = tok.nextToken(); | |||
debugSet.add( debug ); | |||
} | |||
return debugSet; } | |||
private String fromDebugSet( Set debugSet ) { | |||
if ( debugSet == null ) return DEFAULT; | |||
StringBuffer debugOptions = new StringBuffer(); | |||
Iterator it = debugSet.iterator(); | |||
while ( it.hasNext() ) { | |||
String d = (String) it.next(); | |||
if (debugOptions.length() > 0 ) debugOptions.append(','); | |||
debugOptions.append( d ); | |||
} | |||
return debugOptions.toString(); | |||
} | |||
} |
@@ -1,7 +1,7 @@ | |||
package figures; | |||
//import figures.primitives.planar.Point; | |||
import figures.primitives.planar.Point; | |||
import java.awt.Canvas; | |||
@@ -73,7 +73,9 @@ aspect Figure { | |||
declare parents: Point implements java.util.Observable; | |||
declare soft: Point: call(* *(..)); | |||
// AMC - this next line doesn't make sense!! Can these tests ever | |||
// have been run??? | |||
//declare soft: Point: call(* *(..)); | |||
} | |||
aspect Checks { |
@@ -22,6 +22,7 @@ public class AjdeTests extends TestCase { | |||
TestSuite suite = new TestSuite(AjdeTests.class.getName()); | |||
//$JUnit-BEGIN$ | |||
suite.addTestSuite(BuildOptionsTest.class); | |||
suite.addTestSuite(BuildConfigurationTests.class); | |||
suite.addTestSuite(StructureModelRegressionTest.class); | |||
suite.addTestSuite(StructureModelTest.class); | |||
suite.addTestSuite(VersionTest.class); |
@@ -0,0 +1,506 @@ | |||
/********************************************************************** | |||
Copyright (c) 2003 IBM Corporation and others. | |||
All rights reserved. This program and the accompanying materials | |||
are made available under the terms of the Common Public License v1.0 | |||
which accompanies this distribution, and is available at | |||
http://www.eclipse.org/legal/cpl-v10.html | |||
Contributors: | |||
Adrian Colyer - initial version | |||
... | |||
**********************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.io.File; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import javax.swing.JFrame; | |||
import junit.framework.TestSuite; | |||
import org.aspectj.ajde.internal.CompilerAdapter; | |||
import org.aspectj.ajde.ui.IdeUIAdapter; | |||
import org.aspectj.ajde.ui.UserPreferencesAdapter; | |||
import org.aspectj.ajde.ui.internal.AjcBuildOptions; | |||
import org.aspectj.ajde.ui.internal.UserPreferencesStore; | |||
import org.aspectj.ajde.ui.swing.AjdeUIManager; | |||
import org.aspectj.ajde.ui.swing.BasicEditor; | |||
import org.aspectj.ajde.ui.swing.IconRegistry; | |||
import org.aspectj.ajdt.internal.core.builder.AjBuildConfig; | |||
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; | |||
/** | |||
* Tests that a correctly populated AjBuildConfig object is created | |||
* in reponse to the setting in BuildOptionsAdapter and | |||
* ProjectPropretiesAdapter | |||
*/ | |||
public class BuildConfigurationTests extends AjdeTestCase { | |||
private CompilerAdapter compilerAdapter; | |||
private AjBuildConfig buildConfig = null; | |||
private AjcBuildOptions buildOptions = null; | |||
private UserPreferencesAdapter preferencesAdapter = null; | |||
private NullIdeProperties projectProperties = null; | |||
private static final String configFile = | |||
"testdata/examples/figures-coverage/all.lst"; | |||
public BuildConfigurationTests( String name ) { | |||
super( name ); | |||
} | |||
public static void main(String[] args) { | |||
junit.swingui.TestRunner.run(BuildConfigurationTests.class); | |||
} | |||
public static TestSuite suite() { | |||
TestSuite result = new TestSuite(); | |||
result.addTestSuite(BuildConfigurationTests.class); | |||
return result; | |||
} | |||
// The tests... | |||
public void testCharacterEncoding() { | |||
buildOptions.setCharacterEncoding( "12345" ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
String encoding = (String) options.get( CompilerOptions.OPTION_Encoding ); | |||
assertEquals( "character encoding", "12345", encoding ); | |||
} | |||
public void testComplianceLevel() { | |||
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14 ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); | |||
String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); | |||
assertEquals( "compliance level", CompilerOptions.VERSION_1_4, compliance); | |||
assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel ); | |||
} | |||
public void testSourceCompatibilityLevel() { | |||
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_13); | |||
buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_14); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); | |||
String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); | |||
assertEquals( "compliance level", CompilerOptions.VERSION_1_3, compliance); | |||
assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel ); | |||
} | |||
public void testSourceIncompatibilityLevel() { | |||
// this config should "fail" and leave source level at 1.4 | |||
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14); | |||
buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_13); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
String compliance = (String) options.get(CompilerOptions.OPTION_Compliance); | |||
String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source); | |||
assertEquals( "compliance level", CompilerOptions.VERSION_1_4, compliance); | |||
assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel ); | |||
} | |||
public void testNullWarnings() { | |||
buildOptions.setWarnings( null ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
// this should leave us with the default warnings | |||
assertOptionEquals( "report overriding package default", | |||
options, | |||
CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report method with cons name", | |||
options, | |||
CompilerOptions.OPTION_ReportMethodWithConstructorName, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report deprecation", | |||
options, | |||
CompilerOptions.OPTION_ReportDeprecation, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report hidden catch block", | |||
options, | |||
CompilerOptions.OPTION_ReportHiddenCatchBlock, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report unused local", | |||
options, | |||
CompilerOptions.OPTION_ReportUnusedLocal, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report unused param", | |||
options, | |||
CompilerOptions.OPTION_ReportUnusedParameter, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report synthectic access", | |||
options, | |||
CompilerOptions.OPTION_ReportSyntheticAccessEmulation, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report non-externalized string literal", | |||
options, | |||
CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report assert identifer", | |||
options, | |||
CompilerOptions.OPTION_ReportAssertIdentifier, | |||
CompilerOptions.IGNORE); | |||
} | |||
public void testEmptyWarnings() { | |||
buildOptions.setWarnings( new HashSet() ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
// this should leave us with the user specifiable warnings | |||
// turned off | |||
assertOptionEquals( "report overriding package default", | |||
options, | |||
CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report method with cons name", | |||
options, | |||
CompilerOptions.OPTION_ReportMethodWithConstructorName, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report deprecation", | |||
options, | |||
CompilerOptions.OPTION_ReportDeprecation, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report hidden catch block", | |||
options, | |||
CompilerOptions.OPTION_ReportHiddenCatchBlock, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report unused local", | |||
options, | |||
CompilerOptions.OPTION_ReportUnusedLocal, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report unused param", | |||
options, | |||
CompilerOptions.OPTION_ReportUnusedParameter, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report synthectic access", | |||
options, | |||
CompilerOptions.OPTION_ReportSyntheticAccessEmulation, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report non-externalized string literal", | |||
options, | |||
CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, | |||
CompilerOptions.IGNORE); | |||
assertOptionEquals( "report assert identifer", | |||
options, | |||
CompilerOptions.OPTION_ReportAssertIdentifier, | |||
CompilerOptions.IGNORE); | |||
} | |||
public void testSetOfWarnings() { | |||
HashSet warnings = new HashSet(); | |||
warnings.add( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER ); | |||
warnings.add( BuildOptionsAdapter.WARN_CONSTRUCTOR_NAME ); | |||
warnings.add( BuildOptionsAdapter.WARN_DEPRECATION ); | |||
warnings.add( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS ); | |||
warnings.add( BuildOptionsAdapter.WARN_PACKAGE_DEFAULT_METHOD ); | |||
warnings.add( BuildOptionsAdapter.WARN_SYNTHETIC_ACCESS ); | |||
warnings.add( BuildOptionsAdapter.WARN_UNUSED_ARGUMENTS ); | |||
warnings.add( BuildOptionsAdapter.WARN_UNUSED_IMPORTS ); | |||
warnings.add( BuildOptionsAdapter.WARN_UNUSED_LOCALS ); | |||
warnings.add( BuildOptionsAdapter.WARN_NLS ); | |||
buildOptions.setWarnings( warnings ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
// this should leave us with all the user specifiable warnings | |||
// turned on | |||
assertOptionEquals( "report overriding package default", | |||
options, | |||
CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report method with cons name", | |||
options, | |||
CompilerOptions.OPTION_ReportMethodWithConstructorName, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report deprecation", | |||
options, | |||
CompilerOptions.OPTION_ReportDeprecation, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report hidden catch block", | |||
options, | |||
CompilerOptions.OPTION_ReportHiddenCatchBlock, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report unused local", | |||
options, | |||
CompilerOptions.OPTION_ReportUnusedLocal, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report unused param", | |||
options, | |||
CompilerOptions.OPTION_ReportUnusedParameter, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report synthectic access", | |||
options, | |||
CompilerOptions.OPTION_ReportSyntheticAccessEmulation, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report non-externalized string literal", | |||
options, | |||
CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, | |||
CompilerOptions.WARNING); | |||
assertOptionEquals( "report assert identifer", | |||
options, | |||
CompilerOptions.OPTION_ReportAssertIdentifier, | |||
CompilerOptions.WARNING); | |||
} | |||
public void testNoDebugOptions() { | |||
buildOptions.setDebugLevel( null ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
// this should leave us with the default debug settings | |||
assertOptionEquals( "debug source", | |||
options, | |||
CompilerOptions.OPTION_SourceFileAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
assertOptionEquals( "debug lines", | |||
options, | |||
CompilerOptions.OPTION_LineNumberAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
assertOptionEquals( "debug vars", | |||
options, | |||
CompilerOptions.OPTION_LocalVariableAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
} | |||
public void testEmptyDebugOptions() { | |||
buildOptions.setDebugLevel( new HashSet() ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
// this should leave us with the debug off | |||
assertOptionEquals( "debug source", | |||
options, | |||
CompilerOptions.OPTION_SourceFileAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
assertOptionEquals( "debug lines", | |||
options, | |||
CompilerOptions.OPTION_LineNumberAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
assertOptionEquals( "debug vars", | |||
options, | |||
CompilerOptions.OPTION_LocalVariableAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
} | |||
public void testDebugAll() { | |||
HashSet debugOpts = new HashSet(); | |||
debugOpts.add( BuildOptionsAdapter.DEBUG_ALL ); | |||
buildOptions.setDebugLevel( debugOpts ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
// this should leave us with all debug on | |||
assertOptionEquals( "debug source", | |||
options, | |||
CompilerOptions.OPTION_SourceFileAttribute, | |||
CompilerOptions.GENERATE); | |||
assertOptionEquals( "debug lines", | |||
options, | |||
CompilerOptions.OPTION_LineNumberAttribute, | |||
CompilerOptions.GENERATE); | |||
assertOptionEquals( "debug vars", | |||
options, | |||
CompilerOptions.OPTION_LocalVariableAttribute, | |||
CompilerOptions.GENERATE); | |||
} | |||
public void testDebugSet() { | |||
HashSet debugOpts = new HashSet(); | |||
debugOpts.add( BuildOptionsAdapter.DEBUG_SOURCE ); | |||
debugOpts.add( BuildOptionsAdapter.DEBUG_VARS ); | |||
buildOptions.setDebugLevel( debugOpts ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
// this should leave us with all debug on | |||
assertOptionEquals( "debug source", | |||
options, | |||
CompilerOptions.OPTION_SourceFileAttribute, | |||
CompilerOptions.GENERATE); | |||
assertOptionEquals( "debug lines", | |||
options, | |||
CompilerOptions.OPTION_LineNumberAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
assertOptionEquals( "debug vars", | |||
options, | |||
CompilerOptions.OPTION_LocalVariableAttribute, | |||
CompilerOptions.GENERATE); | |||
} | |||
public void testNoImport() { | |||
buildOptions.setNoImportError( true ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
String noImport = (String) options.get( CompilerOptions.OPTION_ReportInvalidImport ); | |||
assertEquals( "no import", CompilerOptions.WARNING, noImport ); | |||
buildOptions.setNoImportError( false ); | |||
} | |||
public void testPreserveAllLocals() { | |||
buildOptions.setPreserveAllLocals( true ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
Map options = buildConfig.getJavaOptions(); | |||
String preserve = (String) options.get( CompilerOptions.OPTION_PreserveUnusedLocal ); | |||
assertEquals( "preserve unused", CompilerOptions.PRESERVE, preserve ); | |||
} | |||
public void testNonStandardOptions() { | |||
buildOptions.setNonStandardOptions( "-XnoWeave" ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
assertTrue( "XnoWeave", buildConfig.isNoWeave() ); | |||
buildOptions.setNonStandardOptions( "-XserializableAspects" ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
assertTrue( "XserializableAspects", buildConfig.isXserializableAspects() ); | |||
buildOptions.setNonStandardOptions( "-XnoInline" ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
assertTrue( "XnoInline", buildConfig.isXnoInline()); | |||
buildOptions.setNonStandardOptions( "-Xlint" ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
assertEquals( "Xlint", AjBuildConfig.AJLINT_DEFAULT, | |||
buildConfig.getLintMode()); | |||
buildOptions.setNonStandardOptions( "-Xlint:error" ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
assertEquals( "Xlint", AjBuildConfig.AJLINT_ERROR, | |||
buildConfig.getLintMode()); | |||
buildOptions.setNonStandardOptions( "-Xlintfile testdata/AspectJBuildManagerTest/lint.properties" ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
assertEquals( "Xlintfile", new File( "testdata/AspectJBuildManagerTest/lint.properties" ).getAbsolutePath(), | |||
buildConfig.getLintSpecFile().toString()); | |||
// and a few options thrown in at once | |||
buildOptions.setNonStandardOptions( "-Xlint -XnoInline -XserializableAspects" ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
assertEquals( "Xlint", AjBuildConfig.AJLINT_DEFAULT, | |||
buildConfig.getLintMode()); | |||
assertTrue( "XnoInline", buildConfig.isXnoInline()); | |||
assertTrue( "XserializableAspects", buildConfig.isXserializableAspects() ); | |||
} | |||
public void testSourceRoots() { | |||
Set roots = new HashSet(); | |||
projectProperties.setSourceRoots( roots ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List configRoots = buildConfig.getSourceRoots(); | |||
assertTrue( "no source dirs", configRoots.isEmpty() ); | |||
File f = new File( "testdata/examples/figures/figures-coverage" ); | |||
roots.add( f ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List configRoots2 = buildConfig.getSourceRoots(); | |||
assertTrue( "one source dir", configRoots2.size() == 1 ); | |||
assertTrue( "source dir", configRoots2.contains(f) ); | |||
File f2 = new File( "testdata/examples/figures/figures-demo" ); | |||
roots.add( f2 ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List configRoots3 = buildConfig.getSourceRoots(); | |||
assertTrue( "two source dirs", configRoots3.size() == 2 ); | |||
assertTrue( "source dir 1", configRoots3.contains(f) ); | |||
assertTrue( "source dir 2", configRoots3.contains(f2) ); | |||
} | |||
public void testInJars() { | |||
Set jars = new HashSet(); | |||
projectProperties.setInJars( jars ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List inJars = buildConfig.getInJars(); | |||
assertTrue( "no in jars", inJars.isEmpty() ); | |||
File f = new File( "jarone.jar" ); | |||
jars.add( f ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List inJars2 = buildConfig.getInJars(); | |||
assertTrue( "one in jar", inJars2.size() == 1 ); | |||
assertTrue( "in jar", inJars2.contains(f) ); | |||
File f2 = new File( "jartwo.jar" ); | |||
jars.add( f2 ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List inJars3 = buildConfig.getInJars(); | |||
assertTrue( "two in jars", inJars3.size() == 2 ); | |||
assertTrue( "in jar 1", inJars3.contains(f) ); | |||
assertTrue( "in jar 2", inJars3.contains(f2) ); | |||
} | |||
public void testAspectPath() { | |||
Set aspects = new HashSet(); | |||
projectProperties.setAspectPath( aspects ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List aPath = buildConfig.getAspectpath(); | |||
assertTrue( "no aspect path", aPath.isEmpty() ); | |||
File f = new File( "jarone.jar" ); | |||
aspects.add( f ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List aPath2 = buildConfig.getAspectpath(); | |||
assertTrue( "one jar in path", aPath2.size() == 1 ); | |||
assertTrue( "1 aspectpath", aPath2.contains(f) ); | |||
File f2 = new File( "jartwo.jar" ); | |||
aspects.add( f2 ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
List aPath3 = buildConfig.getAspectpath(); | |||
assertTrue( "two jars in path", aPath3.size() == 2 ); | |||
assertTrue( "1 aspectpath", aPath3.contains(f) ); | |||
assertTrue( "2 aspectpath", aPath3.contains(f2) ); | |||
} | |||
public void testOutJar() { | |||
String outJar = "mybuild.jar"; | |||
projectProperties.setOutJar( outJar ); | |||
buildConfig = compilerAdapter.genBuildConfig( configFile ); | |||
assertEquals( "out jar", outJar, buildConfig.getOutputJar().toString() ); | |||
} | |||
protected void setUp() throws Exception { | |||
preferencesAdapter = new UserPreferencesStore(); | |||
buildOptions = new AjcBuildOptions(preferencesAdapter); | |||
compilerAdapter = new CompilerAdapter(); | |||
projectProperties = new NullIdeProperties( "" ); | |||
init(); | |||
} | |||
protected void tearDown() throws Exception { | |||
super.tearDown(); | |||
buildOptions.setCharacterEncoding(""); | |||
} | |||
public void init() { | |||
try { | |||
Ajde.init( | |||
null, | |||
null, | |||
null, | |||
projectProperties, | |||
buildOptions, | |||
null, | |||
null, | |||
null); | |||
//Ajde.getDefault().enableLogging( System.out ); | |||
} catch (Throwable t) { | |||
t.printStackTrace(); | |||
Ajde.getDefault().getErrorHandler().handleError( | |||
"Ajde failed to initialize.", | |||
t); | |||
} | |||
} | |||
private void assertOptionEquals( String reason, Map options, String optionName, String value) { | |||
String mapValue = (String) options.get(optionName); | |||
assertEquals( reason, value, mapValue ); | |||
} | |||
} |
@@ -8,11 +8,16 @@ | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* AMC 01.21.2003 extended to cover new AspectJ1.1 options | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
import java.util.HashSet; | |||
import java.util.Iterator; | |||
import java.util.Set; | |||
import junit.framework.TestSuite; | |||
import org.aspectj.ajde.ui.UserPreferencesAdapter; | |||
@@ -47,6 +52,97 @@ public class BuildOptionsTest extends AjdeTestCase { | |||
buildOptions.setPortingMode(true); | |||
assertTrue("porting mode", buildOptions.getPortingMode()); | |||
} | |||
public void testVerboseMode() { | |||
buildOptions.setVerboseMode(true); | |||
assertTrue("verbose mode", buildOptions.getVerboseMode()); | |||
} | |||
public void testNonStandardOptions() { | |||
buildOptions.setNonStandardOptions( "-Xlint" ); | |||
assertEquals( "non std options", "-Xlint", | |||
buildOptions.getNonStandardOptions()); | |||
} | |||
public void testComplianceLevel() { | |||
buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14 ); | |||
assertEquals( "compliance level", | |||
BuildOptionsAdapter.VERSION_14, | |||
buildOptions.getComplianceLevel()); | |||
} | |||
public void testSourceCompatibilityLevel() { | |||
buildOptions.setSourceCompatibilityLevel(BuildOptionsAdapter.VERSION_13); | |||
assertEquals( "source level", | |||
BuildOptionsAdapter.VERSION_13, | |||
buildOptions.getSourceCompatibilityLevel()); | |||
} | |||
public void testWarnings() { | |||
buildOptions.setWarnings( null ); | |||
assertNull( "null warning set", buildOptions.getWarnings()); | |||
HashSet s = new HashSet(); | |||
buildOptions.setWarnings( s ); | |||
Set s2 = buildOptions.getWarnings(); | |||
assertTrue( "empty warning set", s2.isEmpty() ); | |||
s.add( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER ); | |||
s.add( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS ); | |||
buildOptions.setWarnings( s ); | |||
s2 = buildOptions.getWarnings(); | |||
assertTrue( "two warnings", s2.size() == 2 ); | |||
boolean warn_assert_found = false; | |||
boolean warn_catch_found = false; | |||
Iterator it = s2.iterator(); | |||
while (it.hasNext()) { | |||
String option = (String) it.next(); | |||
if ( option.equals( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER ) ) { | |||
warn_assert_found = true; | |||
} | |||
if ( option.equals( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS ) ) { | |||
warn_catch_found = true; | |||
} | |||
} | |||
assertTrue( "assert warning found", warn_assert_found ); | |||
assertTrue( "catch waning found", warn_catch_found ); | |||
} | |||
public void testDebugLevel() { | |||
buildOptions.setDebugLevel( null ); | |||
assertNull( "null debug set", buildOptions.getDebugLevel()); | |||
HashSet s = new HashSet(); | |||
buildOptions.setDebugLevel( s ); | |||
Set s2 = buildOptions.getDebugLevel(); | |||
assertTrue( "empty debug set", s2.isEmpty() ); | |||
s.add( BuildOptionsAdapter.DEBUG_LINES ); | |||
s.add( BuildOptionsAdapter.DEBUG_SOURCE ); | |||
buildOptions.setDebugLevel( s ); | |||
s2 = buildOptions.getDebugLevel(); | |||
assertTrue( "two warnings", s2.size() == 2 ); | |||
boolean debug_lines_found = false; | |||
boolean debug_source_found = false; | |||
Iterator it = s2.iterator(); | |||
while (it.hasNext()) { | |||
String option = (String) it.next(); | |||
if ( option.equals( BuildOptionsAdapter.DEBUG_LINES ) ) { | |||
debug_lines_found = true; | |||
} | |||
if ( option.equals( BuildOptionsAdapter.DEBUG_SOURCE ) ) { | |||
debug_source_found = true; | |||
} | |||
} | |||
assertTrue( "debug lines found", debug_lines_found ); | |||
assertTrue( "debug source found", debug_source_found ); | |||
} | |||
public void testNoImportError() { | |||
buildOptions.setNoImportError(true); | |||
assertTrue("no import error", buildOptions.getNoImportError()); | |||
} | |||
public void testPreserveLocals() { | |||
buildOptions.setPreserveAllLocals(true); | |||
assertTrue("preserve all locals", buildOptions.getPreserveAllLocals()); | |||
} | |||
protected void setUp() throws Exception { | |||
super.setUp(); |
@@ -44,6 +44,8 @@ public class NullIdeManager { | |||
new IconRegistry(), | |||
nullFrame, | |||
true); | |||
//Ajde.getDefault().enableLogging( System.out ); | |||
} catch (Throwable t) { | |||
t.printStackTrace(); | |||
Ajde.getDefault().getErrorHandler().handleError( |
@@ -8,6 +8,7 @@ | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* AMC 01.20.2003 extended to support AspectJ 1.1 options | |||
* ******************************************************************/ | |||
@@ -24,6 +25,11 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { | |||
private String testProjectPath = ""; | |||
private List buildConfigFiles = new ArrayList(); | |||
private Set inJars; | |||
private Set sourceRoots; | |||
private Set aspectPath; | |||
private String outJar; | |||
public NullIdeProperties(String testProjectPath) { | |||
this.testProjectPath = testProjectPath; | |||
} | |||
@@ -58,7 +64,10 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { | |||
public String getClasspath() { | |||
//XXX | |||
return testProjectPath + System.getProperty("sun.boot.class.path") + File.pathSeparator + "../../../runtime/bin"; | |||
// AMC - added in path separator since absence was causing | |||
// build failures with invalid classpath | |||
return testProjectPath + File.pathSeparator + | |||
System.getProperty("sun.boot.class.path") + File.pathSeparator + "../runtime/bin"; | |||
} | |||
public String getOutputPath() { | |||
@@ -84,4 +93,28 @@ public class NullIdeProperties implements ProjectPropertiesAdapter { | |||
public String getVmArgs() { | |||
return null; | |||
} | |||
public void setInJars( Set jars ) { this.inJars = jars; } | |||
public Set getInJars( ) { | |||
return inJars; | |||
} | |||
public void setOutJar( String jar ){ this.outJar = jar; } | |||
public String getOutJar() { | |||
return outJar; | |||
} | |||
public void setSourceRoots( Set roots ) { this.sourceRoots = roots; } | |||
public Set getSourceRoots() { | |||
return sourceRoots; | |||
} | |||
public void setAspectPath( Set path ) { this.aspectPath = path; } | |||
public Set getAspectPath() { | |||
return aspectPath; | |||
} | |||
} |
@@ -14,10 +14,12 @@ | |||
package org.aspectj.ajde; | |||
import java.io.File; | |||
import java.util.List; | |||
import junit.framework.TestSuite; | |||
import org.aspectj.asm.StructureModel; | |||
import org.aspectj.asm.StructureNode; | |||
public class StructureModelRegressionTest extends AjdeTestCase { | |||
@@ -36,7 +38,7 @@ public class StructureModelRegressionTest extends AjdeTestCase { | |||
} | |||
public void test() { | |||
String testLstFile = "StructureModelRegressionTest/example.lst"; | |||
String testLstFile = "testdata/StructureModelRegressionTest/example.lst"; | |||
File f = new File(testLstFile); | |||
assertTrue(testLstFile, f.canRead()); | |||
assertTrue("saved model: " + testLstFile, verifyAgainstSavedModel(testLstFile)); | |||
@@ -52,7 +54,14 @@ public class StructureModelRegressionTest extends AjdeTestCase { | |||
StructureModel savedModel = Ajde.getDefault().getStructureModelManager().getStructureModel(); | |||
//System.err.println( savedModel.getRoot().getClass() + ", " + savedModel.getRoot()); | |||
return savedModel.getRoot().equals(model.getRoot()); | |||
// AMC This test will not pass as written until StructureNode defines | |||
// equals. The equals loic is commented out in the StructureNode | |||
// class - adding it back in could have unforeseen system-wide | |||
// consequences, so I've defined a structureNodesEqual( ) helper | |||
// method here instead. | |||
StructureNode rootNode = model.getRoot(); | |||
StructureNode savedRootNode = savedModel.getRoot(); | |||
return structureNodesEqual( rootNode, savedRootNode ); | |||
} else { | |||
Ajde.getDefault().getStructureModelManager().writeStructureModel(lstFile); | |||
return true; | |||
@@ -60,6 +69,30 @@ public class StructureModelRegressionTest extends AjdeTestCase { | |||
//return true; | |||
} | |||
private boolean structureNodesEqual( StructureNode s1, StructureNode s2 ) { | |||
final boolean equal = true; | |||
if ( s1 == s2 ) return equal; | |||
if ( null == s1 || null == s2 ) return !equal; | |||
if (!s1.getName( ).equals(s2.getName())) return !equal; | |||
if (!s1.getKind( ).equals(s2.getKind())) return !equal; | |||
// check child nodes | |||
List s1Kids = s1.getChildren(); | |||
List s2Kids = s2.getChildren(); | |||
if ( s1Kids != null && s2Kids != null ) { | |||
if (s1Kids == null || s2Kids == null) return !equal; | |||
if (s1Kids.size() != s2Kids.size() ) return !equal; | |||
for ( int k=0; k<s1Kids.size(); k++ ) { | |||
StructureNode k1 = (StructureNode) s1Kids.get(k); | |||
StructureNode k2 = (StructureNode) s2Kids.get(k); | |||
if (!structureNodesEqual( k1, k2 )) return !equal; | |||
} | |||
} | |||
return equal; | |||
} | |||
private StructureModel getModelForFile(String lstFile) { | |||
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lstFile); | |||
Ajde.getDefault().getBuildManager().buildStructure(); |
@@ -8,6 +8,7 @@ | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* AMC 21.01.2003 fixed for new source location in eclipse.org | |||
* ******************************************************************/ | |||
package org.aspectj.ajde; | |||
@@ -43,7 +44,7 @@ public class StructureModelTest extends AjdeTestCase { | |||
} | |||
public void testFieldInitializerCorrespondence() throws IOException { | |||
File testFile = createFile("../examples/figures-coverage/figures/Figure.java"); | |||
File testFile = createFile("testdata/examples/figures-coverage/figures/Figure.java"); | |||
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( | |||
testFile.getCanonicalPath(), 28); | |||
assertTrue("find result", node != null) ; | |||
@@ -65,7 +66,7 @@ public class StructureModelTest extends AjdeTestCase { | |||
assertTrue("find associated node", foundNode != null) ; | |||
File pointFile = createFile("../examples/figures-coverage/figures/primitives/planar/Point.java"); | |||
File pointFile = createFile("testdata/examples/figures-coverage/figures/primitives/planar/Point.java"); | |||
StructureNode fieldNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( | |||
pointFile.getCanonicalPath(), 12); | |||
assertTrue("find result", fieldNode != null); | |||
@@ -74,7 +75,7 @@ public class StructureModelTest extends AjdeTestCase { | |||
} | |||
public void testFileNodeFind() throws IOException { | |||
File testFile = createFile("../examples/figures-coverage/figures/Main.java"); | |||
File testFile = createFile("testdata/examples/figures-coverage/figures/Main.java"); | |||
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( | |||
testFile.getCanonicalPath(), 1); | |||
assertTrue("find result", node != null) ; | |||
@@ -87,7 +88,7 @@ public class StructureModelTest extends AjdeTestCase { | |||
*/ | |||
public void testMainClassNodeInfo() throws IOException { | |||
assertTrue("root exists", Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot() != null); | |||
File testFile = createFile("../examples/figures-coverage/figures/Main.java"); | |||
File testFile = createFile("testdata/examples/figures-coverage/figures/Main.java"); | |||
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( | |||
testFile.getCanonicalPath(), 11); | |||
assertTrue("find result", node != null); |
@@ -83,6 +83,7 @@ public class StructureViewManagerTest extends AjdeTestCase { | |||
assertTrue("notified", renderer.getHasBeenNotified()); | |||
//System.err.println(">>>>>> " + currentView.getRootNode().getStructureNode()); | |||
StructureNode n = currentView.getRootNode().getStructureNode(); | |||
assertTrue( | |||
"no structure", | |||
currentView.getRootNode().getStructureNode().getChildren().get(0) |
@@ -355,7 +355,9 @@ public class BuildArgParser extends org.eclipse.jdt.internal.compiler.batch.Main | |||
} else if (arg.equals("-emacssym")) { | |||
buildConfig.setEmacsSymMode(true); | |||
buildConfig.setGenerateModelMode(true); | |||
} else if (arg.equals("-noweave")) { | |||
//AMC - added -XnoWeave to options that match, in line with | |||
// AspectJ 1.1 release notes documentation. | |||
} else if (arg.equals("-noweave") || arg.equals( "-XnoWeave")) { | |||
buildConfig.setNoWeave(true); | |||
} else if (arg.equals("-XserializableAspects")) { | |||
buildConfig.setXserializableAspects(true); |
@@ -8,6 +8,9 @@ | |||
* | |||
* Contributors: | |||
* PARC initial implementation | |||
* Adrian Colyer added constructor to populate javaOptions with | |||
* default settings - 01.20.2003 | |||
* Bugzilla #29768, 29769 | |||
* ******************************************************************/ | |||
@@ -16,12 +19,14 @@ package org.aspectj.ajdt.internal.core.builder; | |||
import java.io.File; | |||
import java.util.*; | |||
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; | |||
/** | |||
* All configuration information needed to run the AspectJ compiler. | |||
*/ | |||
public class AjBuildConfig { | |||
public static final String AJLINT_INGORE = "ignore"; | |||
public static final String AJLINT_IGNORE = "ignore"; | |||
public static final String AJLINT_WARN = "warn"; | |||
public static final String AJLINT_ERROR = "error"; | |||
public static final String AJLINT_DEFAULT = "default"; | |||
@@ -44,6 +49,72 @@ public class AjBuildConfig { | |||
private String lintMode = AJLINT_DEFAULT; | |||
private File lintSpecFile = null; | |||
/** | |||
* Intialises the javaOptions Map to hold the default | |||
* JDT Compiler settings. Added by AMC 01.20.2003 in reponse | |||
* to bug #29768 and enh. 29769. | |||
* The settings here are duplicated from those set in | |||
* org.eclipse.jdt.internal.compiler.batch.Main, but I've elected to | |||
* copy them rather than refactor the JDT class since this keeps | |||
* integration with future JDT releases easier (?). | |||
*/ | |||
public AjBuildConfig( ) { | |||
javaOptions.put( | |||
CompilerOptions.OPTION_LocalVariableAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_LineNumberAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_SourceFileAttribute, | |||
CompilerOptions.DO_NOT_GENERATE); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_PreserveUnusedLocal, | |||
CompilerOptions.OPTIMIZE_OUT); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportUnreachableCode, | |||
CompilerOptions.ERROR); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportInvalidImport, | |||
CompilerOptions.ERROR); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod, | |||
CompilerOptions.WARNING); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportMethodWithConstructorName, | |||
CompilerOptions.WARNING); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportDeprecation, | |||
CompilerOptions.WARNING); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportHiddenCatchBlock, | |||
CompilerOptions.WARNING); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportUnusedLocal, | |||
CompilerOptions.IGNORE); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportUnusedParameter, | |||
CompilerOptions.IGNORE); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportSyntheticAccessEmulation, | |||
CompilerOptions.IGNORE); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportNonExternalizedStringLiteral, | |||
CompilerOptions.IGNORE); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_ReportAssertIdentifier, | |||
CompilerOptions.IGNORE); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_Compliance, | |||
CompilerOptions.VERSION_1_3); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_Source, | |||
CompilerOptions.VERSION_1_3); | |||
javaOptions.put( | |||
CompilerOptions.OPTION_TargetPlatform, | |||
CompilerOptions.VERSION_1_1); | |||
} | |||
/** | |||
* returned files includes <ul> | |||
* <li>files explicitly listed on command-line</li> |
@@ -335,7 +335,7 @@ public class BuildArgParserTestCase extends TestCase { | |||
config = parser.genBuildConfig(new String[] {"-Xlint:error"}, messageWriter); | |||
assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_ERROR)); | |||
config = parser.genBuildConfig(new String[] {"-Xlint:ignore"}, messageWriter); | |||
assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_INGORE)); | |||
assertTrue("", config.getLintMode().equals(AjBuildConfig.AJLINT_IGNORE)); | |||
} | |||
public void testXlintfile() throws InvalidInputException { |