From: aclement Date: Mon, 16 Aug 2004 16:44:13 +0000 (+0000) Subject: Fix for Bugzilla Bug 72016: No problem type information from AspectJ compiler / AJDE X-Git-Tag: V1_2_1~135 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eb1d697f95742d25109b1d285db38da40464b340;p=aspectj.git Fix for Bugzilla Bug 72016: No problem type information from AspectJ compiler / AJDE --- diff --git a/ajde/testdata/extensions/UnusedImport.java b/ajde/testdata/extensions/UnusedImport.java new file mode 100644 index 000000000..ba561cca1 --- /dev/null +++ b/ajde/testdata/extensions/UnusedImport.java @@ -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(); + } +} diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java index a2155fd9b..924ff6cbb 100644 --- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -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 index 000000000..d4659e3a8 --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/ExtensionTests.java @@ -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); + } + + + +} diff --git a/bridge/src/org/aspectj/bridge/IMessage.java b/bridge/src/org/aspectj/bridge/IMessage.java index fcb807016..7829633e9 100644 --- a/bridge/src/org/aspectj/bridge/IMessage.java +++ b/bridge/src/org/aspectj/bridge/IMessage.java @@ -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(); diff --git a/bridge/src/org/aspectj/bridge/Message.java b/bridge/src/org/aspectj/bridge/Message.java index 1ddb18d69..b568f9641 100644 --- a/bridge/src/org/aspectj/bridge/Message.java +++ b/bridge/src/org/aspectj/bridge/Message.java @@ -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; + } + } 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 fa79a8360..f3d5c2359 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,7 @@ public class EclipseAdapterUtils { problem.isError() ? IMessage.ERROR : IMessage.WARNING, sourceLocation, null, - seeAlsoLocations,declared); + seeAlsoLocations,declared,problem.getID()); return msg; } diff --git a/testing/src/org/aspectj/testing/xml/SoftMessage.java b/testing/src/org/aspectj/testing/xml/SoftMessage.java index 88869e757..3f26e1509 100644 --- a/testing/src/org/aspectj/testing/xml/SoftMessage.java +++ b/testing/src/org/aspectj/testing/xml/SoftMessage.java @@ -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() diff --git a/weaver/src/org/aspectj/weaver/Checker.java b/weaver/src/org/aspectj/weaver/Checker.java index e8f5266f7..84bde4564 100644 --- a/weaver/src/org/aspectj/weaver/Checker.java +++ b/weaver/src/org/aspectj/weaver/Checker.java @@ -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);