]> source.dussan.org Git - aspectj.git/commitdiff
fix for pr98290, 'matches declare' relationship not correctly created because offset...
authoracolyer <acolyer>
Thu, 1 Sep 2005 19:47:37 +0000 (19:47 +0000)
committeracolyer <acolyer>
Thu, 1 Sep 2005 19:47:37 +0000 (19:47 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java

index 9cad79a29c9771e2f0b614490b15a90f2fb987a8..5125ecc39fc7d6313a7852527a940327030afdb6 100644 (file)
@@ -3040,10 +3040,23 @@ public class BcelShadow extends Shadow {
                        return getEnclosingClass().getType().getSourceLocation();
                } else {
                    // For staticinitialization, if we have a nice offset, don't build a new source loc
-                       if (getKind()==Shadow.StaticInitialization && getEnclosingClass().getType().getSourceLocation().getOffset()!=0)
+                       if (getKind()==Shadow.StaticInitialization && getEnclosingClass().getType().getSourceLocation().getOffset()!=0) {
                                return getEnclosingClass().getType().getSourceLocation();
-                       else 
-                           return getEnclosingClass().getType().getSourceContext().makeSourceLocation(sourceLine, 0);
+                       } else {
+                               int offset = 0;
+                               Kind kind = getKind();
+                       if ( (kind == MethodExecution)  ||
+                                (kind == ConstructorExecution) ||
+                                        (kind == AdviceExecution) || 
+                                        (kind == StaticInitialization) ||
+                                        (kind == PreInitialization) ||
+                                        (kind == Initialization)) {
+                               if (getEnclosingMethod().hasDeclaredLineNumberInfo()) {
+                                       offset = getEnclosingMethod().getDeclarationOffset();
+                               }
+                       }
+                           return getEnclosingClass().getType().getSourceContext().makeSourceLocation(sourceLine, offset);
+                       }
                }
        }
 
index e3ce8170d7c6c7ce8579d5692ac4f92b33439c8c..cb31e7a36c0a267da85287e7b9b31f8a2859fd13 100644 (file)
@@ -210,6 +210,14 @@ public final class LazyMethodGen {
        }
     }
     
+       public int getDeclarationOffset() {
+       if (hasDeclaredLineNumberInfo()) {
+               return memberView.getDeclarationOffset();
+       } else {
+               return 0;
+       }
+       }
+    
     public void addAnnotation(AnnotationX ax) {
        initialize();
                if (memberView==null) {
@@ -1407,4 +1415,5 @@ public final class LazyMethodGen {
         newAttributes[attributes.length] = attr;
         attributes = newAttributes;
     }
+
 }