20
19
import java.util.List;
23
* Wrap message with any associated throwable or source location.
22
* Wrap message with any associated throwable or source location.
25
24
public interface IMessage {
27
26
public static final IMessage[] RA_IMessage = new IMessage[0];
29
28
// int values must sync with KINDS order below
30
public static final Kind WEAVEINFO = new Kind("weaveinfo",5);
29
public static final Kind WEAVEINFO = new Kind("weaveinfo", 5);
31
30
public static final Kind INFO = new Kind("info", 10);
32
31
public static final Kind DEBUG = new Kind("debug", 20);
33
public static final Kind TASKTAG = new Kind("task",25); // represents a 'TODO' from eclipse - producted by the compiler and consumed by AJDT
32
public static final Kind TASKTAG = new Kind("task", 25); // represents a 'TODO' from eclipse - producted by the compiler and
34
34
public static final Kind WARNING = new Kind("warning", 30);
35
35
public static final Kind ERROR = new Kind("error", 40);
36
36
public static final Kind FAIL = new Kind("fail", 50);
37
37
public static final Kind ABORT = new Kind("abort", 60);
38
38
// XXX prefer another Kind to act as selector for "any",
39
39
// but can't prohibit creating messages with it.
40
//public static final Kind ANY = new Kind("any-selector", 0);
40
// public static final Kind ANY = new Kind("any-selector", 0);
42
/** list of Kind in precedence order. 0 is less than
43
* IMessage.Kind.COMPARATOR.compareTo(KINDS.get(i), KINDS.get(i + 1))
43
* list of Kind in precedence order. 0 is less than IMessage.Kind.COMPARATOR.compareTo(KINDS.get(i), KINDS.get(i + 1))
45
public static final List KINDS =
46
Collections.unmodifiableList(
48
new Kind[] { WEAVEINFO, INFO, DEBUG, TASKTAG, WARNING, ERROR, FAIL, ABORT }));
45
public static final List<Kind> KINDS = Collections.unmodifiableList(Arrays.asList(new Kind[] { WEAVEINFO, INFO, DEBUG, TASKTAG,
46
WARNING, ERROR, FAIL, ABORT }));
50
48
/** @return non-null String with simple message */
51
49
String getMessage();
62
60
/** @return true if this is an internal debug message */
65
/** @return true if this is information for the user */
63
/** @return true if this is information for the user */
68
/** @return true if the process is aborting */
66
/** @return true if the process is aborting */
69
67
boolean isAbort(); // XXX ambiguous
71
69
/** @return true if this is a task tag message */
72
70
boolean isTaskTag();
74
/** @return true if something failed */
72
/** @return true if something failed */
75
73
boolean isFailed();
77
75
/** Caller can verify if this message came about because of a DEOW */
78
76
boolean getDeclared();
80
78
/** Return the ID of the message where applicable, see IProblem for list of valid IDs */
83
81
/** Return the start position of the problem (inclusive), or -1 if unknown. */
84
82
int getSourceStart();
86
84
/** Return the end position of the problem (inclusive), or -1 if unknown. */
87
85
int getSourceEnd();
89
87
/** @return Throwable associated with this message, or null if none */
90
88
Throwable getThrown();
92
90
/** @return source location associated with this message, or null if none */
93
91
ISourceLocation getSourceLocation();
95
public static final class Kind implements Comparable {
96
public static final Comparator COMPARATOR = new Comparator() {
97
public int compare(Object o1, Object o2) {
93
public static final class Kind implements Comparable<IMessage.Kind> {
94
public static final Comparator<IMessage.Kind> COMPARATOR = new Comparator<IMessage.Kind>() {
95
public int compare(IMessage.Kind one, IMessage.Kind two) {
100
96
if (null == one) {
101
97
return (null == two ? 0 : -1);
102
98
} else if (null == two) {
113
* @param kind the Kind floor
114
* @return false if kind is null or this
115
* has less precedence than kind,
109
* @param kind the Kind floor
110
* @return false if kind is null or this has less precedence than kind, true otherwise.
118
112
public boolean isSameOrLessThan(Kind kind) {
119
return (0 >= COMPARATOR.compare(this, kind));
113
return (0 >= COMPARATOR.compare(this, kind));
122
public int compareTo(Object other) {
116
public int compareTo(IMessage.Kind other) {
123
117
return COMPARATOR.compare(this, other);
130
124
this.name = name;
131
125
this.precedence = precedence;
133
128
public String toString() {
139
* @return Detailed information about the message. For example, for declare
140
* error/warning messages this returns information about the corresponding
141
* join point's static part.
134
* @return Detailed information about the message. For example, for declare error/warning messages this returns information
135
* about the corresponding join point's static part.
143
137
public String getDetails();
147
* @return List of <code>ISourceLocation</code> instances that indicate
148
* additional source locations relevent to this message as specified by the
149
* message creator. The list should not include the primary source location
150
* associated with the message which can be obtained from
151
* <code>getSourceLocation()<code>.
140
* @return List of <code>ISourceLocation</code> instances that indicate additional source locations relevent to this message as
141
* specified by the message creator. The list should not include the primary source location associated with the message
142
* which can be obtained from <code>getSourceLocation()<code>.
153
144
* An example of using extra locations would be in a warning message that
154
145
* flags all shadow locations that will go unmatched due to a pointcut definition
155
* being based on a subtype of a defining type.
156
* @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=41952">AspectJ bug 41952</a>
158
public List getExtraSourceLocations();
146
* being based on a subtype of a defining type.
147
* @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=41952">AspectJ bug 41952</a>
149
public List<ISourceLocation> getExtraSourceLocations();