diff options
author | aclement <aclement> | 2006-08-25 10:14:07 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-08-25 10:14:07 +0000 |
commit | 91c20abd138e0cf548e1cebc90fabad3586abc09 (patch) | |
tree | 04792650eddd44b3443685beb60cbd158577acb7 /ajde/src | |
parent | 04c679e8e06ab8295a9d6916960cdcfc1c0025af (diff) | |
download | aspectj-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)
Diffstat (limited to 'ajde/src')
-rw-r--r-- | ajde/src/org/aspectj/ajde/internal/AjdeMessageHandler.java | 71 | ||||
-rw-r--r-- | ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java | 26 |
2 files changed, 72 insertions, 25 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()); |