diff options
author | mkersten <mkersten> | 2003-08-13 20:51:10 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-08-13 20:51:10 +0000 |
commit | bffcd4c30591bce89ba938325159374e1ea1ea96 (patch) | |
tree | 29f2247cf0806c7e5ea7e419c33d86b6a3738b38 /ajde | |
parent | 11d7649fc3219af5a71d3bf0b9fe004c075c2b4f (diff) | |
download | aspectj-bffcd4c30591bce89ba938325159374e1ea1ea96.tar.gz aspectj-bffcd4c30591bce89ba938325159374e1ea1ea96.zip |
Added support for multiple relationships for a single program element. Renamed model container class.
Diffstat (limited to 'ajde')
12 files changed, 49 insertions, 47 deletions
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 ); } |