View | Details | Raw Unified | Return to bug 295551 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java (+4 lines)
Lines 102-107 Link Here
102
		return _severity == Severity.WARNING;
102
		return _severity == Severity.WARNING;
103
	}
103
	}
104
	
104
	
105
	public boolean isPromotedWarning() {
106
		return false;
107
	}
108
	
105
	public String toString()
109
	public String toString()
106
	{
110
	{
107
		return _message == null ? "<null message>" : _message ;  //$NON-NLS-1$
111
		return _message == null ? "<null message>" : _message ;  //$NON-NLS-1$
(-)compiler/org/eclipse/jdt/core/compiler/IProblem.java (+7 lines)
Lines 206-211 Link Here
206
boolean isWarning();
206
boolean isWarning();
207
207
208
/**
208
/**
209
 * Checks the severity to see if the promotedWarning bit is set.
210
 *
211
 * @return true if the promotedWarning bit is set for the severity, false otherwise
212
 */
213
boolean isPromotedWarning();
214
215
/**
209
 * Set the end position of the problem (inclusive), or -1 if unknown.
216
 * Set the end position of the problem (inclusive), or -1 if unknown.
210
 * Used for shifting problem positions.
217
 * Used for shifting problem positions.
211
 *
218
 *
(-)compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java (+14 lines)
Lines 278-283 Link Here
278
	return false;
278
	return false;
279
}
279
}
280
280
281
/**
282
 * Difference between this and {@link #hasErrors()} is that this variant
283
 * ignores errors that were promoted up from warnings due to the
284
 * "Promote all warnings to errors" option.
285
 */
286
public boolean hasGenuineErrors() {
287
	if (this.problems != null)
288
		for (int i = 0; i < this.problemCount; i++) {
289
			if (this.problems[i].isError() && !this.problems[i].isPromotedWarning())
290
				return true;
291
		}
292
	return false;
293
}
294
281
public boolean hasProblems() {
295
public boolean hasProblems() {
282
	return this.problemCount != 0;
296
	return this.problemCount != 0;
283
}
297
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-2 / +5 lines)
Lines 217-223 Link Here
217
	nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) {
217
	nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) {
218
		CategorizedProblem problem = problems[iProblem];
218
		CategorizedProblem problem = problems[iProblem];
219
		int problemID = problem.getID();
219
		int problemID = problem.getID();
220
		if (problem.isError()) {
220
		if (problem.isError() && !problem.isPromotedWarning()) { // honor @SupressWarnings for errors promoted up from warnings  
221
			if (problemID != IProblem.UnusedWarningToken) {
221
			if (problemID != IProblem.UnusedWarningToken) {
222
			// tolerate unused warning tokens which were promoted as errors
222
			// tolerate unused warning tokens which were promoted as errors
223
				hasErrors = true;
223
				hasErrors = true;
Lines 528-534 Link Here
528
				this.types[i].resolve(this.scope);
528
				this.types[i].resolve(this.scope);
529
			}
529
			}
530
		}
530
		}
531
		if (!this.compilationResult.hasErrors()) checkUnusedImports();
531
		// Warnings that have been promoted up to errors are subject to
532
		// being silenced by @SuppressWarnings. Check unused imports only if
533
		// there are no "real" errors
534
		if (!this.compilationResult.hasGenuineErrors()) checkUnusedImports();
532
		reportNLSProblems();
535
		reportNLSProblems();
533
	} catch (AbortCompilationUnit e) {
536
	} catch (AbortCompilationUnit e) {
534
		this.ignoreFurtherInvestigation = true;
537
		this.ignoreFurtherInvestigation = true;
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (+15 lines)
Lines 115-120 Link Here
115
	public static final String OPTION_ReportUnusedWarningToken =  "org.eclipse.jdt.core.compiler.problem.unusedWarningToken"; //$NON-NLS-1$
115
	public static final String OPTION_ReportUnusedWarningToken =  "org.eclipse.jdt.core.compiler.problem.unusedWarningToken"; //$NON-NLS-1$
116
	public static final String OPTION_ReportUnusedLabel =  "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$
116
	public static final String OPTION_ReportUnusedLabel =  "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$
117
	public static final String OPTION_FatalOptionalError =  "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$
117
	public static final String OPTION_FatalOptionalError =  "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$
118
	public static final String OPTION_PromoteWarningsToErrors = "org.eclipse.jdt.core.compiler.problem.promoteWarningsToErrors"; //$NON-NLS-1$
118
	public static final String OPTION_ReportParameterAssignment =  "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
119
	public static final String OPTION_ReportParameterAssignment =  "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
119
	public static final String OPTION_ReportFallthroughCase =  "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$
120
	public static final String OPTION_ReportFallthroughCase =  "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$
120
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
121
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
Lines 335-340 Link Here
335
	public boolean generateClassFiles;
336
	public boolean generateClassFiles;
336
	/** Indicate if method bodies should be ignored */
337
	/** Indicate if method bodies should be ignored */
337
	public boolean ignoreMethodBodies;
338
	public boolean ignoreMethodBodies;
339
	/** Indicate if all warnings should be promoted to errors */
340
	private boolean promoteWarningsToErrors;
338
341
339
	// keep in sync with warningTokenToIrritant and warningTokenFromIrritant
342
	// keep in sync with warningTokenToIrritant and warningTokenFromIrritant
340
	public final static String[] warningTokens = {
343
	public final static String[] warningTokens = {
Lines 861-866 Link Here
861
		optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel));
864
		optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel));
