From c5175f34dc5c7828d67dec3b790632cccefbe8a6 Mon Sep 17 00:00:00 2001 From: wisberg Date: Mon, 28 Apr 2003 23:22:33 +0000 Subject: 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 --- .../ajdt/internal/core/builder/AjBuildManager.java | 28 +++++++++++++++------- .../ajdt/internal/core/builder/AsmBuilder.java | 25 ++++++++++++++++++- 2 files changed, 44 insertions(+), 9 deletions(-) (limited to 'org.aspectj.ajdt.core') 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); } -- cgit v1.2.3