blob: 26afbf88240669cec193a108b5789798b3f5254a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
/********************************************************************
* Copyright (c) 2007 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 - initial version (bug 148190)
*******************************************************************/
package org.aspectj.systemtest.incremental.tools;
import java.util.ArrayList;
import java.util.List;
import org.aspectj.ajde.core.IBuildMessageHandler;
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessage.Kind;
/**
* IMessageHandler which by default ignores INFO and WEAVEINFO messages. Records the warning, weaving, compiler errors and error
* messages and provides methods to get them.
*/
public class MultiProjTestMessageHandler implements IBuildMessageHandler {
private final boolean VERBOSE = false;
private boolean receivedNonIncrementalBuildMessage = false;
private boolean receivedBatchBuildMessage = false;
private List<IMessage> errorMessages;
private List<IMessage> warningMessages;
private List<IMessage> weavingMessages;
private List compilerErrors;
private List ignoring;
public MultiProjTestMessageHandler() {
ignoring = new ArrayList();
errorMessages = new ArrayList<IMessage>();
warningMessages = new ArrayList<IMessage>();
weavingMessages = new ArrayList<IMessage>();
compilerErrors = new ArrayList();
ignore(IMessage.INFO);
ignore(IMessage.WEAVEINFO);
}
public boolean handleMessage(IMessage message) throws AbortException {
IMessage.Kind kind = message.getKind();
if (isIgnoring(kind)) {
return true;
}
if (kind.equals(IMessage.ABORT) || message.getThrown() != null) {
log("> AjCompiler error: " + message.getMessage() + ", " + message.getThrown() + ")"); //$NON-NLS-1$
message.getThrown().printStackTrace();
compilerErrors.add(message + ", (" + message.getThrown() + ")");
if (VERBOSE && (message.getThrown() != null)) {
message.getThrown().printStackTrace();
}
return true;
}
if (message.getKind() == IMessage.ERROR) {
errorMessages.add(message);
}
if (message.getKind() == IMessage.WARNING) {
warningMessages.add(message);
}
if (message.getKind() == IMessage.WEAVEINFO) {
weavingMessages.add(message);
}
log("IMessageHandler.handleMessage(" + message + ")");
return true;
}
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);
}
}
public boolean hasWarning() {
return !warningMessages.isEmpty();
}
public boolean hasErrorMessages() {
return !errorMessages.isEmpty();
}
public boolean hasCompilerErrorMessages() {
return !compilerErrors.isEmpty();
}
public List<IMessage> getErrorMessages() {
return errorMessages;
}
public List<IMessage> getWarningMessages() {
return warningMessages;
}
public List<IMessage> getWeavingMessages() {
return weavingMessages;
}
public List<IMessage> getCompilerErrors() {
return compilerErrors;
}
public void log(String s) {
if (VERBOSE) {
System.out.println(s);
}
}
public void reset() {
receivedNonIncrementalBuildMessage = false;
receivedBatchBuildMessage = false;
errorMessages.clear();
warningMessages.clear();
weavingMessages.clear();
compilerErrors.clear();
}
}
|