aboutsummaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authoraclement <aclement>2004-08-03 12:31:29 +0000
committeraclement <aclement>2004-08-03 12:31:29 +0000
commit2982b4cc622a2a95429b16f0aa3c55b7e20d798a (patch)
treea1453e59e3356d36b7bacaf272298f91f6fa1407 /bridge
parentfe049bdf23ae91b938e64fc2106aebf72be34e3b (diff)
downloadaspectj-2982b4cc622a2a95429b16f0aa3c55b7e20d798a.tar.gz
aspectj-2982b4cc622a2a95429b16f0aa3c55b7e20d798a.zip
The BIG commit.
- Enhanced structure model support. - *Incremental* structure model support written and tested (currently switched off, see incModelTests.xml) - -showWeaveInfo compiler option - existence of a 'runtimetest' surfaced through relationships - UI can determine if errors/warnings came from DEOWs. - Code to enable type mungers to remember source locations written (currently switched off)
Diffstat (limited to 'bridge')
-rw-r--r--bridge/src/org/aspectj/bridge/IMessage.java6
-rw-r--r--bridge/src/org/aspectj/bridge/Message.java34
-rw-r--r--bridge/src/org/aspectj/bridge/MessageHandler.java3
-rw-r--r--bridge/src/org/aspectj/bridge/WeaveMessage.java75
4 files changed, 106 insertions, 12 deletions
diff --git a/bridge/src/org/aspectj/bridge/IMessage.java b/bridge/src/org/aspectj/bridge/IMessage.java
index 2bafc7d7a..fcb807016 100644
--- a/bridge/src/org/aspectj/bridge/IMessage.java
+++ b/bridge/src/org/aspectj/bridge/IMessage.java
@@ -27,6 +27,7 @@ public interface IMessage {
public static final IMessage[] RA_IMessage = new IMessage[0];
// int values must sync with KINDS order below
+ public static final Kind WEAVEINFO = new Kind("weaveinfo",5);
public static final Kind INFO = new Kind("info", 10);
public static final Kind DEBUG = new Kind("debug", 20);
public static final Kind WARNING = new Kind("warning", 30);
@@ -43,7 +44,7 @@ public interface IMessage {
public static final List KINDS =
Collections.unmodifiableList(
Arrays.asList(
- new Kind[] { INFO, DEBUG, WARNING, ERROR, FAIL, ABORT }));
+ new Kind[] { WEAVEINFO, INFO, DEBUG, WARNING, ERROR, FAIL, ABORT }));
/** @return non-null String with simple message */
String getMessage();
@@ -69,6 +70,9 @@ public interface IMessage {
/** @return true if something failed */
boolean isFailed();
+ /** Caller can verify if this message came about because of a DEOW */
+ boolean getDeclared();
+
/** @return Throwable associated with this message, or null if none */
Throwable getThrown();
diff --git a/bridge/src/org/aspectj/bridge/Message.java b/bridge/src/org/aspectj/bridge/Message.java
index af032b6de..1ddb18d69 100644
--- a/bridge/src/org/aspectj/bridge/Message.java
+++ b/bridge/src/org/aspectj/bridge/Message.java
@@ -30,6 +30,7 @@ public class Message implements IMessage {
private final ISourceLocation sourceLocation;
private final String details;
private final List/*SourceLocation*/ extraSourceLocations;
+ private final boolean declared; // Is it a DEOW ?
/**
* Create a (compiler) error or warning message
@@ -46,7 +47,7 @@ public class Message implements IMessage {
this(message, "",(isError ? IMessage.ERROR : IMessage.WARNING), location, null,
(extraSourceLocations.length > 0 ? extraSourceLocations : null));
}
-
+
/**
* Create a message, handling null values for message and kind
* if thrown is not null.
@@ -61,25 +62,31 @@ public class Message implements IMessage {
*/
public Message(String message, String details, IMessage.Kind kind,
ISourceLocation sourceLocation, Throwable thrown, ISourceLocation[] extraSourceLocations) {
+ this(message,details,kind,sourceLocation,thrown,extraSourceLocations,false);
+ }
+
+ public Message(String message, String details, IMessage.Kind kind,
+ ISourceLocation sLoc, Throwable thrown, ISourceLocation[] otherLocs,
+ boolean declared) {
this.details = details;
this.message = ((message!=null) ? message : ((thrown==null) ? null : thrown.getMessage()));
this.kind = kind;
- this.sourceLocation = sourceLocation;
+ this.sourceLocation = sLoc;
this.thrown = thrown;
-
- if (extraSourceLocations != null) {
+ if (otherLocs != null) {
this.extraSourceLocations
- = Collections.unmodifiableList(Arrays.asList(extraSourceLocations));
+ = Collections.unmodifiableList(Arrays.asList(otherLocs));
+ }
+ else {
+ this.extraSourceLocations = Collections.EMPTY_LIST;
}
- else {
- this.extraSourceLocations = Collections.EMPTY_LIST;
- }
if (null == this.kind) {
throw new IllegalArgumentException("null kind");
}
- if (null == this.message) {
- throw new IllegalArgumentException("null message");
- }
+ if (null == this.message) {
+ throw new IllegalArgumentException("null message");
+ }
+ this.declared = declared;
}
/**
@@ -130,6 +137,11 @@ public class Message implements IMessage {
return kind == IMessage.ABORT;
}
+ /** Caller can verify if this message came about because of a DEOW */
+ public boolean getDeclared() {
+ return declared;
+ }
+
/**
* @return true if kind == IMessage.FAIL
*/
diff --git a/bridge/src/org/aspectj/bridge/MessageHandler.java b/bridge/src/org/aspectj/bridge/MessageHandler.java
index 6882306e8..7187b2c46 100644
--- a/bridge/src/org/aspectj/bridge/MessageHandler.java
+++ b/bridge/src/org/aspectj/bridge/MessageHandler.java
@@ -55,6 +55,7 @@ public class MessageHandler implements IMessageHolder {
messages = new ArrayList();
ignoring = new ArrayList();
init(accumulateOnly);
+ ignore(IMessage.WEAVEINFO); // Off by default, need to explicitly be enabled (see -showWeaveInfo)
}
/**
@@ -76,7 +77,9 @@ public class MessageHandler implements IMessageHolder {
messages.clear();
}
if (0 < ignoring.size()) {
+ boolean ignoringWeaveMessages = isIgnoring(IMessage.WEAVEINFO);
ignoring.clear();
+ if (ignoringWeaveMessages) ignore(IMessage.WEAVEINFO);
}
if (null != interceptor) {
interceptor = null;
diff --git a/bridge/src/org/aspectj/bridge/WeaveMessage.java b/bridge/src/org/aspectj/bridge/WeaveMessage.java
new file mode 100644
index 000000000..e15abeae7
--- /dev/null
+++ b/bridge/src/org/aspectj/bridge/WeaveMessage.java
@@ -0,0 +1,75 @@
+/* *******************************************************************
+ * Copyright (c) 2004 IBM Corporation
+ * 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:
+ * Andy Clement IBM initial implementation 30-May-2004
+ * ******************************************************************/
+
+package org.aspectj.bridge;
+
+public class WeaveMessage extends Message {
+
+ // Kinds of weaving message we can produce
+
+ public static WeaveMessageKind WEAVEMESSAGE_DECLAREPARENTSIMPLEMENTS =
+ new WeaveMessageKind(1,"Extending interface set for type '%1' (%2) to include '%3' (%4)");
+
+ public static WeaveMessageKind WEAVEMESSAGE_ITD =
+ new WeaveMessageKind(2,"Type '%1' (%2) has intertyped %3 from '%4' (%5)");
+
+ // %6 is information like "[with runtime test]"
+ public static WeaveMessageKind WEAVEMESSAGE_ADVISES =
+ new WeaveMessageKind(3,"Type '%1' (%2) advised by %3 advice from '%4' (%5)%6");
+
+ public static WeaveMessageKind WEAVEMESSAGE_DECLAREPARENTSEXTENDS =
+ new WeaveMessageKind(4,"Setting superclass of type '%1' (%2) to '%3' (%4)");
+
+ public static WeaveMessageKind WEAVEMESSAGE_SOFTENS =
+ new WeaveMessageKind(5,"Softening exceptions in type '%1' (%2) as defined by aspect '%3' (%4)");
+
+
+ // private ctor - use the static factory method
+ private WeaveMessage(String message) {
+ super(message, IMessage.WEAVEINFO, null, null);
+ }
+
+ /**
+ * Static helper method for constructing weaving messages.
+ * @param kind what kind of message (e.g. declare parents)
+ * @param inserts inserts for the message (inserts are marked %n in the message)
+ * @param affectedtypename the type which is being advised/declaredUpon
+ * @param aspectname the aspect that defined the advice or declares
+ * @return new weaving message
+ */
+ public static WeaveMessage constructWeavingMessage(
+ WeaveMessageKind kind,
+ String[] inserts) {
+ StringBuffer str = new StringBuffer(kind.getMessage());
+ int pos = -1;
+ while ((pos=str.indexOf("%"))!=-1) {
+ int n = Character.getNumericValue(str.charAt(pos+1));
+ str.replace(pos,pos+2,inserts[n-1]);
+ }
+ return new WeaveMessage(str.toString());
+ }
+
+
+
+ public static class WeaveMessageKind {
+
+ private int id;
+ private String message;
+
+ public WeaveMessageKind(int id,String message) {
+ this.id = id;
+ this.message = message;
+ }
+
+ public String getMessage() { return message; }
+ }
+}