]> source.dussan.org Git - aspectj.git/commitdiff
test and initial patches for 141556
authoraclement <aclement>
Thu, 3 Aug 2006 10:03:43 +0000 (10:03 +0000)
committeraclement <aclement>
Thu, 3 Aug 2006 10:03:43 +0000 (10:03 +0000)
ajde/src/org/aspectj/ajde/internal/AspectJBuildManager.java
ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
tests/multiIncremental/PR141556/base/pkg/A.aj [new file with mode: 0644]
tests/multiIncremental/PR141556/base/pkg/C.java [new file with mode: 0644]
tests/multiIncremental/PR141556/inc1/pkg/A.aj [new file with mode: 0644]
tests/multiIncremental/PR141556/inc2/pkg/A.aj [new file with mode: 0644]
tests/multiIncremental/PR141556/inc3/pkg/A.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/incremental/tools/AbstractMultiProjectIncrementalAjdeInteractionTestbed.java
tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
weaver/src/org/aspectj/weaver/Lint.java

index eca810e5c979b4481ea59e911d4e5dfc4c2ef998..42ca0e9113b0a3a59397f1abbb3e74aa8f790aa0 100644 (file)
@@ -257,6 +257,10 @@ public class AspectJBuildManager implements BuildManager {
        public void setBuildModelMode(boolean b) {
                buildModelMode = b;
        }
+       
+       public CompilerAdapter getCompilerAdapter() {
+               return compilerAdapter;
+       }
 
 }
 
index 0ba47eb7ff6b6b05b73afb449d0b89de354d7ead..39baebb94c33750ba4cd043dd9797394c7a2baea 100644 (file)
@@ -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 (file)
index 0000000..0978b13
--- /dev/null
@@ -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 (file)
index 0000000..7923fe0
--- /dev/null
@@ -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 (file)
index 0000000..efa0153
--- /dev/null
@@ -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 (file)
index 0000000..0827506
--- /dev/null
@@ -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 (file)
index 0000000..0a1556f
--- /dev/null
@@ -0,0 +1,11 @@
+package pkg;
+
+public aspect A {
+
+       pointcut p() :  execution(* C.method1());
+        
+       before(): p() {
+               System.out.println(thisJoinPoint);
+       }
+       
+}
index f0a063c38d0bea3f8a271e31f3d0c28a9d50f4b6..7c30f2c02e7499c9c2699e2414527065cf44b73b 100644 (file)
@@ -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) {
index d50e340fbe3b46d8e9fe32c6d0b222c2ad519828..11daccd48539a7ea31fdb60eaba0316b4ceb5bb7 100644 (file)
@@ -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();
 //             }
index c136644793632d0d92ea3474dd72f262ff381faa..b596bb5f4779af7115bbccfb928759af2d32a1e6 100644 (file)
@@ -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");
index 739ba02d0940411eb985c8c6516f0c4819a9427e..ab12e7aac629cf4dd47da395fd98c449a60085ff 100644 (file)
@@ -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);
+               }
+       }
+       
 }