diff options
author | acolyer <acolyer> | 2004-01-23 10:03:14 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-01-23 10:03:14 +0000 |
commit | f24286d65906e4fca5e2872ca1fa8295c1ab6bc7 (patch) | |
tree | 7b267c2d0b9a23ee0364b796a61e5da91815107b | |
parent | 36dc0a5c631183cd674f2482a7ee0fae090d60ea (diff) | |
download | aspectj-f24286d65906e4fca5e2872ca1fa8295c1ab6bc7.tar.gz aspectj-f24286d65906e4fca5e2872ca1fa8295c1ab6bc7.zip |
enh 48072 - ICrossReferenceHandler support to get xref info from the weaver
6 files changed, 49 insertions, 4 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 368ef0064..3727498c1 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -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); diff --git a/weaver/src/org/aspectj/weaver/Checker.java b/weaver/src/org/aspectj/weaver/Checker.java index 3baa45175..c87221bfa 100644 --- a/weaver/src/org/aspectj/weaver/Checker.java +++ b/weaver/src/org/aspectj/weaver/Checker.java @@ -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 index 000000000..c0ffeae40 --- /dev/null +++ b/weaver/src/org/aspectj/weaver/ICrossReferenceHandler.java @@ -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); + +} diff --git a/weaver/src/org/aspectj/weaver/Shadow.java b/weaver/src/org/aspectj/weaver/Shadow.java index c79b4b87b..3fbd92ab3 100644 --- a/weaver/src/org/aspectj/weaver/Shadow.java +++ b/weaver/src/org/aspectj/weaver/Shadow.java @@ -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); diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index 37406d20e..289c5ae7f 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -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, diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java index 873b07818..512af4143 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java @@ -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) { |