]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 72016: No problem type information from AspectJ compiler / AJDE
authoraclement <aclement>
Mon, 16 Aug 2004 16:44:13 +0000 (16:44 +0000)
committeraclement <aclement>
Mon, 16 Aug 2004 16:44:13 +0000 (16:44 +0000)
ajde/testdata/extensions/UnusedImport.java [new file with mode: 0644]
ajde/testsrc/org/aspectj/ajde/AjdeTests.java
ajde/testsrc/org/aspectj/ajde/ExtensionTests.java [new file with mode: 0644]
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

diff --git a/ajde/testdata/extensions/UnusedImport.java b/ajde/testdata/extensions/UnusedImport.java
new file mode 100644 (file)
index 0000000..ba561cc
--- /dev/null
@@ -0,0 +1,9 @@
+import java.util.List;
+import java.util.Vector;
+import java.util.ArrayList;
+
+public class UnusedImport {
+  public static void main(String[] argv) {
+    Vector v = new Vector();
+  }
+}
index a2155fd9baf3889716de504756a67b4592be2d6b..924ff6cbb8780dd87b210255772622bd1b6fcbe8 100644 (file)
@@ -39,6 +39,7 @@ public class AjdeTests extends TestCase {
                suite.addTestSuite(JarManifestTest.class);
                suite.addTestSuite(DuplicateManifestTest.class);
                suite.addTestSuite(ShowWeaveMessagesTestCase.class);
+               suite.addTestSuite(ExtensionTests.class);
                
         //$JUnit-END$
         return suite;
diff --git a/ajde/testsrc/org/aspectj/ajde/ExtensionTests.java b/ajde/testsrc/org/aspectj/ajde/ExtensionTests.java
new file mode 100644 (file)
index 0000000..d4659e3
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2004 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:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package org.aspectj.ajde;
+
+import java.util.List;
+import java.io.File;
+
+import org.aspectj.bridge.IMessage;
+import org.aspectj.tools.ajc.AjcTestCase;
+import org.aspectj.tools.ajc.CompilationResult;
+import org.eclipse.jdt.core.compiler.IProblem;
+
+/**
+ * Tests the 'extensions' to AJDE:
+ * 1) ID is now available on messages to allow you to see what 'kind' of 
+ *    message it is - this activates quick fixes/etc in Eclipse.
+ */
+public class ExtensionTests extends AjcTestCase {
+
+       public static final String PROJECT_DIR = "extensions";
+
+       private File baseDir;
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+               baseDir = new File("../ajde/testdata",PROJECT_DIR);
+       }
+       
+       /**
+        * Aim: Check that the ID of certain message kinds are correct
+        * 
+        *   ajc -warn:unusedImport UnusedImport.java
+        * 
+        * Expected result = id 
+        */
+       public void testOutjarInInjars () {
+               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 ID of message to be "+IProblem.UnusedImport+" (UnusedImport) but found an ID of "+m.getID(),
+                       m.getID()==IProblem.UnusedImport);
+       }
+       
+       
+
+}
index fcb8070166f681b31f9a733475b8f92eade3d8d1..7829633e925a25b9e0133ebce447245840fbbeb7 100644 (file)
@@ -73,6 +73,9 @@ public interface IMessage {
        /** Caller can verify if this message came about because of a DEOW */
        boolean getDeclared();
        
+       /** Return the ID of the message where applicable, see IProblem for list of valid IDs */
+       int getID();
+       
        /** @return Throwable associated with this message, or null if none */
        Throwable getThrown();
 
index 1ddb18d697654a5945056d3e125a34a6c2b96dc1..b568f9641fb5236e9215841db029a29d3abe7c40 100644 (file)
@@ -31,6 +31,7 @@ public class Message implements IMessage {
     private final String details;
     private final List/*SourceLocation*/ extraSourceLocations;
     private final boolean declared; // Is it a DEOW ?
+    private final int id; 
         
     /**
      * Create a (compiler) error or warning message
@@ -62,13 +63,14 @@ 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);
+               this(message,details,kind,sourceLocation,thrown,extraSourceLocations,false,0);
        }
        
        public Message(String message, String details, IMessage.Kind kind,
                       ISourceLocation sLoc, Throwable thrown, ISourceLocation[] otherLocs,
-                      boolean declared) {
+                      boolean declared,int id) {
                this.details = details;
+               this.id = id;
                this.message = ((message!=null) ? message : ((thrown==null) ? null : thrown.getMessage()));
                this.kind = kind;
                this.sourceLocation = sLoc;
@@ -176,4 +178,8 @@ public class Message implements IMessage {
                return extraSourceLocations;
        }
 
+       public int getID() {
+               return id;
+       }
+
 }
index fa79a83601a94288b9769b5c02a64071a94a1741..f3d5c23595489dad6164bb8dbfed48f13698cc45 100644 (file)
@@ -151,7 +151,7 @@ public class EclipseAdapterUtils {
                                                                   problem.isError() ? IMessage.ERROR : IMessage.WARNING,
                                                                   sourceLocation, 
                                                                   null,
-                                                                  seeAlsoLocations,declared);
+                                                                  seeAlsoLocations,declared,problem.getID());
         return msg;
     }               
 
index 88869e757224eec1344316a5a5b80cd00efd5406..3f26e15097a376893513144f329e82edc29c9f36 100644 (file)
@@ -39,6 +39,7 @@ public class SoftMessage implements IMessage {
        private Throwable thrown;
        private ISourceLocation sourceLocation;
        private String details;
+       private int id;
        private final ArrayList extraSourceLocations = new ArrayList();
 
        //private ISourceLocation pseudoSourceLocation;  // set directly
@@ -323,6 +324,14 @@ public class SoftMessage implements IMessage {
        public void setDetails(String string) {
                details = string;
        }
+       
+       public int getID() {
+               return id;
+       }
+       
+       public void setID(int id) {
+               this.id = id;
+       }
 
        /* (non-Javadoc)
         * @see org.aspectj.bridge.IMessage#getExtraSourceLocations()
index e8f5266f7ed1fbb1c8091cdd4cc66c58fcc0a162..84bde45644be2035a25651fd33793d84883aed97 100644 (file)
@@ -52,7 +52,7 @@ public class Checker extends ShadowMunger {
                                isError ? IMessage.ERROR : IMessage.WARNING,
                                shadow.getSourceLocation(),
                 null,
-                new ISourceLocation[]{this.getSourceLocation()},true);
+                new ISourceLocation[]{this.getSourceLocation()},true,0);
             
             world.getMessageHandler().handleMessage(message);