862
		optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK));
865
		optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK));
863
		optionsMap.put(OPTION_FatalOptionalError, this.treatOptionalErrorAsFatal ? ENABLED : DISABLED);
866
		optionsMap.put(OPTION_FatalOptionalError, this.treatOptionalErrorAsFatal ? ENABLED : DISABLED);
867
		optionsMap.put(OPTION_PromoteWarningsToErrors, this.promoteWarningsToErrors ? ENABLED : DISABLED);
864
		if (this.defaultEncoding != null) {
868
		if (this.defaultEncoding != null) {
865
			optionsMap.put(OPTION_Encoding, this.defaultEncoding);
869
			optionsMap.put(OPTION_Encoding, this.defaultEncoding);
866
		}
870
		}
Lines 1009-1014 Link Here
1009
		// treat optional error as fatal or just like warning?
1013
		// treat optional error as fatal or just like warning?
1010
		this.treatOptionalErrorAsFatal = true;
1014
		this.treatOptionalErrorAsFatal = true;
1011
1015
1016
		// promote all warnings to errors?
1017
		this.promoteWarningsToErrors = false;
1018
1012
		// parser perform statements recovery
1019
		// parser perform statements recovery
1013
		this.performMethodsFullRecovery = true;
1020
		this.performMethodsFullRecovery = true;
1014
1021
Lines 1224-1229 Link Here
1224
				this.treatOptionalErrorAsFatal = false;
1231
				this.treatOptionalErrorAsFatal = false;
1225
			}
1232
			}
1226
		}
1233
		}
1234
		if ((optionValue = optionsMap.get(OPTION_PromoteWarningsToErrors)) != null) {
1235
			if (ENABLED.equals(optionValue)) {
1236
				this.promoteWarningsToErrors = true;
1237
			} else if (DISABLED.equals(optionValue)) {
1238
				this.promoteWarningsToErrors = false;
1239
			}
1240
		}
