]> source.dussan.org Git - aspectj.git/commitdiff
Ported inline annotation support to new ASM API. Ported aspect visualizer. Improved...
authormkersten <mkersten>
Fri, 15 Aug 2003 00:22:07 +0000 (00:22 +0000)
committermkersten <mkersten>
Fri, 15 Aug 2003 00:22:07 +0000 (00:22 +0000)
ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNode.java
asm/src/org/aspectj/asm/AsmManager.java
asm/src/org/aspectj/asm/IProgramElement.java
asm/src/org/aspectj/asm/internal/ProgramElement.java

index b7cbe7403eda7a37e99bf83d92d3653781c59d78..de4da1406776c9ba5f075de36ee521ee77a85140 100644 (file)
@@ -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();
                }
index 3fcb353e07367abd6c0bf9ee7ef2876aaf33e64a..fced532bc59c4fc6500b0b1ca1a7e4da49acdc25 100644 (file)
@@ -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);
index 0c1b0595c75397d5b923650bd7cb36d3300b8c00..d15d944ab5fe4c696f74b4435603e1df5081b884 100644 (file)
@@ -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
index 830b323bdaccb74bc33cd7866cab7647b38ea07a..8e7743e8bd9dcfcda85a6106615fea148e799c11 100644 (file)
@@ -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) {