/** 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);
import java.util.*;
+import org.aspectj.asm.IRelationship;
import org.aspectj.bridge.*;
import org.aspectj.weaver.patterns.*;
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;
}
--- /dev/null
+/*******************************************************************************
+ * 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);
+
+}
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;
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);
public abstract class World {
protected IMessageHandler messageHandler = IMessageHandler.SYSTEM_ERR;
+ protected ICrossReferenceHandler xrefHandler = null;
protected Map typeMap = new HashMap(); // Signature to ResolvedType
this.messageHandler = messageHandler;
}
+ public void setXRefHandler(ICrossReferenceHandler xrefHandler) {
+ this.xrefHandler = xrefHandler;
+ }
+
public void showMessage(
Kind kind,
String message,
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;
}
public BcelWorld(String cp) {
- this(makeDefaultClasspath(cp), IMessageHandler.THROW);
+ this(makeDefaultClasspath(cp), IMessageHandler.THROW, null);
}
private static List makeDefaultClasspath(String cp) {
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) {