1227
		if ((optionValue = optionsMap.get(OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation)) != null) {
1241
		if ((optionValue = optionsMap.get(OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation)) != null) {
1228
			if (ENABLED.equals(optionValue)) {
1242
			if (ENABLED.equals(optionValue)) {
1229
				this.reportMissingOverrideAnnotationForInterfaceMethodImplementation = true;
1243
				this.reportMissingOverrideAnnotationForInterfaceMethodImplementation = true;
Lines 1477-1482 Link Here
1477
		buf.append("\n\t- unused warning token: ").append(getSeverityString(UnusedWarningToken)); //$NON-NLS-1$
1491
		buf.append("\n\t- unused warning token: ").append(getSeverityString(UnusedWarningToken)); //$NON-NLS-1$
1478
		buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$
1492
		buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$
1479
		buf.append("\n\t- treat optional error as fatal: ").append(this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); //$NON-NLS-1$
1493
		buf.append("\n\t- treat optional error as fatal: ").append(this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); //$NON-NLS-1$
1494
		buf.append("\n\t- promote warnings to errors: ").append(this.promoteWarningsToErrors ? ENABLED : DISABLED); //$NON-NLS-1$
1480
		buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$
1495
		buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$
1481
		buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
1496
		buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
1482
		buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
1497
		buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
(-)compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java (+8 lines)
Lines 242-247 Link Here
242
	return (this.severity & ProblemSeverities.Error) == 0;
242
	return (this.severity & ProblemSeverities.Error) == 0;
243
}
243
}
244
244
245
/*
246
 * @see org.eclipse.jdt.core.compiler.IProblem#isPromotedWarning()
247
 */
248
public boolean isPromotedWarning() {
249
	return isError() && ((this.severity & ProblemSeverities.Promoted) != 0);
250
}
251
252
245
public void setOriginatingFileName(char[] fileName) {
253
public void setOriginatingFileName(char[] fileName) {
246
	this.fileName = fileName;
254
	this.fileName = fileName;
247
}
255
}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java (+12 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.problem;
11
package org.eclipse.jdt.internal.compiler.problem;
12
12
13
import org.eclipse.jdt.core.JavaCore;
13
import org.eclipse.jdt.core.compiler.CategorizedProblem;
14
import org.eclipse.jdt.core.compiler.CategorizedProblem;
14
import org.eclipse.jdt.core.compiler.CharOperation;
15
import org.eclipse.jdt.core.compiler.CharOperation;
15
import org.eclipse.jdt.internal.compiler.CompilationResult;
16
import org.eclipse.jdt.internal.compiler.CompilationResult;
Lines 131-136 Link Here
131
	int columnNumber = problemStartPosition >= 0
132
	int columnNumber = problemStartPosition >= 0
132
			? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition)
133
			? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition)
133
			: 0;
134
			: 0;
135
136
	// User can promote all warnings to errors via an option. If this is a warning
137
	// and the option is on, then promote the problem to an error, but mark it
138
	// to allow for special handling (e.g., honor @SuppressWarning) 
139
	if ((severity & ProblemSeverities.Error) == 0) {
140
		String option = (String)this.options.getMap().get(JavaCore.COMPILER_PB_PROMOTE_WARNINGS_TO_ERRS);
141
		if (option != null && option.equals(JavaCore.ENABLED)) {
142
			severity |= (ProblemSeverities.Error | ProblemSeverities.Promoted);
143
		}
144
	}
145
			
134
	CategorizedProblem problem =
146
	CategorizedProblem problem =
135
		this.createProblem(
147
		this.createProblem(
136
			unitResult.getFileName(),
148
			unitResult.getFileName(),
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java (+1 lines)
Lines 24-27 Link Here
24
	final int Optional = 32; // when bit is set: problem was configurable
24
	final int Optional = 32; // when bit is set: problem was configurable
25
	final int SecondaryError = 64;
25
	final int SecondaryError = 64;
26
	final int Fatal = 128; // when bit is set: problem was either a mandatory error, or an optional+treatOptionalErrorAsFatal
26
	final int Fatal = 128; // when bit is set: problem was either a mandatory error, or an optional+treatOptionalErrorAsFatal
27
	final int Promoted = 512; // when bit is set, the problem is a warning that has been promoted to an error via the "promote all warnings to error" setting 
27
}
28
}
(-)model/org/eclipse/jdt/core/IJavaModelMarker.java (+14 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core;
11
package org.eclipse.jdt.core;
12
12
13
import org.eclipse.core.resources.IMarker;
14
13
/**
15
/**
14
 * Markers used by the Java model.
16
 * Markers used by the Java model.
15
 * <p>
17
 * <p>
Lines 84-89 Link Here
84
	String FLAGS = "flags"; //$NON-NLS-1$
86
	String FLAGS = "flags"; //$NON-NLS-1$
85
87
86
	/**
88
	/**
89
	 * Boolean marker attribute indicating if the marker is for an error that
90
	 * was promoted up from a warning by the "Promote all warnings to errors"
91
	 * option (value <code>"promotedWarning"</code>). The
92
	 * {@link IMarker#SEVERITY} attribute will contain
93
	 * <code>SEVERITY_ERROR</code> if this attribute is present and set to true.
94
	 * That is, this attribute merely further qualifies the error marker.
95
	 * 
96
	 * @since 3.6
97
	 */
98
	String PROMOTED_WARNING = "promotedWarning"; //$NON-NLS-1$
99
	
100
	/**
87
	 * Cycle detected marker attribute (value <code>"cycleDetected"</code>).
101
	 * Cycle detected marker attribute (value <code>"cycleDetected"</code>).
88
	 * Used only on buildpath problem markers. The value of this attribute is
102
	 * Used only on buildpath problem markers. The value of this attribute is
89
	 * either "true" or "false".
103
	 * either "true" or "false".
(-)model/org/eclipse/jdt/core/JavaCore.java (+15 lines)
Lines 1281-1286 Link Here
1281
	 * @category CompilerOptionID
1281
	 * @category CompilerOptionID
1282
	 */
1282
	 */
1283
	public static final String COMPILER_PB_FATAL_OPTIONAL_ERROR = PLUGIN_ID + ".compiler.problem.fatalOptionalError"; //$NON-NLS-1$
1283
	public static final String COMPILER_PB_FATAL_OPTIONAL_ERROR = PLUGIN_ID + ".compiler.problem.fatalOptionalError"; //$NON-NLS-1$
1284
1285
	/**
1286
	 * Compiler option ID: Promote all warnings to errors
1287
	 * <p>When enabled, all warnings will be promoted up to errors. Those errors are subject to exclusion by @SuppressWarnings 
1288
	 * <dl>
1289
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.promoteWarningsToErrors"</code></dd>
1290
	 * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd>
1291
	 * <dt>Default:</dt><dd><code>"enabled"</code></dd>
1292
	 * </dl>
1293
	 * @since 3.6
1294
	 * @category CompilerOptionID
1295
	 */
1296
	public static final String COMPILER_PB_PROMOTE_WARNINGS_TO_ERRS = PLUGIN_ID + ".compiler.problem.promoteWarningsToErrors"; //$NON-NLS-1$
1297
	
1298
	
1284
	/**
1299
	/**
1285
	 * Compiler option ID: Reporting Parameter Assignment.
1300
	 * Compiler option ID: Reporting Parameter Assignment.
1286
	 * <p>When enabled, the compiler will issue an error or a warning if a parameter is
1301
	 * <p>When enabled, the compiler will issue an error or a warning if a parameter is
(-)model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java (+3 lines)
Lines 66-71 Link Here
66
	IMarker.LINE_NUMBER,
66
	IMarker.LINE_NUMBER,
67
	IJavaModelMarker.ARGUMENTS,
67
	IJavaModelMarker.ARGUMENTS,
68
	IJavaModelMarker.CATEGORY_ID,
68
	IJavaModelMarker.CATEGORY_ID,
69
	IJavaModelMarker.PROMOTED_WARNING,
69
};
70
};
70
public final static String[] JAVA_TASK_MARKER_ATTRIBUTE_NAMES = {
71
public final static String[] JAVA_TASK_MARKER_ATTRIBUTE_NAMES = {
71
	IMarker.MESSAGE,
72
	IMarker.MESSAGE,
Lines 734-739 Link Here
734
			allValues[index++] = new Integer(problem.getSourceLineNumber()); // line
735
			allValues[index++] = new Integer(problem.getSourceLineNumber()); // line
735
			allValues[index++] = Util.getProblemArgumentsForMarker(problem.getArguments()); // arguments
736
			allValues[index++] = Util.getProblemArgumentsForMarker(problem.getArguments()); // arguments
736
			allValues[index++] = new Integer(problem.getCategoryID()); // category ID
737
			allValues[index++] = new Integer(problem.getCategoryID()); // category ID
738
			allValues[index++] = new Boolean(problem.isPromotedWarning());	// IJavaModelMarker.PROMOTED_WARNING
739
737
			// SOURCE_ID attribute for JDT problems
740
			// SOURCE_ID attribute for JDT problems
738
			if (managedLength > 0)
741
			if (managedLength > 0)
739
				allValues[index++] = JavaBuilder.SOURCE_ID;
742
				allValues[index++] = JavaBuilder.SOURCE_ID;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+1 lines)
Lines 1834-1839 Link Here
1834
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" +
1834
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.parameterAssignment\" value=\"ignore\"/>\n" +
1835
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" +
1835
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\n" +
1836
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.potentialNullReference\" value=\"ignore\"/>\n" +
1836
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.potentialNullReference\" value=\"ignore\"/>\n" +
1837
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.promoteWarningsToErrors\" value=\"disabled\"/>\n" + 
1837
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"warning\"/>\n" +
1838
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.rawTypeReference\" value=\"warning\"/>\n" +
1838
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantNullCheck\" value=\"ignore\"/>\n" +
1839
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantNullCheck\" value=\"ignore\"/>\n" +
1839
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantSuperinterface\" value=\"ignore\"/>\n" +
1840
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.redundantSuperinterface\" value=\"ignore\"/>\n" +
(-)ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java (+11 lines)
Lines 194-199 Link Here
194
		private int fLayer= IAnnotationAccessExtension.DEFAULT_LAYER;
194
		private int fLayer= IAnnotationAccessExtension.DEFAULT_LAYER;
195
		private boolean fIsQuickFixable;
195
		private boolean fIsQuickFixable;
196
		private boolean fIsQuickFixableStateSet= false;
196
		private boolean fIsQuickFixableStateSet= false;
197
		private boolean fIsPromotedWarning;
197
198
198
199
199
		public ProblemAnnotation(IProblem problem, ICompilationUnit cu) {
200
		public ProblemAnnotation(IProblem problem, ICompilationUnit cu) {
Lines 217-222 Link Here
217
				setType(JavaMarkerAnnotation.INFO_ANNOTATION_TYPE);
218
				setType(JavaMarkerAnnotation.INFO_ANNOTATION_TYPE);
218
				fLayer= INFO_LAYER;
219
				fLayer= INFO_LAYER;
219
			}
220
			}
221
			fIsPromotedWarning = problem.isPromotedWarning(); 
222
			
220
		}
223
		}
221
224
222
		/*
225
		/*
Lines 396-401 Link Here
396
			Assert.isTrue(isQuickFixableStateSet());
399
			Assert.isTrue(isQuickFixableStateSet());
397
			return fIsQuickFixable;
400
			return fIsQuickFixable;
398
		}
401
		}
402
403
		/* 
404
		 * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#isPromotedWarning()
405
		 * @since 3.6
406
		 */
407
		public boolean isPromotedWarning() {
408
			return fIsPromotedWarning;
409
		}
399
	}
410
	}
