aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten <mkersten>2003-08-13 20:51:10 +0000
committermkersten <mkersten>2003-08-13 20:51:10 +0000
commitbffcd4c30591bce89ba938325159374e1ea1ea96 (patch)
tree29f2247cf0806c7e5ea7e419c33d86b6a3738b38
parent11d7649fc3219af5a71d3bf0b9fe004c075c2b4f (diff)
downloadaspectj-bffcd4c30591bce89ba938325159374e1ea1ea96.tar.gz
aspectj-bffcd4c30591bce89ba938325159374e1ea1ea96.zip
Added support for multiple relationships for a single program element. Renamed model container class.
-rw-r--r--ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java2
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java4
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java4
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewManager.java6
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java35
-rw-r--r--ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java6
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java4
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java2
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java2
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java19
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java6
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelTest.java2
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java6
-rw-r--r--asm/src/org/aspectj/asm/AsmManager.java10
-rw-r--r--asm/src/org/aspectj/asm/AspectJModel.java (renamed from asm/src/org/aspectj/asm/StructureModel.java)6
-rw-r--r--asm/src/org/aspectj/asm/HierarchyWalker.java6
-rw-r--r--asm/src/org/aspectj/asm/IRelationship.java2
-rw-r--r--asm/src/org/aspectj/asm/IRelationshipMapper.java23
-rw-r--r--asm/src/org/aspectj/asm/IStructureModelListener.java2
-rw-r--r--asm/src/org/aspectj/asm/internal/RelationshipMapper.java42
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java8
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java6
-rw-r--r--weaver/src/org/aspectj/weaver/AsmAdapter.java14
-rw-r--r--weaver/src/org/aspectj/weaver/World.java8
24 files changed, 137 insertions, 88 deletions
diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java
index c11db4399..6f7523f7a 100644
--- a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java
+++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java
@@ -47,7 +47,7 @@ public class BrowserManager {
private static TopFrame topFrame = null;
public final IStructureModelListener VIEW_LISTENER = new IStructureModelListener() {
- public void containmentHierarchyUpdated(StructureModel model) {
+ public void containmentHierarchyUpdated(AspectJModel model) {
FileStructureView fsv = Ajde.getDefault().getStructureViewManager().getDefaultFileView();
if (fsv != null) {
fsv.setSourceFile(BrowserManager.getDefault().getEditorManager().getCurrFile());
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
index ec0b44a9e..578c04e0c 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
@@ -114,9 +114,9 @@ public class StructureModelUtil {
public static List getPackagesInModel() {
List packages = new ArrayList();
- StructureModel model =
+ AspectJModel model =
Ajde.getDefault().getStructureModelManager().getModel();
- if (model.equals(StructureModel.NO_STRUCTURE)) {
+ if (model.equals(AspectJModel.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 f98f5147e..c1f77c243 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java
@@ -34,8 +34,8 @@ public class StructureSearchManager {
IProgramElement.Kind kind) {
List matches = new ArrayList();
- StructureModel model = Ajde.getDefault().getStructureModelManager().getModel();
- if (model.equals(StructureModel.NO_STRUCTURE)) {
+ AspectJModel model = Ajde.getDefault().getStructureModelManager().getModel();
+ if (model.equals(AspectJModel.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 7170001ba..7eb9dfa5f 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
@@ -36,7 +36,7 @@ public class StructureViewManager {
private static final List AVAILABLE_RELATIONS;
public final IStructureModelListener VIEW_LISTENER = new IStructureModelListener() {
- public void containmentHierarchyUpdated(StructureModel model) {
+ public void containmentHierarchyUpdated(AspectJModel model) {
Ajde.getDefault().logEvent("updating structure views: " + structureViews);
//
// if (defaultFileView != null) {
@@ -44,7 +44,7 @@ public class StructureViewManager {
// }
for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
- treeViewBuilder.buildView((StructureView)it.next(), (StructureModel)model);
+ treeViewBuilder.buildView((StructureView)it.next(), (AspectJModel)model);
}
}
};
@@ -116,7 +116,7 @@ public class StructureViewManager {
*/
private void navigationAction(IProgramElement node, boolean recordHistory) {
if (node == null
- || node == StructureModel.NO_STRUCTURE) {
+ || node == AspectJModel.NO_STRUCTURE) {
Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("Source not available for node: " + node.getName());
return;
}
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
index 2cb822827..2339614ab 100644
--- a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
+++ b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java
@@ -37,22 +37,25 @@ public abstract class StructureViewNodeFactory {
AbstractIcon icon = iconRegistry.getStructureIcon(node.getKind(), node.getAccessibility());
IStructureViewNode svNode = createDeclaration(node, icon, children);
- IRelationship rel = AsmManager.getDefault().getMapper().get(node);
- if (rel != null && rel.getTargets().size() > 0) {
- IStructureViewNode relNode = createRelationship(
- rel,
- iconRegistry.getIcon(rel.getKind())
- );
- svNode.add(relNode, 0);
-
- for (Iterator it = rel.getTargets().iterator(); it.hasNext(); ) {
- IProgramElement link = (IProgramElement)it.next();
- IStructureViewNode linkNode = createLink(
- link,
- iconRegistry.getStructureIcon(link.getKind(), link.getAccessibility())
- );
- relNode.add(linkNode);
-
+ 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);
+
+ }
}
}
return svNode;
diff --git a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
index cdbd5a11d..239628176 100644
--- a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
+++ b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
@@ -34,14 +34,14 @@ public class TreeStructureViewBuilder {
/**
* @todo get rid of instanceof tests
*/
- public void buildView(StructureView view, StructureModel model) {
+ public void buildView(StructureView view, AspectJModel model) {
StructureViewProperties properties = view.getViewProperties();
IProgramElement modelRoot = null;
boolean noStructure = false;
if (isFileView(view)) {
FileStructureView fileView = (FileStructureView)view;
if (fileView.getSourceFile() == null) {
- modelRoot = StructureModel.NO_STRUCTURE;
+ modelRoot = AspectJModel.NO_STRUCTURE;
noStructure = true;
} else {
modelRoot = model.findRootNodeForSourceFile(fileView.getSourceFile());
@@ -197,7 +197,7 @@ public class TreeStructureViewBuilder {
}
}
- private IStructureViewNode buildCustomTree(GlobalStructureView view, StructureModel model) {
+ private IStructureViewNode buildCustomTree(GlobalStructureView view, AspectJModel model) {
IProgramElement rootNode = model.getRoot();
IStructureViewNode treeNode = nodeFactory.createNode(rootNode);
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java
index dc9b5cd76..66c3a0e0a 100644
--- a/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java
+++ b/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java
@@ -33,7 +33,7 @@ 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.StructureModel;
+import org.aspectj.asm.AspectJModel;
import org.aspectj.asm.IStructureModelListener;
public class SimpleStructureViewToolPanel extends JPanel {
@@ -61,7 +61,7 @@ public class SimpleStructureViewToolPanel extends JPanel {
BorderLayout borderLayout4 = new BorderLayout();
public final IStructureModelListener MODEL_LISTENER = new IStructureModelListener() {
- public void containmentHierarchyUpdated(StructureModel model) {
+ public void containmentHierarchyUpdated(AspectJModel model) {
String path = Ajde.getDefault().getConfigurationManager().getActiveConfigFile();
String fileName = "<no active config>";
if (path != null) fileName = new File(path).getName();
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java b/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java
index 29871bf8d..efb786b7f 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(StructureModel.NO_STRUCTURE, new AbstractIcon(null), new ArrayList()));
+ = new StructureTreeModel(new SwingTreeViewNode(AspectJModel.NO_STRUCTURE, new AbstractIcon(null), new ArrayList()));
/**
* @todo should probably avoid that MouseListener cast
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
index b0d854238..8b815224b 100644
--- a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
@@ -20,7 +20,7 @@ import org.aspectj.asm.IProgramElement.Kind;
// TODO: add tests for java kinds
public class AsmDeclarationsTest extends AjdeTestCase {
- private StructureModel model = null;
+ private AspectJModel model = null;
private static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
private static final int DEC_MESSAGE_LENGTH = AsmNodeFormatter.MAX_MESSAGE_LENGTH;
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
index 3714da143..f2a005670 100644
--- a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
@@ -16,7 +16,6 @@ import java.util.List;
import org.aspectj.asm.*;
import org.aspectj.asm.internal.ProgramElement;
-
// TODO: check for return types
public class AsmRelationshipsTest extends AjdeTestCase {
@@ -28,32 +27,32 @@ public class AsmRelationshipsTest extends AjdeTestCase {
}
// public void testInterTypeDeclarations() {
-// checkMapping("InterTypeDecCoverage", "Point", "Point.xxx:", "xxx");
+// checkMapping("InterTypeDecCoverage", "Point", "Point.xxx:", "xxx", "declared on", "aspect declarations");
// }
public void testAdvice() {
- checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..", "setX(int)");
- checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): getP..", "field-get(int Point.x)");
- checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): setP..", "field-set(int Point.xxx)");
+ checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..", "setX(int)", "advises", "advised by");
+ checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): getP..", "field-get(int Point.x)", "advises");
+ checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): setP..", "field-set(int Point.xxx)", "advises");
}
- private void checkUniDirectionalMapping(String fromType, String toType, String from, String to) {
+ private void checkUniDirectionalMapping(String fromType, String toType, String from, String to, String relName) {
IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, fromType);
assertNotNull(aspect);
String beforeExec = from;
IProgramElement beforeExecNode = manager.getModel().findNode(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
- IRelationship rel = manager.getMapper().get(beforeExecNode);
+ IRelationship rel = manager.getMapper().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
assertEquals(((IProgramElement)rel.getTargets().get(0)).getName(), to);
}
- private void checkMapping(String fromType, String toType, String from, String to) {
+ private void checkMapping(String fromType, String toType, String from, String to, String forwardRelName, String backRelName) {
IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, fromType);
assertNotNull(aspect);
String beforeExec = from;
IProgramElement beforeExecNode = manager.getModel().findNode(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
- IRelationship rel = manager.getMapper().get(beforeExecNode);
+ IRelationship rel = manager.getMapper().get(beforeExecNode, IRelationship.Kind.ADVICE, forwardRelName);
assertEquals(((IProgramElement)rel.getTargets().get(0)).getName(), to);
IProgramElement clazz = AsmManager.getDefault().getModel().findNodeForType(null, toType);
@@ -61,7 +60,7 @@ public class AsmRelationshipsTest extends AjdeTestCase {
String set = to;
IProgramElement setNode = manager.getModel().findNode(clazz, IProgramElement.Kind.METHOD, set);
assertNotNull(setNode);
- IRelationship rel2 = manager.getMapper().get(setNode);
+ IRelationship rel2 = manager.getMapper().get(setNode, IRelationship.Kind.ADVICE, backRelName);
assertEquals(((IProgramElement)rel2.getTargets().get(0)).getName(), from);
}
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java
index d7c1038aa..cae44a403 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));
- StructureModel model = getModelForFile(lstFile);
+ AspectJModel model = getModelForFile(lstFile);
if (modelFile.exists()) {
Ajde.getDefault().getStructureModelManager().readStructureModel(lstFile);
- StructureModel savedModel = Ajde.getDefault().getStructureModelManager().getModel();
+ AspectJModel savedModel = Ajde.getDefault().getStructureModelManager().getModel();
// 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 StructureModel getModelForFile(String lstFile) {
+ private AspectJModel getModelForFile(String lstFile) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lstFile);
Ajde.getDefault().getBuildManager().build(); // was buildStructure...
while(!testerBuildListener.getBuildFinished()) {
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
index ba451fcfa..674895e41 100644
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
@@ -115,7 +115,7 @@ 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 {
- StructureModel model = Ajde.getDefault().getStructureModelManager().getModel();
+ AspectJModel model = Ajde.getDefault().getStructureModelManager().getModel();
assertTrue("model exists", model != null);
assertTrue("root exists", model.getRoot() != null);
File testFile = openFile("figures-coverage/figures/Main.java");
diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java
index dad5bf240..99ff905f4 100644
--- a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java
@@ -66,7 +66,7 @@ public class StructureViewManagerTest extends AjdeTestCase {
assertTrue(
"no structure",
currentView.getRootNode().getStructureNode().getChildren().get(0)
- == StructureModel.NO_STRUCTURE
+ == AspectJModel.NO_STRUCTURE
);
}
@@ -87,7 +87,7 @@ public class StructureViewManagerTest extends AjdeTestCase {
assertTrue(
"no structure",
//currentView.getRootNode().getIProgramElement().getChildren().get(0)
- n == StructureModel.NO_STRUCTURE
+ n == AspectJModel.NO_STRUCTURE
);
}
@@ -125,7 +125,7 @@ public class StructureViewManagerTest extends AjdeTestCase {
assertTrue(
"no structure",
currentView.getRootNode().getStructureNode()
- == StructureModel.NO_STRUCTURE
+ == AspectJModel.NO_STRUCTURE
);
}
diff --git a/asm/src/org/aspectj/asm/AsmManager.java b/asm/src/org/aspectj/asm/AsmManager.java
index dda0ab096..b090abfcf 100644
--- a/asm/src/org/aspectj/asm/AsmManager.java
+++ b/asm/src/org/aspectj/asm/AsmManager.java
@@ -29,7 +29,7 @@ public class AsmManager {
*/
private static AsmManager INSTANCE = new AsmManager();
private boolean shouldSaveModel = true;
- protected StructureModel model = new StructureModel();
+ protected AspectJModel model = new AspectJModel();
private List structureListeners = new ArrayList();
private IRelationshipMapper mapper;
@@ -39,7 +39,7 @@ public class AsmManager {
mapper = new RelationshipMapper();
}
- public StructureModel getModel() {
+ public AspectJModel getModel() {
return model;
}
@@ -140,16 +140,16 @@ public class AsmManager {
public void readStructureModel(String configFilePath) {
try {
if (configFilePath == null) {
- model.setRoot(StructureModel.NO_STRUCTURE);
+ model.setRoot(AspectJModel.NO_STRUCTURE);
} else {
String filePath = genExternFilePath(configFilePath);
FileInputStream in = new FileInputStream(filePath);
ObjectInputStream s = new ObjectInputStream(in);
- model = (StructureModel)s.readObject();
+ model = (AspectJModel)s.readObject();
}
} catch (Exception e) {
//System.err.println("AJDE Message: could not read structure model: " + e);
- model.setRoot(StructureModel.NO_STRUCTURE);
+ model.setRoot(AspectJModel.NO_STRUCTURE);
} finally {
notifyListeners();
}
diff --git a/asm/src/org/aspectj/asm/StructureModel.java b/asm/src/org/aspectj/asm/AspectJModel.java
index 36318a2e5..e8c723edc 100644
--- a/asm/src/org/aspectj/asm/StructureModel.java
+++ b/asm/src/org/aspectj/asm/AspectJModel.java
@@ -23,7 +23,7 @@ import org.aspectj.bridge.*;
/**
* @author Mik Kersten
*/
-public class StructureModel implements Serializable {
+public class AspectJModel implements Serializable {
protected IProgramElement root = null;
protected String configFile = null;
@@ -156,7 +156,7 @@ public class StructureModel implements Serializable {
public IProgramElement findRootNodeForSourceFile(String sourceFile) {
try {
if (!isValid() || sourceFile == null) {
- return StructureModel.NO_STRUCTURE;
+ return AspectJModel.NO_STRUCTURE;
} else {
String correctedPath = new File(sourceFile).getCanonicalPath();//.replace('\\', '/');
//StructureNode node = (StructureNode)getFileMap().get(correctedPath);//findFileNode(filePath, model);
@@ -168,7 +168,7 @@ public class StructureModel implements Serializable {
}
}
} catch (Exception e) {
- return StructureModel.NO_STRUCTURE;
+ return AspectJModel.NO_STRUCTURE;
}
}
diff --git a/asm/src/org/aspectj/asm/HierarchyWalker.java b/asm/src/org/aspectj/asm/HierarchyWalker.java
index b1d9e6100..cac375482 100644
--- a/asm/src/org/aspectj/asm/HierarchyWalker.java
+++ b/asm/src/org/aspectj/asm/HierarchyWalker.java
@@ -17,15 +17,15 @@ package org.aspectj.asm;
/**
* @author Mik Kersten
*/
-public class HierarchyWalker {
+public abstract class HierarchyWalker {
- private StructureModel model;
+ private AspectJModel model;
public HierarchyWalker() {
super();
}
- public HierarchyWalker(StructureModel model) {
+ public HierarchyWalker(AspectJModel model) {
this.model = model;
}
diff --git a/asm/src/org/aspectj/asm/IRelationship.java b/asm/src/org/aspectj/asm/IRelationship.java
index 892f50006..b6377e832 100644
--- a/asm/src/org/aspectj/asm/IRelationship.java
+++ b/asm/src/org/aspectj/asm/IRelationship.java
@@ -29,7 +29,7 @@ public interface IRelationship extends Serializable {
public IProgramElement getSource();
public Kind getKind();
-
+
/**
* Uses "typesafe enum" pattern.
*/
diff --git a/asm/src/org/aspectj/asm/IRelationshipMapper.java b/asm/src/org/aspectj/asm/IRelationshipMapper.java
index ab8fffd34..747347222 100644
--- a/asm/src/org/aspectj/asm/IRelationshipMapper.java
+++ b/asm/src/org/aspectj/asm/IRelationshipMapper.java
@@ -18,18 +18,31 @@ import java.util.List;
import org.aspectj.asm.IRelationship.Kind;
/**
+ * Maps from a program element to a list of relationships between that element
+ * and othe program elements. Each element in the list or relationships is
+ * uniquely identified by a kind and a relationship name.
+ *
* @author Mik Kersten
*/
public interface IRelationshipMapper extends Serializable {
- // TODO: return a list
- public IRelationship get(IProgramElement source);
+ /**
+ * @return an empty list if the element is not found.
+ */
+ public List get(IProgramElement source);
+
+ /**
+ * Return a relationship matching the kind and name for the given element.
+ *
+ * @return null if the relationship is not found.
+ */
+ public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName);
- // TODO: return a list
- public IRelationship get(String handle);
- public void put(IProgramElement source, IRelationship relationship);
+ public List/*IRelationship*/ get(String handle);
+ public void put(IProgramElement source, IRelationship relationship);
+
}
diff --git a/asm/src/org/aspectj/asm/IStructureModelListener.java b/asm/src/org/aspectj/asm/IStructureModelListener.java
index 9356b6f2d..6e2879ee1 100644
--- a/asm/src/org/aspectj/asm/IStructureModelListener.java
+++ b/asm/src/org/aspectj/asm/IStructureModelListener.java
@@ -23,5 +23,5 @@ import java.util.EventListener;
*/
public interface IStructureModelListener extends EventListener {
- public void containmentHierarchyUpdated(StructureModel rootNode);
+ public void containmentHierarchyUpdated(AspectJModel rootNode);
}
diff --git a/asm/src/org/aspectj/asm/internal/RelationshipMapper.java b/asm/src/org/aspectj/asm/internal/RelationshipMapper.java
index e794b76e0..c3d1a5f4c 100644
--- a/asm/src/org/aspectj/asm/internal/RelationshipMapper.java
+++ b/asm/src/org/aspectj/asm/internal/RelationshipMapper.java
@@ -21,16 +21,50 @@ import org.aspectj.asm.*;
*/
public class RelationshipMapper extends HashMap implements IRelationshipMapper {
- public IRelationship get(IProgramElement source) {
- return (IRelationship)super.get(source);
+ public List get(IProgramElement source) {
+ List relationships = (List)super.get(source);
+ if (relationships == null) {
+ return Collections.EMPTY_LIST;
+ } else {
+ return relationships;
+ }
}
- public IRelationship get(String handle) {
+ /**
+ * @return null if the relationship is not found.
+ */
+ public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName) {
+ List relationships = get(source);
+ for (Iterator it = relationships.iterator(); it.hasNext(); ) {
+ IRelationship curr = (IRelationship)it.next();
+ if (curr.getKind() == kind && curr.getName() == relationshipName) {
+ return curr;
+ }
+ }
+ return null;
+ }
+
+ public List get(String handle) {
throw new RuntimeException("unimplemented");
}
public void put(IProgramElement source, IRelationship relationship) {
- super.put(source, relationship);
+ List list = (List)super.get(source);
+ if (list == null) {
+ list = new ArrayList();
+ list.add(relationship);
+ super.put(source, list);
+ } else {
+ boolean matched = false;
+ for (Iterator it = list.iterator(); it.hasNext(); ) {
+ IRelationship curr = (IRelationship)it.next();
+ if (curr.getName().equals(relationship.getName())) {
+ curr.getTargets().addAll(relationship.getTargets());
+ matched = true;
+ }
+ }
+ if (!matched) list.add(relationship);
+ }
}
// TODO: add a remove, and a clear all
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 37f50061c..8cb60f48f 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
@@ -42,7 +42,7 @@ public class AjBuildManager {
private int compiledCount;
private int sourceFileCount;
- private StructureModel structureModel;
+ private AspectJModel structureModel;
public AjBuildConfig buildConfig;
AjState state = new AjState(this);
@@ -167,7 +167,7 @@ public class AjBuildManager {
private void setupModel() {
String rootLabel = "<root>";
- StructureModel model = AsmManager.getDefault().getModel();
+ AspectJModel model = AsmManager.getDefault().getModel();
IProgramElement.Kind kind = IProgramElement.Kind.FILE_JAVA;
if (buildConfig.getConfigFile() != null) {
rootLabel = buildConfig.getConfigFile().getName();
@@ -523,14 +523,14 @@ public class AjBuildManager {
}
- public void setStructureModel(StructureModel structureModel) {
+ public void setStructureModel(AspectJModel structureModel) {
this.structureModel = structureModel;
}
/**
* Returns null if there is no structure model
*/
- public StructureModel getStructureModel() {
+ public AspectJModel getStructureModel() {
return structureModel;
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
index b7fd8d1be..c159919d5 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
@@ -32,7 +32,7 @@ public class AsmHierarchyBuilder extends AbstractSyntaxTreeVisitorAdapter {
public static void build(
CompilationUnitDeclaration unit,
- StructureModel structureModel) {
+ AspectJModel structureModel) {
LangUtil.throwIaxIfNull(unit, "unit");
new AsmHierarchyBuilder(unit.compilationResult()).internalBuild(unit, structureModel);
}
@@ -53,7 +53,7 @@ public class AsmHierarchyBuilder extends AbstractSyntaxTreeVisitorAdapter {
*/
private void internalBuild(
CompilationUnitDeclaration unit,
- StructureModel structureModel) {
+ AspectJModel structureModel) {
LangUtil.throwIaxIfNull(structureModel, "structureModel");
if (!currCompilationResult.equals(unit.compilationResult())) {
throw new IllegalArgumentException("invalid unit: " + unit);
@@ -116,7 +116,7 @@ public class AsmHierarchyBuilder extends AbstractSyntaxTreeVisitorAdapter {
*/
private IProgramElement genAddToNode(
CompilationUnitDeclaration unit,
- StructureModel structureModel) {
+ AspectJModel structureModel) {
final IProgramElement addToNode;
{
ImportReference currentPackage = unit.currentPackage;
diff --git a/weaver/src/org/aspectj/weaver/AsmAdapter.java b/weaver/src/org/aspectj/weaver/AsmAdapter.java
index 2c4188db6..5c121b169 100644
--- a/weaver/src/org/aspectj/weaver/AsmAdapter.java
+++ b/weaver/src/org/aspectj/weaver/AsmAdapter.java
@@ -26,11 +26,11 @@ public class AsmAdapter {
public static final String DECLARES_ON = "declares on";
public static final String DECLAREDY_BY = "declared by";
- public static void checkerMunger(StructureModel model, Shadow shadow) {
+ public static void checkerMunger(AspectJModel model, Shadow shadow) {
// System.err.println("> " + shadow.getThisVar() + " to " + shadow.getTargetVar());
}
- public static void nodeMunger(StructureModel model, Shadow shadow, ShadowMunger munger) {
+ public static void nodeMunger(AspectJModel model, Shadow shadow, ShadowMunger munger) {
if (munger instanceof Advice) {
Advice a = (Advice)munger;
if (a.getKind().isPerEntry() || a.getKind().isCflow()) {
@@ -43,7 +43,7 @@ public class AsmAdapter {
IProgramElement adviceNode = getNode(model, a);
if (adviceNode != null && targetNode != null) {
- IRelationship foreward = mapper.get(adviceNode);
+ IRelationship foreward = mapper.get(adviceNode, IRelationship.Kind.ADVICE, ADVISES);
if (foreward == null) {
foreward = new Relationship(
ADVISES,
@@ -55,7 +55,7 @@ public class AsmAdapter {
}
foreward.getTargets().add(targetNode);
- IRelationship back = mapper.get(targetNode);
+ IRelationship back = mapper.get(targetNode, IRelationship.Kind.ADVICE, ADVISED_BY);
if (back == null) {
back = new Relationship(
ADVISED_BY,
@@ -70,14 +70,14 @@ public class AsmAdapter {
}
}
- private static IProgramElement getNode(StructureModel model, Advice a) {
+ private static IProgramElement getNode(AspectJModel model, Advice a) {
//ResolvedTypeX inAspect = a.getConcreteAspect();
Member member = a.getSignature();
if (a.getSignature() == null) return null;
return lookupMember(model, member);
}
- private static IProgramElement getNode(StructureModel model, Shadow shadow) {
+ private static IProgramElement getNode(AspectJModel model, Shadow shadow) {
Member enclosingMember = shadow.getEnclosingCodeSignature();
IProgramElement enclosingNode = lookupMember(model, enclosingMember);
@@ -130,7 +130,7 @@ public class AsmAdapter {
return peNode;
}
- public static IProgramElement lookupMember(StructureModel model, Member member) {
+ public static IProgramElement lookupMember(AspectJModel model, Member member) {
TypeX declaringType = member.getDeclaringType();
IProgramElement classNode =
model.findNodeForType(declaringType.getPackageName(), declaringType.getClassName());
diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java
index 792201dd0..9f2285e23 100644
--- a/weaver/src/org/aspectj/weaver/World.java
+++ b/weaver/src/org/aspectj/weaver/World.java
@@ -19,7 +19,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.aspectj.asm.StructureModel;
+import org.aspectj.asm.AspectJModel;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.Message;
@@ -36,7 +36,7 @@ public abstract class World {
protected CrosscuttingMembersSet crosscuttingMembersSet = new CrosscuttingMembersSet(this);
- protected StructureModel model = null;
+ protected AspectJModel model = null;
protected Lint lint = new Lint(this);
@@ -340,11 +340,11 @@ public abstract class World {
return crosscuttingMembersSet;
}
- public StructureModel getModel() {
+ public AspectJModel getModel() {
return model;
}
- public void setModel(StructureModel model) {
+ public void setModel(AspectJModel model) {
this.model = model;
}