summaryrefslogtreecommitdiffstats
path: root/ajde.core
diff options
context:
space:
mode:
authoraclement <aclement>2008-08-31 20:27:08 +0000
committeraclement <aclement>2008-08-31 20:27:08 +0000
commit74407d4cb10df42abcb685da3ffb26344849437b (patch)
tree1f0a24298dce01132a08eec006db215d644414f3 /ajde.core
parentfd8aebb985420425a95e163b814cc03bd997f042 (diff)
downloadaspectj-74407d4cb10df42abcb685da3ffb26344849437b.tar.gz
aspectj-74407d4cb10df42abcb685da3ffb26344849437b.zip
removing unused code
Diffstat (limited to 'ajde.core')
-rw-r--r--ajde.core/src/org/aspectj/ajde/core/AjCompiler.java120
-rw-r--r--ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java194
-rw-r--r--ajde.core/testsrc/org/aspectj/ajde/core/tests/AjConfigTests.java2
3 files changed, 151 insertions, 165 deletions
diff --git a/ajde.core/src/org/aspectj/ajde/core/AjCompiler.java b/ajde.core/src/org/aspectj/ajde/core/AjCompiler.java
index afd8d784f..221f0b58c 100644
--- a/ajde.core/src/org/aspectj/ajde/core/AjCompiler.java
+++ b/ajde.core/src/org/aspectj/ajde/core/AjCompiler.java
@@ -17,84 +17,54 @@ import org.aspectj.bridge.Message;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
/**
- * The class to be used by tools to drive a build. An AjCompiler is created
- * with a unique id (for example the absolute pathname of a project
- * or .lst file) along with implementations of ICompilerConfiguration,
- * IBuildProgressMonitor and IBuildMessageHandler. Tools then call
- * build() or buildFresh() on this AjCompiler.
+ * The class to be used by tools to drive a build. An AjCompiler is created with a unique id (for example the absolute pathname of a
+ * project or .lst file) along with implementations of ICompilerConfiguration, IBuildProgressMonitor and IBuildMessageHandler. Tools
+ * then call build() or buildFresh() on this AjCompiler.
*
- * <p>An AjCompiler is associated with one id, therefore a new one
- * needs to be created for a new id (project, .lst file etc.). It is the
- * responsibility of the tools to manage the lifecycle of the AjCompiler's.
+ * <p>
+ * An AjCompiler is associated with one id, therefore a new one needs to be created for a new id (project, .lst file etc.). It is
+ * the responsibility of the tools to manage the lifecycle of the AjCompiler's.
*/
public class AjCompiler {
+ private String compilerId;
private ICompilerConfiguration compilerConfig;
private IBuildProgressMonitor monitor;
private IBuildMessageHandler handler;
- private String compilerId;
-
private AjdeCoreBuildManager buildManager;
/**
- * Creates a new AjCompiler for the given id, ICompilerConfiguration,
- * IBuildProgressMonitor and IBuildMessageHandler. None of the arguments
- * can be null.
+ * Creates a new AjCompiler for the given id, ICompilerConfiguration, IBuildProgressMonitor and IBuildMessageHandler. None of
+ * the arguments can be null.
*
* @param compilerId - Unique String used to identify this AjCompiler
* @param compilerConfig - ICompilerConfiguration implementation
* @param buildProgressMonitor - IBuildProgressMonitor implementation
* @param buildMessageHandler - IBuildMessageHandler implementation
*/
- public AjCompiler(
- String compilerId,
- ICompilerConfiguration compilerConfig,
- IBuildProgressMonitor buildProgressMonitor,
+ public AjCompiler(String compilerId, ICompilerConfiguration compilerConfig, IBuildProgressMonitor buildProgressMonitor,
IBuildMessageHandler buildMessageHandler) {
this.compilerConfig = compilerConfig;
this.monitor = buildProgressMonitor;
this.handler = buildMessageHandler;
this.compilerId = compilerId;
-
- buildManager = new AjdeCoreBuildManager(this);
- }
-
- /**
- * Set a CustomMungerFactory to the compiler's weaver
- *
- * The type of factory should be org.aspectj.weaver.CustomMungerFactory but
- * due to dependency problem of project ajde.core, it is Object for now.
- *
- * @param factory
- */
- public void setCustomMungerFactory(Object factory) {
- buildManager.setCustomMungerFactory(factory);
+ this.buildManager = new AjdeCoreBuildManager(this);
}
/**
- * @return the CustomMungerFactory from the compiler's weaver
- *
- * The return type should be org.aspectj.weaver.CustomMungerFactory but
- * due to dependency problem of project ajde.core, it is Object for now.
- */
- public Object getCustomMungerFactory() {
- return buildManager.getCustomMungerFactory();
- }
-
- /**
* @return the id for this AjCompiler
*/
public String getId() {
return compilerId;
}
-
+
/**
* @return the ICompilerConfiguration associated with this AjCompiler
*/
public ICompilerConfiguration getCompilerConfiguration() {
return compilerConfig;
}
-
+
/**
* @return the IBuildProgressMonitor associated with this AjCompiler
*/
@@ -108,56 +78,72 @@ public class AjCompiler {
public IBuildMessageHandler getMessageHandler() {
return handler;
}
-
+
/**
- * Perform an incremental build if possible, otherwise it will
- * default to a full build.
+ * Perform an incremental build if possible, otherwise it will default to a full build.
*/
public void build() {
if (hasValidId()) {
- buildManager.doBuild(false);
+ buildManager.performBuild(false);
}
}
-
+
/**
- * Perform a full build
+ * Perform a full build.
*/
public void buildFresh() {
if (hasValidId()) {
- buildManager.doBuild(true);
+ buildManager.performBuild(true);
}
}
-
+
/**
- * Clear the incremental state associated with this AjCompiler
- * from the IncrementalStateManager. This is necessary until AjState
- * is reworked and there's an AjState associated with an AjCompiler
- * rather than requiring a map of them.
+ * Clear the incremental state associated with this AjCompiler from the IncrementalStateManager. This is necessary until AjState
+ * is reworked and there's an AjState associated with an AjCompiler rather than requiring a map of them.
*/
public void clearLastState() {
IncrementalStateManager.removeIncrementalStateInformationFor(compilerId);
}
-
+
/**
- * @return true if the underlying version of the compiler
- * is compatible with Java 6, returns false otherwise.
+ * @return true if the underlying version of the compiler is compatible with Java 6, returns false otherwise.
*/
public boolean isJava6Compatible() {
return CompilerOptions.versionToJdkLevel(JavaOptions.VERSION_16) != 0;
}
-
+
/**
- * Ensures that the id associated with this compiler is non-null. If
- * it is null then sends an ABORT message to the messageHandler
+ * Ensures that the id associated with this compiler is non-null. If it is null then sends an ABORT message to the
+ * messageHandler.
*/
private boolean hasValidId() {
if (compilerId == null) {
- Message msg = new Message("compiler didn't have an id associated " +
- "with it",IMessage.ABORT,null,null);
- handler.handleMessage(msg);
- return false;
- }
+ Message msg = new Message("compiler didn't have an id associated with it", IMessage.ABORT, null, null);
+ handler.handleMessage(msg);
+ return false;
+ }
return true;
}
-
+
+ /**
+ * Set a CustomMungerFactory to the compiler's weaver
+ *
+ * The type of factory should be org.aspectj.weaver.CustomMungerFactory but due to dependency problem of project ajde.core, it
+ * is Object for now.
+ *
+ * @param factory
+ */
+ public void setCustomMungerFactory(Object factory) {
+ buildManager.setCustomMungerFactory(factory);
+ }
+
+ /**
+ * @return the CustomMungerFactory from the compiler's weaver
+ *
+ * The return type should be org.aspectj.weaver.CustomMungerFactory but due to dependency problem of project ajde.core,
+ * it is Object for now.
+ */
+ public Object getCustomMungerFactory() {
+ return buildManager.getCustomMungerFactory();
+ }
}
diff --git a/ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java b/ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java
index 850fde2e7..30da06449 100644
--- a/ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java
+++ b/ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java
@@ -46,16 +46,16 @@ import org.aspectj.util.LangUtil;
public class AjdeCoreBuildManager {
private AjCompiler compiler;
-
- private AjdeCoreBuildNotifierAdapter currNotifier = null;
+ private AjdeCoreBuildNotifierAdapter buildEventNotifier = null;
private AjBuildManager ajBuildManager;
private IMessageHandler msgHandlerAdapter;
public AjdeCoreBuildManager(AjCompiler compiler) {
this.compiler = compiler;
- msgHandlerAdapter = new AjdeCoreMessageHandlerAdapter(compiler.getMessageHandler());
- ajBuildManager = new AjBuildManager(msgHandlerAdapter);
- ajBuildManager.environmentSupportsIncrementalCompilation(true);
+ this.msgHandlerAdapter = new AjdeCoreMessageHandlerAdapter(compiler.getMessageHandler());
+ this.ajBuildManager = new AjBuildManager(msgHandlerAdapter);
+ this.ajBuildManager.environmentSupportsIncrementalCompilation(true);
+
// this static information needs to be set to ensure
// incremental compilation works correctly
IncrementalStateManager.recordIncrementalStates = true;
@@ -63,45 +63,51 @@ public class AjdeCoreBuildManager {
AsmManager.attemptIncrementalModelRepairs = true;
}
- // XXX hideous, should not be Object
- public void setCustomMungerFactory(Object o) {
- ajBuildManager.setCustomMungerFactory(o);
- }
-
- public Object getCustomMungerFactory() {
- return ajBuildManager.getCustomMungerFactory();
- }
-
/**
- * @param buildFresh - true if want to force a full build, false otherwise
+ * Execute a full or incremental build
+ *
+ * @param fullBuild true if requesting a full build, false if requesting to try an incremental build
*/
- public void doBuild(boolean buildFresh) {
- if (!buildFresh) {
- buildFresh = updateAsmManagerInformation();
+ public void performBuild(boolean fullBuild) {
+
+ // If an incremental build is requested, check that we can
+ if (!fullBuild) {
+ AjState existingState = IncrementalStateManager.retrieveStateFor(compiler.getId());
+ if (existingState == null) {
+ // No existing state so we must do a full build
+ fullBuild = true;
+ } else {
+ AsmManager.getDefault().setRelationshipMap(existingState.getRelationshipMap());
+ AsmManager.getDefault().setHierarchy(existingState.getStructureModel());
+ }
}
try {
- startNotifiers();
+ reportProgressBegin();
- // record the options passed to the compiler
- if (!compiler.getMessageHandler().isIgnoring(IMessage.INFO)) {
+ // record the options passed to the compiler if INFO turned on
+ if (!msgHandlerAdapter.isIgnoring(IMessage.INFO)) {
handleMessage(new Message(getFormattedOptionsString(), IMessage.INFO, null, null));
}
CompilationAndWeavingContext.reset();
- if (buildFresh) {
- AjBuildConfig buildConfig = genAjBuildConfig();
+ if (fullBuild) { // FULL BUILD
+ AjBuildConfig buildConfig = generateAjBuildConfig();
if (buildConfig == null) {
return;
}
ajBuildManager.batchBuild(buildConfig, msgHandlerAdapter);
- } else {
+ } else { // INCREMENTAL BUILD
// Only rebuild the config object if the configuration has changed
AjBuildConfig buildConfig = null;
ICompilerConfiguration compilerConfig = compiler.getCompilerConfiguration();
int changes = compilerConfig.getConfigurationChanges();
if (changes != ICompilerConfiguration.NO_CHANGES) {
- buildConfig = genAjBuildConfig();
+
+ // What configuration changes can we cope with? And besides just repairing the config object
+ // what does it mean for any existing state that we have?
+
+ buildConfig = generateAjBuildConfig();
if (buildConfig == null) {
return;
}
@@ -144,25 +150,10 @@ public class AjdeCoreBuildManager {
/**
* Starts the various notifiers which are interested in the build progress
*/
- private void startNotifiers() {
+ private void reportProgressBegin() {
compiler.getBuildProgressMonitor().begin();
- currNotifier = new AjdeCoreBuildNotifierAdapter(compiler.getBuildProgressMonitor());
- ajBuildManager.setProgressListener(currNotifier);
- }
-
- /**
- * Switches the relationshipMap and hierarchy used by AsmManager to be the one for the current compiler - this will not be
- * necessary once the static nature is removed from the asm.
- */
- private boolean updateAsmManagerInformation() {
- AjState updatedState = IncrementalStateManager.retrieveStateFor(compiler.getId());
- if (updatedState == null) {
- return true;
- } else {
- AsmManager.getDefault().setRelationshipMap(updatedState.getRelationshipMap());
- AsmManager.getDefault().setHierarchy(updatedState.getStructureModel());
- }
- return false;
+ buildEventNotifier = new AjdeCoreBuildNotifierAdapter(compiler.getBuildProgressMonitor());
+ ajBuildManager.setProgressListener(buildEventNotifier);
}
private String getFormattedOptionsString() {
@@ -211,65 +202,37 @@ public class AjdeCoreBuildManager {
}
/**
- * Generate a new AjBuildConfig from the compiler configuration associated with this AjdeCoreBuildManager
+ * Generate a new AjBuildConfig from the compiler configuration associated with this AjdeCoreBuildManager or from a
+ * configuration file.
*
* @return null if invalid configuration, corresponding AjBuildConfig otherwise
*/
- public AjBuildConfig genAjBuildConfig() {
+ public AjBuildConfig generateAjBuildConfig() {
File configFile = new File(compiler.getId());
+ ICompilerConfiguration compilerConfig = compiler.getCompilerConfiguration();
+ CountingMessageHandler handler = CountingMessageHandler.makeCountingMessageHandler(msgHandlerAdapter);
+
String[] args = null;
+ // Retrieve the set of files from either an arg file (@filename) or the compiler configuration
if (configFile.exists() && configFile.isFile()) {
args = new String[] { "@" + configFile.getAbsolutePath() };
} else {
- List l = compiler.getCompilerConfiguration().getProjectSourceFiles();
- if (l == null)
+ List l = compilerConfig.getProjectSourceFiles();
+ if (l == null) {
return null;
- args = new String[l.size()];
- int counter = 0;
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
- args[counter] = element;
- counter++;
}
+ args = (String[]) l.toArray(new String[l.size()]);
}
- CountingMessageHandler handler = CountingMessageHandler.makeCountingMessageHandler(msgHandlerAdapter);
+
BuildArgParser parser = new BuildArgParser(handler);
AjBuildConfig config = new AjBuildConfig();
- parser.populateBuildConfig(config, args, false, configFile);
- configureCompilerOptions(config);
- compiler.getCompilerConfiguration().configurationRead();
- ISourceLocation location = null;
- if (config.getConfigFile() != null) {
- location = new SourceLocation(config.getConfigFile(), 0);
- }
-
- String message = parser.getOtherMessages(true);
- if (null != message) {
- IMessage m = new Message(message, IMessage.ERROR, null, location);
- handler.handleMessage(m);
- }
-
- // always force model generation in AJDE
- config.setGenerateModelMode(true);
- // always be in incremental mode in AJDE
- config.setIncrementalMode(true);
- // always force proceedOnError in AJDE
- config.setProceedOnError(true);
- return config;
- }
-
- /**
- * Configure the given AjBuildConfig with the options found in the ICompilerConfiguration implementation associated with the
- * AjCompiler for this AjdeCoreBuildManager
- *
- * @param config
- */
- private void configureCompilerOptions(AjBuildConfig config) {
+ parser.populateBuildConfig(config, args, false, configFile);
- String propcp = compiler.getCompilerConfiguration().getClasspath();
- if (!LangUtil.isEmpty(propcp)) {
+ // Process the CLASSPATH
+ String propcp = compilerConfig.getClasspath();
+ if (propcp != null && propcp.length() != 0) {
StringTokenizer st = new StringTokenizer(propcp, File.pathSeparator);
List configClasspath = config.getClasspath();
ArrayList toAdd = new ArrayList();
@@ -287,29 +250,36 @@ public class AjdeCoreBuildManager {
}
}
- // set the outputjar
+ // Process the OUTJAR
if (config.getOutputJar() == null) {
- String outJar = compiler.getCompilerConfiguration().getOutJar();
- if (!LangUtil.isEmpty(outJar)) {
+ String outJar = compilerConfig.getOutJar();
+ if (outJar != null && outJar.length() != 0) {
config.setOutputJar(new File(outJar));
}
}
- // set compilation result destination manager
- IOutputLocationManager outputLocationManager = compiler.getCompilerConfiguration().getOutputLocationManager();
+ // Process the OUTPUT LOCATION MANAGER
+ IOutputLocationManager outputLocationManager = compilerConfig.getOutputLocationManager();
if (config.getCompilationResultDestinationManager() == null && outputLocationManager != null) {
config.setCompilationResultDestinationManager(new OutputLocationAdapter(outputLocationManager));
}
- join(config.getInpath(), compiler.getCompilerConfiguration().getInpath());
+ // Process the INPATH
+ mergeInto(config.getInpath(), compilerConfig.getInpath());
// bug 168840 - calling 'setInPath(..)' creates BinarySourceFiles which
// are used to see if there have been changes in classes on the inpath
- if (config.getInpath() != null)
+ if (config.getInpath() != null) {
config.setInPath(config.getInpath());
- config.setSourcePathResources(compiler.getCompilerConfiguration().getSourcePathResources());
- join(config.getAspectpath(), compiler.getCompilerConfiguration().getAspectPath());
+ }
- Map jom = compiler.getCompilerConfiguration().getJavaOptionsMap();
+ // Process the SOURCE PATH RESOURCES
+ config.setSourcePathResources(compilerConfig.getSourcePathResources());
+
+ // Process the ASPECTPATH
+ mergeInto(config.getAspectpath(), compilerConfig.getAspectPath());
+
+ // Process the JAVA OPTIONS MAP
+ Map jom = compilerConfig.getJavaOptionsMap();
if (jom != null) {
String version = (String) jom.get(CompilerOptions.OPTION_Compliance);
if (version != null && (version.equals(CompilerOptions.VERSION_1_5) || version.equals(CompilerOptions.VERSION_1_6))) {
@@ -318,10 +288,32 @@ public class AjdeCoreBuildManager {
config.getOptions().set(jom);
}
+ // Process the NON-STANDARD COMPILER OPTIONS
configureNonStandardOptions(config);
+
+ compilerConfig.configurationRead();
+
+ ISourceLocation location = null;
+ if (config.getConfigFile() != null) {
+ location = new SourceLocation(config.getConfigFile(), 0);
+ }
+
+ String message = parser.getOtherMessages(true);
+ if (null != message) {
+ IMessage m = new Message(message, IMessage.ERROR, null, location);
+ handler.handleMessage(m);
+ }
+
+ // always force model generation in AJDE
+ config.setGenerateModelMode(true);
+ // always be in incremental mode in AJDE
+ config.setIncrementalMode(true);
+ // always force proceedOnError in AJDE
+ config.setProceedOnError(true);
+ return config;
}
- private void join(Collection target, Collection source) {
+ private void mergeInto(Collection target, Collection source) {
if ((null == target) || (null == source)) {
return;
}
@@ -389,4 +381,12 @@ public class AjdeCoreBuildManager {
private void handleMessage(Message msg) {
compiler.getMessageHandler().handleMessage(msg);
}
+
+ public void setCustomMungerFactory(Object o) {
+ ajBuildManager.setCustomMungerFactory(o);
+ }
+
+ public Object getCustomMungerFactory() {
+ return ajBuildManager.getCustomMungerFactory();
+ }
}
diff --git a/ajde.core/testsrc/org/aspectj/ajde/core/tests/AjConfigTests.java b/ajde.core/testsrc/org/aspectj/ajde/core/tests/AjConfigTests.java
index c38c4e20e..ec474444b 100644
--- a/ajde.core/testsrc/org/aspectj/ajde/core/tests/AjConfigTests.java
+++ b/ajde.core/testsrc/org/aspectj/ajde/core/tests/AjConfigTests.java
@@ -217,7 +217,7 @@ public class AjConfigTests extends AjdeCoreTestCase {
}
private AjBuildConfig genAjBuildConfig() {
- AjBuildConfig buildConfig = ajdeBuildManager.genAjBuildConfig();
+ AjBuildConfig buildConfig = ajdeBuildManager.generateAjBuildConfig();
assertNotNull("exepected to generate a non null AjBuildConfig but " +
"didn't", buildConfig);
return buildConfig;