400
411
401
	/**
412
	/**
(-)ui/org/eclipse/jdt/internal/ui/javaeditor/IJavaAnnotation.java (+10 lines)
Lines 105-110 Link Here
105
	boolean isProblem();
105
	boolean isProblem();
106
106
107
	/**
107
	/**
108
	 * Tells whether this annotation is a problem annotation, specifically an
109
	 * error that was promoted up from a warning by the
110
	 * "Promote all warnings to errors" option. If this returns true, then
111
	 * {@link #isProblem()} is guaranteed to also return true.
112
	 * 
113
	 * @return <code>true</code> if it is an error that was promoted up from a warning
114
	 */
115
	boolean isPromotedWarning();
116
	
117
	/**
108
	 * Returns the compilation unit corresponding to the document on which the annotation.
118
	 * Returns the compilation unit corresponding to the document on which the annotation.
109
	 * 
119
	 * 
110
	 * @return the compilation unit or <code>null</code> if no corresponding compilation unit exists
120
	 * @return the compilation unit or <code>null</code> if no corresponding compilation unit exists
(-)ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMarkerAnnotation.java (+11 lines)
Lines 102-107 Link Here
102
		return WARNING_ANNOTATION_TYPE.equals(type) || ERROR_ANNOTATION_TYPE.equals(type);
102
		return WARNING_ANNOTATION_TYPE.equals(type) || ERROR_ANNOTATION_TYPE.equals(type);
103
	}
103
	}
104
104
105
	/*
106
	 * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#isPromotedWarning()
107
	 */
