Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 16-21
Link Here
|
16 |
|
16 |
|
17 |
import org.eclipse.jdt.core.compiler.CategorizedProblem; |
17 |
import org.eclipse.jdt.core.compiler.CategorizedProblem; |
18 |
import org.eclipse.jdt.core.compiler.CharOperation; |
18 |
import org.eclipse.jdt.core.compiler.CharOperation; |
|
|
19 |
import org.eclipse.jdt.core.compiler.IProblem; |
19 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
20 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
20 |
import org.eclipse.jdt.internal.compiler.ClassFile; |
21 |
import org.eclipse.jdt.internal.compiler.ClassFile; |
21 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
22 |
import org.eclipse.jdt.internal.compiler.CompilationResult; |
Lines 207-230
Link Here
|
207 |
} |
208 |
} |
208 |
|
209 |
|
209 |
public void finalizeProblems() { |
210 |
public void finalizeProblems() { |
210 |
if (this.suppressWarningsCount == 0) return; |
211 |
if (this.suppressWarningsCount == 0) { |
|
|
212 |
if (this.compilationResult.hasErrors()) { |
213 |
// we need to check if we should discard unused locals warnings (336648) |
214 |
int removed = 0; |
215 |
CategorizedProblem[] problems = this.compilationResult.problems; |
216 |
int problemCount = this.compilationResult.problemCount; |
217 |
for (int i = 0; i < problemCount; i++) { |
218 |
if (problems[i].getID() == IProblem.LocalVariableIsNeverUsed) { |
219 |
problems[i] = null; |
220 |
removed++; |
221 |
} |
222 |
} |
223 |
// compact remaining problems |
224 |
if (removed > 0) { |
225 |
for (int i = 0, index = 0; i < problemCount; i++) { |
226 |
CategorizedProblem problem; |
227 |
if ((problem = problems[i]) != null) { |
228 |
if (i > index) { |
229 |
problems[index++] = problem; |
230 |
} else { |
231 |
index++; |
232 |
} |
233 |
} |
234 |
} |
235 |
this.compilationResult.problemCount -= removed; |
236 |
} |
237 |
} |
238 |
return; |
239 |
} |
211 |
int removed = 0; |
240 |
int removed = 0; |
212 |
CategorizedProblem[] problems = this.compilationResult.problems; |
241 |
CategorizedProblem[] problems = this.compilationResult.problems; |
213 |
int problemCount = this.compilationResult.problemCount; |
242 |
int problemCount = this.compilationResult.problemCount; |
214 |
IrritantSet[] foundIrritants = new IrritantSet[this.suppressWarningsCount]; |
243 |
IrritantSet[] foundIrritants = new IrritantSet[this.suppressWarningsCount]; |
215 |
CompilerOptions options = this.scope.compilerOptions(); |
244 |
CompilerOptions options = this.scope.compilerOptions(); |
216 |
boolean hasMandatoryErrors = false; |
245 |
boolean hasMandatoryErrors = false; |
|
|
246 |
int remainingErrors = 0; |
217 |
nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) { |
247 |
nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) { |
218 |
CategorizedProblem problem = problems[iProblem]; |
248 |
CategorizedProblem problem = problems[iProblem]; |
219 |
int problemID = problem.getID(); |
249 |
int problemID = problem.getID(); |
220 |
int irritant = ProblemReporter.getIrritant(problemID); |
250 |
int irritant = ProblemReporter.getIrritant(problemID); |
221 |
if (problem.isError()) { |
251 |
boolean isError = problem.isError(); |
|
|
252 |
if (isError) { |
222 |
if (irritant == 0) { |
253 |
if (irritant == 0) { |
223 |
// tolerate unused warning tokens when mandatory errors |
254 |
// tolerate unused warning tokens when mandatory errors |
224 |
hasMandatoryErrors = true; |
255 |
hasMandatoryErrors = true; |
|
|
256 |
remainingErrors++; |
225 |
continue; |
257 |
continue; |
226 |
} |
258 |
} |
227 |
if (!options.suppressOptionalErrors) { |
259 |
if (!options.suppressOptionalErrors) { |
|
|
260 |
remainingErrors++; |
228 |
continue; |
261 |
continue; |
229 |
} |
262 |
} |
230 |
} |
263 |
} |
Lines 234-246
Link Here
|
234 |
long position = this.suppressWarningScopePositions[iSuppress]; |
267 |
long position = this.suppressWarningScopePositions[iSuppress]; |
235 |
int startSuppress = (int) (position >>> 32); |
268 |
int startSuppress = (int) (position >>> 32); |
236 |
int endSuppress = (int) position; |
269 |
int endSuppress = (int) position; |
237 |
if (start < startSuppress) continue nextSuppress; |
270 |
if (start < startSuppress) { |
238 |
if (end > endSuppress) continue nextSuppress; |
|
|
239 |
if (!this.suppressWarningIrritants[iSuppress].isSet(irritant)) |
240 |
continue nextSuppress; |
271 |
continue nextSuppress; |
|
|
272 |
} |
273 |
if (end > endSuppress) { |
274 |
continue nextSuppress; |
275 |
} |
276 |
if (!this.suppressWarningIrritants[iSuppress].isSet(irritant)) { |
277 |
continue nextSuppress; |
278 |
} |
241 |
// discard suppressed warning |
279 |
// discard suppressed warning |
242 |
removed++; |
280 |
removed++; |
243 |
problems[iProblem] = null; |
281 |
problems[iProblem] = null; |
|
|
282 |
if (isError) { |
283 |
this.compilationResult.numberOfErrors--; |
284 |
} |
244 |
if (this.compilationResult.problemsMap != null) this.compilationResult.problemsMap.remove(problem); |
285 |
if (this.compilationResult.problemsMap != null) this.compilationResult.problemsMap.remove(problem); |
245 |
if (this.compilationResult.firstErrors != null) this.compilationResult.firstErrors.remove(problem); |
286 |
if (this.compilationResult.firstErrors != null) this.compilationResult.firstErrors.remove(problem); |
246 |
if (foundIrritants[iSuppress] == null){ |
287 |
if (foundIrritants[iSuppress] == null){ |
Lines 250-255
Link Here
|
250 |
} |
291 |
} |
251 |
continue nextProblem; |
292 |
continue nextProblem; |
252 |
} |
293 |
} |
|
|
294 |
if (isError) { |
295 |
remainingErrors++; |
296 |
} |
297 |
} |
298 |
// we need to check if we should discard unused locals warnings that were not already filtered out (336648) |
299 |
if (remainingErrors > 0) { |
300 |
for (int i = 0; i < problemCount; i++) { |
301 |
CategorizedProblem problem; |
302 |
if ((problem = problems[i]) != null && problem.getID() == IProblem.LocalVariableIsNeverUsed) { |
303 |
problems[i] = null; |
304 |
removed++; |
305 |
} |
306 |
} |
253 |
} |
307 |
} |
254 |
// compact remaining problems |
308 |
// compact remaining problems |
255 |
if (removed > 0) { |
309 |
if (removed > 0) { |