]> source.dussan.org Git - aspectj.git/commitdiff
remaining fix for 72016 (problem/type information flowing through AJDE)
authoraclement <aclement>
Tue, 17 Aug 2004 09:43:12 +0000 (09:43 +0000)
committeraclement <aclement>
Tue, 17 Aug 2004 09:43:12 +0000 (09:43 +0000)
ajde/testsrc/org/aspectj/ajde/ExtensionTests.java
bridge/src/org/aspectj/bridge/IMessage.java
bridge/src/org/aspectj/bridge/Message.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseAdapterUtils.java
testing/src/org/aspectj/testing/xml/SoftMessage.java
weaver/src/org/aspectj/weaver/Checker.java

index ab492011f79f4a4b329e96470a9de148873ad56d..ab1d1253be9e4cdfa86c73e88b119f2378ebf07c 100644 (file)
@@ -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);
+       }       
+
 }
index 7829633e925a25b9e0133ebce447245840fbbeb7..b6050224e9688ffcd4a8716c2ee447b437a1163a 100644 (file)
@@ -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();
 
index b568f9641fb5236e9215841db029a29d3abe7c40..02ecbb820b42368f38e63d81fa2c826030b59802 100644 (file)
@@ -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;
+       }
 }
index f3d5c23595489dad6164bb8dbfed48f13698cc45..d13255aff94c89b95ccfbd22d28a814fdf554476 100644 (file)
@@ -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;
     }               
 
index 3f26e15097a376893513144f329e82edc29c9f36..cec8baf71f869c0c905b0f0d7fca2856e7376751 100644 (file)
@@ -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()
index 84bde45644be2035a25651fd33793d84883aed97..8c8107e96f7fbfac023107a45c31970f834fe043 100644 (file)
@@ -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);