summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2006-08-25 10:14:07 +0000
committeraclement <aclement>2006-08-25 10:14:07 +0000
commit91c20abd138e0cf548e1cebc90fabad3586abc09 (patch)
tree04792650eddd44b3443685beb60cbd158577acb7
parent04c679e8e06ab8295a9d6916960cdcfc1c0025af (diff)
downloadaspectj-91c20abd138e0cf548e1cebc90fabad3586abc09.tar.gz
aspectj-91c20abd138e0cf548e1cebc90fabad3586abc09.zip
141556#13 - messagehandler pulled out of CompilerAdapter and changed to have nothing to do with holders (since it doesnt need to store messages)
-rw-r--r--ajde/src/org/aspectj/ajde/internal/AjdeMessageHandler.java71
-rw-r--r--ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java26
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java12
3 files changed, 81 insertions, 28 deletions
diff --git a/ajde/src/org/aspectj/ajde/internal/AjdeMessageHandler.java b/ajde/src/org/aspectj/ajde/internal/AjdeMessageHandler.java
new file mode 100644
index 000000000..2756af0e4
--- /dev/null
+++ b/ajde/src/org/aspectj/ajde/internal/AjdeMessageHandler.java
@@ -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);
+ }
+ }
+
+}
diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
index eb5f9cfb6..ef407e149 100644
--- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
+++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
@@ -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());
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
index c76470168..84145e176 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
@@ -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);