]> source.dussan.org Git - aspectj.git/commitdiff
141556#13 - messagehandler pulled out of CompilerAdapter and changed to have nothing...
authoraclement <aclement>
Fri, 25 Aug 2006 10:14:07 +0000 (10:14 +0000)
committeraclement <aclement>
Fri, 25 Aug 2006 10:14:07 +0000 (10:14 +0000)
ajde/src/org/aspectj/ajde/internal/AjdeMessageHandler.java [new file with mode: 0644]
ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java

diff --git a/ajde/src/org/aspectj/ajde/internal/AjdeMessageHandler.java b/ajde/src/org/aspectj/ajde/internal/AjdeMessageHandler.java
new file mode 100644 (file)
index 0000000..2756af0
--- /dev/null
@@ -0,0 +1,71 @@
+/********************************************************************
+ * Copyright (c) 2006 Contributors. All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: IBM Corporation - initial API and implementation 
+ *                              Helen Hawkins   - moved into separate class
+ *******************************************************************/
+package org.aspectj.ajde.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.ajde.Ajde;
+import org.aspectj.ajde.TaskListManager;
+import org.aspectj.bridge.AbortException;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.bridge.IMessage.Kind;
+
+/**
+ * IMessageHandler used by Ajde. No messages are stored
+ * within the handler as it delegates to the TaskListManager.
+ * By default IMessage.INFO and IMessage.WEAVEINFO messages
+ * are ignored.
+ */
+public class AjdeMessageHandler implements IMessageHandler {
+
+       private TaskListManager taskListManager;
+       private List ignoring;
+       
+       public AjdeMessageHandler() {
+        ignoring = new ArrayList();
+        ignore(IMessage.INFO);
+        ignore(IMessage.WEAVEINFO);
+               this.taskListManager = Ajde.getDefault().getTaskListManager();
+       }       
+
+       public boolean handleMessage(IMessage message) throws AbortException {
+        IMessage.Kind kind = message.getKind(); 
+        if (kind == IMessage.ABORT) return handleAbort(message);
+        if (isIgnoring(kind)) {
+            return true;
+        }      
+               taskListManager.addSourcelineTask(message);
+               return true;
+       }
+       
+       private boolean handleAbort(IMessage abortMessage) {
+               throw new AbortException(abortMessage);
+       }
+
+       public void dontIgnore(Kind kind) {
+           if (null != kind) {
+               ignoring.remove(kind);
+           }
+       }
+
+       public boolean isIgnoring(Kind kind) {
+               return ((null != kind) && (ignoring.contains(kind)));
+       }
+       
+       public void ignore(Kind kind) {
+           if ((null != kind) && (!ignoring.contains(kind))) {
+               ignoring.add(kind);
+           }   
+       }
+       
+}
index eb5f9cfb6be5b932c59f15ff153becb2000d8166..ef407e1499e384399c685a4ee1cafb11b99d7962 100644 (file)
@@ -594,7 +594,7 @@ public class CompilerAdapter {
                        if (Ajde.getDefault().getMessageHandler() != null) {
                                this.messageHandler = Ajde.getDefault().getMessageHandler();
                        } else {
-                               this.messageHandler = new MessageHandlerAdapter();
+                               this.messageHandler = new AjdeMessageHandler();
                        }
                        buildManager = new AjBuildManager(messageHandler);
                        buildManager.environmentSupportsIncrementalCompilation(true);
@@ -603,30 +603,6 @@ public class CompilerAdapter {
                }
        }
        
-       class MessageHandlerAdapter extends MessageHandler {
-               private TaskListManager taskListManager;
-
-               public MessageHandlerAdapter() {
-                       this.taskListManager = Ajde.getDefault().getTaskListManager();
-                       ignore(IMessage.INFO);
-               }       
-
-               public boolean handleMessage(IMessage message) throws AbortException {
-            IMessage.Kind kind = message.getKind(); 
-            if (kind == IMessage.ABORT) return handleAbort(message);
-            if (isIgnoring(kind)) {
-                    return true;
-            }
-                       
-                       taskListManager.addSourcelineTask(message);
-                       return true;// return super.handleMessage(message); // also store...    
-               }
-               
-               private boolean handleAbort(IMessage abortMessage) {
-                       throw new AbortException(abortMessage);
-               }
-       }
-
        public void setState(AjState buildState) {
                buildManager.setState(buildState);      
                buildManager.setStructureModel(buildState.getStructureModel());
index c76470168309551f59e3a98dd422a298f559bee2..84145e176eefd54fe845f06379747fa1076d6d88 100644 (file)
@@ -1461,10 +1461,16 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                initialiseProject("PR141556");
                build("PR141556");
                IMessageHandler handler = AjdeManager.getMessageHandler();
-               assertTrue("expected the handler to be an IMessageHolder but wasn't ",
+               // the handler used to be an IMessageHolder (extended MessageHandler)
+               // which stored the messages, consequently we checked that none
+               // were being stored. Since we no longer stored any messages (fix
+               // for bug 141564) it was unnecessary to be an IMessageHolder as all the
+               // IMessageHolder methods in MessageHander used the list of stored
+               // messages. Therefore, rather than checking that the list of messages
+               // is empty we can check that we're an IMessageHandler but not an
+               // IMessageHolder.
+               assertFalse("expected the handler not to be an IMessageHolder but was ",
                                handler instanceof IMessageHolder);
-               IMessage[] msgs = ((IMessageHolder)AjdeManager.getMessageHandler()).getMessages(null,true);
-               assertTrue("There should be no messages but I found: "+msgs.length,msgs.length==0);
                
                List tasklistMessages = MyTaskListManager.getWarningMessages();
                assertTrue("Should be one message but found "+tasklistMessages.size(),tasklistMessages.size()==1);