108
	public boolean isPromotedWarning() {
109
		IMarker marker = getMarker();
110
		if (marker != null && marker.exists()) {
111
			return marker.getAttribute(IJavaModelMarker.PROMOTED_WARNING, false);
112
		}
113
		return false;
114
	}
115
	
105
	/**
116
	/**
106
	 * Overlays this annotation with the given javaAnnotation.
117
	 * Overlays this annotation with the given javaAnnotation.
107
	 *
118
	 *
(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java (+1 lines)
Lines 276-281 Link Here
276
	public static String ProblemSeveritiesConfigurationBlock_pb_redundant_null_check;
276
	public static String ProblemSeveritiesConfigurationBlock_pb_redundant_null_check;
277
	public static String ProblemSeveritiesConfigurationBlock_pb_redundant_super_interface_label;
277
	public static String ProblemSeveritiesConfigurationBlock_pb_redundant_super_interface_label;
278
	public static String ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal;
278
	public static String ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal;
279
	public static String ProblemSeveritiesConfigurationBlock_promote_warnings_to_errors;
279
	public static String SourceAttachmentPropertyPage_error_title;
280
	public static String SourceAttachmentPropertyPage_error_title;
280
	public static String SourceAttachmentPropertyPage_error_message;
281
	public static String SourceAttachmentPropertyPage_error_message;
281
	public static String SourceAttachmentPropertyPage_invalid_container;
282
	public static String SourceAttachmentPropertyPage_invalid_container;
(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties (+1 lines)
Lines 352-357 Link Here
352
JavaBuildConfigurationBlock_needsbuild_title=Building Settings Changed
352
JavaBuildConfigurationBlock_needsbuild_title=Building Settings Changed
353
JavaBuildConfigurationBlock_needsfullbuild_message=The Building settings have changed. A full rebuild is required for changes to take effect. Do the full build now?
353
JavaBuildConfigurationBlock_needsfullbuild_message=The Building settings have changed. A full rebuild is required for changes to take effect. Do the full build now?
354
ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal=Treat errors like &fatal compiler errors (make compiled code not executable)
354
ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal=Treat errors like &fatal compiler errors (make compiled code not executable)
355
ProblemSeveritiesConfigurationBlock_promote_warnings_to_errors=Promote all warnings to errors
355
JavaBuildConfigurationBlock_needsprojectbuild_message=The Building settings have changed. A rebuild of the project is required for changes to take effect. Build the project now?
356
JavaBuildConfigurationBlock_needsprojectbuild_message=The Building settings have changed. A rebuild of the project is required for changes to take effect. Build the project now?
356
357
357
JavaBuildConfigurationBlock_resource_filter_description=Filtered resources are not copied to the output folder during a build. List is comma separated (e.g. '*.doc, plugin.xml, scripts/')
358
JavaBuildConfigurationBlock_resource_filter_description=Filtered resources are not copied to the output folder during a build. List is comma separated (e.g. '*.doc, plugin.xml, scripts/')
(-)ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java (-1 / +5 lines)
Lines 105-110 Link Here
105
	private static final Key PREF_PB_SUPPRESS_WARNINGS= getJDTCoreKey(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS);
105
	private static final Key PREF_PB_SUPPRESS_WARNINGS= getJDTCoreKey(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS);
106
	private static final Key PREF_PB_UNHANDLED_WARNING_TOKEN= getJDTCoreKey(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN);
106
	private static final Key PREF_PB_UNHANDLED_WARNING_TOKEN= getJDTCoreKey(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN);
107
	private static final Key PREF_PB_FATAL_OPTIONAL_ERROR= getJDTCoreKey(JavaCore.COMPILER_PB_FATAL_OPTIONAL_ERROR);
107
	private static final Key PREF_PB_FATAL_OPTIONAL_ERROR= getJDTCoreKey(JavaCore.COMPILER_PB_FATAL_OPTIONAL_ERROR);
108
	private static final Key PREF_PB_PROMOTE_WARNINGS_TO_ERRS = getJDTCoreKey(JavaCore.COMPILER_PB_PROMOTE_WARNINGS_TO_ERRS);
108
109
109
	private static final Key PREF_PB_MISSING_HASHCODE_METHOD= getJDTCoreKey(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD);
110
	private static final Key PREF_PB_MISSING_HASHCODE_METHOD= getJDTCoreKey(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD);
110
	private static final Key PREF_PB_DEAD_CODE= getJDTCoreKey(JavaCore.COMPILER_PB_DEAD_CODE);
111
	private static final Key PREF_PB_DEAD_CODE= getJDTCoreKey(JavaCore.COMPILER_PB_DEAD_CODE);
Lines 154-160 Link Here
154
				PREF_15_PB_AUTOBOXING_PROBLEM, PREF_15_PB_MISSING_OVERRIDE_ANNOTATION, PREF_16_PB_MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION,
155
				PREF_15_PB_AUTOBOXING_PROBLEM, PREF_15_PB_MISSING_OVERRIDE_ANNOTATION, PREF_16_PB_MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION,
155
				PREF_15_PB_ANNOTATION_SUPER_INTERFACE,
156
				PREF_15_PB_ANNOTATION_SUPER_INTERFACE,
156
				PREF_15_PB_TYPE_PARAMETER_HIDING, PREF_15_PB_INCOMPLETE_ENUM_SWITCH, PREF_PB_MISSING_DEPRECATED_ANNOTATION,
157
				PREF_15_PB_TYPE_PARAMETER_HIDING, PREF_15_PB_INCOMPLETE_ENUM_SWITCH, PREF_PB_MISSING_DEPRECATED_ANNOTATION,
157
				PREF_15_PB_RAW_TYPE_REFERENCE, PREF_PB_FATAL_OPTIONAL_ERROR,
158
				PREF_15_PB_RAW_TYPE_REFERENCE, PREF_PB_FATAL_OPTIONAL_ERROR, PREF_PB_PROMOTE_WARNINGS_TO_ERRS,
158
				PREF_PB_FORBIDDEN_REFERENCE, PREF_PB_DISCOURRAGED_REFERENCE, PREF_PB_SUPPRESS_WARNINGS, PREF_PB_UNHANDLED_WARNING_TOKEN,
159
				PREF_PB_FORBIDDEN_REFERENCE, PREF_PB_DISCOURRAGED_REFERENCE, PREF_PB_SUPPRESS_WARNINGS, PREF_PB_UNHANDLED_WARNING_TOKEN,
159
				PREF_PB_COMPARING_IDENTICAL, PREF_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, PREF_PB_MISSING_HASHCODE_METHOD,
160
				PREF_PB_COMPARING_IDENTICAL, PREF_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, PREF_PB_MISSING_HASHCODE_METHOD,
160
				PREF_PB_DEAD_CODE
161
				PREF_PB_DEAD_CODE
Lines 483-488 Link Here
483
		label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal;
484
		label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal;
484
		addCheckBox(composite, label, PREF_PB_FATAL_OPTIONAL_ERROR, enableDisableValues, 0);
485
		addCheckBox(composite, label, PREF_PB_FATAL_OPTIONAL_ERROR, enableDisableValues, 0);
485
486
487
		label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_promote_warnings_to_errors;
488
		addCheckBox(composite, label, PREF_PB_PROMOTE_WARNINGS_TO_ERRS, enableDisableValues, 0);
489
486
490
487
		IDialogSettings section= JavaPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME);
491
		IDialogSettings section= JavaPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME);
488
		restoreSectionExpansionStates(section);
492
		restoreSectionExpansionStates(section);
(-)ui/org/eclipse/jdt/internal/ui/text/correction/ProblemLocation.java (-1 / +9 lines)
Lines 33-38 Link Here
33
	private final int fLength;
33
	private final int fLength;
34
	private final boolean fIsError;
34
	private final boolean fIsError;
35
	private final String fMarkerType;
35
	private final String fMarkerType;
36
	private boolean fIsPromotedWarning;
36
37
37
	public ProblemLocation(int offset, int length, IJavaAnnotation annotation) {
38
	public ProblemLocation(int offset, int length, IJavaAnnotation annotation) {
38
		fId= annotation.getId();
39
		fId= annotation.getId();
Lines 40-46 Link Here
40
		fOffset= offset;
41
		fOffset= offset;
41
		fLength= length;
42
		fLength= length;
42
		fIsError= JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType());
43
		fIsError= JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType());
43
44
		fIsPromotedWarning = annotation.isPromotedWarning();
44
		String markerType= annotation.getMarkerType();
45
		String markerType= annotation.getMarkerType();
45
		fMarkerType= markerType != null ? markerType : IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER;
46
		fMarkerType= markerType != null ? markerType : IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER;
46
	}
47
	}
Lines 98-103 Link Here
98
	public boolean isError() {
99
	public boolean isError() {
99
		return fIsError;
100
		return fIsError;
100
	}
101
	}
102
	
103
	/* (non-Javadoc)
104
	 * @see org.eclipse.jdt.ui.text.java.IProblemLocation#isPromotedWarning()
105
	 */
