]> source.dussan.org Git - aspectj.git/commitdiff
enh 48072 - ICrossReferenceHandler support to get xref info from the weaver
authoracolyer <acolyer>
Fri, 23 Jan 2004 10:03:14 +0000 (10:03 +0000)
committeracolyer <acolyer>
Fri, 23 Jan 2004 10:03:14 +0000 (10:03 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
weaver/src/org/aspectj/weaver/Checker.java
weaver/src/org/aspectj/weaver/ICrossReferenceHandler.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/Shadow.java
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java

index 368ef006406a400c5e9675d5437730a4795212bc..3727498c1f3d52974022f9c97c86cf3a4ade16a6 100644 (file)
@@ -185,7 +185,7 @@ public class AjBuildManager {
     
     /** init only on initial batch compile? no file-specific options */
        private void initBcelWorld(IMessageHandler handler) throws IOException {
-               bcelWorld = new BcelWorld(buildConfig.getClasspath(), handler);
+               bcelWorld = new BcelWorld(buildConfig.getClasspath(), handler, null);
                bcelWorld.setXnoInline(buildConfig.isXnoInline());
                bcelWeaver = new BcelWeaver(bcelWorld);
                
index 3baa45175f80b97d1dcedab23bfaead64936d85c..c87221bfa179cdb2e674834b7176eab535912af4 100644 (file)
@@ -15,6 +15,7 @@ package org.aspectj.weaver;
 
 import java.util.*;
 
+import org.aspectj.asm.IRelationship;
 import org.aspectj.bridge.*;
 import org.aspectj.weaver.patterns.*;
 
@@ -54,7 +55,13 @@ public class Checker extends ShadowMunger {
                 new ISourceLocation[]{this.getSourceLocation()});
                        world.getMessageHandler().handleMessage(message);
                        
-                       AsmRelationshipProvider.checkerMunger(world.getModel(), shadow, this);
+                       if (world.xrefHandler != null) {
+                               world.xrefHandler.addCrossReference(this.getSourceLocation(),shadow.getSourceLocation(),IRelationship.Kind.DECLARE);
+                       }
+                       
+                       if (world.getModel() != null) {
+                               AsmRelationshipProvider.checkerMunger(world.getModel(), shadow, this);
+                       }
                }
                return false;
        }
diff --git a/weaver/src/org/aspectj/weaver/ICrossReferenceHandler.java b/weaver/src/org/aspectj/weaver/ICrossReferenceHandler.java
new file mode 100644 (file)
index 0000000..c0ffeae
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.asm.IRelationship;
+import org.aspectj.bridge.ISourceLocation;
+
+/**
+ * Clients can pass a single cross-reference handler to the weaver on construction
+ * of a BcelWorld. Any cross-references detected during munging will be notified
+ * to the handler.
+ */
+public interface ICrossReferenceHandler {
+
+       void addCrossReference(ISourceLocation from, ISourceLocation to, IRelationship.Kind kind);
+       
+}
index c79b4b87bc7a567176af98fb8a716a666409a8a2..3fbd92ab35a4cfe5e609381610640ad129b4232b 100644 (file)
@@ -19,6 +19,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.aspectj.asm.IRelationship;
 import org.aspectj.bridge.*;
 import org.aspectj.bridge.MessageUtil;
 import org.aspectj.lang.JoinPoint;
@@ -338,6 +339,11 @@ public abstract class Shadow {
                for (Iterator iter = mungers.iterator(); iter.hasNext();) {
                        ShadowMunger munger = (ShadowMunger) iter.next();
                        munger.implementOn(this);
+                       
+                       if (world.xrefHandler != null) {
+                               world.xrefHandler.addCrossReference(munger.getSourceLocation(),this.getSourceLocation(),IRelationship.Kind.ADVICE);
+                       }
+                       
                        if (world.getModel() != null) {
                                //System.err.println("munger: " + munger + " on " + this);
                                AsmRelationshipProvider.adviceMunger(world.getModel(), this, munger);
index 37406d20e6416e4b7e438749ca56c8a55bb1402d..289c5ae7f16fa51cdcb22d2fe794cfbd3d35a1c5 100644 (file)
@@ -30,6 +30,7 @@ import org.aspectj.weaver.patterns.Pointcut;
 
 public abstract class World {
        protected IMessageHandler messageHandler = IMessageHandler.SYSTEM_ERR;
+       protected ICrossReferenceHandler xrefHandler = null;
 
     protected Map typeMap = new HashMap(); // Signature to ResolvedType
     
@@ -241,6 +242,10 @@ public abstract class World {
                this.messageHandler = messageHandler;
        }
        
+       public void setXRefHandler(ICrossReferenceHandler xrefHandler) {
+               this.xrefHandler = xrefHandler;
+       }
+       
        public void showMessage(
                Kind kind,
                String message,
index 873b0781888b15b95a64daf21182b40435a4a451..512af4143e5579211ea5c2f3f5ee2406e4f769bb 100644 (file)
@@ -38,6 +38,7 @@ import org.aspectj.weaver.Advice;
 import org.aspectj.weaver.AdviceKind;
 import org.aspectj.weaver.AjAttribute;
 import org.aspectj.weaver.ConcreteTypeMunger;
+import org.aspectj.weaver.ICrossReferenceHandler;
 import org.aspectj.weaver.Member;
 import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedTypeMunger;
@@ -61,7 +62,7 @@ public class BcelWorld extends World {
        }
        
        public BcelWorld(String cp) {
-               this(makeDefaultClasspath(cp), IMessageHandler.THROW);
+               this(makeDefaultClasspath(cp), IMessageHandler.THROW, null);
        }
        
        private static List makeDefaultClasspath(String cp) {
@@ -82,10 +83,11 @@ public class BcelWorld extends World {
        return ret;
        }
        
-       public BcelWorld(List classPath, IMessageHandler handler) {
+       public BcelWorld(List classPath, IMessageHandler handler, ICrossReferenceHandler xrefHandler) {
                //this.aspectPath = new ClassPathManager(aspectPath, handler);
                this.classPath = new ClassPathManager(classPath, handler);
                setMessageHandler(handler);     
+               setXRefHandler(xrefHandler);
        }
        
        public void addPath (String name) {