summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTests.java1
-rw-r--r--ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java104
-rw-r--r--asm/src/org/aspectj/asm/IProgramElement.java8
3 files changed, 110 insertions, 3 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
index a6c7b740d..22905ca8f 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
@@ -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
index 000000000..e74b2fc90
--- /dev/null
+++ b/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java
@@ -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();
+ }
+}
+
diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java
index 944675e2b..f45493e4e 100644
--- a/asm/src/org/aspectj/asm/IProgramElement.java
+++ b/asm/src/org/aspectj/asm/IProgramElement.java
@@ -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++) {