Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 371832 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java (-1 / +35 lines)
Lines 47-53 Link Here
47
	// Static initializer to specify tests subset using TESTS_* static variables
47
	// Static initializer to specify tests subset using TESTS_* static variables
48
	// All specified tests which do not belong to the class are skipped...
48
	// All specified tests which do not belong to the class are skipped...
49
	static {
49
	static {
50
//		TESTS_NAMES = new String[] { "testBug365437" };
50
//		TESTS_NAMES = new String[] { "test135" };
51
//		TESTS_NUMBERS = new int[] { 297 };
51
//		TESTS_NUMBERS = new int[] { 297 };
52
//		TESTS_RANGE = new int[] { 294, -1 };
52
//		TESTS_RANGE = new int[] { 294, -1 };
53
	}
53
	}
Lines 10517-10520 Link Here
10517
		"----------\n",
10517
		"----------\n",
10518
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
10518
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
10519
}
10519
}
10520
10521
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=371832
10522
//Unused imports should be reported even if other errors are suppressed.
10523
public void testBug371832() throws Exception {
10524
	Map customOptions = getCompilerOptions();
10525
	customOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.ERROR);
10526
	customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR);
10527
	customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED);
10528
	customOptions.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.ERROR);
10529
	String testFiles [] = new String[] {
10530
			"A.java",
10531
			"import java.util.List;\n"+
10532
			"@SuppressWarnings(\"serial\")\n" +
10533
			"public class A implements java.io.Serializable {\n" +
10534
			"	void foo() { \n" +
10535
			"	}\n"+
10536
			"}\n"
10537
			};
10538
	String expectedErrorString = 
10539
			"----------\n" + 
10540
			"1. ERROR in A.java (at line 1)\n" + 
10541
			"	import java.util.List;\n" + 
10542
			"	       ^^^^^^^^^^^^^^\n" + 
10543
			"The import java.util.List is never used\n" + 
10544
			"----------\n";
10545
	runNegativeTest(
10546
			true,
10547
			testFiles,
10548
			null, 
10549
			customOptions,
10550
			expectedErrorString,
10551
			JavacTestOptions.Excuse.EclipseWarningConfiguredAsError);
10552
}
10553
10520
}
10554
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java (-1 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 73-78 Link Here
73
	public char[][] packageName;
73
	public char[][] packageName;
74
	public boolean checkSecondaryTypes = false; // check for secondary types which were created after the initial buildTypeBindings call
74
	public boolean checkSecondaryTypes = false; // check for secondary types which were created after the initial buildTypeBindings call
75
	private int numberOfErrors;
75
	private int numberOfErrors;
76
	private boolean hasMandatoryErrors;
76
77
77
	private static final int[] EMPTY_LINE_ENDS = Util.EMPTY_INT_ARRAY;
78
	private static final int[] EMPTY_LINE_ENDS = Util.EMPTY_INT_ARRAY;
78
	private static final Comparator PROBLEM_COMPARATOR = new Comparator() {
79
	private static final Comparator PROBLEM_COMPARATOR = new Comparator() {
Lines 274-279 Link Here
274
	return this.numberOfErrors != 0;
275
	return this.numberOfErrors != 0;
275
}
276
}
276
277
278
public boolean hasMandatoryErrors() {
279
	return this.hasMandatoryErrors;
280
}
281
277
public boolean hasProblems() {
282
public boolean hasProblems() {
278
	return this.problemCount != 0;
283
	return this.problemCount != 0;
279
}
284
}
Lines 324-329 Link Here
324
}
329
}
325
330
326
public void record(CategorizedProblem newProblem, ReferenceContext referenceContext) {
331
public void record(CategorizedProblem newProblem, ReferenceContext referenceContext) {
332
	record(newProblem, referenceContext, true);
333
	return;
334
}
335
336
public void record(CategorizedProblem newProblem, ReferenceContext referenceContext, boolean mandatoryError) {
327
	//new Exception("VERBOSE PROBLEM REPORTING").printStackTrace();
337
	//new Exception("VERBOSE PROBLEM REPORTING").printStackTrace();
328
	if(newProblem.getID() == IProblem.Task) {
338
	if(newProblem.getID() == IProblem.Task) {
329
		recordTask(newProblem);
339
		recordTask(newProblem);
Lines 343-348 Link Here
343
	}
353
	}
344
	if (newProblem.isError()) {
354
	if (newProblem.isError()) {
345
		this.numberOfErrors++;
355
		this.numberOfErrors++;
356
		if (mandatoryError) this.hasMandatoryErrors = true;
346
		if ((newProblem.getID() & IProblem.Syntax) != 0) {
357
		if ((newProblem.getID() & IProblem.Syntax) != 0) {
347
			this.hasSyntaxError = true;
358
			this.hasSyntaxError = true;
348
		}
359
		}
Lines 409-412 Link Here
409
	}
420
	}
410
	return buffer.toString();
421
	return buffer.toString();
411
}
422
}
423
412
}
424
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 602-608 Link Here
602
							0, // source end
