mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-09-13 15:45:38 +02:00
Fix for Bugzilla Bug 72016: No problem type information from AspectJ compiler / AJDE
This commit is contained in:
parent
6b1ef0ff7c
commit
eb1d697f95
9
ajde/testdata/extensions/UnusedImport.java
vendored
Normal file
9
ajde/testdata/extensions/UnusedImport.java
vendored
Normal file
@ -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();
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
55
ajde/testsrc/org/aspectj/ajde/ExtensionTests.java
Normal file
55
ajde/testsrc/org/aspectj/ajde/ExtensionTests.java
Normal file
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public class EclipseAdapterUtils {
|
||||
problem.isError() ? IMessage.ERROR : IMessage.WARNING,
|
||||
sourceLocation,
|
||||
null,
|
||||
seeAlsoLocations,declared);
|
||||
seeAlsoLocations,declared,problem.getID());
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user