diff options
author | mkersten <mkersten> | 2003-08-14 09:07:44 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-08-14 09:07:44 +0000 |
commit | b5d8b449c79cbedc82e03381cc459ae8c8ae9718 (patch) | |
tree | 839c55908b7814d7fab40208b1c2afaa5fb84483 /ajde/src | |
parent | bffcd4c30591bce89ba938325159374e1ea1ea96 (diff) | |
download | aspectj-b5d8b449c79cbedc82e03381cc459ae8c8ae9718.tar.gz aspectj-b5d8b449c79cbedc82e03381cc459ae8c8ae9718.zip |
Updated org.aspectj.asm relationship model to string-handle-based API in order to support adding and removing relationships at any point in the compilation cycle, and to support external tools building relationships (e.g. JDT's incremental containment hierarchy builder). Also made inter-type declaration relationships show up in the model.
Diffstat (limited to 'ajde/src')
9 files changed, 63 insertions, 56 deletions
diff --git a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java index 578c04e0c..0923caa79 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java @@ -18,6 +18,7 @@ import java.util.*; import org.aspectj.ajde.Ajde; import org.aspectj.asm.*; +import org.aspectj.asm.internal.*; /** * Prototype functionality for package view clients. @@ -114,9 +115,9 @@ public class StructureModelUtil { 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( diff --git a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java index c1f77c243..835ccc5be 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java @@ -18,6 +18,7 @@ import java.util.*; import org.aspectj.ajde.Ajde; import org.aspectj.asm.*; +import org.aspectj.asm.internal.*; /** * @author Mik Kersten @@ -34,8 +35,8 @@ public class StructureSearchManager { 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); diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java index 7eb9dfa5f..b2fe1224f 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewManager.java @@ -19,6 +19,7 @@ import java.util.*; import org.aspectj.ajde.Ajde; import org.aspectj.ajde.ui.internal.*; import org.aspectj.asm.*; +import org.aspectj.asm.internal.*; /** * @author Mik Kersten @@ -35,8 +36,8 @@ public class StructureViewManager { 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) { @@ -44,7 +45,7 @@ public class StructureViewManager { // } for (Iterator it = structureViews.iterator(); it.hasNext(); ) { - treeViewBuilder.buildView((StructureView)it.next(), (AspectJModel)model); + treeViewBuilder.buildView((StructureView)it.next(), (AspectJElementHierarchy)model); } } }; @@ -84,7 +85,7 @@ public class StructureViewManager { * @param newFilePath the canonicalized path to the new file */ public void fireNavigationAction(String newFilePath, int lineNumber) { - IProgramElement currNode = Ajde.getDefault().getStructureModelManager().getModel().findNodeForSourceLine( + IProgramElement currNode = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceLine( newFilePath, lineNumber); @@ -116,7 +117,7 @@ public class StructureViewManager { */ 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; } @@ -127,7 +128,7 @@ public class StructureViewManager { if (defaultFileView.getSourceFile() != null && !defaultFileView.getSourceFile().equals(newFilePath)) { defaultFileView.setSourceFile(newFilePath); - treeViewBuilder.buildView(defaultFileView, AsmManager.getDefault().getModel()); + treeViewBuilder.buildView(defaultFileView, AsmManager.getDefault().getHierarchy()); } } @@ -161,7 +162,7 @@ public class StructureViewManager { 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); } @@ -195,7 +196,7 @@ public class StructureViewManager { 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; } diff --git a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java index 2339614ab..828d419ef 100644 --- a/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java +++ b/ajde/src/org/aspectj/ajde/ui/StructureViewNodeFactory.java @@ -36,25 +36,31 @@ public abstract class StructureViewNodeFactory { 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); + } + } + } } } } diff --git a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java index 239628176..ecf8ed5ae 100644 --- a/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java +++ b/ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java @@ -18,6 +18,7 @@ import java.util.*; import org.aspectj.ajde.ui.*; import org.aspectj.asm.*; +import org.aspectj.asm.internal.*; import org.aspectj.asm.internal.ProgramElement; /** @@ -34,17 +35,17 @@ public class TreeStructureViewBuilder { /** * @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(); @@ -197,7 +198,7 @@ public class TreeStructureViewBuilder { } } - private IStructureViewNode buildCustomTree(GlobalStructureView view, AspectJModel model) { + private IStructureViewNode buildCustomTree(GlobalStructureView view, IHierarchy model) { IProgramElement rootNode = model.getRoot(); IStructureViewNode treeNode = nodeFactory.createNode(rootNode); diff --git a/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java b/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java index bd1f9d76b..583ce0539 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/AjdeUIManager.java @@ -42,6 +42,7 @@ public class AjdeUIManager { private IdeUIAdapter ideUIAdapter = null; private TreeViewBuildConfigEditor buildConfigEditor = null; private IconRegistry iconRegistry; + private boolean initialized = false; private OptionsFrame optionsFrame = null; private Frame rootFrame = null; @@ -116,11 +117,13 @@ public class AjdeUIManager { 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); } @@ -190,6 +193,10 @@ public class AjdeUIManager { public IconRegistry getIconRegistry() { return iconRegistry; } + public boolean isInitialized() { + return initialized; + } + } //public abstract class AjdeAction { diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java b/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java index 66c3a0e0a..f5b3fb555 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SimpleStructureViewToolPanel.java @@ -14,27 +14,17 @@ 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 { @@ -60,10 +50,10 @@ 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); } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java b/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java index efb786b7f..9a32c26e5 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java @@ -35,7 +35,7 @@ class StructureTreeManager { private TreeSelectionListener treeListener = null; private final StructureTreeModel NO_STRUCTURE_MODEL - = new StructureTreeModel(new SwingTreeViewNode(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 diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java index dbd0c7aad..b7cbe7403 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java @@ -108,7 +108,7 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements IStruct if (kind == IStructureViewNode.Kind.RELATIONSHIP) { return relationshipName; } else { - return programElement.getName(); + return programElement.toLabelString(); } } |