aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java2
-rw-r--r--ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java6
-rw-r--r--ajde/src/org/aspectj/ajde/internal/LstBuildConfigManager.java18
-rw-r--r--ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java70
-rw-r--r--ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java13
-rw-r--r--ajde/src/org/aspectj/ajde/ui/BuildConfigNode.java136
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java87
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java24
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureView.java8
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewManager.java79
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewNode.java4
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java48
-rw-r--r--ajde/src/org/aspectj/ajde/ui/StructureViewProperties.java26
-rw-r--r--ajde/src/org/aspectj/ajde/ui/internal/NavigationHistoryModel.java14
-rw-r--r--ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java348
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java28
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/BrowserStructureViewToolPanel.java57
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/BrowserView.java4
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java26
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java69
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/BuildConfigPopupMenu.java4
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/IconRegistry.java30
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/PointcutWizard.java4
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java8
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java56
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java28
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java34
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeFactory.java16
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java82
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java12
-rw-r--r--ajde/testdata/examples/coverage/ModelCoverage.java2
-rw-r--r--ajde/testdata/examples/coverage/coverage.lst3
-rw-r--r--ajde/testdata/examples/coverage/pkg/InPackage.java4
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTests.java1
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java80
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java64
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java29
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeManager.java3
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java45
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java4
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java2
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java23
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelTest.java46
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ui/StructureModelUtilTest.java24
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ui/StructureSearchManagerTest.java4
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ui/StructureViewManagerTest.java18
-rw-r--r--asm/src/org/aspectj/asm/AdviceAssociation.java191
-rw-r--r--asm/src/org/aspectj/asm/Association.java30
-rw-r--r--asm/src/org/aspectj/asm/HierarchyWalker.java (renamed from asm/src/org/aspectj/asm/ModelWalker.java)12
-rw-r--r--asm/src/org/aspectj/asm/IProgramElement.java218
-rw-r--r--asm/src/org/aspectj/asm/IRelationship.java60
-rw-r--r--asm/src/org/aspectj/asm/IStructureModelListener.java (renamed from asm/src/org/aspectj/asm/StructureModelListener.java)2
-rw-r--r--asm/src/org/aspectj/asm/InheritanceAssociation.java102
-rw-r--r--asm/src/org/aspectj/asm/IntroductionAssociation.java67
-rw-r--r--asm/src/org/aspectj/asm/LinkNode.java67
-rw-r--r--asm/src/org/aspectj/asm/ProgramElementNode.java413
-rw-r--r--asm/src/org/aspectj/asm/ReferenceAssociation.java153
-rw-r--r--asm/src/org/aspectj/asm/Relation.java89
-rw-r--r--asm/src/org/aspectj/asm/RelationNode.java39
-rw-r--r--asm/src/org/aspectj/asm/StructureModel.java63
-rw-r--r--asm/src/org/aspectj/asm/StructureModelManager.java102
-rw-r--r--asm/src/org/aspectj/asm/StructureNode.java265
-rw-r--r--asm/src/org/aspectj/asm/StructureNodeFactory.java299
-rw-r--r--asm/src/org/aspectj/asm/internal/ProgramElement.java364
-rw-r--r--asm/src/org/aspectj/asm/internal/Relationship.java53
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java15
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java33
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java (renamed from org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java)188
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmNodeFormatter.java40
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java81
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java2
-rw-r--r--testing/src/org/aspectj/testing/ajde/CompileCommand.java22
-rw-r--r--weaver/src/org/aspectj/weaver/AsmAdaptor.java128
73 files changed, 1988 insertions, 2803 deletions
diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java
index 7af4f2199..d5ca9956f 100644
--- a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java
+++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserManager.java
@@ -46,7 +46,7 @@ public class BrowserManager {
private static TopFrame topFrame = null;
- public final StructureModelListener VIEW_LISTENER = new StructureModelListener() {
+ public final IStructureModelListener VIEW_LISTENER = new IStructureModelListener() {
public void modelUpdated(StructureModel model) {
FileStructureView fsv = Ajde.getDefault().getStructureViewManager().getDefaultFileView();
if (fsv != null) {
diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java
index e97ae9dd1..5fa109e6a 100644
--- a/ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java
+++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/TopFrame.java
@@ -24,7 +24,7 @@ import javax.swing.filechooser.FileFilter;
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.swing.*;
-import org.aspectj.asm.ProgramElementNode;
+import org.aspectj.asm.IProgramElement;
/**
* UI for standalone operation.
@@ -123,7 +123,7 @@ public class TopFrame extends JFrame {
projectDebug_menuItem.setIcon(AjdeUIManager.getDefault().getIconRegistry().getDebugIcon());
this.setJMenuBar(menuBar);
- this.setIconImage(((ImageIcon)AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.ADVICE)).getImage());
+ this.setIconImage(((ImageIcon)AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.ADVICE)).getImage());
this.setLocation(75, 10);
this.setSize(900, 650);
this.setTitle(BrowserManager.TITLE);
@@ -381,7 +381,7 @@ public class TopFrame extends JFrame {
editConfig_button_actionPerformed(e);
}
});
- editConfig_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.FILE_LST));
+ editConfig_button.setIcon(AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(IProgramElement.Kind.FILE_LST));
editConfig_button.setText("Edit Config");
editConfig_button.setToolTipText("Edit Config...");
editConfig_button.setPreferredSize(new Dimension(80, 20));
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 {
diff --git a/asm/src/org/aspectj/asm/AdviceAssociation.java b/asm/src/org/aspectj/asm/AdviceAssociation.java
deleted file mode 100644
index 0ff166783..000000000
--- a/asm/src/org/aspectj/asm/AdviceAssociation.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Mik Kersten
- */
-public class AdviceAssociation implements Association {
-
- public static final String NAME = "Advice";
- public static final Relation METHOD_RELATION = new Relation("advises methods", "method advised by", NAME, true, false);
- public static final Relation METHOD_CALL_SITE_RELATION = new Relation("advises method call sites", "method call site advised by", NAME, true, false);
- public static final Relation CONSTRUCTOR_RELATION = new Relation("advises constructors", "constructors advised by", NAME, true, false);
- public static final Relation CONSTRUCTOR_CALL_SITE_RELATION = new Relation("advises constructions", "construction advised by", NAME, true, false);
- public static final Relation HANDLER_RELATION = new Relation("advises exception handlers", "exception handler advised by", NAME, true, false);
- public static final Relation INITIALIZER_RELATION = new Relation("advises initializers", "initializers advised by", NAME, true, false);
- public static final Relation FIELD_ACCESS_RELATION = new Relation("advises field access", "field access advised by", NAME, true, false);
- public static final Relation INTRODUCTION_RELATION = new Relation("advises introduction", "introduction advised by", NAME, true, false);
-
- private List relations = new ArrayList();
-
- public AdviceAssociation() {
- relations.add(METHOD_RELATION);
- relations.add(METHOD_CALL_SITE_RELATION);
- relations.add(CONSTRUCTOR_RELATION);
- relations.add(CONSTRUCTOR_CALL_SITE_RELATION);
- relations.add(HANDLER_RELATION);
- relations.add(INITIALIZER_RELATION);
- relations.add(FIELD_ACCESS_RELATION);
- relations.add(INTRODUCTION_RELATION);
- }
-
- public List getRelations() {
- return relations;
- }
-
- public List getRelationNodes() {
- List relations = new ArrayList();
- List methods = new ArrayList();
- List methodCallSites = new ArrayList();
- List constructors = new ArrayList();
- List constructorCallSites = new ArrayList();
- List handlers = new ArrayList();
- List initializers = new ArrayList();
- List fieldAccesses = new ArrayList();
- List introductions = new ArrayList();
-// Set forwardCorrs = StructureModelManager.correspondences.getAffects(astObject);
-// Set backCorrs = StructureModelManager.correspondences.getAffectedBy(astObject);
-//
-// if (astObject instanceof AdviceDec) {
-// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
-// ASTObject node = (ASTObject)it.next();
-// LinkNode link = StructureNodeFactory.makeLink(node, false);
-// if (node instanceof MethodDec) {
-// if (((MethodDec)node).isSynthetic()) {
-// ASTObject resolvedNode = resolveSyntheticMethodToIntroduction((MethodDec)node);
-// introductions.add(StructureNodeFactory.makeLink(resolvedNode, false));
-// } else {
-// methods.add(link);
-// }
-// } else if (node instanceof CallExpr) {
-// methodCallSites.add(link);
-// } else if (node instanceof ConstructorDec) {
-// constructors.add(link);
-// } else if (node instanceof NewInstanceExpr) {
-// constructorCallSites.add(link);
-// } else if (node instanceof CatchClause) {
-// handlers.add(link);
-// } else if (node instanceof InitializerDec) {
-// initializers.add(link);
-// } else if (node instanceof FieldDec) {
-// fieldAccesses.add(link);
-// } else if (node instanceof BasicAssignExpr || node instanceof FieldAccessExpr) {
-// fieldAccesses.add(link);
-// }
-// }
-// if (!methods.isEmpty()) relations.add(new RelationNode(METHOD_RELATION, METHOD_RELATION.getForwardNavigationName(), methods));
-// if (!methodCallSites.isEmpty()) relations.add(new RelationNode(METHOD_RELATION, METHOD_CALL_SITE_RELATION.getForwardNavigationName(), methodCallSites));
-// if (!constructors.isEmpty()) relations.add(new RelationNode(CONSTRUCTOR_RELATION, CONSTRUCTOR_RELATION.getForwardNavigationName(), constructors));
-// if (!constructorCallSites.isEmpty()) relations.add(new RelationNode(CONSTRUCTOR_CALL_SITE_RELATION, CONSTRUCTOR_CALL_SITE_RELATION.getForwardNavigationName(), constructorCallSites));
-// if (!handlers.isEmpty()) relations.add(new RelationNode(HANDLER_RELATION, HANDLER_RELATION.getForwardNavigationName(), handlers));
-// if (!initializers.isEmpty()) relations.add(new RelationNode(INITIALIZER_RELATION, INITIALIZER_RELATION.getForwardNavigationName(), initializers));
-// if (!fieldAccesses.isEmpty()) relations.add(new RelationNode(FIELD_ACCESS_RELATION, FIELD_ACCESS_RELATION.getForwardNavigationName(), fieldAccesses));
-// if (!introductions.isEmpty()) relations.add(new RelationNode(INTRODUCTION_RELATION, INTRODUCTION_RELATION.getForwardNavigationName(), introductions));
-// } else {
-// if (astObject instanceof IntroducedDec) {
-// Set adviceDecs = resolveAdviceAffectingIntroduction((IntroducedDec)astObject);
-// if (adviceDecs != null) {
-// for (Iterator adIt = adviceDecs.iterator(); adIt.hasNext(); ) {
-// introductions.add(StructureNodeFactory.makeLink((ASTObject)adIt.next(), false));
-// }
-// }
-// }
-//
-// for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
-// ASTObject node = (ASTObject)it.next();
-// if (node instanceof AdviceDec) {
-// if (astObject instanceof MethodDec) {
-// methods.add(StructureNodeFactory.makeLink(node, false));
-// } else if (astObject instanceof CallExpr) {
-// methodCallSites.add(StructureNodeFactory.makeLink(node, false));
-// } else if (astObject instanceof ConstructorDec) {
-// constructors.add(StructureNodeFactory.makeLink(node, false));
-// } else if (astObject instanceof NewInstanceExpr) {
-// constructorCallSites.add(StructureNodeFactory.makeLink(node, false));
-// } else if (astObject instanceof CatchClause) {
-// handlers.add(StructureNodeFactory.makeLink(node, false));
-// } else if (astObject instanceof InitializerDec) {
-// initializers.add(StructureNodeFactory.makeLink(node, false));
-// } else if (astObject instanceof FieldDec) {
-// fieldAccesses.add(StructureNodeFactory.makeLink(node, false));
-// } else if (astObject instanceof BasicAssignExpr
-// || astObject instanceof FieldAccessExpr) {
-// fieldAccesses.add(StructureNodeFactory.makeLink(node, false));
-// }
-// }
-// }
-// if (!methods.isEmpty()) relations.add(new RelationNode(METHOD_RELATION, METHOD_RELATION.getBackNavigationName(), methods));
-// if (!methodCallSites.isEmpty()) relations.add(new RelationNode(METHOD_CALL_SITE_RELATION, METHOD_CALL_SITE_RELATION.getBackNavigationName(), methodCallSites));
-// if (!constructors.isEmpty()) relations.add(new RelationNode(CONSTRUCTOR_RELATION, CONSTRUCTOR_RELATION.getBackNavigationName(), constructors));
-// if (!constructorCallSites.isEmpty()) relations.add(new RelationNode(CONSTRUCTOR_CALL_SITE_RELATION, CONSTRUCTOR_CALL_SITE_RELATION.getBackNavigationName(), constructorCallSites));
-// if (!handlers.isEmpty()) relations.add(new RelationNode(HANDLER_RELATION, HANDLER_RELATION.getBackNavigationName(), handlers));
-// if (!initializers.isEmpty()) relations.add(new RelationNode(INITIALIZER_RELATION, INITIALIZER_RELATION.getBackNavigationName(), initializers));
-// if (!fieldAccesses.isEmpty()) relations.add(new RelationNode(FIELD_ACCESS_RELATION, FIELD_ACCESS_RELATION.getBackNavigationName(), fieldAccesses));
-// if (!introductions.isEmpty()) relations.add(new RelationNode(INTRODUCTION_RELATION, INTRODUCTION_RELATION.getBackNavigationName(), introductions));
-// }
- return relations;
- }
-
- public String getName() {
- return NAME;
- }
-
-// /**
-// * @todo HACK: this search and hacked name-match should be replace by a fix to the correspondeces db
-// */
-// private ASTObject resolveSyntheticMethodToIntroduction(MethodDec node) {
-// Set backCorrs = StructureModelManager.correspondences.getAffectedBy(node.getDeclaringType().getTypeDec());
-// Method method = node.getMethod();
-// String name = method.getDeclaringType().getName() + '.' + method.getName();
-// for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
-// Object next = it.next();
-// if (next instanceof IntroducedDec) {
-// IntroducedDec introducedDec = (IntroducedDec)next;
-// if (name.equals(introducedDec.toShortString())) return introducedDec;
-// }
-// }
-// return node;
-// }
-
-// /**
-// * @todo HACK: this search and hacked name-match should be replace by a fix to the correspondeces db
-// */
-// private Set resolveAdviceAffectingIntroduction(IntroducedDec node) {
-// Set forwardCorrs = StructureModelManager.correspondences.getAffects(node);
-// String name = node.getId();
-// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
-// Object next = it.next();
-// if (next instanceof TypeDec) {
-// TypeDec typeDec = (TypeDec)next;
-// List decs = typeDec.getBody().getList();
-// for (Iterator it2 = decs.iterator(); it2.hasNext(); ) {
-// Dec bodyDec = (Dec)it2.next();
-// if (bodyDec != null && !(bodyDec instanceof InitializerDec)) {
-// if (bodyDec instanceof MethodDec && bodyDec.isSynthetic() && name.equals(bodyDec.getName())) {
-// MethodDec methodDec = (MethodDec)bodyDec;
-// return StructureModelManager.correspondences.getAffectedBy(methodDec);
-// }
-// }
-// }
-// }
-// }
-// return null;
-// }
-}
-
diff --git a/asm/src/org/aspectj/asm/Association.java b/asm/src/org/aspectj/asm/Association.java
deleted file mode 100644
index c0431d694..000000000
--- a/asm/src/org/aspectj/asm/Association.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.List;
-
-/**
- * @author Mik Kersten
- */
-public interface Association {
-
- public List getRelations();
-
- // XXX used ASTObject parameter
- public List getRelationNodes();
-
- public String getName();
-}
diff --git a/asm/src/org/aspectj/asm/ModelWalker.java b/asm/src/org/aspectj/asm/HierarchyWalker.java
index e5e19deee..b1d9e6100 100644
--- a/asm/src/org/aspectj/asm/ModelWalker.java
+++ b/asm/src/org/aspectj/asm/HierarchyWalker.java
@@ -17,23 +17,23 @@ package org.aspectj.asm;
/**
* @author Mik Kersten
*/
-public class ModelWalker {
+public class HierarchyWalker {
private StructureModel model;
- public ModelWalker() {
+ public HierarchyWalker() {
super();
}
- public ModelWalker(StructureModel model) {
+ public HierarchyWalker(StructureModel model) {
this.model = model;
}
- protected void preProcess(StructureNode node) { }
+ protected void preProcess(IProgramElement node) { }
- protected void postProcess(StructureNode node) { }
+ protected void postProcess(IProgramElement node) { }
- public StructureNode process(StructureNode node) {
+ public IProgramElement process(IProgramElement node) {
preProcess(node);
node.walk(this);
postProcess(node);
diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java
new file mode 100644
index 000000000..24132f55d
--- /dev/null
+++ b/asm/src/org/aspectj/asm/IProgramElement.java
@@ -0,0 +1,218 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * ******************************************************************/
+
+package org.aspectj.asm;
+
+import java.io.*;
+import java.util.*;
+
+import org.aspectj.bridge.*;
+
+/**
+ * Represents program elements in the AspectJ containment hierarchy.
+ *
+ * @author Mik Kersten
+ */
+public interface IProgramElement extends Serializable {
+
+ public List/*IProgramElement*/ getChildren();
+ public void addChild(IProgramElement child);
+ public Kind getKind();
+ public List getModifiers();
+ public Accessibility getAccessibility();
+ public String getDeclaringType();
+ public String getPackageName();
+ public String getSignature();
+ public String getName();
+ public boolean isCode();
+ public boolean isMemberKind();
+ public void setRunnable(boolean value);
+ public boolean isRunnable();
+ public boolean isImplementor();
+ public void setImplementor(boolean value);
+ public boolean isOverrider();
+ public void setOverrider(boolean value);
+ public List getRelations();
+ public void setRelations(List relations);
+ public String getFormalComment();
+ public String toString();
+ public String getBytecodeName();
+ public String getBytecodeSignature();
+ public void setBytecodeName(String bytecodeName);
+ public void setBytecodeSignature(String bytecodeSignature);
+ public String getFullSignature();
+ public void setFullSignature(String string);
+ public void setKind(Kind kind);
+ public void setReturnType(String returnType);
+ public String getReturnType();
+ public ISourceLocation getSourceLocation();
+ public void setSourceLocation(ISourceLocation sourceLocation);
+ public IMessage getMessage();
+ public void setMessage(IMessage message);
+ public IProgramElement getParent();
+ public void setParent(IProgramElement parent);
+ public IProgramElement walk(HierarchyWalker walker);
+ public void setName(String name);
+ public void setChildren(List children);
+
+ /**
+ * Uses "typesafe enum" pattern.
+ */
+ public static class Modifiers implements Serializable {
+
+ public static final Modifiers STATIC = new Modifiers("static");
+ public static final Modifiers FINAL = new Modifiers("final");
+ public static final Modifiers ABSTRACT = new Modifiers("abstract");
+ public static final Modifiers SYNCHRONIZED = new Modifiers("synchronized");
+ public static final Modifiers VOLATILE = new Modifiers("volatile");
+ public static final Modifiers STRICTFP = new Modifiers("strictfp");
+ public static final Modifiers TRANSIENT = new Modifiers("transient");
+ public static final Modifiers NATIVE = new Modifiers("native");
+ public static final Modifiers[] ALL = { STATIC, FINAL, ABSTRACT, SYNCHRONIZED, TRANSIENT, VOLATILE, STRICTFP, NATIVE };
+ private final String name;
+
+ private Modifiers(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ // The 4 declarations below are necessary for serialization
+ private static int nextOrdinal = 0;
+ private final int ordinal = nextOrdinal++;
+ private Object readResolve() throws ObjectStreamException {
+ return ALL[ordinal];
+ }
+ }
+
+ /**
+ * Uses "typesafe enum" pattern.
+ */
+ public static class Accessibility implements Serializable {
+
+ public static final Accessibility PUBLIC = new Accessibility("public");
+ public static final Accessibility PACKAGE = new Accessibility("package");
+ public static final Accessibility PROTECTED = new Accessibility("protected");
+ public static final Accessibility PRIVATE = new Accessibility("private");
+ public static final Accessibility PRIVILEGED = new Accessibility("privileged");
+ public static final Accessibility[] ALL = { PUBLIC, PACKAGE, PROTECTED, PRIVATE, PRIVILEGED };
+ private final String name;
+
+ private Accessibility(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ // The 4 declarations below are necessary for serialization
+ private static int nextOrdinal = 0;
+ private final int ordinal = nextOrdinal++;
+ private Object readResolve() throws ObjectStreamException {
+ return ALL[ordinal];
+ }
+ }
+
+ /**
+ * Uses "typesafe enum" pattern.
+ */
+ public static class Kind implements Serializable {
+
+ public static final Kind PROJECT = new Kind("project");
+ public static final Kind PACKAGE = new Kind("package");
+ public static final Kind FILE = new Kind("file");
+ public static final Kind FILE_JAVA = new Kind("java source file");
+ public static final Kind FILE_ASPECTJ = new Kind("aspect source file");
+ public static final Kind FILE_LST = new Kind("build configuration file");
+ public static final Kind CLASS = new Kind("class");
+ public static final Kind INTERFACE = new Kind("interface");
+ public static final Kind ASPECT = new Kind("aspect");
+ public static final Kind INITIALIZER = new Kind("initializer");
+ public static final Kind INTER_TYPE_FIELD = new Kind("inter-type field");
+ public static final Kind INTER_TYPE_METHOD = new Kind("inter-type method");
+ public static final Kind INTER_TYPE_CONSTRUCTOR = new Kind("inter-type constructor");
+ public static final Kind CONSTRUCTOR = new Kind("constructor");
+ public static final Kind METHOD = new Kind("method");
+ public static final Kind FIELD = new Kind("field");
+ public static final Kind POINTCUT = new Kind("pointcut");
+ public static final Kind ADVICE = new Kind("advice");
+ public static final Kind DECLARE_PARENTS = new Kind("declare parents");
+ public static final Kind DECLARE_WARNING = new Kind("declare warning");
+ public static final Kind DECLARE_ERROR = new Kind("declare error");
+ public static final Kind DECLARE_SOFT = new Kind("declare soft");
+ public static final Kind DECLARE_PRECEDENCE= new Kind("declare precedence");
+ public static final Kind CODE = new Kind("decBodyElement");
+ public static final Kind ERROR = new Kind("error");
+
+ public static final Kind[] ALL = { PROJECT, PACKAGE, FILE, FILE_JAVA,
+ FILE_ASPECTJ, FILE_LST, CLASS, INTERFACE, ASPECT,
+ INITIALIZER, INTER_TYPE_FIELD, INTER_TYPE_METHOD, INTER_TYPE_CONSTRUCTOR,
+ CONSTRUCTOR, METHOD, FIELD, POINTCUT, ADVICE, DECLARE_PARENTS,
+ DECLARE_WARNING, DECLARE_ERROR, DECLARE_SOFT, CODE, ERROR };
+
+ public static Kind getKindForString(String kindString) {
+ for (int i = 0; i < ALL.length; i++) {
+ if (ALL[i].toString().equals(kindString)) return ALL[i];
+ }
+ return ERROR;
+ }
+
+ private final String name;
+
+ private Kind(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ public static List getNonAJMemberKinds() {
+ List list = new ArrayList();
+ list.add(METHOD);
+ list.add(FIELD);
+ list.add(CONSTRUCTOR);
+ return list;
+ }
+
+ public boolean isMemberKind() {
+ return this == FIELD
+ || this == METHOD
+ || this == CONSTRUCTOR
+ || this == POINTCUT
+ || this == ADVICE;
+ }
+
+ public boolean isTypeKind() {
+ return this == CLASS
+ || this == INTERFACE
+ || this == ASPECT;
+ }
+
+ public boolean isSourceFileKind() {
+ return this == FILE_ASPECTJ
+ || this == FILE_JAVA;
+ }
+
+ public boolean isDeclareKind() {
+ return name.startsWith("declare");
+ }
+
+ // The 4 declarations below are necessary for serialization
+ private static int nextOrdinal = 0;
+ private final int ordinal = nextOrdinal++;
+ private Object readResolve() throws ObjectStreamException {
+ return ALL[ordinal];
+ }
+ }
+} \ No newline at end of file
diff --git a/asm/src/org/aspectj/asm/IRelationship.java b/asm/src/org/aspectj/asm/IRelationship.java
new file mode 100644
index 000000000..ab8d9bf09
--- /dev/null
+++ b/asm/src/org/aspectj/asm/IRelationship.java
@@ -0,0 +1,60 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.asm;
+
+import java.io.*;
+import java.util.List;
+
+/**
+ * @author Mik Kersten
+ */
+public interface IRelationship extends Serializable {
+
+ public String getName();
+
+ public Kind getKind();
+
+ public IProgramElement getSource();
+
+ public List/*IProgramElement*/ getTargets();
+
+ /**
+ * Uses "typesafe enum" pattern.
+ */
+ public static class Kind implements Serializable {
+
+ public static final Kind ADVICE = new Kind("static");
+ public static final Kind INHERITANCE = new Kind("final");
+ public static final Kind REFERENCE = new Kind("abstract");
+ public static final Kind DECLARE = new Kind("volatile");
+ public static final Kind[] ALL = { ADVICE, INHERITANCE, REFERENCE, DECLARE };
+ private final String name;
+
+ private Kind(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ // The 4 declarations below are necessary for serialization
+ private static int nextOrdinal = 0;
+ private final int ordinal = nextOrdinal++;
+ private Object readResolve() throws ObjectStreamException {
+ return ALL[ordinal];
+ }
+ }
+}
diff --git a/asm/src/org/aspectj/asm/StructureModelListener.java b/asm/src/org/aspectj/asm/IStructureModelListener.java
index eab786b64..9512045ac 100644
--- a/asm/src/org/aspectj/asm/StructureModelListener.java
+++ b/asm/src/org/aspectj/asm/IStructureModelListener.java
@@ -21,7 +21,7 @@ import java.util.EventListener;
*
* @author Mik Kersten
*/
-public interface StructureModelListener extends EventListener {
+public interface IStructureModelListener extends EventListener {
public void modelUpdated(StructureModel rootNode);
}
diff --git a/asm/src/org/aspectj/asm/InheritanceAssociation.java b/asm/src/org/aspectj/asm/InheritanceAssociation.java
deleted file mode 100644
index dea4bd689..000000000
--- a/asm/src/org/aspectj/asm/InheritanceAssociation.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Mik Kersten
- */
-public class InheritanceAssociation implements Association {
- public static final String NAME = "Inheritance";
- public static final Relation INHERITS_RELATION = new Relation("inherits", "is inherited by", NAME, true, true);
- public static final Relation IMPLEMENTS_RELATION = new Relation("implements", "is implemented by", NAME, true, true);
- public static final Relation INHERITS_MEMBERS_RELATION = new Relation("inherits members", NAME, false);
- private List relations = new ArrayList();
-
- public InheritanceAssociation() {
- relations.add(INHERITS_RELATION);
- relations.add(IMPLEMENTS_RELATION);
- relations.add(INHERITS_MEMBERS_RELATION);
- }
-
- public List getRelations() {
- return relations;
- }
-
- public List getRelationNodes() {
- List relations = new ArrayList();
-// if (astObject instanceof TypeDec) {
-// TypeDec typeDec = (TypeDec)astObject;
-// boolean isInterface = (astObject instanceof InterfaceDec);
-// List superTypes = getTypeLinks(typeDec.getType().getDirectSuperTypes(), true, isInterface);
-// List subTypes = getTypeLinks(typeDec.getType().getDirectSubTypes(), true, isInterface);
-// if (!superTypes.isEmpty()) relations.add(new RelationNode(INHERITS_RELATION, INHERITS_RELATION.getForwardNavigationName(), superTypes));
-// if (!subTypes.isEmpty()) relations.add(new RelationNode(INHERITS_RELATION, INHERITS_RELATION.getBackNavigationName(), subTypes));
-//
-// List implementedInterfaces = getTypeLinks(typeDec.getType().getDirectSuperTypes(), false, isInterface);
-// List implementors = getTypeLinks(typeDec.getType().getDirectSubTypes(), false, isInterface);
-// if (!implementedInterfaces.isEmpty()) relations.add(new RelationNode(IMPLEMENTS_RELATION, IMPLEMENTS_RELATION.getForwardNavigationName(), implementedInterfaces));
-// if (!implementors.isEmpty()) relations.add(new RelationNode(IMPLEMENTS_RELATION, IMPLEMENTS_RELATION.getBackNavigationName(), implementors));
-//
-// List inheritedMembers = new ArrayList(getMemberLinks(typeDec.getType().getInheritedMethods()));
-// if (!inheritedMembers.isEmpty()) relations.add(new RelationNode(INHERITS_MEMBERS_RELATION, INHERITS_MEMBERS_RELATION.getForwardNavigationName(), inheritedMembers));
-// }
- return relations;
- }
-
-// private List getTypeLinks(Collection types, boolean isInheritance, boolean isInterface) {
-// List links = new ArrayList();
-// if (types != null) {
-// for (Iterator it = types.iterator(); it.hasNext(); ) {
-// NameType nameType = (NameType)it.next();
-// if (!nameType.getId().equals("Object")) {
-// if (isInheritance && ((isInterface && nameType.isInterface()) || (!isInterface && !nameType.isInterface()))
-// || !isInheritance && (!isInterface && nameType.isInterface())) {
-// Dec dec = nameType.getCorrespondingDec();
-// links.add(StructureNodeFactory.makeLink(dec, false));
-// }
-// }
-// }
-// }
-// return links;
-// }
-
-// private List getMemberLinks(Collection members) {
-// List links = new ArrayList();
-// if (members != null) {
-// for (Iterator it = members.iterator(); it.hasNext(); ) {
-// Object object = it.next();
-// if (object instanceof Method) {
-// Method method = (Method)object;
-// if (!method.getDeclaringType().getId().equals("Object")) {
-// links.add(StructureNodeFactory.makeLink(method.getCorrespondingDec(), false));
-// }
-// } else if (object instanceof Field) {
-// Field field = (Field)object;
-// if (!field.getDeclaringType().getId().equals("Object")) {
-// links.add(StructureNodeFactory.makeLink(field.getCorrespondingDec(), false));
-// }
-// }
-// }
-// }
-// return links;
-// }
-
- public String getName() {
- return NAME;
- }
-}
diff --git a/asm/src/org/aspectj/asm/IntroductionAssociation.java b/asm/src/org/aspectj/asm/IntroductionAssociation.java
deleted file mode 100644
index 867baa61c..000000000
--- a/asm/src/org/aspectj/asm/IntroductionAssociation.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Mik Kersten
- */
-public class IntroductionAssociation implements Association {
- public static final String NAME = "Introduction";
- public static final Relation INTRODUCES_RELATION = new Relation("declares member on", "inter-type declared members", NAME, true, false);
- private List relations = new ArrayList();
-
- public IntroductionAssociation() {
- relations.add(INTRODUCES_RELATION);
- }
-
- public List getRelations() {
- return relations;
- }
-
- public List getRelationNodes() {
- List relations = new ArrayList();
- List introduces = new ArrayList();
-// Set forwardCorrs = StructureModelManager.correspondences.getAffects(astObject);
-// Set backCorrs = StructureModelManager.correspondences.getAffectedBy(astObject);
-// if (astObject instanceof IntroducedDec) {
-// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
-// ASTObject node = (ASTObject)it.next();
-// LinkNode link = StructureNodeFactory.makeLink(node, false);
-// if (node instanceof TypeDec) {
-// introduces.add(link);
-// }
-// }
-// if (!introduces.isEmpty()) relations.add(new RelationNode(INTRODUCES_RELATION, INTRODUCES_RELATION.getForwardNavigationName(), introduces));
-// } else {
-// for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
-// ASTObject node = (ASTObject)it.next();
-// if (astObject instanceof TypeDec) {
-// if (node instanceof IntroducedDec) {
-// introduces.add(StructureNodeFactory.makeLink(node, false));
-// }
-// }
-// }
-// if (!introduces.isEmpty()) relations.add(new RelationNode(INTRODUCES_RELATION, INTRODUCES_RELATION.getBackNavigationName(), introduces));
-// }
- return relations;
- }
-
- public String getName() {
- return NAME;
- }
-}
diff --git a/asm/src/org/aspectj/asm/LinkNode.java b/asm/src/org/aspectj/asm/LinkNode.java
deleted file mode 100644
index 9db0dd2bb..000000000
--- a/asm/src/org/aspectj/asm/LinkNode.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-
-/**
- * @author Mik Kersten
- */
-public class LinkNode extends StructureNode {
-
- private ProgramElementNode programElementNode = null;
-
- /**
- * Used during de-serialization.
- */
- public LinkNode() { }
-
- /**
- * @param node can not be null
- */
- public LinkNode(ProgramElementNode node) {
- super(node.getSignature().toString(), "internal", null);
- this.programElementNode = node;
- }
-
- public ProgramElementNode getProgramElementNode() {
- return programElementNode;
- }
-
- public String toString() {
- String name = "";
- if (programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.ADVICE) ||
- programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.INTER_TYPE_FIELD) ||
- programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.INTER_TYPE_METHOD) ||
- programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR) ||
- programElementNode.getProgramElementKind().equals(ProgramElementNode.Kind.CODE)) {
- name = programElementNode.parent.toString() + ": " + programElementNode.getName();
- StructureNode grandparent = programElementNode.parent.parent;
- if ( grandparent instanceof ProgramElementNode ) {
- ProgramElementNode pe_grandparent = (ProgramElementNode)grandparent;
- if ( pe_grandparent.getProgramElementKind().equals(ProgramElementNode.Kind.CLASS) ||
- pe_grandparent.getProgramElementKind().equals(ProgramElementNode.Kind.INTERFACE)
- ) {
- name = pe_grandparent.toString() + "." + name;
- }
- }
-
- } else if (programElementNode.isMemberKind()) {
- name = programElementNode.parent.toString() + '.' + programElementNode.getName();
- } else {
- name = programElementNode.toString();
- }
- return name;
- }
-}
diff --git a/asm/src/org/aspectj/asm/ProgramElementNode.java b/asm/src/org/aspectj/asm/ProgramElementNode.java
deleted file mode 100644
index 37861a48f..000000000
--- a/asm/src/org/aspectj/asm/ProgramElementNode.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.*;
-import java.io.*;
-
-import org.aspectj.bridge.ISourceLocation;
-
-
-/**
- * @author Mik Kersten
- */
-public class ProgramElementNode extends StructureNode {
-
- private List modifiers = new ArrayList();
- private List relations = new ArrayList();
-
- private Kind kind;
- private Accessibility accessibility;
- private String declaringType = "";
- private String formalComment = "";
- private String packageName = null;
- private boolean runnable = false;
- private boolean implementor = false;
- private boolean overrider = false;
-
- private String bytecodeName;
- private String bytecodeSignature;
- private String fullSignature;
- private String returnType;
-
- /**
- * Used during de-externalization.
- */
- public ProgramElementNode() { }
-
- /**
- * Use to create program element nodes that do not correspond to source locations.
- */
- public ProgramElementNode(
- String signature,
- Kind kind,
- List children) {
- super(signature, kind.toString(), children);
- this.kind = kind;
- }
-
- public ProgramElementNode(
- String signature,
- ProgramElementNode.Kind kind,
- ISourceLocation sourceLocation,
- int modifiers,
- String formalComment,
- List children)
- {
- super(signature, kind.toString(), children);
- super.sourceLocation = sourceLocation;
- this.kind = kind;
- this.formalComment = formalComment;
- this.modifiers = genModifiers(modifiers);
- this.accessibility = genAccessibility(modifiers);
- }
-
- /**
- * Use to create program element nodes that correspond to source locations.
- */
- public ProgramElementNode(
- String signature,
- Kind kind,
- List modifiers,
- Accessibility accessibility,
- String declaringType,
- String packageName,
- String formalComment,
- ISourceLocation sourceLocation,
- List relations,
- List children,
- boolean member) {
-
- super(signature, kind.toString(), children);
- super.sourceLocation = sourceLocation;
- this.kind = kind;
- this.modifiers = modifiers;
- this.accessibility = accessibility;
- this.declaringType = declaringType;
- this.packageName = packageName;
- this.formalComment = formalComment;
- this.relations = relations;
- }
-
- public Kind getProgramElementKind() {
- return kind;
- }
-
- public List getModifiers() {
- return modifiers;
- }
-
- public Accessibility getAccessibility() {
- return accessibility;
- }
-
- public String getDeclaringType() {
- return declaringType;
- }
-
- public String getPackageName() {
- if (kind == Kind.PACKAGE) return getSignature();
- if (getParent() == null || !(getParent() instanceof ProgramElementNode)) {
- return "";
- }
- return ((ProgramElementNode)getParent()).getPackageName();
- }
-
- public String getKind() {
- return super.kind;
- }
-
- public String getSignature() {
- return super.name;
- }
-
- public boolean isCode() {
- return kind.equals(Kind.CODE);
- }
-
- public boolean isMemberKind() {
- return kind.isMemberKind();
- }
-
- public void setRunnable(boolean value) {
- this.runnable = value;
- }
-
- public boolean isRunnable() {
- return runnable;
- }
-
- public boolean isImplementor() {
- return implementor;
- }
-
- public void setImplementor(boolean value) {
- this.implementor = value;
- }
-
- public boolean isOverrider() {
- return overrider;
- }
-
- public void setOverrider(boolean value) {
- this.overrider = value;
- }
-
- public List getRelations() {
- return relations;
- }
-
- public void setRelations(List relations) {
- if (relations.size() > 0) {
- this.relations = relations;
- }
- }
-
- public String getFormalComment() {
- return formalComment;
- }
-
- public String toString() {
- return super.name;
- }
-
- public static List genModifiers(int modifiers) {
- List modifiersList = new ArrayList();
- if ((modifiers & AccStatic) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
- if ((modifiers & AccFinal) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
- if ((modifiers & AccSynchronized) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
- if ((modifiers & AccVolatile) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
- if ((modifiers & AccTransient) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
- if ((modifiers & AccNative) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
- if ((modifiers & AccAbstract) != 0) modifiersList.add(ProgramElementNode.Modifiers.STATIC);
- return modifiersList;
- }
-
- public static ProgramElementNode.Accessibility genAccessibility(int modifiers) {
- if ((modifiers & AccPublic) != 0) return ProgramElementNode.Accessibility.PUBLIC;
- if ((modifiers & AccPrivate) != 0) return ProgramElementNode.Accessibility.PRIVATE;
- if ((modifiers & AccProtected) != 0) return ProgramElementNode.Accessibility.PROTECTED;
- if ((modifiers & AccPrivileged) != 0) return ProgramElementNode.Accessibility.PRIVILEGED;
- else return ProgramElementNode.Accessibility.PACKAGE;
- }
-
- /**
- * Uses "typesafe enum" pattern.
- */
- public static class Modifiers implements Serializable {
-
- public static final Modifiers STATIC = new Modifiers("static");
- public static final Modifiers FINAL = new Modifiers("final");
- public static final Modifiers ABSTRACT = new Modifiers("abstract");
- public static final Modifiers SYNCHRONIZED = new Modifiers("synchronized");
- public static final Modifiers VOLATILE = new Modifiers("volatile");
- public static final Modifiers STRICTFP = new Modifiers("strictfp");
- public static final Modifiers TRANSIENT = new Modifiers("transient");
- public static final Modifiers NATIVE = new Modifiers("native");
- public static final Modifiers[] ALL = { STATIC, FINAL, ABSTRACT, SYNCHRONIZED, TRANSIENT, VOLATILE, STRICTFP, NATIVE };
- private final String name;
-
- private Modifiers(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- // The 4 declarations below are necessary for serialization
- private static int nextOrdinal = 0;
- private final int ordinal = nextOrdinal++;
- private Object readResolve() throws ObjectStreamException {
- return ALL[ordinal];
- }
- }
-
- /**
- * Uses "typesafe enum" pattern.
- */
- public static class Accessibility implements Serializable {
-
- public static final Accessibility PUBLIC = new Accessibility("public");
- public static final Accessibility PACKAGE = new Accessibility("package");
- public static final Accessibility PROTECTED = new Accessibility("protected");
- public static final Accessibility PRIVATE = new Accessibility("private");
- public static final Accessibility PRIVILEGED = new Accessibility("privileged");
- public static final Accessibility[] ALL = { PUBLIC, PACKAGE, PROTECTED, PRIVATE, PRIVILEGED };
- private final String name;
-
- private Accessibility(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- // The 4 declarations below are necessary for serialization
- private static int nextOrdinal = 0;
- private final int ordinal = nextOrdinal++;
- private Object readResolve() throws ObjectStreamException {
- return ALL[ordinal];
- }
- }
-
- /**
- * Uses "typesafe enum" pattern.
- */
- public static class Kind implements Serializable {
-
- public static final Kind PROJECT = new Kind("project");
- public static final Kind PACKAGE = new Kind("package");
- public static final Kind FILE = new Kind("file");
- public static final Kind FILE_JAVA = new Kind("java source file");
- public static final Kind FILE_ASPECTJ = new Kind("aspect source file");
- public static final Kind FILE_LST = new Kind("build configuration file");
- public static final Kind CLASS = new Kind("class");
- public static final Kind INTERFACE = new Kind("interface");
- public static final Kind ASPECT = new Kind("aspect");
- public static final Kind INITIALIZER = new Kind("initializer");
- public static final Kind INTER_TYPE_FIELD = new Kind("inter-type field");
- public static final Kind INTER_TYPE_METHOD = new Kind("inter-type method");
- public static final Kind INTER_TYPE_CONSTRUCTOR = new Kind("inter-type constructor");
- public static final Kind CONSTRUCTOR = new Kind("constructor");
- public static final Kind METHOD = new Kind("method");
- public static final Kind FIELD = new Kind("field");
- public static final Kind POINTCUT = new Kind("pointcut");
- public static final Kind ADVICE = new Kind("advice");
- public static final Kind DECLARE_PARENTS = new Kind("declare parents");
- public static final Kind DECLARE_WARNING = new Kind("declare warning");
- public static final Kind DECLARE_ERROR = new Kind("declare error");
- public static final Kind DECLARE_SOFT = new Kind("declare soft");
- public static final Kind DECLARE_PRECEDENCE= new Kind("declare precedence");
- public static final Kind CODE = new Kind("decBodyElement");
- public static final Kind ERROR = new Kind("error");
-
- public static final Kind[] ALL = { PROJECT, PACKAGE, FILE, FILE_JAVA,
- FILE_ASPECTJ, FILE_LST, CLASS, INTERFACE, ASPECT,
- INITIALIZER, INTER_TYPE_FIELD, INTER_TYPE_METHOD, INTER_TYPE_CONSTRUCTOR,
- CONSTRUCTOR, METHOD, FIELD, POINTCUT, ADVICE, DECLARE_PARENTS,
- DECLARE_WARNING, DECLARE_ERROR, DECLARE_SOFT, CODE, ERROR };
-
- public static Kind getKindForString(String kindString) {
- for (int i = 0; i < ALL.length; i++) {
- if (ALL[i].toString().equals(kindString)) return ALL[i];
- }
- return ERROR;
- }
-
- private final String name;
-
- private Kind(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- public static List getNonAJMemberKinds() {
- List list = new ArrayList();
- list.add(METHOD);
- list.add(FIELD);
- list.add(CONSTRUCTOR);
- return list;
- }
-
- public boolean isMemberKind() {
- return this == FIELD
- || this == METHOD
- || this == CONSTRUCTOR
- || this == POINTCUT
- || this == ADVICE;
- }
-
- public boolean isTypeKind() {
- return this == CLASS
- || this == INTERFACE
- || this == ASPECT;
- }
-
- public boolean isSourceFileKind() {
- return this == FILE_ASPECTJ
- || this == FILE_JAVA;
- }
-
- public boolean isDeclareKind() {
- return name.startsWith("declare");
- }
-
- // The 4 declarations below are necessary for serialization
- private static int nextOrdinal = 0;
- private final int ordinal = nextOrdinal++;
- private Object readResolve() throws ObjectStreamException {
- return ALL[ordinal];
- }
- }
-
- // XXX these names and values are from org.eclipse.jdt.internal.compiler.env.IConstants
- private static int AccPublic = 0x0001;
- private static int AccPrivate = 0x0002;
- private static int AccProtected = 0x0004;
- private static int AccPrivileged = 0x0006; // XXX is this right?
- private static int AccStatic = 0x0008;
- private static int AccFinal = 0x0010;
- private static int AccSynchronized = 0x0020;
- private static int AccVolatile = 0x0040;
- private static int AccTransient = 0x0080;
- private static int AccNative = 0x0100;
- private static int AccInterface = 0x0200;
- private static int AccAbstract = 0x0400;
- private static int AccStrictfp = 0x0800;
-
-
- public String getBytecodeName() {
- return bytecodeName;
- }
-
- public String getBytecodeSignature() {
- return bytecodeSignature;
- }
-
- public void setBytecodeName(String bytecodeName) {
- this.bytecodeName = bytecodeName;
- }
-
- public void setBytecodeSignature(String bytecodeSignature) {
- this.bytecodeSignature = bytecodeSignature;
- }
-
- public String getFullSignature() {
- return fullSignature;
- }
-
- public void setFullSignature(String string) {
- fullSignature = string;
- }
-
- public void setKind(Kind kind) {
- this.kind = kind;
- }
-
- public void setReturnType(String returnType) {
- this.returnType = returnType;
- }
-
- public String getReturnType() {
- return returnType;
- }
-
-}
-
diff --git a/asm/src/org/aspectj/asm/ReferenceAssociation.java b/asm/src/org/aspectj/asm/ReferenceAssociation.java
deleted file mode 100644
index abe53ace4..000000000
--- a/asm/src/org/aspectj/asm/ReferenceAssociation.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Mik Kersten
- */
-public class ReferenceAssociation implements Association {
- public static final String NAME = "Reference";
- public static final Relation USES_POINTCUT_RELATION = new Relation("uses pointcut", "pointcut used by", NAME, true, true);
- public static final Relation IMPORTS_RELATION = new Relation("imports", NAME, false);
- //public static final Relation THROWS_RELATION = new Relation("throws", NAME, false);
- //public static final Relation USES_TYPE_RELATION = new Relation("uses type", NAME, false);
-
- private List relations = new ArrayList();
-
- public ReferenceAssociation() {
- relations.add(USES_POINTCUT_RELATION);
- relations.add(IMPORTS_RELATION);
- //relations.add(THROWS_RELATION);
- //relations.add(USES_TYPE_RELATION);
- }
-
- public List getRelations() {
- return relations;
- }
-
- public List getRelationNodes() {
- List relations = new ArrayList();
- List pointcutsUsed = new ArrayList();
- List pointcutUsedBy = new ArrayList();
- List throwsTypes = new ArrayList();
- List imports = new ArrayList();
- List usesType = new ArrayList();
-// Set forwardCorrs = StructureModelManager.correspondences.getAffects(astObject);
-// Set backCorrs = StructureModelManager.correspondences.getAffectedBy(astObject);
-//
-// if (astObject instanceof AdviceDec) {
-// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
-// ASTObject node = (ASTObject)it.next();
-// if (node instanceof PointcutDec) {
-// pointcutsUsed.add(StructureNodeFactory.makeLink(node, false));
-// }
-// }
-// } else if (astObject instanceof PointcutDec) {
-// for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
-// ASTObject node = (ASTObject)it.next();
-// if (node instanceof PointcutDec || node instanceof AdviceDec) {
-// pointcutUsedBy.add(StructureNodeFactory.makeLink(node, false));
-// }
-// }
-// for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
-// ASTObject node = (ASTObject)it.next();
-// if (node instanceof PointcutDec) {
-// pointcutsUsed.add(StructureNodeFactory.makeLink(node, false));
-// }
-// }
-// } else if (astObject instanceof MethodDec) {
-// Method method = ((MethodDec)astObject).getMethod();
-// TypeDs throwsDs = method.getThrows();
-// if (throwsDs != null) {
-// for (Iterator it = throwsDs.iterator(); it.hasNext(); ) {
-// Object o = it.next();
-// if (o instanceof ResolvedTypeD) {
-// ResolvedTypeD resolved = (ResolvedTypeD)o;
-// if (resolved.getType().getCorrespondingDec() != null) {
-// throwsTypes.add(StructureNodeFactory.makeLink(resolved.getType().getCorrespondingDec(), false));
-// }
-// }
-// }
-// }
-// if (!(method.getReturnType() instanceof PrimitiveType) && method.getReturnType().getCorrespondingDec() != null) {
-// usesType.add(StructureNodeFactory.makeLink(method.getReturnType().getCorrespondingDec(), false));
-// }
-// } else if (astObject instanceof FieldDec) {
-// Field field = ((FieldDec)astObject).getField();
-// if (!(field.getFieldType() instanceof PrimitiveType) && field.getFieldType().getCorrespondingDec() != null) {
-// usesType.add(StructureNodeFactory.makeLink(field.getFieldType().getCorrespondingDec(), false));
-// }
-// }
-// else if (astObject instanceof CompilationUnit) {
-// CompilationUnit cu = (CompilationUnit)astObject;
-// org.aspectj.compiler.base.ast.Imports cuImports = cu.getImports();
-// for (int i = 0; cuImports != null && i < cuImports.getChildCount(); i++) {
-// Import imp = cuImports.get(i);
-// if (!imp.getStar() && imp != null && imp.getType() != null) {
-// Type type = imp.getType();
-// Dec dec = type.getCorrespondingDec();
-// if (dec != null) imports.add(StructureNodeFactory.makeLink(dec, true));
-// }
-// }
-// }
-//
-// if (!pointcutsUsed.isEmpty()) relations.add(new RelationNode(USES_POINTCUT_RELATION, USES_POINTCUT_RELATION.getForwardNavigationName(), pointcutsUsed));
-// if (!pointcutUsedBy.isEmpty()) relations.add(new RelationNode(USES_POINTCUT_RELATION, USES_POINTCUT_RELATION.getBackNavigationName(), pointcutUsedBy));
-// if (!imports.isEmpty()) relations.add(new RelationNode(IMPORTS_RELATION, IMPORTS_RELATION.getForwardNavigationName(), imports));
- return relations;
- }
-
- public String getName() {
- return NAME;
- }
-}
-
-
-//public class JavadocSeeAlso {
-//
-// private static final String DOC =
-// "<b>Relates:</b> a declaration to another by the @seeAlso tag<br>" +
-// "<b>Symmetric: </b> yes";
-//
-// public List makeLinks(ASTObject astObject, boolean forwardNavigation) {
-// List linkList = new Vector();
-// org.aspectj.compiler.base.ast.Comment comment = astObject.getComment();
-// try {
-// Object[] os = (Object[])comment.getClass().getMethod("seeTags", new Class[]{}).invoke(comment, new Object[]{});
-// for (int i = 0; i < os.length; i++) {
-// Object o = os[i];
-// Dec docDec = null;
-// TypeDec typeDec = (TypeDec)o.getClass().getMethod("referencedClass", new Class[]{}).invoke(o, new Object[]{});
-// Dec memberDec = (Dec)o.getClass().getMethod("referencedMember", new Class[]{}).invoke(o, new Object[]{});
-// if (memberDec != null) {
-// docDec = memberDec;
-// } else if (typeDec != null) {
-// docDec = typeDec;
-// }
-// if (docDec != null) {
-// linkList.add(StructureNodeFactory.makeLink(docDec, false));
-//
-// }
-// }
-// } catch (Throwable t) {
-// // ingore
-// }
-// return linkList;
-// }
-
-
diff --git a/asm/src/org/aspectj/asm/Relation.java b/asm/src/org/aspectj/asm/Relation.java
deleted file mode 100644
index 31bfdc42f..000000000
--- a/asm/src/org/aspectj/asm/Relation.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-
-package org.aspectj.asm;
-
-import java.io.Serializable;
-
-/**
- * @author Mik Kersten
- */
-public class Relation implements Serializable {
-
- private String forwardNavigationName;
- private String backNavigationName;
- private String associationName;
- private boolean symmetrical;
- private boolean transitive;
-
- public Relation(String forwardNavigationName,
- String backNavigationName,
- String associationName,
- boolean symmetrical,
- boolean transitive) {
- this.forwardNavigationName = forwardNavigationName;
- this.backNavigationName = backNavigationName;
- this.associationName = associationName;
- this.symmetrical = symmetrical;
- this.transitive = transitive;
- }
-
- /**
- * Constructor for asymetrical relations.
- */
- public Relation(String forwardNavigationName,
- String associationName,
- boolean transitive) {
- this(forwardNavigationName, "<no back navigation name>", associationName, false, transitive);
- }
-
- public String getForwardNavigationName() {
- return forwardNavigationName;
- }
-
- public String getBackNavigationName() {
- return backNavigationName;
- }
-
- public String getAssociationName() {
- return associationName;
- }
-
- public boolean isSymmetrical() {
- return symmetrical;
- }
-
- public boolean isTransitive() {
- return transitive;
- }
-
- public boolean equals(Object o) {
- if (!(o instanceof Relation)) return false;
- Relation r = (Relation)o;
- return forwardNavigationName.equals(r.getForwardNavigationName())
- && backNavigationName.equals(r.getBackNavigationName())
- && associationName.equals(r.getAssociationName())
- && (symmetrical == r.isSymmetrical())
- && (transitive == r.isTransitive());
- }
-
- public String toString() {
- if (symmetrical) {
- return forwardNavigationName + " / " + backNavigationName;
- } else {
- return forwardNavigationName;
- }
- }
-}
diff --git a/asm/src/org/aspectj/asm/RelationNode.java b/asm/src/org/aspectj/asm/RelationNode.java
deleted file mode 100644
index ec4c51357..000000000
--- a/asm/src/org/aspectj/asm/RelationNode.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.List;
-
-/**
- * @author Mik Kersten
- */
-public class RelationNode extends StructureNode {
-
- private Relation relation;
-
- /**
- * Used during de-externalization.
- */
- public RelationNode() { }
-
- public RelationNode(Relation relation, String name, List children) {
- super(name, relation.getAssociationName(), children);
- this.relation = relation;
- }
-
- public Relation getRelation() {
- return relation;
- }
-}
diff --git a/asm/src/org/aspectj/asm/StructureModel.java b/asm/src/org/aspectj/asm/StructureModel.java
index 3998c41bb..65b596d05 100644
--- a/asm/src/org/aspectj/asm/StructureModel.java
+++ b/asm/src/org/aspectj/asm/StructureModel.java
@@ -14,11 +14,10 @@
package org.aspectj.asm;
-import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
+import java.io.*;
import java.util.*;
+import org.aspectj.asm.internal.ProgramElement;
import org.aspectj.bridge.SourceLocation;
/**
@@ -26,16 +25,16 @@ import org.aspectj.bridge.SourceLocation;
*/
public class StructureModel implements Serializable {
- protected StructureNode root = null;
+ protected IProgramElement root = null;
protected String configFile = null;
private Map fileMap = null;
- public static final ProgramElementNode NO_STRUCTURE = new ProgramElementNode("<build to view structure>", ProgramElementNode.Kind.ERROR, null);
+ public static final IProgramElement NO_STRUCTURE = new ProgramElement("<build to view structure>", IProgramElement.Kind.ERROR, null);
- public StructureNode getRoot() {
+ public IProgramElement getRoot() {
return root;
}
- public void setRoot(StructureNode root) {
+ public void setRoot(IProgramElement root) {
this.root = root;
}
@@ -71,14 +70,14 @@ public class StructureModel implements Serializable {
* @param decErrLabel
* @return null if not found
*/
- public ProgramElementNode findNode(ProgramElementNode parent, ProgramElementNode.Kind kind, String name) {
+ public IProgramElement findNode(IProgramElement parent, IProgramElement.Kind kind, String name) {
for (Iterator it = parent.getChildren().iterator(); it.hasNext(); ) {
- ProgramElementNode node = (ProgramElementNode)it.next();
- if (node.getProgramElementKind().equals(kind)
+ IProgramElement node = (IProgramElement)it.next();
+ if (node.getKind().equals(kind)
&& name.equals(node.getName())) {
return node;
} else {
- ProgramElementNode childSearch = findNode(node, kind, name);
+ IProgramElement childSearch = findNode(node, kind, name);
if (childSearch != null) return childSearch;
}
}
@@ -89,13 +88,13 @@ public class StructureModel implements Serializable {
* @param packageName if null default package is searched
* @param className can't be null
*/
- public ProgramElementNode findNodeForClass(String packageName, String className) {
- StructureNode packageNode = null;
+ public IProgramElement findNodeForClass(String packageName, String className) {
+ IProgramElement packageNode = null;
if (packageName == null) {
packageNode = root;
} else {
for (Iterator it = root.getChildren().iterator(); it.hasNext(); ) {
- StructureNode node = (StructureNode)it.next();
+ IProgramElement node = (IProgramElement)it.next();
if (packageName.equals(node.getName())) {
packageNode = node;
}
@@ -105,15 +104,15 @@ public class StructureModel implements Serializable {
// this searches each file for a class
for (Iterator it = packageNode.getChildren().iterator(); it.hasNext(); ) {
- ProgramElementNode fileNode = (ProgramElementNode)it.next();
- ProgramElementNode ret = findClassInNodes(fileNode.getChildren(), className);
+ IProgramElement fileNode = (IProgramElement)it.next();
+ IProgramElement ret = findClassInNodes(fileNode.getChildren(), className);
if (ret != null) return ret;
}
return null;
}
- private ProgramElementNode findClassInNodes(Collection nodes, String name) {
+ private IProgramElement findClassInNodes(Collection nodes, String name) {
String baseName;
String innerName;
int dollar = name.indexOf('$');
@@ -127,7 +126,7 @@ public class StructureModel implements Serializable {
for (Iterator j = nodes.iterator(); j.hasNext(); ) {
- ProgramElementNode classNode = (ProgramElementNode)j.next();
+ IProgramElement classNode = (IProgramElement)j.next();
// System.err.println("checking: " + classNode + " for " + baseName);
// System.err.println("children: " + classNode.getChildren());
if (baseName.equals(classNode.getName())) {
@@ -145,14 +144,14 @@ public class StructureModel implements Serializable {
* @param sourceFilePath modified to '/' delimited path for consistency
* @return a new structure node for the file if it was not found in the model
*/
- public StructureNode findRootNodeForSourceFile(String sourceFile) {
+ public IProgramElement findRootNodeForSourceFile(String sourceFile) {
try {
if (!isValid() || sourceFile == null) {
return StructureModel.NO_STRUCTURE;
} else {
String correctedPath = new File(sourceFile).getCanonicalPath();//.replace('\\', '/');
//StructureNode node = (StructureNode)getFileMap().get(correctedPath);//findFileNode(filePath, model);
- StructureNode node = (StructureNode)findInFileMap(correctedPath);//findFileNode(filePath, model);
+ IProgramElement node = (IProgramElement)findInFileMap(correctedPath);//findFileNode(filePath, model);
if (node != null) {
return node;
} else {
@@ -171,9 +170,9 @@ public class StructureModel implements Serializable {
* @param lineNumber if 0 or 1 the corresponding file node will be returned
* @return a new structure node for the file if it was not found in the model
*/
- public StructureNode findNodeForSourceLine(String sourceFilePath, int lineNumber) {
+ public IProgramElement findNodeForSourceLine(String sourceFilePath, int lineNumber) {
String correctedPath = sourceFilePath;//.replace('\\', '/');
- StructureNode node = findNodeForSourceLineHelper(root, correctedPath, lineNumber);
+ IProgramElement node = findNodeForSourceLineHelper(root, correctedPath, lineNumber);
if (node != null) {
return node;
} else {
@@ -181,16 +180,16 @@ public class StructureModel implements Serializable {
}
}
- private StructureNode createFileStructureNode(String sourceFilePath) {
+ private IProgramElement createFileStructureNode(String sourceFilePath) {
String fileName = new File(sourceFilePath).getName();
- ProgramElementNode fileNode = new ProgramElementNode(fileName, ProgramElementNode.Kind.FILE_JAVA, null);
+ IProgramElement fileNode = new ProgramElement(fileName, IProgramElement.Kind.FILE_JAVA, null);
fileNode.setSourceLocation(new SourceLocation(new File(sourceFilePath), 1, 1));
fileNode.addChild(NO_STRUCTURE);
return fileNode;
}
- private StructureNode findNodeForSourceLineHelper(StructureNode node, String sourceFilePath, int lineNumber) {
+ private IProgramElement findNodeForSourceLineHelper(IProgramElement node, String sourceFilePath, int lineNumber) {
if (matches(node, sourceFilePath, lineNumber)
&& !hasMoreSpecificChild(node, sourceFilePath, lineNumber)) {
return node;
@@ -198,8 +197,8 @@ public class StructureModel implements Serializable {
if (node != null && node.getChildren() != null) {
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
- StructureNode foundNode = findNodeForSourceLineHelper(
- (StructureNode)it.next(),
+ IProgramElement foundNode = findNodeForSourceLineHelper(
+ (IProgramElement)it.next(),
sourceFilePath,
lineNumber);
if (foundNode != null) return foundNode;
@@ -209,7 +208,7 @@ public class StructureModel implements Serializable {
return null;
}
- private boolean matches(StructureNode node, String sourceFilePath, int lineNumber) {
+ private boolean matches(IProgramElement node, String sourceFilePath, int lineNumber) {
try {
// if (node != null && node.getSourceLocation() != null)
// System.err.println("====\n1: " +
@@ -224,17 +223,17 @@ public class StructureModel implements Serializable {
&& node.getSourceLocation().getEndLine() >= lineNumber)
||
(lineNumber <= 1
- && node instanceof ProgramElementNode
- && ((ProgramElementNode)node).getProgramElementKind().isSourceFileKind())
+ && node instanceof IProgramElement
+ && ((IProgramElement)node).getKind().isSourceFileKind())
);
} catch (IOException ioe) {
return false;
}
}
- private boolean hasMoreSpecificChild(StructureNode node, String sourceFilePath, int lineNumber) {
+ private boolean hasMoreSpecificChild(IProgramElement node, String sourceFilePath, int lineNumber) {
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
- ProgramElementNode child = (ProgramElementNode)it.next();
+ IProgramElement child = (IProgramElement)it.next();
if (matches(child, sourceFilePath, lineNumber)) return true;
}
return false;
diff --git a/asm/src/org/aspectj/asm/StructureModelManager.java b/asm/src/org/aspectj/asm/StructureModelManager.java
index 1464a1eaf..c99b747ad 100644
--- a/asm/src/org/aspectj/asm/StructureModelManager.java
+++ b/asm/src/org/aspectj/asm/StructureModelManager.java
@@ -34,10 +34,10 @@ public class StructureModelManager {
private List associations = new ArrayList();
protected StructureModelManager() {
- associations.add(new AdviceAssociation());
- associations.add(new IntroductionAssociation());
- associations.add(new InheritanceAssociation());
- associations.add(new ReferenceAssociation());
+// associations.add(new AdviceAssociation());
+// associations.add(new IntroductionAssociation());
+// associations.add(new InheritanceAssociation());
+// associations.add(new ReferenceAssociation());
}
public StructureModel getStructureModel() {
@@ -59,62 +59,64 @@ public class StructureModelManager {
boolean showSubMember,
boolean showMemberAndType) {
- if (!model.isValid()) return null;
-
- HashMap annotations = new HashMap();
- StructureNode node = model.findRootNodeForSourceFile(sourceFile);
- if (node == StructureModel.NO_STRUCTURE) {
- return null;
- } else {
- ProgramElementNode fileNode = (ProgramElementNode)node;
- ArrayList peNodes = new ArrayList();
- getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType);
- for (Iterator it = peNodes.iterator(); it.hasNext(); ) {
- ProgramElementNode peNode = (ProgramElementNode)it.next();
- List entries = new ArrayList();
- entries.add(peNode);
- ISourceLocation sourceLoc = peNode.getSourceLocation();
- if (null != sourceLoc) {
- Integer hash = new Integer(sourceLoc.getLine());
- List existingEntry = (List)annotations.get(hash);
- if (existingEntry != null) {
- entries.addAll(existingEntry);
- }
- annotations.put(hash, entries);
- }
- }
- return annotations;
- }
- }
-
- private void getAllStructureChildren(ProgramElementNode node, List result, boolean showSubMember, boolean showMemberAndType) {
- List children = node.getChildren();
- for (Iterator it = children.iterator(); it.hasNext(); ) {
- StructureNode next = (StructureNode)it.next();
- if (next instanceof ProgramElementNode) {
- ProgramElementNode pNode = (ProgramElementNode)next;
- if (pNode != null
- && ((pNode.isCode() && showSubMember) || (!pNode.isCode() && showMemberAndType))
- && pNode.getRelations() != null
- && pNode.getRelations().size() > 0) {
- result.add(next);
- }
- getAllStructureChildren((ProgramElementNode)next, result, showSubMember, showMemberAndType);
- }
- }
+ throw new RuntimeException("unimplemented");
+
+// if (!model.isValid()) return null;
+//
+// HashMap annotations = new HashMap();
+// IProgramElement node = model.findRootNodeForSourceFile(sourceFile);
+// if (node == StructureModel.NO_STRUCTURE) {
+// return null;
+// } else {
+// IProgramElement fileNode = (IProgramElement)node;
+// ArrayList peNodes = new ArrayList();
+// getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType);
+// for (Iterator it = peNodes.iterator(); it.hasNext(); ) {
+// IProgramElement peNode = (IProgramElement)it.next();
+// List entries = new ArrayList();
+// entries.add(peNode);
+// ISourceLocation sourceLoc = peNode.getSourceLocation();
+// if (null != sourceLoc) {
+// Integer hash = new Integer(sourceLoc.getLine());
+// List existingEntry = (List)annotations.get(hash);
+// if (existingEntry != null) {
+// entries.addAll(existingEntry);
+// }
+// annotations.put(hash, entries);
+// }
+// }
+// return annotations;
+// }
}
- public void addListener(StructureModelListener listener) {
+// private void getAllStructureChildren(IProgramElement node, List result, boolean showSubMember, boolean showMemberAndType) {
+// List children = node.getChildren();
+// for (Iterator it = children.iterator(); it.hasNext(); ) {
+// IProgramElement next = (IProgramElement)it.next();
+// if (next instanceof IProgramElement) {
+// IProgramElement pNode = (IProgramElement)next;
+// if (pNode != null
+// && ((pNode.isCode() && showSubMember) || (!pNode.isCode() && showMemberAndType))
+// && pNode.getRelations() != null
+// && pNode.getRelations().size() > 0) {
+// result.add(next);
+// }
+// getAllStructureChildren((IProgramElement)next, result, showSubMember, showMemberAndType);
+// }
+// }
+// }
+
+ public void addListener(IStructureModelListener listener) {
structureListeners.add(listener);
}
- public void removeStructureListener(StructureModelListener listener) {
+ public void removeStructureListener(IStructureModelListener listener) {
structureListeners.remove(listener);
}
private void notifyListeners() {
for (Iterator it = structureListeners.iterator(); it.hasNext(); ) {
- ((StructureModelListener)it.next()).modelUpdated(model);
+ ((IStructureModelListener)it.next()).modelUpdated(model);
}
}
diff --git a/asm/src/org/aspectj/asm/StructureNode.java b/asm/src/org/aspectj/asm/StructureNode.java
deleted file mode 100644
index 2c3322ab9..000000000
--- a/asm/src/org/aspectj/asm/StructureNode.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.*;
-import java.io.*;
-
-import org.aspectj.bridge.*;
-import org.aspectj.bridge.IMessage;
-
-/**
- * Children are non-repeating making the parent-child structure a strict
- * tree.
- *
- * !!! relies on a java.io.Serializable implementation of ISourceLocation
- *
- * @author Mik Kersten
- */
-public abstract class StructureNode implements Serializable, Comparable {
-
- protected StructureNode parent = null;
- protected String name = "";
- protected String kind = "";
- // children.listIterator() should support remove() operation
- protected List children = new ArrayList();
- protected IMessage message = null;
- protected ISourceLocation sourceLocation = null;
-
- /**
- * Used during serialization.
- */
- public StructureNode() { }
-
- public StructureNode(String name, String kind, List children) {
- this.name = name;
- this.kind = kind;
- if (children != null) {
- this.children = children;
- }
- setParents();
- }
-
- public StructureNode(String name, String kind) {
- this.name = name;
- this.kind = kind;
- }
-
- public String toLongString() {
- final StringBuffer buffer = new StringBuffer();
- ModelWalker walker = new ModelWalker() {
- private int depth = 0;
-
- public void preProcess(StructureNode node) {
- for (int i = 0; i < depth; i++) buffer.append(' ');
- buffer.append(node.toString());
- buffer.append('\n');
- depth += 2;
- }
-
- public void postProcess(StructureNode node) {
- depth -= 2;
- }
- };
- walker.process(this);
- return buffer.toString();
- }
-
- public String toString() {
- return name;
- }
-
- public String getKind() {
- return kind;
- }
-
- public List getChildren() {
- return children;
- }
-
- public void addChild(StructureNode child) {
- if (children == null) {
- children = new ArrayList();
- }
- children.add(child);
- child.setParent(this);
- }
-
- public void addChild(int position, StructureNode child) {
- if (children == null) {
- children = new ArrayList();
- }
- children.add(position, child);
- child.setParent(this);
- }
-
- public boolean removeChild(StructureNode child) {
- child.setParent(null);
- return children.remove(child);
- }
-
- public StructureNode walk(ModelWalker walker) {
- for (Iterator it = children.iterator(); it.hasNext(); ) {
- StructureNode child = (StructureNode)it.next();
- walker.process(child);
- }
- return this;
- }
-
-// public boolean equals(Object o) {
-// if (!(o instanceof StructureNode)) return false;
-// StructureNode sn = (StructureNode)o;
-// return objectEqual(sn.getName(), this.getName())
-// && objectEqual(sn.getKind(), this.getKind())
-// && objectEqual(sn.getChildren(), this.getChildren());
-// }
-//
-// protected boolean objectEqual(Object o1, Object o2) {
-// return (o1 == null && o2 == null) || (o1 != null && o1.equals(o2));
-// }
-
- /**
- * Comparison is string-name based only.
- */
- public int compareTo(Object o) throws ClassCastException {
- if (this == o) {
- return 0;
- } else {
- StructureNode sn = (StructureNode)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 StructureNode getParent() {
- return parent;
- }
-
- public void setParent(StructureNode parent) {
- this.parent = parent;
- }
-
- private void setParents() {
- if (children == null) return;
- for (Iterator it = children.iterator(); it.hasNext(); ) {
- ((StructureNode)it.next()).setParent(this);
- }
- }
-//
-// /**
-// * Creates and returns a copy of this object.
-// */
-// public Object clone() {
-// List cloneChildren = new ArrayList();
-// for (Iterator it = children.iterator(); it.hasNext(); ) {
-// cloneChildren.add(((StructureNode)it.next()).clone());
-// }
-// StructureNode cloneNode = new StructureNode(name, kind, cloneChildren);
-// return cloneNode;
-// }
-
- public void setName(String string) {
- name = string;
- }
-
-}
-
-
-// private void writeObject(ObjectOutputStream s) throws IOException {
-// s.defaultWriteObject();
-// // customized serialization code
-// }
-//
-// private void readObject(ObjectInputStream s) throws IOException {
-// s.defaultReadObject();
-// // customized deserialization code
-// ...
-// // followed by code to update the object, if necessary
-// }
-
-// public void writeExternal(ObjectOutput out) throws IOException {
-// if (this instanceof ProgramElementNode) {
-// out.writeInt(1);
-// writeString(name, out);
-// writeString(kind, out);
-// ((ProgramElementNode)this).writeExternal(out);
-// } if (this instanceof RelationNode) {
-// out.writeInt(1);
-// writeString(name, out);
-// writeString(kind, out);
-// ((RelationNode)this).writeExternal(out);
-// } if (this instanceof LinkNode) {
-// out.writeInt(3);
-// writeString(name, out);
-// writeString(kind, out);
-// ((LinkNode)this).writeExternal(out);
-// } else {
-// out.writeInt(0);
-// writeString(name, out);
-// writeString(kind, out);
-// }
-// }
-//
-// public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-// int kindint = in.readInt();
-// name = readString(in);
-// kind = readString(in);
-//
-// switch (kindint) {
-// case 1:
-// ((StructureNode)it.next()).readExternal(in);
-// break;
-// case 2:
-// ((RelationNode)it.next()).readExternal(in);
-// break;
-// case 3:
-// ((LinkNode)it.next()).readExternal(in);
-// break;
-// }
-// }
-//
-// protected void writeString(String s, ObjectOutput out) throws IOException {
-// out.writeInt(s.length());
-// out.write(s.getBytes());
-// }
-//
-// protected String readString(ObjectInput in) throws IOException {
-// int length = in.readInt();
-// byte[] nameArray = new byte[length];
-// in.read(nameArray, 0, length);
-// return new String(nameArray);
-// }
-//
-
-
diff --git a/asm/src/org/aspectj/asm/StructureNodeFactory.java b/asm/src/org/aspectj/asm/StructureNodeFactory.java
deleted file mode 100644
index 40428739d..000000000
--- a/asm/src/org/aspectj/asm/StructureNodeFactory.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.asm;
-
-import java.util.Hashtable;
-import java.util.List;
-
-/**
- * @author Mik Kersten
- */
-public class StructureNodeFactory {
-
- private static Hashtable programElementNodes = new Hashtable();
-
- private static final ProgramElementNode UNRESOLVED_LINK_NODE = new ProgramElementNode("<error: unresolved link>", ProgramElementNode.Kind.ERROR, null, null, "", "", "", null, null, null, false);
-
- public static void clear() {
- programElementNodes.clear();
- }
-
- public static ProgramElementNode makeNode(List relations, List children) {
- return makeNode(relations, children, false);
- }
-
- public static LinkNode makeLink(boolean terminal) {
- ProgramElementNode peNode = null;
- if (terminal) {
- peNode = makeNode(null, null, false);
- } else {
- peNode = makeNode(null, null, true);
- }
-
- if (peNode == null) {
- return new LinkNode(UNRESOLVED_LINK_NODE);
- } else {
- return new LinkNode(peNode);
- }
- }
-
- private static ProgramElementNode makeNode(List relations, List children, boolean resolve) {
-// if (resolve) {
-// if (astObject instanceof InitializerDec) {
-// InitializerDec initDec = (InitializerDec)astObject;
-// return (ProgramElementNode)programElementNodes.get(initDec.getDeclaringType().getTypeDec());
-// } else if (astObject instanceof Decs) {
-// Decs decs = (Decs)astObject;
-// return (ProgramElementNode)programElementNodes.get(decs.getDeclaringType().getTypeDec());
-// } else {
-// ProgramElementNode peNode = (ProgramElementNode)programElementNodes.get(astObject);
-// if (peNode == null) {
-// return makeNode(astObject, null, null, false);
-// } else {
-// return peNode;
-// }
-// }
-// } else {
-// String declaringType = "";
-// if (astObject.getDeclaringType() != null) {
-// declaringType = astObject.getDeclaringType().toShortString();
-// }
-//
-// org.aspectj.asm.SourceLocation sourceLocation = new org.aspectj.asm.SourceLocation(
-// astObject.getSourceLocation().getSourceFileName(),
-// astObject.getSourceLocation().getBeginLine(),
-// astObject.getSourceLocation().getEndLine(),
-// astObject.getSourceLocation().getBeginColumn());
-//
-// ProgramElementNode newNode = new ProgramElementNode(
-// genSignature(astObject).trim(),
-// genKind(astObject),
-// genModifiers(astObject),
-// genAccessibility(astObject),
-// declaringType,
-// genPackageName(astObject),
-// genFormalComment(astObject),
-// sourceLocation,
-// relations,
-// children,
-// isMemberKind(astObject),
-// astObject);
-// programElementNodes.put(astObject, newNode);
-// newNode.setRunnable(genIsRunnable(newNode));
-// setSpecifiers(astObject, newNode);
-//
-// return newNode;
-// }
- return null;
- }
-
-// private static void setSpecifiers(ASTObject astObject, ProgramElementNode node) {
-// if (astObject instanceof MethodDec) {
-// Method method = ((MethodDec)astObject).getMethod();
-// for (Iterator it = method.getDeclaringType().getDirectSuperTypes().iterator(); it.hasNext(); ) {
-// NameType type = (NameType)it.next();
-// SemanticObject so = type.findMatchingSemanticObject(method);
-//
-// if (so != null && so instanceof Method) {
-//
-// Method superMethod = (Method)so;
-// if (so.isAbstract()) {
-// node.setImplementor(true);
-// } else {
-// node.setOverrider(true);
-// }
-// }
-// }
-// }
-// }
-//
-// private static boolean genIsRunnable(ProgramElementNode node) {
-// if (node.getModifiers().contains(ProgramElementNode.Modifiers.STATIC)
-// && node.getAccessibility().equals(ProgramElementNode.Accessibility.PUBLIC)
-// && node.getSignature().equals("main(String[])")) {
-// return true;
-// } else {
-// return false;
-// }
-// }
-//
-// private static boolean genIsStmntKind(ASTObject astObject) {
-// return astObject instanceof CatchClause
-// || astObject instanceof SOLink
-// || astObject instanceof BasicAssignExpr;
-// }
-//
-// private static List genModifiers(ASTObject astObject) {
-// List modifiers = new ArrayList();
-// if (astObject instanceof Dec) {
-// Dec dec = (Dec)astObject;
-// if (dec.getModifiers().isStrict()) modifiers.add(ProgramElementNode.Modifiers.STRICTFP);
-// if (dec.getModifiers().isAbstract()) modifiers.add(ProgramElementNode.Modifiers.ABSTRACT);
-// if (dec.getModifiers().isSynchronized()) modifiers.add(ProgramElementNode.Modifiers.SYNCHRONIZED);
-// if (dec.getModifiers().isNative()) modifiers.add(ProgramElementNode.Modifiers.NATIVE);
-// if (dec.getModifiers().isFinal()) modifiers.add(ProgramElementNode.Modifiers.FINAL);
-// if (dec.getModifiers().isTransient()) modifiers.add(ProgramElementNode.Modifiers.TRANSIENT);
-// if (dec.getModifiers().isStatic()) modifiers.add(ProgramElementNode.Modifiers.STATIC);
-// if (dec.getModifiers().isVolatile()) modifiers.add(ProgramElementNode.Modifiers.VOLATILE);
-// }
-// return modifiers;
-// }
-//
-// private static ProgramElementNode.Accessibility genAccessibility(ASTObject astObject) {
-// //List modifiers = new ArrayList();
-// if (astObject instanceof Dec) {
-// Dec dec = (Dec)astObject;
-// if (dec.getModifiers().isPublic()) return ProgramElementNode.Accessibility.PUBLIC;
-// if (dec.getModifiers().isProtected()) return ProgramElementNode.Accessibility.PROTECTED;
-// if (dec.getModifiers().isPrivileged()) return ProgramElementNode.Accessibility.PRIVILEGED;
-// if (dec.getModifiers().isPackagePrivate()) return ProgramElementNode.Accessibility.PACKAGE;
-// if (dec.getModifiers().isPrivate()) return ProgramElementNode.Accessibility.PRIVATE;
-// }
-// return ProgramElementNode.Accessibility.PUBLIC;
-// }
-//
-// /**
-// * @todo special cases should be fixes to AST nodes, this should have no instanceof tests.
-// */
-// private static ProgramElementNode.Kind genKind(ASTObject astObject) {
-// if (astObject instanceof CompilationUnit) {
-// return ProgramElementNode.Kind.FILE_JAVA;
-// } else if (genIsStmntKind(astObject)) {
-// return ProgramElementNode.Kind.CODE;
-// } else if (astObject instanceof Dec) {
-// String kindString = ((Dec)astObject).getKind();
-// return ProgramElementNode.Kind.getKindForString(kindString);
-// } else {
-// return ProgramElementNode.Kind.ERROR;
-// }
-// }
-//
-// private static boolean isMemberKind(ASTObject astObject) {
-// if (astObject instanceof Dec) {
-// Dec dec = (Dec)astObject;
-// return dec.getDeclaringType() != null && !dec.getDeclaringType().equals(dec.getName());
-// } else {
-// return false;
-// }
-// }
-//
-// private static String genPackageName(ASTObject astObject) {
-// if (astObject instanceof TypeDec) {
-// return ((TypeDec)astObject).getPackageName();
-// } else if (astObject instanceof CompilationUnit) {
-// return ((CompilationUnit)astObject).getPackageName();
-// } else if (astObject.getDeclaringType() != null) {
-// return astObject.getDeclaringType().getPackageName();
-// } else {
-// return "";
-// }
-// }
-//
-// private static String genDeclaringType(ASTObject astObject) {
-// if (astObject != null && astObject.getDeclaringType() != null) {
-// return astObject.getDeclaringType().toShortString();
-// } else {
-// return null;
-// }
-// }
-//
-// /**
-// * Tries to return the ajdoc generated comment, otherwise returns the raw comment.
-// */
-// private static String genFormalComment(ASTObject astObject) {
-// try {
-// return (String)astObject.getComment().getClass().getMethod("commentText", new Class[]{}).invoke(astObject.getComment(), new Object[]{});
-// } catch (Throwable t) {
-// if (astObject != null) {
-// return astObject.getFormalComment();
-// } else {
-// return "";
-// }
-// }
-// }
-//
-// /**
-// * Specialized signature generation for nodes in the structure model.
-// *
-// * @todo the compiler should generate these names, doing it this way is atrocious
-// */
-// private static String genSignature(ASTObject astObject) {
-// String name = "";
-// if (astObject instanceof CompilationUnit) {
-// return astObject.getSourceFile().getName();
-// } else if (astObject instanceof MethodDec) {
-// Method method = ((MethodDec)astObject).getMethod();
-// return method.getName() + method.getFormals().toShortString();
-// } else if (astObject instanceof TypeDec) {
-// return ((TypeDec)astObject).getSourceExtendedId();
-// } else if (astObject instanceof FieldDec) {
-// return ((FieldDec)astObject).getName();
-// } else if (astObject instanceof ConstructorDec) {
-// ConstructorDec constructorDec = (ConstructorDec)astObject;
-// return constructorDec.getDeclaringType().getSourceExtendedId() + constructorDec.getFormals().toShortString();
-// } else if (astObject instanceof IntroducedDec) {
-// IntroducedDec introDec = (IntroducedDec)astObject;
-// return introDec.getTargets().toShortString() + '.' + genSignature(introDec.getDec());
-//// introDec.toShortString();
-// } else if (astObject instanceof PointcutDec) {
-// PointcutDec pointcutDec = (PointcutDec)astObject;
-// return pointcutDec.getName() + pointcutDec.getFormals().toShortString();
-//// } else if (astObject instanceof CallExpr) {
-//// CallExpr call = (CallExpr)astObject;
-//// name = call.get;
-// } else if (astObject instanceof ShowErrorDec) {
-// ShowErrorDec errorDec = (ShowErrorDec)astObject;
-// return errorDec.toShortString();
-// } else if (astObject instanceof SoftThrowableDec) {
-// SoftThrowableDec softThrowableDec = (SoftThrowableDec)astObject;
-// return softThrowableDec.toShortString();
-// } else if (astObject instanceof IntroducedSuperDec) {
-// IntroducedSuperDec introducedSuperDec = (IntroducedSuperDec)astObject;
-// return introducedSuperDec.toShortString();
-// } else if (astObject instanceof AdviceDec) {
-// AdviceDec adviceDec = (AdviceDec)astObject;
-// return adviceDec.toShortString();
-// } else if (astObject instanceof SOLink) {
-// SOLink soLink = (SOLink)astObject;
-// return genSignature(soLink.getTarget().getCorrespondingDec());
-// } else if (astObject instanceof CatchClause) {
-// CatchClause catchClause = (CatchClause)astObject;
-// return catchClause.getFormal().getType().getSourceExtendedId();
-// } else if (astObject instanceof BasicAssignExpr) {
-// return astObject.unparse();
-//// } else if (genIsStmntKind(astObject)) {
-//// name = astObject.unparse();
-//// name = name.replace('/', ' ');
-//// name = name.replace('*', ' ');
-//// name = name.replace('\n', ' ');
-//// name.trim();
-//// java.util.StringTokenizer st = new java.util.StringTokenizer(name, " ");
-//// String s = "";
-//// while (st.hasMoreElements()) {
-//// s += ((String)st.nextElement()).trim() + " ";
-//// }
-//// name = s;
-//// int endIndex = name.indexOf(')');
-//// if (endIndex != -1) {
-//// name = name.substring(0, endIndex+1);
-//// }
-//// if (name.startsWith("this.")) {
-//// name = name.substring(5);
-//// }
-// } else {
-// return "? " + astObject.toShortString();
-// }
-// }
-}
diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java
new file mode 100644
index 000000000..5fd769e02
--- /dev/null
+++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java
@@ -0,0 +1,364 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * ******************************************************************/
+
+
+package org.aspectj.asm.internal;
+
+import java.util.*;
+
+import org.aspectj.asm.*;
+import org.aspectj.bridge.*;
+import org.aspectj.bridge.IMessage.Kind;
+
+
+/**
+ * @author Mik Kersten
+ */
+public class ProgramElement implements IProgramElement {
+
+ protected IProgramElement parent = null;
+ protected String name = "";
+ // children.listIterator() should support remove() operation
+ protected List children = new ArrayList();
+ protected IMessage message = null;
+ protected ISourceLocation sourceLocation = null;
+
+ private List modifiers = new ArrayList();
+ private List relations = new ArrayList();
+
+ private Kind kind;
+ private Accessibility accessibility;
+ private String declaringType = "";
+ private String formalComment = "";
+ private String packageName = null;
+ private boolean runnable = false;
+ private boolean implementor = false;
+ private boolean overrider = false;
+
+ private String bytecodeName;
+ private String bytecodeSignature;
+ private String fullSignature;
+ private String returnType;
+
+ /**
+ * Used during de-externalization.
+ */
+ public ProgramElement() { }
+
+ /**
+ * Use to create program element nodes that do not correspond to source locations.
+ */
+ public ProgramElement(
+ String name,
+ Kind kind,
+ List children) {
+ this.name = name;
+ this.kind = kind;
+ setChildren(children);
+// System.err.println("> created: " + name + ", children: " + children);
+ }
+
+ public ProgramElement(
+ String name,
+ IProgramElement.Kind kind,
+ ISourceLocation sourceLocation,
+ int modifiers,
+ String formalComment,
+ List children)
+ {
+ this(name, kind, children);
+ this.sourceLocation = sourceLocation;
+ this.kind = kind;
+ this.formalComment = formalComment;
+ this.modifiers = genModifiers(modifiers);
+ this.accessibility = genAccessibility(modifiers);
+ }
+
+ /**
+ * Use to create program element nodes that correspond to source locations.
+ */
+ public ProgramElement(
+ String name,
+ Kind kind,
+ List modifiers,
+ Accessibility accessibility,
+ String declaringType,
+ String packageName,
+ String formalComment,
+ ISourceLocation sourceLocation,
+ List relations,
+ List children,
+ boolean member) {
+
+ this(name, kind, children);
+ this.sourceLocation = sourceLocation;
+ this.kind = kind;
+ this.modifiers = modifiers;
+ this.accessibility = accessibility;
+ this.declaringType = declaringType;
+ this.packageName = packageName;
+ this.formalComment = formalComment;
+ this.relations = relations;
+ }
+
+ public List getModifiers() {
+ return modifiers;
+ }
+
+ public Accessibility getAccessibility() {
+ return accessibility;
+ }
+
+ public String getDeclaringType() {
+ return declaringType;
+ }
+
+ public String getPackageName() {
+ if (kind == Kind.PACKAGE) return getSignature();
+ if (getParent() == null || !(getParent() instanceof IProgramElement)) {
+ return "";
+ }
+ return ((IProgramElement)getParent()).getPackageName();
+ }
+
+ public Kind getKind() {
+ return kind;
+ }
+
+ public String getSignature() {
+ return name;
+ }
+
+ public boolean isCode() {
+ return kind.equals(Kind.CODE);
+ }
+
+ 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 IProgramElement getParent() {
+ return parent;
+ }
+
+ public void setParent(IProgramElement parent) {
+ this.parent = parent;
+ }
+
+ public boolean isMemberKind() {
+ return kind.isMemberKind();
+ }
+
+ public void setRunnable(boolean value) {
+ this.runnable = value;
+ }
+
+ public boolean isRunnable() {
+ return runnable;
+ }
+
+ public boolean isImplementor() {
+ return implementor;
+ }
+
+ public void setImplementor(boolean value) {
+ this.implementor = value;
+ }
+
+ public boolean isOverrider() {
+ return overrider;
+ }
+
+ public void setOverrider(boolean value) {
+ this.overrider = value;
+ }
+
+ public List getRelations() {
+ return relations;
+ }
+
+ public void setRelations(List relations) {
+ if (relations.size() > 0) {
+ this.relations = relations;
+ }
+ }
+
+ public String getFormalComment() {
+ return formalComment;
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public static List genModifiers(int modifiers) {
+ List modifiersList = new ArrayList();
+ if ((modifiers & AccStatic) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
+ if ((modifiers & AccFinal) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
+ if ((modifiers & AccSynchronized) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
+ if ((modifiers & AccVolatile) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
+ if ((modifiers & AccTransient) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
+ if ((modifiers & AccNative) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
+ if ((modifiers & AccAbstract) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
+ return modifiersList;
+ }
+
+ public static IProgramElement.Accessibility genAccessibility(int modifiers) {
+ if ((modifiers & AccPublic) != 0) return IProgramElement.Accessibility.PUBLIC;
+ if ((modifiers & AccPrivate) != 0) return IProgramElement.Accessibility.PRIVATE;
+ if ((modifiers & AccProtected) != 0) return IProgramElement.Accessibility.PROTECTED;
+ if ((modifiers & AccPrivileged) != 0) return IProgramElement.Accessibility.PRIVILEGED;
+ else return IProgramElement.Accessibility.PACKAGE;
+ }
+
+
+
+ // XXX these names and values are from org.eclipse.jdt.internal.compiler.env.IConstants
+ private static int AccPublic = 0x0001;
+ private static int AccPrivate = 0x0002;
+ private static int AccProtected = 0x0004;
+ private static int AccPrivileged = 0x0006; // XXX is this right?
+ private static int AccStatic = 0x0008;
+ private static int AccFinal = 0x0010;
+ private static int AccSynchronized = 0x0020;
+ private static int AccVolatile = 0x0040;
+ private static int AccTransient = 0x0080;
+ private static int AccNative = 0x0100;
+ private static int AccInterface = 0x0200;
+ private static int AccAbstract = 0x0400;
+ private static int AccStrictfp = 0x0800;
+
+
+ public String getBytecodeName() {
+ return bytecodeName;
+ }
+
+ public String getBytecodeSignature() {
+ return bytecodeSignature;
+ }
+
+ public void setBytecodeName(String bytecodeName) {
+ this.bytecodeName = bytecodeName;
+ }
+
+ public void setBytecodeSignature(String bytecodeSignature) {
+ this.bytecodeSignature = bytecodeSignature;
+ }
+
+ public String getFullSignature() {
+ return fullSignature;
+ }
+
+ public void setFullSignature(String string) {
+ fullSignature = string;
+ }
+
+ public void setKind(Kind kind) {
+ this.kind = kind;
+ }
+
+ public void setReturnType(String returnType) {
+ this.returnType = returnType;
+ }
+
+ public String getReturnType() {
+ return returnType;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ if (children == null) return;
+ for (Iterator it = children.iterator(); it.hasNext(); ) {
+ ((IProgramElement)it.next()).setParent(this);
+ }
+ }
+
+ public void addChild(IProgramElement child) {
+ if (children == null) {
+ children = new ArrayList();
+ }
+ children.add(child);
+ child.setParent(this);
+ }
+
+ public void addChild(int position, IProgramElement child) {
+ if (children == null) {
+ children = new ArrayList();
+ }
+ children.add(position, child);
+ child.setParent(this);
+ }
+
+ public boolean removeChild(IProgramElement child) {
+ child.setParent(null);
+ return children.remove(child);
+ }
+
+ public void setName(String string) {
+ name = string;
+ }
+
+// private void setParents() {
+//// System.err.println(">> setting parents on: " + name);
+// if (children == null) return;
+// for (Iterator it = children.iterator(); it.hasNext(); ) {
+// ((IProgramElement)it.next()).setParent(this);
+// }
+// }
+
+ public IProgramElement walk(HierarchyWalker walker) {
+ for (Iterator it = children.iterator(); it.hasNext(); ) {
+ IProgramElement child = (IProgramElement)it.next();
+ walker.process(child);
+ }
+ return this;
+ }
+
+ public String toLongString() {
+ final StringBuffer buffer = new StringBuffer();
+ HierarchyWalker walker = new HierarchyWalker() {
+ private int depth = 0;
+
+ public void preProcess(IProgramElement node) {
+ for (int i = 0; i < depth; i++) buffer.append(' ');
+ buffer.append(node.toString());
+ buffer.append('\n');
+ depth += 2;
+ }
+
+ public void postProcess(IProgramElement node) {
+ depth -= 2;
+ }
+ };
+ walker.process(this);
+ return buffer.toString();
+ }
+}
+
diff --git a/asm/src/org/aspectj/asm/internal/Relationship.java b/asm/src/org/aspectj/asm/internal/Relationship.java
new file mode 100644
index 000000000..bb26501dc
--- /dev/null
+++ b/asm/src/org/aspectj/asm/internal/Relationship.java
@@ -0,0 +1,53 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Common Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * ******************************************************************/
+
+
+package org.aspectj.asm.internal;
+
+import java.util.List;
+
+import org.aspectj.asm.*;
+import org.aspectj.asm.IRelationship;
+import org.aspectj.asm.IRelationship.Kind;
+
+
+/**
+ * @author Mik Kersten
+ */
+public class Relationship implements IRelationship {
+
+ private String name = null;
+ private IProgramElement source = null;
+ private List/*IProgramElement*/ targets = null;
+ private Kind kind = null;
+
+ public Relationship(String name, IProgramElement source, List targets, Kind kind) {
+ this.name = name;
+ this.source = source;
+ this.targets = targets;
+ this.kind = kind;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public IProgramElement getSource() {
+ return null;
+ }
+
+ public List getTargets() {
+ return null;
+ }
+
+ public Kind getKind() {
+ return null;
+ }
+}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
index e9f9f0402..244ab288c 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
@@ -15,19 +15,16 @@ package org.aspectj.ajdt.internal.compiler.lookup;
import java.util.*;
-import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
-import org.aspectj.ajdt.internal.compiler.ast.AstUtil;
-import org.aspectj.ajdt.internal.core.builder.AjBuildManager;
-import org.aspectj.ajdt.internal.core.builder.AsmBuilder;
+import org.aspectj.ajdt.internal.compiler.ast.*;
+import org.aspectj.ajdt.internal.core.builder.*;
import org.aspectj.bridge.ISourceLocation;
import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.weaver.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.*;
-import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
+import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.core.compiler.CharOperation;
-
+
/**
*
* @author Jim Hugunin
@@ -300,7 +297,7 @@ public class EclipseFactory {
public void finishedCompilationUnit(CompilationUnitDeclaration unit) {
if (buildManager.doGenerateModel()) {
- AsmBuilder.build(unit, buildManager.getStructureModel());
+ AsmHierarchyBuilder.build(unit, buildManager.getStructureModel());
}
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
index ab0551dbe..162f852d0 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
@@ -13,33 +13,24 @@
package org.aspectj.ajdt.internal.core.builder;
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
import java.util.*;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
+import java.util.jar.*;
import org.aspectj.ajdt.internal.compiler.AjCompiler;
-import org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment;
-import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
+import org.aspectj.ajdt.internal.compiler.lookup.*;
import org.aspectj.ajdt.internal.compiler.parser.AjParser;
import org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter;
-import org.aspectj.asm.ProgramElementNode;
-import org.aspectj.asm.StructureModel;
-import org.aspectj.asm.StructureModelManager;
+import org.aspectj.asm.*;
+import org.aspectj.asm.internal.ProgramElement;
import org.aspectj.bridge.*;
import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelWeaver;
-import org.aspectj.weaver.bcel.BcelWorld;
-import org.aspectj.weaver.bcel.UnwovenClassFile;
-import org.eclipse.jdt.core.compiler.CharOperation;
-import org.eclipse.jdt.core.compiler.IProblem;
+import org.aspectj.weaver.bcel.*;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
+import org.eclipse.jdt.internal.compiler.batch.*;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
@@ -177,15 +168,15 @@ public class AjBuildManager {
private void setupModel() {
String rootLabel = "<root>";
StructureModel model = StructureModelManager.getDefault().getStructureModel();
- ProgramElementNode.Kind kind = ProgramElementNode.Kind.FILE_JAVA;
+ IProgramElement.Kind kind = IProgramElement.Kind.FILE_JAVA;
if (buildConfig.getConfigFile() != null) {
rootLabel = buildConfig.getConfigFile().getName();
model.setConfigFile(
buildConfig.getConfigFile().getAbsolutePath()
);
- kind = ProgramElementNode.Kind.FILE_LST;
+ kind = IProgramElement.Kind.FILE_LST;
}
- model.setRoot(new ProgramElementNode(rootLabel, kind, new ArrayList()));
+ model.setRoot(new ProgramElement(rootLabel, kind, new ArrayList()));
HashMap modelFileMap = new HashMap();
model.setFileMap(new HashMap());
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
index 3c3528975..1cdc99870 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmBuilder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
@@ -16,33 +16,32 @@ package org.aspectj.ajdt.internal.core.builder;
import java.io.*;
import java.util.*;
-import org.aspectj.ajdt.internal.compiler.ast.*;
+import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.ProgramElement;
import org.aspectj.bridge.*;
import org.aspectj.util.LangUtil;
-import org.aspectj.weaver.*;
-import org.aspectj.weaver.patterns.*;
+import org.aspectj.weaver.Member;
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.ProblemHandler;
-public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
+public class AsmHierarchyBuilder extends AbstractSyntaxTreeVisitorAdapter {
- public static void build(
+ public static void build(
CompilationUnitDeclaration unit,
StructureModel structureModel) {
LangUtil.throwIaxIfNull(unit, "unit");
-
- new AsmBuilder(unit.compilationResult()).internalBuild(unit, structureModel);
+ new AsmHierarchyBuilder(unit.compilationResult()).internalBuild(unit, structureModel);
}
private final Stack stack;
private final CompilationResult currCompilationResult;
private AsmNodeFormatter formatter = new AsmNodeFormatter();
- protected AsmBuilder(CompilationResult result) {
+ protected AsmHierarchyBuilder(CompilationResult result) {
LangUtil.throwIaxIfNull(result, "result");
currCompilationResult = result;
stack = new Stack();
@@ -55,7 +54,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
private void internalBuild(
CompilationUnitDeclaration unit,
StructureModel structureModel) {
- LangUtil.throwIaxIfNull(structureModel, "structureModel");
+ LangUtil.throwIaxIfNull(structureModel, "structureModel");
if (!currCompilationResult.equals(unit.compilationResult())) {
throw new IllegalArgumentException("invalid unit: " + unit);
}
@@ -67,67 +66,27 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
// -- create node to add
final File file = new File(new String(unit.getFileName()));
- final ProgramElementNode cuNode;
+ final IProgramElement cuNode;
{
// AMC - use the source start and end from the compilation unit decl
int startLine = getStartLine(unit);
int endLine = getEndLine(unit);
ISourceLocation sourceLocation
= new SourceLocation(file, startLine, endLine);
- cuNode = new ProgramElementNode(
+ cuNode = new ProgramElement(
new String(file.getName()),
- ProgramElementNode.Kind.FILE_JAVA,
+ IProgramElement.Kind.FILE_JAVA,
sourceLocation,
0,
"",
new ArrayList());
}
- // -- get node (package or root) to add to
- final StructureNode addToNode;
- {
- ImportReference currentPackage = unit.currentPackage;
- if (null == currentPackage) {
- addToNode = structureModel.getRoot();
- } else {
- String pkgName;
- {
- StringBuffer nameBuffer = new StringBuffer();
- final char[][] importName = currentPackage.getImportName();
- final int last = importName.length-1;
- for (int i = 0; i < importName.length; i++) {
- nameBuffer.append(new String(importName[i]));
- if (i < last) {
- nameBuffer.append('.');
- }
- }
- pkgName = nameBuffer.toString();
- }
-
- ProgramElementNode pkgNode = null;
- for (Iterator it = structureModel.getRoot().getChildren().iterator();
- it.hasNext(); ) {
- ProgramElementNode currNode = (ProgramElementNode)it.next();
- if (pkgName.equals(currNode.getName())) {
- pkgNode = currNode;
- break; // any reason not to quit when found?
- }
- }
- if (pkgNode == null) {
- // note packages themselves have no source location
- pkgNode = new ProgramElementNode(
- pkgName,
- ProgramElementNode.Kind.PACKAGE,
- new ArrayList());
- structureModel.getRoot().addChild(pkgNode);
- }
- addToNode = pkgNode;
- }
- }
+ final IProgramElement addToNode = genAddToNode(unit, structureModel);
// -- remove duplicates before adding (XXX use them instead?)
for (ListIterator itt = addToNode.getChildren().listIterator(); itt.hasNext(); ) {
- ProgramElementNode child = (ProgramElementNode)itt.next();
+ IProgramElement child = (IProgramElement)itt.next();
ISourceLocation childLoc = child.getSourceLocation();
if (null == childLoc) {
// XXX ok, packages have null source locations
@@ -149,15 +108,66 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
+ " creating path for " + file );
// XXX signal IOException when canonicalizing file path
}
- }
+
+ }
+
+ /**
+ * Get/create teh node (package or root) to add to.
+ */
+ private IProgramElement genAddToNode(
+ CompilationUnitDeclaration unit,
+ StructureModel structureModel) {
+ final IProgramElement addToNode;
+ {
+ ImportReference currentPackage = unit.currentPackage;
+ if (null == currentPackage) {
+ addToNode = structureModel.getRoot();
+ } else {
+ String pkgName;
+ {
+ StringBuffer nameBuffer = new StringBuffer();
+ final char[][] importName = currentPackage.getImportName();
+ final int last = importName.length-1;
+ for (int i = 0; i < importName.length; i++) {
+ nameBuffer.append(new String(importName[i]));
+ if (i < last) {
+ nameBuffer.append('.');
+ }
+ }
+ pkgName = nameBuffer.toString();
+ }
+
+ IProgramElement pkgNode = null;
+ for (Iterator it = structureModel.getRoot().getChildren().iterator();
+ it.hasNext(); ) {
+ IProgramElement currNode = (IProgramElement)it.next();
+ if (pkgName.equals(currNode.getName())) {
+ pkgNode = currNode;
+ break;
+ }
+ }
+ if (pkgNode == null) {
+ // note packages themselves have no source location
+ pkgNode = new ProgramElement(
+ pkgName,
+ IProgramElement.Kind.PACKAGE,
+ new ArrayList()
+ );
+ structureModel.getRoot().addChild(pkgNode);
+ }
+ addToNode = pkgNode;
+ }
+ }
+ return addToNode;
+ }
public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope scope) {
String name = new String(typeDeclaration.name);
- ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
- if (typeDeclaration instanceof AspectDeclaration) kind = ProgramElementNode.Kind.ASPECT;
- else if (typeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
+ IProgramElement.Kind kind = IProgramElement.Kind.CLASS;
+ if (typeDeclaration instanceof AspectDeclaration) kind = IProgramElement.Kind.ASPECT;
+ else if (typeDeclaration.isInterface()) kind = IProgramElement.Kind.INTERFACE;
- ProgramElementNode peNode = new ProgramElementNode(
+ IProgramElement peNode = new ProgramElement(
name,
kind,
makeLocation(typeDeclaration),
@@ -166,7 +176,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
// peNode.setFullSignature(typeDeclaration.());
- ((StructureNode)stack.peek()).addChild(peNode);
+ ((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
@@ -179,11 +189,11 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
String name = new String(memberTypeDeclaration.name);
//System.err.println("member type with name: " + name);
- ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
- if (memberTypeDeclaration instanceof AspectDeclaration) kind = ProgramElementNode.Kind.ASPECT;
- else if (memberTypeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
+ IProgramElement.Kind kind = IProgramElement.Kind.CLASS;
+ if (memberTypeDeclaration instanceof AspectDeclaration) kind = IProgramElement.Kind.ASPECT;
+ else if (memberTypeDeclaration.isInterface()) kind = IProgramElement.Kind.INTERFACE;
- ProgramElementNode peNode = new ProgramElementNode(
+ IProgramElement peNode = new ProgramElement(
name,
kind,
makeLocation(memberTypeDeclaration),
@@ -193,7 +203,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
peNode.setFullSignature(memberTypeDeclaration.toString());
- ((StructureNode)stack.peek()).addChild(peNode);
+ ((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
@@ -216,10 +226,10 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
// System.err.println("member type with name: " + name + ", " +
// new String(fullName));
- ProgramElementNode.Kind kind = ProgramElementNode.Kind.CLASS;
- if (memberTypeDeclaration.isInterface()) kind = ProgramElementNode.Kind.INTERFACE;
+ IProgramElement.Kind kind = IProgramElement.Kind.CLASS;
+ if (memberTypeDeclaration.isInterface()) kind = IProgramElement.Kind.INTERFACE;
- ProgramElementNode peNode = new ProgramElementNode(
+ IProgramElement peNode = new ProgramElement(
fullName,
kind,
makeLocation(memberTypeDeclaration),
@@ -244,21 +254,21 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
stack.pop();
}
- private StructureNode findEnclosingClass(Stack stack) {
+ private IProgramElement findEnclosingClass(Stack stack) {
for (int i = stack.size()-1; i >= 0; i--) {
- ProgramElementNode pe = (ProgramElementNode)stack.get(i);
- if (pe.getProgramElementKind() == ProgramElementNode.Kind.CLASS) {
+ IProgramElement pe = (IProgramElement)stack.get(i);
+ if (pe.getKind() == IProgramElement.Kind.CLASS) {
return pe;
}
}
- return (StructureNode)stack.peek();
+ return (IProgramElement)stack.peek();
}
public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
- ProgramElementNode peNode = new ProgramElementNode(
+ IProgramElement peNode = new ProgramElement(
"",
- ProgramElementNode.Kind.ERROR,
+ IProgramElement.Kind.ERROR,
makeLocation(methodDeclaration),
methodDeclaration.modifiers,
"",
@@ -268,9 +278,9 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
genBytecodeInfo(methodDeclaration, peNode);
// TODO: should improve determining what the main method is
- if (peNode.getProgramElementKind().equals(ProgramElementNode.Kind.METHOD)) {
+ if (peNode.getKind().equals(IProgramElement.Kind.METHOD)) {
if (peNode.getName().equals("main")) {
- ((ProgramElementNode)stack.peek()).setRunnable(true);
+ ((IProgramElement)stack.peek()).setRunnable(true);
}
}
@@ -278,7 +288,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
return true;
}
- private void genBytecodeInfo(MethodDeclaration methodDeclaration, ProgramElementNode peNode) {
+ private void genBytecodeInfo(MethodDeclaration methodDeclaration, IProgramElement peNode) {
if (methodDeclaration.binding != null) {
String memberName = "";
String memberBytecodeSignature = "";
@@ -293,7 +303,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
peNode.setBytecodeName(memberName);
peNode.setBytecodeSignature(memberBytecodeSignature);
}
- ((StructureNode)stack.peek()).addChild(peNode);
+ ((IProgramElement)stack.peek()).addChild(peNode);
}
public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
@@ -301,14 +311,14 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
}
public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
- ProgramElementNode peNode = new ProgramElementNode(
+ IProgramElement peNode = new ProgramElement(
new String(fieldDeclaration.name),
- ProgramElementNode.Kind.FIELD,
+ IProgramElement.Kind.FIELD,
makeLocation(fieldDeclaration),
fieldDeclaration.modifiers,
"",
new ArrayList());
- ((StructureNode)stack.peek()).addChild(peNode);
+ ((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
@@ -325,7 +335,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
// 0,
// "",
// new ArrayList());
-// ((StructureNode)stack.peek()).addChild(0, peNode);
+// ((IProgramElement)stack.peek()).addChild(0, peNode);
// stack.push(peNode);
// return true;
// }
@@ -338,14 +348,14 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
stack.push(null); // a little wierd but does the job
return true;
}
- ProgramElementNode peNode = new ProgramElementNode(
+ IProgramElement peNode = new ProgramElement(
new String(constructorDeclaration.selector),
- ProgramElementNode.Kind.CONSTRUCTOR,
+ IProgramElement.Kind.CONSTRUCTOR,
makeLocation(constructorDeclaration),
constructorDeclaration.modifiers,
"",
new ArrayList());
- ((StructureNode)stack.peek()).addChild(peNode);
+ ((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
}
@@ -361,7 +371,7 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
// clinit.modifiers,
// "",
// new ArrayList());
-// ((StructureNode)stack.peek()).addChild(peNode);
+// ((IProgramElement)stack.peek()).addChild(peNode);
// stack.push(peNode);
// return false;
// }
@@ -376,14 +386,14 @@ public class AsmBuilder extends AbstractSyntaxTreeVisitorAdapter {
if (initializer == inInitializer) return false;
inInitializer = initializer;
- ProgramElementNode peNode = new ProgramElementNode(
+ IProgramElement peNode = new ProgramElement(
"...",
- ProgramElementNode.Kind.INITIALIZER,
+ IProgramElement.Kind.INITIALIZER,
makeLocation(initializer),
initializer.modifiers,
"",
new ArrayList());
- ((StructureNode)stack.peek()).addChild(peNode);
+ ((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
initializer.block.traverse(this, scope);
stack.pop();
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmNodeFormatter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmNodeFormatter.java
index b7425d426..e2025743e 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmNodeFormatter.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmNodeFormatter.java
@@ -13,7 +13,7 @@ package org.aspectj.ajdt.internal.core.builder;
import java.util.Iterator;
import org.aspectj.ajdt.internal.compiler.ast.*;
-import org.aspectj.asm.ProgramElementNode;
+import org.aspectj.asm.IProgramElement;
import org.aspectj.weaver.*;
import org.aspectj.weaver.patterns.*;
import org.eclipse.jdt.internal.compiler.ast.*;
@@ -31,10 +31,10 @@ public class AsmNodeFormatter {
public static final int MAX_MESSAGE_LENGTH = 18;
public static final String DEC_LABEL = "declare";
- public void genLabelAndKind(MethodDeclaration methodDeclaration, ProgramElementNode node) {
+ public void genLabelAndKind(MethodDeclaration methodDeclaration, IProgramElement node) {
if (methodDeclaration instanceof AdviceDeclaration) {
AdviceDeclaration ad = (AdviceDeclaration)methodDeclaration;
- node.setKind( ProgramElementNode.Kind.ADVICE);
+ node.setKind( IProgramElement.Kind.ADVICE);
String label = "";
label += ad.kind.toString();
label += "(" + genArguments(ad) + "): ";
@@ -66,12 +66,12 @@ public class AsmNodeFormatter {
}
} else {
label += POINTCUT_ABSTRACT;
- }
+ }
node.setName(label);
} else if (methodDeclaration instanceof PointcutDeclaration) {
PointcutDeclaration pd = (PointcutDeclaration)methodDeclaration;
- node.setKind( ProgramElementNode.Kind.POINTCUT);
+ node.setKind( IProgramElement.Kind.POINTCUT);
String label = translatePointcutName(new String(methodDeclaration.selector));
label += "(" + genArguments(pd) + ")";
node.setName(label);
@@ -83,29 +83,29 @@ public class AsmNodeFormatter {
DeclareErrorOrWarning deow = (DeclareErrorOrWarning)declare.declare;
if (deow.isError()) {
- node.setKind( ProgramElementNode.Kind.DECLARE_ERROR);
+ node.setKind( IProgramElement.Kind.DECLARE_ERROR);
label += DECLARE_ERROR;
} else {
- node.setKind( ProgramElementNode.Kind.DECLARE_WARNING);
+ node.setKind( IProgramElement.Kind.DECLARE_WARNING);
label += DECLARE_WARNING;
}
node.setName(label + "\"" + genDeclareMessage(deow.getMessage()) + "\"") ;
} else if (declare.declare instanceof DeclareParents) {
- node.setKind( ProgramElementNode.Kind.DECLARE_PARENTS);
+ node.setKind( IProgramElement.Kind.DECLARE_PARENTS);
DeclareParents dp = (DeclareParents)declare.declare;
node.setName(label + DECLARE_PARENTS + genTypePatternLabel(dp.getChild()));
} else if (declare.declare instanceof DeclareSoft) {
- node.setKind( ProgramElementNode.Kind.DECLARE_SOFT);
+ node.setKind( IProgramElement.Kind.DECLARE_SOFT);
DeclareSoft ds = (DeclareSoft)declare.declare;
node.setName(label + DECLARE_SOFT + genTypePatternLabel(ds.getException()));
} else if (declare.declare instanceof DeclarePrecedence) {
- node.setKind( ProgramElementNode.Kind.DECLARE_PRECEDENCE);
+ node.setKind( IProgramElement.Kind.DECLARE_PRECEDENCE);
DeclarePrecedence ds = (DeclarePrecedence)declare.declare;
node.setName(label + DECLARE_PRECEDENCE + genPrecedenceListLabel(ds.getPatterns()));
} else {
- node.setKind( ProgramElementNode.Kind.ERROR);
+ node.setKind( IProgramElement.Kind.ERROR);
node.setName(DECLARE_UNKNONWN);
}
@@ -113,23 +113,29 @@ public class AsmNodeFormatter {
InterTypeDeclaration itd = (InterTypeDeclaration)methodDeclaration;
String label = itd.onType.toString() + "." + new String(itd.getDeclaredSelector());
if (methodDeclaration instanceof InterTypeFieldDeclaration) {
- node.setKind(ProgramElementNode.Kind.INTER_TYPE_FIELD);
+ node.setKind(IProgramElement.Kind.INTER_TYPE_FIELD);
} else if (methodDeclaration instanceof InterTypeMethodDeclaration) {
- node.setKind(ProgramElementNode.Kind.INTER_TYPE_METHOD);
+ node.setKind(IProgramElement.Kind.INTER_TYPE_METHOD);
InterTypeMethodDeclaration itmd = (InterTypeMethodDeclaration)methodDeclaration;
label += "(" + genArguments(itd) + ")";
} else if (methodDeclaration instanceof InterTypeConstructorDeclaration) {
- node.setKind(ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR);
+ node.setKind(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR);
InterTypeConstructorDeclaration itcd = (InterTypeConstructorDeclaration)methodDeclaration;
} else {
- node.setKind(ProgramElementNode.Kind.ERROR);
+ node.setKind(IProgramElement.Kind.ERROR);
}
node.setName(label);
node.setReturnType(itd.returnType.toString());
} else {
- node.setKind(ProgramElementNode.Kind.METHOD);
- node.setName(new String(methodDeclaration.selector));
+ if (methodDeclaration.isConstructor()) {
+ node.setKind(IProgramElement.Kind.CONSTRUCTOR);
+ } else {
+ node.setKind(IProgramElement.Kind.METHOD);
+ }
+ String label = new String(methodDeclaration.selector);
+ label += "(" + genArguments(methodDeclaration) + ")";
+ node.setName(label);
}
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java
index 8f662e160..74a394da4 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java
@@ -14,20 +14,10 @@
package org.aspectj.ajdt.internal.core.builder;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.aspectj.asm.AdviceAssociation;
-import org.aspectj.asm.IntroductionAssociation;
-import org.aspectj.asm.LinkNode;
-import org.aspectj.asm.ProgramElementNode;
-import org.aspectj.asm.RelationNode;
-import org.aspectj.asm.StructureModelManager;
+import java.io.*;
+import java.util.*;
+
+import org.aspectj.asm.*;
//import org.aspectj.ajde.compiler.AjdeCompiler;
/**
@@ -48,7 +38,7 @@ public class EmacsStructureModelManager {
//Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMap().entrySet();
Set fileSet = StructureModelManager.getDefault().getStructureModel().getFileMapEntrySet();
for (Iterator it = fileSet.iterator(); it.hasNext(); ) {
- ProgramElementNode peNode = (ProgramElementNode)((Map.Entry)it.next()).getValue();
+ IProgramElement peNode = (IProgramElement)((Map.Entry)it.next()).getValue();
dumpStructureToFile(peNode);
}
} catch (IOException ioe) {
@@ -64,10 +54,10 @@ public class EmacsStructureModelManager {
// writer.flush();
// }
- private void dumpStructureToFile(ProgramElementNode node) throws IOException {
- String s = node.getKind();
- if (! (s.equals(ProgramElementNode.Kind.FILE_ASPECTJ.toString())
- || s.equals(ProgramElementNode.Kind.FILE_JAVA.toString()))) {
+ private void dumpStructureToFile(IProgramElement node) throws IOException {
+ String s = node.getKind().toString();
+ if (! (s.equals(IProgramElement.Kind.FILE_ASPECTJ.toString())
+ || s.equals(IProgramElement.Kind.FILE_JAVA.toString()))) {
throw new IllegalArgumentException("externalize file, not " + node);
}
// source files have source locations
@@ -98,43 +88,46 @@ public class EmacsStructureModelManager {
this.writer = writer;
}
- private void printDecls(ProgramElementNode node) {
+ private void printDecls(IProgramElement node) {
print("(");
for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
// this ignores relations on the compile unit
Object nodeObject = it.next();
- if (nodeObject instanceof ProgramElementNode) {
- ProgramElementNode child = (ProgramElementNode)nodeObject;
+// throw new RuntimeException("unimplemented");
+// if (nodeObject instanceof IProgramElement) {
+ IProgramElement child = (IProgramElement)nodeObject;
printDecl(child, true);
- } else if (nodeObject instanceof LinkNode) {
- LinkNode child = (LinkNode)nodeObject;
- printDecl(child.getProgramElementNode(), false);
- }
+// }
+// else if (nodeObject instanceof LinkNode) {
+// LinkNode child = (LinkNode)nodeObject;
+// printDecl(child.getProgramElementNode(), false);
+// }
}
print(") ");
}
- private void printDecls(RelationNode node) {
- for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
+ private void printDecls(IRelationship node) {
+ for (Iterator it = node.getTargets().iterator(); it.hasNext(); ) {
// this ignores relations on the compile unit
Object nodeObject = it.next();
- if (nodeObject instanceof LinkNode) {
- LinkNode child = (LinkNode)nodeObject;
- if (//!child.getProgramElementNode().getKind().equals("stmnt") &&
- !child.getProgramElementNode().getKind().equals("<undefined>")) {
- printDecl(child.getProgramElementNode(), false);
+ throw new RuntimeException("unimplemented");
+// if (nodeObject instanceof LinkNode) {
+// LinkNode child = (LinkNode)nodeObject;
+// if (//!child.getProgramElementNode().getKind().equals("stmnt") &&
+// !child.getProgramElementNode().getKind().equals("<undefined>")) {
// printDecl(child.getProgramElementNode(), false);
- }
- }
+//// printDecl(child.getProgramElementNode(), false);
+// }
+// }
}
}
/**
* @param structureNode can be a ProgramElementNode or a LinkNode
*/
- private void printDecl(ProgramElementNode node, boolean recurse) {
+ private void printDecl(IProgramElement node, boolean recurse) {
if (node == null || node.getSourceLocation() == null) return;
- String kind = node.getKind().toLowerCase();
+ String kind = node.getKind().toString().toLowerCase();
print("(");
print("(" + node.getSourceLocation().getLine() + " . " + node.getSourceLocation().getColumn() + ") ");
print("(" + node.getSourceLocation().getLine() + " . " + node.getSourceLocation().getColumn() + ") ");
@@ -161,13 +154,13 @@ public class EmacsStructureModelManager {
print("nil");
} else {
print("(");
- if (node instanceof ProgramElementNode) {
- java.util.List relations = ((ProgramElementNode)node).getRelations();
+ if (node instanceof IProgramElement) {
+ java.util.List relations = ((IProgramElement)node).getRelations();
if (relations != null) {
for (Iterator it = relations.iterator(); it.hasNext(); ) {
- RelationNode relNode = (RelationNode)it.next();
- if (relNode.getRelation().getAssociationName().equals(AdviceAssociation.NAME) ||
- relNode.getRelation().getAssociationName().equals(IntroductionAssociation.NAME)) {
+ IRelationship relNode = (IRelationship)it.next();
+ if (relNode.getKind() == IRelationship.Kind.ADVICE ||
+ relNode.getKind() == IRelationship.Kind.DECLARE) {
printDecls(relNode); // 6
}
}
@@ -182,8 +175,8 @@ public class EmacsStructureModelManager {
while (it3.hasNext()) {
// this ignores relations on the compile unit
Object nodeObject = it3.next();
- if (nodeObject instanceof ProgramElementNode) {
- ProgramElementNode currNode = (ProgramElementNode)nodeObject;
+ if (nodeObject instanceof IProgramElement) {
+ IProgramElement currNode = (IProgramElement)nodeObject;
if (//!currNode.isStmntKind() &&
!currNode.getKind().equals("<undefined>")) {
printDecl(currNode, true);
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java
index 759dbcb82..983f69f96 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java
@@ -60,7 +60,7 @@ public class AsmBuilderTest extends TestCase {
BlockScope scope = null;
try {
- new AsmBuilder(new CompilationResult(cu, 0, 0, 0)).visit(local, scope);
+ new AsmHierarchyBuilder(new CompilationResult(cu, 0, 0, 0)).visit(local, scope);
} catch (Exception e) {
assertTrue(e instanceof EmptyStackException);
}
diff --git a/testing/src/org/aspectj/testing/ajde/CompileCommand.java b/testing/src/org/aspectj/testing/ajde/CompileCommand.java
index fa8fb7d99..02da4ab43 100644
--- a/testing/src/org/aspectj/testing/ajde/CompileCommand.java
+++ b/testing/src/org/aspectj/testing/ajde/CompileCommand.java
@@ -16,15 +16,14 @@ import java.awt.Frame;
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
-import java.util.List;
import org.aspectj.ajde.*;
import org.aspectj.ajde.ui.*;
import org.aspectj.ajde.ui.internal.*;
import org.aspectj.ajde.ui.swing.*;
-import org.aspectj.asm.StructureNode;
+import org.aspectj.asm.*;
+import org.aspectj.asm.IProgramElement;
import org.aspectj.bridge.*;
-import org.aspectj.util.*;
import org.aspectj.util.FileUtil;
/**
@@ -147,12 +146,17 @@ public class CompileCommand implements ICommand {
};
StructureViewNodeFactory structureViewNodeFactory =
new StructureViewNodeFactory(iconRegistry) {
- protected StructureViewNode createConcreteNode(
- StructureNode node,
- AbstractIcon icon,
- List children) {
- return new SwingTreeViewNode(node, icon, children);
- }
+ protected StructureViewNode createConcreteNode(
+ IProgramElement node,
+ AbstractIcon icon,
+ List children) {
+ return new SwingTreeViewNode(node, icon, children);
+ }
+ protected StructureViewNode createConcreteNode(
+ IRelationship node,
+ AbstractIcon icon) {
+ return new SwingTreeViewNode(node, icon);
+ }
};
Ajde.init(
diff --git a/weaver/src/org/aspectj/weaver/AsmAdaptor.java b/weaver/src/org/aspectj/weaver/AsmAdaptor.java
index 15e94274e..8b557cf33 100644
--- a/weaver/src/org/aspectj/weaver/AsmAdaptor.java
+++ b/weaver/src/org/aspectj/weaver/AsmAdaptor.java
@@ -13,17 +13,11 @@
package org.aspectj.weaver;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.aspectj.asm.AdviceAssociation;
-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.bridge.ISourceLocation;
-import org.aspectj.bridge.SourceLocation;
+import java.util.*;
+
+import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
+import org.aspectj.bridge.*;
public class AsmAdaptor {
public static void noteMunger(StructureModel model, Shadow shadow, ShadowMunger munger) {
@@ -35,89 +29,89 @@ public class AsmAdaptor {
}
// System.out.println("--------------------------");
- ProgramElementNode targetNode = getNode(model, shadow);
- ProgramElementNode adviceNode = getNode(model, a);
-
- Relation relation;
- if (shadow.getKind().equals(Shadow.FieldGet) || shadow.getKind().equals(Shadow.FieldSet)) {
- relation = AdviceAssociation.FIELD_ACCESS_RELATION;
- } else if (shadow.getKind().equals(Shadow.Initialization) || shadow.getKind().equals(Shadow.StaticInitialization)) {
- relation = AdviceAssociation.INITIALIZER_RELATION;
- } else if (shadow.getKind().equals(Shadow.ExceptionHandler)) {
- relation = AdviceAssociation.HANDLER_RELATION;
- } else if (shadow.getKind().equals(Shadow.MethodCall)) {
- relation = AdviceAssociation.METHOD_CALL_SITE_RELATION;
- } else if (shadow.getKind().equals(Shadow.ConstructorCall)) {
- relation = AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION;
- } else if (shadow.getKind().equals(Shadow.MethodExecution) || shadow.getKind().equals(Shadow.AdviceExecution)) {
- relation = AdviceAssociation.METHOD_RELATION;
- } else if (shadow.getKind().equals(Shadow.ConstructorExecution)) {
- relation = AdviceAssociation.CONSTRUCTOR_RELATION;
- } else if (shadow.getKind().equals(Shadow.PreInitialization)) {
- // TODO: someone should check that this behaves reasonably in the IDEs
- relation = AdviceAssociation.INITIALIZER_RELATION;
- } else {
- System.err.println("> unmatched relation: " + shadow.getKind());
- relation = AdviceAssociation.METHOD_RELATION;
- }
+ IProgramElement targetNode = getNode(model, shadow);
+ IProgramElement adviceNode = getNode(model, a);
+// throw new RuntimeException("unimplemented");
+ IRelationship relation = null;
+// if (shadow.getKind().equals(Shadow.FieldGet) || shadow.getKind().equals(Shadow.FieldSet)) {
+// relation = AdviceAssociation.FIELD_ACCESS_RELATION;
+// } else if (shadow.getKind().equals(Shadow.Initialization) || shadow.getKind().equals(Shadow.StaticInitialization)) {
+// relation = AdviceAssociation.INITIALIZER_RELATION;
+// } else if (shadow.getKind().equals(Shadow.ExceptionHandler)) {
+// relation = AdviceAssociation.HANDLER_RELATION;
+// } else if (shadow.getKind().equals(Shadow.MethodCall)) {
+// relation = AdviceAssociation.METHOD_CALL_SITE_RELATION;
+// } else if (shadow.getKind().equals(Shadow.ConstructorCall)) {
+// relation = AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION;
+// } else if (shadow.getKind().equals(Shadow.MethodExecution) || shadow.getKind().equals(Shadow.AdviceExecution)) {
+// relation = AdviceAssociation.METHOD_RELATION;
+// } else if (shadow.getKind().equals(Shadow.ConstructorExecution)) {
+// relation = AdviceAssociation.CONSTRUCTOR_RELATION;
+// } else if (shadow.getKind().equals(Shadow.PreInitialization)) {
+// // TODO: someone should check that this behaves reasonably in the IDEs
+// relation = AdviceAssociation.INITIALIZER_RELATION;
+// } else {
+// System.err.println("> unmatched relation: " + shadow.getKind());
+// relation = AdviceAssociation.METHOD_RELATION;
+// }
+//
// System.out.println("> target: " + targetNode + ", advice: " + adviceNode);
createAppropriateLinks(targetNode, adviceNode, relation);
}
}
private static void createAppropriateLinks(
- ProgramElementNode target,
- ProgramElementNode advice,
- Relation relation)
+ IProgramElement target,
+ IProgramElement advice,
+ IRelationship relation)
{
if (target == null || advice == null) return;
- addLink(target, new LinkNode(advice), relation, true);
- addLink(advice, new LinkNode(target), relation, false);
-
-// System.out.println(">> added target: " + target.getProgramElementKind() + ", advice: " + advice);
-// System.out.println(">> target: " + target + ", advice: " + target.getSourceLocation());
+// addLink(target, new LinkNode(advice), relation, true);
+// addLink(advice, new LinkNode(target), relation, false);
}
private static void addLink(
- ProgramElementNode onNode,
- LinkNode linkNode,
- Relation relation,
+ IProgramElement onNode,
+// LinkNode linkNode,
+ IRelationship relation,
boolean isBack)
{
- RelationNode node = null;
- String relationName = isBack ? relation.getBackNavigationName() : relation.getForwardNavigationName();
+ IRelationship node = null;
+ String relationName = relation.getName();
+// isBack ? relation() : relation.getForwardNavigationName();
//System.err.println("on: " + onNode + " relationName: " + relationName + " existin: " + onNode.getRelations());
for (Iterator i = onNode.getRelations().iterator(); i.hasNext();) {
- RelationNode relationNode = (RelationNode) i.next();
+ IRelationship relationNode = (IRelationship) i.next();
if (relationName.equals(relationNode.getName())) {
node = relationNode;
break;
}
}
if (node == null) {
- node = new RelationNode(relation, relationName, new ArrayList());
- onNode.getRelations().add(node);
+ throw new RuntimeException("unimplemented");
+// node = new Relationship(relation, relationName, new ArrayList());
+// onNode.getRelations().add(node);
}
- node.getChildren().add(linkNode);
+// node.getTargets().add(linkNode);
}
- private static ProgramElementNode getNode(StructureModel model, Advice a) {
+ private static IProgramElement getNode(StructureModel model, Advice a) {
//ResolvedTypeX inAspect = a.getConcreteAspect();
Member member = a.getSignature();
if (a.getSignature() == null) return null;
return lookupMember(model, member);
}
- private static ProgramElementNode getNode(StructureModel model, Shadow shadow) {
+ private static IProgramElement getNode(StructureModel model, Shadow shadow) {
Member enclosingMember = shadow.getEnclosingCodeSignature();
- ProgramElementNode enclosingNode = lookupMember(model, enclosingMember);
+ IProgramElement enclosingNode = lookupMember(model, enclosingMember);
if (enclosingNode == null) {
Lint.Kind err = shadow.getIWorld().getLint().shadowNotInStructure;
if (err.isEnabled()) {
@@ -128,19 +122,19 @@ public class AsmAdaptor {
Member shadowSig = shadow.getSignature();
if (!shadowSig.equals(enclosingMember)) {
- ProgramElementNode bodyNode = findOrCreateBodyNode(enclosingNode, shadowSig, shadow);
+ IProgramElement bodyNode = findOrCreateBodyNode(enclosingNode, shadowSig, shadow);
return bodyNode;
} else {
return enclosingNode;
}
}
- private static ProgramElementNode findOrCreateBodyNode(
- ProgramElementNode enclosingNode,
+ private static IProgramElement findOrCreateBodyNode(
+ IProgramElement enclosingNode,
Member shadowSig, Shadow shadow)
{
for (Iterator it = enclosingNode.getChildren().iterator(); it.hasNext(); ) {
- ProgramElementNode node = (ProgramElementNode)it.next();
+ IProgramElement node = (IProgramElement)it.next();
if (shadowSig.getName().equals(node.getBytecodeName()) &&
shadowSig.getSignature().equals(node.getBytecodeSignature()))
{
@@ -150,9 +144,9 @@ public class AsmAdaptor {
ISourceLocation sl = shadow.getSourceLocation();
- ProgramElementNode peNode = new ProgramElementNode(
+ IProgramElement peNode = new ProgramElement(
shadow.toString(),
- ProgramElementNode.Kind.CODE,
+ IProgramElement.Kind.CODE,
//XXX why not use shadow file? new SourceLocation(sl.getSourceFile(), sl.getLine()),
new SourceLocation(enclosingNode.getSourceLocation().getSourceFile(), sl.getLine()),
// enclosingNode.getSourceLocation(),
@@ -171,20 +165,20 @@ public class AsmAdaptor {
- public static ProgramElementNode lookupMember(StructureModel model, Member member) {
+ public static IProgramElement lookupMember(StructureModel model, Member member) {
TypeX declaringType = member.getDeclaringType();
- ProgramElementNode classNode =
+ IProgramElement classNode =
model.findNodeForClass(declaringType.getPackageName(), declaringType.getClassName());
return findMemberInClass(classNode, member);
}
- private static ProgramElementNode findMemberInClass(
- ProgramElementNode classNode,
+ private static IProgramElement findMemberInClass(
+ IProgramElement classNode,
Member member)
{
if (classNode == null) return null; // XXX remove this check
for (Iterator it = classNode.getChildren().iterator(); it.hasNext(); ) {
- ProgramElementNode node = (ProgramElementNode)it.next();
+ IProgramElement node = (IProgramElement)it.next();
//System.err.println("checking: " + member.getName() + " with " + node.getBytecodeName() + ", " + node.getBytecodeSignature());
if (member.getName().equals(node.getBytecodeName()) &&
member.getSignature().equals(node.getBytecodeSignature()))