]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for 134063
authoraclement <aclement>
Fri, 31 Mar 2006 14:38:58 +0000 (14:38 +0000)
committeraclement <aclement>
Fri, 31 Mar 2006 14:38:58 +0000 (14:38 +0000)
ajdoc/src/org/aspectj/tools/ajdoc/StructureUtil.java
ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java
ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java

index df063f2bd1b4f05cb53a2bbd6fed43eae5c75d53..9ac03867f78a8d5564d6a42fbe8191f3a4e59665 100644 (file)
@@ -44,7 +44,11 @@ public class StructureUtil {
         * @return null if a relationship of that kind is not found
         */
        public static List /*String*/ getTargets(IProgramElement node, IRelationship.Kind kind, String relName) {
-               List relations = AsmManager.getDefault().getRelationshipMap().get(node);
+               List relations = new ArrayList();
+               List rels = AsmManager.getDefault().getRelationshipMap().get(node);
+               if (rels != null) {
+                       relations.addAll(rels);
+               }
            for (Iterator iter = node.getChildren().iterator(); iter.hasNext();) {
                        IProgramElement child = (IProgramElement) iter.next();
                        // if we're not a type, or if we are and the child is code, then
@@ -54,25 +58,29 @@ public class StructureUtil {
                                        || child.getKind().equals(IProgramElement.Kind.CODE) ) {
                                List childRelations = AsmManager.getDefault().getRelationshipMap().get(child);
                                if (childRelations != null) {
-                                       if (relations == null) {
-                                               relations = childRelations;
-                                       } else {
-                                               relations.addAll(childRelations);
+                                       for (Iterator iterator = childRelations.iterator(); iterator
+                                                       .hasNext();) {
+                                               IRelationship rel = (IRelationship) iterator.next();
+                                               if (!relations.contains(rel)) {
+                                                       relations.add(rel);
+                                               }
                                        }
                                }                                       
                        }
                }                       
-               List targets = null; 
            if (relations == null || relations.isEmpty()) return null;
+               List targets = new ArrayList(); 
                for (Iterator it = relations.iterator(); it.hasNext(); ) {
                IRelationship rtn = (IRelationship)it.next();
                if (rtn.getKind().equals(kind)
                                && ((relName != null  && relName.equals(rtn.getName()))
                                                || relName == null)){
-                       if (targets == null) {
-                               targets = rtn.getTargets();
-                               } else {
-                                       targets.addAll(rtn.getTargets());
+                       List targs = rtn.getTargets();
+                       for (Iterator iter = targs.iterator(); iter.hasNext();) {
+                                       String element = (String) iter.next();
+                                       if (!targets.contains(element)) {
+                                               targets.add(element);
+                                       }
                                }
                }
             }
index 372c9c6371c9216323ac414665a1de2f08a98c28..3b79bdb1e89ed3c63edf11e066a6a15761b0a97c 100644 (file)
@@ -273,4 +273,27 @@ public class AjdocTestCase extends TestCase{
                }
         org.aspectj.tools.ajdoc.Main.main(args);
        }
+       
+       /**
+        * Run the ajdoc command with the given visibility argument,
+        * the default source level and the given input directories. 
+        */
+       public void runAjdoc(String visibility, String lstFile) {
+               if (!visibility.equals("public") 
+                               && !visibility.equals("protected")
+                               && !visibility.equals("private")) {
+                               fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
+               }
+       
+               String[] args = new String[8];
+               args[0] = "-" + visibility;
+               args[1] = "-classpath";
+               args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
+               args[3] = "-d";
+               args[4] = getAbsolutePathOutdir();
+               args[5] = "-sourcepath";
+               args[6] = getAbsoluteProjectDir();
+               args[7] = "@" + getAbsoluteProjectDir() + File.separatorChar + lstFile;
+        org.aspectj.tools.ajdoc.Main.main(args);
+       }
 }
index b6aa0c4b8f9ccef9bf9615cfdab611c69b9eb422..cefdae1d738f4d0ec8bd3db1668639687ec5188a 100644 (file)
@@ -11,6 +11,8 @@
  * ******************************************************************/
  package org.aspectj.tools.ajdoc;
 
+import java.io.File;
+
 
 /**
  * @author Mik Kersten
@@ -32,4 +34,8 @@ public class SpacewarTestCase extends AjdocTestCase {
                runAjdoc("public",dirs);
        }
 
+       public void testPr134063() {
+               String lstFile = "spacewar" + File.separatorChar + "demo.lst";
+               runAjdoc("private",lstFile);
+       }
 }