--- /dev/null
+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();
+ }
+}
suite.addTestSuite(JarManifestTest.class);
suite.addTestSuite(DuplicateManifestTest.class);
suite.addTestSuite(ShowWeaveMessagesTestCase.class);
+ suite.addTestSuite(ExtensionTests.class);
//$JUnit-END$
return suite;
--- /dev/null
+/*******************************************************************************
+ * 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);
+ }
+
+
+
+}
/** 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();
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
*/
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;
return extraSourceLocations;
}
+ public int getID() {
+ return id;
+ }
+
}
problem.isError() ? IMessage.ERROR : IMessage.WARNING,
sourceLocation,
null,
- seeAlsoLocations,declared);
+ seeAlsoLocations,declared,problem.getID());
return msg;
}
private Throwable thrown;
private ISourceLocation sourceLocation;
private String details;
+ private int id;
private final ArrayList extraSourceLocations = new ArrayList();
//private ISourceLocation pseudoSourceLocation; // set directly
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()
isError ? IMessage.ERROR : IMessage.WARNING,
shadow.getSourceLocation(),
null,
- new ISourceLocation[]{this.getSourceLocation()},true);
+ new ISourceLocation[]{this.getSourceLocation()},true,0);
world.getMessageHandler().handleMessage(message);