]> source.dussan.org Git - aspectj.git/commitdiff
265729: fault in binary aspects for itds/decps and search for them correctly
authoraclement <aclement>
Tue, 24 Feb 2009 19:17:28 +0000 (19:17 +0000)
committeraclement <aclement>
Tue, 24 Feb 2009 19:17:28 +0000 (19:17 +0000)
asm/src/org/aspectj/asm/IHierarchy.java
asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
asm/src/org/aspectj/asm/internal/HandleProviderDelimiter.java

index e1f3dded9f13917d941c6a2f70ea8f64fb22431f..d4351d17b7df24beb680dc45c49c5e35b6ef0e5a 100644 (file)
@@ -13,6 +13,7 @@ package org.aspectj.asm;
 
 import java.io.Serializable;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Set;
 
 import org.aspectj.asm.internal.ProgramElement;
@@ -102,4 +103,13 @@ public interface IHierarchy extends Serializable {
        public void flushHandleMap();
 
        public void updateHandleMap(Set deletedFiles);
+
+       /**
+        * For a specified node, check if any of the children more accurately represent the specified line.
+        * 
+        * @param node where to start looking
+        * @param lineno the line number
+        * @return any closer match below 'node' or null if nothing is a more accurate match
+        */
+       public IProgramElement findCloserMatchForLineNumber(IProgramElement node, int lineno);
 }
\ No newline at end of file
index 63066ba38dbee71dc59c4f9a78ee65f843ca940c..adee792fdf87f33830e7ac53d234623545a4b8cc 100644 (file)
@@ -224,6 +224,7 @@ public class AspectJElementHierarchy implements IHierarchy {
                                        }
                                }
                        }
+                       // 'binaries' will be checked automatically by the code above as it is represented as a SOURCE_FOLDER
                        return matchingPackageNodes;
                } else {
                        // dealing directly with packages below the root, no source folders. Therefore at most one
@@ -243,6 +244,20 @@ public class AspectJElementHierarchy implements IHierarchy {
                                                return result;
                                        }
                                }
+                               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;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
                        }
                }
                return Collections.EMPTY_LIST;
@@ -325,8 +340,8 @@ public class AspectJElementHierarchy implements IHierarchy {
        public IProgramElement findElementForSourceLine(String sourceFilePath, int lineNumber) {
                String canonicalSFP = asm.getCanonicalFilePath(new File(sourceFilePath));
                // Used to do this:
-//             IProgramElement node2 = findNodeForSourceLineHelper(root, canonicalSFP, lineNumber, -1);
-               
+               // IProgramElement node2 = findNodeForSourceLineHelper(root, canonicalSFP, lineNumber, -1);
+
                // Find the relevant source file node first
                IProgramElement node = findNodeForSourceFile(root, canonicalSFP);
                if (node == null) {
@@ -358,7 +373,7 @@ public class AspectJElementHierarchy implements IHierarchy {
                                return node;
                        }
                        return null; // no need to search children of a source file node
-               } else  {
+               } else {
                        // check the children
                        for (Iterator iterator = node.getChildren().iterator(); iterator.hasNext();) {
                                IProgramElement foundit = findNodeForSourceFile((IProgramElement) iterator.next(), sourcefilePath);
@@ -408,7 +423,7 @@ public class AspectJElementHierarchy implements IHierarchy {
         * @param lineno the line number
         * @return any closer match below 'node' or null if nothing is a more accurate match
         */
-       private IProgramElement findCloserMatchForLineNumber(IProgramElement node, int lineno) {
+       public IProgramElement findCloserMatchForLineNumber(IProgramElement node, int lineno) {
                for (Iterator childrenIter = node.getChildren().iterator(); childrenIter.hasNext();) {
                        IProgramElement child = (IProgramElement) childrenIter.next();
                        ISourceLocation childLoc = child.getSourceLocation();
@@ -421,11 +436,12 @@ public class AspectJElementHierarchy implements IHierarchy {
                                        } else {
                                                return evenCloserMatch;
                                        }
-                               } else if (child.getKind().isType()) { // types are a bit clueless about where they are... do other nodes have similar problems??
+                               } else if (child.getKind().isType()) { // types are a bit clueless about where they are... do other nodes have
+                                       // similar problems??
                                        IProgramElement evenCloserMatch = findCloserMatchForLineNumber(child, lineno);
                                        if (evenCloserMatch != null) {
                                                return evenCloserMatch;
-                                       }                                       
+                                       }
                                }
                        }
                }
index 396cba3a800f1418f4abd0ba719a0fb37dd34089..fb3221a5eac537f20b7f4cf875ffc897cc0a6073 100644 (file)
@@ -111,6 +111,8 @@ public class HandleProviderDelimiter {
                } else if (kind == IProgramElement.Kind.FILE) {
                        if (ipe.getName().endsWith(".class")) {
                                return CLASSFILE.getDelimiter();
+                       } else if (ipe.getName().endsWith(".aj")) {
+                               return ASPECT_CU.getDelimiter();
                        } else {
                                return empty;
                        }