import org.aspectj.ajde.ui.internal.UserPreferencesStore;
import org.aspectj.ajde.ui.swing.*;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
/**
* IDE manager for standalone AJDE application.
private static TopFrame topFrame = null;
- public final IStructureModelListener VIEW_LISTENER = new IStructureModelListener() {
- public void containmentHierarchyUpdated(AspectJModel model) {
+ public final IHierarchyListener VIEW_LISTENER = new IHierarchyListener() {
+ public void elementsUpdated(IHierarchy model) {
FileStructureView fsv = Ajde.getDefault().getStructureViewManager().getDefaultFileView();
if (fsv != null) {
fsv.setSourceFile(BrowserManager.getDefault().getEditorManager().getCurrFile());
import org.aspectj.ajde.Ajde;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
/**
* Prototype functionality for package view clients.
public static List getPackagesInModel() {
List packages = new ArrayList();
- AspectJModel model =
- Ajde.getDefault().getStructureModelManager().getModel();
- if (model.equals(AspectJModel.NO_STRUCTURE)) {
+ IHierarchy model =
+ Ajde.getDefault().getStructureModelManager().getHierarchy();
+ if (model.equals(IHierarchy.NO_STRUCTURE)) {
return null;
} else {
return getPackagesHelper(
import org.aspectj.ajde.Ajde;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
/**
* @author Mik Kersten
IProgramElement.Kind kind) {
List matches = new ArrayList();
- AspectJModel model = Ajde.getDefault().getStructureModelManager().getModel();
- if (model.equals(AspectJModel.NO_STRUCTURE)) {
+ IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
+ if (model.equals(IHierarchy.NO_STRUCTURE)) {
return null;
} else {
return findMatchesHelper((IProgramElement)model.getRoot(), pattern, kind, matches);
import org.aspectj.ajde.Ajde;
import org.aspectj.ajde.ui.internal.*;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
/**
* @author Mik Kersten
private static final StructureViewProperties DEFAULT_VIEW_PROPERTIES;
private static final List AVAILABLE_RELATIONS;
- public final IStructureModelListener VIEW_LISTENER = new IStructureModelListener() {
- public void containmentHierarchyUpdated(AspectJModel model) {
+ public final IHierarchyListener VIEW_LISTENER = new IHierarchyListener() {
+ public void elementsUpdated(IHierarchy model) {
Ajde.getDefault().logEvent("updating structure views: " + structureViews);
//
// if (defaultFileView != null) {
// }
for (Iterator it = structureViews.iterator(); it.hasNext(); ) {
- treeViewBuilder.buildView((StructureView)it.next(), (AspectJModel)model);
+ treeViewBuilder.buildView((StructureView)it.next(), (AspectJElementHierarchy)model);
}
}
};
* @param newFilePath the canonicalized path to the new file
*/
public void fireNavigationAction(String newFilePath, int lineNumber) {
- IProgramElement currNode = Ajde.getDefault().getStructureModelManager().getModel().findNodeForSourceLine(
+ IProgramElement currNode = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceLine(
newFilePath,
lineNumber);
*/
private void navigationAction(IProgramElement node, boolean recordHistory) {
if (node == null
- || node == AspectJModel.NO_STRUCTURE) {
+ || node == IHierarchy.NO_STRUCTURE) {
Ajde.getDefault().getIdeUIAdapter().displayStatusInformation("Source not available for node: " + node.getName());
return;
}
if (defaultFileView.getSourceFile() != null
&& !defaultFileView.getSourceFile().equals(newFilePath)) {
defaultFileView.setSourceFile(newFilePath);
- treeViewBuilder.buildView(defaultFileView, AsmManager.getDefault().getModel());
+ treeViewBuilder.buildView(defaultFileView, AsmManager.getDefault().getHierarchy());
}
}
public void refreshView(StructureView view) {
IStructureViewNode activeNode = view.getActiveNode();
- treeViewBuilder.buildView(view, Ajde.getDefault().getStructureModelManager().getModel());
+ treeViewBuilder.buildView(view, Ajde.getDefault().getStructureModelManager().getHierarchy());
view.setActiveNode(activeNode);
}
if (properties == null) properties = DEFAULT_VIEW_PROPERTIES;
FileStructureView view = new FileStructureView(properties);
view.setSourceFile(sourceFilePath);
- treeViewBuilder.buildView(view, AsmManager.getDefault().getModel());
+ treeViewBuilder.buildView(view, AsmManager.getDefault().getHierarchy());
structureViews.add(view);
return view;
}
public IStructureViewNode createNode(IProgramElement node, List children) {
AbstractIcon icon = iconRegistry.getStructureIcon(node.getKind(), node.getAccessibility());
- IStructureViewNode svNode = createDeclaration(node, icon, children);
- List relationships = AsmManager.getDefault().getMapper().get(node);
- for (Iterator it = relationships.iterator(); it.hasNext(); ) {
- IRelationship rel = (IRelationship)it.next();
- if (rel != null && rel.getTargets().size() > 0) {
- IStructureViewNode relNode = createRelationship(
- rel,
- iconRegistry.getIcon(rel.getKind())
- );
- svNode.add(relNode, 0);
-
- for (Iterator it2 = rel.getTargets().iterator(); it2.hasNext(); ) {
- IProgramElement link = (IProgramElement)it2.next();
- IStructureViewNode linkNode = createLink(
- link,
- iconRegistry.getStructureIcon(link.getKind(), link.getAccessibility())
- );
- relNode.add(linkNode);
-
+ IStructureViewNode svNode = createDeclaration(node, icon, children);
+ String nodeHandle = node.getHandleIdentifier();
+ if (nodeHandle != null) {
+ List relationships = AsmManager.getDefault().getRelationshipMap().get(nodeHandle);
+ if (relationships != null) {
+ for (Iterator it = relationships.iterator(); it.hasNext(); ) {
+ IRelationship rel = (IRelationship)it.next();
+ if (rel != null && rel.getTargets().size() > 0) {
+ IStructureViewNode relNode = createRelationship(
+ rel,
+ iconRegistry.getIcon(rel.getKind())
+ );
+ svNode.add(relNode, 0);
+ for (Iterator it2 = rel.getTargets().iterator(); it2.hasNext(); ) {
+ String handle = (String)it2.next();
+ IProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(handle);
+ if (link != null) {
+ IStructureViewNode linkNode = createLink(
+ link,
+ iconRegistry.getStructureIcon(link.getKind(), link.getAccessibility())
+ );
+ relNode.add(linkNode);
+ }
+ }
+ }
}
}
}
import org.aspectj.ajde.ui.*;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
import org.aspectj.asm.internal.ProgramElement;
/**
/**
* @todo get rid of instanceof tests
*/
- public void buildView(StructureView view, AspectJModel model) {
+ public void buildView(StructureView view, IHierarchy model) {
StructureViewProperties properties = view.getViewProperties();
IProgramElement modelRoot = null;
boolean noStructure = false;
if (isFileView(view)) {
FileStructureView fileView = (FileStructureView)view;
if (fileView.getSourceFile() == null) {
- modelRoot = AspectJModel.NO_STRUCTURE;
+ modelRoot = IHierarchy.NO_STRUCTURE;
noStructure = true;
} else {
- modelRoot = model.findRootNodeForSourceFile(fileView.getSourceFile());
+ modelRoot = model.findElementForSourceFile(fileView.getSourceFile());
}
} else {
modelRoot = model.getRoot();
}
}
- private IStructureViewNode buildCustomTree(GlobalStructureView view, AspectJModel model) {
+ private IStructureViewNode buildCustomTree(GlobalStructureView view, IHierarchy model) {
IProgramElement rootNode = model.getRoot();
IStructureViewNode treeNode = nodeFactory.createNode(rootNode);
private IdeUIAdapter ideUIAdapter = null;
private TreeViewBuildConfigEditor buildConfigEditor = null;
private IconRegistry iconRegistry;
+ private boolean initialized = false;
private OptionsFrame optionsFrame = null;
private Frame rootFrame = null;
viewManager = new BrowserViewManager();
optionsFrame = new OptionsFrame(iconRegistry);
+
//Ajde.getDefault().getStructureViewManager().refreshView(
// Ajde.getDefault().getStructureViewManager().getDefaultFileStructureView()
//);
//viewManager.updateView();
+ initialized = true;
} catch (Throwable t) {
Ajde.getDefault().getErrorHandler().handleError("AJDE failed to initialize.", t);
}
public IconRegistry getIconRegistry() {
return iconRegistry;
}
+ public boolean isInitialized() {
+ return initialized;
+ }
+
}
//public abstract class AjdeAction {
package org.aspectj.ajde.ui.swing;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.SystemColor;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-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.StructureView;
-import org.aspectj.ajde.ui.StructureViewProperties;
-import org.aspectj.asm.IProgramElement;
-import org.aspectj.asm.AspectJModel;
-import org.aspectj.asm.IStructureModelListener;
+import org.aspectj.ajde.ui.*;
+import org.aspectj.asm.*;
public class SimpleStructureViewToolPanel extends JPanel {
BorderLayout borderLayout3 = new BorderLayout();
BorderLayout borderLayout4 = new BorderLayout();
- public final IStructureModelListener MODEL_LISTENER = new IStructureModelListener() {
- public void containmentHierarchyUpdated(AspectJModel model) {
+ public final IHierarchyListener MODEL_LISTENER = new IHierarchyListener() {
+ public void elementsUpdated(IHierarchy model) {
String path = Ajde.getDefault().getConfigurationManager().getActiveConfigFile();
- String fileName = "<no active config>";
+ String fileName = "<no active config>";
if (path != null) fileName = new File(path).getName();
updateCurrConfigLabel(fileName);
}
private TreeSelectionListener treeListener = null;
private final StructureTreeModel NO_STRUCTURE_MODEL
- = new StructureTreeModel(new SwingTreeViewNode(AspectJModel.NO_STRUCTURE, new AbstractIcon(null), new ArrayList()));
+ = new StructureTreeModel(new SwingTreeViewNode(IHierarchy.NO_STRUCTURE, new AbstractIcon(null), new ArrayList()));
/**
* @todo should probably avoid that MouseListener cast
if (kind == IStructureViewNode.Kind.RELATIONSHIP) {
return relationshipName;
} else {
- return programElement.getName();
+ return programElement.toLabelString();
}
}
public Point() { }
- public int getX() { return x; }
+ public int getX() {
+ return x;
+ }
- public void setX(int x) { this.x = x; }
+ public void setX(int x) {
+ this.x = x;
+ }
public int changeX(int x) {
this.x = x;
currTestDataPath = TEST_DATA_PATH + File.separatorChar + testDataPath;
ideManager.init(currTestDataPath);
super.setUp();
+ assertTrue(NullIdeManager.getIdeManager().isInitialized());
Ajde.getDefault().getBuildManager().addListener(testerBuildListener);
}
import java.util.Iterator;
-import org.aspectj.ajdt.internal.core.builder.AsmNodeFormatter;
+import org.aspectj.ajdt.internal.core.builder.AsmElementFormatter;
import org.aspectj.asm.*;
import org.aspectj.asm.IProgramElement.Kind;
// TODO: add tests for java kinds
public class AsmDeclarationsTest extends AjdeTestCase {
- private AspectJModel model = null;
+ private IHierarchy model = null;
private static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
- private static final int DEC_MESSAGE_LENGTH = AsmNodeFormatter.MAX_MESSAGE_LENGTH;
+ private static final int DEC_MESSAGE_LENGTH = AsmElementFormatter.MAX_MESSAGE_LENGTH;
public AsmDeclarationsTest(String name) {
super(name);
public void testRoot() {
IProgramElement root = (IProgramElement)model.getRoot();
assertNotNull(root);
- assertEquals(root.getName(), "coverage.lst");
+ assertEquals(root.toLabelString(), "coverage.lst");
}
public void testFileInPackageAndDefaultPackage() {
IProgramElement root = model.getRoot();
- assertEquals(root.getName(), "coverage.lst");
+ assertEquals(root.toLabelString(), "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");
+ assertEquals(pkg.toLabelString(), "pkg");
+ assertEquals(((IProgramElement)pkg.getChildren().get(0)).toLabelString(), "InPackage.java");
+ assertEquals(((IProgramElement)root.getChildren().get(0)).toLabelString(), "ModelCoverage.java");
}
public void testDeclares() {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "DeclareCoverage");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "DeclareCoverage");
assertNotNull(aspect);
- String decErrMessage = "declare error: \"Illegal construct..\"";
- IProgramElement decErrNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_ERROR, decErrMessage);
+ String label = "declare error: \"Illegal construct..\"";
+ IProgramElement decErrNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_ERROR, "declare error");
assertNotNull(decErrNode);
- assertEquals(decErrNode.getName(), decErrMessage);
+ assertEquals(decErrNode.toLabelString(), label);
String decWarnMessage = "declare warning: \"Illegal construct..\"";
- IProgramElement decWarnNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_WARNING, decWarnMessage);
+ IProgramElement decWarnNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_WARNING, "declare warning");
assertNotNull(decWarnNode);
- assertEquals(decWarnNode.getName(), decWarnMessage);
+ assertEquals(decWarnNode.toLabelString(), decWarnMessage);
String decParentsMessage = "declare parents: Point";
- IProgramElement decParentsNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsMessage);
+ IProgramElement decParentsNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PARENTS, "declare parents");
assertNotNull(decParentsNode);
- assertEquals(decParentsNode.getName(), decParentsMessage);
-
- String decParentsPtnMessage = "declare parents: Point+";
- IProgramElement decParentsPtnNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsPtnMessage);
- assertNotNull(decParentsPtnNode);
- assertEquals(decParentsPtnNode.getName(), decParentsPtnMessage);
-
- String decParentsTPMessage = "declare parents: <type pattern>";
- IProgramElement decParentsTPNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PARENTS, decParentsTPMessage);
- assertNotNull(decParentsTPNode);
- assertEquals(decParentsTPNode.getName(), decParentsTPMessage);
+ assertEquals(decParentsNode.toLabelString(), decParentsMessage);
+ // check the next two relative to this one
+ int declareIndex = decParentsNode.getParent().getChildren().indexOf(decParentsNode);
+ String decParentsPtnMessage = "declare parents: Point+";
+ assertEquals(((IProgramElement)aspect.getChildren().get(declareIndex+1)).toLabelString(), decParentsPtnMessage);
+ String decParentsTPMessage = "declare parents: <type pattern>";
+ assertEquals(((IProgramElement)aspect.getChildren().get(declareIndex+2)).toLabelString(), decParentsTPMessage);
String decSoftMessage = "declare soft: SizeException";
- IProgramElement decSoftNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_SOFT, decSoftMessage);
+ IProgramElement decSoftNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_SOFT, "declare soft");
assertNotNull(decSoftNode);
- assertEquals(decSoftNode.getName(), decSoftMessage);
+ assertEquals(decSoftNode.toLabelString(), decSoftMessage);
String decPrecMessage = "declare precedence: AdviceCoverage, InterTypeDecCoverage, <type pattern>";
- IProgramElement decPrecNode = model.findNode(aspect, IProgramElement.Kind.DECLARE_PRECEDENCE, decPrecMessage);
+ IProgramElement decPrecNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PRECEDENCE, "declare precedence");
assertNotNull(decPrecNode);
- assertEquals(decPrecNode.getName(), decPrecMessage);
+ assertEquals(decPrecNode.toLabelString(), decPrecMessage);
}
public void testInterTypeMemberDeclares() {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "InterTypeDecCoverage");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "InterTypeDecCoverage");
assertNotNull(aspect);
String fieldMsg = "Point.xxx";
- IProgramElement fieldNode = model.findNode(aspect, IProgramElement.Kind.INTER_TYPE_FIELD, fieldMsg);
+ IProgramElement fieldNode = model.findElementForLabel(aspect, IProgramElement.Kind.INTER_TYPE_FIELD, fieldMsg);
assertNotNull(fieldNode);
- assertEquals(fieldNode.getName(), fieldMsg);
+ assertEquals(fieldNode.toLabelString(), fieldMsg);
String methodMsg = "Point.check(int, Line)";
- IProgramElement methodNode = model.findNode(aspect, IProgramElement.Kind.INTER_TYPE_METHOD, methodMsg);
+ IProgramElement methodNode = model.findElementForLabel(aspect, IProgramElement.Kind.INTER_TYPE_METHOD, methodMsg);
assertNotNull(methodNode);
- assertEquals(methodNode.getName(), methodMsg);
+ assertEquals(methodNode.toLabelString(), methodMsg);
// TODO: enable
// String constructorMsg = "Point.new(int, int, int)";
// ProgramElementNode constructorNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR, constructorMsg);
// assertNotNull(constructorNode);
-// assertEquals(constructorNode.getName(), constructorMsg);
+// assertEquals(constructorNode.toLabelString(), constructorMsg);
}
public void testPointcuts() {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "AdviceNamingCoverage");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage");
assertNotNull(aspect);
String ptct = "named()";
- IProgramElement ptctNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, ptct);
+ IProgramElement ptctNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, ptct);
assertNotNull(ptctNode);
- assertEquals(ptctNode.getName(), ptct);
+ assertEquals(ptctNode.toLabelString(), ptct);
String params = "namedWithArgs(int, int)";
- IProgramElement paramsNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, params);
+ IProgramElement paramsNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, params);
assertNotNull(paramsNode);
- assertEquals(paramsNode.getName(), params);
+ assertEquals(paramsNode.toLabelString(), params);
}
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "AbstractAspect");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AbstractAspect");
assertNotNull(aspect);
String abst = "abPtct()";
- IProgramElement abstNode = model.findNode(aspect, IProgramElement.Kind.POINTCUT, abst);
+ IProgramElement abstNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, abst);
assertNotNull(abstNode);
- assertEquals(abstNode.getName(), abst);
+ assertEquals(abstNode.toLabelString(), abst);
}
public void testAdvice() {
IProgramElement node = (IProgramElement)model.getRoot();
assertNotNull(node);
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, "AdviceNamingCoverage");
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage");
assertNotNull(aspect);
String anon = "before(): <anonymous pointcut>";
- IProgramElement anonNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, anon);
+ IProgramElement anonNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, anon);
assertNotNull(anonNode);
- assertEquals(anonNode.getName(), anon);
+ assertEquals(anonNode.toLabelString(), anon);
String named = "before(): named..";
- IProgramElement namedNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, named);
+ IProgramElement namedNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, named);
assertNotNull(namedNode);
- assertEquals(namedNode.getName(), named);
+ assertEquals(namedNode.toLabelString(), named);
String namedWithOneArg = "around(int): namedWithOneArg..";
- IProgramElement namedWithOneArgNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, namedWithOneArg);
+ IProgramElement namedWithOneArgNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, namedWithOneArg);
assertNotNull(namedWithOneArgNode);
- assertEquals(namedWithOneArgNode.getName(), namedWithOneArg);
+ assertEquals(namedWithOneArgNode.toLabelString(), namedWithOneArg);
String afterReturning = "afterReturning(int, int): namedWithArgs..";
- IProgramElement afterReturningNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, afterReturning);
+ IProgramElement afterReturningNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, afterReturning);
assertNotNull(afterReturningNode);
- assertEquals(afterReturningNode.getName(), afterReturning);
+ assertEquals(afterReturningNode.toLabelString(), afterReturning);
String around = "around(int): namedWithOneArg..";
- IProgramElement aroundNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, around);
+ IProgramElement aroundNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, around);
assertNotNull(aroundNode);
- assertEquals(aroundNode.getName(), around);
+ assertEquals(aroundNode.toLabelString(), around);
String compAnon = "before(int): <anonymous pointcut>..";
- IProgramElement compAnonNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, compAnon);
+ IProgramElement compAnonNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, compAnon);
assertNotNull(compAnonNode);
- assertEquals(compAnonNode.getName(), compAnon);
+ assertEquals(compAnonNode.toLabelString(), compAnon);
String compNamed = "before(int): named()..";
- IProgramElement compNamedNode = model.findNode(aspect, IProgramElement.Kind.ADVICE, compNamed);
+ IProgramElement compNamedNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, compNamed);
assertNotNull(compNamedNode);
- assertEquals(compNamedNode.getName(), compNamed);
+ assertEquals(compNamedNode.toLabelString(), compNamed);
}
protected void setUp() throws Exception {
super.setUp("examples");
assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH));
- model = AsmManager.getDefault().getModel();
+ model = AsmManager.getDefault().getHierarchy();
}
protected void tearDown() throws Exception {
super(name);
}
-// public void testInterTypeDeclarations() {
-// checkMapping("InterTypeDecCoverage", "Point", "Point.xxx:", "xxx", "declared on", "aspect declarations");
-// }
+ public void testInterTypeDeclarations() {
+// checkMapping("InterTypeDecCoverage", "Point", "Point.xxx", "xxx", "declared on", "aspect declarations");
+// checkMapping("InterTypeDecCoverage", "Point", "Point.check(int, Line)", "Point", "declared on", "aspect declarations");
+
+ }
public void testAdvice() {
checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..", "setX(int)", "advises", "advised by");
}
private void checkUniDirectionalMapping(String fromType, String toType, String from, String to, String relName) {
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, fromType);
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
assertNotNull(aspect);
String beforeExec = from;
- IProgramElement beforeExecNode = manager.getModel().findNode(aspect, IProgramElement.Kind.ADVICE, beforeExec);
+ IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
- IRelationship rel = manager.getMapper().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
- assertEquals(((IProgramElement)rel.getTargets().get(0)).getName(), to);
+ IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
+ String handle = (String)rel.getTargets().get(0);
+ assertEquals(manager.getHierarchy().findElementForHandle(handle).toLabelString(), to);
}
private void checkMapping(String fromType, String toType, String from, String to, String forwardRelName, String backRelName) {
- IProgramElement aspect = AsmManager.getDefault().getModel().findNodeForType(null, fromType);
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
assertNotNull(aspect);
String beforeExec = from;
- IProgramElement beforeExecNode = manager.getModel().findNode(aspect, IProgramElement.Kind.ADVICE, beforeExec);
+ IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
- IRelationship rel = manager.getMapper().get(beforeExecNode, IRelationship.Kind.ADVICE, forwardRelName);
- assertEquals(((IProgramElement)rel.getTargets().get(0)).getName(), to);
+ IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, forwardRelName);
+ String handle = (String)rel.getTargets().get(0);
+ assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
- IProgramElement clazz = AsmManager.getDefault().getModel().findNodeForType(null, toType);
+ IProgramElement clazz = AsmManager.getDefault().getHierarchy().findElementForType(null, toType);
assertNotNull(clazz);
String set = to;
- IProgramElement setNode = manager.getModel().findNode(clazz, IProgramElement.Kind.METHOD, set);
+ IProgramElement setNode = manager.getHierarchy().findElementForLabel(clazz, IProgramElement.Kind.METHOD, set);
assertNotNull(setNode);
- IRelationship rel2 = manager.getMapper().get(setNode, IRelationship.Kind.ADVICE, backRelName);
- assertEquals(((IProgramElement)rel2.getTargets().get(0)).getName(), from);
+ IRelationship rel2 = manager.getRelationshipMap().get(setNode, IRelationship.Kind.ADVICE, backRelName);
+ String handle2 = (String)rel2.getTargets().get(0);
+ assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
}
protected void setUp() throws Exception {
private static NullIdeManager ideManager = null;
private NullIdeTaskListManager taskListManager = null;
private NullIdeProperties projectProperties = null;
+ private boolean initialized = false;
public static NullIdeManager getIdeManager() {
if ( null == ideManager ) {
EditorAdapter ajdeEditor = new NullIdeEditorAdapter();
IdeUIAdapter uiAdapter = new NullIdeUIAdapter();
JFrame nullFrame = new JFrame();
- //configurationManager.setConfigFiles(getConfigFilesList(configFiles));
AjdeUIManager.getDefault().init(
ajdeEditor,
new NullIdeProgressMonitor(),
new NullIdeErrorHandler(),
true);
- //Ajde.getDefault().enableLogging( System.out );
+ initialized = true;
} catch (Throwable t) {
+ initialized = false;
t.printStackTrace();
Ajde.getDefault().getErrorHandler().handleError(
"Null IDE failed to initialize.",
projectProperties = properties;
}
+ public boolean isInitialized() {
+ return initialized && AjdeUIManager.getDefault().isInitialized();
+ }
+
}
public boolean verifyAgainstSavedModel(String lstFile) {
File modelFile = new File(genStructureModelExternFilePath(lstFile));
- AspectJModel model = getModelForFile(lstFile);
+ IHierarchy model = getModelForFile(lstFile);
if (modelFile.exists()) {
Ajde.getDefault().getStructureModelManager().readStructureModel(lstFile);
- AspectJModel savedModel = Ajde.getDefault().getStructureModelManager().getModel();
+ IHierarchy savedModel = Ajde.getDefault().getStructureModelManager().getHierarchy();
// 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
return equal;
}
- private AspectJModel getModelForFile(String lstFile) {
+ private IHierarchy getModelForFile(String lstFile) {
Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lstFile);
Ajde.getDefault().getBuildManager().build(); // was buildStructure...
while(!testerBuildListener.getBuildFinished()) {
Thread.sleep(300);
} catch (InterruptedException ie) { }
}
- return Ajde.getDefault().getStructureModelManager().getModel();
+ return Ajde.getDefault().getStructureModelManager().getHierarchy();
}
protected void setUp() throws Exception {
}
public void testModelExists() {
- assertTrue(Ajde.getDefault().getStructureModelManager().getModel() != null);
+ assertTrue(Ajde.getDefault().getStructureModelManager().getHierarchy() != null);
}
protected void tearDown() throws Exception {
public void testRootForSourceFile() throws IOException {
File testFile = openFile("figures-coverage/figures/Figure.java");
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findRootNodeForSourceFile(
- testFile.getCanonicalPath());
+ IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceFile(
+ testFile.getAbsolutePath());
assertTrue("find result", node != null) ;
IProgramElement pNode = (IProgramElement)node;
String child = ((IProgramElement)pNode.getChildren().get(0)).getName();
public void testPointcutName() throws IOException {
File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findRootNodeForSourceFile(
- testFile.getCanonicalPath());
+ IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceFile(
+ testFile.getAbsolutePath());
assertTrue("find result", node != null) ;
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()"));
- }
-
- public void testDeclare() {
-
-
+ assertTrue("found node: " + pointcut.getName(), pointcut.toLabelString().equals("testptct()"));
}
public void testFileNodeFind() throws IOException {
File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getModel().findNodeForSourceLine(
+ IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceLine(
testFile.getCanonicalPath(), 1);
assertTrue("find result", node != null) ;
assertEquals("find result has children", 2, node.getChildren().size()) ;
* @todo add negative test to make sure things that aren't runnable aren't annotated
*/
public void testMainClassNodeInfo() throws IOException {
- AspectJModel model = Ajde.getDefault().getStructureModelManager().getModel();
+ IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
assertTrue("model exists", model != null);
assertTrue("root exists", model.getRoot() != null);
File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = model.findNodeForSourceLine(testFile.getCanonicalPath(), 11);
+ IProgramElement node = model.findElementForSourceLine(testFile.getCanonicalPath(), 11);
assertTrue("find result", node != null);
IProgramElement pNode = (IProgramElement)((IProgramElement)node).getParent();
if (null == pNode) {
* Integrity could be checked somewhere in the API.
*/
public void testModelIntegrity() {
- IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getModel().getRoot();
+ IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot();
assertTrue("root exists", modelRoot != null);
try {
}
}
};
- Ajde.getDefault().getStructureModelManager().getModel().getRoot().walk(walker);
+ Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker);
}
protected void setUp() throws Exception {
}
public void testModelExists() {
- assertTrue(Ajde.getDefault().getStructureModelManager().getModel() != null);
+ assertTrue(Ajde.getDefault().getStructureModelManager().getHierarchy() != null);
}
public void testNotificationAfterConfigFileChange() {
assertTrue(
"no structure",
currentView.getRootNode().getStructureNode().getChildren().get(0)
- == AspectJModel.NO_STRUCTURE
+ == IHierarchy.NO_STRUCTURE
);
}
assertTrue("notified", renderer.getHasBeenNotified());
// AMC should this be currentView, or should we recreate the root... do the latter
//IProgramElement n = currentView.getRootNode().getIProgramElement();
- IProgramElement n = Ajde.getDefault().getStructureModelManager().getModel().getRoot();
+ IProgramElement n = Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot();
assertTrue(
"no structure",
//currentView.getRootNode().getIProgramElement().getChildren().get(0)
- n == AspectJModel.NO_STRUCTURE
+ n == IHierarchy.NO_STRUCTURE
);
}
public void testModelIntegrity() {
doSynchronousBuild(CONFIG_FILE_PATH);
- IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getModel().getRoot();
+ IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot();
assertTrue("root exists", modelRoot != null);
try {
assertTrue(
"no structure",
currentView.getRootNode().getStructureNode()
- == AspectJModel.NO_STRUCTURE
+ == IHierarchy.NO_STRUCTURE
);
}
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2003 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
- * Xerox/PARC initial implementation
+ * Mik Kersten initial implementation
* ******************************************************************/
*/
private static AsmManager INSTANCE = new AsmManager();
private boolean shouldSaveModel = true;
- protected AspectJModel model = new AspectJModel();
+ protected IHierarchy hierarchy;
private List structureListeners = new ArrayList();
- private IRelationshipMapper mapper;
+ private IRelationshipMap mapper;
protected AsmManager() {
+ hierarchy = new AspectJElementHierarchy();
List relationships = new ArrayList();
-// relationships.add(ADVICE);
- mapper = new RelationshipMapper();
+ mapper = new RelationshipMap(hierarchy);
}
- public AspectJModel getModel() {
- return model;
+ public IHierarchy getHierarchy() {
+ return hierarchy;
+ }
+
+ public static AsmManager getDefault() {
+ return INSTANCE;
+ }
+
+ public IRelationshipMap getRelationshipMap() {
+ return mapper;
}
public void fireModelUpdated() {
notifyListeners();
- if (model.getConfigFile() != null) {
- writeStructureModel(model.getConfigFile());
+ if (hierarchy.getConfigFile() != null) {
+ writeStructureModel(hierarchy.getConfigFile());
}
}
// }
// }
- public void addListener(IStructureModelListener listener) {
+ public void addListener(IHierarchyListener listener) {
structureListeners.add(listener);
}
- public void removeStructureListener(IStructureModelListener listener) {
+ public void removeStructureListener(IHierarchyListener listener) {
structureListeners.remove(listener);
}
private void notifyListeners() {
for (Iterator it = structureListeners.iterator(); it.hasNext(); ) {
- ((IStructureModelListener)it.next()).containmentHierarchyUpdated(model);
+ ((IHierarchyListener)it.next()).elementsUpdated(hierarchy);
}
}
try {
String filePath = genExternFilePath(configFilePath);
ObjectOutputStream s = new ObjectOutputStream(new FileOutputStream(filePath));
- s.writeObject(model);
+ s.writeObject(hierarchy);
s.flush();
} catch (Exception e) {
// ignore
public void readStructureModel(String configFilePath) {
try {
if (configFilePath == null) {
- model.setRoot(AspectJModel.NO_STRUCTURE);
+ hierarchy.setRoot(IHierarchy.NO_STRUCTURE);
} else {
String filePath = genExternFilePath(configFilePath);
FileInputStream in = new FileInputStream(filePath);
ObjectInputStream s = new ObjectInputStream(in);
- model = (AspectJModel)s.readObject();
+ hierarchy = (AspectJElementHierarchy)s.readObject();
}
} catch (Exception e) {
//System.err.println("AJDE Message: could not read structure model: " + e);
- model.setRoot(AspectJModel.NO_STRUCTURE);
+ hierarchy.setRoot(IHierarchy.NO_STRUCTURE);
} finally {
notifyListeners();
}
public void setShouldSaveModel(boolean shouldSaveModel) {
this.shouldSaveModel = shouldSaveModel;
}
-
- public static AsmManager getDefault() {
- return INSTANCE;
- }
-
- public IRelationshipMapper getMapper() {
- return mapper;
- }
-
}
+++ /dev/null
-/* *******************************************************************
- * 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.*;
-
-import org.aspectj.asm.internal.ProgramElement;
-import org.aspectj.bridge.*;
-
-/**
- * @author Mik Kersten
- */
-public class AspectJModel implements Serializable {
-
- protected IProgramElement root = null;
- protected String configFile = null;
-
- private Map fileMap = null;
-
- public static final IProgramElement NO_STRUCTURE = new ProgramElement("<build to view structure>", IProgramElement.Kind.ERROR, null);
-
- public IProgramElement getElement(String handle) {
- throw new RuntimeException("unimplemented");
- }
-
- public IProgramElement getRoot() {
- return root;
- }
-
- public void setRoot(IProgramElement root) {
- this.root = root;
- }
-
- public void addToFileMap( Object key, Object value ){
- fileMap.put( key, value );
- }
-
- public void setFileMap(HashMap fileMap) {
- this.fileMap = fileMap;
- }
-
- public Object findInFileMap( Object key ) {
- return fileMap.get(key);
- }
-
-
- public Set getFileMapEntrySet() {
- return fileMap.entrySet();
- }
-
- public boolean isValid() {
- return root != null && fileMap != null;
- }
-
-
- /**
- * Returns the first match
- *
- * @param parent
- * @param kind not null
- * @param decErrLabel
- * @return null if not found
- */
- public IProgramElement findNode(IProgramElement parent, IProgramElement.Kind kind, String name) {
- for (Iterator it = parent.getChildren().iterator(); it.hasNext(); ) {
- IProgramElement node = (IProgramElement)it.next();
- if (node.getKind().equals(kind)
- && name.equals(node.getName())) {
- return node;
- } else {
- IProgramElement childSearch = findNode(node, kind, name);
- if (childSearch != null) return childSearch;
- }
- }
- return null;
- }
-
- /**
- *
- * @param signatureKey PackageName.TypeName.Signature.SourceLine.SourceColumn
- */
- public IProgramElement findNodeForSignatureKey(String signatureKey) {
- throw new RuntimeException("unimplemented");
- }
-
- /**
- * @param packageName if null default package is searched
- * @param className can't be null
- */
- public IProgramElement findNodeForType(String packageName, String typeName) {
- IProgramElement packageNode = null;
- if (packageName == null) {
- packageNode = root;
- } else {
- for (Iterator it = root.getChildren().iterator(); it.hasNext(); ) {
- IProgramElement node = (IProgramElement)it.next();
- if (packageName.equals(node.getName())) {
- packageNode = node;
- }
- }
- if (packageNode == null) return null;
- }
-
- // this searches each file for a class
- for (Iterator it = packageNode.getChildren().iterator(); it.hasNext(); ) {
- IProgramElement fileNode = (IProgramElement)it.next();
- IProgramElement ret = findClassInNodes(fileNode.getChildren(), typeName);
- if (ret != null) return ret;
- }
-
- return null;
- }
-
- private IProgramElement findClassInNodes(Collection nodes, String name) {
- String baseName;
- String innerName;
- int dollar = name.indexOf('$');
- if (dollar == -1) {
- baseName = name;
- innerName = null;
- } else {
- baseName = name.substring(0, dollar);
- innerName = name.substring(dollar+1);
- }
-
- for (Iterator j = nodes.iterator(); j.hasNext(); ) {
- IProgramElement classNode = (IProgramElement)j.next();
- if (baseName.equals(classNode.getName())) {
- if (innerName == null) return classNode;
- else return findClassInNodes(classNode.getChildren(), innerName);
- } else if (name.equals(classNode.getName())) {
- return classNode;
- }
- }
- return null;
- }
-
-
- /**
- * @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 IProgramElement findRootNodeForSourceFile(String sourceFile) {
- try {
- if (!isValid() || sourceFile == null) {
- return AspectJModel.NO_STRUCTURE;
- } else {
- String correctedPath = new File(sourceFile).getCanonicalPath();//.replace('\\', '/');
- //StructureNode node = (StructureNode)getFileMap().get(correctedPath);//findFileNode(filePath, model);
- IProgramElement node = (IProgramElement)findInFileMap(correctedPath);//findFileNode(filePath, model);
- if (node != null) {
- return node;
- } else {
- return createFileStructureNode(correctedPath);
- }
- }
- } catch (Exception e) {
- return AspectJModel.NO_STRUCTURE;
- }
- }
-
- /**
- * TODO: discriminate columns
- */
- public IProgramElement findNodeForSourceLine(ISourceLocation location) {
- return findNodeForSourceLine(location.getSourceFile().getAbsolutePath(), location.getLine());
- }
-
- /**
- * Never returns null
- *
- * @param sourceFilePath canonicalized path for consistency
- * @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 IProgramElement findNodeForSourceLine(String sourceFilePath, int lineNumber) {
- IProgramElement node = findNodeForSourceLineHelper(root, sourceFilePath, lineNumber);
- if (node != null) {
- return node;
- } else {
- return createFileStructureNode(sourceFilePath);
- }
- }
-
- private IProgramElement createFileStructureNode(String sourceFilePath) {
- String fileName = new File(sourceFilePath).getName();
- 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 IProgramElement findNodeForSourceLineHelper(IProgramElement node, String sourceFilePath, int lineNumber) {
- if (matches(node, sourceFilePath, lineNumber)
- && !hasMoreSpecificChild(node, sourceFilePath, lineNumber)) {
- return node;
- }
-
- if (node != null && node.getChildren() != null) {
- for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
- IProgramElement foundNode = findNodeForSourceLineHelper(
- (IProgramElement)it.next(),
- sourceFilePath,
- lineNumber);
- if (foundNode != null) return foundNode;
- }
- }
-
- return null;
- }
-
- private boolean matches(IProgramElement node, String sourceFilePath, int lineNumber) {
- try {
-// if (node != null && node.getSourceLocation() != null)
-// System.err.println("====\n1: " +
-// sourceFilePath + "\n2: " +
-// node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath)
-// );
-
- return node != null
- && node.getSourceLocation() != null
- && node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath)
- && ((node.getSourceLocation().getLine() <= lineNumber
- && node.getSourceLocation().getEndLine() >= lineNumber)
- ||
- (lineNumber <= 1
- && node instanceof IProgramElement
- && ((IProgramElement)node).getKind().isSourceFileKind())
- );
- } catch (IOException ioe) {
- return false;
- }
- }
-
- private boolean hasMoreSpecificChild(IProgramElement node, String sourceFilePath, int lineNumber) {
- for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
- IProgramElement child = (IProgramElement)it.next();
- if (matches(child, sourceFilePath, lineNumber)) return true;
- }
- return false;
- }
-
- public String getConfigFile() {
- return configFile;
- }
-
- public void setConfigFile(String configFile) {
- this.configFile = configFile;
- }
-}
-
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2003 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
- * Xerox/PARC initial implementation
+ * Mik Kersten initial implementation
* ******************************************************************/
package org.aspectj.asm;
+import org.aspectj.asm.internal.*;
+import org.aspectj.asm.internal.*;
+
/**
* @author Mik Kersten
*/
public abstract class HierarchyWalker {
- private AspectJModel model;
+ private IHierarchy hierarchy;
public HierarchyWalker() {
super();
}
- public HierarchyWalker(AspectJModel model) {
- this.model = model;
+ public HierarchyWalker(IHierarchy hierarchy) {
+ this.hierarchy = hierarchy;
}
protected void preProcess(IProgramElement node) { }
--- /dev/null
+/* *******************************************************************
+ * 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.Serializable;
+import java.util.*;
+
+import org.aspectj.asm.internal.ProgramElement;
+import org.aspectj.bridge.ISourceLocation;
+
+/**
+ * @author Mik Kersten
+ */
+public interface IHierarchy extends Serializable {
+ public static final IProgramElement NO_STRUCTURE =
+ new ProgramElement(
+ "<build to view structure>",
+ IProgramElement.Kind.ERROR,
+ null);
+
+ public IProgramElement getElement(String handle);
+ public IProgramElement getRoot();
+ public void setRoot(IProgramElement root);
+ public void addToFileMap(Object key, Object value);
+ public void setFileMap(HashMap fileMap);
+ public Object findInFileMap(Object key);
+ public Set getFileMapEntrySet();
+ public boolean isValid();
+
+ /**
+ * @return null if not found
+ */
+ public IProgramElement findElementForHandle(String handle);
+
+ /**
+ * Returns the first match
+ *
+ * @param parent
+ * @param kind not null
+ * @return null if not found
+ */
+ public IProgramElement findElementForSignature(
+ IProgramElement parent,
+ IProgramElement.Kind kind,
+ String signature);
+
+ /**
+ * Returns the first match
+ *
+ * @param parent
+ * @param kind not null
+ * @return null if not found
+ */
+ public IProgramElement findElementForLabel(
+ IProgramElement parent,
+ IProgramElement.Kind kind,
+ String label);
+
+ /**
+ * @param packageName if null default package is searched
+ * @param className can't be null
+ */
+ public IProgramElement findElementForType(String packageName, String typeName);
+
+ /**
+ * @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 IProgramElement findElementForSourceFile(String sourceFile);
+
+ /**
+ * TODO: discriminate columns
+ */
+ public IProgramElement findElementForSourceLine(ISourceLocation location);
+
+ /**
+ * Never returns null
+ *
+ * @param sourceFilePath canonicalized path for consistency
+ * @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 IProgramElement findElementForSourceLine(String sourceFilePath, int lineNumber);
+
+ public String getConfigFile();
+
+ public void setConfigFile(String configFile);
+}
\ No newline at end of file
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2003 Contributors.
+ * 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:
+ * Mik Kersten initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.asm;
+
+import java.util.EventListener;
+
+import org.aspectj.asm.internal.*;
+
+/**
+ * Compiler listeners get notified of structure model update events.
+ *
+ * @author Mik Kersten
+ */
+public interface IHierarchyListener extends EventListener {
+
+ public void elementsUpdated(IHierarchy rootNode);
+}
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2003 Contributors.
* 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:
+ * Mik Kersten initial implementation
* ******************************************************************/
package org.aspectj.asm;
*/
public interface IProgramElement extends Serializable {
+ public static final String ID_DELIM = "|";
+
public List/*IProgramElement*/ getChildren();
public void setChildren(List children);
public String getName();
public void setName(String name);
+
+ public String getDetails();
+ public void setDetails(String details);
public IProgramElement.Kind getKind();
public void setKind(Kind kind);
public void setReturnType(String returnType);
public String getReturnType();
- public String getFullSignature();
- public void setFullSignature(String string);
+ public String toSignatureString();
public void setRunnable(boolean value);
public boolean isRunnable();
public void setSourceLocation(ISourceLocation sourceLocation);
public String toString();
+
+ /**
+ * Includes name, parameter types (if any) and details (if any).
+ */
+ public String toLabelString();
+
+ public List getParameterTypes();
+ public void setParameterTypes(List list);
+
+ public List getParameterNames();
+ public void setParameterNames(List list);
- // public String getHandle() TODO: check IJavaElement
+ /**
+ * The format of the string handle is not specified, but is stable across
+ * compilation sessions.
+ *
+ * @return a string representtaion of this element
+ */
+ public String getHandleIdentifier();
/**
* @return a string representation of this node and all of its children (recursive)
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 INTER_TYPE_PARENT = new Kind("inter-type parent");
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 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 CODE = new Kind("code");
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 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,
+ INTER_TYPE_PARENT,
+ CONSTRUCTOR,
+ METHOD,
+ FIELD,
+ POINTCUT,
+ ADVICE,
+ DECLARE_PARENTS,
+ DECLARE_WARNING,
+ DECLARE_ERROR,
+ DECLARE_SOFT,
+ DECLARE_PRECEDENCE,
+ CODE,
+ ERROR };
public static Kind getKindForString(String kindString) {
for (int i = 0; i < ALL.length; i++) {
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2003 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
- * Xerox/PARC initial implementation
+ * Mik Kersten initial implementation
* ******************************************************************/
public String getName();
- public List getTargets();
+ public List/*String*/ getTargets();
- public IProgramElement getSource();
+ public String getSourceHandle();
public Kind getKind();
public static final Kind ADVICE = new Kind("advice");
public static final Kind DECLARE = new Kind("declare");
+ public static final Kind DECLARE_INTER_TYPE = new Kind("inter-type declaration");
public static final Kind[] ALL = { ADVICE, DECLARE };
private final String name;
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2003 Contributors.
+ * 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:
+ * Mik Kersten initial implementation
+ * ******************************************************************/
+
+package org.aspectj.asm;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.aspectj.asm.IRelationship.Kind;
+
+/**
+ * Maps from a program element handles to a list of relationships between that element
+ * and othe program elements. Each element in the list or relationships is
+ * uniquely identified by a kind and a relationship name.
+ *
+ * The elemetns can be stored and looked up as IProgramElement(s), in which cases the
+ * element corresponding to the handle is looked up in the containment hierarchy.
+ *
+ * put/get methods taking IProgramElement as a parameter are for convenience only.
+ * They work identically to calling their counterparts with IProgramElement.getIdentifierHandle()
+ *
+ * @author Mik Kersten
+ */
+public interface IRelationshipMap extends Serializable {
+
+ /**
+ * @return an empty list if the element is not found.
+ */
+ public List/*IRelationship*/ get(IProgramElement source);
+
+ /**
+ * @return an empty list if the element is not found.
+ */
+ public List/*IRelationship*/ get(String handle);
+
+ /**
+ * Return a relationship matching the kind and name for the given element.
+ *
+ * @return null if the relationship is not found.
+ */
+ public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName);
+
+ /**
+ * Return a relationship matching the kind and name for the given element.
+ * Creates the relationship if not found.
+ *
+ * @return null if the relationship is not found.
+ */
+ public IRelationship get(String source, IRelationship.Kind kind, String relationshipName);
+
+ public void put(IProgramElement source, IRelationship relationship);
+
+ public void put(String handle, IRelationship relationship);
+
+ public void remove(String handle, IRelationship relationship);
+
+ public void removeAll(String source);
+
+}
+++ /dev/null
-/* *******************************************************************
- * Copyright (c) 2003 Contributors.
- * 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:
- * Mik Kersten initial implementation
- * ******************************************************************/
-
-package org.aspectj.asm;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.aspectj.asm.IRelationship.Kind;
-
-/**
- * Maps from a program element to a list of relationships between that element
- * and othe program elements. Each element in the list or relationships is
- * uniquely identified by a kind and a relationship name.
- *
- * @author Mik Kersten
- */
-public interface IRelationshipMapper extends Serializable {
-
- /**
- * @return an empty list if the element is not found.
- */
- public List get(IProgramElement source);
-
- /**
- * Return a relationship matching the kind and name for the given element.
- *
- * @return null if the relationship is not found.
- */
- public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName);
-
-
- public List/*IRelationship*/ get(String handle);
-
- public void put(IProgramElement source, IRelationship relationship);
-
-
-
-}
+++ /dev/null
-/* *******************************************************************
- * 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.EventListener;
-
-/**
- * Compiler listeners get notified of structure model update events.
- *
- * @author Mik Kersten
- */
-public interface IStructureModelListener extends EventListener {
-
- public void containmentHierarchyUpdated(AspectJModel rootNode);
-}
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2003 Contributors.
+ * 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:
+ * Mik Kersten initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.asm.internal;
+
+import java.io.*;
+import java.util.*;
+
+import org.aspectj.asm.*;
+import org.aspectj.asm.IProgramElement.Kind;
+import org.aspectj.bridge.*;
+
+/**
+ * @author Mik Kersten
+ */
+public class AspectJElementHierarchy implements IHierarchy {
+
+ protected IProgramElement root = null;
+ protected String configFile = null;
+
+ private Map fileMap = null;
+
+ public IProgramElement getElement(String handle) {
+ throw new RuntimeException("unimplemented");
+ }
+
+ public IProgramElement getRoot() {
+ return root;
+ }
+
+ public void setRoot(IProgramElement root) {
+ this.root = root;
+ }
+
+ public void addToFileMap( Object key, Object value ){
+ fileMap.put( key, value );
+ }
+
+ public void setFileMap(HashMap fileMap) {
+ this.fileMap = fileMap;
+ }
+
+ public Object findInFileMap( Object key ) {
+ return fileMap.get(key);
+ }
+
+
+ public Set getFileMapEntrySet() {
+ return fileMap.entrySet();
+ }
+
+ public boolean isValid() {
+ return root != null && fileMap != null;
+ }
+
+ /**
+ * Returns the first match
+ *
+ * @param parent
+ * @param kind not null
+ * @return null if not found
+ */
+ public IProgramElement findElementForSignature(IProgramElement parent, IProgramElement.Kind kind, String signature) {
+ for (Iterator it = parent.getChildren().iterator(); it.hasNext(); ) {
+ IProgramElement node = (IProgramElement)it.next();
+ if (node.getKind() == kind && signature.equals(node.toSignatureString())) {
+ return node;
+ } else {
+ IProgramElement childSearch = findElementForSignature(node, kind, signature);
+ if (childSearch != null) return childSearch;
+ }
+ }
+ return null;
+ }
+
+ public IProgramElement findElementForLabel(
+ IProgramElement parent,
+ IProgramElement.Kind kind,
+ String label) {
+
+ for (Iterator it = parent.getChildren().iterator(); it.hasNext(); ) {
+ IProgramElement node = (IProgramElement)it.next();
+ if (node.getKind() == kind && label.equals(node.toLabelString())) {
+ return node;
+ } else {
+ IProgramElement childSearch = findElementForSignature(node, kind, label);
+ if (childSearch != null) return childSearch;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param packageName if null default package is searched
+ * @param className can't be null
+ */
+ public IProgramElement findElementForType(String packageName, String typeName) {
+ IProgramElement packageNode = null;
+ if (packageName == null) {
+ packageNode = root;
+ } else {
+ for (Iterator it = root.getChildren().iterator(); it.hasNext(); ) {
+ IProgramElement node = (IProgramElement)it.next();
+ if (packageName.equals(node.getName())) {
+ packageNode = node;
+ }
+ }
+ if (packageNode == null) return null;
+ }
+
+ // this searches each file for a class
+ for (Iterator it = packageNode.getChildren().iterator(); it.hasNext(); ) {
+ IProgramElement fileNode = (IProgramElement)it.next();
+ IProgramElement ret = findClassInNodes(fileNode.getChildren(), typeName);
+ if (ret != null) return ret;
+ }
+
+ return null;
+ }
+
+ private IProgramElement findClassInNodes(Collection nodes, String name) {
+ String baseName;
+ String innerName;
+ int dollar = name.indexOf('$');
+ if (dollar == -1) {
+ baseName = name;
+ innerName = null;
+ } else {
+ baseName = name.substring(0, dollar);
+ innerName = name.substring(dollar+1);
+ }
+
+ for (Iterator j = nodes.iterator(); j.hasNext(); ) {
+ IProgramElement classNode = (IProgramElement)j.next();
+ if (baseName.equals(classNode.getName())) {
+ if (innerName == null) return classNode;
+ else return findClassInNodes(classNode.getChildren(), innerName);
+ } else if (name.equals(classNode.getName())) {
+ return classNode;
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * @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 IProgramElement findElementForSourceFile(String sourceFile) {
+ try {
+ if (!isValid() || sourceFile == null) {
+ return IHierarchy.NO_STRUCTURE;
+ } else {
+ String correctedPath = new File(sourceFile).getCanonicalPath();//.replace('\\', '/');
+ //StructureNode node = (StructureNode)getFileMap().get(correctedPath);//findFileNode(filePath, model);
+ IProgramElement node = (IProgramElement)findInFileMap(correctedPath);//findFileNode(filePath, model);
+ if (node != null) {
+ return node;
+ } else {
+ return createFileStructureNode(correctedPath);
+ }
+ }
+ } catch (Exception e) {
+ return IHierarchy.NO_STRUCTURE;
+ }
+ }
+
+ /**
+ * TODO: discriminate columns
+ */
+ public IProgramElement findElementForSourceLine(ISourceLocation location) {
+ try {
+ return findElementForSourceLine(location.getSourceFile().getCanonicalPath(), location.getLine());
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Never returns null
+ *
+ * @param sourceFilePath canonicalized path for consistency
+ * @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 IProgramElement findElementForSourceLine(String sourceFilePath, int lineNumber) {
+ IProgramElement node = findNodeForSourceLineHelper(root, sourceFilePath, lineNumber);
+ if (node != null) {
+ return node;
+ } else {
+ return createFileStructureNode(sourceFilePath);
+ }
+ }
+
+ private IProgramElement createFileStructureNode(String sourceFilePath) {
+ String fileName = new File(sourceFilePath).getName();
+ 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 IProgramElement findNodeForSourceLineHelper(IProgramElement node, String sourceFilePath, int lineNumber) {
+ if (matches(node, sourceFilePath, lineNumber)
+ && !hasMoreSpecificChild(node, sourceFilePath, lineNumber)) {
+ return node;
+ }
+
+ if (node != null && node.getChildren() != null) {
+ for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
+ IProgramElement foundNode = findNodeForSourceLineHelper(
+ (IProgramElement)it.next(),
+ sourceFilePath,
+ lineNumber);
+ if (foundNode != null) return foundNode;
+ }
+ }
+
+ return null;
+ }
+
+ private boolean matches(IProgramElement node, String sourceFilePath, int lineNumber) {
+ try {
+// if (node != null && node.getSourceLocation() != null)
+// System.err.println("====\n1: " +
+// sourceFilePath + "\n2: " +
+// node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath)
+// );
+ return node != null
+ && node.getSourceLocation() != null
+ && node.getSourceLocation().getSourceFile().getCanonicalPath().equals(sourceFilePath)
+ && ((node.getSourceLocation().getLine() <= lineNumber
+ && node.getSourceLocation().getEndLine() >= lineNumber)
+ ||
+ (lineNumber <= 1
+ && node.getKind().isSourceFileKind())
+ );
+ } catch (IOException ioe) {
+ return false;
+ }
+ }
+
+ private boolean hasMoreSpecificChild(IProgramElement node, String sourceFilePath, int lineNumber) {
+ for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
+ IProgramElement child = (IProgramElement)it.next();
+ if (matches(child, sourceFilePath, lineNumber)) return true;
+ }
+ return false;
+ }
+
+ public String getConfigFile() {
+ return configFile;
+ }
+
+ public void setConfigFile(String configFile) {
+ this.configFile = configFile;
+ }
+
+ // TODO: optimize this lookup
+ public IProgramElement findElementForHandle(String handle) {
+ StringTokenizer st = new StringTokenizer(handle, IProgramElement.ID_DELIM);
+ String file = st.nextToken();
+ int line = new Integer(st.nextToken()).intValue();
+ int col = new Integer(st.nextToken()).intValue();
+ // TODO: use column number when available
+ return findElementForSourceLine(file, line);
+
+// IProgramElement parent = findElementForType(packageName, typeName);
+// if (parent == null) return null;
+// if (kind == IProgramElement.Kind.CLASS ||
+// kind == IProgramElement.Kind.ASPECT) {
+// return parent;
+// } else {
+// return findElementForSignature(parent, kind, name);
+// }
+ }
+//
+// private IProgramElement findElementForBytecodeInfo(
+// IProgramElement node,
+// String parentName,
+// String name,
+// String signature) {
+// for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
+// IProgramElement curr = (IProgramElement)it.next();
+// if (parentName.equals(curr.getParent().getBytecodeName())
+// && name.equals(curr.getBytecodeName())
+// && signature.equals(curr.getBytecodeSignature())) {
+// return node;
+// } else {
+// IProgramElement childSearch = findElementForBytecodeInfo(curr, parentName, name, signature);
+// if (childSearch != null) return childSearch;
+// }
+// }
+// return null;
+// }
+}
+
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2003 Contributors.
* 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:
+ * Mik Kersten initial implementation
* ******************************************************************/
package org.aspectj.asm.internal;
+import java.io.IOException;
import java.util.*;
import org.aspectj.asm.*;
private String bytecodeSignature;
private String fullSignature;
private String returnType;
+
+ private List parameterNames = null;
+ private List parameterTypes = null;
+
+ private String details = null;
/**
* Used during de-externalization.
}
public String toString() {
- return getName();
+ return toLabelString();
}
private static List genModifiers(int modifiers) {
this.bytecodeSignature = bytecodeSignature;
}
- public String getFullSignature() {
- return fullSignature;
- }
-
- public void setFullSignature(String string) {
- fullSignature = string;
- }
+// public String getFullSignature() {
+// return fullSignature;
+// }
+//
+// public void setFullSignature(String string) {
+// fullSignature = string;
+// }
public void setKind(Kind kind) {
this.kind = kind;
this.modifiers = genModifiers(i);
}
- public String getSignatureKey() {
- return packageName + '/'
- + name + ':'
- + sourceLocation.getLine() + ':'
- + sourceLocation.getColumn();
+ public String toSignatureString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(name);
+
+ if (parameterTypes != null ) {
+ sb.append('(');
+ for (Iterator it = parameterTypes.iterator(); it.hasNext(); ) {
+ sb.append((String)it.next());
+ if (it.hasNext()) sb.append(", ");
+ }
+ sb.append(')');
+ }
+
+ return sb.toString();
}
+ public String toLabelString() {
+ String label = toSignatureString();
+ if (details != null) {
+ label += ": " + details;
+ }
+ return label;
+ }
+
+ public String getHandleIdentifier() {
+ try {
+ StringBuffer sb = new StringBuffer();
+ if (sourceLocation == null) {
+ return null;
+ } else {
+ sb.append(sourceLocation.getSourceFile().getCanonicalPath());
+ sb.append(ID_DELIM);
+ sb.append(sourceLocation.getLine());
+ sb.append(ID_DELIM);
+ sb.append(sourceLocation.getColumn());
+ return sb.toString();
+ }
+ } catch (IOException ioe) {
+ return null;
+ }
+ }
+
+ public List getParameterNames() {
+ return parameterNames;
+ }
+
+ public List getParameterTypes() {
+ return parameterTypes;
+ }
+
+ public void setParameterNames(List list) {
+ parameterNames = list;
+ }
+
+ public void setParameterTypes(List list) {
+ parameterTypes = list;
+ }
+
+ public String getDetails() {
+ return details;
+ }
+
+ public void setDetails(String string) {
+ details = string;
+ }
}
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * Copyright (c) 2003 Contributors.
* 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:
+ * Mik Kersten initial implementation
* ******************************************************************/
private String name;
private Kind kind;
- private IProgramElement source;
+ private String sourceHandle;
private List targets;
public Relationship(
String name,
Kind kind,
- IProgramElement source,
+ String sourceHandle,
List targets) {
this.name = name;
this.kind = kind;
- this.source = source;
+ this.sourceHandle = sourceHandle;
this.targets = targets;
}
return name;
}
- public IProgramElement getSource() {
- return source;
+ public String getSourceHandle() {
+ return sourceHandle;
}
public List getTargets() {
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2003 Contributors.
+ * 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:
+ * Mik Kersten initial implementation
+ * ******************************************************************/
+
+package org.aspectj.asm.internal;
+
+import java.util.*;
+
+import org.aspectj.asm.*;
+
+/**
+ * TODO: add a remove, and a clear all
+ *
+ * @author Mik Kersten
+ *
+ */
+public class RelationshipMap extends HashMap implements IRelationshipMap {
+
+ private IHierarchy hierarchy;
+
+ public RelationshipMap(IHierarchy hierarchy) {
+ this.hierarchy = hierarchy;
+ }
+
+ public List get(String handle) {
+ List relationships = (List)super.get(handle);
+ if (relationships == null) {
+ return null;
+ } else {
+ return relationships;
+ }
+ }
+
+ public List get(IProgramElement source) {
+ return get(source.getHandleIdentifier());
+ }
+
+ public IRelationship get(String source, IRelationship.Kind kind, String relationshipName) {
+ List relationships = get(source);
+ if (relationships == null) {
+ relationships = new ArrayList();
+ IRelationship rel = new Relationship(relationshipName, kind, source, new ArrayList());
+ relationships.add(rel);
+ super.put(source, relationships);
+ return rel;
+ } else {
+ for (Iterator it = relationships.iterator(); it.hasNext(); ) {
+ IRelationship curr = (IRelationship)it.next();
+ if (curr.getKind() == kind && curr.getName().equals(relationshipName)) {
+ return curr;
+ }
+ }
+ }
+ return null;
+ }
+
+ public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName) {
+ return get(source.getHandleIdentifier(), kind, relationshipName);
+ }
+
+ public void remove(String source, IRelationship relationship) {
+ List list = (List)super.get(source);
+ if (list != null) {
+ boolean matched = false;
+ for (Iterator it = list.iterator(); it.hasNext(); ) {
+ IRelationship curr = (IRelationship)it.next();
+ if (curr.getName().equals(relationship.getName())) {
+ curr.getTargets().addAll(relationship.getTargets());
+ matched = true;
+ }
+ }
+ if (!matched) list.remove(relationship);
+ }
+ }
+
+ public void removeAll(String source) {
+ List list = (List)super.remove(source);
+ }
+
+ public void put(String source, IRelationship relationship) {
+ System.err.println(">> for: " + source + ", put::" + relationship);
+
+ List list = (List)super.get(source);
+ if (list == null) {
+ list = new ArrayList();
+ list.add(relationship);
+ super.put(source, list);
+ } else {
+ boolean matched = false;
+ for (Iterator it = list.iterator(); it.hasNext(); ) {
+ IRelationship curr = (IRelationship)it.next();
+ if (curr.getName().equals(relationship.getName())
+ && curr.getKind() == relationship.getKind()) {
+ curr.getTargets().addAll(relationship.getTargets());
+ matched = true;
+ }
+ }
+ if (matched) list.add(relationship);
+ }
+ }
+
+ public void put(IProgramElement source, IRelationship relationship) {
+ put(source.getHandleIdentifier(), relationship);
+ }
+
+}
+++ /dev/null
-/* *******************************************************************
- * Copyright (c) 2003 Contributors.
- * 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:
- * Mik Kersten initial implementation
- * ******************************************************************/
-
-package org.aspectj.asm.internal;
-
-import java.util.*;
-
-import org.aspectj.asm.*;
-
-/**
- * @author Mik Kersten
- */
-public class RelationshipMapper extends HashMap implements IRelationshipMapper {
-
- public List get(IProgramElement source) {
- List relationships = (List)super.get(source);
- if (relationships == null) {
- return Collections.EMPTY_LIST;
- } else {
- return relationships;
- }
- }
-
- /**
- * @return null if the relationship is not found.
- */
- public IRelationship get(IProgramElement source, IRelationship.Kind kind, String relationshipName) {
- List relationships = get(source);
- for (Iterator it = relationships.iterator(); it.hasNext(); ) {
- IRelationship curr = (IRelationship)it.next();
- if (curr.getKind() == kind && curr.getName() == relationshipName) {
- return curr;
- }
- }
- return null;
- }
-
- public List get(String handle) {
- throw new RuntimeException("unimplemented");
- }
-
- public void put(IProgramElement source, IRelationship relationship) {
- List list = (List)super.get(source);
- if (list == null) {
- list = new ArrayList();
- list.add(relationship);
- super.put(source, list);
- } else {
- boolean matched = false;
- for (Iterator it = list.iterator(); it.hasNext(); ) {
- IRelationship curr = (IRelationship)it.next();
- if (curr.getName().equals(relationship.getName())) {
- curr.getTargets().addAll(relationship.getTargets());
- matched = true;
- }
- }
- if (!matched) list.add(relationship);
- }
- }
-
- // TODO: add a remove, and a clear all
-
- private static class RelationshipTable {
- private IRelationship relationship;
- private Map map;
-
- public RelationshipTable(IRelationship relationship) {
- this.relationship = relationship;
- map = new HashMap();
- }
-
- public Map getMap() {
- return map;
- }
-
- public IRelationship getRelationship() {
- return relationship;
- }
- }
-
-}
import java.util.*;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
+import org.aspectj.asm.*;
+import org.aspectj.asm.IProgramElement;
+import org.aspectj.asm.internal.Relationship;
import org.aspectj.bridge.IMessage;
import org.aspectj.weaver.*;
import org.aspectj.weaver.patterns.*;
needOldStyleWarning = false;
}
onType.addInterTypeMunger(munger);
+
+ AsmInterTypeRelationshipProvider.addRelationship(onType, munger);
}
}
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2003 Contributors.
+ * 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:
+ * Mik Kersten initial implementation
+ * ******************************************************************/
+
+package org.aspectj.ajdt.internal.compiler.lookup;
+
+import java.util.*;
+
+import org.aspectj.asm.*;
+import org.aspectj.asm.internal.Relationship;
+import org.aspectj.weaver.*;
+
+/**
+ * @author Mik Kersten
+ */
+public class AsmInterTypeRelationshipProvider {
+
+ public static final String INTER_TYPE_DECLARES = "declares on";
+ public static final String INTER_TYPE_DECLARED_BY = "aspect declarations";
+
+ public static void addRelationship(
+ ResolvedTypeX onType,
+ EclipseTypeMunger munger) {
+
+ IProgramElement.Kind kind = IProgramElement.Kind.ERROR;
+ if (munger.getMunger().getKind() == ResolvedTypeMunger.Field) {
+ kind = IProgramElement.Kind.INTER_TYPE_FIELD;
+ } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Constructor) {
+ kind = IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR;
+ } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Method) {
+ kind = IProgramElement.Kind.INTER_TYPE_METHOD;
+ } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Parent) {
+ kind = IProgramElement.Kind.INTER_TYPE_PARENT;
+ }
+
+ if (munger.getSourceLocation() != null
+ && munger.getSourceLocation() != null) {
+ String sourceHandle =
+ munger.getSourceLocation().getSourceFile().getAbsolutePath() + IProgramElement.ID_DELIM
+ + munger.getSourceLocation().getLine() + IProgramElement.ID_DELIM
+ + munger.getSourceLocation().getColumn();
+
+ String targetHandle =
+ onType.getSourceLocation().getSourceFile().getAbsolutePath() + IProgramElement.ID_DELIM
+ + onType.getSourceLocation().getLine() + IProgramElement.ID_DELIM
+ + onType.getSourceLocation().getColumn();
+
+ IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
+ if (sourceHandle != null && targetHandle != null) {
+ IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.ADVICE, INTER_TYPE_DECLARES);
+ foreward.getTargets().add(targetHandle);
+
+ IRelationship back = mapper.get(targetHandle, IRelationship.Kind.ADVICE, INTER_TYPE_DECLARED_BY);
+ back.getTargets().add(sourceHandle);
+ }
+ }
+ }
+
+}
import org.aspectj.ajdt.internal.compiler.parser.AjParser;
import org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter;
import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
import org.aspectj.asm.internal.ProgramElement;
import org.aspectj.bridge.*;
import org.aspectj.weaver.World;
private int compiledCount;
private int sourceFileCount;
- private AspectJModel structureModel;
+ private IHierarchy structureModel;
public AjBuildConfig buildConfig;
AjState state = new AjState(this);
if (batch) {
// System.err.println("XXXX batch: " + buildConfig.getFiles());
if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
- bcelWorld.setModel(AsmManager.getDefault().getModel());
+ bcelWorld.setModel(AsmManager.getDefault().getHierarchy());
// in incremental build, only get updated model?
}
performCompilation(buildConfig.getFiles());
private void setupModel() {
String rootLabel = "<root>";
- AspectJModel model = AsmManager.getDefault().getModel();
+ IHierarchy model = AsmManager.getDefault().getHierarchy();
IProgramElement.Kind kind = IProgramElement.Kind.FILE_JAVA;
if (buildConfig.getConfigFile() != null) {
rootLabel = buildConfig.getConfigFile().getName();
}
- public void setStructureModel(AspectJModel structureModel) {
+ public void setStructureModel(IHierarchy structureModel) {
this.structureModel = structureModel;
}
/**
* Returns null if there is no structure model
*/
- public AspectJModel getStructureModel() {
+ public IHierarchy getStructureModel() {
return structureModel;
}
--- /dev/null
+/* *******************************************************************
+ * 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.ajdt.internal.core.builder;
+
+import java.util.*;
+
+import org.aspectj.ajdt.internal.compiler.ast.*;
+import org.aspectj.asm.IProgramElement;
+import org.aspectj.weaver.*;
+import org.aspectj.weaver.patterns.*;
+import org.eclipse.jdt.internal.compiler.ast.*;
+
+public class AsmElementFormatter {
+
+ public static final String DECLARE_PRECEDENCE = "precedence";
+ public static final String DECLARE_SOFT = "soft";
+ public static final String DECLARE_PARENTS = "parents";
+ public static final String DECLARE_WARNING = "warning";
+ public static final String DECLARE_ERROR = "error";
+ public static final String DECLARE_UNKNONWN = "<unknown declare>";
+ public static final String POINTCUT_ABSTRACT = "<abstract pointcut>";
+ public static final String POINTCUT_ANONYMOUS = "<anonymous pointcut>";
+ public static final int MAX_MESSAGE_LENGTH = 18;
+ public static final String DEC_LABEL = "declare";
+
+ public void genLabelAndKind(MethodDeclaration methodDeclaration, IProgramElement node) {
+
+ if (methodDeclaration instanceof AdviceDeclaration) {
+ AdviceDeclaration ad = (AdviceDeclaration)methodDeclaration;
+ node.setKind(IProgramElement.Kind.ADVICE);
+
+ if (ad.kind == AdviceKind.Around) {
+ node.setReturnType(ad.returnTypeToString(0));
+ }
+
+ String details = "";
+ if (ad.pointcutDesignator != null) {
+ if (ad.pointcutDesignator.getPointcut() instanceof ReferencePointcut) {
+ ReferencePointcut rp = (ReferencePointcut)ad.pointcutDesignator.getPointcut();
+ details += rp.name + "..";
+ } else if (ad.pointcutDesignator.getPointcut() instanceof AndPointcut) {
+ AndPointcut ap = (AndPointcut)ad.pointcutDesignator.getPointcut();
+ if (ap.getLeft() instanceof ReferencePointcut) {
+ details += ap.getLeft().toString() + "..";
+ } else {
+ details += POINTCUT_ANONYMOUS + "..";
+ }
+ } else if (ad.pointcutDesignator.getPointcut() instanceof OrPointcut) {
+ OrPointcut op = (OrPointcut)ad.pointcutDesignator.getPointcut();
+ if (op.getLeft() instanceof ReferencePointcut) {
+ details += op.getLeft().toString() + "..";
+ } else {
+ details += POINTCUT_ANONYMOUS + "..";
+ }
+ } else {
+ details += POINTCUT_ANONYMOUS;
+ }
+ } else {
+ details += POINTCUT_ABSTRACT;
+ }
+ node.setName(ad.kind.toString());
+ node.setDetails(details);
+ setParameters(methodDeclaration, node);
+
+ } else if (methodDeclaration instanceof PointcutDeclaration) {
+ PointcutDeclaration pd = (PointcutDeclaration)methodDeclaration;
+ node.setKind(IProgramElement.Kind.POINTCUT);
+ node.setName(translatePointcutName(new String(methodDeclaration.selector)));
+ setParameters(methodDeclaration, node);
+
+ } else if (methodDeclaration instanceof DeclareDeclaration) {
+ DeclareDeclaration declare = (DeclareDeclaration)methodDeclaration;
+ String name = DEC_LABEL + " ";
+ if (declare.declare instanceof DeclareErrorOrWarning) {
+ DeclareErrorOrWarning deow = (DeclareErrorOrWarning)declare.declare;
+
+ if (deow.isError()) {
+ node.setKind( IProgramElement.Kind.DECLARE_ERROR);
+ name += DECLARE_ERROR;
+ } else {
+ node.setKind( IProgramElement.Kind.DECLARE_WARNING);
+ name += DECLARE_WARNING;
+ }
+ node.setName(name) ;
+ node.setDetails("\"" + genDeclareMessage(deow.getMessage()) + "\"");
+
+ } else if (declare.declare instanceof DeclareParents) {
+ node.setKind( IProgramElement.Kind.DECLARE_PARENTS);
+ DeclareParents dp = (DeclareParents)declare.declare;
+ node.setName(name + DECLARE_PARENTS);
+ node.setDetails(genTypePatternLabel(dp.getChild()));
+
+ } else if (declare.declare instanceof DeclareSoft) {
+ node.setKind( IProgramElement.Kind.DECLARE_SOFT);
+ DeclareSoft ds = (DeclareSoft)declare.declare;
+ node.setName(name + DECLARE_SOFT);
+ node.setDetails(genTypePatternLabel(ds.getException()));
+
+ } else if (declare.declare instanceof DeclarePrecedence) {
+ node.setKind( IProgramElement.Kind.DECLARE_PRECEDENCE);
+ DeclarePrecedence ds = (DeclarePrecedence)declare.declare;
+ node.setName(name + DECLARE_PRECEDENCE);
+ node.setDetails(genPrecedenceListLabel(ds.getPatterns()));
+
+
+ } else {
+ node.setKind(IProgramElement.Kind.ERROR);
+ node.setName(DECLARE_UNKNONWN);
+ }
+
+ } else if (methodDeclaration instanceof InterTypeDeclaration) {
+ InterTypeDeclaration itd = (InterTypeDeclaration)methodDeclaration;
+ String name = itd.onType.toString() + "." + new String(itd.getDeclaredSelector());
+ if (methodDeclaration instanceof InterTypeFieldDeclaration) {
+ node.setKind(IProgramElement.Kind.INTER_TYPE_FIELD);
+ } else if (methodDeclaration instanceof InterTypeMethodDeclaration) {
+ node.setKind(IProgramElement.Kind.INTER_TYPE_METHOD);
+ InterTypeMethodDeclaration itmd = (InterTypeMethodDeclaration)methodDeclaration;
+ } else if (methodDeclaration instanceof InterTypeConstructorDeclaration) {
+ node.setKind(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR);
+ InterTypeConstructorDeclaration itcd = (InterTypeConstructorDeclaration)methodDeclaration;
+ } else {
+ node.setKind(IProgramElement.Kind.ERROR);
+ }
+ node.setName(name);
+ node.setReturnType(itd.returnType.toString());
+ if (node.getKind() != IProgramElement.Kind.INTER_TYPE_FIELD) {
+ setParameters(methodDeclaration, node);
+ }
+ } else {
+ if (methodDeclaration.isConstructor()) {
+ node.setKind(IProgramElement.Kind.CONSTRUCTOR);
+ } else {
+ node.setKind(IProgramElement.Kind.METHOD);
+ }
+ String label = new String(methodDeclaration.selector);
+ node.setName(label);
+ setParameters(methodDeclaration, node);
+ }
+ }
+
+
+ private String genPrecedenceListLabel(TypePatternList list) {
+ String tpList = "";
+ for (int i = 0; i < list.size(); i++) {
+ tpList += genTypePatternLabel(list.get(i));
+ if (i < list.size()-1) tpList += ", ";
+ }
+ return tpList;
+ }
+
+// private String genArguments(MethodDeclaration md) {
+// String args = "";
+// Argument[] argArray = md.arguments;
+// if (argArray == null) return args;
+// for (int i = 0; i < argArray.length; i++) {
+// String argName = new String(argArray[i].name);
+// String argType = argArray[i].type.toString();
+// if (acceptArgument(argName, argType)) {
+// args += argType + ", ";
+// }
+// }
+// int lastSepIndex = args.lastIndexOf(',');
+// if (lastSepIndex != -1 && args.endsWith(", ")) args = args.substring(0, lastSepIndex);
+// return args;
+// }
+
+ private void setParameters(MethodDeclaration md, IProgramElement pe) {
+ Argument[] argArray = md.arguments;
+ List names = new ArrayList();
+ List types = new ArrayList();
+ pe.setParameterNames(names);
+ pe.setParameterTypes(types);
+
+ if (argArray == null) return;
+ for (int i = 0; i < argArray.length; i++) {
+ String argName = new String(argArray[i].name);
+ String argType = argArray[i].type.toString();
+ if (acceptArgument(argName, argType)) {
+ names.add(argName);
+ types.add(argType);
+ }
+ }
+ }
+
+ // TODO: fix this way of determing ajc-added arguments, make subtype of Argument with extra info
+ private boolean acceptArgument(String name, String type) {
+ return !name.startsWith("ajc$this_")
+ && !type.equals("org.aspectj.lang.JoinPoint.StaticPart")
+ && !type.equals("org.aspectj.lang.JoinPoint")
+ && !type.equals("org.aspectj.runtime.internal.AroundClosure");
+ }
+
+
+ public String genTypePatternLabel(TypePattern tp) {
+ final String TYPE_PATTERN_LITERAL = "<type pattern>";
+ String label;
+ TypeX typeX = tp.getExactType();
+
+ if (typeX != ResolvedTypeX.MISSING) {
+ label = typeX.getName();
+ if (tp.isIncludeSubtypes()) label += "+";
+ } else {
+ label = TYPE_PATTERN_LITERAL;
+ }
+ return label;
+
+ }
+
+ public String genDeclareMessage(String message) {
+ int length = message.length();
+ if (length < MAX_MESSAGE_LENGTH) {
+ return message;
+ } else {
+ return message.substring(0, MAX_MESSAGE_LENGTH-1) + "..";
+ }
+ }
+
+// // TODO:
+// private String translateAdviceName(String label) {
+// if (label.indexOf("before") != -1) return "before";
+// if (label.indexOf("returning") != -1) return "after returning";
+// if (label.indexOf("after") != -1) return "after";
+// if (label.indexOf("around") != -1) return "around";
+// else return "<advice>";
+// }
+
+// // !!! move or replace
+// private String translateDeclareName(String name) {
+// int colonIndex = name.indexOf(":");
+// if (colonIndex != -1) {
+// return name.substring(0, colonIndex);
+// } else {
+// return name;
+// }
+// }
+
+ // !!! move or replace
+// private String translateInterTypeDecName(String name) {
+// int index = name.lastIndexOf('$');
+// if (index != -1) {
+// return name.substring(index+1);
+// } else {
+// return name;
+// }
+// }
+
+ // !!! move or replace
+ private String translatePointcutName(String name) {
+ int index = name.indexOf("$$")+2;
+ int endIndex = name.lastIndexOf('$');
+ if (index != -1 && endIndex != -1) {
+ return name.substring(index, endIndex);
+ } else {
+ return name;
+ }
+ }
+
+
+}
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.*;
import org.aspectj.asm.internal.ProgramElement;
import org.aspectj.bridge.*;
import org.aspectj.util.LangUtil;
public static void build(
CompilationUnitDeclaration unit,
- AspectJModel structureModel) {
+ IHierarchy structureModel) {
LangUtil.throwIaxIfNull(unit, "unit");
new AsmHierarchyBuilder(unit.compilationResult()).internalBuild(unit, structureModel);
}
private final Stack stack;
private final CompilationResult currCompilationResult;
- private AsmNodeFormatter formatter = new AsmNodeFormatter();
+ private AsmElementFormatter formatter = new AsmElementFormatter();
protected AsmHierarchyBuilder(CompilationResult result) {
LangUtil.throwIaxIfNull(result, "result");
*/
private void internalBuild(
CompilationUnitDeclaration unit,
- AspectJModel structureModel) {
+ IHierarchy structureModel) {
LangUtil.throwIaxIfNull(structureModel, "structureModel");
if (!currCompilationResult.equals(unit.compilationResult())) {
throw new IllegalArgumentException("invalid unit: " + unit);
}
/**
- * Get/create teh node (package or root) to add to.
+ * Get/create the node (package or root) to add to.
*/
private IProgramElement genAddToNode(
CompilationUnitDeclaration unit,
- AspectJModel structureModel) {
+ IHierarchy structureModel) {
final IProgramElement addToNode;
{
ImportReference currentPackage = unit.currentPackage;
typeDeclaration.modifiers, "",
new ArrayList());
-// peNode.setFullSignature(typeDeclaration.());
-
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
"",
new ArrayList());
- peNode.setFullSignature(memberTypeDeclaration.toString());
-
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
return true;
return (IProgramElement)stack.peek();
}
- public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
+ public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
IProgramElement peNode = new ProgramElement(
"",
IProgramElement.Kind.ERROR,
// TODO: add return type test
if (peNode.getKind().equals(IProgramElement.Kind.METHOD)) {
- if (peNode.getName().equals("main(String[])")
+ if (peNode.toLabelString().equals("main(String[])")
&& peNode.getModifiers().contains(IProgramElement.Modifiers.STATIC)
&& peNode.getAccessibility().equals(IProgramElement.Accessibility.PUBLIC)) {
((IProgramElement)stack.peek()).setRunnable(true);
+++ /dev/null
-/* *******************************************************************
- * 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.ajdt.internal.core.builder;
-
-import java.util.Iterator;
-
-import org.aspectj.ajdt.internal.compiler.ast.*;
-import org.aspectj.asm.IProgramElement;
-import org.aspectj.weaver.*;
-import org.aspectj.weaver.patterns.*;
-import org.eclipse.jdt.internal.compiler.ast.*;
-
-public class AsmNodeFormatter {
-
- public static final String DECLARE_PRECEDENCE = "precedence: ";
- public static final String DECLARE_SOFT = "soft: ";
- public static final String DECLARE_PARENTS = "parents: ";
- public static final String DECLARE_WARNING = "warning: ";
- public static final String DECLARE_ERROR = "error: ";
- public static final String DECLARE_UNKNONWN = "<unknown declare>";
- public static final String POINTCUT_ABSTRACT = "<abstract pointcut>";
- public static final String POINTCUT_ANONYMOUS = "<anonymous pointcut>";
- public static final int MAX_MESSAGE_LENGTH = 18;
- public static final String DEC_LABEL = "declare";
-
- public void genLabelAndKind(MethodDeclaration methodDeclaration, IProgramElement node) {
- if (methodDeclaration instanceof AdviceDeclaration) {
- AdviceDeclaration ad = (AdviceDeclaration)methodDeclaration;
- node.setKind( IProgramElement.Kind.ADVICE);
- String label = "";
- label += ad.kind.toString();
- label += "(" + genArguments(ad) + "): ";
-
- if (ad.kind == AdviceKind.Around) {
- node.setReturnType(ad.returnTypeToString(0));
- }
-
- if (ad.pointcutDesignator != null) {
- if (ad.pointcutDesignator.getPointcut() instanceof ReferencePointcut) {
- ReferencePointcut rp = (ReferencePointcut)ad.pointcutDesignator.getPointcut();
- label += rp.name + "..";
- } else if (ad.pointcutDesignator.getPointcut() instanceof AndPointcut) {
- AndPointcut ap = (AndPointcut)ad.pointcutDesignator.getPointcut();
- if (ap.getLeft() instanceof ReferencePointcut) {
- label += ap.getLeft().toString() + "..";
- } else {
- label += POINTCUT_ANONYMOUS + "..";
- }
- } else if (ad.pointcutDesignator.getPointcut() instanceof OrPointcut) {
- OrPointcut op = (OrPointcut)ad.pointcutDesignator.getPointcut();
- if (op.getLeft() instanceof ReferencePointcut) {
- label += op.getLeft().toString() + "..";
- } else {
- label += POINTCUT_ANONYMOUS + "..";
- }
- } else {
- label += POINTCUT_ANONYMOUS;
- }
- } else {
- label += POINTCUT_ABSTRACT;
- }
- node.setName(label);
-
- } else if (methodDeclaration instanceof PointcutDeclaration) {
- PointcutDeclaration pd = (PointcutDeclaration)methodDeclaration;
- node.setKind( IProgramElement.Kind.POINTCUT);
- String label = translatePointcutName(new String(methodDeclaration.selector));
- label += "(" + genArguments(pd) + ")";
- node.setName(label);
-
- } else if (methodDeclaration instanceof DeclareDeclaration) {
- DeclareDeclaration declare = (DeclareDeclaration)methodDeclaration;
- String label = DEC_LABEL + " ";
- if (declare.declare instanceof DeclareErrorOrWarning) {
- DeclareErrorOrWarning deow = (DeclareErrorOrWarning)declare.declare;
-
- if (deow.isError()) {
- node.setKind( IProgramElement.Kind.DECLARE_ERROR);
- label += DECLARE_ERROR;
- } else {
- node.setKind( IProgramElement.Kind.DECLARE_WARNING);
- label += DECLARE_WARNING;
- }
- node.setName(label + "\"" + genDeclareMessage(deow.getMessage()) + "\"") ;
-
- } else if (declare.declare instanceof DeclareParents) {
- 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( 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( IProgramElement.Kind.DECLARE_PRECEDENCE);
- DeclarePrecedence ds = (DeclarePrecedence)declare.declare;
- node.setName(label + DECLARE_PRECEDENCE + genPrecedenceListLabel(ds.getPatterns()));
- } else {
- node.setKind( IProgramElement.Kind.ERROR);
- node.setName(DECLARE_UNKNONWN);
- }
-
- } else if (methodDeclaration instanceof InterTypeDeclaration) {
- InterTypeDeclaration itd = (InterTypeDeclaration)methodDeclaration;
- String label = itd.onType.toString() + "." + new String(itd.getDeclaredSelector());
- if (methodDeclaration instanceof InterTypeFieldDeclaration) {
- node.setKind(IProgramElement.Kind.INTER_TYPE_FIELD);
- } else if (methodDeclaration instanceof InterTypeMethodDeclaration) {
- node.setKind(IProgramElement.Kind.INTER_TYPE_METHOD);
- InterTypeMethodDeclaration itmd = (InterTypeMethodDeclaration)methodDeclaration;
- label += "(" + genArguments(itd) + ")";
- } else if (methodDeclaration instanceof InterTypeConstructorDeclaration) {
- node.setKind(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR);
- InterTypeConstructorDeclaration itcd = (InterTypeConstructorDeclaration)methodDeclaration;
- } else {
- node.setKind(IProgramElement.Kind.ERROR);
- }
- node.setName(label);
- node.setReturnType(itd.returnType.toString());
-
- } else {
- 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);
- }
- }
-
-
- private String genPrecedenceListLabel(TypePatternList list) {
- String tpList = "";
- for (int i = 0; i < list.size(); i++) {
- tpList += genTypePatternLabel(list.get(i));
- if (i < list.size()-1) tpList += ", ";
- }
- return tpList;
- }
-
- private String genArguments(MethodDeclaration md) {
- String args = "";
- Argument[] argArray = md.arguments;
- if (argArray == null) return args;
- for (int i = 0; i < argArray.length; i++) {
- String argName = new String(argArray[i].name);
- String argType = argArray[i].type.toString();
-// TODO: fix this way of determing ajc-added arguments, make subtype of Argument with extra info
- if (!argName.startsWith("ajc$this_")
- && !argType.equals("org.aspectj.lang.JoinPoint.StaticPart")
- && !argType.equals("org.aspectj.lang.JoinPoint")
- && !argType.equals("org.aspectj.runtime.internal.AroundClosure")) {
- args += argType + ", ";
- }
- }
- int lastSepIndex = args.lastIndexOf(',');
- if (lastSepIndex != -1 && args.endsWith(", ")) args = args.substring(0, lastSepIndex);
- return args;
- }
-
- public String genTypePatternLabel(TypePattern tp) {
- final String TYPE_PATTERN_LITERAL = "<type pattern>";
- String label;
- TypeX typeX = tp.getExactType();
-
- if (typeX != ResolvedTypeX.MISSING) {
- label = typeX.getName();
- if (tp.isIncludeSubtypes()) label += "+";
- } else {
- label = TYPE_PATTERN_LITERAL;
- }
- return label;
-
- }
-
- public String genDeclareMessage(String message) {
- int length = message.length();
- if (length < MAX_MESSAGE_LENGTH) {
- return message;
- } else {
- return message.substring(0, MAX_MESSAGE_LENGTH-1) + "..";
- }
- }
-
-// // TODO:
-// private String translateAdviceName(String label) {
-// if (label.indexOf("before") != -1) return "before";
-// if (label.indexOf("returning") != -1) return "after returning";
-// if (label.indexOf("after") != -1) return "after";
-// if (label.indexOf("around") != -1) return "around";
-// else return "<advice>";
-// }
-
-// // !!! move or replace
-// private String translateDeclareName(String name) {
-// int colonIndex = name.indexOf(":");
-// if (colonIndex != -1) {
-// return name.substring(0, colonIndex);
-// } else {
-// return name;
-// }
-// }
-
- // !!! move or replace
-// private String translateInterTypeDecName(String name) {
-// int index = name.lastIndexOf('$');
-// if (index != -1) {
-// return name.substring(index+1);
-// } else {
-// return name;
-// }
-// }
-
- // !!! move or replace
- private String translatePointcutName(String name) {
- int index = name.indexOf("$$")+2;
- int endIndex = name.lastIndexOf('$');
- if (index != -1 && endIndex != -1) {
- return name.substring(index, endIndex);
- } else {
- return name;
- }
- }
-
-
-}
}
public void externalizeModel() {
- if (!AsmManager.getDefault().getModel().isValid()) return;
+ if (!AsmManager.getDefault().getHierarchy().isValid()) return;
try {
//Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMap().entrySet();
- Set fileSet = AsmManager.getDefault().getModel().getFileMapEntrySet();
+ Set fileSet = AsmManager.getDefault().getHierarchy().getFileMapEntrySet();
for (Iterator it = fileSet.iterator(); it.hasNext(); ) {
IProgramElement peNode = (IProgramElement)((Map.Entry)it.next()).getValue();
dumpStructureToFile(peNode);
}, messageWriter);
String err = parser.getOtherMessages(true);
assertTrue(err, null == err);
- manager.setStructureModel(AsmManager.getDefault().getModel());
+ manager.setStructureModel(AsmManager.getDefault().getHierarchy());
MessageHandler handler = new MessageHandler();
manager.batchBuild(buildConfig, handler);
assertCompileMessagesValid(handler);
+++ /dev/null
-/* *******************************************************************
- * 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
- *
- * Contributors:
- * PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.weaver;
-
-import java.util.*;
-
-import org.aspectj.asm.*;
-import org.aspectj.asm.internal.*;
-import org.aspectj.bridge.*;
-
-public class AsmAdapter {
-
- public static final String ADVISES = "advises";
- public static final String ADVISED_BY = "advised by";
- public static final String DECLARES_ON = "declares on";
- public static final String DECLAREDY_BY = "declared by";
-
- public static void checkerMunger(AspectJModel model, Shadow shadow) {
-// System.err.println("> " + shadow.getThisVar() + " to " + shadow.getTargetVar());
- }
-
- public static void nodeMunger(AspectJModel model, Shadow shadow, ShadowMunger munger) {
- if (munger instanceof Advice) {
- Advice a = (Advice)munger;
- if (a.getKind().isPerEntry() || a.getKind().isCflow()) {
- // TODO: might want to show these in the future
- return;
- }
- IRelationshipMapper mapper = AsmManager.getDefault().getMapper();
-
- IProgramElement targetNode = getNode(model, shadow);
- IProgramElement adviceNode = getNode(model, a);
-
- if (adviceNode != null && targetNode != null) {
- IRelationship foreward = mapper.get(adviceNode, IRelationship.Kind.ADVICE, ADVISES);
- if (foreward == null) {
- foreward = new Relationship(
- ADVISES,
- IRelationship.Kind.ADVICE,
- adviceNode,
- new ArrayList()
- );
- mapper.put(adviceNode, foreward);
- }
- foreward.getTargets().add(targetNode);
-
- IRelationship back = mapper.get(targetNode, IRelationship.Kind.ADVICE, ADVISED_BY);
- if (back == null) {
- back = new Relationship(
- ADVISED_BY,
- IRelationship.Kind.ADVICE,
- targetNode,
- new ArrayList()
- );
- mapper.put(targetNode, back);
- }
- back.getTargets().add(adviceNode);
- }
- }
- }
-
- private static IProgramElement getNode(AspectJModel model, Advice a) {
- //ResolvedTypeX inAspect = a.getConcreteAspect();
- Member member = a.getSignature();
- if (a.getSignature() == null) return null;
- return lookupMember(model, member);
- }
-
- private static IProgramElement getNode(AspectJModel model, Shadow shadow) {
- Member enclosingMember = shadow.getEnclosingCodeSignature();
-
- IProgramElement enclosingNode = lookupMember(model, enclosingMember);
- if (enclosingNode == null) {
- Lint.Kind err = shadow.getIWorld().getLint().shadowNotInStructure;
- if (err.isEnabled()) {
- err.signal(shadow.toString(), shadow.getSourceLocation());
- }
- return null;
- }
-
- Member shadowSig = shadow.getSignature();
- if (!shadowSig.equals(enclosingMember)) {
- IProgramElement bodyNode = findOrCreateBodyNode(enclosingNode, shadowSig, shadow);
- return bodyNode;
- } else {
- return enclosingNode;
- }
- }
-
- private static IProgramElement findOrCreateBodyNode(
- IProgramElement enclosingNode,
- Member shadowSig, Shadow shadow)
- {
- for (Iterator it = enclosingNode.getChildren().iterator(); it.hasNext(); ) {
- IProgramElement node = (IProgramElement)it.next();
- if (shadowSig.getName().equals(node.getBytecodeName()) &&
- shadowSig.getSignature().equals(node.getBytecodeSignature()))
- {
- return node;
- }
- }
-
- ISourceLocation sl = shadow.getSourceLocation();
-
- IProgramElement peNode = new ProgramElement(
- shadow.toString(),
- IProgramElement.Kind.CODE,
-//XXX why not use shadow file? new SourceLocation(sl.getSourceFile(), sl.getLine()),
- new SourceLocation(enclosingNode.getSourceLocation().getSourceFile(), sl.getLine()),
-// enclosingNode.getSourceLocation(),
- 0,
- "",
- new ArrayList());
-
- //System.err.println(peNode.getSourceLocation());
- peNode.setBytecodeName(shadowSig.getName());
- peNode.setBytecodeSignature(shadowSig.getSignature());
- enclosingNode.addChild(peNode);
- return peNode;
- }
-
- public static IProgramElement lookupMember(AspectJModel model, Member member) {
- TypeX declaringType = member.getDeclaringType();
- IProgramElement classNode =
- model.findNodeForType(declaringType.getPackageName(), declaringType.getClassName());
- return findMemberInClass(classNode, member);
- }
-
- 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(); ) {
- 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()))
- {
- return node;
- }
- }
- // if we can't find the member, we'll just put it in the class
- return classNode;
- }
-}
--- /dev/null
+/* *******************************************************************
+ * 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
+ *
+ * Contributors:
+ * PARC initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.weaver;
+
+import java.io.IOException;
+import java.util.*;
+
+import org.aspectj.asm.*;
+import org.aspectj.asm.internal.*;
+import org.aspectj.bridge.*;
+
+public class AsmAdviceRelationshipProvider {
+
+ public static final String ADVISES = "advises";
+ public static final String ADVISED_BY = "advised by";
+ public static final String DECLARES_ON = "declares on";
+ public static final String DECLAREDY_BY = "declared by";
+
+ public static void checkerMunger(IHierarchy model, Shadow shadow) {
+// System.err.println("> " + shadow.getThisVar() + " to " + shadow.getTargetVar());
+ }
+
+ public static void nodeMunger(IHierarchy model, Shadow shadow, ShadowMunger munger) {
+ if (munger instanceof Advice) {
+ Advice advice = (Advice)munger;
+ if (advice.getKind().isPerEntry() || advice.getKind().isCflow()) {
+ // TODO: might want to show these in the future
+ return;
+ }
+ IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
+ IProgramElement targetNode = getNode(AsmManager.getDefault().getHierarchy(), shadow);
+ try {
+ if (advice.getSourceLocation() != null && targetNode != null) {
+ String adviceHandle =
+ advice.getSourceLocation().getSourceFile().getCanonicalPath()
+ + IProgramElement.ID_DELIM + advice.getSourceLocation().getLine()
+ + IProgramElement.ID_DELIM + advice.getSourceLocation().getColumn();
+
+
+
+ if (targetNode != null) {
+ String targetHandle = targetNode.getHandleIdentifier();
+
+ IRelationship foreward = mapper.get(adviceHandle, IRelationship.Kind.ADVICE, ADVISES);
+ if (foreward != null) foreward.getTargets().add(targetHandle);
+
+ IRelationship back = mapper.get(targetHandle, IRelationship.Kind.ADVICE, ADVISED_BY);
+ if (back != null) back.getTargets().add(adviceHandle);
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static IProgramElement getNode(IHierarchy model, Shadow shadow) {
+ Member enclosingMember = shadow.getEnclosingCodeSignature();
+
+ IProgramElement enclosingNode = lookupMember(model, enclosingMember);
+ if (enclosingNode == null) {
+ Lint.Kind err = shadow.getIWorld().getLint().shadowNotInStructure;
+ if (err.isEnabled()) {
+ err.signal(shadow.toString(), shadow.getSourceLocation());
+ }
+ return null;
+ }
+
+ Member shadowSig = shadow.getSignature();
+ if (!shadowSig.equals(enclosingMember)) {
+ IProgramElement bodyNode = findOrCreateCodeNode(enclosingNode, shadowSig, shadow);
+ return bodyNode;
+ } else {
+ return enclosingNode;
+ }
+ }
+
+ private static IProgramElement findOrCreateCodeNode(IProgramElement enclosingNode, Member shadowSig, Shadow shadow)
+ {
+ for (Iterator it = enclosingNode.getChildren().iterator(); it.hasNext(); ) {
+ IProgramElement node = (IProgramElement)it.next();
+ if (shadowSig.getName().equals(node.getBytecodeName()) &&
+ shadowSig.getSignature().equals(node.getBytecodeSignature()))
+ {
+ return node;
+ }
+ }
+
+ ISourceLocation sl = shadow.getSourceLocation();
+
+ IProgramElement peNode = new ProgramElement(
+ shadow.toString(),
+ IProgramElement.Kind.CODE,
+ //XXX why not use shadow file? new SourceLocation(sl.getSourceFile(), sl.getLine()),
+ new SourceLocation(enclosingNode.getSourceLocation().getSourceFile(), sl.getLine()),
+ 0,
+ "",
+ new ArrayList());
+
+ peNode.setBytecodeName(shadowSig.getName());
+ peNode.setBytecodeSignature(shadowSig.getSignature());
+ enclosingNode.addChild(peNode);
+ return peNode;
+ }
+
+ private static IProgramElement lookupMember(IHierarchy model, Member member) {
+ TypeX declaringType = member.getDeclaringType();
+ IProgramElement classNode =
+ model.findElementForType(declaringType.getPackageName(), declaringType.getClassName());
+ return findMemberInClass(classNode, member);
+ }
+
+ 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(); ) {
+ 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()))
+ {
+ return node;
+ }
+ }
+ // if we can't find the member, we'll just put it in the class
+ return classNode;
+ }
+
+// private static IProgramElement.Kind genShadowKind(Shadow shadow) {
+// IProgramElement.Kind shadowKind;
+// if (shadow.getKind() == Shadow.MethodCall
+// || shadow.getKind() == Shadow.ConstructorCall
+// || shadow.getKind() == Shadow.FieldGet
+// || shadow.getKind() == Shadow.FieldSet
+// || shadow.getKind() == Shadow.ExceptionHandler) {
+// return IProgramElement.Kind.CODE;
+//
+// } else if (shadow.getKind() == Shadow.MethodExecution) {
+// return IProgramElement.Kind.METHOD;
+//
+// } else if (shadow.getKind() == Shadow.ConstructorExecution) {
+// return IProgramElement.Kind.CONSTRUCTOR;
+//
+// } else if (shadow.getKind() == Shadow.PreInitialization
+// || shadow.getKind() == Shadow.Initialization) {
+// return IProgramElement.Kind.CLASS;
+//
+// } else if (shadow.getKind() == Shadow.AdviceExecution) {
+// return IProgramElement.Kind.ADVICE;
+//
+// } else {
+// return IProgramElement.Kind.ERROR;
+// }
+// }
+
+}
shadow.getSourceLocation());
world.getMessageHandler().handleMessage(message);
- AsmAdapter.checkerMunger(world.getModel(), shadow);
+ AsmAdviceRelationshipProvider.checkerMunger(world.getModel(), shadow);
}
return false;
}
munger.implementOn(this);
if (world.getModel() != null) {
//System.err.println("munger: " + munger + " on " + this);
- AsmAdapter.nodeMunger(world.getModel(), this, munger);
+ AsmAdviceRelationshipProvider.nodeMunger(world.getModel(), this, munger);
}
}
}
package org.aspectj.weaver;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.aspectj.asm.AspectJModel;
-import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.Message;
-import org.aspectj.bridge.MessageUtil;
+import java.util.*;
+
+import org.aspectj.asm.IHierarchy;
+import org.aspectj.asm.internal.AspectJElementHierarchy;
+import org.aspectj.bridge.*;
import org.aspectj.bridge.IMessage.Kind;
-import org.aspectj.weaver.ResolvedTypeX.Name;
-import org.aspectj.weaver.patterns.DeclarePrecedence;
-import org.aspectj.weaver.patterns.Pointcut;
+import org.aspectj.weaver.patterns.*;
public abstract class World {
protected IMessageHandler messageHandler = IMessageHandler.SYSTEM_ERR;
protected CrosscuttingMembersSet crosscuttingMembersSet = new CrosscuttingMembersSet(this);
- protected AspectJModel model = null;
+ protected IHierarchy model = null;
protected Lint lint = new Lint(this);
return crosscuttingMembersSet;
}
- public AspectJModel getModel() {
+ public IHierarchy getModel() {
return model;
}
- public void setModel(AspectJModel model) {
+ public void setModel(IHierarchy model) {
this.model = model;
}