]> source.dussan.org Git - aspectj.git/commitdiff
Checking in Mik's changes sent by email today for model and incremental support in...
authorwisberg <wisberg>
Mon, 28 Apr 2003 23:22:33 +0000 (23:22 +0000)
committerwisberg <wisberg>
Mon, 28 Apr 2003 23:22:33 +0000 (23:22 +0000)
ajde has the same test failing as it did before this checkin,
perhaps caused by a regression per bug 37020

ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java

index e6e5669e23a9c435579c9e8181053ca5d355a2c9..7100abed5edcc8b2331c42b21ffd8a03ffbc932f 100644 (file)
@@ -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;
+       }
+
 }
index 5d43089510ebcc720c68d873e16d8c75b34cc2ff..32daa8a3445687b0f7a730a6ecc108102e971557 100644 (file)
@@ -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
index b9a1ea58891f4e504f903937ce2b8d46a2e77161..4f2dbb6c51473f0f6103a7eab763cc235ea4b401 100644 (file)
@@ -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;        
index b781dfbb8384ba3077b4a42b96febcb2d147d986..572744043d16ab347ed84662536a2796fa511bba 100644 (file)
@@ -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);
                }