From: wisberg Date: Mon, 28 Apr 2003 23:22:33 +0000 (+0000) Subject: Checking in Mik's changes sent by email today for model and incremental support in... X-Git-Tag: V1_1_0_RC2~144 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c5175f34dc5c7828d67dec3b790632cccefbe8a6;p=aspectj.git Checking in Mik's changes sent by email today for model and incremental support in AJDE. ajde has the same test failing as it did before this checkin, perhaps caused by a regression per bug 37020 --- diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java index e6e5669e2..7100abed5 100644 --- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java +++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java @@ -47,6 +47,7 @@ public class CompilerAdapter { private boolean initialized = false; private boolean structureDirty = true; private boolean firstBuild = true; + private boolean incrementalEnabled = true; // XXX make false by default public CompilerAdapter() { super(); @@ -67,7 +68,7 @@ public class CompilerAdapter { public boolean compile(String configFile, BuildProgressMonitor progressMonitor) { init(); - try { + try { AjBuildConfig buildConfig = genBuildConfig(configFile); buildConfig.setGenerateModelMode(true); @@ -84,12 +85,12 @@ public class CompilerAdapter { 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"); @@ -424,4 +425,18 @@ public class CompilerAdapter { } } + /** + * @return + */ + public boolean isIncrementalEnabled() { + return incrementalEnabled; + } + + /** + * @param b + */ + public void setIncrementalEnabled(boolean b) { + incrementalEnabled = b; + } + } diff --git a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java index 5d4308951..32daa8a34 100644 --- a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java +++ b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java @@ -154,7 +154,7 @@ public class TreeStructureViewBuilder { 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 diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index b9a1ea588..4f2dbb6c5 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -163,22 +163,38 @@ public class AjBuildManager { //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()); // } @@ -186,6 +202,7 @@ public class AjBuildManager { 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; @@ -194,12 +211,6 @@ public class AjBuildManager { 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; @@ -208,10 +219,11 @@ public class AjBuildManager { state.successfulCompile(buildConfig); boolean weaved = weaveAndGenerateClassFiles(); + if (buildConfig.isGenerateModelMode()) { StructureModelManager.INSTANCE.fireModelUpdated(); - } + } return !handler.hasErrors(); } finally { handler = null; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java index b781dfbb8..572744043 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java @@ -64,6 +64,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter { new AsmBuilder().internalBuild(unit, structureModel); } + private void internalBuild(CompilationUnitDeclaration unit, StructureModel structureModel) { currCompilationResult = unit.compilationResult(); File file = new File(new String(unit.getFileName())); @@ -104,8 +105,30 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter { 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); }