diff options
author | mkersten <mkersten> | 2003-08-15 00:22:07 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-08-15 00:22:07 +0000 |
commit | 1c58e3476d511ec33a6cdb2df64124181c386357 (patch) | |
tree | c98fd9d185f930ef7e8e3e7f9363cd52aa5b855e /asm/src | |
parent | ae6983bd75683253edcb16e5e6875cbc1e8e4d8c (diff) | |
download | aspectj-1c58e3476d511ec33a6cdb2df64124181c386357.tar.gz aspectj-1c58e3476d511ec33a6cdb2df64124181c386357.zip |
Ported inline annotation support to new ASM API. Ported aspect visualizer. Improved link siganture generation. Improved ASM test coverage.
Diffstat (limited to 'asm/src')
-rw-r--r-- | asm/src/org/aspectj/asm/AsmManager.java | 89 | ||||
-rw-r--r-- | asm/src/org/aspectj/asm/IProgramElement.java | 11 | ||||
-rw-r--r-- | asm/src/org/aspectj/asm/internal/ProgramElement.java | 20 |
3 files changed, 75 insertions, 45 deletions
diff --git a/asm/src/org/aspectj/asm/AsmManager.java b/asm/src/org/aspectj/asm/AsmManager.java index 3fcb353e0..fced532bc 100644 --- a/asm/src/org/aspectj/asm/AsmManager.java +++ b/asm/src/org/aspectj/asm/AsmManager.java @@ -17,6 +17,7 @@ import java.io.*; import java.util.*; import org.aspectj.asm.internal.*; +import org.aspectj.bridge.ISourceLocation; /** * @author Mik Kersten @@ -64,53 +65,51 @@ public class AsmManager { String sourceFile, boolean showSubMember, boolean showMemberAndType) { - - throw new RuntimeException("unimplemented"); - -// if (!model.isValid()) return null; -// -// HashMap annotations = new HashMap(); -// IProgramElement node = model.findRootNodeForSourceFile(sourceFile); -// if (node == StructureModel.NO_STRUCTURE) { -// return null; -// } else { -// IProgramElement fileNode = (IProgramElement)node; -// ArrayList peNodes = new ArrayList(); -// getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType); -// for (Iterator it = peNodes.iterator(); it.hasNext(); ) { -// IProgramElement peNode = (IProgramElement)it.next(); -// List entries = new ArrayList(); -// entries.add(peNode); -// ISourceLocation sourceLoc = peNode.getSourceLocation(); -// if (null != sourceLoc) { -// Integer hash = new Integer(sourceLoc.getLine()); -// List existingEntry = (List)annotations.get(hash); -// if (existingEntry != null) { -// entries.addAll(existingEntry); -// } -// annotations.put(hash, entries); -// } -// } -// return annotations; -// } + + if (!hierarchy.isValid()) return null; + + HashMap annotations = new HashMap(); + IProgramElement node = hierarchy.findElementForSourceFile(sourceFile); + if (node == IHierarchy.NO_STRUCTURE) { + return null; + } else { + IProgramElement fileNode = (IProgramElement)node; + ArrayList peNodes = new ArrayList(); + getAllStructureChildren(fileNode, peNodes, showSubMember, showMemberAndType); + for (Iterator it = peNodes.iterator(); it.hasNext(); ) { + IProgramElement peNode = (IProgramElement)it.next(); + List entries = new ArrayList(); + entries.add(peNode); + ISourceLocation sourceLoc = peNode.getSourceLocation(); + if (null != sourceLoc) { + Integer hash = new Integer(sourceLoc.getLine()); + List existingEntry = (List)annotations.get(hash); + if (existingEntry != null) { + entries.addAll(existingEntry); + } + annotations.put(hash, entries); + } + } + return annotations; + } } -// private void getAllStructureChildren(IProgramElement node, List result, boolean showSubMember, boolean showMemberAndType) { -// List children = node.getChildren(); -// for (Iterator it = children.iterator(); it.hasNext(); ) { -// IProgramElement next = (IProgramElement)it.next(); -// if (next instanceof IProgramElement) { -// IProgramElement pNode = (IProgramElement)next; -// if (pNode != null -// && ((pNode.isCode() && showSubMember) || (!pNode.isCode() && showMemberAndType)) -// && pNode.getRelations() != null -// && pNode.getRelations().size() > 0) { -// result.add(next); -// } -// getAllStructureChildren((IProgramElement)next, result, showSubMember, showMemberAndType); -// } -// } -// } + private void getAllStructureChildren(IProgramElement node, List result, boolean showSubMember, boolean showMemberAndType) { + List children = node.getChildren(); + if (node.getChildren() == null) return; + for (Iterator it = children.iterator(); it.hasNext(); ) { + IProgramElement next = (IProgramElement)it.next(); + List rels = AsmManager.getDefault().getRelationshipMap().get(next); + if (next != null + && ((next.getKind() == IProgramElement.Kind.CODE && showSubMember) + || (next.getKind() != IProgramElement.Kind.CODE && showMemberAndType)) + && rels != null + && rels.size() > 0) { + result.add(next); + } + getAllStructureChildren((IProgramElement)next, result, showSubMember, showMemberAndType); + } + } public void addListener(IHierarchyListener listener) { structureListeners.add(listener); diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index 0c1b0595c..d15d944ab 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -72,6 +72,11 @@ public interface IProgramElement extends Serializable { public String toString(); /** + * Includes information about the origin of the node. + */ + public String toLinkLabelString(); + + /** * Includes name, parameter types (if any) and details (if any). */ public String toLabelString(); @@ -258,6 +263,12 @@ public interface IProgramElement extends Serializable { || this == POINTCUT || this == ADVICE; } + + public boolean isInterTypeMemberKind() { + return this == INTER_TYPE_CONSTRUCTOR + || this == INTER_TYPE_FIELD + || this == INTER_TYPE_METHOD; + } public boolean isTypeKind() { return this == CLASS diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index 830b323bd..8e7743e8b 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -384,6 +384,26 @@ public class ProgramElement implements IProgramElement { return sb.toString(); } + public String toLinkLabelString() { + String label; + if (kind == Kind.CODE || kind == Kind.INITIALIZER) { + label = parent.getParent().getName() + ": "; + } else if (kind.isInterTypeMemberKind()) { + int dotIndex = name.indexOf('.'); + if (dotIndex != -1) { + return parent.getName() + ": " + toLabelString().substring(dotIndex+1); + } else { + label = parent.getName() + '.'; + } + } else if (kind == Kind.CLASS || kind == kind.ASPECT) { + label = ""; + } else { + label = parent.getName() + '.'; + } + label += toLabelString(); + return label; + } + public String toLabelString() { String label = toSignatureString(); if (details != null) { |