]> source.dussan.org Git - aspectj.git/commitdiff
remember source location and handle identifier across invocations
authoracolyer <acolyer>
Thu, 11 Sep 2003 08:46:16 +0000 (08:46 +0000)
committeracolyer <acolyer>
Thu, 11 Sep 2003 08:46:16 +0000 (08:46 +0000)
weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java
weaver/src/org/aspectj/weaver/ShadowMunger.java

index d2c837c65c2ff2fdcbb29a6ae5a4ab9786b43886..bd4d72876a5664adf0bc0d722b1887c966036b21 100644 (file)
@@ -15,7 +15,6 @@ package org.aspectj.weaver;
 
 import java.util.ArrayList;
 import java.util.Iterator;
-
 import org.aspectj.asm.*;
 import org.aspectj.asm.internal.ProgramElement;
 import org.aspectj.bridge.ISourceLocation;
@@ -61,12 +60,13 @@ public class AsmRelationshipProvider {
                                return;
                        }
                        IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
-                       IProgramElement targetNode = getNode(AsmManager.getDefault().getHierarchy(), shadow);
-                       if (advice.getSourceLocation() != null && targetNode != null) {
-                               String adviceHandle = ProgramElement.createHandleIdentifier(
-                                       advice.getSourceLocation().getSourceFile(),
-                                       advice.getSourceLocation().getLine(),
-                                       advice.getSourceLocation().getColumn());
+                       IProgramElement targetNode = getNode(AsmManager.getDefault().getHierarchy(), shadow);                   
+                       String adviceHandle = advice.getHandle(); 
+                       if (adviceHandle != null && targetNode != null) {
+//                             ProgramElement.createHandleIdentifier(
+//                                     advice.getSourceLocation().getSourceFile(),
+//                                     advice.getSourceLocation().getLine(),
+//                                     advice.getSourceLocation().getColumn());
                
                                if (targetNode != null) {
                                        String targetHandle = targetNode.getHandleIdentifier(); 
index a8cf1dd806626ae13185992b5083f1cc4b495fc2..57c629ff2e295386dc168dce4d9514b823004e02 100644 (file)
@@ -15,6 +15,7 @@ package org.aspectj.weaver;
 
 import java.util.Collection;
 
+import org.aspectj.asm.internal.ProgramElement;
 import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.util.PartialOrder;
 import org.aspectj.weaver.patterns.PerClause;
@@ -38,6 +39,8 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
        // these three fields hold the source location of this munger
        protected int start, end;
        protected ISourceContext sourceContext;
+       private ISourceLocation sourceLocation;
+       private String handle = null;
 
        
        public ShadowMunger(Pointcut pointcut, int start, int end, ISourceContext sourceContext) {
@@ -72,14 +75,27 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH
        }
        
     public ISourceLocation getSourceLocation() {
-       //System.out.println("get context: " + this + " is " + sourceContext);
-       if (sourceContext == null) {
-               //System.err.println("no context: " + this);
-               return null;
+       if (sourceLocation == null) {
+               if (sourceContext != null) {
+                               sourceLocation = sourceContext.makeSourceLocation(this);
+               }
        }
-       return sourceContext.makeSourceLocation(this);
+       return sourceLocation;
     }
 
+       public String getHandle() {
+               if (null == handle) {
+                       ISourceLocation sl = getSourceLocation();
+                       if (sl != null) {
+                               handle = ProgramElement.createHandleIdentifier(
+                                           sl.getSourceFile(),
+                                           sl.getLine(),
+                                           sl.getColumn());
+                       }
+               }
+               return handle;
+       }
+
        // ---- fields
        
     public static final ShadowMunger[] NONE = new ShadowMunger[0];