]> source.dussan.org Git - aspectj.git/commitdiff
Fixed bug#45489 "Structure model is wrong when re-opened"
authormkersten <mkersten>
Thu, 19 Feb 2004 16:02:06 +0000 (16:02 +0000)
committermkersten <mkersten>
Thu, 19 Feb 2004 16:02:06 +0000 (16:02 +0000)
ajde/testsrc/org/aspectj/ajde/AjdeTests.java
ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java [new file with mode: 0644]
asm/src/org/aspectj/asm/IProgramElement.java

index a6c7b740d0014cbddaf9c115af1c13e0fdd89610..22905ca8fb6c7566d39021de01cf0e160d3a2b1d 100644 (file)
@@ -33,6 +33,7 @@ public class AjdeTests extends TestCase {
                suite.addTestSuite(InpathTestcase.class);
                suite.addTestSuite(ResourceCopyTestCase.class);
                suite.addTestSuite(ModelPerformanceTest.class);
+               suite.addTestSuite(SavedModelConsistencyTest. class);
                
         //$JUnit-END$
         return suite;
diff --git a/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java b/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java
new file mode 100644 (file)
index 0000000..e74b2fc
--- /dev/null
@@ -0,0 +1,104 @@
+
+
+/* *******************************************************************
+ * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Common Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://www.eclipse.org/legal/cpl-v10.html 
+ *  
+ * Contributors: 
+ *     Mik Kersten     initial implementation 
+ * ******************************************************************/
+
+package org.aspectj.ajde;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.aspectj.asm.HierarchyWalker;
+import org.aspectj.asm.IHierarchy;
+import org.aspectj.asm.IProgramElement;
+
+/**
+ * @author Mik Kersten
+ */
+public class SavedModelConsistencyTest extends AjdeTestCase {
+       
+       private final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
+
+       public SavedModelConsistencyTest(String name) {
+               super(name);
+       }
+
+       public static void main(String[] args) {
+               junit.swingui.TestRunner.run(SavedModelConsistencyTest.class);
+       }
+       
+       public void testInterfaceIsSameInBoth() {
+               File configFile = openFile(CONFIG_FILE_PATH);   
+               Ajde.getDefault().getStructureModelManager().readStructureModel(configFile.getAbsolutePath());
+               
+        IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
+        assertTrue("model exists", model != null);
+        
+               assertTrue("root exists", model.getRoot() != null);
+               File testFile = openFile("../examples/coverage/ModelCoverage.java");
+               assertTrue(testFile.exists());
+               
+               IProgramElement nodePreBuild = model.findElementForSourceLine(testFile.getAbsolutePath(), 5);   
+//             System.err.println(nodePreBuild.getKind());
+
+               doSynchronousBuild(CONFIG_FILE_PATH);   
+
+               IProgramElement nodePostBuild = model.findElementForSourceLine(testFile.getAbsolutePath(), 5);  
+//             System.err.println(nodePostBuild.getKind());
+               
+               assertTrue(nodePreBuild.getKind().equals(nodePostBuild.getKind()));
+               
+       }
+
+       public void testModelIsSamePreAndPostBuild() {
+               File configFile = openFile(CONFIG_FILE_PATH);   
+               Ajde.getDefault().getStructureModelManager().readStructureModel(configFile.getAbsolutePath());
+               
+        IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
+        assertTrue("model exists", model != null);
+       
+        final List preBuildKinds = new ArrayList();
+               HierarchyWalker walker = new HierarchyWalker() {
+                   public void preProcess(IProgramElement node) {
+                       preBuildKinds.add(node.getKind());
+                   }
+               };
+               Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker);
+
+               doSynchronousBuild(CONFIG_FILE_PATH);
+               
+        final List postBuildKinds = new ArrayList();
+               HierarchyWalker walker2 = new HierarchyWalker() {
+                   public void preProcess(IProgramElement node) {
+                       postBuildKinds.add(node.getKind());
+                   }
+               };
+               Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker2);
+                       
+//             System.err.println(preBuildKinds);
+//             System.err.println(postBuildKinds);
+               
+               assertTrue(preBuildKinds.equals(postBuildKinds));
+               
+       }
+         
+       protected void setUp() throws Exception {
+               super.setUp("examples");
+       }
+
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+}
+
index 944675e2ba86e41ff340a2241997e53d959928c9..f45493e4ec41ca436c906d69ca64c749fdb2f736 100644 (file)
@@ -120,7 +120,7 @@ public interface IProgramElement extends Serializable {
                public static final Modifiers STRICTFP = new Modifiers("strictfp");
                public static final Modifiers TRANSIENT = new Modifiers("transient");
                public static final Modifiers NATIVE = new Modifiers("native");
-               public static final Modifiers[] ALL = { STATIC, FINAL, ABSTRACT, SYNCHRONIZED, TRANSIENT, VOLATILE, STRICTFP, NATIVE };
+               public static final Modifiers[] ALL = { STATIC, FINAL, ABSTRACT, SYNCHRONIZED, VOLATILE, STRICTFP, TRANSIENT, NATIVE };
                private final String name;
                
                private Modifiers(String name) {
@@ -211,9 +211,9 @@ public interface IProgramElement extends Serializable {
                                FILE_JAVA,
                                FILE_ASPECTJ,
                                FILE_LST,
+                               IMPORT_REFERENCE,
                                CLASS,
                                INTERFACE,
-                               IMPORT_REFERENCE,
                                ASPECT,
                                INITIALIZER,
                                INTER_TYPE_FIELD,
@@ -231,7 +231,9 @@ public interface IProgramElement extends Serializable {
                                DECLARE_SOFT,
                                DECLARE_PRECEDENCE,
                                CODE,
-                               ERROR };
+                               ERROR
+
+                       };
                
                public static Kind getKindForString(String kindString) {
                        for (int i = 0; i < ALL.length; i++) {