602
							0, // source end
603
							0, // line number
603
							0, // line number
604
							0),// column number
604
							0),// column number
605
					unit);
605
					unit, true);
606
606
607
			/* hand back the compilation result */
607
			/* hand back the compilation result */
608
			if (!result.hasBeenAccepted) {
608
			if (!result.hasBeenAccepted) {
Lines 664-670 Link Here
664
					if (distantProblem instanceof DefaultProblem) { // fixup filename TODO (philippe) should improve API to make this official
664
					if (distantProblem instanceof DefaultProblem) { // fixup filename TODO (philippe) should improve API to make this official
665
						((DefaultProblem) distantProblem).setOriginatingFileName(result.getFileName());
665
						((DefaultProblem) distantProblem).setOriginatingFileName(result.getFileName());
666
					}
666
					}
667
					result.record(distantProblem, unit);
667
					result.record(distantProblem, unit, true);
668
				}
668
				}
669
			} else {
669
			} else {
670
				/* distant internal exception which could not be reported back there */
670
				/* distant internal exception which could not be reported back there */
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-1 / +1 lines)
Lines 561-567 Link Here
561
				this.types[i].resolve(this.scope);
561
				this.types[i].resolve(this.scope);
562
			}
562
			}
563
		}
563
		}
564
		if (!this.compilationResult.hasErrors()) checkUnusedImports();
564
		if (!this.compilationResult.hasMandatoryErrors()) checkUnusedImports();
565
		reportNLSProblems();
565
		reportNLSProblems();
566
	} catch (AbortCompilationUnit e) {
566
	} catch (AbortCompilationUnit e) {
567
		this.ignoreFurtherInvestigation = true;
567
		this.ignoreFurtherInvestigation = true;
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java (-5 / +6 lines)
Lines 157-166 Link Here
157
157
158
	switch (severity & ProblemSeverities.Error) {
158
	switch (severity & ProblemSeverities.Error) {
159
		case ProblemSeverities.Error :
159
		case ProblemSeverities.Error :
160
			record(problem, unitResult, referenceContext);
160
			boolean mandatory = ((severity & ProblemSeverities.Optional) == 0);
161
			record(problem, unitResult, referenceContext, mandatory);
161
			if ((severity & ProblemSeverities.Fatal) != 0) {
162
			if ((severity & ProblemSeverities.Fatal) != 0) {
162
				// don't abort or tag as error if the error is suppressed
163
				// don't abort or tag as error if the error is suppressed
163
				if (!referenceContext.hasErrors() && (severity & ProblemSeverities.Optional) != 0 && this.options.suppressOptionalErrors) {
164
				if (!referenceContext.hasErrors() && !mandatory && this.options.suppressOptionalErrors) {
164
					CompilationUnitDeclaration unitDecl = referenceContext.getCompilationUnitDeclaration();
165
					CompilationUnitDeclaration unitDecl = referenceContext.getCompilationUnitDeclaration();
165
					if (unitDecl != null && unitDecl.isSuppressed(problem)) {
166
					if (unitDecl != null && unitDecl.isSuppressed(problem)) {
166
						return;
167
						return;
Lines 175-181 Link Here
175
			}
176
			}
176
			break;
177
			break;
177
		case ProblemSeverities.Warning :
178
		case ProblemSeverities.Warning :
178
			record(problem, unitResult, referenceContext);
179
			record(problem, unitResult, referenceContext, false);
179
			break;
180
			break;
180
	}
181
	}
181
}
182
}
Lines 203-209 Link Here
203
		referenceContext,
204
		referenceContext,
204
		unitResult);
205
		unitResult);
205
}
206
}
206
public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) {
207
public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext, boolean optionalError) {
207
	unitResult.record(problem, referenceContext);
208
	unitResult.record(problem, referenceContext, optionalError);
208
}
209
}
209
}
210
}
(-)a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2012 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 86-93 Link Here
86
		DefaultErrorHandlingPolicies.exitAfterAllProblems(),
86
		DefaultErrorHandlingPolicies.exitAfterAllProblems(),
87
		options,
87
		options,
88
		problemFactory) {
88
		problemFactory) {
89
		public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext context) {
89
		public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext context, boolean mandatoryError) {
90
			unitResult.record(problem, context); // TODO (jerome) clients are trapping problems either through factory or requestor... is result storing needed?
90
			unitResult.record(problem, context, mandatoryError); // TODO (jerome) clients are trapping problems either through factory or requestor... is result storing needed?
91
			SourceElementParser.this.requestor.acceptProblem(problem);
91
			SourceElementParser.this.requestor.acceptProblem(problem);
92
		}
92
		}
93
	};
93
	};

Return to bug 371832