summaryrefslogtreecommitdiffstats
path: root/ajde
diff options
context:
space:
mode:
Diffstat (limited to 'ajde')
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java7
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java5
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewManager.java17
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java44
-rw-r--r--ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java9
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java7
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java26
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java2
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java2
-rw-r--r--ajde/testdata/examples/coverage/ModelCoverage.java8
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java1
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java116
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java35
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeManager.java9
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java10
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelTest.java25
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java12
17 files changed, 174 insertions, 161 deletions
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
index 578c04e0c..0923caa79 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
@@ -18,6 +18,7 @@ import java.util.*;
import org.aspectj.ajde.Ajde;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
/**
* Prototype functionality for package view clients.
@@ -114,9 +115,9 @@ public class StructureModelUtil {
public static List getPackagesInModel() {
List packages = new ArrayList();
- AspectJModel model =
- Ajde.getDefault().getStructureModelManager().getModel();
- if (model.equals(AspectJModel.NO_STRUCTURE)) {
+ IHierarchy model =
+ Ajde.getDefault().getStructureModelManager().getHierarchy();
+ if (model.equals(IHierarchy.NO_STRUCTURE)) {
return null;
} else {
return getPackagesHelper(
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java
index c1f77c243..835ccc5be 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java
@@ -18,6 +18,7 @@ import java.util.*;
import org.aspectj.ajde.Ajde;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
/**
* @author Mik Kersten
@@ -34,8 +35,8 @@ public class StructureSearchManager {
IProgramElement.Kind kind) {
List matches = new ArrayList();
- AspectJModel model = Ajde.getDefault().getStructureModelManager().getModel();
- if (model.equals(AspectJModel.NO_STRUCTURE)) {
+ IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
+ if (model.equals(IHierarchy.NO_STRUCTURE)) {
return null;
} else {
return findMatchesHelper((IProgramElement)model.getRoot(), pattern, kind, matches);
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
index 7eb9dfa5f..b2fe1224f 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
@@ -19,6 +19,7 @@ import java.util.*;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.internal.*;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
/**
* @author Mik Kersten
@@ -35,8 +36,8 @@ public class StructureViewManager {
private static final StructureViewProperties DEFAULT_VIEW_PROPERTIES;
private static final List AVAILABLE_RELATIONS;
- public final IStructureModelListener VIEW_LISTENER = new IStructureModelListener() {
- public void containmentHierarchyUpdated(AspectJModel model) {
+ public final IHierarchyListener VIEW_LISTENER = new IHierarchyListener() {
+ public void elementsUpdated(IHierarchy model) {
Ajde.getDefault().logEvent("updating structure views: " + structureViews);
//
// if (defaultFileView != null) {
@@ -44,7 +45,7 @@ public class StructureViewManager {
// }
for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
- treeViewBuilder.buildView((StructureView)it.next(), (AspectJModel)model);
+ treeViewBuilder.buildView((StructureView)it.next(), (AspectJElementHierarchy)model);
}
}
};
@@ -84,7 +85,7 @@ public class StructureViewManager {
* @param newFilePath the canonicalized path to the new file
*/
public void fireNavigationAction(String newFilePath, int lineNumber) {
- IProgramElement currNode = Ajde.getDefault().getStructureModelManager().getModel().findNodeForSourceLine(
+ IProgramElement currNode = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceLine(
newFilePath,
lineNumber);
@@ -116,7 +117,7 @@ public class StructureViewManager {
*/
private void navigationAction(IProgramElement node, boolean recordHistory) {
if (node == null
- || node == AspectJModel.NO_STRUCTURE) {
+ || node == IHierarchy.NO_STRUCTURE) {
Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("Source not available for node: " + node.getName());
return;
}
@@ -127,7 +128,7 @@ public class StructureViewManager {
if (defaultFileView.getSourceFile() != null
&& !defaultFileView.getSourceFile().equals(newFilePath)) {
defaultFileView.setSourceFile(newFilePath);
- treeViewBuilder.buildView(defaultFileView, AsmManager.getDefault().getModel());
+ treeViewBuilder.buildView(defaultFileView, AsmManager.getDefault().getHierarchy());
}
}
@@ -161,7 +162,7 @@ public class StructureViewManager {
public void refreshView(StructureView view) {
IStructureViewNode activeNode = view.getActiveNode();
- treeViewBuilder.buildView(view, Ajde.getDefault().getStructureModelManager().getModel());
+ treeViewBuilder.buildView(view, Ajde.getDefault().getStructureModelManager().getHierarchy());
view.setActiveNode(activeNode);
}
@@ -195,7 +196,7 @@ public class StructureViewManager {
if (properties == null) properties = DEFAULT_VIEW_PROPERTIES;
FileStructureView view = new FileStructureView(properties);
view.setSourceFile(sourceFilePath);
- treeViewBuilder.buildView(view, AsmManager.getDefault().getModel());
+ treeViewBuilder.buildView(view, AsmManager.getDefault().getHierarchy());
structureViews.add(view);
return view;
}
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
index 2339614ab..828d419ef 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
@@ -36,25 +36,31 @@ public abstract class StructureViewNodeFactory {
public IStructureViewNode createNode(IProgramElement node, List children) {
AbstractIcon icon = iconRegistry.getStructureIcon(node.getKind(), node.getAccessibility());
- IStructureViewNode svNode = createDeclaration(node, icon, children);
- List relationships = AsmManager.getDefault().getMapper().get(node);
- for (Iterator it = relationships.iterator(); it.hasNext(); ) {
- IRelationship rel = (IRelationship)it.next();
- if (rel != null && rel.getTargets().size() > 0) {
- IStructureViewNode relNode = createRelationship(
- rel,
- iconRegistry.getIcon(rel.getKind())
- );
- svNode.add(relNode, 0);
-
- for (Iterator it2 = rel.getTargets().iterator(); it2.hasNext(); ) {
- IProgramElement link = (IProgramElement)it2.next();
- IStructureViewNode linkNode = createLink(
- link,
- iconRegistry.getStructureIcon(link.getKind(), link.getAccessibility())
- );
- relNode.add(linkNode);
-
+ IStructureViewNode svNode = createDeclaration(node, icon, children);
+ String nodeHandle = node.getHandleIdentifier();
+ if (nodeHandle != null) {
+ List relationships = AsmManager.getDefault().getRelationshipMap().get(nodeHandle);
+ if (relationships != null) {
+ for (Iterator it = relationships.iterator(); it.hasNext(); ) {
+ IRelationship rel = (IRelationship)it.next();
+ if (rel != null && rel.getTargets().size() > 0) {
+ IStructureViewNode relNode = createRelationship(
+ rel,
+ iconRegistry.getIcon(rel.getKind())
+ );
+ svNode.add(relNode, 0);
+ for (Iterator it2 = rel.getTargets().iterator(); it2.hasNext(); ) {
+ String handle = (String)it2.next();
+ IProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(handle);
+ if (link != null) {
+ IStructureViewNode linkNode = createLink(
+ link,
+ iconRegistry.getStructureIcon(link.getKind(), link.getAccessibility())
+ );
+ relNode.add(linkNode);
+ }
+ }
+ }
}
}
}
diff --git a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
index 239628176..ecf8ed5ae 100644
--- a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
+++ b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
@@ -18,6 +18,7 @@ import java.util.*;
import org.aspectj.ajde.ui.*;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
import org.aspectj.asm.internal.ProgramElement;
/**
@@ -34,17 +35,17 @@ public class TreeStructureViewBuilder {
/**
* @todo get rid of instanceof tests
*/
- public void buildView(StructureView view, AspectJModel model) {
+ public void buildView(StructureView view, IHierarchy model) {
StructureViewProperties properties = view.getViewProperties();
IProgramElement modelRoot = null;
boolean noStructure = false;
if (isFileView(view)) {
FileStructureView fileView = (FileStructureView)view;
if (fileView.getSourceFile() == null) {
- modelRoot = AspectJModel.NO_STRUCTURE;
+ modelRoot = IHierarchy.NO_STRUCTURE;
noStructure = true;
} else {
- modelRoot = model.findRootNodeForSourceFile(fileView.getSourceFile());
+ modelRoot = model.findElementForSourceFile(fileView.getSourceFile());
}
} else {
modelRoot = model.getRoot();
@@ -197,7 +198,7 @@ public class TreeStructureViewBuilder {
}
}
- private IStructureViewNode buildCustomTree(GlobalStructureView view, AspectJModel model) {
+ private IStructureViewNode buildCustomTree(GlobalStructureView view, IHierarchy model) {
IProgramElement rootNode = model.getRoot();
IStructureViewNode treeNode = nodeFactory.createNode(rootNode);
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java b/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java
index bd1f9d76b..583ce0539 100644
--- a/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java
+++ b/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java
@@ -42,6 +42,7 @@ public class AjdeUIManager {
private IdeUIAdapter ideUIAdapter = null;
private TreeViewBuildConfigEditor buildConfigEditor = null;
private IconRegistry iconRegistry;
+ private boolean initialized = false;
private OptionsFrame optionsFrame = null;
private Frame rootFrame = null;
@@ -116,11 +117,13 @@ public class AjdeUIManager {
viewManager = new BrowserViewManager();
optionsFrame = new OptionsFrame(iconRegistry);
+
//Ajde.getDefault().getStructureViewManager().refreshView(
// Ajde.getDefault().getStructureViewManager().getDefaultFileStructureView()
//);
//viewManager.updateView();
+ initialized = true;
} catch (Throwable t) {
Ajde.getDefault().getErrorHandler().handleError("AJDE failed to initialize.", t);
}
@@ -190,6 +193,10 @@ public class AjdeUIManager {
public IconRegistry getIconRegistry() {
return iconRegistry;
}
+ public boolean isInitialized() {
+ return initialized;
+ }
+
}
//public abstract class AjdeAction {
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java
index 66c3a0e0a..f5b3fb555 100644
--- a/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java
+++ b/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java
@@ -14,27 +14,17 @@
package org.aspectj.ajde.ui.swing;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.SystemColor;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.border.BevelBorder;
-import javax.swing.border.Border;
+import javax.swing.*;
+import javax.swing.border.*;
import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.ui.StructureView;
-import org.aspectj.ajde.ui.StructureViewProperties;
-import org.aspectj.asm.IProgramElement;
-import org.aspectj.asm.AspectJModel;
-import org.aspectj.asm.IStructureModelListener;
+import org.aspectj.ajde.ui.*;
+import org.aspectj.asm.*;
public class SimpleStructureViewToolPanel extends JPanel {
@@ -60,10 +50,10 @@ public class SimpleStructureViewToolPanel extends JPanel {
BorderLayout borderLayout3 = new BorderLayout();
BorderLayout borderLayout4 = new BorderLayout();
- public final IStructureModelListener MODEL_LISTENER = new IStructureModelListener() {
- public void containmentHierarchyUpdated(AspectJModel model) {
+ public final IHierarchyListener MODEL_LISTENER = new IHierarchyListener() {
+ public void elementsUpdated(IHierarchy model) {
String path = Ajde.getDefault().getConfigurationManager().getActiveConfigFile();
- String fileName = "<no active config>";
+ String fileName = "<no active config>";
if (path != null) fileName = new File(path).getName();
updateCurrConfigLabel(fileName);
}
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java b/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java
index efb786b7f..9a32c26e5 100644
--- a/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java
+++ b/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java
@@ -35,7 +35,7 @@ class StructureTreeManager {
private TreeSelectionListener treeListener = null;
private final StructureTreeModel NO_STRUCTURE_MODEL
- = new StructureTreeModel(new SwingTreeViewNode(AspectJModel.NO_STRUCTURE, new AbstractIcon(null), new ArrayList()));
+ = new StructureTreeModel(new SwingTreeViewNode(IHierarchy.NO_STRUCTURE, new AbstractIcon(null), new ArrayList()));
/**
* @todo should probably avoid that MouseListener cast
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java
index dbd0c7aad..b7cbe7403 100644
--- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java
+++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java
@@ -108,7 +108,7 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements IStruct
if (kind == IStructureViewNode.Kind.RELATIONSHIP) {
return relationshipName;
} else {
- return programElement.getName();
+ return programElement.toLabelString();
}
}
diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java
index cb7b8391b..075bddc3b 100644
--- a/ajde/testdata/examples/coverage/ModelCoverage.java
+++ b/ajde/testdata/examples/coverage/ModelCoverage.java
@@ -10,9 +10,13 @@ class Point {
public Point() { }
- public int getX() { return x; }
+ public int getX() {
+ return x;
+ }
- public void setX(int x) { this.x = x; }
+ public void setX(int x) {
+ this.x = x;
+ }
public int changeX(int x) {
this.x = x;
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java b/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
index c280b68dc..7f3e2a481 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
@@ -52,6 +52,7 @@ public class AjdeTestCase extends TestCase {
currTestDataPath = TEST_DATA_PATH + File.separatorChar + testDataPath;
ideManager.init(currTestDataPath);
super.setUp();
+ assertTrue(NullIdeManager.getIdeManager().isInitialized());
Ajde.getDefault().getBuildManager().addListener(testerBuildListener);
}
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
index 8b815224b..9d7bdf79c 100644
--- a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
@@ -12,7 +12,7 @@ package org.aspectj.ajde;
import java.util.Iterator;
-import org.aspectj.ajdt.internal.core.builder.AsmNodeFormatter;
+import org.aspectj.ajdt.internal.core.builder.AsmElementFormatter;
import org.aspectj.asm.*;
import org.aspectj.asm.IProgramElement.Kind;
@@ -20,9 +20,9 @@ import org.aspectj.asm.IProgramElement.Kind;
// TODO: add tests for java kinds
public class AsmDeclarationsTest extends AjdeTestCase {
- private AspectJModel model = null;
+ private IHierarchy model = null;
private static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
- private static final int DEC_MESSAGE_LENGTH = AsmNodeFormatter.MAX_MESSAGE_LENGTH;
+ private static final int DEC_MESSAGE_LENGTH = AsmElementFormatter.MAX_MESSAGE_LENGTH;
public AsmDeclarationsTest(String name) {
super(name);
@@ -31,101 +31,97 @@ public class AsmDeclarationsTest extends AjdeTestCase {
public void testRoot() {
IProgramElement root = (IProgramElement)model.getRoot();
assertNotNull(root);
- assertEquals(root.getName(), "coverage.lst");
+ assertEquals(root.toLabelString(), "coverage.lst");
}
public void testFileInPackageAndDefaultPackage() {
IProgramElement root = model.getRoot();
- assertEquals(root.getName(), "coverage.lst");
+ assertEquals(root.toLabelString(), "coverage.lst");
IProgramElement pkg = (IProgramElement)root.getChildren().get(1);
- assertEquals(pkg.getName(), "pkg");
- assertEquals(((IProgramElement)pkg.getChildren().get(0)).getName(), "InPackage.java");
- assertEquals(((IProgramElement)root.getChildren().get(0)).getName(), "ModelCoverage.java");
+ assertEquals(pkg.toLabelString(), "pkg");
+ assertEquals(((IProgramElement)pkg.getChildren().get(0)).toLabelString(), "InPackage.java");
+ assertEquals(((IProgramElement)root.getChildren().get(0)).toLabelString(), "ModelCoverage.java");
}
public void testDeclares() {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "DeclareCoverage");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "DeclareCoverage");
assertNotNull(aspect);
- String decErrMessage = "declare error: \"Illegal construct..\"";
- IProgramElement decErrNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_ERROR, decErrMessage);
+ String label = "declare error: \"Illegal construct..\"";
+ IProgramElement decErrNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_ERROR, "declare error");
assertNotNull(decErrNode);
- assertEquals(decErrNode.getName(), decErrMessage);
+ assertEquals(decErrNode.toLabelString(), label);
String decWarnMessage = "declare warning: \"Illegal construct..\"";
- IProgramElement decWarnNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_WARNING, decWarnMessage);
+ IProgramElement decWarnNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_WARNING, "declare warning");
assertNotNull(decWarnNode);
- assertEquals(decWarnNode.getName(), decWarnMessage);
+ assertEquals(decWarnNode.toLabelString(), decWarnMessage);
String decParentsMessage = "declare parents: Point";
- IProgramElement decParentsNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsMessage);
+ IProgramElement decParentsNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PARENTS, "declare parents");
assertNotNull(decParentsNode);
- assertEquals(decParentsNode.getName(), decParentsMessage);
-
- String decParentsPtnMessage = "declare parents: Point+";
- IProgramElement decParentsPtnNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsPtnMessage);
- assertNotNull(decParentsPtnNode);
- assertEquals(decParentsPtnNode.getName(), decParentsPtnMessage);
-
- String decParentsTPMessage = "declare parents: <type pattern>";
- IProgramElement decParentsTPNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsTPMessage);
- assertNotNull(decParentsTPNode);
- assertEquals(decParentsTPNode.getName(), decParentsTPMessage);
+ assertEquals(decParentsNode.toLabelString(), decParentsMessage);
+ // check the next two relative to this one
+ int declareIndex = decParentsNode.getParent().getChildren().indexOf(decParentsNode);
+ String decParentsPtnMessage = "declare parents: Point+";
+ assertEquals(((IProgramElement)aspect.getChildren().get(declareIndex+1)).toLabelString(), decParentsPtnMessage);
+ String decParentsTPMessage = "declare parents: <type pattern>";
+ assertEquals(((IProgramElement)aspect.getChildren().get(declareIndex+2)).toLabelString(), decParentsTPMessage);
String decSoftMessage = "declare soft: SizeException";
- IProgramElement decSoftNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_SOFT, decSoftMessage);
+ IProgramElement decSoftNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_SOFT, "declare soft");
assertNotNull(decSoftNode);
- assertEquals(decSoftNode.getName(), decSoftMessage);
+ assertEquals(decSoftNode.toLabelString(), decSoftMessage);
String decPrecMessage = "declare precedence: AdviceCoverage, InterTypeDecCoverage, <type pattern>";
- IProgramElement decPrecNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PRECEDENCE, decPrecMessage);
+ IProgramElement decPrecNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PRECEDENCE, "declare precedence");
assertNotNull(decPrecNode);
- assertEquals(decPrecNode.getName(), decPrecMessage);
+ assertEquals(decPrecNode.toLabelString(), decPrecMessage);
}
public void testInterTypeMemberDeclares() {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "InterTypeDecCoverage");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "InterTypeDecCoverage");
assertNotNull(aspect);
String fieldMsg = "Point.xxx";
- IProgramElement fieldNode = model.findNode(aspect, IProgramElement.Kind.INTER_TYPE_FIELD, fieldMsg);
+ IProgramElement fieldNode = model.findElementForLabel(aspect, IProgramElement.Kind.INTER_TYPE_FIELD, fieldMsg);
assertNotNull(fieldNode);
- assertEquals(fieldNode.getName(), fieldMsg);
+ assertEquals(fieldNode.toLabelString(), fieldMsg);
String methodMsg = "Point.check(int, Line)";
- IProgramElement methodNode = model.findNode(aspect, IProgramElement.Kind.INTER_TYPE_METHOD, methodMsg);
+ IProgramElement methodNode = model.findElementForLabel(aspect, IProgramElement.Kind.INTER_TYPE_METHOD, methodMsg);
assertNotNull(methodNode);
- assertEquals(methodNode.getName(), methodMsg);
+ assertEquals(methodNode.toLabelString(), methodMsg);
// TODO: enable
// String constructorMsg = "Point.new(int, int, int)";
// ProgramElementNode constructorNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR, constructorMsg);
// assertNotNull(constructorNode);
-// assertEquals(constructorNode.getName(), constructorMsg);
+// assertEquals(constructorNode.toLabelString(), constructorMsg);
}
public void testPointcuts() {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "AdviceNamingCoverage");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage");
assertNotNull(aspect);
String ptct = "named()";
- IProgramElement ptctNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, ptct);
+ IProgramElement ptctNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, ptct);
assertNotNull(ptctNode);
- assertEquals(ptctNode.getName(), ptct);
+ assertEquals(ptctNode.toLabelString(), ptct);
String params = "namedWithArgs(int, int)";
- IProgramElement paramsNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, params);
+ IProgramElement paramsNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, params);
assertNotNull(paramsNode);
- assertEquals(paramsNode.getName(), params);
+ assertEquals(paramsNode.toLabelString(), params);
}
@@ -134,62 +130,62 @@ public class AsmDeclarationsTest extends AjdeTestCase {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "AbstractAspect");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AbstractAspect");
assertNotNull(aspect);
String abst = "abPtct()";
- IProgramElement abstNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, abst);
+ IProgramElement abstNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, abst);
assertNotNull(abstNode);
- assertEquals(abstNode.getName(), abst);
+ assertEquals(abstNode.toLabelString(), abst);
}
public void testAdvice() {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "AdviceNamingCoverage");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage");
assertNotNull(aspect);
String anon = "before(): <anonymous pointcut>";
- IProgramElement anonNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, anon);
+ IProgramElement anonNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, anon);
assertNotNull(anonNode);
- assertEquals(anonNode.getName(), anon);
+ assertEquals(anonNode.toLabelString(), anon);
String named = "before(): named..";
- IProgramElement namedNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, named);
+ IProgramElement namedNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, named);
assertNotNull(namedNode);
- assertEquals(namedNode.getName(), named);
+ assertEquals(namedNode.toLabelString(), named);
String namedWithOneArg = "around(int): namedWithOneArg..";
- IProgramElement namedWithOneArgNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, namedWithOneArg);
+ IProgramElement namedWithOneArgNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, namedWithOneArg);
assertNotNull(namedWithOneArgNode);
- assertEquals(namedWithOneArgNode.getName(), namedWithOneArg);
+ assertEquals(namedWithOneArgNode.toLabelString(), namedWithOneArg);
String afterReturning = "afterReturning(int, int): namedWithArgs..";
- IProgramElement afterReturningNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, afterReturning);
+ IProgramElement afterReturningNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, afterReturning);
assertNotNull(afterReturningNode);
- assertEquals(afterReturningNode.getName(), afterReturning);
+ assertEquals(afterReturningNode.toLabelString(), afterReturning);
String around = "around(int): namedWithOneArg..";
- IProgramElement aroundNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, around);
+ IProgramElement aroundNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, around);
assertNotNull(aroundNode);
- assertEquals(aroundNode.getName(), around);
+ assertEquals(aroundNode.toLabelString(), around);
String compAnon = "before(int): <anonymous pointcut>..";
- IProgramElement compAnonNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, compAnon);
+ IProgramElement compAnonNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, compAnon);
assertNotNull(compAnonNode);
- assertEquals(compAnonNode.getName(), compAnon);
+ assertEquals(compAnonNode.toLabelString(), compAnon);
String compNamed = "before(int): named()..";
- IProgramElement compNamedNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, compNamed);
+ IProgramElement compNamedNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, compNamed);
assertNotNull(compNamedNode);
- assertEquals(compNamedNode.getName(), compNamed);
+ assertEquals(compNamedNode.toLabelString(), compNamed);
}
protected void setUp() throws Exception {
super.setUp("examples");
assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH));
- model = AsmManager.getDefault().getModel();
+ model = AsmManager.getDefault().getHierarchy();
}
protected void tearDown() throws Exception {
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
index f2a005670..db82a96cf 100644
--- a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
@@ -26,9 +26,11 @@ public class AsmRelationshipsTest extends AjdeTestCase {
super(name);
}
-// public void testInterTypeDeclarations() {
-// checkMapping("InterTypeDecCoverage", "Point", "Point.xxx:", "xxx", "declared on", "aspect declarations");
-// }
+ public void testInterTypeDeclarations() {
+// checkMapping("InterTypeDecCoverage", "Point", "Point.xxx", "xxx", "declared on", "aspect declarations");
+// checkMapping("InterTypeDecCoverage", "Point", "Point.check(int, Line)", "Point", "declared on", "aspect declarations");
+
+ }
public void testAdvice() {
checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..", "setX(int)", "advises", "advised by");
@@ -37,31 +39,34 @@ public class AsmRelationshipsTest extends AjdeTestCase {
}
private void checkUniDirectionalMapping(String fromType, String toType, String from, String to, String relName) {
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, fromType);
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
assertNotNull(aspect);
String beforeExec = from;
- IProgramElement beforeExecNode = manager.getModel().findNode(aspect, IProgramElement.Kind.ADVICE, beforeExec);
+ IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
- IRelationship rel = manager.getMapper().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
- assertEquals(((IProgramElement)rel.getTargets().get(0)).getName(), to);
+ IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
+ String handle = (String)rel.getTargets().get(0);
+ assertEquals(manager.getHierarchy().findElementForHandle(handle).toLabelString(), to);
}
private void checkMapping(String fromType, String toType, String from, String to, String forwardRelName, String backRelName) {
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, fromType);
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
assertNotNull(aspect);
String beforeExec = from;
- IProgramElement beforeExecNode = manager.getModel().findNode(aspect, IProgramElement.Kind.ADVICE, beforeExec);
+ IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
- IRelationship rel = manager.getMapper().get(beforeExecNode, IRelationship.Kind.ADVICE, forwardRelName);
- assertEquals(((IProgramElement)rel.getTargets().get(0)).getName(), to);
+ IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, forwardRelName);
+ String handle = (String)rel.getTargets().get(0);
+ assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
- IProgramElement clazz = AsmManager.getDefault().getModel().findNodeForType(null, toType);
+ IProgramElement clazz = AsmManager.getDefault().getHierarchy().findElementForType(null, toType);
assertNotNull(clazz);
String set = to;
- IProgramElement setNode = manager.getModel().findNode(clazz, IProgramElement.Kind.METHOD, set);
+ IProgramElement setNode = manager.getHierarchy().findElementForLabel(clazz, IProgramElement.Kind.METHOD, set);
assertNotNull(setNode);
- IRelationship rel2 = manager.getMapper().get(setNode, IRelationship.Kind.ADVICE, backRelName);
- assertEquals(((IProgramElement)rel2.getTargets().get(0)).getName(), from);
+ IRelationship rel2 = manager.getRelationshipMap().get(setNode, IRelationship.Kind.ADVICE, backRelName);
+ String handle2 = (String)rel2.getTargets().get(0);
+ assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
}
protected void setUp() throws Exception {
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
index 504907666..c535cff2c 100644
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
+++ b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
@@ -33,6 +33,7 @@ public class NullIdeManager {
private static NullIdeManager ideManager = null;
private NullIdeTaskListManager taskListManager = null;
private NullIdeProperties projectProperties = null;
+ private boolean initialized = false;
public static NullIdeManager getIdeManager() {
if ( null == ideManager ) {
@@ -49,7 +50,6 @@ public class NullIdeManager {
EditorAdapter ajdeEditor = new NullIdeEditorAdapter();
IdeUIAdapter uiAdapter = new NullIdeUIAdapter();
JFrame nullFrame = new JFrame();
- //configurationManager.setConfigFiles(getConfigFilesList(configFiles));
AjdeUIManager.getDefault().init(
ajdeEditor,
@@ -62,8 +62,9 @@ public class NullIdeManager {
new NullIdeProgressMonitor(),
new NullIdeErrorHandler(),
true);
- //Ajde.getDefault().enableLogging( System.out );
+ initialized = true;
} catch (Throwable t) {
+ initialized = false;
t.printStackTrace();
Ajde.getDefault().getErrorHandler().handleError(
"Null IDE failed to initialize.",
@@ -83,4 +84,8 @@ public class NullIdeManager {
projectProperties = properties;
}
+ public boolean isInitialized() {
+ return initialized && AjdeUIManager.getDefault().isInitialized();
+ }
+
}
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java
index cae44a403..70ffc8f30 100644
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java
@@ -45,11 +45,11 @@ public class StructureModelRegressionTest extends AjdeTestCase {
public boolean verifyAgainstSavedModel(String lstFile) {
File modelFile = new File(genStructureModelExternFilePath(lstFile));
- AspectJModel model = getModelForFile(lstFile);
+ IHierarchy model = getModelForFile(lstFile);
if (modelFile.exists()) {
Ajde.getDefault().getStructureModelManager().readStructureModel(lstFile);
- AspectJModel savedModel = Ajde.getDefault().getStructureModelManager().getModel();
+ IHierarchy savedModel = Ajde.getDefault().getStructureModelManager().getHierarchy();
// AMC This test will not pass as written until IProgramElement defines
// equals. The equals loic is commented out in the IProgramElement
// class - adding it back in could have unforeseen system-wide
@@ -89,7 +89,7 @@ public class StructureModelRegressionTest extends AjdeTestCase {
return equal;
}
- private AspectJModel getModelForFile(String lstFile) {
+ private IHierarchy getModelForFile(String lstFile) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lstFile);
Ajde.getDefault().getBuildManager().build(); // was buildStructure...
while(!testerBuildListener.getBuildFinished()) {
@@ -97,7 +97,7 @@ public class StructureModelRegressionTest extends AjdeTestCase {
Thread.sleep(300);
} catch (InterruptedException ie) { }
}
- return Ajde.getDefault().getStructureModelManager().getModel();
+ return Ajde.getDefault().getStructureModelManager().getHierarchy();
}
protected void setUp() throws Exception {
@@ -106,7 +106,7 @@ public class StructureModelRegressionTest extends AjdeTestCase {
}
public void testModelExists() {
- assertTrue(Ajde.getDefault().getStructureModelManager().getModel() != null);
+ assertTrue(Ajde.getDefault().getStructureModelManager().getHierarchy() != null);
}
protected void tearDown() throws Exception {
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
index 674895e41..4332cf7d5 100644
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
@@ -77,8 +77,8 @@ public class StructureModelTest extends AjdeTestCase {
public void testRootForSourceFile() throws IOException {
File testFile = openFile("figures-coverage/figures/Figure.java");
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findRootNodeForSourceFile(
- testFile.getCanonicalPath());
+ IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceFile(
+ testFile.getAbsolutePath());
assertTrue("find result", node != null) ;
IProgramElement pNode = (IProgramElement)node;
String child = ((IProgramElement)pNode.getChildren().get(0)).getName();
@@ -87,23 +87,18 @@ public class StructureModelTest extends AjdeTestCase {
public void testPointcutName() throws IOException {
File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findRootNodeForSourceFile(
- testFile.getCanonicalPath());
+ IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceFile(
+ testFile.getAbsolutePath());
assertTrue("find result", node != null) ;
IProgramElement pNode = (IProgramElement)((IProgramElement)node).getChildren().get(1);
IProgramElement pointcut = (IProgramElement)pNode.getChildren().get(0);
assertTrue("kind", pointcut.getKind().equals(IProgramElement.Kind.POINTCUT));
- assertTrue("found node: " + pointcut.getName(), pointcut.getName().equals("testptct()"));
- }
-
- public void testDeclare() {
-
-
+ assertTrue("found node: " + pointcut.getName(), pointcut.toLabelString().equals("testptct()"));
}
public void testFileNodeFind() throws IOException {
File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findNodeForSourceLine(
+ IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceLine(
testFile.getCanonicalPath(), 1);
assertTrue("find result", node != null) ;
assertEquals("find result has children", 2, node.getChildren().size()) ;
@@ -115,11 +110,11 @@ public class StructureModelTest extends AjdeTestCase {
* @todo add negative test to make sure things that aren't runnable aren't annotated
*/
public void testMainClassNodeInfo() throws IOException {
- AspectJModel model = Ajde.getDefault().getStructureModelManager().getModel();
+ IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
assertTrue("model exists", model != null);
assertTrue("root exists", model.getRoot() != null);
File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = model.findNodeForSourceLine(testFile.getCanonicalPath(), 11);
+ IProgramElement node = model.findElementForSourceLine(testFile.getCanonicalPath(), 11);
assertTrue("find result", node != null);
IProgramElement pNode = (IProgramElement)((IProgramElement)node).getParent();
if (null == pNode) {
@@ -132,7 +127,7 @@ public class StructureModelTest extends AjdeTestCase {
* Integrity could be checked somewhere in the API.
*/
public void testModelIntegrity() {
- IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getModel().getRoot();
+ IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot();
assertTrue("root exists", modelRoot != null);
try {
@@ -162,7 +157,7 @@ public class StructureModelTest extends AjdeTestCase {
}
}
};
- Ajde.getDefault().getStructureModelManager().getModel().getRoot().walk(walker);
+ Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker);
}
protected void setUp() throws Exception {
diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java
index 99ff905f4..7977cc663 100644
--- a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java
@@ -50,7 +50,7 @@ public class StructureViewManagerTest extends AjdeTestCase {
}
public void testModelExists() {
- assertTrue(Ajde.getDefault().getStructureModelManager().getModel() != null);
+ assertTrue(Ajde.getDefault().getStructureModelManager().getHierarchy() != null);
}
public void testNotificationAfterConfigFileChange() {
@@ -66,7 +66,7 @@ public class StructureViewManagerTest extends AjdeTestCase {
assertTrue(
"no structure",
currentView.getRootNode().getStructureNode().getChildren().get(0)
- == AspectJModel.NO_STRUCTURE
+ == IHierarchy.NO_STRUCTURE
);
}
@@ -83,17 +83,17 @@ public class StructureViewManagerTest extends AjdeTestCase {
assertTrue("notified", renderer.getHasBeenNotified());
// AMC should this be currentView, or should we recreate the root... do the latter
//IProgramElement n = currentView.getRootNode().getIProgramElement();
- IProgramElement n = Ajde.getDefault().getStructureModelManager().getModel().getRoot();
+ IProgramElement n = Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot();
assertTrue(
"no structure",
//currentView.getRootNode().getIProgramElement().getChildren().get(0)
- n == AspectJModel.NO_STRUCTURE
+ n == IHierarchy.NO_STRUCTURE
);
}
public void testModelIntegrity() {
doSynchronousBuild(CONFIG_FILE_PATH);
- IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getModel().getRoot();
+ IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot();
assertTrue("root exists", modelRoot != null);
try {
@@ -125,7 +125,7 @@ public class StructureViewManagerTest extends AjdeTestCase {
assertTrue(
"no structure",
currentView.getRootNode().getStructureNode()
- == AspectJModel.NO_STRUCTURE
+ == IHierarchy.NO_STRUCTURE
);
}