Skip to main content
summaryrefslogtreecommitdiffstats
blob: 812c53225bbdcaadce81508bcb8e9b74e96fa553 (plain) (blame)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package org.eclipse.jdt.internal.core.builder.impl;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
import org.eclipse.core.runtime.IPath;

import org.eclipse.jdt.internal.compiler.IProblem;
import org.eclipse.jdt.internal.core.builder.*;
import org.eclipse.jdt.internal.core.Util;

/**
 * @see IProblemDetail
 */
public class ProblemDetailImpl implements IProblemDetail, IProblem {
	protected SourceEntry fSourceEntry;
	protected String fMessage;
	protected int fStartPos, fEndPos, fLineNumber;
	protected int fSeverity;

	/**
	 * The ID of the problem returned by the compiler.
	 * @see com.ibm.compiler.java.problem.ProblemIrritants
	 */
	protected int fID;

	/**
	 * Severity flag indicating a syntax error (also covers namespace errors such as duplicates).
	 */
	protected static final int S_SYNTAX_ERROR = 2;
/**
 * Creates a problem detail.
 */
public ProblemDetailImpl(String msg, int id, int severity, SourceEntry sourceEntry, int startPos, int endPos, int lineNumber) {
	fMessage = msg;
	fID = id;
	fSeverity = severity;
	fSourceEntry = sourceEntry;
	fStartPos = startPos;
	fEndPos = endPos;
	fLineNumber = lineNumber;
}
/**
 * Creates a problem detail.
 */
public ProblemDetailImpl(String msg, SourceEntry sourceEntry) {
	this(msg, 0, S_ERROR, sourceEntry, -1, -1, -1);
}
public boolean equals(Object o) {
	if (this == o) return true;
	if (!(this instanceof ProblemDetailImpl)) return false;
	return equals((ProblemDetailImpl) o, false);
}
public boolean equals(ProblemDetailImpl pb, boolean ignorePositions) {
	return
		fMessage.equals(pb.fMessage)
			&& Util.equalOrNull(fSourceEntry, pb.fSourceEntry)
			&& fSeverity == pb.fSeverity
			&& (ignorePositions || 
				(fStartPos == pb.fStartPos && fEndPos == pb.fEndPos));
}
/**
 * @see IProblem
 */
public String[] getArguments() {
	return null; // not kept
}
/**
 * Returns the end pos.
 */
public int getEndPos() {
	return fEndPos;
}
/**
 * @see IProblemDetail
 */
public int getID() {
	return fID;
}
/**
 * @see IProblemDetail
 */
public int getKind() {
	return IProblemDetail.K_COMPILATION_PROBLEM;
}
/**
 * @see IProblemDetail
 */
public int getLineNumber() {
	return fLineNumber;
}
/**
 * @see IProblemDetail
 */
public String getMessage() {
	return fMessage;
}
/**
 * getOriginatingFileName method comment.
 */
public char[] getOriginatingFileName() {
	return fSourceEntry.getPathWithZipEntryName().toCharArray();
}
/**
 * Returns the path of the source entry.
 */
IPath getPath() {
	return fSourceEntry == null ? null : fSourceEntry.getPath();
}
/**
 * @see IProblemDetail
 */
public int getSeverity() {
	return fSeverity;
}
/**
 * @see IProblem
 */
public int getSourceEnd() {
	return fEndPos;
}
/**
 * Returns the source entry
 */
SourceEntry getSourceEntry() {
	return fSourceEntry;
}
/**
 * @see ICompilationProblem
 */
public ISourceFragment getSourceFragment() {
	if (fSourceEntry == null) {
		return null;
	}
	return new SourceFragmentImpl(fStartPos, fEndPos, fSourceEntry);
}
/**
 * @see IProblem
 */
public int getSourceLineNumber() {
	return fLineNumber; 
}
/**
 * @see IProblem
 */
public int getSourceStart() {
	return fStartPos;
}
/**
 * Returns the start pos.
 */
public int getStartPos() {
	return fStartPos;
}
public int hashCode() {
	return fMessage.hashCode() * 17 + (fSourceEntry == null ? 0 : fSourceEntry.hashCode());
}
/**
 * @see IProblem
 */
public boolean isError() {
	return (fSeverity & S_ERROR) != 0;
}
/**
 * @see IProblem
 */
public boolean isWarning() {
	return (fSeverity & S_ERROR) == 0;
}
/**
 * @see IProblem
 */
public void setSourceEnd(int sourceEnd) {
	fEndPos = sourceEnd;
}
/**
 * Internal - Set the source entry.
 */
public void setSourceEntry(SourceEntry sourceEntry) {
	fSourceEntry = sourceEntry;
}
/**
 * @see IProblem
 */
public void setSourceLineNumber(int lineNumber) {
	fLineNumber = lineNumber;
}
/**
 * @see IProblem
 */
public void setSourceStart(int sourceStart) {
	fStartPos = sourceStart;
}
/**
 * Returns a readable representation of the class.  This method is for debugging
 * purposes only. Non-NLS.
 */
public String toString() {
	return "ProblemDetail("/*nonNLS*/ + getMessage() + ")"/*nonNLS*/;
}
}

Back to the top