106
	public boolean isPromotedWarning() {
107
		return fIsPromotedWarning;
108
	}
101
109
102
	/* (non-Javadoc)
110
	/* (non-Javadoc)
103
	 * @see org.eclipse.jdt.ui.text.java.IProblemLocation#getMarkerType()
111
	 * @see org.eclipse.jdt.ui.text.java.IProblemLocation#getMarkerType()
(-)ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java (-1 / +2 lines)
Lines 84-90 Link Here
84
84
85
85
86
	public static void addSuppressWarningsProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) {
86
	public static void addSuppressWarningsProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) {
87
		if (problem.isError()) {
87
		// @SuppressWarings is available only to warnings, and errors that were promoted up to warnings 
88
		if (problem.isError() && !problem.isPromotedWarning()) {
88
			return;
89
			return;
89
		}
90
		}
90
		if (JavaCore.DISABLED.equals(context.getCompilationUnit().getJavaProject().getOption(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS, true))) {
91
		if (JavaCore.DISABLED.equals(context.getCompilationUnit().getJavaProject().getOption(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS, true))) {
(-)ui/org/eclipse/jdt/internal/ui/text/spelling/CoreSpellingProblem.java (+7 lines)
Lines 155-160 Link Here
155
	public boolean isWarning() {
155
	public boolean isWarning() {
156
		return true;
156
		return true;
157
	}
157
	}
158
	
159
	/*
160
	 * @see org.eclipse.jdt.core.compiler.IProblem#isPromotedWarning()
161
	 */
162
	public boolean isPromotedWarning() {
163
		return false;
164
	}
158
165
159
	/*
166
	/*
160
	 * @see org.eclipse.jdt.core.compiler.IProblem#setSourceStart(int)
167
	 * @see org.eclipse.jdt.core.compiler.IProblem#setSourceStart(int)
(-)ui/org/eclipse/jdt/ui/text/java/IProblemLocation.java (+8 lines)
Lines 73-78 Link Here
73
	boolean isError();
73
	boolean isError();
74
74
75
	/**
75
	/**
76
	 * Returns if the problem is an error that was promoted up from a warning by the
77
	 * "Promote all warnings to errors" option
78
	 * 
79
	 * @return <code>true</code> is the problem is an error that was promoted up from a warning
80
	 */
81
	boolean isPromotedWarning();
82
83
	/**
76
	 * Convenience method to evaluate the AST node covering this problem.
84
	 * Convenience method to evaluate the AST node covering this problem.
77
	 *
85
	 *
78
	 * @param astRoot The root node of the current AST
86
	 * @param astRoot The root node of the current AST

Return to bug 295551