summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2004-08-17 09:43:12 +0000
committeraclement <aclement>2004-08-17 09:43:12 +0000
commitcd4aeb90df088cb6b9d817298529ac8d54e2b8eb (patch)
treee5c34620ec1ee022e12a22ae0314c89f03a1d74c
parenta2469c733c9f65514c3949cb1cc7254495011894 (diff)
downloadaspectj-cd4aeb90df088cb6b9d817298529ac8d54e2b8eb.tar.gz
aspectj-cd4aeb90df088cb6b9d817298529ac8d54e2b8eb.zip
remaining fix for 72016 (problem/type information flowing through AJDE)
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ExtensionTests.java22
-rw-r--r--bridge/src/org/aspectj/bridge/IMessage.java6
-rw-r--r--bridge/src/org/aspectj/bridge/Message.java14
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java5
-rw-r--r--testing/src/org/aspectj/testing/xml/SoftMessage.java17
-rw-r--r--weaver/src/org/aspectj/weaver/Checker.java4
6 files changed, 62 insertions, 6 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/ExtensionTests.java b/ajde/testsrc/org/aspectj/ajde/ExtensionTests.java
index ab492011f..ab1d1253b 100644
--- a/ajde/testsrc/org/aspectj/ajde/ExtensionTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/ExtensionTests.java
@@ -43,9 +43,9 @@ public class ExtensionTests extends AjcTestCase {
*
* ajc -warn:unusedImport UnusedImport.java
*
- * Expected result = id
+ * Expected result is that id matches IProblem.UnusedImport
*/
- public void testOutjarInInjars () {
+ public void testMessageID () {
String[] args = new String[] {"UnusedImport.java","-warn:unusedImport"};
CompilationResult result = ajc(baseDir,args);
List l = result.getWarningMessages();
@@ -128,4 +128,22 @@ public class ExtensionTests extends AjcTestCase {
}
+ /**
+ * Aim: Check that the start/end of certain warnings are correct
+ *
+ * ajc -warn:unusedImport UnusedImport.java
+ *
+ * Expected result is first warning message has start=7 end=20
+ */
+ public void testMessageSourceStartEnd() {
+ String[] args = new String[] {"UnusedImport.java","-warn:unusedImport"};
+ CompilationResult result = ajc(baseDir,args);
+ List l = result.getWarningMessages();
+ IMessage m = ((IMessage)l.get(0));
+ assertTrue("Expected source start to be 7 but was "+m.getSourceStart(),
+ m.getSourceStart()==7);
+ assertTrue("Expected source end to be 20 but was "+m.getSourceEnd(),
+ m.getSourceEnd()==20);
+ }
+
}
diff --git a/bridge/src/org/aspectj/bridge/IMessage.java b/bridge/src/org/aspectj/bridge/IMessage.java
index 7829633e9..b6050224e 100644
--- a/bridge/src/org/aspectj/bridge/IMessage.java
+++ b/bridge/src/org/aspectj/bridge/IMessage.java
@@ -76,6 +76,12 @@ public interface IMessage {
/** Return the ID of the message where applicable, see IProblem for list of valid IDs */
int getID();
+ /** Return the start position of the problem (inclusive), or -1 if unknown. */
+ int getSourceStart();
+
+ /** Return the end position of the problem (inclusive), or -1 if unknown. */
+ int getSourceEnd();
+
/** @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 b568f9641..02ecbb820 100644
--- a/bridge/src/org/aspectj/bridge/Message.java
+++ b/bridge/src/org/aspectj/bridge/Message.java
@@ -32,6 +32,7 @@ public class Message implements IMessage {
private final List/*SourceLocation*/ extraSourceLocations;
private final boolean declared; // Is it a DEOW ?
private final int id;
+ private final int sourceStart,sourceEnd;
/**
* Create a (compiler) error or warning message
@@ -63,14 +64,16 @@ 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,0);
+ this(message,details,kind,sourceLocation,thrown,extraSourceLocations,false,0,-1,-1);
}
public Message(String message, String details, IMessage.Kind kind,
ISourceLocation sLoc, Throwable thrown, ISourceLocation[] otherLocs,
- boolean declared,int id) {
+ boolean declared,int id,int sourcestart,int sourceend) {
this.details = details;
this.id = id;
+ this.sourceStart = sourcestart;
+ this.sourceEnd = sourceend;
this.message = ((message!=null) ? message : ((thrown==null) ? null : thrown.getMessage()));
this.kind = kind;
this.sourceLocation = sLoc;
@@ -182,4 +185,11 @@ public class Message implements IMessage {
return id;
}
+ public int getSourceStart() {
+ return sourceStart;
+ }
+
+ public int getSourceEnd() {
+ return sourceEnd;
+ }
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
index f3d5c2359..d13255aff 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
@@ -151,7 +151,10 @@ public class EclipseAdapterUtils {
problem.isError() ? IMessage.ERROR : IMessage.WARNING,
sourceLocation,
null,
- seeAlsoLocations,declared,problem.getID());
+ seeAlsoLocations,
+ declared,
+ problem.getID(),
+ problem.getSourceStart(),problem.getSourceEnd());
return msg;
}
diff --git a/testing/src/org/aspectj/testing/xml/SoftMessage.java b/testing/src/org/aspectj/testing/xml/SoftMessage.java
index 3f26e1509..cec8baf71 100644
--- a/testing/src/org/aspectj/testing/xml/SoftMessage.java
+++ b/testing/src/org/aspectj/testing/xml/SoftMessage.java
@@ -40,6 +40,7 @@ public class SoftMessage implements IMessage {
private ISourceLocation sourceLocation;
private String details;
private int id;
+ private int sourceStart,sourceEnd;
private final ArrayList extraSourceLocations = new ArrayList();
//private ISourceLocation pseudoSourceLocation; // set directly
@@ -332,6 +333,22 @@ public class SoftMessage implements IMessage {
public void setID(int id) {
this.id = id;
}
+
+ public int getSourceStart() {
+ return sourceStart;
+ }
+
+ public void setSourceStart(int s) {
+ sourceStart = s;
+ }
+
+ public int getSourceEnd() {
+ return sourceStart;
+ }
+
+ public void setSourceEnd(int s) {
+ sourceEnd = s;
+ }
/* (non-Javadoc)
* @see org.aspectj.bridge.IMessage#getExtraSourceLocations()
diff --git a/weaver/src/org/aspectj/weaver/Checker.java b/weaver/src/org/aspectj/weaver/Checker.java
index 84bde4564..8c8107e96 100644
--- a/weaver/src/org/aspectj/weaver/Checker.java
+++ b/weaver/src/org/aspectj/weaver/Checker.java
@@ -52,7 +52,9 @@ public class Checker extends ShadowMunger {
isError ? IMessage.ERROR : IMessage.WARNING,
shadow.getSourceLocation(),
null,
- new ISourceLocation[]{this.getSourceLocation()},true,0);
+ new ISourceLocation[]{this.getSourceLocation()},true,
+ 0, // id
+ -1,-1); // source start/end
world.getMessageHandler().handleMessage(message);