private boolean initialized = false;
private boolean structureDirty = true;
private boolean firstBuild = true;
+ private boolean incrementalEnabled = true; // XXX make false by default
public CompilerAdapter() {
super();
public boolean compile(String configFile, BuildProgressMonitor progressMonitor) {
init();
- try {
+ try {
AjBuildConfig buildConfig = genBuildConfig(configFile);
buildConfig.setGenerateModelMode(true);
return false;
}
- if (firstBuild) {
- firstBuild = false;
- return buildManager.batchBuild(buildConfig, messageHandler);
- } else {
- return buildManager.batchBuild(buildConfig, messageHandler); // XXX incremental not implemented
+ if (incrementalEnabled && !firstBuild){
+ return buildManager.incrementalBuild(buildConfig, messageHandler); // XXX incremental not implemented
// return buildManager.incrementalBuild(buildConfig);
+ } else {
+ firstBuild = false;
+ return buildManager.batchBuild(buildConfig, messageHandler);
}
} catch (OperationCanceledException ce) {
Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("build cancelled by user");
}
}
+ /**
+ * @return
+ */
+ public boolean isIncrementalEnabled() {
+ return incrementalEnabled;
+ }
+
+ /**
+ * @param b
+ */
+ public void setIncrementalEnabled(boolean b) {
+ incrementalEnabled = b;
+ }
+
}
if (granularity == StructureViewProperties.Granularity.DECLARED_ELEMENTS) {
return true;
} else if (granularity == StructureViewProperties.Granularity.MEMBER &&
- (kind == ProgramElementNode.Kind.CODE)) {
+ (kind != ProgramElementNode.Kind.CODE)) {
return true;
} else if (granularity == StructureViewProperties.Granularity.TYPE
&& (kind == ProgramElementNode.Kind.PROJECT
//XXX fake incremental
public boolean incrementalBuild(AjBuildConfig buildConfig, IMessageHandler baseHandler) throws IOException {
+// StructureModelManager.INSTANCE.getStructureModel().getRoot().removeChildren();
+
+
if (!state.prepareForNextBuild(buildConfig)) {
return batchBuild(buildConfig, baseHandler);
}
+
+
//!!! too much cut-and-paste from batchBuild
this.handler = CountingMessageHandler.makeCountingMessageHandler(baseHandler);
+ String check = checkRtJar(buildConfig);
+ if (check != null) {
+ IMessage message = new Message(check, Message.WARNING, null, null);
+ // give delegate a chance to implement different message (abort)?
+ handler.handleMessage(message);
+ }
+
try {
setBuildConfig(buildConfig);
- //setupModel();
+ setupModel();
// initBcelWorld(handler);
// if (handler.hasErrors()) {
// return false;
// }
+ if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
+ bcelWorld.setModel(StructureModelManager.INSTANCE.getStructureModel());
+ }
+
// if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
// bcelWorld.setModel(StructureModelManager.INSTANCE.getStructureModel());
// }
List filesToCompile;
while ( !(filesToCompile = state.getFilesToCompile(count == 0)).isEmpty() ) {
//if (count > 0) return batchBuild(buildConfig, baseHandler); //??? only 1 try
+
performCompilation(filesToCompile);
if (handler.hasErrors()) return false;
return batchBuild(buildConfig, baseHandler);
}
}
-
- //System.err.println("built in " + count + " cycles");
-
-// if (buildConfig.isEmacsSymMode()) {
-// new org.aspectj.ajdt.internal.core.builder.EmacsStructureModelManager().externalizeModel();
-// }
if (handler.hasErrors()) {
return false;
state.successfulCompile(buildConfig);
boolean weaved = weaveAndGenerateClassFiles();
+
if (buildConfig.isGenerateModelMode()) {
StructureModelManager.INSTANCE.fireModelUpdated();
- }
+ }
return !handler.hasErrors();
} finally {
handler = null;
new AsmBuilder().internalBuild(unit, structureModel);
}
+
private void internalBuild(CompilationUnitDeclaration unit, StructureModel structureModel) {
currCompilationResult = unit.compilationResult();
File file = new File(new String(unit.getFileName()));
new ArrayList());
StructureModelManager.INSTANCE.getStructureModel().getRoot().addChild(pkgNode);
}
- pkgNode.addChild(cuNode);
+ // if the node already exists remove before adding
+ ProgramElementNode duplicate = null;
+ for (Iterator itt = pkgNode.getChildren().iterator(); itt.hasNext(); ) {
+ ProgramElementNode child = (ProgramElementNode)itt.next();
+ if (child.getSourceLocation().getSourceFile().equals(file)) {
+ duplicate = child;
+ }
+ }
+ if (duplicate != null) {
+ pkgNode.removeChild(duplicate);
+ }
+ pkgNode.addChild(cuNode);
} else {
+ // if the node already exists remove before adding
+ ProgramElementNode duplicate = null;
+ for (Iterator itt = StructureModelManager.INSTANCE.getStructureModel().getRoot().getChildren().iterator(); itt.hasNext(); ) {
+ ProgramElementNode child = (ProgramElementNode)itt.next();
+ if (child.getSourceLocation().getSourceFile().equals(file)) {
+ duplicate = child;
+ }
+ }
+ if (duplicate != null) {
+ StructureModelManager.INSTANCE.getStructureModel().getRoot().removeChild(duplicate);
+ }
StructureModelManager.INSTANCE.getStructureModel().getRoot().addChild(cuNode);
}