From f1deb9c11024ecebab2e0aa17a260821375c25bd Mon Sep 17 00:00:00 2001 From: mkersten <mkersten> Date: Fri, 8 Aug 2003 11:02:53 +0000 Subject: Reimplemented ASM API as described in bug "41254: revise asm and create interfaces". Containment hierarchy is done and tests added. Relationships are not done yet. All clients except AJDT ported. More UI porting in Swing clients required. --- .../ajde/internal/LstBuildConfigManager.java | 18 +- .../org/aspectj/ajde/ui/AbstractIconRegistry.java | 70 ++--- ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java | 13 +- ajde/src/org/aspectj/ajde/ui/BuildConfigNode.java | 136 +++++++- .../org/aspectj/ajde/ui/StructureModelUtil.java | 87 +++--- .../aspectj/ajde/ui/StructureSearchManager.java | 24 +- ajde/src/org/aspectj/ajde/ui/StructureView.java | 8 +- .../org/aspectj/ajde/ui/StructureViewManager.java | 79 ++--- .../src/org/aspectj/ajde/ui/StructureViewNode.java | 4 +- .../aspectj/ajde/ui/StructureViewNodeFactory.java | 48 +-- .../aspectj/ajde/ui/StructureViewProperties.java | 26 +- .../ajde/ui/internal/NavigationHistoryModel.java | 14 +- .../ajde/ui/internal/TreeStructureViewBuilder.java | 348 ++++++++++----------- .../org/aspectj/ajde/ui/swing/AjdeUIManager.java | 28 +- .../ui/swing/BrowserStructureViewToolPanel.java | 57 ++-- .../src/org/aspectj/ajde/ui/swing/BrowserView.java | 4 +- .../aspectj/ajde/ui/swing/BrowserViewManager.java | 26 +- .../ajde/ui/swing/BrowserViewTreeListener.java | 69 ++-- .../ajde/ui/swing/BuildConfigPopupMenu.java | 4 +- .../org/aspectj/ajde/ui/swing/IconRegistry.java | 30 +- .../org/aspectj/ajde/ui/swing/PointcutWizard.java | 4 +- .../ui/swing/SimpleStructureViewToolPanel.java | 8 +- .../ajde/ui/swing/StructureTreeManager.java | 56 ++-- .../aspectj/ajde/ui/swing/StructureViewPanel.java | 28 +- .../aspectj/ajde/ui/swing/SwingTreeViewNode.java | 34 +- .../ajde/ui/swing/SwingTreeViewNodeFactory.java | 16 +- .../ajde/ui/swing/SwingTreeViewNodeRenderer.java | 82 +++-- .../ajde/ui/swing/TreeViewBuildConfigEditor.java | 12 +- ajde/testdata/examples/coverage/ModelCoverage.java | 2 +- ajde/testdata/examples/coverage/coverage.lst | 3 +- ajde/testdata/examples/coverage/pkg/InPackage.java | 4 + ajde/testsrc/org/aspectj/ajde/AjdeTests.java | 1 + .../org/aspectj/ajde/AsmDeclarationsTest.java | 80 +++-- .../org/aspectj/ajde/AsmRelationshipsTest.java | 64 ++++ .../org/aspectj/ajde/NullIdeErrorHandler.java | 29 ++ ajde/testsrc/org/aspectj/ajde/NullIdeManager.java | 3 +- .../org/aspectj/ajde/NullIdeProgressMonitor.java | 45 +++ .../org/aspectj/ajde/NullIdeTaskListManager.java | 4 +- .../testsrc/org/aspectj/ajde/NullIdeUIAdapter.java | 2 +- .../aspectj/ajde/StructureModelRegressionTest.java | 23 +- .../org/aspectj/ajde/StructureModelTest.java | 46 ++- .../aspectj/ajde/ui/StructureModelUtilTest.java | 24 +- .../ajde/ui/StructureSearchManagerTest.java | 4 +- .../aspectj/ajde/ui/StructureViewManagerTest.java | 18 +- 44 files changed, 947 insertions(+), 738 deletions(-) create mode 100644 ajde/testdata/examples/coverage/pkg/InPackage.java create mode 100644 ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java create mode 100644 ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java create mode 100644 ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java (limited to 'ajde') diff --git a/ajde/src/org/aspectj/ajde/internal/LstBuildConfigManager.java b/ajde/src/org/aspectj/ajde/internal/LstBuildConfigManager.java index f6e23cf61..779a8350e 100644 --- a/ajde/src/org/aspectj/ajde/internal/LstBuildConfigManager.java +++ b/ajde/src/org/aspectj/ajde/internal/LstBuildConfigManager.java @@ -14,20 +14,12 @@ package org.aspectj.ajde.internal; -import java.io.File; -import java.io.FileFilter; -import java.io.FilenameFilter; +import java.io.*; import java.util.*; -import org.aspectj.ajde.Ajde; -import org.aspectj.ajde.BuildConfigListener; -import org.aspectj.ajde.BuildConfigManager; -import org.aspectj.ajde.ui.BuildConfigModel; -import org.aspectj.ajde.ui.BuildConfigNode; -import org.aspectj.asm.StructureNode; -import org.aspectj.bridge.IMessage; -import org.aspectj.bridge.Message; -import org.aspectj.bridge.SourceLocation; +import org.aspectj.ajde.*; +import org.aspectj.ajde.ui.*; +import org.aspectj.bridge.*; import org.aspectj.util.ConfigParser; /** @@ -247,7 +239,7 @@ public class LstBuildConfigManager implements BuildConfigManager { } for (Iterator it = nodesToRemove.iterator(); it.hasNext(); ) { - StructureNode currNode = (StructureNode)it.next(); + BuildConfigNode currNode = (BuildConfigNode)it.next(); node.removeChild(currNode); } return node.getChildren().size() > 0; diff --git a/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java b/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java index 1b281d1ed..6e4a32b41 100644 --- a/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java +++ b/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java @@ -14,11 +14,7 @@ package org.aspectj.ajde.ui; -import org.aspectj.asm.AdviceAssociation; -import org.aspectj.asm.InheritanceAssociation; -import org.aspectj.asm.IntroductionAssociation; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.Relation; +import org.aspectj.asm.*; /** * Uses the factory pattern. @@ -62,12 +58,12 @@ 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(Relation relation) { - if (relation.getAssociationName().equals(AdviceAssociation.NAME)) { + public AbstractIcon getRelationIcon(IRelationship.Kind relationship) { + if (relationship == IRelationship.Kind.ADVICE) { return RELATION_ADVICE_FORWARD; - } else if (relation.getAssociationName().equals(IntroductionAssociation.NAME)) { + } else if (relationship == IRelationship.Kind.DECLARE) { return RELATION_ADVICE_FORWARD; - } else if (relation.getAssociationName().equals(InheritanceAssociation.NAME)) { + } else if (relationship == IRelationship.Kind.INHERITANCE) { return RELATION_INHERITANCE_FORWARD; } else { return RELATION_REFERENCE_FORWARD; @@ -77,8 +73,8 @@ public abstract class AbstractIconRegistry { /** * @return null if the kind could not be resolved */ - protected AbstractIcon getStructureIcon(ProgramElementNode.Kind kind, ProgramElementNode.Accessibility accessibility) { - return getStructureIcon(kind, ProgramElementNode.Accessibility.PUBLIC); + protected AbstractIcon getStructureIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) { + return getStructureIcon(kind, IProgramElement.Accessibility.PUBLIC); } /** @@ -86,56 +82,56 @@ public abstract class AbstractIconRegistry { * * @return null if the kind could not be resolved */ - public AbstractIcon getStructureIcon(ProgramElementNode.Kind kind) { - if (kind == ProgramElementNode.Kind.PROJECT) { + public AbstractIcon getStructureIcon(IProgramElement.Kind kind) { + if (kind == IProgramElement.Kind.PROJECT) { return PROJECT; - } else if (kind == ProgramElementNode.Kind.PACKAGE) { + } else if (kind == IProgramElement.Kind.PACKAGE) { return PACKAGE; - } else if (kind == ProgramElementNode.Kind.FILE) { + } else if (kind == IProgramElement.Kind.FILE) { return FILE; - } else if (kind == ProgramElementNode.Kind.FILE_JAVA) { + } else if (kind == IProgramElement.Kind.FILE_JAVA) { return FILE_JAVA; - } else if (kind == ProgramElementNode.Kind.FILE_ASPECTJ) { + } else if (kind == IProgramElement.Kind.FILE_ASPECTJ) { return FILE_ASPECTJ; - } else if (kind == ProgramElementNode.Kind.FILE_LST) { + } else if (kind == IProgramElement.Kind.FILE_LST) { return FILE_LST; - } else if (kind == ProgramElementNode.Kind.CLASS) { + } else if (kind == IProgramElement.Kind.CLASS) { return CLASS; - } else if (kind == ProgramElementNode.Kind.INTERFACE) { + } else if (kind == IProgramElement.Kind.INTERFACE) { return INTERFACE; - } else if (kind == ProgramElementNode.Kind.ASPECT) { + } else if (kind == IProgramElement.Kind.ASPECT) { return ASPECT; - } else if (kind == ProgramElementNode.Kind.INITIALIZER) { + } else if (kind == IProgramElement.Kind.INITIALIZER) { return INITIALIZER; - } else if (kind == ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR) { + } else if (kind == IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR) { return INTRODUCTION; - } else if (kind == ProgramElementNode.Kind.INTER_TYPE_FIELD) { + } else if (kind == IProgramElement.Kind.INTER_TYPE_FIELD) { return INTRODUCTION; - } else if (kind == ProgramElementNode.Kind.INTER_TYPE_METHOD) { + } else if (kind == IProgramElement.Kind.INTER_TYPE_METHOD) { return INTRODUCTION; - } else if (kind == ProgramElementNode.Kind.CONSTRUCTOR) { + } else if (kind == IProgramElement.Kind.CONSTRUCTOR) { return CONSTRUCTOR; - } else if (kind == ProgramElementNode.Kind.METHOD) { + } else if (kind == IProgramElement.Kind.METHOD) { return METHOD; - } else if (kind == ProgramElementNode.Kind.FIELD) { + } else if (kind == IProgramElement.Kind.FIELD) { return FIELD; - } else if (kind == ProgramElementNode.Kind.POINTCUT) { + } else if (kind == IProgramElement.Kind.POINTCUT) { return POINTCUT; - } else if (kind == ProgramElementNode.Kind.ADVICE) { + } else if (kind == IProgramElement.Kind.ADVICE) { return ADVICE; - } else if (kind == ProgramElementNode.Kind.DECLARE_PARENTS) { + } else if (kind == IProgramElement.Kind.DECLARE_PARENTS) { return DECLARE_PARENTS; - } else if (kind == ProgramElementNode.Kind.DECLARE_WARNING) { + } else if (kind == IProgramElement.Kind.DECLARE_WARNING) { return DECLARE_WARNING; - } else if (kind == ProgramElementNode.Kind.DECLARE_ERROR) { + } else if (kind == IProgramElement.Kind.DECLARE_ERROR) { return DECLARE_ERROR; - } else if (kind == ProgramElementNode.Kind.DECLARE_SOFT) { + } else if (kind == IProgramElement.Kind.DECLARE_SOFT) { return DECLARE_SOFT; - } else if (kind == ProgramElementNode.Kind.DECLARE_PRECEDENCE) { + } else if (kind == IProgramElement.Kind.DECLARE_PRECEDENCE) { return DECLARE_SOFT; - } else if (kind == ProgramElementNode.Kind.CODE) { + } else if (kind == IProgramElement.Kind.CODE) { return CODE; - } else if (kind == ProgramElementNode.Kind.ERROR) { + } else if (kind == IProgramElement.Kind.ERROR) { return ERROR; } else { System.err.println("AJDE Message: unresolved icon kind " + kind); diff --git a/ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java b/ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java index 1687e69ee..fdd00fb76 100644 --- a/ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java +++ b/ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java @@ -24,7 +24,9 @@ import org.aspectj.asm.StructureModel; /** * @author Mik Kersten */ -public class BuildConfigModel extends StructureModel { +public class BuildConfigModel { + + private BuildConfigNode root = null; private String sourceFile; @@ -94,6 +96,15 @@ public class BuildConfigModel extends StructureModel { public void setSourceFile(String sourceFile) { this.sourceFile = sourceFile; } + + public BuildConfigNode getRoot() { + return root; + } + + public void setRoot(BuildConfigNode node) { + root = node; + } + } diff --git a/ajde/src/org/aspectj/ajde/ui/BuildConfigNode.java b/ajde/src/org/aspectj/ajde/ui/BuildConfigNode.java index 5c28c7e43..eff97262b 100644 --- a/ajde/src/org/aspectj/ajde/ui/BuildConfigNode.java +++ b/ajde/src/org/aspectj/ajde/ui/BuildConfigNode.java @@ -14,31 +14,141 @@ package org.aspectj.ajde.ui; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.util.List; +import java.io.*; +import java.util.*; -import org.aspectj.asm.StructureNode; +import org.aspectj.bridge.*; /** * @author Mik Kersten + * + * TODO: clean-up after merging of org.aspectj.asm.StructureNode */ -public class BuildConfigNode extends StructureNode { +public class BuildConfigNode { + + + + protected BuildConfigNode parent = null; + protected String name = ""; + protected Kind kind; + // children.listIterator() should support remove() operation + protected List children = new ArrayList(); + protected IMessage message = null; + protected ISourceLocation sourceLocation = null; + + /** + * Used during serialization. + */ + public BuildConfigNode() { } + +// public BuildConfigNode(String name, String kind, String resourcePath, List children) { +// this(name, kind, children); +// this.resourcePath = resourcePath; +// } - private String resourcePath; - private Kind kind; - private boolean isActive = true; - public BuildConfigNode(String name, Kind kind, String resourcePath) { - super(name, kind.toString()); + this(name, kind); this.kind = kind; this.resourcePath = resourcePath; } - public BuildConfigNode(String name, String kind, String resourcePath, List children) { - super(name, kind, children); - this.resourcePath = resourcePath; +// public BuildConfigNode(String name, Kind kind, List children) { +// this.name = name; +// this.kind = kind; +// if (children != null) { +// this.children = children; +// } +// setParents(); +// } + + public BuildConfigNode(String name, Kind kind) { + this.name = name; + this.kind = kind; + } + + public String toString() { + return name; + } + + public List getChildren() { + return children; + } + + public void addChild(BuildConfigNode child) { + if (children == null) { + children = new ArrayList(); + } + children.add(child); + child.setParent(this); + } + + public void addChild(int position, BuildConfigNode child) { + if (children == null) { + children = new ArrayList(); + } + children.add(position, child); + child.setParent(this); + } + + public boolean removeChild(BuildConfigNode child) { + child.setParent(null); + return children.remove(child); + } + + /** + * Comparison is string-name based only. + */ + public int compareTo(Object o) throws ClassCastException { + if (this == o) { + return 0; + } else { + BuildConfigNode sn = (BuildConfigNode)o; + return this.getName().compareTo(sn.getName()); + } + } + + public String getName() { + return name; } + + public ISourceLocation getSourceLocation() { + return sourceLocation; + } + + public void setSourceLocation(ISourceLocation sourceLocation) { + this.sourceLocation = sourceLocation; + } + + public IMessage getMessage() { + return message; + } + + public void setMessage(IMessage message) { + this.message = message; + } + + public BuildConfigNode getParent() { + return parent; + } + + public void setParent(BuildConfigNode parent) { + this.parent = parent; + } + + private void setParents() { + if (children == null) return; + for (Iterator it = children.iterator(); it.hasNext(); ) { + ((BuildConfigNode)it.next()).setParent(this); + } + } + + public void setName(String string) { + name = string; + } + + + private String resourcePath; + private boolean isActive = true; public String getResourcePath() { return resourcePath; diff --git a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java index 81d33f75c..1b4a1a9d1 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java @@ -14,25 +14,10 @@ package org.aspectj.ajde.ui; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Vector; +import java.util.*; import org.aspectj.ajde.Ajde; -import org.aspectj.asm.LinkNode; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.RelationNode; -import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureModelManager; -import org.aspectj.asm.StructureNode; +import org.aspectj.asm.*; /** * Prototype functionality for package view clients. @@ -63,15 +48,15 @@ public class StructureModelUtil { Object key = it.next(); List annotations = (List) annotationsMap.get(key); for (Iterator it2 = annotations.iterator(); it2.hasNext();) { - ProgramElementNode node = (ProgramElementNode) it2.next(); + IProgramElement node = (IProgramElement) it2.next(); List relations = node.getRelations(); for (Iterator it3 = relations.iterator(); it3.hasNext();) { - RelationNode relationNode = (RelationNode) it3.next(); + IRelationship relationNode = (IRelationship) it3.next(); if (relationNode.getKind().equals("Advice")) { - List children = relationNode.getChildren(); + List children = relationNode.getTargets(); List aspects = new Vector(); @@ -80,19 +65,19 @@ public class StructureModelUtil { ) { Object object = it4.next(); - if (object instanceof LinkNode) { - ProgramElementNode pNode = - ((LinkNode) object).getProgramElementNode(); - - if (pNode.getProgramElementKind() - == ProgramElementNode.Kind.ADVICE) { - - StructureNode theAspect = pNode.getParent(); - - aspects.add(theAspect); - - } - } +// if (object instanceof LinkNode) { +// IProgramElement pNode = +// ((LinkNode) object).getProgramElementNode(); +// +// if (pNode.getProgramElementKind() +// == IProgramElement.Kind.ADVICE) { +// +// IProgramElement theAspect = pNode.getParent(); +// +// aspects.add(theAspect); +// +// } +// } } if (!aspects.isEmpty()) { aspectMap.put(key, aspects); @@ -111,11 +96,11 @@ public class StructureModelUtil { * * @return the set of aspects with advice that affects the specified package */ - public static Set getAspectsAffectingPackage(ProgramElementNode packageNode) { + public static Set getAspectsAffectingPackage(IProgramElement packageNode) { List files = StructureModelUtil.getFilesInPackage(packageNode); Set aspects = new HashSet(); for (Iterator it = files.iterator(); it.hasNext();) { - ProgramElementNode fileNode = (ProgramElementNode) it.next(); + IProgramElement fileNode = (IProgramElement) it.next(); Map adviceMap = getLinesToAspectMap( fileNode.getSourceLocation().getSourceFile().getAbsolutePath()); @@ -135,20 +120,20 @@ public class StructureModelUtil { return null; } else { return getPackagesHelper( - (ProgramElementNode) model.getRoot(), - ProgramElementNode.Kind.PACKAGE, + (IProgramElement) model.getRoot(), + IProgramElement.Kind.PACKAGE, null, packages); } } private static List getPackagesHelper( - ProgramElementNode node, - ProgramElementNode.Kind kind, + IProgramElement node, + IProgramElement.Kind kind, String prename, List matches) { - if (kind == null || node.getProgramElementKind().equals(kind)) { + if (kind == null || node.getKind().equals(kind)) { if (prename == null) { prename = new String(node.toString()); } else { @@ -162,10 +147,10 @@ public class StructureModelUtil { } for (Iterator it = node.getChildren().iterator(); it.hasNext();) { - StructureNode nextNode = (StructureNode) it.next(); - if (nextNode instanceof ProgramElementNode) { + IProgramElement nextNode = (IProgramElement) it.next(); + if (nextNode instanceof IProgramElement) { getPackagesHelper( - (ProgramElementNode) nextNode, + (IProgramElement) nextNode, kind, prename, matches); @@ -202,8 +187,8 @@ public class StructureModelUtil { private class SortingComparator implements Comparator { public int compare(Object o1, Object o2) { - ProgramElementNode p1 = (ProgramElementNode) o1; - ProgramElementNode p2 = (ProgramElementNode) o2; + IProgramElement p1 = (IProgramElement) o1; + IProgramElement p2 = (IProgramElement) o2; String name1 = p1.getName(); String name2 = p2.getName(); @@ -217,8 +202,8 @@ public class StructureModelUtil { Object[] array1 = (Object[]) o1; Object[] array2 = (Object[]) o2; - ProgramElementNode p1 = (ProgramElementNode) array1[1]; - ProgramElementNode p2 = (ProgramElementNode) array2[1]; + IProgramElement p1 = (IProgramElement) array1[1]; + IProgramElement p2 = (IProgramElement) array2[1]; String name1 = p1.getName(); String name2 = p2.getName(); @@ -230,7 +215,7 @@ public class StructureModelUtil { /** * @return all of the AspectJ and Java source files in a package */ - public static List getFilesInPackage(ProgramElementNode packageNode) { + public static List getFilesInPackage(IProgramElement packageNode) { List packageContents; if (packageNode == null) { return null; @@ -239,9 +224,9 @@ public class StructureModelUtil { } List files = new ArrayList(); for (Iterator it = packageContents.iterator(); it.hasNext(); ) { - ProgramElementNode packageItem = (ProgramElementNode)it.next(); - if (packageItem.getProgramElementKind() == ProgramElementNode.Kind.FILE_JAVA - || packageItem.getProgramElementKind() == ProgramElementNode.Kind.FILE_ASPECTJ) { + IProgramElement packageItem = (IProgramElement)it.next(); + if (packageItem.getKind() == IProgramElement.Kind.FILE_JAVA + || packageItem.getKind() == IProgramElement.Kind.FILE_ASPECTJ) { files.add(packageItem); } } diff --git a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java index e997091b4..6afc5b91e 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java @@ -14,14 +14,10 @@ package org.aspectj.ajde.ui; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import java.util.*; import org.aspectj.ajde.Ajde; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureNode; +import org.aspectj.asm.*; /** * @author Mik Kersten @@ -35,35 +31,35 @@ public class StructureSearchManager { */ public List findMatches( String pattern, - ProgramElementNode.Kind kind) { + IProgramElement.Kind kind) { List matches = new ArrayList(); StructureModel model = Ajde.getDefault().getStructureModelManager().getStructureModel(); if (model.equals(StructureModel.NO_STRUCTURE)) { return null; } else { - return findMatchesHelper((ProgramElementNode)model.getRoot(), pattern, kind, matches); + return findMatchesHelper((IProgramElement)model.getRoot(), pattern, kind, matches); } } private List findMatchesHelper( - ProgramElementNode node, + IProgramElement node, String pattern, - ProgramElementNode.Kind kind, + IProgramElement.Kind kind, List matches) { if (node != null && node.getName().indexOf(pattern) != -1) { - if (kind == null || node.getProgramElementKind().equals(kind)) { + if (kind == null || node.getKind().equals(kind)) { matches.add(node); } } for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - StructureNode nextNode = (StructureNode)it.next(); - if (nextNode instanceof ProgramElementNode) { + IProgramElement nextNode = (IProgramElement)it.next(); + if (nextNode instanceof IProgramElement) { findMatchesHelper( - (ProgramElementNode)nextNode, + (IProgramElement)nextNode, pattern, kind, matches); diff --git a/ajde/src/org/aspectj/ajde/ui/StructureView.java b/ajde/src/org/aspectj/ajde/ui/StructureView.java index 52d592479..3ff063d0c 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureView.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureView.java @@ -16,7 +16,7 @@ package org.aspectj.ajde.ui; import java.util.Iterator; -import org.aspectj.asm.ProgramElementNode; +import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten @@ -57,7 +57,7 @@ public abstract class StructureView { */ public StructureViewNode getActiveNode() { if (activeNode != null - && activeNode.getStructureNode() instanceof ProgramElementNode) { + && activeNode.getStructureNode() instanceof IProgramElement) { return activeNode; } else { return null; @@ -69,11 +69,11 @@ public abstract class StructureView { * * @return the first match */ - public StructureViewNode findCorrespondingViewNode(ProgramElementNode node) { + public StructureViewNode findCorrespondingViewNode(IProgramElement node) { return findCorrespondingViewNodeHelper(rootNode, node); } - private StructureViewNode findCorrespondingViewNodeHelper(StructureViewNode node, ProgramElementNode pNode) { + private StructureViewNode findCorrespondingViewNodeHelper(StructureViewNode node, IProgramElement pNode) { if (node != null && node.getStructureNode() != null diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java index ad2be9c79..880ddd5ae 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java @@ -14,23 +14,11 @@ package org.aspectj.ajde.ui; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import java.util.*; import org.aspectj.ajde.Ajde; -import org.aspectj.ajde.ui.internal.NavigationHistoryModel; -import org.aspectj.ajde.ui.internal.TreeStructureViewBuilder; -import org.aspectj.asm.AdviceAssociation; -import org.aspectj.asm.InheritanceAssociation; -import org.aspectj.asm.IntroductionAssociation; -import org.aspectj.asm.LinkNode; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.ReferenceAssociation; -import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureModelListener; -import org.aspectj.asm.StructureModelManager; -import org.aspectj.asm.StructureNode; +import org.aspectj.ajde.ui.internal.*; +import org.aspectj.asm.*; /** * @author Mik Kersten @@ -47,7 +35,7 @@ public class StructureViewManager { private static final StructureViewProperties DEFAULT_VIEW_PROPERTIES; private static final List AVAILABLE_RELATIONS; - public final StructureModelListener VIEW_LISTENER = new StructureModelListener() { + public final IStructureModelListener VIEW_LISTENER = new IStructureModelListener() { public void modelUpdated(StructureModel model) { Ajde.getDefault().logEvent("updating structure views: " + structureViews); // @@ -71,7 +59,7 @@ public class StructureViewManager { } public void fireNavigateBackAction(StructureView view) { - ProgramElementNode backNode = historyModel.navigateBack(); + IProgramElement backNode = historyModel.navigateBack(); if (backNode == null) { Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("No node to navigate back to in history"); @@ -81,7 +69,7 @@ public class StructureViewManager { } public void fireNavigateForwardAction(StructureView view) { - ProgramElementNode forwardNode = historyModel.navigateForward(); + IProgramElement forwardNode = historyModel.navigateForward(); if (forwardNode == null) { Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("No node to navigate forward to in history"); @@ -96,26 +84,27 @@ public class StructureViewManager { * @param newFilePath the canonicalized path to the new file */ public void fireNavigationAction(String newFilePath, int lineNumber) { - StructureNode currNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( + IProgramElement currNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( newFilePath, lineNumber); - if (currNode instanceof ProgramElementNode) { - navigationAction((ProgramElementNode)currNode, true); + if (currNode instanceof IProgramElement) { + navigationAction((IProgramElement)currNode, true); } } /** * History is recorded for {@link LinkNode} navigations. */ - public void fireNavigationAction(StructureNode structureNode) { - ProgramElementNode node = null; + public void fireNavigationAction(IProgramElement IProgramElement) { + IProgramElement node = null; boolean recordHistory = false; - if (structureNode instanceof LinkNode) { - node = ((LinkNode)structureNode).getProgramElementNode(); - recordHistory = true; - } else if (structureNode instanceof ProgramElementNode) { - node = (ProgramElementNode)structureNode; +// if (IProgramElement instanceof LinkNode) { +// node = ((LinkNode)IProgramElement).getProgramElementNode(); +// recordHistory = true; +// } else + if (IProgramElement instanceof IProgramElement) { + node = (IProgramElement)IProgramElement; } if (node != null) navigationAction(node, recordHistory); } @@ -125,7 +114,7 @@ public class StructureViewManager { * and as such is below the granularity visible in the view the parent is highlighted, * along with the corresponding sourceline. */ - private void navigationAction(ProgramElementNode node, boolean recordHistory) { + private void navigationAction(IProgramElement node, boolean recordHistory) { if (node == null || node == StructureModel.NO_STRUCTURE) { Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("Source not available for node: " + node.getName()); @@ -145,8 +134,8 @@ public class StructureViewManager { for (Iterator it = structureViews.iterator(); it.hasNext(); ) { StructureView view = (StructureView)it.next(); if (!(view instanceof GlobalStructureView) || !recordHistory || defaultFileView == null) { - if (node.getProgramElementKind().equals(ProgramElementNode.Kind.CODE)) { - ProgramElementNode parentNode = (ProgramElementNode)node.getParent(); + if (node.getKind().equals(IProgramElement.Kind.CODE)) { + IProgramElement parentNode = (IProgramElement)node.getParent(); if (parentNode != null) { StructureViewNode currNode = view.findCorrespondingViewNode(parentNode); int lineOffset = node.getSourceLocation().getLine() - parentNode.getSourceLocation().getLine(); @@ -160,11 +149,11 @@ public class StructureViewManager { } } - private ProgramElementNode getProgramElementNode(StructureViewNode node) { - if (node.getStructureNode() instanceof ProgramElementNode) { - return (ProgramElementNode)node.getStructureNode(); - } else if (node.getStructureNode() instanceof LinkNode) { - return ((LinkNode)node.getStructureNode()).getProgramElementNode(); + private IProgramElement getProgramElementNode(StructureViewNode node) { + if (node.getStructureNode() instanceof IProgramElement) { + return (IProgramElement)node.getStructureNode(); +// } else if (node.getStructureNode() instanceof LinkNode) { +// return ((LinkNode)node.getStructureNode()).getProgramElementNode(); } else { return null; } @@ -228,20 +217,10 @@ public class StructureViewManager { static { AVAILABLE_RELATIONS = new ArrayList(); - AVAILABLE_RELATIONS.add(AdviceAssociation.METHOD_CALL_SITE_RELATION); - AVAILABLE_RELATIONS.add(AdviceAssociation.METHOD_RELATION); - AVAILABLE_RELATIONS.add(AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION); - AVAILABLE_RELATIONS.add(AdviceAssociation.CONSTRUCTOR_RELATION); - AVAILABLE_RELATIONS.add(AdviceAssociation.FIELD_ACCESS_RELATION); - AVAILABLE_RELATIONS.add(AdviceAssociation.INITIALIZER_RELATION); - AVAILABLE_RELATIONS.add(AdviceAssociation.HANDLER_RELATION); - AVAILABLE_RELATIONS.add(AdviceAssociation.INTRODUCTION_RELATION); - AVAILABLE_RELATIONS.add(IntroductionAssociation.INTRODUCES_RELATION); - AVAILABLE_RELATIONS.add(InheritanceAssociation.IMPLEMENTS_RELATION); - AVAILABLE_RELATIONS.add(InheritanceAssociation.INHERITS_RELATION); - AVAILABLE_RELATIONS.add(InheritanceAssociation.INHERITS_MEMBERS_RELATION); - AVAILABLE_RELATIONS.add(ReferenceAssociation.USES_POINTCUT_RELATION); - AVAILABLE_RELATIONS.add(ReferenceAssociation.IMPORTS_RELATION); + AVAILABLE_RELATIONS.add(IRelationship.Kind.ADVICE); + AVAILABLE_RELATIONS.add(IRelationship.Kind.INHERITANCE); + AVAILABLE_RELATIONS.add(IRelationship.Kind.DECLARE); + AVAILABLE_RELATIONS.add(IRelationship.Kind.REFERENCE); DEFAULT_VIEW_PROPERTIES = new StructureViewProperties(); DEFAULT_VIEW_PROPERTIES.setRelations(AVAILABLE_RELATIONS); diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNode.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNode.java index fc2700813..f225a6a05 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewNode.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewNode.java @@ -16,14 +16,14 @@ package org.aspectj.ajde.ui; import java.util.List; -import org.aspectj.asm.StructureNode; +import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten */ public interface StructureViewNode { - public StructureNode getStructureNode(); + public IProgramElement getStructureNode(); public AbstractIcon getIcon(); diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java index 102d58b95..19f64a315 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java @@ -16,10 +16,7 @@ package org.aspectj.ajde.ui; import java.util.List; -import org.aspectj.asm.LinkNode; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.RelationNode; -import org.aspectj.asm.StructureNode; +import org.aspectj.asm.*; /** * @author Mik Kersten @@ -32,31 +29,40 @@ public abstract class StructureViewNodeFactory { this.iconRegistry = iconRegistry; } - public StructureViewNode createNode(StructureNode node) { + public StructureViewNode createNode(IProgramElement node) { return createNode(node, null); } - public StructureViewNode createNode(StructureNode node, List children) { + public StructureViewNode createNode(IProgramElement node, List children) { AbstractIcon icon; - if (node instanceof ProgramElementNode) { - ProgramElementNode pNode = (ProgramElementNode)node; - icon = iconRegistry.getStructureIcon(pNode.getProgramElementKind(), pNode.getAccessibility()); - } else if (node instanceof RelationNode) { - RelationNode relationNode = (RelationNode)node; - icon = iconRegistry.getRelationIcon(relationNode.getRelation()); - } else if (node instanceof LinkNode) { - LinkNode linkNode = (LinkNode)node; - icon = iconRegistry.getStructureIcon( - linkNode.getProgramElementNode().getProgramElementKind(), - linkNode.getProgramElementNode().getAccessibility()); - } else { - icon = new AbstractIcon(null); - } +// 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 StructureViewNode createNode(IRelationship relationship) { + AbstractIcon icon; + icon = iconRegistry.getRelationIcon(relationship.getKind()); + return createConcreteNode(relationship, icon); + } + protected abstract StructureViewNode createConcreteNode(IRelationship relationship, AbstractIcon icon); + /** * Implementors must override this method in order to create new nodes. */ - protected abstract StructureViewNode createConcreteNode(StructureNode node, AbstractIcon icon, List children); + protected abstract StructureViewNode createConcreteNode(IProgramElement node, AbstractIcon icon, List children); } diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewProperties.java b/ajde/src/org/aspectj/ajde/ui/StructureViewProperties.java index 230108d62..519d928a7 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewProperties.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewProperties.java @@ -15,11 +15,9 @@ package org.aspectj.ajde.ui; import java.io.ObjectStreamException; -import java.util.ArrayList; -import java.util.List; +import java.util.*; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.Relation; +import org.aspectj.asm.*; /** * Nested properties use the typesafe enum pattern. @@ -54,12 +52,12 @@ public class StructureViewProperties { this.relations = relations; } - public void addRelation(Relation relation) { - relations.add(relation); + public void addRelation(IRelationship.Kind kind) { + relations.add(kind); } - public void removeRelation(Relation relation) { - relations.remove(relation); + public void removeRelation(IRelationship.Kind kind) { + relations.remove(kind); } public void setFilteredMemberAccessibility(List memberVisibility) { @@ -70,11 +68,11 @@ public class StructureViewProperties { return filteredMemberAccessibility; } - public void addFilteredMemberAccessibility(ProgramElementNode.Accessibility accessibility) { + public void addFilteredMemberAccessibility(IProgramElement.Accessibility accessibility) { this.filteredMemberAccessibility.add(accessibility); } - public void removeFilteredMemberAccessibility(ProgramElementNode.Accessibility accessibility) { + public void removeFilteredMemberAccessibility(IProgramElement.Accessibility accessibility) { this.filteredMemberAccessibility.remove(accessibility); } @@ -86,11 +84,11 @@ public class StructureViewProperties { this.filteredMemberModifiers = memberModifiers; } - public void addFilteredMemberModifiers(ProgramElementNode.Modifiers modifiers) { + public void addFilteredMemberModifiers(IProgramElement.Modifiers modifiers) { this.filteredMemberModifiers.add(modifiers); } - public void removeFilteredMemberModifiers(ProgramElementNode.Modifiers modifiers) { + public void removeFilteredMemberModifiers(IProgramElement.Modifiers modifiers) { this.filteredMemberModifiers.remove(modifiers); } @@ -110,11 +108,11 @@ public class StructureViewProperties { this.filteredMemberKinds = memberKinds; } - public void addFilteredMemberKind(ProgramElementNode.Kind kind) { + public void addFilteredMemberKind(IProgramElement.Kind kind) { this.filteredMemberKinds.add(kind); } - public void removeFilteredMemberKind(ProgramElementNode.Kind kind) { + public void removeFilteredMemberKind(IProgramElement.Kind kind) { this.filteredMemberKinds.remove(kind); } diff --git a/ajde/src/org/aspectj/ajde/ui/internal/NavigationHistoryModel.java b/ajde/src/org/aspectj/ajde/ui/internal/NavigationHistoryModel.java index d15167926..2f1425a94 100644 --- a/ajde/src/org/aspectj/ajde/ui/internal/NavigationHistoryModel.java +++ b/ajde/src/org/aspectj/ajde/ui/internal/NavigationHistoryModel.java @@ -16,41 +16,41 @@ package org.aspectj.ajde.ui.internal; import java.util.Stack; -import org.aspectj.asm.ProgramElementNode; +import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten */ public class NavigationHistoryModel { - private ProgramElementNode currNode = null; + private IProgramElement currNode = null; private Stack backHistory = new Stack(); private Stack forwardHistory = new Stack(); /** * @return null if the history is empty */ - public ProgramElementNode navigateBack() { + public IProgramElement navigateBack() { if (backHistory.isEmpty() || currNode == null) return null; forwardHistory.push(currNode); - currNode = (ProgramElementNode)backHistory.pop(); + currNode = (IProgramElement)backHistory.pop(); return currNode; } /** * @return null if the history is empty */ - public ProgramElementNode navigateForward() { + public IProgramElement navigateForward() { if (forwardHistory.isEmpty() || currNode == null) return null; backHistory.push(currNode); - currNode = (ProgramElementNode)forwardHistory.pop(); + currNode = (IProgramElement)forwardHistory.pop(); return currNode; } - public void navigateToNode(ProgramElementNode toNode) { + public void navigateToNode(IProgramElement toNode) { if (currNode != null) backHistory.push(currNode); currNode = toNode; } diff --git a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java index 32daa8a34..4473dc1e9 100644 --- a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java +++ b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java @@ -14,24 +14,11 @@ package org.aspectj.ajde.ui.internal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; +import java.util.*; -import org.aspectj.ajde.ui.FileStructureView; -import org.aspectj.ajde.ui.GlobalStructureView; -import org.aspectj.ajde.ui.StructureView; -import org.aspectj.ajde.ui.StructureViewNode; -import org.aspectj.ajde.ui.StructureViewNodeFactory; -import org.aspectj.ajde.ui.StructureViewProperties; -import org.aspectj.asm.LinkNode; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.Relation; -import org.aspectj.asm.RelationNode; -import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureNode; +import org.aspectj.ajde.ui.*; +import org.aspectj.asm.*; +import org.aspectj.asm.internal.ProgramElement; /** * @author Mik Kersten @@ -49,7 +36,7 @@ public class TreeStructureViewBuilder { */ public void buildView(StructureView view, StructureModel model) { StructureViewProperties properties = view.getViewProperties(); - StructureNode modelRoot = null; + IProgramElement modelRoot = null; boolean noStructure = false; if (isFileView(view)) { FileStructureView fileView = (FileStructureView)view; @@ -62,7 +49,7 @@ public class TreeStructureViewBuilder { } else { modelRoot = model.getRoot(); } - + StructureViewNode viewRoot = null; if (!isFileView(view)) { StructureViewProperties.Hierarchy hierarchy @@ -90,53 +77,50 @@ public class TreeStructureViewBuilder { private void addPackageNode(StructureView view, StructureViewNode viewRoot) { if (isFileView(view)) { - ProgramElementNode fileNode = (ProgramElementNode)viewRoot.getStructureNode(); - - StructureNode parentNode = fileNode.getParent(); - if (parentNode instanceof ProgramElementNode - && ((ProgramElementNode)parentNode).getProgramElementKind().equals(ProgramElementNode.Kind.PACKAGE)) { - String name = ((ProgramElementNode)parentNode).getName(); - ProgramElementNode packageNode = new ProgramElementNode(name, ProgramElementNode.Kind.PACKAGE, null); - packageNode.setSourceLocation(fileNode.getSourceLocation()); - StructureViewNode packageViewNode = createViewNode( - packageNode, - view.getViewProperties() - ); - viewRoot.getChildren().add(0, packageViewNode); - }; +// IProgramElement fileNode = viewRoot.getStructureNode(); +// IProgramElement parentNode = fileNode.getParent(); +// +// if (parentNode.getKind() == IProgramElement.Kind.PACKAGE) { +// String name = parentNode.getName(); +// IProgramElement packageNode = new ProgramElement(name, IProgramElement.Kind.PACKAGE, null); +// packageNode.setSourceLocation(fileNode.getSourceLocation()); +// StructureViewNode packageViewNode = createViewNode( +// packageNode, +// view.getViewProperties() +// ); +// viewRoot.getChildren().add(0, packageViewNode); +// }; } } - private StructureViewNode createViewNode(StructureNode node, StructureViewProperties properties) { + private StructureViewNode createViewNode(IProgramElement node, StructureViewProperties properties) { if (node == null) return null; List children = new ArrayList(); - if (node instanceof ProgramElementNode) { - ProgramElementNode pNode = (ProgramElementNode)node; - if (pNode.getRelations() != null) { - for (Iterator it = pNode.getRelations().iterator(); it.hasNext(); ) { - StructureNode structureNode = (StructureNode)it.next(); - if (acceptNode(structureNode, properties)) { - children.add(createViewNode(structureNode, properties)); - } - } - } - if (pNode.isRunnable() && pNode.getParent() != null) { - ProgramElementNode parent = (ProgramElementNode)pNode.getParent(); - if (parent.getProgramElementKind().equals(ProgramElementNode.Kind.CLASS) - || parent.getProgramElementKind().equals(ProgramElementNode.Kind.ASPECT)) { - parent.setRunnable(true); - pNode.setRunnable(false); - } - } - } - if (node.getChildren() != null) { - for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - StructureNode structureNode = (StructureNode)it.next(); - if (acceptNode(structureNode, properties)) { - children.add(createViewNode(structureNode, properties)); +// IProgramElement pNode = node; + if (node.getRelations() != null) { + for (Iterator it = node.getRelations().iterator(); it.hasNext(); ) { + IProgramElement IProgramElement = (IProgramElement)it.next(); + if (acceptNode(IProgramElement, properties)) { + children.add(createViewNode(IProgramElement, properties)); } } } + if (node.isRunnable() && node.getParent() != null) { + IProgramElement parent = node.getParent(); + if (parent.getKind().equals(IProgramElement.Kind.CLASS) + || parent.getKind().equals(IProgramElement.Kind.ASPECT)) { + parent.setRunnable(true); + node.setRunnable(false); + } + } +// if (node.getChildren() != null) { +// for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { +// IProgramElement IProgramElement = (IProgramElement)it.next(); +// if (acceptNode(IProgramElement, properties)) { +// children.add(createViewNode(IProgramElement, properties)); +// } +// } +// } StructureViewNode viewNode = nodeFactory.createNode(node, children);//new TreeViewNode(root, null, children); return viewNode; } @@ -149,43 +133,43 @@ public class TreeStructureViewBuilder { && !(view instanceof GlobalStructureView); } - private boolean acceptGranularity(ProgramElementNode.Kind kind, StructureViewProperties.Granularity granularity) { + private boolean acceptGranularity(IProgramElement.Kind kind, StructureViewProperties.Granularity granularity) { if (granularity == StructureViewProperties.Granularity.DECLARED_ELEMENTS) { return true; } else if (granularity == StructureViewProperties.Granularity.MEMBER && - (kind != ProgramElementNode.Kind.CODE)) { + (kind != IProgramElement.Kind.CODE)) { return true; } else if (granularity == StructureViewProperties.Granularity.TYPE - && (kind == ProgramElementNode.Kind.PROJECT - || kind == ProgramElementNode.Kind.PACKAGE + && (kind == IProgramElement.Kind.PROJECT + || kind == IProgramElement.Kind.PACKAGE || kind.isSourceFileKind() || kind.isTypeKind())) { return true; } else if (granularity == StructureViewProperties.Granularity.FILE - && (kind == ProgramElementNode.Kind.PROJECT - || kind == ProgramElementNode.Kind.PACKAGE + && (kind == IProgramElement.Kind.PROJECT + || kind == IProgramElement.Kind.PACKAGE || kind.isSourceFileKind())) { return true; } else if (granularity == StructureViewProperties.Granularity.PACKAGE - && (kind == ProgramElementNode.Kind.PROJECT - || kind == ProgramElementNode.Kind.PACKAGE)) { + && (kind == IProgramElement.Kind.PROJECT + || kind == IProgramElement.Kind.PACKAGE)) { return true; } else { return false; } } - private boolean acceptNode(StructureNode node, StructureViewProperties properties) { - if (node instanceof ProgramElementNode) { - ProgramElementNode pNode = (ProgramElementNode)node; - if (!acceptGranularity(pNode.getProgramElementKind(), properties.getGranularity())) { + private boolean acceptNode(IProgramElement node, StructureViewProperties properties) { + if (node instanceof IProgramElement) { + IProgramElement pNode = (IProgramElement)node; + if (!acceptGranularity(pNode.getKind(), properties.getGranularity())) { return false; } else if (pNode.isMemberKind()) { if (properties.getFilteredMemberAccessibility().contains(pNode.getAccessibility())) { return false; } - if (properties.getFilteredMemberKinds().contains(pNode.getProgramElementKind())) { + if (properties.getFilteredMemberKinds().contains(pNode.getKind())) { return false; } for (Iterator it = pNode.getModifiers().iterator(); it.hasNext(); ) { @@ -194,8 +178,8 @@ public class TreeStructureViewBuilder { } } } - } else if (node instanceof RelationNode) { - Relation relation = ((RelationNode)node).getRelation(); + } else if (node instanceof IRelationship) { + IRelationship relation = (IRelationship)node; return properties.getRelations().contains(relation); } else { return true; @@ -213,7 +197,7 @@ public class TreeStructureViewBuilder { } private StructureViewNode buildCustomTree(GlobalStructureView view, StructureModel model) { - StructureNode rootNode = model.getRoot(); + IProgramElement rootNode = model.getRoot(); StructureViewNode treeNode = nodeFactory.createNode(rootNode); List rootNodes = new ArrayList(); @@ -221,10 +205,10 @@ public class TreeStructureViewBuilder { for (Iterator it = rootNodes.iterator(); it.hasNext(); ) { if (view.getGlobalViewProperties().getHierarchy().equals(StructureViewProperties.Hierarchy.CROSSCUTTING)) { - treeNode.add(getCrosscuttingChildren((StructureNode)it.next())); + treeNode.add(getCrosscuttingChildren((IProgramElement)it.next())); } else if (view.getGlobalViewProperties().getHierarchy().equals(StructureViewProperties.Hierarchy.INHERITANCE)) { treeNode.add(getInheritanceChildren( - (StructureNode)it.next(), + (IProgramElement)it.next(), view.getViewProperties().getRelations()) ); } @@ -232,123 +216,125 @@ public class TreeStructureViewBuilder { return treeNode; } - private void getRoots(StructureNode rootNode, List roots, StructureViewProperties.Hierarchy hierarchy) { - if (rootNode != null && rootNode.getChildren() != null) { - for (Iterator it = rootNode.getChildren().iterator(); it.hasNext(); ) { - StructureNode node = (StructureNode)it.next(); - if (node instanceof ProgramElementNode) { - if (acceptNodeAsRoot((ProgramElementNode)node, hierarchy)) { - ProgramElementNode pNode = (ProgramElementNode)node; - List relations = pNode.getRelations(); - String delimiter = ""; - if (hierarchy.equals(StructureViewProperties.Hierarchy.CROSSCUTTING)) { - delimiter = "uses pointcut"; - } else if (hierarchy.equals(StructureViewProperties.Hierarchy.INHERITANCE)) { - delimiter = "inherits"; - } - if (relations != null && relations.toString().indexOf(delimiter) == -1) { - boolean found = false; - for (Iterator it2 = roots.iterator(); it2.hasNext(); ) { - if (((ProgramElementNode)it2.next()).equals(pNode)) found = true; - } - if (!found) roots.add(pNode); - } - } - } - getRoots(node, roots, hierarchy); - } - } + private void getRoots(IProgramElement rootNode, List roots, StructureViewProperties.Hierarchy hierarchy) { +// if (rootNode != null && rootNode.getChildren() != null) { +// for (Iterator it = rootNode.getChildren().iterator(); it.hasNext(); ) { +// IProgramElement node = (IProgramElement)it.next(); +// if (node instanceof IProgramElement) { +// if (acceptNodeAsRoot((IProgramElement)node, hierarchy)) { +// IProgramElement pNode = (IProgramElement)node; +// List relations = pNode.getRelations(); +// String delimiter = ""; +// if (hierarchy.equals(StructureViewProperties.Hierarchy.CROSSCUTTING)) { +// delimiter = "uses pointcut"; +// } else if (hierarchy.equals(StructureViewProperties.Hierarchy.INHERITANCE)) { +// delimiter = "inherits"; +// } +// if (relations != null && relations.toString().indexOf(delimiter) == -1) { +// boolean found = false; +// for (Iterator it2 = roots.iterator(); it2.hasNext(); ) { +// if (((IProgramElement)it2.next()).equals(pNode)) found = true; +// } +// if (!found) roots.add(pNode); +// } +// } +// } +// getRoots(node, roots, hierarchy); +// } +// } } - public boolean acceptNodeAsRoot(ProgramElementNode node, StructureViewProperties.Hierarchy hierarchy) { + public boolean acceptNodeAsRoot(IProgramElement node, StructureViewProperties.Hierarchy hierarchy) { if (hierarchy.equals(StructureViewProperties.Hierarchy.CROSSCUTTING)) { - return node.getProgramElementKind().equals(ProgramElementNode.Kind.ADVICE) - || node.getProgramElementKind().equals(ProgramElementNode.Kind.POINTCUT); + return node.getKind().equals(IProgramElement.Kind.ADVICE) + || node.getKind().equals(IProgramElement.Kind.POINTCUT); } else if (hierarchy.equals(StructureViewProperties.Hierarchy.INHERITANCE)) { - return node.getProgramElementKind().equals(ProgramElementNode.Kind.CLASS); + return node.getKind().equals(IProgramElement.Kind.CLASS); } else { return false; } } - private StructureViewNode getInheritanceChildren(StructureNode node, List associations) { + private StructureViewNode getInheritanceChildren(IProgramElement node, List associations) { StructureViewNode treeNode = nodeFactory.createNode(node); //StructureViewNode treeNode = new StructureViewNodeAdapter(node); - List relations = ((ProgramElementNode)node).getRelations(); - if (relations != null) { - for (Iterator it = relations.iterator(); it.hasNext(); ) { - RelationNode relation = (RelationNode)it.next(); - if (relation.getName().equals("is inherited by")) { - for (Iterator it2 = relation.getChildren().iterator(); it2.hasNext(); ) { - ProgramElementNode pNode = ((LinkNode)it2.next()).getProgramElementNode(); - StructureViewNode newNode = getInheritanceChildren(pNode, associations); - StructureViewNode typeChildren = buildTree(newNode.getStructureNode(), associations); - for (int i = 0; i < typeChildren.getChildren().size(); i++) { - newNode.add((StructureViewNode)typeChildren.getChildren().get(i)); - } - treeNode.add(newNode); - } - } - } - } - return treeNode; + List relations = ((IProgramElement)node).getRelations(); + throw new RuntimeException("unimplemented"); +// if (relations != null) { +// for (Iterator it = relations.iterator(); it.hasNext(); ) { +// IRelationship relation = (IRelationship)it.next(); +// if (relation.getName().equals("is inherited by")) { +// for (Iterator it2 = relation.getTargets().iterator(); it2.hasNext(); ) { +//// IProgramElement pNode = ((LinkNode)it2.next()).getProgramElementNode(); +//// StructureViewNode newNode = getInheritanceChildren(pNode, associations); +// StructureViewNode typeChildren = buildTree(newNode.getStructureNode(), associations); +// for (int i = 0; i < typeChildren.getChildren().size(); i++) { +// newNode.add((StructureViewNode)typeChildren.getChildren().get(i)); +// } +// treeNode.add(newNode); +// } +// } +// } +// } +// return treeNode; } - private StructureViewNode getCrosscuttingChildren(StructureNode node) { + private StructureViewNode getCrosscuttingChildren(IProgramElement node) { //StructureViewNodeAdapter treeNode = new StructureViewNodeAdapter(node); StructureViewNode treeNode = nodeFactory.createNode(node); - List relations = ((ProgramElementNode)node).getRelations(); - if (relations != null) { - for (Iterator it = relations.iterator(); it.hasNext(); ) { - RelationNode relation = (RelationNode)it.next(); - if (relation.getName().equals("pointcut used by")) { - for (Iterator it2 = relation.getChildren().iterator(); it2.hasNext(); ) { - ProgramElementNode pNode = ((LinkNode)it2.next()).getProgramElementNode(); - StructureViewNode newNode = getCrosscuttingChildren(pNode); - for (Iterator it3 = pNode.getRelations().iterator(); it3.hasNext(); ) { - RelationNode relationNode = (RelationNode)it3.next(); - if (relationNode.getName().indexOf("pointcut") == -1) { - newNode.add(getRelations(relationNode)); - } - } - treeNode.add(newNode); - } - } else if (relations.toString().indexOf("uses pointcut") == -1) { - for (Iterator it4 = relations.iterator(); it4.hasNext(); ) { - RelationNode relationNode = (RelationNode)it4.next(); - if (relationNode.getName().indexOf("pointcut") == -1) { - treeNode.add(getRelations(relationNode)); - } - } - } - } - } - return treeNode; + List relations = ((IProgramElement)node).getRelations(); + throw new RuntimeException("unimplemented"); +// if (relations != null) { +// for (Iterator it = relations.iterator(); it.hasNext(); ) { +// IRelationship relation = (IRelationship)it.next(); +// if (relation.getName().equals("pointcut used by")) { +// for (Iterator it2 = relation.getTargets().iterator(); it2.hasNext(); ) { +// IProgramElement pNode = ((LinkNode)it2.next()).getProgramElementNode(); +// StructureViewNode newNode = getCrosscuttingChildren(pNode); +// for (Iterator it3 = pNode.getRelations().iterator(); it3.hasNext(); ) { +// IRelationship relationNode = (IRelation)it3.next(); +// if (relationNode.getName().indexOf("pointcut") == -1) { +// newNode.add(getRelations(relationNode)); +// } +// } +// treeNode.add(newNode); +// } +// } else if (relations.toString().indexOf("uses pointcut") == -1) { +// for (Iterator it4 = relations.iterator(); it4.hasNext(); ) { +// IRelation relationNode = (IRelationship)it4.next(); +// if (relationNode.getName().indexOf("pointcut") == -1) { +// treeNode.add(getRelations(relationNode)); +// } +// } +// } +// } +// } +// return treeNode; } - private StructureViewNode buildTree(StructureNode node, List associations) { + private StructureViewNode buildTree(IProgramElement node, List associations) { //StructureViewNode treeNode = new StructureViewNodeAdapter(node); StructureViewNode treeNode = nodeFactory.createNode(node); - if (node instanceof ProgramElementNode) { - List relations = ((ProgramElementNode)node).getRelations(); - if (relations != null) { - for (Iterator it = relations.iterator(); it.hasNext(); ) { - RelationNode relationNode = (RelationNode)it.next(); - if (associations.contains(relationNode.getRelation().toString())) { - treeNode.add(buildTree(relationNode, associations)); - } - } - } - } +// if (node instanceof IProgramElement) { +// List relations = ((IProgramElement)node).getRelations(); +// if (relations != null) { +// for (Iterator it = relations.iterator(); it.hasNext(); ) { +// IRelationship relationNode = (IRelationship)it.next(); +// if (associations.contains(relationNode.toString())) { +// treeNode.add(buildTree(relationNode, associations)); +// } +// } +// } +// } if (node != null) { List children = null; children = node.getChildren(); if (children != null) { List childList = new ArrayList(); for (Iterator itt = children.iterator(); itt.hasNext(); ) { - StructureNode child = (StructureNode)itt.next(); - if (child instanceof ProgramElementNode) { - ProgramElementNode progNode = (ProgramElementNode)child; + IProgramElement child = (IProgramElement)itt.next(); + if (child instanceof IProgramElement) { + IProgramElement progNode = (IProgramElement)child; if (!progNode.isCode()) { childList.add(buildTree(child, associations)); } @@ -366,12 +352,12 @@ public class TreeStructureViewBuilder { return treeNode; } - private StructureViewNode getRelations(RelationNode node) { + private StructureViewNode getRelations(IRelationship node) { //StructureViewNode treeNode = new StructureViewNode(node); StructureViewNode treeNode = nodeFactory.createNode(node); - for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { + for (Iterator it = node.getTargets().iterator(); it.hasNext(); ) { treeNode.add( - nodeFactory.createNode((StructureNode)it.next()) + nodeFactory.createNode((IProgramElement)it.next()) ); } return treeNode; @@ -392,11 +378,11 @@ public class TreeStructureViewBuilder { private static final Comparator ALPHABETICAL_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { - StructureNode sv1 = ((StructureViewNode)o1).getStructureNode(); - StructureNode sv2 = ((StructureViewNode)o2).getStructureNode(); - if (sv1 instanceof ProgramElementNode && sv2 instanceof ProgramElementNode) { - ProgramElementNode p1 = (ProgramElementNode)sv1; - ProgramElementNode p2 = (ProgramElementNode)sv2; + IProgramElement sv1 = ((StructureViewNode)o1).getStructureNode(); + IProgramElement sv2 = ((StructureViewNode)o2).getStructureNode(); + if (sv1 instanceof IProgramElement && sv2 instanceof IProgramElement) { + IProgramElement p1 = (IProgramElement)sv1; + IProgramElement p2 = (IProgramElement)sv2; return p1.getName().compareTo(p2.getName()); } else { return 0; @@ -406,11 +392,11 @@ public class TreeStructureViewBuilder { private static final Comparator DECLARATIONAL_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { - StructureNode sv1 = ((StructureViewNode)o1).getStructureNode(); - StructureNode sv2 = ((StructureViewNode)o2).getStructureNode(); - if (sv1 instanceof ProgramElementNode && sv2 instanceof ProgramElementNode) { - ProgramElementNode p1 = (ProgramElementNode)sv1; - ProgramElementNode p2 = (ProgramElementNode)sv2; + IProgramElement sv1 = ((StructureViewNode)o1).getStructureNode(); + IProgramElement sv2 = ((StructureViewNode)o2).getStructureNode(); + if (sv1 instanceof IProgramElement && sv2 instanceof IProgramElement) { + IProgramElement p1 = (IProgramElement)sv1; + IProgramElement p2 = (IProgramElement)sv2; if (p1.getSourceLocation() == null) { return 0; } else if (p1.getSourceLocation().getLine() < p2.getSourceLocation().getLine()) { diff --git a/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java b/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java index c2dbd074c..bd1f9d76b 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java @@ -47,6 +47,28 @@ public class AjdeUIManager { private Frame rootFrame = null; private StructureViewPanel fileStructurePanel = null; + public void init( + EditorAdapter editorAdapter, + TaskListManager taskListManager, + ProjectPropertiesAdapter projectProperties, + UserPreferencesAdapter userPreferencesAdapter, + IdeUIAdapter ideUIAdapter, + IconRegistry iconRegistry, + Frame rootFrame, + boolean useFileView) { + + init(editorAdapter, + taskListManager, + projectProperties, + userPreferencesAdapter, + ideUIAdapter, + iconRegistry, + rootFrame, + new DefaultBuildProgressMonitor(rootFrame), + new AjdeErrorHandler(), + useFileView); + } + /** * Order of initialization is critical here. */ @@ -58,10 +80,10 @@ public class AjdeUIManager { IdeUIAdapter ideUIAdapter, IconRegistry iconRegistry, Frame rootFrame, + BuildProgressMonitor progressMonitor, + ErrorHandler errorHandler, boolean useFileView) { try { - BuildProgressMonitor compileProgress = new DefaultBuildProgressMonitor(rootFrame); - ErrorHandler errorHandler = new AjdeErrorHandler(); this.iconRegistry = iconRegistry; //ConfigurationManager configManager = new LstConfigurationManager(); this.ideUIAdapter = ideUIAdapter; @@ -72,7 +94,7 @@ public class AjdeUIManager { Ajde.init( editorAdapter, taskListManager, - compileProgress, + progressMonitor, projectProperties, buildOptionsAdapter, new SwingTreeViewNodeFactory(iconRegistry), diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java index 3b69fd7a6..0ab69ae09 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java @@ -14,29 +14,16 @@ package org.aspectj.ajde.ui.swing; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.awt.*; +import java.awt.event.*; import java.util.Iterator; -import javax.swing.ButtonGroup; -import javax.swing.Icon; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JSeparator; +import javax.swing.*; import javax.swing.border.Border; import org.aspectj.ajde.Ajde; -import org.aspectj.ajde.ui.GlobalStructureView; -import org.aspectj.ajde.ui.StructureView; -import org.aspectj.ajde.ui.StructureViewProperties; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.Relation; +import org.aspectj.ajde.ui.*; +import org.aspectj.asm.*; public class BrowserStructureViewToolPanel extends JPanel { @@ -112,7 +99,7 @@ public class BrowserStructureViewToolPanel extends JPanel { private JPopupMenu createFilterMenu() { JPopupMenu filterMenu = new JPopupMenu(); - ProgramElementNode.Accessibility[] accessibility = ProgramElementNode.Accessibility.ALL; + IProgramElement.Accessibility[] accessibility = IProgramElement.Accessibility.ALL; for (int i = 0; i < accessibility.length; i++) { CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(accessibility[i]); menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getAccessibilitySwingIcon(accessibility[i])); @@ -120,7 +107,7 @@ public class BrowserStructureViewToolPanel extends JPanel { } filterMenu.add(new JSeparator()); - ProgramElementNode.Kind[] kinds = ProgramElementNode.Kind.ALL; + IProgramElement.Kind[] kinds = IProgramElement.Kind.ALL; for (int i = 0; i < kinds.length; i++) { if (kinds[i].isMemberKind()) { CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(kinds[i]); @@ -130,7 +117,7 @@ public class BrowserStructureViewToolPanel extends JPanel { } filterMenu.add(new JSeparator()); - ProgramElementNode.Modifiers[] modifiers = ProgramElementNode.Modifiers.ALL; + IProgramElement.Modifiers[] modifiers = IProgramElement.Modifiers.ALL; for (int i = 0; i < modifiers.length; i++) { CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(modifiers[i]); filterMenu.add(menuItem); @@ -143,7 +130,7 @@ public class BrowserStructureViewToolPanel extends JPanel { java.util.List relations = Ajde.getDefault().getStructureViewManager().getAvailableRelations(); for (Iterator it = relations.iterator(); it.hasNext(); ) { - Relation relation = (Relation)it.next(); + IRelationship.Kind relation = (IRelationship.Kind)it.next(); CheckBoxSelectionMenuButton menuItem = new CheckBoxSelectionMenuButton(relation); menuItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getRelationIcon(relation).getIconResource()); relationsMenu.add(menuItem); @@ -198,17 +185,17 @@ public class BrowserStructureViewToolPanel extends JPanel { //super.setSelected(true); } - public CheckBoxSelectionMenuButton(ProgramElementNode.Accessibility accessibility) { + public CheckBoxSelectionMenuButton(IProgramElement.Accessibility accessibility) { this(accessibility.toString()); this.addActionListener(new CheckBoxSelectionMenuActionListener(accessibility)); } - public CheckBoxSelectionMenuButton(ProgramElementNode.Kind kind) { + public CheckBoxSelectionMenuButton(IProgramElement.Kind kind) { this(kind.toString()); this.addActionListener(new CheckBoxSelectionMenuActionListener(kind)); } - public CheckBoxSelectionMenuButton(ProgramElementNode.Modifiers modifiers) { + public CheckBoxSelectionMenuButton(IProgramElement.Modifiers modifiers) { this(modifiers.toString()); this.addActionListener(new CheckBoxSelectionMenuActionListener(modifiers)); } @@ -218,7 +205,7 @@ public class BrowserStructureViewToolPanel extends JPanel { this.addActionListener(new CheckBoxSelectionMenuActionListener(sorting)); } - public CheckBoxSelectionMenuButton(Relation relation) { + public CheckBoxSelectionMenuButton(IRelationship.Kind relation) { this(relation.toString()); this.addActionListener(new CheckBoxSelectionMenuActionListener(relation)); } @@ -228,21 +215,21 @@ public class BrowserStructureViewToolPanel extends JPanel { * Ewwwwww! */ private class CheckBoxSelectionMenuActionListener implements ActionListener { - private ProgramElementNode.Accessibility accessibility = null; - private ProgramElementNode.Kind kind = null; - private ProgramElementNode.Modifiers modifiers = null; + private IProgramElement.Accessibility accessibility = null; + private IProgramElement.Kind kind = null; + private IProgramElement.Modifiers modifiers = null; private StructureViewProperties.Sorting sorting = null; - private Relation relation = null; + private IRelationship.Kind relation = null; - public CheckBoxSelectionMenuActionListener(ProgramElementNode.Accessibility accessibility) { + public CheckBoxSelectionMenuActionListener(IProgramElement.Accessibility accessibility) { this.accessibility = accessibility; } - public CheckBoxSelectionMenuActionListener(ProgramElementNode.Kind kind) { + public CheckBoxSelectionMenuActionListener(IProgramElement.Kind kind) { this.kind = kind; } - public CheckBoxSelectionMenuActionListener(ProgramElementNode.Modifiers modifiers) { + public CheckBoxSelectionMenuActionListener(IProgramElement.Modifiers modifiers) { this.modifiers = modifiers; } @@ -250,8 +237,8 @@ public class BrowserStructureViewToolPanel extends JPanel { this.sorting = sorting; } - public CheckBoxSelectionMenuActionListener(Relation relation) { - this.relation = relation; + public CheckBoxSelectionMenuActionListener(IRelationship.Kind relationKind) { + this.relation = relationKind; } public void actionPerformed(ActionEvent e) { diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BrowserView.java b/ajde/src/org/aspectj/ajde/ui/swing/BrowserView.java index aa1ed12d3..acabee500 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BrowserView.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BrowserView.java @@ -37,7 +37,7 @@ import javax.swing.ListCellRenderer; import javax.swing.border.Border; import org.aspectj.ajde.Ajde; -import org.aspectj.asm.ProgramElementNode; +import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten @@ -215,7 +215,7 @@ class BrowserView extends JPanel { joinpointProbe_button_actionPerformed(e); } }); - joinpointProbe_button.setIcon(icons.getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT)); + joinpointProbe_button.setIcon(icons.getStructureSwingIcon(IProgramElement.Kind.POINTCUT)); joinpointProbe_button.setToolTipText("Create joinpoint probe"); joinpointProbe_button.setPreferredSize(new Dimension(20, 20)); joinpointProbe_button.setMinimumSize(new Dimension(20, 20)); diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java b/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java index 2e21a3631..7763573d2 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java @@ -35,7 +35,7 @@ public class BrowserViewManager { private Stack backHistory = new Stack(); private Stack forwardHistory = new Stack(); - private ProgramElementNode currNode = null; + private IProgramElement currNode = null; private final GlobalStructureView DECLARATION_VIEW; private final GlobalStructureView CROSSCUTTING_VIEW; @@ -68,17 +68,19 @@ public class BrowserViewManager { CROSSCUTTING_VIEW_PROPERTIES = new GlobalViewProperties(StructureViewProperties.Hierarchy.CROSSCUTTING); INHERITANCE_VIEW_PROPERTIES = new GlobalViewProperties(StructureViewProperties.Hierarchy.INHERITANCE); - CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.METHOD_RELATION); - CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.METHOD_CALL_SITE_RELATION); - CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.CONSTRUCTOR_RELATION); - CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION); - CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.HANDLER_RELATION); - CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.INITIALIZER_RELATION); - CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.FIELD_ACCESS_RELATION); - - INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.IMPLEMENTS_RELATION); - INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.INHERITS_MEMBERS_RELATION); - INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.INHERITS_RELATION); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(IRelationship.Kind.ADVICE); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(IRelationship.Kind.ADVICE); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(IRelationship.Kind.ADVICE); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.METHOD_CALL_SITE_RELATION); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.CONSTRUCTOR_RELATION); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.HANDLER_RELATION); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.INITIALIZER_RELATION); +// CROSSCUTTING_VIEW_PROPERTIES.addRelation(AdviceAssociation.FIELD_ACCESS_RELATION); +// +// INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.IMPLEMENTS_RELATION); +// INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.INHERITS_MEMBERS_RELATION); +// INHERITANCE_VIEW_PROPERTIES.addRelation(InheritanceAssociation.INHERITS_RELATION); DECLARATION_VIEW_PROPERTIES.setRelations(Ajde.getDefault().getStructureViewManager().getAvailableRelations()); diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java b/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java index 814d48e04..9dfd6bb50 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java @@ -14,23 +14,14 @@ package org.aspectj.ajde.ui.swing; -import java.awt.event.ActionEvent; -import java.awt.event.InputEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.AbstractAction; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; +import java.awt.event.*; +import java.util.*; + +import javax.swing.*; +import javax.swing.event.*; import javax.swing.tree.TreePath; -import org.aspectj.asm.LinkNode; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.StructureNode; +import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten @@ -61,20 +52,21 @@ class BrowserViewTreeListener implements TreeSelectionListener, MouseListener { public void singleClickNavigation(MouseEvent e) { SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent(); if (treeNode != null && !e.isControlDown() && !e.isShiftDown() && e.getModifiers() != 4) { - StructureNode currNode = (StructureNode)treeNode.getUserObject(); - if (currNode instanceof ProgramElementNode && !e.isControlDown() + IProgramElement currNode = (IProgramElement)treeNode.getUserObject(); + if (currNode instanceof IProgramElement && !e.isControlDown() && !e.isShiftDown() && e.getModifiers() != 4) { //AjdeUIManager.getDefault().getViewManager().showNodeInMasterView((ProgramElementNode)currNode); //if (AjdeUIManager.getDefault().getViewManager().isSplitViewMode()) { // AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView((ProgramElementNode)currNode); //} - } else if (currNode instanceof LinkNode) { + } +// else if (currNode instanceof LinkNode) { //if (!AjdeUIManager.getDefault().getViewManager().isSplitViewMode()) { // AjdeUIManager.getDefault().getViewManager().showNodeInMasterView((LinkNode)currNode); //} else { // AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView(((LinkNode)currNode).getProgramElementNode()); //} - } +// } } } @@ -82,18 +74,19 @@ class BrowserViewTreeListener implements TreeSelectionListener, MouseListener { int clickCount = e.getClickCount(); SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent(); if (treeNode != null) { - StructureNode currNode = (StructureNode)treeNode.getUserObject(); - if (currNode instanceof ProgramElementNode && !e.isControlDown() && !e.isShiftDown() + IProgramElement currNode = (IProgramElement)treeNode.getUserObject(); + if (currNode instanceof IProgramElement && !e.isControlDown() && !e.isShiftDown() && e.getModifiers() != 4) { //AjdeUIManager.getDefault().getViewManager().showNodeInMasterView(((LinkNode)currNode).getProgramElementNode()); //AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView(((LinkNode)currNode).getProgramElementNode()); - } else if (currNode instanceof LinkNode) { - if (clickCount == 1) { - //AjdeUIManager.getDefault().getViewManager().showLink((LinkNode)currNode); - } else if (clickCount == 2) { - //navigationAction((ProgramElementNode)((LinkNode)currNode).getProgramElementNode(), true, true); - } - } + } +// else if (currNode instanceof LinkNode) { +// if (clickCount == 1) { +// //AjdeUIManager.getDefault().getViewManager().showLink((LinkNode)currNode); +// } else if (clickCount == 2) { +// //navigationAction((ProgramElementNode)((LinkNode)currNode).getProgramElementNode(), true, true); +// } +// } } } @@ -107,14 +100,14 @@ class BrowserViewTreeListener implements TreeSelectionListener, MouseListener { TreePath[] selectionPaths = tree.getSelectionPaths(); final List signatures = new ArrayList(); for (int i = 0; i < selectionPaths.length; i++) { - StructureNode currNode = (StructureNode)((SwingTreeViewNode)selectionPaths[i].getLastPathComponent()).getUserObject(); - if (currNode instanceof LinkNode || currNode instanceof ProgramElementNode) { - signatures.add(currNode); - } + IProgramElement currNode = (IProgramElement)((SwingTreeViewNode)selectionPaths[i].getLastPathComponent()).getUserObject(); +// if (currNode instanceof LinkNode || currNode instanceof IProgramElement) { +// signatures.add(currNode); +// } } JPopupMenu popup = new JPopupMenu(); - JMenuItem showSourcesItem = new JMenuItem("Display sources", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.CODE)); + JMenuItem showSourcesItem = new JMenuItem("Display sources", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.CODE)); showSourcesItem.setFont(new java.awt.Font("Dialog", 0, 11)); showSourcesItem.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { @@ -123,11 +116,11 @@ class BrowserViewTreeListener implements TreeSelectionListener, MouseListener { // public void showSourcesNodes(java.util.List nodes) { // for (Iterator it = nodes.iterator(); it.hasNext(); ) { // ProgramElementNode currNode = null; -// StructureNode structureNode = (StructureNode)it.next(); -// if (structureNode instanceof LinkNode) { -// currNode = ((LinkNode)structureNode).getProgramElementNode(); +// IProgramElement IProgramElement = (IProgramElement)it.next(); +// if (IProgramElement instanceof LinkNode) { +// currNode = ((LinkNode)IProgramElement).getProgramElementNode(); // } else { -// currNode = (ProgramElementNode)structureNode; +// currNode = (ProgramElementNode)IProgramElement; // } // ISourceLocation sourceLoc = currNode.getSourceLocation(); // if (null != sourceLoc) { @@ -143,7 +136,7 @@ class BrowserViewTreeListener implements TreeSelectionListener, MouseListener { popup.add(showSourcesItem); popup.addSeparator(); - JMenuItem generatePCD = new JMenuItem("Pointcut Wizard (alpha)...", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT)); + JMenuItem generatePCD = new JMenuItem("Pointcut Wizard (alpha)...", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.POINTCUT)); generatePCD.setFont(new java.awt.Font("Dialog", 0, 11)); generatePCD.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent e) { diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java b/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java index 6ad79052a..ebb9319ef 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java @@ -24,7 +24,7 @@ import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import org.aspectj.ajde.Ajde; -import org.aspectj.asm.ProgramElementNode; +import org.aspectj.asm.IProgramElement; public class BuildConfigPopupMenu extends JPopupMenu { @@ -47,7 +47,7 @@ public class BuildConfigPopupMenu extends JPopupMenu { action.actionPerformed(e); } }); - buildItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(ProgramElementNode.Kind.FILE_LST).getIconResource()); + buildItem.setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(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 875ba9ed1..decccab65 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java @@ -14,13 +14,11 @@ package org.aspectj.ajde.ui.swing; -import javax.swing.Icon; -import javax.swing.ImageIcon; +import javax.swing.*; -import org.aspectj.ajde.ui.AbstractIcon; -import org.aspectj.ajde.ui.AbstractIconRegistry; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.Relation; +import org.aspectj.ajde.ui.*; +import org.aspectj.asm.*; +import org.aspectj.asm.IProgramElement; /** * Default icons. Override behavior for custom icons. @@ -110,32 +108,32 @@ public class IconRegistry extends AbstractIconRegistry { public Icon getMergeStructureViewIcon() { return MERGE_STRUCTURE_VIEW; } public Icon getStructureViewIcon() { return STRUCTURE_VIEW; } - public Icon getAssociationSwingIcon(Relation relation) { + public Icon getAssociationSwingIcon(IRelationship.Kind relation) { return convertToSwingIcon(getRelationIcon(relation)); } - protected AbstractIcon getStructureIcon(ProgramElementNode.Kind kind, ProgramElementNode.Accessibility accessibility) { + protected AbstractIcon getStructureIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) { return getStructureIcon(kind); } - public Icon getStructureSwingIcon(ProgramElementNode.Kind kind, ProgramElementNode.Accessibility accessibility) { + public Icon getStructureSwingIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) { return convertToSwingIcon(getStructureIcon(kind, accessibility)); } - public Icon getStructureSwingIcon(ProgramElementNode.Kind kind) { + public Icon getStructureSwingIcon(IProgramElement.Kind kind) { return convertToSwingIcon(getStructureIcon(kind)); } - public Icon getAccessibilitySwingIcon(ProgramElementNode.Accessibility accessibility) { - if (accessibility == ProgramElementNode.Accessibility.PUBLIC) { + public Icon getAccessibilitySwingIcon(IProgramElement.Accessibility accessibility) { + if (accessibility == IProgramElement.Accessibility.PUBLIC) { return ACCESSIBILITY_PUBLIC; - } else if (accessibility == ProgramElementNode.Accessibility.PACKAGE) { + } else if (accessibility == IProgramElement.Accessibility.PACKAGE) { return ACCESSIBILITY_PACKAGE; - } else if (accessibility == ProgramElementNode.Accessibility.PROTECTED) { + } else if (accessibility == IProgramElement.Accessibility.PROTECTED) { return ACCESSIBILITY_PROTECTED; - } else if (accessibility == ProgramElementNode.Accessibility.PRIVATE) { + } else if (accessibility == IProgramElement.Accessibility.PRIVATE) { return ACCESSIBILITY_PRIVATE; - } else if (accessibility == ProgramElementNode.Accessibility.PRIVILEGED) { + } else if (accessibility == IProgramElement.Accessibility.PRIVILEGED) { return ACCESSIBILITY_PRIVILEGED; } else { return null; diff --git a/ajde/src/org/aspectj/ajde/ui/swing/PointcutWizard.java b/ajde/src/org/aspectj/ajde/ui/swing/PointcutWizard.java index 045f361a3..bfd469a6d 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/PointcutWizard.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/PointcutWizard.java @@ -21,7 +21,7 @@ import java.util.*; import javax.swing.*; import org.aspectj.ajde.ui.*; -import org.aspectj.asm.InheritanceAssociation; +import org.aspectj.asm.IRelationship; /** * @author Mik Kersten @@ -69,7 +69,7 @@ class PointcutWizard extends JFrame { private Map getViewProperties() { Map views = new HashMap(); GlobalViewProperties INHERITANCE_VIEW = new GlobalViewProperties(StructureViewProperties.Hierarchy.INHERITANCE); - INHERITANCE_VIEW.addRelation(InheritanceAssociation.INHERITS_RELATION); + INHERITANCE_VIEW.addRelation(IRelationship.Kind.INHERITANCE); views.put(INHERITANCE_VIEW.toString(), INHERITANCE_VIEW); return views; } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java index 4ec5e8ff0..afdf6ba52 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java @@ -32,9 +32,9 @@ import javax.swing.border.Border; import org.aspectj.ajde.Ajde; import org.aspectj.ajde.ui.StructureView; import org.aspectj.ajde.ui.StructureViewProperties; -import org.aspectj.asm.ProgramElementNode; +import org.aspectj.asm.IProgramElement; import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureModelListener; +import org.aspectj.asm.IStructureModelListener; public class SimpleStructureViewToolPanel extends JPanel { @@ -60,7 +60,7 @@ public class SimpleStructureViewToolPanel extends JPanel { BorderLayout borderLayout3 = new BorderLayout(); BorderLayout borderLayout4 = new BorderLayout(); - public final StructureModelListener MODEL_LISTENER = new StructureModelListener() { + public final IStructureModelListener MODEL_LISTENER = new IStructureModelListener() { public void modelUpdated(StructureModel model) { String path = Ajde.getDefault().getConfigurationManager().getActiveConfigFile(); String fileName = "<no active config>"; @@ -218,7 +218,7 @@ public class SimpleStructureViewToolPanel extends JPanel { hideNonAJ_button.setBorder(AjdeWidgetStyles.LOWERED_BEVEL_BORDER); hideNonAJEnabled = true; currentView.getViewProperties().setFilteredMemberKinds( - ProgramElementNode.Kind.getNonAJMemberKinds() + IProgramElement.Kind.getNonAJMemberKinds() ); } Ajde.getDefault().getStructureViewManager().refreshView(currentView); diff --git a/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java b/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java index 1ab612a80..29871bf8d 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java @@ -19,21 +19,11 @@ import java.util.ArrayList; import javax.swing.SwingUtilities; import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeModel; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; +import javax.swing.tree.*; import org.aspectj.ajde.Ajde; -import org.aspectj.ajde.ui.AbstractIcon; -import org.aspectj.ajde.ui.GlobalStructureView; -import org.aspectj.ajde.ui.StructureView; -import org.aspectj.ajde.ui.StructureViewProperties; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.RelationNode; -import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureNode; +import org.aspectj.ajde.ui.*; +import org.aspectj.asm.*; /** * @author Mik Kersten @@ -64,24 +54,24 @@ class StructureTreeManager { structureTree.addMouseListener((MouseListener)treeListener); } - public void highlightNode(ProgramElementNode node) { + public void highlightNode(IProgramElement node) { highlightNode((SwingTreeViewNode)structureTree.getModel().getRoot(), node); } - public StructureNode getSelectedStructureNode() { - return (StructureNode)((SwingTreeViewNode)structureTree.getLastSelectedPathComponent()).getUserObject(); + public IProgramElement getSelectedIProgramElement() { + return (IProgramElement)((SwingTreeViewNode)structureTree.getLastSelectedPathComponent()).getUserObject(); } public void scrollToHighlightedNode() { structureTree.scrollPathToVisible(structureTree.getSelectionPath()); } - private void highlightNode(SwingTreeViewNode parent, ProgramElementNode node) { + private void highlightNode(SwingTreeViewNode parent, IProgramElement node) { for (int i = 0; i < parent.getChildCount(); i++) { SwingTreeViewNode currNode = (SwingTreeViewNode)parent.getChildAt(i); - StructureNode sNode = (StructureNode)currNode.getUserObject(); - if (sNode instanceof ProgramElementNode && - ((ProgramElementNode)sNode).equals(node)) { + IProgramElement sNode = (IProgramElement)currNode.getUserObject(); + if (sNode instanceof IProgramElement && + ((IProgramElement)sNode).equals(node)) { TreePath path = new TreePath(currNode.getPath()); structureTree.setSelectionPath(path); int currRow = structureTree.getRowForPath(path); @@ -146,11 +136,11 @@ class StructureTreeManager { for (int i = 0; i < structureTree.getRowCount(); i++) { TreePath path = structureTree.getPathForRow(i); SwingTreeViewNode node = (SwingTreeViewNode)path.getLastPathComponent(); - if (node.getUserObject() instanceof ProgramElementNode) { - ProgramElementNode pNode = (ProgramElementNode)node.getUserObject(); - ProgramElementNode.Kind kind = pNode.getProgramElementKind(); - if (kind == ProgramElementNode.Kind.PROJECT - || kind == ProgramElementNode.Kind.PACKAGE) { + if (node.getUserObject() instanceof IProgramElement) { + IProgramElement pNode = (IProgramElement)node.getUserObject(); + IProgramElement.Kind kind = pNode.getKind(); + if (kind == IProgramElement.Kind.PROJECT + || kind == IProgramElement.Kind.PACKAGE) { structureTree.expandPath(path); } else { structureTree.collapsePath(path); @@ -166,7 +156,7 @@ class StructureTreeManager { for (int i = 0; i < structureTree.getRowCount(); i++) { TreePath path = structureTree.getPathForRow(i); SwingTreeViewNode node = (SwingTreeViewNode)path.getLastPathComponent(); - if (path.getPath().length-1 > depth || node.getUserObject() instanceof RelationNode) { + if (path.getPath().length-1 > depth || node.getUserObject() instanceof IRelationship) { structureTree.collapsePath(path); } else { structureTree.expandPath(path); @@ -371,7 +361,7 @@ class StructureTreeManager { // } // public ProgramElementNode getRootProgramElementNode() { -// StructureNode node = (StructureNode)((SwingTreeViewNode)structureTree.getModel().getRoot()).getUserObject(); +// IProgramElement node = (IProgramElement)((SwingTreeViewNode)structureTree.getModel().getRoot()).getUserObject(); // if (node instanceof ProgramElementNode) { // return (ProgramElementNode)node; // } else { @@ -383,7 +373,7 @@ class StructureTreeManager { // * @todo HACK: this is a workaround and can break // */ // private static ProgramElementNode mapResult = null; -// private ProgramElementNode getNodeForLink(LinkNode node, StructureNode rootNode) { +// private ProgramElementNode getNodeForLink(LinkNode node, IProgramElement rootNode) { // ProgramElementNode result = null; // if (rootNode instanceof ProgramElementNode && // ((ProgramElementNode)rootNode).getName().equals(node.getProgramElementNode().getName())) { @@ -391,7 +381,7 @@ class StructureTreeManager { // } else { // ProgramElementNode linkedNode = node.getProgramElementNode(); // for (Iterator it = rootNode.getChildren().iterator(); it.hasNext(); ) { -// StructureNode child = (StructureNode)it.next(); +// IProgramElement child = (IProgramElement)it.next(); // getNodeForLink(node, child); // } // } @@ -400,14 +390,14 @@ class StructureTreeManager { // private void sortNodes(List nodes) { // if (sortNodes) { -// Collections.sort(nodes, structureNodeComparator); +// Collections.sort(nodes, IProgramElementComparator); // } // } -// private class StructureNodeComparator implements Comparator { +// private class IProgramElementComparator implements Comparator { // public int compare(Object o1, Object o2) { -// StructureNode t1 = (StructureNode) ((SwingTreeViewNode) o1).getUserObject(); -// StructureNode t2 = (StructureNode) ((SwingTreeViewNode) o2).getUserObject(); +// IProgramElement t1 = (IProgramElement) ((SwingTreeViewNode) o1).getUserObject(); +// IProgramElement t2 = (IProgramElement) ((SwingTreeViewNode) o2).getUserObject(); // if (t1 instanceof ProgramElementNode && t2 instanceof ProgramElementNode) { // ProgramElementNode p1 = (ProgramElementNode) t1; // ProgramElementNode p2 = (ProgramElementNode) t2; diff --git a/ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java index 89ece89e3..ed93d0706 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java @@ -14,23 +14,15 @@ package org.aspectj.ajde.ui.swing; -import java.awt.BorderLayout; -import java.awt.Color; +import java.awt.*; import java.util.Iterator; -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.border.BevelBorder; -import javax.swing.border.Border; +import javax.swing.*; +import javax.swing.border.*; import org.aspectj.ajde.Ajde; -import org.aspectj.ajde.ui.FileStructureView; -import org.aspectj.ajde.ui.StructureView; -import org.aspectj.ajde.ui.StructureViewNode; -import org.aspectj.ajde.ui.StructureViewRenderer; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.StructureNode; +import org.aspectj.ajde.ui.*; +import org.aspectj.asm.IProgramElement; /** * Represents the configuration of a structure view of the system, rendered @@ -98,8 +90,8 @@ public class StructureViewPanel extends JPanel implements StructureViewRenderer public void setActiveNode(StructureViewNode node, int lineOffset) { if (node == null) return; - if (!(node.getStructureNode() instanceof ProgramElementNode)) return; - ProgramElementNode pNode = (ProgramElementNode)node.getStructureNode(); + if (!(node.getStructureNode() instanceof IProgramElement)) return; + IProgramElement pNode = (IProgramElement)node.getStructureNode(); treeManager.highlightNode(pNode); if (pNode.getSourceLocation() != null) { Ajde.getDefault().getEditorAdapter().showSourceLine( @@ -112,9 +104,9 @@ public class StructureViewPanel extends JPanel implements StructureViewRenderer public void highlightActiveNode() { if (currentView.getActiveNode() == null) return; - StructureNode node = currentView.getActiveNode().getStructureNode(); - if (node instanceof ProgramElementNode) { - treeManager.highlightNode((ProgramElementNode)node); + IProgramElement node = currentView.getActiveNode().getStructureNode(); + if (node instanceof IProgramElement) { + treeManager.highlightNode((IProgramElement)node); } } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java index 75810c575..e1ca0bd75 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java @@ -14,27 +14,24 @@ package org.aspectj.ajde.ui.swing; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import java.util.*; import javax.swing.tree.DefaultMutableTreeNode; -import org.aspectj.ajde.ui.AbstractIcon; -import org.aspectj.ajde.ui.StructureViewNode; -import org.aspectj.asm.StructureNode; +import org.aspectj.ajde.ui.*; +import org.aspectj.asm.*; /** * @author Mik Kersten */ public class SwingTreeViewNode extends DefaultMutableTreeNode implements StructureViewNode { - private StructureNode structureNode; + private IProgramElement programElement; private AbstractIcon icon; - public SwingTreeViewNode(StructureNode structureNode, AbstractIcon icon, List children) { - super(structureNode, true); - this.structureNode = structureNode; + public SwingTreeViewNode(IProgramElement programElement, AbstractIcon icon, List children) { + super(programElement, true); + this.programElement = programElement; this.icon = icon; if (children != null) { @@ -43,9 +40,22 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements Structu } } } + + 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()); +// } +// } + } - public StructureNode getStructureNode() { - return structureNode; + public IProgramElement getStructureNode() { + return programElement; } public AbstractIcon getIcon() { diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java index 440e2341f..9c45432d2 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java @@ -16,10 +16,9 @@ package org.aspectj.ajde.ui.swing; import java.util.List; -import org.aspectj.ajde.ui.AbstractIcon; -import org.aspectj.ajde.ui.StructureViewNode; -import org.aspectj.ajde.ui.StructureViewNodeFactory; -import org.aspectj.asm.StructureNode; +import org.aspectj.ajde.ui.*; +import org.aspectj.asm.*; +import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten @@ -30,7 +29,14 @@ public class SwingTreeViewNodeFactory extends StructureViewNodeFactory { super(iconRegistry); } - protected StructureViewNode createConcreteNode(StructureNode node, AbstractIcon icon, List children) { + protected StructureViewNode createConcreteNode(IProgramElement node, AbstractIcon icon, List children) { return new SwingTreeViewNode(node, icon, children); } + + protected StructureViewNode createConcreteNode( + 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 a2ba8a601..019c96361 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java @@ -14,20 +14,13 @@ package org.aspectj.ajde.ui.swing; -import java.awt.Color; -import java.awt.Component; -import java.awt.Font; +import java.awt.*; -import javax.swing.Icon; -import javax.swing.JTree; +import javax.swing.*; import javax.swing.tree.DefaultTreeCellRenderer; -import org.aspectj.asm.LinkNode; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.RelationNode; -import org.aspectj.asm.StructureNode; -import org.aspectj.bridge.IMessage; -import org.aspectj.bridge.ISourceLocation; +import org.aspectj.asm.*; +import org.aspectj.bridge.*; /** * @author Mik Kersten @@ -43,19 +36,19 @@ class SwingTreeViewNodeRenderer extends DefaultTreeCellRenderer { boolean hasFocus) { if (treeNode == null) return null; SwingTreeViewNode viewNode = (SwingTreeViewNode)treeNode; - StructureNode node = viewNode.getStructureNode(); + 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 { +// 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); @@ -66,29 +59,30 @@ class SwingTreeViewNodeRenderer extends DefaultTreeCellRenderer { setIcon(null); } - if (node instanceof ProgramElementNode) { - ProgramElementNode pNode = (ProgramElementNode)node; - if (pNode.isRunnable()) { - //setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon()); - } - if (pNode.isImplementor()) { - //this.setText("<implementor>"); - } - if (pNode.isOverrider()) { - //this.setText("<overrider>"); - } - } else if (node instanceof RelationNode) { - this.setFont(new Font(this.getFont().getName(), Font.ITALIC, this.getFont().getSize())); - } + if (node instanceof IProgramElement) { + IProgramElement pNode = (IProgramElement)node; +// if (pNode.isRunnable()) { +// //setIcon(AjdeUIManager.getDefault().getIconRegistry().getExecuteIcon()); +// } +// if (pNode.isImplementor()) { +// //this.setText("<implementor>"); +// } +// if (pNode.isOverrider()) { +// //this.setText("<overrider>"); +// } + + if (node.getMessage() != null) { + if (node.getMessage().getKind().equals(IMessage.WARNING)) { + setIcon(AjdeUIManager.getDefault().getIconRegistry().getWarningIcon()); + } else if (node.getMessage().getKind().equals(IMessage.ERROR)) { + setIcon(AjdeUIManager.getDefault().getIconRegistry().getErrorIcon()); + } else { + setIcon(AjdeUIManager.getDefault().getIconRegistry().getInfoIcon()); + } + } - if (node.getMessage() != null) { - if (node.getMessage().getKind().equals(IMessage.WARNING)) { - setIcon(AjdeUIManager.getDefault().getIconRegistry().getWarningIcon()); - } else if (node.getMessage().getKind().equals(IMessage.ERROR)) { - setIcon(AjdeUIManager.getDefault().getIconRegistry().getErrorIcon()); - } else { - setIcon(AjdeUIManager.getDefault().getIconRegistry().getInfoIcon()); - } + } 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 0b0eb19db..13b65d4b0 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java @@ -46,7 +46,7 @@ import org.aspectj.ajde.ui.BuildConfigEditor; import org.aspectj.ajde.ui.BuildConfigModel; import org.aspectj.ajde.ui.BuildConfigNode; import org.aspectj.ajde.ui.InvalidResourceException; -import org.aspectj.asm.ProgramElementNode; +import org.aspectj.asm.IProgramElement; /** * UI for editing build configuration (".lst") files via a graphical tree-based * representation. @@ -246,15 +246,15 @@ public class TreeViewBuildConfigEditor extends JPanel implements BuildConfigEdit //} BuildConfigNode.Kind kind = ctn.getModelNode().getBuildConfigNodeKind(); if (kind.equals(BuildConfigNode.Kind.FILE_ASPECTJ)) { - setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_ASPECTJ)); + setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.FILE_ASPECTJ)); } else if (kind.equals(BuildConfigNode.Kind.FILE_JAVA)) { - setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_JAVA)); + setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.FILE_JAVA)); } else if (kind.equals(BuildConfigNode.Kind.FILE_LST)) { - setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_LST)); + setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.FILE_LST)); } else if (kind.equals(BuildConfigNode.Kind.DIRECTORY)) { - setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.PACKAGE)); + setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.PACKAGE)); } else { - setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(ProgramElementNode.Kind.ERROR).getIconResource()); + setIcon((Icon)AjdeUIManager.getDefault().getIconRegistry().getStructureIcon(IProgramElement.Kind.ERROR).getIconResource()); p.remove(cbox); } diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java index e1e53be97..2ba60fbf0 100644 --- a/ajde/testdata/examples/coverage/ModelCoverage.java +++ b/ajde/testdata/examples/coverage/ModelCoverage.java @@ -65,7 +65,7 @@ aspect AdviceNamingCoverage { int around(int i) throws SizeException: namedWithOneArg(i) { return proceed(i); } before(): named() { } - before(int i): call(* XXX.mumble()) && named() && namedWithOneArg(i) { } + before(int i): call(* *.mumble()) && named() && namedWithOneArg(i) { } before(int i): named() && call(* *.mumble()) && namedWithOneArg(i) { } before(): call(* *.mumble()) { } diff --git a/ajde/testdata/examples/coverage/coverage.lst b/ajde/testdata/examples/coverage/coverage.lst index fae756a9c..9857809b9 100644 --- a/ajde/testdata/examples/coverage/coverage.lst +++ b/ajde/testdata/examples/coverage/coverage.lst @@ -1 +1,2 @@ -ModelCoverage.java +ModelCoverage.java +pkg/InPackage.java diff --git a/ajde/testdata/examples/coverage/pkg/InPackage.java b/ajde/testdata/examples/coverage/pkg/InPackage.java new file mode 100644 index 000000000..3e3bc8aa4 --- /dev/null +++ b/ajde/testdata/examples/coverage/pkg/InPackage.java @@ -0,0 +1,4 @@ + +package pkg; + +public interface InPackage { } \ No newline at end of file diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java index f5fa1fc98..e6be0bc12 100644 --- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -28,6 +28,7 @@ public class AjdeTests extends TestCase { suite.addTestSuite(VersionTest.class); suite.addTestSuite(CompilerMessagesTest.class); suite.addTestSuite(AsmDeclarationsTest.class); + suite.addTestSuite(AsmRelationshipsTest.class); suite.addTestSuite(ResourceCopyTestCase.class); //$JUnit-END$ diff --git a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java index 81f054f6b..ea4b060bc 100644 --- a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java +++ b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java @@ -1,4 +1,3 @@ - /* ******************************************************************* * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). * All rights reserved. @@ -15,10 +14,10 @@ import java.util.Iterator; import org.aspectj.ajdt.internal.core.builder.AsmNodeFormatter; import org.aspectj.asm.*; -import org.aspectj.asm.ProgramElementNode.Kind; +import org.aspectj.asm.IProgramElement.Kind; -// TODO: check for return types +// TODO: add tests for java kinds public class AsmDeclarationsTest extends AjdeTestCase { private StructureModel model = null; @@ -26,66 +25,81 @@ public class AsmDeclarationsTest extends AjdeTestCase { private static final int DEC_MESSAGE_LENGTH = AsmNodeFormatter.MAX_MESSAGE_LENGTH; public AsmDeclarationsTest(String name) { - super(name); + super(name); + } + + public void testRoot() { + IProgramElement root = (IProgramElement)model.getRoot(); + assertNotNull(root); + assertEquals(root.getName(), "coverage.lst"); } + + public void testFileInPackageAndDefaultPackage() { + IProgramElement root = model.getRoot(); + assertEquals(root.getName(), "coverage.lst"); + IProgramElement pkg = (IProgramElement)root.getChildren().get(1); + assertEquals(pkg.getName(), "pkg"); + assertEquals(((IProgramElement)pkg.getChildren().get(0)).getName(), "InPackage.java"); + assertEquals(((IProgramElement)root.getChildren().get(0)).getName(), "ModelCoverage.java"); + } public void testDeclares() { - ProgramElementNode node = (ProgramElementNode)model.getRoot(); + IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage"); + IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage"); assertNotNull(aspect); String decErrMessage = "declare error: \"Illegal construct..\""; - ProgramElementNode decErrNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_ERROR, decErrMessage); + IProgramElement decErrNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_ERROR, decErrMessage); assertNotNull(decErrNode); assertEquals(decErrNode.getName(), decErrMessage); String decWarnMessage = "declare warning: \"Illegal construct..\""; - ProgramElementNode decWarnNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_WARNING, decWarnMessage); + IProgramElement decWarnNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_WARNING, decWarnMessage); assertNotNull(decWarnNode); assertEquals(decWarnNode.getName(), decWarnMessage); String decParentsMessage = "declare parents: Point"; - ProgramElementNode decParentsNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsMessage); + IProgramElement decParentsNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsMessage); assertNotNull(decParentsNode); assertEquals(decParentsNode.getName(), decParentsMessage); String decParentsPtnMessage = "declare parents: Point+"; - ProgramElementNode decParentsPtnNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsPtnMessage); + IProgramElement decParentsPtnNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsPtnMessage); assertNotNull(decParentsPtnNode); assertEquals(decParentsPtnNode.getName(), decParentsPtnMessage); String decParentsTPMessage = "declare parents: <type pattern>"; - ProgramElementNode decParentsTPNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PARENTS, decParentsTPMessage); + IProgramElement decParentsTPNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsTPMessage); assertNotNull(decParentsTPNode); assertEquals(decParentsTPNode.getName(), decParentsTPMessage); String decSoftMessage = "declare soft: SizeException"; - ProgramElementNode decSoftNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_SOFT, decSoftMessage); + IProgramElement decSoftNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_SOFT, decSoftMessage); assertNotNull(decSoftNode); assertEquals(decSoftNode.getName(), decSoftMessage); String decPrecMessage = "declare precedence: AdviceCoverage, InterTypeDecCoverage, <type pattern>"; - ProgramElementNode decPrecNode = model.findNode(aspect, ProgramElementNode.Kind.DECLARE_PRECEDENCE, decPrecMessage); + IProgramElement decPrecNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PRECEDENCE, decPrecMessage); assertNotNull(decPrecNode); assertEquals(decPrecNode.getName(), decPrecMessage); } public void testInterTypeMemberDeclares() { - ProgramElementNode node = (ProgramElementNode)model.getRoot(); + IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage"); + IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "InterTypeDecCoverage"); assertNotNull(aspect); String fieldMsg = "Point.xxx"; - ProgramElementNode fieldNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_FIELD, fieldMsg); + IProgramElement fieldNode = model.findNode(aspect, IProgramElement.Kind.INTER_TYPE_FIELD, fieldMsg); assertNotNull(fieldNode); assertEquals(fieldNode.getName(), fieldMsg); String methodMsg = "Point.check(int, Line)"; - ProgramElementNode methodNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_METHOD, methodMsg); + IProgramElement methodNode = model.findNode(aspect, IProgramElement.Kind.INTER_TYPE_METHOD, methodMsg); assertNotNull(methodNode); assertEquals(methodNode.getName(), methodMsg); @@ -97,19 +111,19 @@ public class AsmDeclarationsTest extends AjdeTestCase { } public void testPointcuts() { - ProgramElementNode node = (ProgramElementNode)model.getRoot(); + IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage"); + IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage"); assertNotNull(aspect); String ptct = "named()"; - ProgramElementNode ptctNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, ptct); + IProgramElement ptctNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, ptct); assertNotNull(ptctNode); assertEquals(ptctNode.getName(), ptct); String params = "namedWithArgs(int, int)"; - ProgramElementNode paramsNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, params); + IProgramElement paramsNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, params); assertNotNull(paramsNode); assertEquals(paramsNode.getName(), params); @@ -117,57 +131,57 @@ public class AsmDeclarationsTest extends AjdeTestCase { } public void testAbstract() { - ProgramElementNode node = (ProgramElementNode)model.getRoot(); + IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AbstractAspect"); + IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AbstractAspect"); assertNotNull(aspect); String abst = "abPtct()"; - ProgramElementNode abstNode = model.findNode(aspect, ProgramElementNode.Kind.POINTCUT, abst); + IProgramElement abstNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, abst); assertNotNull(abstNode); assertEquals(abstNode.getName(), abst); } public void testAdvice() { - ProgramElementNode node = (ProgramElementNode)model.getRoot(); + IProgramElement node = (IProgramElement)model.getRoot(); assertNotNull(node); - ProgramElementNode aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage"); + IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage"); assertNotNull(aspect); String anon = "before(): <anonymous pointcut>"; - ProgramElementNode anonNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, anon); + IProgramElement anonNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, anon); assertNotNull(anonNode); assertEquals(anonNode.getName(), anon); String named = "before(): named.."; - ProgramElementNode namedNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, named); + IProgramElement namedNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, named); assertNotNull(namedNode); assertEquals(namedNode.getName(), named); String namedWithOneArg = "around(int): namedWithOneArg.."; - ProgramElementNode namedWithOneArgNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, namedWithOneArg); + IProgramElement namedWithOneArgNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, namedWithOneArg); assertNotNull(namedWithOneArgNode); assertEquals(namedWithOneArgNode.getName(), namedWithOneArg); String afterReturning = "afterReturning(int, int): namedWithArgs.."; - ProgramElementNode afterReturningNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, afterReturning); + IProgramElement afterReturningNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, afterReturning); assertNotNull(afterReturningNode); assertEquals(afterReturningNode.getName(), afterReturning); String around = "around(int): namedWithOneArg.."; - ProgramElementNode aroundNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, around); + IProgramElement aroundNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, around); assertNotNull(aroundNode); assertEquals(aroundNode.getName(), around); String compAnon = "before(int): <anonymous pointcut>.."; - ProgramElementNode compAnonNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, compAnon); + IProgramElement compAnonNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, compAnon); assertNotNull(compAnonNode); assertEquals(compAnonNode.getName(), compAnon); String compNamed = "before(int): named().."; - ProgramElementNode compNamedNode = model.findNode(aspect, ProgramElementNode.Kind.ADVICE, compNamed); + IProgramElement compNamedNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, compNamed); assertNotNull(compNamedNode); assertEquals(compNamedNode.getName(), compNamed); } diff --git a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java new file mode 100644 index 000000000..6dd2a8ea7 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java @@ -0,0 +1,64 @@ + +/* ******************************************************************* + * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * ******************************************************************/ + +package org.aspectj.ajde; + +import java.util.Iterator; + +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 static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst"; + + public AsmRelationshipsTest(String name) { + super(name); + } + + public void testPointcuts() { + IProgramElement node = (IProgramElement)model.getRoot(); + assertNotNull(node); + + System.err.println("> root: " + node); + +// +// IProgramElement aspect = StructureModelManager.getDefault().getStructureModel().findNodeForClass(null, "AdviceNamingCoverage"); +// assertNotNull(aspect); + +// fail(); + +// String ptct = "named()"; +// IProgramElement ptctNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, ptct); +// assertNotNull(ptctNode); +// assertEquals(ptctNode.getName(), ptct); +// +// String params = "namedWithArgs(int, int)"; +// IProgramElement paramsNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, params); +// assertNotNull(paramsNode); +// assertEquals(paramsNode.getName(), params); + } + + protected void setUp() throws Exception { + super.setUp("examples"); + assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH)); + model = StructureModelManager.getDefault().getStructureModel(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java b/ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java new file mode 100644 index 000000000..35a8e74d4 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java @@ -0,0 +1,29 @@ +/* ******************************************************************* + * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * ******************************************************************/ + +package org.aspectj.ajde; + +/** + * @author Mik Kersten + */ +public class NullIdeErrorHandler implements ErrorHandler { + + public void handleWarning(String message) { + System.out.println("NullIde warning: " + message); + } + + public void handleError(String message) { + System.out.println("NullIde error: " + message); + } + + public void handleError(String message, Throwable t) { + System.out.println("NullIde error: " + message); + t.printStackTrace(System.out); + } +} diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java index 06297be3f..61318014e 100644 --- a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java @@ -59,8 +59,9 @@ public class NullIdeManager { uiAdapter, new IconRegistry(), nullFrame, + new NullIdeProgressMonitor(), + new NullIdeErrorHandler(), true); - //Ajde.getDefault().enableLogging( System.out ); } catch (Throwable t) { t.printStackTrace(); diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java new file mode 100644 index 000000000..afd31cbeb --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java @@ -0,0 +1,45 @@ +/* ******************************************************************* + * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * ******************************************************************/ + +package org.aspectj.ajde; + +/** + * @author Mik Kersten + */ +public class NullIdeProgressMonitor implements BuildProgressMonitor { + + public void start(String configFile) { +// System.out.println("> compiling: " + configFile); + } + + public void setProgressText(String text) { + + } + + public void setProgressBarVal(int newVal) { + + } + + public void incrementProgressBarVal() { + + } + + public void setProgressBarMax(int maxVal) { + + } + + public int getProgressBarMax() { + return 0; + } + + public void finish() { + + } + +} diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java index 2b1275bb0..f290197e5 100644 --- a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java @@ -43,7 +43,7 @@ public class NullIdeTaskListManager implements TaskListManager { if (!hasWarning && IMessage.WARNING.isSameOrLessThan(message.getKind())) { hasWarning = true; } - System.out.println("> added sourceline task: " + message + ", file: " + message.getSourceLocation().getSourceFile().getAbsolutePath() + System.out.println("NullIde> task: " + message.getMessage() + ", file: " + message.getSourceLocation().getSourceFile().getAbsolutePath() + ": " + message.getSourceLocation().getLine()); } @@ -51,7 +51,7 @@ public class NullIdeTaskListManager implements TaskListManager { if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) { hasWarning = true; } - System.out.println("> added project task: " + message + ", kind: " + kind); + System.out.println("NullIde> task: " + message + ", kind: " + kind); } public boolean hasWarning() { diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java b/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java index 3289a4bde..e31d021a7 100644 --- a/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java +++ b/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java @@ -18,7 +18,7 @@ import org.aspectj.ajde.ui.*; public class NullIdeUIAdapter implements IdeUIAdapter { public void displayStatusInformation(String message) { - System.out.println("> NullIdeUIAdapter status : " + message); + System.out.println("NullIde> " + message); } public void resetGUI() { diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java index 8fb917802..8e0a5227e 100644 --- a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java @@ -18,8 +18,7 @@ import java.util.List; import junit.framework.TestSuite; -import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureNode; +import org.aspectj.asm.*; public class StructureModelRegressionTest extends AjdeTestCase { @@ -54,14 +53,14 @@ public class StructureModelRegressionTest extends AjdeTestCase { StructureModel savedModel = Ajde.getDefault().getStructureModelManager().getStructureModel(); //System.err.println( savedModel.getRoot().getClass() + ", " + savedModel.getRoot()); - // AMC This test will not pass as written until StructureNode defines - // equals. The equals loic is commented out in the StructureNode + // 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 - // consequences, so I've defined a structureNodesEqual( ) helper + // consequences, so I've defined a IProgramElementsEqual( ) helper // method here instead. - StructureNode rootNode = model.getRoot(); - StructureNode savedRootNode = savedModel.getRoot(); - return structureNodesEqual( rootNode, savedRootNode ); + IProgramElement rootNode = model.getRoot(); + IProgramElement savedRootNode = savedModel.getRoot(); + return IProgramElementsEqual( rootNode, savedRootNode ); } else { Ajde.getDefault().getStructureModelManager().writeStructureModel(lstFile); return true; @@ -69,7 +68,7 @@ public class StructureModelRegressionTest extends AjdeTestCase { //return true; } - private boolean structureNodesEqual( StructureNode s1, StructureNode s2 ) { + private boolean IProgramElementsEqual( IProgramElement s1, IProgramElement s2 ) { final boolean equal = true; if ( s1 == s2 ) return equal; if ( null == s1 || null == s2 ) return !equal; @@ -85,9 +84,9 @@ public class StructureModelRegressionTest extends AjdeTestCase { if (s1Kids == null || s2Kids == null) return !equal; if (s1Kids.size() != s2Kids.size() ) return !equal; for ( int k=0; k<s1Kids.size(); k++ ) { - StructureNode k1 = (StructureNode) s1Kids.get(k); - StructureNode k2 = (StructureNode) s2Kids.get(k); - if (!structureNodesEqual( k1, k2 )) return !equal; + IProgramElement k1 = (IProgramElement) s1Kids.get(k); + IProgramElement k2 = (IProgramElement) s2Kids.get(k); + if (!IProgramElementsEqual( k1, k2 )) return !equal; } } return equal; diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java index 9eec9987d..8dfc26c97 100644 --- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java @@ -13,16 +13,12 @@ package org.aspectj.ajde; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.util.Iterator; import junit.framework.TestSuite; -import org.aspectj.asm.ModelWalker; -import org.aspectj.asm.ProgramElementNode; -import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureNode; +import org.aspectj.asm.*; /** * @author Mik Kersten @@ -48,7 +44,7 @@ public class StructureModelTest extends AjdeTestCase { // XXX this should work // public void testFieldInitializerCorrespondence() throws IOException { // File testFile = createFile("testdata/examples/figures-coverage/figures/Figure.java"); -// StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( +// IProgramElement node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( // testFile.getCanonicalPath(), 28); // assertTrue("find result", node != null) ; // ProgramElementNode pNode = (ProgramElementNode)node; @@ -72,7 +68,7 @@ public class StructureModelTest extends AjdeTestCase { // assertTrue("find associated node", foundNode != null) ; // // File pointFile = createFile("testdata/examples/figures-coverage/figures/primitives/planar/Point.java"); -// StructureNode fieldNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( +// IProgramElement fieldNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( // pointFile.getCanonicalPath(), 12); // assertTrue("find result", fieldNode != null); // @@ -82,24 +78,24 @@ public class StructureModelTest extends AjdeTestCase { public void testRootForSourceFile() throws IOException { File testFile = openFile("figures-coverage/figures/Figure.java"); - StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile( + IProgramElement node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile( testFile.getCanonicalPath()); assertTrue("find result", node != null) ; - ProgramElementNode pNode = (ProgramElementNode)node; - String child = ((StructureNode)pNode.getChildren().get(0)).getName(); + IProgramElement pNode = (IProgramElement)node; + String child = ((IProgramElement)pNode.getChildren().get(0)).getName(); assertTrue("expected Figure got child " + child, child.equals("Figure")); } public void testPointcutName() throws IOException { File testFile = openFile("figures-coverage/figures/Main.java"); //System.err.println("PointcutName, testFile: " + testFile.getCanonicalPath() + " exists: " + testFile.exists()); - StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile( + IProgramElement node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile( testFile.getCanonicalPath()); //System.err.println(" node: " + node); assertTrue("find result", node != null) ; - ProgramElementNode pNode = (ProgramElementNode)((ProgramElementNode)node).getChildren().get(1); - ProgramElementNode pointcut = (ProgramElementNode)pNode.getChildren().get(0); - assertTrue("kind", pointcut.getProgramElementKind().equals(ProgramElementNode.Kind.POINTCUT)); + IProgramElement pNode = (IProgramElement)((IProgramElement)node).getChildren().get(1); + IProgramElement pointcut = (IProgramElement)pNode.getChildren().get(0); + assertTrue("kind", pointcut.getKind().equals(IProgramElement.Kind.POINTCUT)); assertTrue("found node: " + pointcut.getName(), pointcut.getName().equals("testptct()")); } @@ -111,13 +107,13 @@ 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()); - StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( + IProgramElement node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine( testFile.getCanonicalPath(), 1); //System.err.println(" node: " + node); assertTrue("find result", node != null) ; assertEquals("find result has children", 2, node.getChildren().size()) ; - ProgramElementNode pNode = (ProgramElementNode)node; - assertTrue("found node: " + pNode.getName(), pNode.getProgramElementKind().equals(ProgramElementNode.Kind.FILE_JAVA)); + IProgramElement pNode = (IProgramElement)node; + assertTrue("found node: " + pNode.getName(), pNode.getKind().equals(IProgramElement.Kind.FILE_JAVA)); } /** @@ -128,11 +124,11 @@ public class StructureModelTest extends AjdeTestCase { assertTrue("model exists", model != null); assertTrue("root exists", model.getRoot() != null); File testFile = openFile("figures-coverage/figures/Main.java"); - StructureNode node = model.findNodeForSourceLine(testFile.getCanonicalPath(), 11); + IProgramElement node = model.findNodeForSourceLine(testFile.getCanonicalPath(), 11); assertTrue("find result", node != null); - ProgramElementNode pNode = (ProgramElementNode)((ProgramElementNode)node).getParent(); + IProgramElement pNode = (IProgramElement)((IProgramElement)node).getParent(); if (null == pNode) { assertTrue("null parent of " + node, false); } @@ -143,7 +139,7 @@ public class StructureModelTest extends AjdeTestCase { * Integrity could be checked somewhere in the API. */ public void testModelIntegrity() { - StructureNode modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); + IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); assertTrue("root exists", modelRoot != null); try { @@ -153,9 +149,9 @@ public class StructureModelTest extends AjdeTestCase { } } - private void testModelIntegrityHelper(StructureNode node) throws Exception { + private void testModelIntegrityHelper(IProgramElement node) throws Exception { for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - StructureNode child = (StructureNode)it.next(); + IProgramElement child = (IProgramElement)it.next(); if (node == child.getParent()) { testModelIntegrityHelper(child); } else { @@ -165,8 +161,8 @@ public class StructureModelTest extends AjdeTestCase { } public void testNoChildIsNull() { - ModelWalker walker = new ModelWalker() { - public void preProcess(StructureNode node) { + HierarchyWalker walker = new HierarchyWalker() { + public void preProcess(IProgramElement node) { if (node.getChildren() == null) return; for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { if (it.next() == null) throw new NullPointerException("null child on node: " + node.getName()); diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java index 891852741..3f41e5e52 100644 --- a/ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java +++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java @@ -18,7 +18,7 @@ import java.util.*; import junit.framework.TestSuite; import org.aspectj.ajde.AjdeTestCase; -import org.aspectj.asm.ProgramElementNode; +import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten @@ -47,7 +47,7 @@ public class StructureModelUtilTest extends AjdeTestCase { assertTrue("packages list not empty", !packages.isEmpty()); // System.err.println("> packages: " + packages); - ProgramElementNode packageNode = (ProgramElementNode)((Object[])packages.get(0))[0]; + IProgramElement packageNode = (IProgramElement)((Object[])packages.get(0))[0]; assertTrue("package node not null", packageNode != null); // System.err.println("> package node: " + packageNode); @@ -55,15 +55,17 @@ public class StructureModelUtilTest extends AjdeTestCase { assertTrue("fle list not null", files != null); // System.err.println("> file list: " + files); - Map lineAdviceMap = StructureModelUtil.getLinesToAspectMap( - ((ProgramElementNode)files.get(0)).getSourceLocation().getSourceFile().getAbsolutePath() - ); - assertTrue("line->advice map not null", lineAdviceMap != null); - // System.err.println("> line->advice map: " + lineAdviceMap); - - Set aspects = StructureModelUtil.getAspectsAffectingPackage(packageNode); - assertTrue("aspect list not null", aspects != null); - // System.err.println("> aspects affecting package: " + aspects); + // TODO: re-enable +// Map lineAdviceMap = StructureModelUtil.getLinesToAspectMap( +// ((IProgramElement)files.get(0)).getSourceLocation().getSourceFile().getAbsolutePath() +// ); +// +// assertTrue("line->advice map not null", lineAdviceMap != null); +// // System.err.println("> line->advice map: " + lineAdviceMap); +// +// Set aspects = StructureModelUtil.getAspectsAffectingPackage(packageNode); +// assertTrue("aspect list not null", aspects != null); +// // System.err.println("> aspects affecting package: " + aspects); } diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java index 418a4743b..a27630d55 100644 --- a/ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java +++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java @@ -19,7 +19,7 @@ import junit.framework.TestSuite; import org.aspectj.ajde.Ajde; import org.aspectj.ajde.AjdeTestCase; -import org.aspectj.asm.ProgramElementNode; +import org.aspectj.asm.IProgramElement; /** * @author Mik Kersten @@ -54,7 +54,7 @@ public class StructureSearchManagerTest extends AjdeTestCase { public void testFindPatternAndKindMatch() { List matches = Ajde.getDefault().getStructureSearchManager().findMatches( "Point", - ProgramElementNode.Kind.CONSTRUCTOR + IProgramElement.Kind.CONSTRUCTOR ); System.err.println(matches); assertTrue("non existent node", true); diff --git a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java index 2e0e7da39..1bd8776ea 100644 --- a/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java +++ b/ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java @@ -20,8 +20,7 @@ import junit.framework.TestSuite; import org.aspectj.ajde.Ajde; import org.aspectj.ajde.AjdeTestCase; -import org.aspectj.asm.StructureModel; -import org.aspectj.asm.StructureNode; +import org.aspectj.asm.*; /** * @author Mik Kersten @@ -63,6 +62,7 @@ public class StructureViewManagerTest extends AjdeTestCase { renderer.setHasBeenNotified(false); Ajde.getDefault().getConfigurationManager().setActiveConfigFile("MumbleDoesNotExist.lst"); assertTrue("notified", renderer.getHasBeenNotified()); + assertTrue( "no structure", currentView.getRootNode().getStructureNode().getChildren().get(0) @@ -82,20 +82,20 @@ public class StructureViewManagerTest extends AjdeTestCase { Ajde.getDefault().getStructureModelManager().readStructureModel(CONFIG_FILE_PATH); assertTrue("notified", renderer.getHasBeenNotified()); - //System.err.println(">>>>>> " + currentView.getRootNode().getStructureNode()); + //System.err.println(">>>>>> " + currentView.getRootNode().getIProgramElement()); // AMC should this be currentView, or should we recreate the root... do the latter - //StructureNode n = currentView.getRootNode().getStructureNode(); - StructureNode n = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); + //IProgramElement n = currentView.getRootNode().getIProgramElement(); + IProgramElement n = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); assertTrue( "no structure", - //currentView.getRootNode().getStructureNode().getChildren().get(0) + //currentView.getRootNode().getIProgramElement().getChildren().get(0) n == StructureModel.NO_STRUCTURE ); } public void testModelIntegrity() { doSynchronousBuild(CONFIG_FILE_PATH); - StructureNode modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); + IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getStructureModel().getRoot(); assertTrue("root exists", modelRoot != null); try { @@ -105,9 +105,9 @@ public class StructureViewManagerTest extends AjdeTestCase { } } - private void testModelIntegrityHelper(StructureNode node) throws Exception { + private void testModelIntegrityHelper(IProgramElement node) throws Exception { for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) { - StructureNode child = (StructureNode)it.next(); + IProgramElement child = (IProgramElement)it.next(); if (node == child.getParent()) { testModelIntegrityHelper(child); } else { -- cgit v1.2.3