From: mkersten Date: Fri, 15 Aug 2003 00:22:07 +0000 (+0000) Subject: Ported inline annotation support to new ASM API. Ported aspect visualizer. Improved... X-Git-Tag: V1_1_1~89 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1c58e3476d511ec33a6cdb2df64124181c386357;p=aspectj.git Ported inline annotation support to new ASM API. Ported aspect visualizer. Improved link siganture generation. Improved ASM test coverage. --- diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java index b7cbe7403..de4da1406 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java @@ -107,6 +107,8 @@ public class SwingTreeViewNode extends DefaultMutableTreeNode implements IStruct public String toString() { if (kind == IStructureViewNode.Kind.RELATIONSHIP) { return relationshipName; + } else if (kind == IStructureViewNode.Kind.LINK) { + return programElement.toLinkLabelString(); } else { return programElement.toLabelString(); } 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 @@ -71,6 +71,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). */ @@ -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) {