diff options
author | mkersten <mkersten> | 2003-08-08 21:10:32 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-08-08 21:10:32 +0000 |
commit | 4a1a347b2225e48fa4e9d617e7bf083680967a70 (patch) | |
tree | 7e7cc1b56212c86ce562cb7203c6dbf504eaa391 /ajde | |
parent | 3289df4d8c5a8c8e3ada9c301a0b023dda8524a3 (diff) | |
download | aspectj-4a1a347b2225e48fa4e9d617e7bf083680967a70.tar.gz aspectj-4a1a347b2225e48fa4e9d617e7bf083680967a70.zip |
Got advice relationships working.
Diffstat (limited to 'ajde')
29 files changed, 351 insertions, 247 deletions
diff --git a/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java b/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java index edf519bc9..f73ed7874 100644 --- a/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java +++ b/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java @@ -58,7 +58,7 @@ public abstract class AbstractIconRegistry { protected final AbstractIcon RELATION_REFERENCE_FORWARD = createIcon(STRUCTURE_PATH + "referenceForward.gif"); protected final AbstractIcon RELATION_REFERENCE_BACK = createIcon(STRUCTURE_PATH + "referenceBack.gif"); - public AbstractIcon getRelationIcon(IRelationship.Kind relationship) { + public AbstractIcon getIcon(IRelationship.Kind relationship) { if (relationship == IRelationship.Kind.ADVICE) { return RELATION_ADVICE_FORWARD; } else if (relationship == IRelationship.Kind.DECLARE) { @@ -82,7 +82,7 @@ public abstract class AbstractIconRegistry { * * @return null if the kind could not be resolved */ - public AbstractIcon getStructureIcon(IProgramElement.Kind kind) { + public AbstractIcon getIcon(IProgramElement.Kind kind) { if (kind == IProgramElement.Kind.PROJECT) { return PROJECT; } else if (kind == IProgramElement.Kind.PACKAGE) { diff --git a/ajde/src/org/aspectj/ajde/ui/FileStructureView.java b/ajde/src/org/aspectj/ajde/ui/FileStructureView.java index f3451c3cf..f0a14125f 100644 --- a/ajde/src/org/aspectj/ajde/ui/FileStructureView.java +++ b/ajde/src/org/aspectj/ajde/ui/FileStructureView.java @@ -36,7 +36,7 @@ public class FileStructureView extends StructureView { this.sourceFilePath = sourceFile; } - public void setRootNode(StructureViewNode rootNode) { + public void setRootNode(IStructureViewNode rootNode) { super.setRootNode(rootNode); notifyViewUpdated(); } diff --git a/ajde/src/org/aspectj/ajde/ui/IStructureViewNode.java b/ajde/src/org/aspectj/ajde/ui/IStructureViewNode.java new file mode 100644 index 000000000..f0a7ccac5 --- /dev/null +++ b/ajde/src/org/aspectj/ajde/ui/IStructureViewNode.java @@ -0,0 +1,81 @@ +/* ******************************************************************* + * Copyright (c) 1999-2001 Xerox Corporation, + * 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: + * Xerox/PARC initial implementation + * ******************************************************************/ + + +package org.aspectj.ajde.ui; + +import java.io.*; +import java.util.List; + +import org.aspectj.asm.IProgramElement; + +/** + * @author Mik Kersten + */ +public interface IStructureViewNode { + + public IProgramElement getStructureNode(); + + public AbstractIcon getIcon(); + + /** + * Add a child node. + */ + public void add(IStructureViewNode child); + + /** + * Add a child node. + */ + public void add(IStructureViewNode child, int position); + + /** + * Remove a child node. + */ + public void remove(IStructureViewNode child); + + /** + * @return an empty list if there are no children + */ + public List getChildren(); + + public Kind getKind(); + + public String getRelationshipName(); + + /** + * Uses "typesafe enum" pattern. + */ + public static class Kind implements Serializable { + + public static final Kind DECLARATION = new Kind("declaration"); + public static final Kind RELATIONSHIP = new Kind("relationship"); + public static final Kind LINK = new Kind("link"); + public static final Kind[] ALL = { DECLARATION, RELATIONSHIP, LINK }; + private final String name; + + private Kind(String name) { + this.name = name; + } + + public String toString() { + return name; + } + + // The 4 declarations below are necessary for serialization + private static int nextOrdinal = 0; + private final int ordinal = nextOrdinal++; + private Object readResolve() throws ObjectStreamException { + return ALL[ordinal]; + } + } +} diff --git a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java index 540449669..0e12d5f7c 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java @@ -115,7 +115,7 @@ public class StructureModelUtil { public static List getPackagesInModel() { List packages = new ArrayList(); StructureModel model = - Ajde.getDefault().getStructureModelManager().getStructureModel(); + Ajde.getDefault().getStructureModelManager().getModel(); if (model.equals(StructureModel.NO_STRUCTURE)) { return null; } else { diff --git a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java index 6afc5b91e..f98f5147e 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java @@ -34,7 +34,7 @@ public class StructureSearchManager { IProgramElement.Kind kind) { List matches = new ArrayList(); - StructureModel model = Ajde.getDefault().getStructureModelManager().getStructureModel(); + StructureModel model = Ajde.getDefault().getStructureModelManager().getModel(); if (model.equals(StructureModel.NO_STRUCTURE)) { return null; } else { diff --git a/ajde/src/org/aspectj/ajde/ui/StructureView.java b/ajde/src/org/aspectj/ajde/ui/StructureView.java index 3ff063d0c..6086e5748 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureView.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureView.java @@ -23,8 +23,8 @@ import org.aspectj.asm.IProgramElement; */ public abstract class StructureView { - private StructureViewNode rootNode = null; - private StructureViewNode activeNode = null; + private IStructureViewNode rootNode = null; + private IStructureViewNode activeNode = null; protected StructureViewProperties viewProperties = null; protected StructureViewRenderer renderer = null; @@ -32,11 +32,11 @@ public abstract class StructureView { return viewProperties; } - public StructureViewNode getRootNode() { + public IStructureViewNode getRootNode() { return rootNode; } - public void setRootNode(StructureViewNode rootNode) { + public void setRootNode(IStructureViewNode rootNode) { this.rootNode = rootNode; } @@ -55,7 +55,7 @@ public abstract class StructureView { /** * @return the view node corresponding to the active ProgramElementNode or null */ - public StructureViewNode getActiveNode() { + public IStructureViewNode getActiveNode() { if (activeNode != null && activeNode.getStructureNode() instanceof IProgramElement) { return activeNode; @@ -69,11 +69,11 @@ public abstract class StructureView { * * @return the first match */ - public StructureViewNode findCorrespondingViewNode(IProgramElement node) { + public IStructureViewNode findCorrespondingViewNode(IProgramElement node) { return findCorrespondingViewNodeHelper(rootNode, node); } - private StructureViewNode findCorrespondingViewNodeHelper(StructureViewNode node, IProgramElement pNode) { + private IStructureViewNode findCorrespondingViewNodeHelper(IStructureViewNode node, IProgramElement pNode) { if (node != null && node.getStructureNode() != null @@ -83,7 +83,7 @@ public abstract class StructureView { if (node != null && node.getChildren() != null) { for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - StructureViewNode foundNode = findCorrespondingViewNodeHelper((StructureViewNode)it.next(), pNode); + IStructureViewNode foundNode = findCorrespondingViewNodeHelper((IStructureViewNode)it.next(), pNode); if (foundNode != null) return foundNode; } } @@ -91,12 +91,12 @@ public abstract class StructureView { return null; } - public void setActiveNode(StructureViewNode activeNode) { + public void setActiveNode(IStructureViewNode activeNode) { this.activeNode = activeNode; if (renderer != null) renderer.setActiveNode(activeNode); } - public void setActiveNode(StructureViewNode activeNode, int sourceLine) { + public void setActiveNode(IStructureViewNode activeNode, int sourceLine) { this.activeNode = activeNode; if (renderer != null) renderer.setActiveNode(activeNode, sourceLine); } diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java index 5507db525..8acbbacba 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java @@ -84,7 +84,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().getStructureModel().findNodeForSourceLine( + IProgramElement currNode = Ajde.getDefault().getStructureModelManager().getModel().findNodeForSourceLine( newFilePath, lineNumber); @@ -127,7 +127,7 @@ public class StructureViewManager { if (defaultFileView.getSourceFile() != null && !defaultFileView.getSourceFile().equals(newFilePath)) { defaultFileView.setSourceFile(newFilePath); - treeViewBuilder.buildView(defaultFileView, StructureModelManager.getDefault().getStructureModel()); + treeViewBuilder.buildView(defaultFileView, StructureModelManager.getDefault().getModel()); } } @@ -137,19 +137,19 @@ public class StructureViewManager { if (node.getKind().equals(IProgramElement.Kind.CODE)) { IProgramElement parentNode = (IProgramElement)node.getParent(); if (parentNode != null) { - StructureViewNode currNode = view.findCorrespondingViewNode(parentNode); + IStructureViewNode currNode = view.findCorrespondingViewNode(parentNode); int lineOffset = node.getSourceLocation().getLine() - parentNode.getSourceLocation().getLine(); if (currNode != null) view.setActiveNode(currNode, lineOffset); } } else { - StructureViewNode currNode = view.findCorrespondingViewNode(node); + IStructureViewNode currNode = view.findCorrespondingViewNode(node); if (currNode != null) view.setActiveNode(currNode); } } } } - private IProgramElement getProgramElementNode(StructureViewNode node) { + private IProgramElement getProgramElementNode(IStructureViewNode node) { if (node.getStructureNode() instanceof IProgramElement) { return (IProgramElement)node.getStructureNode(); // } else if (node.getStructureNode() instanceof LinkNode) { @@ -160,8 +160,8 @@ public class StructureViewManager { } public void refreshView(StructureView view) { - StructureViewNode activeNode = view.getActiveNode(); - treeViewBuilder.buildView(view, Ajde.getDefault().getStructureModelManager().getStructureModel()); + IStructureViewNode activeNode = view.getActiveNode(); + treeViewBuilder.buildView(view, Ajde.getDefault().getStructureModelManager().getModel()); view.setActiveNode(activeNode); } @@ -195,7 +195,7 @@ public class StructureViewManager { if (properties == null) properties = DEFAULT_VIEW_PROPERTIES; FileStructureView view = new FileStructureView(properties); view.setSourceFile(sourceFilePath); - treeViewBuilder.buildView(view, StructureModelManager.getDefault().getStructureModel()); + treeViewBuilder.buildView(view, StructureModelManager.getDefault().getModel()); structureViews.add(view); return view; } diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNode.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNode.java deleted file mode 100644 index f225a6a05..000000000 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewNode.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 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: - * Xerox/PARC initial implementation - * ******************************************************************/ - - -package org.aspectj.ajde.ui; - -import java.util.List; - -import org.aspectj.asm.IProgramElement; - -/** - * @author Mik Kersten - */ -public interface StructureViewNode { - - public IProgramElement getStructureNode(); - - public AbstractIcon getIcon(); - - /** - * Add a child node. - */ - public void add(StructureViewNode child); - - /** - * Remove a child node. - */ - public void remove(StructureViewNode child); - - /** - * @return an empty list if there are no children - */ - public List getChildren(); -} diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java index 19f64a315..1e41d6759 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java @@ -14,7 +14,7 @@ package org.aspectj.ajde.ui; -import java.util.List; +import java.util.*; import org.aspectj.asm.*; @@ -29,40 +29,47 @@ public abstract class StructureViewNodeFactory { this.iconRegistry = iconRegistry; } - public StructureViewNode createNode(IProgramElement node) { + public IStructureViewNode createNode(IProgramElement node) { return createNode(node, null); } - public StructureViewNode createNode(IProgramElement node, List children) { - AbstractIcon icon; -// if (node instanceof IProgramElement) { -// IProgramElement pNode = (IProgramElement)node; - icon = iconRegistry.getStructureIcon(node.getKind(), node.getAccessibility()); -// } else if (node instanceof IRelationship) { -// IRelationship relationNode = (IRelationship)node; -// icon = iconRegistry.getRelationIcon(relationNode.getKind()); -//// } else if (node instanceof LinkNode) { -//// LinkNode linkNode = (LinkNode)node; -//// icon = iconRegistry.getStructureIcon( -//// linkNode.getProgramElementNode().getProgramElementKind(), -//// linkNode.getProgramElementNode().getAccessibility()); -// } else { -// icon = new AbstractIcon(null); -// } -// node.setChildren(children); - return createConcreteNode(node, icon, children); - } + public IStructureViewNode createNode(IProgramElement node, List children) { + AbstractIcon icon = iconRegistry.getStructureIcon(node.getKind(), node.getAccessibility()); - public StructureViewNode createNode(IRelationship relationship) { - AbstractIcon icon; - icon = iconRegistry.getRelationIcon(relationship.getKind()); - return createConcreteNode(relationship, icon); + IStructureViewNode svNode = createDeclaration(node, icon, children); + IRelationship rel = StructureModelManager.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.getIcon(link.getKind()) + ); + relNode.add(linkNode); + + } + } + return svNode; } + + /** + * Implementors must override this method in order to create link new nodes. + */ + protected abstract IStructureViewNode createLink(IProgramElement node, AbstractIcon icon); - protected abstract StructureViewNode createConcreteNode(IRelationship relationship, AbstractIcon icon); + /** + * Implementors must override this method in order to create new relationship nodes. + */ + protected abstract IStructureViewNode createRelationship(IRelationship relationship, AbstractIcon icon); /** * Implementors must override this method in order to create new nodes. */ - protected abstract StructureViewNode createConcreteNode(IProgramElement node, AbstractIcon icon, List children); + protected abstract IStructureViewNode createDeclaration(IProgramElement node, AbstractIcon icon, List children); } diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewRenderer.java b/ajde/src/org/aspectj/ajde/ui/StructureViewRenderer.java index eb0b2f819..e224a1c99 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewRenderer.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewRenderer.java @@ -36,7 +36,7 @@ public interface StructureViewRenderer extends EventListener { * the corresponding node's sourceline to be highlighted in the * active editor. */ - public void setActiveNode(StructureViewNode node); + public void setActiveNode(IStructureViewNode node); /** * Same behavior as <CODE>setActiveNode(StructureViewNode)</CODE> but @@ -45,5 +45,5 @@ public interface StructureViewRenderer extends EventListener { * @param lineOffset number of lines after the begin and before the * end line of the corresponding <CODE>StructureNode</CODE>. */ - public void setActiveNode(StructureViewNode activeNode, int lineOffset); + public void setActiveNode(IStructureViewNode activeNode, int lineOffset); } diff --git a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java index 35417834a..06534507f 100644 --- a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java +++ b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java @@ -50,7 +50,7 @@ public class TreeStructureViewBuilder { modelRoot = model.getRoot(); } - StructureViewNode viewRoot = null; + IStructureViewNode viewRoot = null; if (!isFileView(view)) { StructureViewProperties.Hierarchy hierarchy = ((GlobalStructureView)view).getGlobalViewProperties().getHierarchy(); @@ -75,7 +75,7 @@ public class TreeStructureViewBuilder { view.setRootNode(viewRoot); } - private void addPackageNode(StructureView view, StructureViewNode viewRoot) { + private void addPackageNode(StructureView view, IStructureViewNode viewRoot) { if (isFileView(view)) { // IProgramElement fileNode = viewRoot.getStructureNode(); // IProgramElement parentNode = fileNode.getParent(); @@ -93,7 +93,7 @@ public class TreeStructureViewBuilder { } } - private StructureViewNode createViewNode(IProgramElement node, StructureViewProperties properties) { + private IStructureViewNode createViewNode(IProgramElement node, StructureViewProperties properties) { if (node == null) return null; List children = new ArrayList(); // IProgramElement pNode = node; @@ -122,7 +122,7 @@ public class TreeStructureViewBuilder { } } - StructureViewNode viewNode = nodeFactory.createNode(node, children);//new TreeViewNode(root, null, children); + IStructureViewNode viewNode = nodeFactory.createNode(node, children);//new TreeViewNode(root, null, children); return viewNode; } @@ -188,18 +188,18 @@ public class TreeStructureViewBuilder { return true; } - private void sortView(StructureViewNode node, Comparator comparator) { + private void sortView(IStructureViewNode node, Comparator comparator) { if (node == null || node.getChildren() == null) return; Collections.sort(node.getChildren(), comparator); for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - StructureViewNode nextNode = (StructureViewNode)it.next(); + IStructureViewNode nextNode = (IStructureViewNode)it.next(); if (nextNode != null) sortView(nextNode, comparator); } } - private StructureViewNode buildCustomTree(GlobalStructureView view, StructureModel model) { + private IStructureViewNode buildCustomTree(GlobalStructureView view, StructureModel model) { IProgramElement rootNode = model.getRoot(); - StructureViewNode treeNode = nodeFactory.createNode(rootNode); + IStructureViewNode treeNode = nodeFactory.createNode(rootNode); List rootNodes = new ArrayList(); getRoots(rootNode, rootNodes, view.getGlobalViewProperties().getHierarchy()); @@ -256,8 +256,8 @@ public class TreeStructureViewBuilder { } } - private StructureViewNode getInheritanceChildren(IProgramElement node, List associations) { - StructureViewNode treeNode = nodeFactory.createNode(node); + private IStructureViewNode getInheritanceChildren(IProgramElement node, List associations) { + IStructureViewNode treeNode = nodeFactory.createNode(node); //StructureViewNode treeNode = new StructureViewNodeAdapter(node); List relations = ((IProgramElement)node).getRelations(); throw new RuntimeException("unimplemented"); @@ -280,9 +280,9 @@ public class TreeStructureViewBuilder { // return treeNode; } - private StructureViewNode getCrosscuttingChildren(IProgramElement node) { + private IStructureViewNode getCrosscuttingChildren(IProgramElement node) { //StructureViewNodeAdapter treeNode = new StructureViewNodeAdapter(node); - StructureViewNode treeNode = nodeFactory.createNode(node); + IStructureViewNode treeNode = nodeFactory.createNode(node); List relations = ((IProgramElement)node).getRelations(); throw new RuntimeException("unimplemented"); // if (relations != null) { @@ -313,9 +313,9 @@ public class TreeStructureViewBuilder { // return treeNode; } - private StructureViewNode buildTree(IProgramElement node, List associations) { + private IStructureViewNode buildTree(IProgramElement node, List associations) { //StructureViewNode treeNode = new StructureViewNodeAdapter(node); - StructureViewNode treeNode = nodeFactory.createNode(node); + IStructureViewNode treeNode = nodeFactory.createNode(node); // if (node instanceof IProgramElement) { // List relations = ((IProgramElement)node).getRelations(); // if (relations != null) { @@ -345,7 +345,7 @@ public class TreeStructureViewBuilder { } //sortNodes(childList); for (Iterator it = childList.iterator(); it.hasNext(); ) { - treeNode.add((StructureViewNode)it.next()); + treeNode.add((IStructureViewNode)it.next()); } } @@ -353,24 +353,25 @@ public class TreeStructureViewBuilder { return treeNode; } - private StructureViewNode getRelations(IRelationship node) { + private IStructureViewNode getRelations(IRelationship node) { + return null; //StructureViewNode treeNode = new StructureViewNode(node); - StructureViewNode treeNode = nodeFactory.createNode(node); +// IStructureViewNode treeNode = nodeFactory.c(node); // for (Iterator it = node.getTargets().iterator(); it.hasNext(); ) { // treeNode.add( // nodeFactory.createNode((IProgramElement)it.next()) // ); -// } - return treeNode; +// } +// return treeNode; } /** * For debugging only. */ - private void dumpView(StructureViewNode root, int level) { + private void dumpView(IStructureViewNode root, int level) { System.out.println(root.getStructureNode()); for (Iterator it = root.getChildren().iterator(); it.hasNext(); ) { - dumpView((StructureViewNode)it.next(), level++); + dumpView((IStructureViewNode)it.next(), level++); } for (int i = 0; i < level; i++) { System.out.print(' '); @@ -379,8 +380,8 @@ public class TreeStructureViewBuilder { private static final Comparator ALPHABETICAL_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { - IProgramElement sv1 = ((StructureViewNode)o1).getStructureNode(); - IProgramElement sv2 = ((StructureViewNode)o2).getStructureNode(); + IProgramElement sv1 = ((IStructureViewNode)o1).getStructureNode(); + IProgramElement sv2 = ((IStructureViewNode)o2).getStructureNode(); if (sv1 instanceof IProgramElement && sv2 instanceof IProgramElement) { IProgramElement p1 = (IProgramElement)sv1; IProgramElement p2 = (IProgramElement)sv2; @@ -393,8 +394,8 @@ public class TreeStructureViewBuilder { private static final Comparator DECLARATIONAL_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { - IProgramElement sv1 = ((StructureViewNode)o1).getStructureNode(); - IProgramElement sv2 = ((StructureViewNode)o2).getStructureNode(); + IProgramElement sv1 = ((IStructureViewNode)o1).getStructureNode(); + IProgramElement sv2 = ((IStructureViewNode)o2).getStructureNode(); if (sv1 instanceof IProgramElement && sv2 instanceof IProgramElement) { IProgramElement p1 = (IProgramElement)sv1; IProgramElement p2 = (IProgramElement)sv2; diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java index 0ab69ae09..2ea14436a 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java @@ -111,7 +111,7 @@ public class BrowserStructureViewToolPanel extends JPanel { for (int i = 0; i < kinds.length; i++) { if (kinds[i].isMemberKind()) { CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(kinds[i]); - menuItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(kinds[i]).getIconResource()); + menuItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getIcon(kinds[i]).getIconResource()); filterMenu.add(menuItem); } } @@ -132,7 +132,7 @@ public class BrowserStructureViewToolPanel extends JPanel { for (Iterator it = relations.iterator(); it.hasNext(); ) { IRelationship.Kind relation = (IRelationship.Kind)it.next(); CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(relation); - menuItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getRelationIcon(relation).getIconResource()); + menuItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getIcon(relation).getIconResource()); relationsMenu.add(menuItem); } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewPanel.java index 33901b2c5..098ca3049 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewPanel.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewPanel.java @@ -30,7 +30,7 @@ import javax.swing.event.ChangeListener; import org.aspectj.ajde.Ajde; import org.aspectj.ajde.ui.GlobalStructureView; import org.aspectj.ajde.ui.StructureView; -import org.aspectj.ajde.ui.StructureViewNode; +import org.aspectj.ajde.ui.IStructureViewNode; import org.aspectj.ajde.ui.StructureViewProperties; import org.aspectj.ajde.ui.StructureViewRenderer; @@ -82,11 +82,11 @@ public class BrowserViewPanel extends JPanel implements StructureViewRenderer { } } - public void setActiveNode(StructureViewNode node) { + public void setActiveNode(IStructureViewNode node) { throw new RuntimeException("not implemented"); } - public void setActiveNode(StructureViewNode activeNode, int lineOffset) { + public void setActiveNode(IStructureViewNode activeNode, int lineOffset) { throw new RuntimeException("not implemented"); } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java b/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java index ebb9319ef..0749dbb2e 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java @@ -47,7 +47,7 @@ public class BuildConfigPopupMenu extends JPopupMenu { action.actionPerformed(e); } }); - buildItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(IProgramElement.Kind.FILE_LST).getIconResource()); + buildItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getIcon(IProgramElement.Kind.FILE_LST).getIconResource()); this.add(buildItem); } } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java b/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java index decccab65..f119a452c 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java @@ -109,11 +109,11 @@ public class IconRegistry extends AbstractIconRegistry { public Icon getStructureViewIcon() { return STRUCTURE_VIEW; } public Icon getAssociationSwingIcon(IRelationship.Kind relation) { - return convertToSwingIcon(getRelationIcon(relation)); + return convertToSwingIcon(getIcon(relation)); } protected AbstractIcon getStructureIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) { - return getStructureIcon(kind); + return getIcon(kind); } public Icon getStructureSwingIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) { @@ -121,7 +121,7 @@ public class IconRegistry extends AbstractIconRegistry { } public Icon getStructureSwingIcon(IProgramElement.Kind kind) { - return convertToSwingIcon(getStructureIcon(kind)); + return convertToSwingIcon(getIcon(kind)); } public Icon getAccessibilitySwingIcon(IProgramElement.Accessibility accessibility) { diff --git a/ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java index ed93d0706..b52e23884 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java @@ -84,11 +84,11 @@ public class StructureViewPanel extends JPanel implements StructureViewRenderer view.setRenderer(this); } - public void setActiveNode(StructureViewNode node) { + public void setActiveNode(IStructureViewNode node) { setActiveNode(node, 0); } - public void setActiveNode(StructureViewNode node, int lineOffset) { + public void setActiveNode(IStructureViewNode node, int lineOffset) { if (node == null) return; if (!(node.getStructureNode() instanceof IProgramElement)) return; IProgramElement pNode = (IProgramElement)node.getStructureNode(); diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java index e1ca0bd75..dbd0c7aad 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java @@ -19,20 +19,27 @@ import java.util.*; import javax.swing.tree.DefaultMutableTreeNode; import org.aspectj.ajde.ui.*; +import org.aspectj.ajde.ui.IStructureViewNode.Kind; import org.aspectj.asm.*; /** * @author Mik Kersten */ -public class SwingTreeViewNode extends DefaultMutableTreeNode implements StructureViewNode { +public class SwingTreeViewNode extends DefaultMutableTreeNode implements IStructureViewNode { + private String relationshipName; private IProgramElement programElement; private AbstractIcon icon; - + private IStructureViewNode.Kind kind; + + /** + * Create a declaration node. + */ public SwingTreeViewNode(IProgramElement programElement, AbstractIcon icon, List children) { super(programElement, true); this.programElement = programElement; this.icon = icon; + this.kind = Kind.DECLARATION; if (children != null) { for (Iterator it = children.iterator(); it.hasNext(); ) { @@ -41,17 +48,24 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements Structu } } + /** + * Create a relationship node. + */ public SwingTreeViewNode(IRelationship relationship, AbstractIcon icon) { -// super(IProgramElement, true); - throw new RuntimeException("unimplemented"); -// this.IProgramElement = IProgramElement; -// this.icon = icon; -// -// if (children != null) { -// for (Iterator it = children.iterator(); it.hasNext(); ) { -// super.add((SwingTreeViewNode)it.next()); -// } -// } + super(null, true); + this.icon = icon; + this.kind = Kind.RELATIONSHIP; + this.relationshipName = relationship.getName(); + } + + /** + * Create a link. + */ + public SwingTreeViewNode(IProgramElement programElement, AbstractIcon icon) { + super(programElement, false); + this.programElement = programElement; + this.kind = Kind.LINK; + this.icon = icon; } public IProgramElement getStructureNode() { @@ -62,11 +76,15 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements Structu return icon; } - public void add(StructureViewNode child) { + public void add(IStructureViewNode child) { super.add((DefaultMutableTreeNode)child); } + + public void add(IStructureViewNode child, int position) { + super.insert((DefaultMutableTreeNode)child, position); + } - public void remove(StructureViewNode child) { + public void remove(IStructureViewNode child) { super.remove((DefaultMutableTreeNode)child); } @@ -77,5 +95,22 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements Structu return children; } } + + public Kind getKind() { + return kind; + } + + public String getRelationshipName() { + return relationshipName; + } + + public String toString() { + if (kind == IStructureViewNode.Kind.RELATIONSHIP) { + return relationshipName; + } else { + return programElement.getName(); + } + } + } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java index 9c45432d2..1d40bf00b 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java @@ -28,12 +28,21 @@ public class SwingTreeViewNodeFactory extends StructureViewNodeFactory { public SwingTreeViewNodeFactory(IconRegistry iconRegistry) { super(iconRegistry); } - - protected StructureViewNode createConcreteNode(IProgramElement node, AbstractIcon icon, List children) { + + protected IStructureViewNode createDeclaration( + IProgramElement node, + AbstractIcon icon, + List children) { return new SwingTreeViewNode(node, icon, children); } - protected StructureViewNode createConcreteNode( + protected IStructureViewNode createLink( + IProgramElement node, + AbstractIcon icon) { + return new SwingTreeViewNode(node, icon); + } + + protected IStructureViewNode createRelationship( IRelationship relationship, AbstractIcon icon) { return new SwingTreeViewNode(relationship, icon); diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java index 907843544..06e300335 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java @@ -19,6 +19,7 @@ import java.awt.*; import javax.swing.*; import javax.swing.tree.DefaultTreeCellRenderer; +import org.aspectj.ajde.ui.IStructureViewNode; import org.aspectj.asm.*; import org.aspectj.bridge.*; @@ -34,41 +35,39 @@ class SwingTreeViewNodeRenderer extends DefaultTreeCellRenderer { boolean leaf, int row, boolean hasFocus) { - if (treeNode == null) return null; + if (treeNode == null) return null; + this.setFont(StructureTree.DEFAULT_FONT); SwingTreeViewNode viewNode = (SwingTreeViewNode)treeNode; IProgramElement node = viewNode.getStructureNode(); -// if (node instanceof LinkNode) { -// ISourceLocation sourceLoc = ((LinkNode)node).getProgramElementNode().getSourceLocation(); -// if ((null != sourceLoc) -// && (null != sourceLoc.getSourceFile().getAbsolutePath())) { -// setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_COLOR); -// } else { -// setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_NO_SOURCE_COLOR); -// } -// } else { - setTextNonSelectionColor(new Color(0, 0, 0)); -// } - - super.getTreeCellRendererComponent(tree, treeNode, sel, expanded, leaf, row, hasFocus); - this.setFont(StructureTree.DEFAULT_FONT); - + if (viewNode.getKind() == IStructureViewNode.Kind.LINK) { + ISourceLocation sourceLoc = node.getSourceLocation(); + if ((null != sourceLoc) + && (null != sourceLoc.getSourceFile().getAbsolutePath())) { + setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_COLOR); + } else { + setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_NO_SOURCE_COLOR); + } + + } else if (viewNode.getKind() == IStructureViewNode.Kind.RELATIONSHIP) { + this.setFont(new Font(this.getFont().getName(), Font.ITALIC, this.getFont().getSize())); + setTextNonSelectionColor(new Color(0, 0, 0)); + + } else if (viewNode.getKind() == IStructureViewNode.Kind.DECLARATION) { + setTextNonSelectionColor(new Color(0, 0, 0)); + } + + super.getTreeCellRendererComponent(tree, treeNode, sel, expanded, leaf, row, hasFocus); if (viewNode.getIcon() != null && viewNode.getIcon().getIconResource() != null) { setIcon((Icon)viewNode.getIcon().getIconResource()); } else { setIcon(null); } - if (node instanceof IProgramElement) { -// if (pNode.isRunnable()) { -// //setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon()); -// } -// if (pNode.isImplementor()) { -// //this.setText("<implementor>"); -// } -// if (pNode.isOverrider()) { -// //this.setText("<overrider>"); -// } + if (node != null) { + if (node.isRunnable()) { + setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon()); + } if (node.getMessage() != null) { if (node.getMessage().getKind().equals(IMessage.WARNING)) { setIcon(AjdeUIManager.getDefault().getIconRegistry().getWarningIcon()); @@ -79,10 +78,7 @@ class SwingTreeViewNodeRenderer extends DefaultTreeCellRenderer { } } - } -// else if (node instanceof IRelationship) { -// this.setFont(new Font(this.getFont().getName(), Font.ITALIC, this.getFont().getSize())); -// } + } return this; } } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java b/ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java index 13b65d4b0..3282f2040 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java @@ -254,7 +254,7 @@ public class TreeViewBuildConfigEditor extends JPanel implements BuildConfigEdit } else if (kind.equals(BuildConfigNode.Kind.DIRECTORY)) { setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.PACKAGE)); } else { - setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(IProgramElement.Kind.ERROR).getIconResource()); + setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getIcon(IProgramElement.Kind.ERROR).getIconResource()); p.remove(cbox); } diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java index 8066ca751..d2d639beb 100644 --- a/ajde/testdata/examples/coverage/ModelCoverage.java +++ b/ajde/testdata/examples/coverage/ModelCoverage.java @@ -36,19 +36,35 @@ class SubPoint extends Point { } class Line { } aspect AdvisesRelationshipCoverage { - pointcut executionP(): execution(void Point.setX(int)); - before(): executionP() { } - - before(): execution(*..*.new(..)) { } - before(): get(int *.*) { } - before(): set(int *.*) { } - before(): initialization(Point.new(..)) { } - before(): staticinitialization(Point) { } - before(): handler(IOException) { } - before(): call(* Point.setX(int)) { } - before(): call(Point.new()) { } - before(): within(*) && execution(* Point.setX(..)) { } - before(): within(*) && execution(Point.new()) { } + pointcut methodExecutionP(): execution(void Point.setX(int)); + before(): methodExecutionP() { } + + pointcut constructorExecutionP(): execution(Point.new()); + before(): constructorExecutionP() { } + + pointcut callMethodP(): call(* Point.setX(int)); + before(): callMethodP() { } + + pointcut callConstructorP(): call(Point.new()); + before(): callConstructorP() { } + + pointcut getP(): get(int *.*); + before(): getP() { } + + pointcut setP(): set(int *.*); + before(): setP() { } + + pointcut initializationP(): initialization(Point.new(..)); + before(): initializationP() { } + + pointcut staticinitializationP(): staticinitialization(Point); + before(): staticinitializationP() { } + + pointcut handlerP(): handler(IOException); + before(): handlerP() { } + +// before(): within(*) && execution(* Point.setX(..)) { } +// before(): within(*) && execution(Point.new()) { } } aspect AdviceNamingCoverage { diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java index dfcd03dc1..e6be0bc12 100644 --- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -29,7 +29,7 @@ public class AjdeTests extends TestCase { suite.addTestSuite(CompilerMessagesTest.class); suite.addTestSuite(AsmDeclarationsTest.class); suite.addTestSuite(AsmRelationshipsTest.class); -// suite.addTestSuite(ResourceCopyTestCase.class); + suite.addTestSuite(ResourceCopyTestCase.class); //$JUnit-END$ return suite; diff --git a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java index ea4b060bc..9e99b7221 100644 --- a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java +++ b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java @@ -47,7 +47,7 @@ public class AsmDeclarationsTest extends AjdeTestCase { IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage"); + IProgramElement aspect = StructureModelManager.getDefault().getModel().findNodeForType(null, "InterTypeDecCoverage"); assertNotNull(aspect); String decErrMessage = "declare error: \"Illegal construct..\""; @@ -90,7 +90,7 @@ public class AsmDeclarationsTest extends AjdeTestCase { IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage"); + IProgramElement aspect = StructureModelManager.getDefault().getModel().findNodeForType(null, "InterTypeDecCoverage"); assertNotNull(aspect); String fieldMsg = "Point.xxx"; @@ -114,7 +114,7 @@ public class AsmDeclarationsTest extends AjdeTestCase { IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage"); + IProgramElement aspect = StructureModelManager.getDefault().getModel().findNodeForType(null, "AdviceNamingCoverage"); assertNotNull(aspect); String ptct = "named()"; @@ -134,7 +134,7 @@ public class AsmDeclarationsTest extends AjdeTestCase { IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AbstractAspect"); + IProgramElement aspect = StructureModelManager.getDefault().getModel().findNodeForType(null, "AbstractAspect"); assertNotNull(aspect); String abst = "abPtct()"; @@ -147,7 +147,7 @@ public class AsmDeclarationsTest extends AjdeTestCase { IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage"); + IProgramElement aspect = StructureModelManager.getDefault().getModel().findNodeForType(null, "AdviceNamingCoverage"); assertNotNull(aspect); String anon = "before(): <anonymous pointcut>"; @@ -189,7 +189,7 @@ public class AsmDeclarationsTest extends AjdeTestCase { protected void setUp() throws Exception { super.setUp("examples"); assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH)); - model = StructureModelManager.getDefault().getStructureModel(); + model = StructureModelManager.getDefault().getModel(); } protected void tearDown() throws Exception { diff --git a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java index dce7331e4..e50ee51cd 100644 --- a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java +++ b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java @@ -11,59 +11,62 @@ package org.aspectj.ajde; -import java.util.Iterator; +import java.util.List; -import org.aspectj.ajdt.internal.core.builder.AsmNodeFormatter; import org.aspectj.asm.*; -import org.aspectj.asm.IProgramElement.Kind; // TODO: check for return types public class AsmRelationshipsTest extends AjdeTestCase { - - private StructureModel model = null; + + private StructureModelManager manager = null; private static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst"; public AsmRelationshipsTest(String name) { super(name); } - - public void testExecution() { - IProgramElement node = (IProgramElement)model.getRoot(); + + public void testAdvice() { + IProgramElement node = (IProgramElement)manager.getModel().getRoot(); assertNotNull(node); - IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdvisesRelationshipCoverage"); + 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)"); + } + + private void checkUniDirectionalMapping(String fromType, String toType, String from, String to) { + IProgramElement aspect = StructureModelManager.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); + assertEquals(((IProgramElement)rel.getTargets().get(0)).getName(), to); + } - String beforeExec = "before(): executionP.."; - IProgramElement beforeExecNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, beforeExec); + private void checkMapping(String fromType, String toType, String from, String to) { + IProgramElement aspect = StructureModelManager.getDefault().getModel().findNodeForType(null, fromType); + assertNotNull(aspect); + String beforeExec = from; + IProgramElement beforeExecNode = manager.getModel().findNode(aspect, IProgramElement.Kind.ADVICE, beforeExec); assertNotNull(beforeExecNode); - - - -// System.err.println("> root: " + node); - - -// assertEquals(ptctNode.getName(), ptct); - -// -// IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage"); -// assertNotNull(aspect); - -// fail(); - - -// -// String params = "namedWithArgs(int, int)"; -// IProgramElement paramsNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, params); -// assertNotNull(paramsNode); -// assertEquals(paramsNode.getName(), params); + IRelationship rel = manager.getMapper().get(beforeExecNode); + assertEquals(((IProgramElement)rel.getTargets().get(0)).getName(), to); + + IProgramElement clazz = StructureModelManager.getDefault().getModel().findNodeForType(null, toType); + assertNotNull(clazz); + String set = to; + IProgramElement setNode = manager.getModel().findNode(clazz, IProgramElement.Kind.METHOD, set); + assertNotNull(setNode); + IRelationship rel2 = manager.getMapper().get(setNode); + assertEquals(((IProgramElement)rel2.getTargets().get(0)).getName(), from); } protected void setUp() throws Exception { super.setUp("examples"); assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH)); - model = StructureModelManager.getDefault().getStructureModel(); + manager = StructureModelManager.getDefault(); } protected void tearDown() throws Exception { diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java index 8e0a5227e..fa097c8dc 100644 --- a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java @@ -50,7 +50,7 @@ public class StructureModelRegressionTest extends AjdeTestCase { if (modelFile.exists()) { Ajde.getDefault().getStructureModelManager().readStructureModel(lstFile); - StructureModel savedModel = Ajde.getDefault().getStructureModelManager().getStructureModel(); + StructureModel savedModel = Ajde.getDefault().getStructureModelManager().getModel(); //System.err.println( savedModel.getRoot().getClass() + ", " + savedModel.getRoot()); // AMC This test will not pass as written until IProgramElement defines @@ -100,7 +100,7 @@ public class StructureModelRegressionTest extends AjdeTestCase { Thread.sleep(300); } catch (InterruptedException ie) { } } - return Ajde.getDefault().getStructureModelManager().getStructureModel(); + return Ajde.getDefault().getStructureModelManager().getModel(); } protected void setUp() throws Exception { @@ -109,7 +109,7 @@ public class StructureModelRegressionTest extends AjdeTestCase { } public void testModelExists() { - assertTrue(Ajde.getDefault().getStructureModelManager().getStructureModel() != null); + assertTrue(Ajde.getDefault().getStructureModelManager().getModel() != 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 8a1952cce..5777715cb 100644 --- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java @@ -78,7 +78,7 @@ public class StructureModelTest extends AjdeTestCase { public void testRootForSourceFile() throws IOException { File testFile = openFile("figures-coverage/figures/Figure.java"); - IProgramElement node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile( + IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findRootNodeForSourceFile( testFile.getCanonicalPath()); assertTrue("find result", node != null) ; IProgramElement pNode = (IProgramElement)node; @@ -89,7 +89,7 @@ public class StructureModelTest extends AjdeTestCase { public void testPointcutName() throws IOException { File testFile = openFile("figures-coverage/figures/Main.java"); //System.err.println("PointcutName, testFile: " + testFile.getCanonicalPath() + " exists: " + testFile.exists()); - IProgramElement node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile( + IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findRootNodeForSourceFile( testFile.getCanonicalPath()); //System.err.println(" node: " + node); assertTrue("find result", node != null) ; @@ -107,7 +107,7 @@ public class StructureModelTest extends AjdeTestCase { public void testFileNodeFind() throws IOException { File testFile = openFile("figures-coverage/figures/Main.java"); //System.err.println("NodeFind, testFile: " + testFile.getCanonicalPath() + " exists: " + testFile.exists()); - IProgramElement node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( + IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findNodeForSourceLine( testFile.getCanonicalPath(), 1); //System.err.println(" node: " + node); assertTrue("find result", node != null) ; @@ -120,7 +120,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().getStructureModel(); + StructureModel model = Ajde.getDefault().getStructureModelManager().getModel(); assertTrue("model exists", model != null); assertTrue("root exists", model.getRoot() != null); File testFile = openFile("figures-coverage/figures/Main.java"); @@ -137,7 +137,7 @@ public class StructureModelTest extends AjdeTestCase { * Integrity could be checked somewhere in the API. */ public void testModelIntegrity() { - IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); + IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getModel().getRoot(); assertTrue("root exists", modelRoot != null); try { @@ -167,7 +167,7 @@ public class StructureModelTest extends AjdeTestCase { } } }; - Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot().walk(walker); + Ajde.getDefault().getStructureModelManager().getModel().getRoot().walk(walker); } protected void setUp() throws Exception { diff --git a/ajde/testsrc/org/aspectj/ajde/ui/NullIdeFileStructureView.java b/ajde/testsrc/org/aspectj/ajde/ui/NullIdeFileStructureView.java index 5127387b7..d77ed3cf0 100644 --- a/ajde/testsrc/org/aspectj/ajde/ui/NullIdeFileStructureView.java +++ b/ajde/testsrc/org/aspectj/ajde/ui/NullIdeFileStructureView.java @@ -32,7 +32,7 @@ public class NullIdeFileStructureView extends FileStructureView { this.sourceFilePath = sourceFile; } - public void setRootNode(StructureViewNode rootNode) { + public void setRootNode(IStructureViewNode rootNode) { super.setRootNode(rootNode); notifyViewUpdated(); } diff --git a/ajde/testsrc/org/aspectj/ajde/ui/NullIdeStructureViewRenderer.java b/ajde/testsrc/org/aspectj/ajde/ui/NullIdeStructureViewRenderer.java index d013e76d7..b871d2add 100644 --- a/ajde/testsrc/org/aspectj/ajde/ui/NullIdeStructureViewRenderer.java +++ b/ajde/testsrc/org/aspectj/ajde/ui/NullIdeStructureViewRenderer.java @@ -25,11 +25,11 @@ public class NullIdeStructureViewRenderer implements StructureViewRenderer { hasBeenNotified = true; } - public void setActiveNode(StructureViewNode node) { + public void setActiveNode(IStructureViewNode node) { // ignored } - public void setActiveNode(StructureViewNode node, int lineOffset) { + public void setActiveNode(IStructureViewNode node, int lineOffset) { // ignored } diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java index 1bd8776ea..680b0ffc9 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().getStructureModel() != null); + assertTrue(Ajde.getDefault().getStructureModelManager().getModel() != null); } public void testNotificationAfterConfigFileChange() { @@ -85,7 +85,7 @@ public class StructureViewManagerTest extends AjdeTestCase { //System.err.println(">>>>>> " + currentView.getRootNode().getIProgramElement()); // AMC should this be currentView, or should we recreate the root... do the latter //IProgramElement n = currentView.getRootNode().getIProgramElement(); - IProgramElement n = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); + IProgramElement n = Ajde.getDefault().getStructureModelManager().getModel().getRoot(); assertTrue( "no structure", //currentView.getRootNode().getIProgramElement().getChildren().get(0) @@ -95,7 +95,7 @@ public class StructureViewManagerTest extends AjdeTestCase { public void testModelIntegrity() { doSynchronousBuild(CONFIG_FILE_PATH); - IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); + IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getModel().getRoot(); assertTrue("root exists", modelRoot != null); try { |