From: aclement Date: Thu, 3 Aug 2006 10:03:43 +0000 (+0000) Subject: test and initial patches for 141556 X-Git-Tag: pre_pr_153572~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b7ccac980f81164b32042522e85834c498f14b94;p=aspectj.git test and initial patches for 141556 --- diff --git a/ajde/src/org/aspectj/ajde/internal/AspectJBuildManager.java b/ajde/src/org/aspectj/ajde/internal/AspectJBuildManager.java index eca810e5c..42ca0e911 100644 --- a/ajde/src/org/aspectj/ajde/internal/AspectJBuildManager.java +++ b/ajde/src/org/aspectj/ajde/internal/AspectJBuildManager.java @@ -257,6 +257,10 @@ public class AspectJBuildManager implements BuildManager { public void setBuildModelMode(boolean b) { buildModelMode = b; } + + public CompilerAdapter getCompilerAdapter() { + return compilerAdapter; + } } diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java index 0ba47eb7f..39baebb94 100644 --- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java +++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java @@ -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(); diff --git a/tests/multiIncremental/PR141556/base/pkg/A.aj b/tests/multiIncremental/PR141556/base/pkg/A.aj new file mode 100644 index 000000000..0978b132d --- /dev/null +++ b/tests/multiIncremental/PR141556/base/pkg/A.aj @@ -0,0 +1,11 @@ +package pkg; + +public aspect A { + + pointcut p() : execution(* C.method1()); + + before(): p() { + System.out.println(thisJoinPoint); + } + +} diff --git a/tests/multiIncremental/PR141556/base/pkg/C.java b/tests/multiIncremental/PR141556/base/pkg/C.java new file mode 100644 index 000000000..7923fe024 --- /dev/null +++ b/tests/multiIncremental/PR141556/base/pkg/C.java @@ -0,0 +1,8 @@ +package pkg; + +public class C { + + public void method1() { + } + +} diff --git a/tests/multiIncremental/PR141556/inc1/pkg/A.aj b/tests/multiIncremental/PR141556/inc1/pkg/A.aj new file mode 100644 index 000000000..efa015328 --- /dev/null +++ b/tests/multiIncremental/PR141556/inc1/pkg/A.aj @@ -0,0 +1,11 @@ +package pkg; + +public aspect A { + + point cut p() : execution(* C.method1()); + + before(): p() { + System.out.println(thisJoinPoint); + } + +} diff --git a/tests/multiIncremental/PR141556/inc2/pkg/A.aj b/tests/multiIncremental/PR141556/inc2/pkg/A.aj new file mode 100644 index 000000000..082750667 --- /dev/null +++ b/tests/multiIncremental/PR141556/inc2/pkg/A.aj @@ -0,0 +1,11 @@ +package pkg; + +public aspect A { + + pointcut p() : execution(* C.method1()); + + before(): p() { + System.out.println(thisJoinPoint); + } + +} diff --git a/tests/multiIncremental/PR141556/inc3/pkg/A.aj b/tests/multiIncremental/PR141556/inc3/pkg/A.aj new file mode 100644 index 000000000..0a1556f73 --- /dev/null +++ b/tests/multiIncremental/PR141556/inc3/pkg/A.aj @@ -0,0 +1,11 @@ +package pkg; + +public aspect A { + + pointcut p() : execution(* C.method1()); + + before(): p() { + System.out.println(thisJoinPoint); + } + +} diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java index f0a063c38..7c30f2c02 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java @@ -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) { diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java index d50e340fb..11daccd48 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java @@ -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(); // } diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java index c13664479..b596bb5f4 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java @@ -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"); diff --git a/weaver/src/org/aspectj/weaver/Lint.java b/weaver/src/org/aspectj/weaver/Lint.java index 739ba02d0..ab12e7aac 100644 --- a/weaver/src/org/aspectj/weaver/Lint.java +++ b/weaver/src/org/aspectj/weaver/Lint.java @@ -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); + } + } + }