]> source.dussan.org Git - aspectj.git/commitdiff
269840: [model] package search fails in binary aspect in same package
authoraclement <aclement>
Tue, 24 Mar 2009 16:43:38 +0000 (16:43 +0000)
committeraclement <aclement>
Tue, 24 Mar 2009 16:43:38 +0000 (16:43 +0000)
asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java

index 8dcdd5bc7728d1e412681dda007fb375162dda1f..d7892b56d425ebb9376bd34d95ec0064f649cfd3 100644 (file)
@@ -235,32 +235,31 @@ public class AspectJElementHierarchy implements IHierarchy {
                                result.add(root);
                                return result;
                        }
+                       List result = new ArrayList();
                        for (Iterator iterator = children.iterator(); iterator.hasNext();) {
                                IProgramElement possiblePackage = (IProgramElement) iterator.next();
-                               if (possiblePackage.getKind() == IProgramElement.Kind.PACKAGE) {
-                                       if (possiblePackage.getName().equals(packagename)) {
-                                               List result = new ArrayList();
-                                               result.add(possiblePackage);
-                                               return result;
-                                       }
+                               if (possiblePackage.getKind() == IProgramElement.Kind.PACKAGE && possiblePackage.getName().equals(packagename)) {
+                                       result.add(possiblePackage);
                                }
                                if (possiblePackage.getKind() == IProgramElement.Kind.SOURCE_FOLDER) { // might be 'binaries'
                                        if (possiblePackage.getName().equals("binaries")) {
                                                for (Iterator iter2 = possiblePackage.getChildren().iterator(); iter2.hasNext();) {
                                                        IProgramElement possiblePackage2 = (IProgramElement) iter2.next();
-                                                       if (possiblePackage2.getKind() == IProgramElement.Kind.PACKAGE) {
-                                                               if (possiblePackage2.getName().equals(packagename)) {
-                                                                       List result = new ArrayList();
-                                                                       result.add(possiblePackage2);
-                                                                       return result;
-                                                               }
+                                                       if (possiblePackage2.getKind() == IProgramElement.Kind.PACKAGE
+                                                                       && possiblePackage2.getName().equals(packagename)) {
+                                                               result.add(possiblePackage2);
+                                                               break; // ok to break here, can't be another entry under binaries
                                                        }
                                                }
                                        }
                                }
                        }
+                       if (result.isEmpty()) {
+                               return Collections.EMPTY_LIST;
+                       } else {
+                               return result;
+                       }
                }
-               return Collections.EMPTY_LIST;
        }
 
        private IProgramElement findClassInNodes(Collection nodes, String name, String typeName) {