@@ -257,6 +257,10 @@ public class AspectJBuildManager implements BuildManager { | |||
public void setBuildModelMode(boolean b) { | |||
buildModelMode = b; | |||
} | |||
public CompilerAdapter getCompilerAdapter() { | |||
return compilerAdapter; | |||
} | |||
} | |||
@@ -646,6 +646,10 @@ public class CompilerAdapter { | |||
buildManager.setState(buildState); | |||
buildManager.setStructureModel(buildState.getStructureModel()); | |||
} | |||
public IMessageHandler getMessageHandler() { | |||
return messageHandler; | |||
} | |||
public boolean wasFullBuild() { | |||
return buildManager.wasFullBuild(); |
@@ -0,0 +1,11 @@ | |||
package pkg; | |||
public aspect A { | |||
pointcut p() : execution(* C.method1()); | |||
before(): p() { | |||
System.out.println(thisJoinPoint); | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
package pkg; | |||
public class C { | |||
public void method1() { | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
package pkg; | |||
public aspect A { | |||
point cut p() : execution(* C.method1()); | |||
before(): p() { | |||
System.out.println(thisJoinPoint); | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
package pkg; | |||
public aspect A { | |||
pointcut p() : execution(* C.method1()); | |||
before(): p() { | |||
System.out.println(thisJoinPoint); | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
package pkg; | |||
public aspect A { | |||
pointcut p() : execution(* C.method1()); | |||
before(): p() { | |||
System.out.println(thisJoinPoint); | |||
} | |||
} |
@@ -27,6 +27,7 @@ public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends | |||
super.tearDown(); | |||
AjState.FORCE_INCREMENTAL_DURING_TESTING = false; | |||
configureBuildStructureModel(false); | |||
MyBuildOptionsAdapter.reset(); | |||
} | |||
public void build(String projectName) { |
@@ -28,11 +28,13 @@ import org.aspectj.ajde.ErrorHandler; | |||
import org.aspectj.ajde.OutputLocationManager; | |||
import org.aspectj.ajde.ProjectPropertiesAdapter; | |||
import org.aspectj.ajde.TaskListManager; | |||
import org.aspectj.ajde.internal.AspectJBuildManager; | |||
import org.aspectj.ajdt.internal.core.builder.AbstractStateListener; | |||
import org.aspectj.ajdt.internal.core.builder.AjState; | |||
import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager; | |||
import org.aspectj.asm.AsmManager; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.IMessageHandler; | |||
import org.aspectj.bridge.ISourceLocation; | |||
import org.aspectj.bridge.IMessage.Kind; | |||
import org.aspectj.tools.ajc.Ajc; | |||
@@ -222,6 +224,14 @@ public class AjdeInteractionTestbed extends TestCase { | |||
} catch (InterruptedException ie) {} | |||
} | |||
public static void setMessageHandler(IMessageHandler handler) { | |||
Ajde.getDefault().setMessageHandler(handler); | |||
} | |||
public static IMessageHandler getMessageHandler() { | |||
AspectJBuildManager buildManager = (AspectJBuildManager) Ajde.getDefault().getBuildManager(); | |||
return buildManager.getCompilerAdapter().getMessageHandler(); | |||
} | |||
// public static boolean lastCompileDefaultedToBatch() { | |||
// return MyTaskListManager.defaultedToBatch(); | |||
// } |
@@ -33,7 +33,10 @@ import org.aspectj.asm.IRelationshipMap; | |||
import org.aspectj.asm.internal.JDTLikeHandleProvider; | |||
import org.aspectj.asm.internal.Relationship; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.IMessageHandler; | |||
import org.aspectj.bridge.IMessageHolder; | |||
import org.aspectj.tools.ajc.Ajc; | |||
import org.aspectj.weaver.Lint.LintMessage; | |||
/** | |||
* The superclass knows all about talking through Ajde to the compiler. | |||
@@ -1423,6 +1426,52 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa | |||
configureBuildStructureModel(false); | |||
} | |||
// public void testDontLoseXlintWarnings_pr141556() { | |||
// configureNonStandardCompileOptions("-Xlint:warning"); | |||
// initialiseProject("PR141556"); | |||
// build("PR141556"); | |||
// checkWasFullBuild(); | |||
// String warningMessage = "can not build thisJoinPoint " + | |||
// "lazily for this advice since it has no suitable guard " + | |||
// "[Xlint:noGuardForLazyTjp]"; | |||
// assertEquals("warning message should be '" + warningMessage + "'", | |||
// warningMessage, | |||
// ((IMessage)MyTaskListManager.getWarningMessages().get(0)) | |||
// .getMessage()); | |||
// | |||
// // add a space to the Aspect but dont do a build | |||
// alter("PR141556","inc1"); | |||
// // remove the space so that the Aspect is exactly as it was | |||
// alter("PR141556","inc2"); | |||
// // build the project and we should not have lost the xlint warning | |||
// build("PR141556"); | |||
// checkWasntFullBuild(); | |||
// assertTrue("there should still be a warning message ", | |||
// !MyTaskListManager.getWarningMessages().isEmpty()); | |||
// assertEquals("warning message should be '" + warningMessage + "'", | |||
// warningMessage, | |||
// ((IMessage)MyTaskListManager.getWarningMessages().get(0)) | |||
// .getMessage()); | |||
// } | |||
public void testLintMessage_pr141564() { | |||
configureNonStandardCompileOptions("-Xlint:warning"); | |||
initialiseProject("PR141556"); | |||
build("PR141556"); | |||
IMessageHandler handler = AjdeManager.getMessageHandler(); | |||
assertTrue("expected the handler to be an IMessageHolder but wasn't ", | |||
handler instanceof IMessageHolder); | |||
IMessage[] msgs = ((IMessageHolder)AjdeManager.getMessageHandler()).getMessages(null,true); | |||
IMessage msg = msgs[msgs.length-1]; | |||
assertTrue("expected message to be a LintMessage but wasn't", | |||
msg instanceof LintMessage); | |||
assertTrue("expected message to be noGuardForLazyTjp xlint message but" + | |||
" instead was " + ((LintMessage)msg).getKind().toString(), | |||
((LintMessage)msg).isNoGuardForLazyTjp()); | |||
assertTrue("expected message to be against file in project 'PR141556' but wasn't", | |||
msg.getSourceLocation().getSourceFile().getAbsolutePath().indexOf("PR141556") != -1); | |||
} | |||
public void testAdviceDidNotMatch_pr152589() { | |||
initialiseProject("PR152589"); | |||
build("PR152589"); |
@@ -283,7 +283,8 @@ public class Lint { | |||
String text = MessageFormat.format(message, new Object[] {info} ); | |||
text += " [Xlint:" + name + "]"; | |||
world.getMessageHandler().handleMessage(new Message(text, kind, null, location)); | |||
world.getMessageHandler().handleMessage( | |||
new LintMessage(text, kind, location,null,getLintKind(name))); | |||
} | |||
public void signal(String[] infos, ISourceLocation location, ISourceLocation[] extraLocations) { | |||
@@ -292,7 +293,38 @@ public class Lint { | |||
String text = MessageFormat.format(message, infos ); | |||
text += " [Xlint:" + name + "]"; | |||
world.getMessageHandler().handleMessage( | |||
new Message(text, "", kind, location, null, extraLocations)); | |||
new LintMessage(text, kind, location,extraLocations,getLintKind(name))); | |||
} | |||
} | |||
public class LintMessage extends Message { | |||
private Lint.Kind lintKind; | |||
public LintMessage( | |||
String message, | |||
IMessage.Kind messageKind, | |||
ISourceLocation location, | |||
ISourceLocation[] extraLocations, | |||
Lint.Kind lintKind) { | |||
super(message,"",messageKind,location,null,extraLocations); | |||
this.lintKind = lintKind; | |||
} | |||
/** | |||
* @return Returns the Lint kind of this message | |||
*/ | |||
public Lint.Kind getLintKind() { | |||
return lintKind; | |||
} | |||
/** | |||
* @return true if this message is a noGuardForLazyTjp xlint | |||
* message and false otherwise | |||
*/ | |||
public boolean isNoGuardForLazyTjp() { | |||
return lintKind.equals(noGuardForLazyTjp); | |||
} | |||
} | |||
} |