]> source.dussan.org Git - aspectj.git/commitdiff
298704
authoraclement <aclement>
Mon, 25 Jan 2010 20:46:09 +0000 (20:46 +0000)
committeraclement <aclement>
Mon, 25 Jan 2010 20:46:09 +0000 (20:46 +0000)
weaver/src/org/aspectj/weaver/model/AsmRelationshipProvider.java

index b8a0c7ef8555c09fa59a589831d21125ef77bbb7..c6f004afcf8338b26b9b4430e2badf3724a4264f 100644 (file)
@@ -124,6 +124,7 @@ public class AsmRelationshipProvider {
                if (model == null) {
                        return;
                }
+
                if (World.createInjarHierarchy && isBinaryAspect(originatingAspect)) {
                        createHierarchy(model, typeTransformer, originatingAspect);
                }
@@ -140,6 +141,28 @@ public class AsmRelationshipProvider {
                                if (closer != null) {
                                        sourceNode = closer;
                                }
+                               if (sourceNode == null) {
+                                       // This can be caused by the aspect defining the type munger actually being on the classpath and not the
+                                       // inpath or aspectpath. Rather than NPE at the next line, let's have another go at faulting it in.
+                                       // This inner loop is a small duplicate of the outer loop that attempts to find something closer than
+                                       // the type declaration
+                                       if (World.createInjarHierarchy) {
+                                               createHierarchy(model, typeTransformer, originatingAspect);
+                                               if (typeTransformer.getSourceLocation() != null && typeTransformer.getSourceLocation().getOffset() != -1
+                                                               && !isMixinRelated(typeTransformer)) {
+                                                       sourceNode = model.getHierarchy().findElementForType(originatingAspect.getPackageName(),
+                                                                       originatingAspect.getClassName());
+                                                       IProgramElement closer2 = model.getHierarchy().findCloserMatchForLineNumber(sourceNode,
+                                                                       typeTransformer.getSourceLocation().getLine());
+                                                       if (closer2 != null) {
+                                                               sourceNode = closer2;
+                                                       }
+                                               } else {
+                                                       sourceNode = model.getHierarchy().findElementForType(originatingAspect.getPackageName(),
+                                                                       originatingAspect.getClassName());
+                                               }
+                                       }
+                               }
                                sourceHandle = sourceNode.getHandleIdentifier();
                        } else {
                                sourceNode = model.getHierarchy().findElementForType(originatingAspect.getPackageName(),