### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.apt.core Index: src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java,v retrieving revision 1.11 diff -u -r1.11 APTProblem.java --- src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java 7 May 2008 15:37:45 -0000 1.11 +++ src/org/eclipse/jdt/apt/core/internal/env/APTProblem.java 19 Nov 2009 06:42:59 -0000 @@ -102,6 +102,10 @@ return _severity == Severity.WARNING; } + public boolean isPromotedWarning() { + return false; + } + public String toString() { return _message == null ? "" : _message ; //$NON-NLS-1$ #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v retrieving revision 1.220 diff -u -r1.220 IProblem.java --- compiler/org/eclipse/jdt/core/compiler/IProblem.java 11 Nov 2009 19:28:04 -0000 1.220 +++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 19 Nov 2009 06:43:01 -0000 @@ -206,6 +206,13 @@ boolean isWarning(); /** + * Checks the severity to see if the promotedWarning bit is set. + * + * @return true if the promotedWarning bit is set for the severity, false otherwise + */ +boolean isPromotedWarning(); + +/** * Set the end position of the problem (inclusive), or -1 if unknown. * Used for shifting problem positions. * Index: compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java,v retrieving revision 1.86 diff -u -r1.86 CompilationUnitDeclaration.java --- compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 12 May 2009 20:49:55 -0000 1.86 +++ compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 19 Nov 2009 06:43:01 -0000 @@ -217,7 +217,7 @@ nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) { CategorizedProblem problem = problems[iProblem]; int problemID = problem.getID(); - if (problem.isError()) { + if (problem.isError() && !problem.isPromotedWarning()) { // honor @SupressWarnings for errors promoted up from warnings if (problemID != IProblem.UnusedWarningToken) { // tolerate unused warning tokens which were promoted as errors hasErrors = true; Index: compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java,v retrieving revision 1.223 diff -u -r1.223 CompilerOptions.java --- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 6 Oct 2009 19:24:18 -0000 1.223 +++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 19 Nov 2009 06:43:01 -0000 @@ -115,6 +115,7 @@ public static final String OPTION_ReportUnusedWarningToken = "org.eclipse.jdt.core.compiler.problem.unusedWarningToken"; //$NON-NLS-1$ public static final String OPTION_ReportUnusedLabel = "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$ public static final String OPTION_FatalOptionalError = "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$ + public static final String OPTION_PromoteWarningsToErrors = "org.eclipse.jdt.core.compiler.problem.promoteWarningsToErrors"; //$NON-NLS-1$ public static final String OPTION_ReportParameterAssignment = "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$ public static final String OPTION_ReportFallthroughCase = "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$ public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation = "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$ @@ -333,6 +334,8 @@ public boolean reportMissingOverrideAnnotationForInterfaceMethodImplementation; /** Indicate if annotation processing generates classfiles */ public boolean generateClassFiles; + /** Indicate if all warnings should be promoted to errors */ + private boolean promoteWarningsToErrors; // keep in sync with warningTokenToIrritant and warningTokenFromIrritant @@ -860,6 +863,7 @@ optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel)); optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK)); optionsMap.put(OPTION_FatalOptionalError, this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); + optionsMap.put(OPTION_PromoteWarningsToErrors, this.promoteWarningsToErrors ? ENABLED : DISABLED); if (this.defaultEncoding != null) { optionsMap.put(OPTION_Encoding, this.defaultEncoding); } @@ -1008,6 +1012,9 @@ // treat optional error as fatal or just like warning? this.treatOptionalErrorAsFatal = true; + // promote all warnings to errors? + this.promoteWarningsToErrors = false; + // parser perform statements recovery this.performMethodsFullRecovery = true; @@ -1221,6 +1228,13 @@ this.treatOptionalErrorAsFatal = false; } } + if ((optionValue = optionsMap.get(OPTION_PromoteWarningsToErrors)) != null) { + if (ENABLED.equals(optionValue)) { + this.promoteWarningsToErrors = true; + } else if (DISABLED.equals(optionValue)) { + this.promoteWarningsToErrors = false; + } + } if ((optionValue = optionsMap.get(OPTION_ReportMissingOverrideAnnotationForInterfaceMethodImplementation)) != null) { if (ENABLED.equals(optionValue)) { this.reportMissingOverrideAnnotationForInterfaceMethodImplementation = true; @@ -1474,6 +1488,7 @@ buf.append("\n\t- unused warning token: ").append(getSeverityString(UnusedWarningToken)); //$NON-NLS-1$ buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$ buf.append("\n\t- treat optional error as fatal: ").append(this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); //$NON-NLS-1$ + buf.append("\n\t- promote warnings to errors: ").append(this.promoteWarningsToErrors ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$ buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$ buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$ Index: compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java,v retrieving revision 1.51 diff -u -r1.51 DefaultProblem.java --- compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java 7 Mar 2009 01:08:10 -0000 1.51 +++ compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java 19 Nov 2009 06:43:02 -0000 @@ -242,6 +242,14 @@ return (this.severity & ProblemSeverities.Error) == 0; } +/* + * @see org.eclipse.jdt.core.compiler.IProblem#isPromotedWarning() + */ +public boolean isPromotedWarning() { + return isError() && ((this.severity & ProblemSeverities.Promoted) != 0); +} + + public void setOriginatingFileName(char[] fileName) { this.fileName = fileName; } Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java,v retrieving revision 1.35 diff -u -r1.35 ProblemHandler.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java 7 Mar 2009 01:08:10 -0000 1.35 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java 19 Nov 2009 06:43:02 -0000 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jdt.internal.compiler.problem; +import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.CompilationResult; @@ -131,6 +132,17 @@ int columnNumber = problemStartPosition >= 0 ? Util.searchColumnNumber(unitResult.getLineSeparatorPositions(), lineNumber, problemStartPosition) : 0; + + // User can promote all warnings to errors via an option. If this is a warning + // and the option is on, then promote the problem to an error, but mark it + // to allow for special handling (e.g., honor @SuppressWarning) + if ((severity & ProblemSeverities.Error) == 0) { + String option = (String)this.options.getMap().get(JavaCore.COMPILER_PB_PROMOTE_WARNINGS_TO_ERRS); + if (option != null && option.equals(JavaCore.ENABLED)) { + severity |= (ProblemSeverities.Error | ProblemSeverities.Promoted); + } + } + CategorizedProblem problem = this.createProblem( unitResult.getFileName(), Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java,v retrieving revision 1.16 diff -u -r1.16 ProblemSeverities.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java 22 Jul 2009 20:03:28 -0000 1.16 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java 19 Nov 2009 06:43:02 -0000 @@ -24,4 +24,5 @@ final int Optional = 32; // when bit is set: problem was configurable final int SecondaryError = 64; final int Fatal = 128; // when bit is set: problem was either a mandatory error, or an optional+treatOptionalErrorAsFatal + 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 } Index: model/org/eclipse/jdt/core/IJavaModelMarker.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java,v retrieving revision 1.41 diff -u -r1.41 IJavaModelMarker.java --- model/org/eclipse/jdt/core/IJavaModelMarker.java 27 Jun 2008 16:04:01 -0000 1.41 +++ model/org/eclipse/jdt/core/IJavaModelMarker.java 19 Nov 2009 06:43:03 -0000 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.jdt.core; +import org.eclipse.core.resources.IMarker; + /** * Markers used by the Java model. *

@@ -84,6 +86,18 @@ String FLAGS = "flags"; //$NON-NLS-1$ /** + * Boolean marker attribute indicating if the marker is for an error that + * was promoted up from a warning by the "Promote all warnings to errors" + * option (value "promotedWarning"). The + * {@link IMarker#SEVERITY} attribute will contain + * SEVERITY_ERROR if this attribute is present and set to true. + * That is, this attribute merely further qualifies the error marker. + * + * @since 3.6 + */ + String PROMOTED_WARNING = "promotedWarning"; //$NON-NLS-1$ + + /** * Cycle detected marker attribute (value "cycleDetected"). * Used only on buildpath problem markers. The value of this attribute is * either "true" or "false". Index: model/org/eclipse/jdt/core/JavaCore.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v retrieving revision 1.643 diff -u -r1.643 JavaCore.java --- model/org/eclipse/jdt/core/JavaCore.java 26 Oct 2009 17:21:09 -0000 1.643 +++ model/org/eclipse/jdt/core/JavaCore.java 19 Nov 2009 06:43:03 -0000 @@ -1281,6 +1281,21 @@ * @category CompilerOptionID */ public static final String COMPILER_PB_FATAL_OPTIONAL_ERROR = PLUGIN_ID + ".compiler.problem.fatalOptionalError"; //$NON-NLS-1$ + + /** + * Compiler option ID: Promote all warnings to errors + *

When enabled, all warnings will be promoted up to errors. Those errors are subject to exclusion by @SuppressWarnings + *

+ *
Option id:
"org.eclipse.jdt.core.compiler.problem.promoteWarningsToErrors"
+ *
Possible values:
{ "enabled", "disabled" }
+ *
Default:
"enabled"
+ *
+ * @since 3.6 + * @category CompilerOptionID + */ + public static final String COMPILER_PB_PROMOTE_WARNINGS_TO_ERRS = PLUGIN_ID + ".compiler.problem.promoteWarningsToErrors"; //$NON-NLS-1$ + + /** * Compiler option ID: Reporting Parameter Assignment. *

When enabled, the compiler will issue an error or a warning if a parameter is Index: model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java,v retrieving revision 1.126 diff -u -r1.126 AbstractImageBuilder.java --- model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java 5 Oct 2009 14:44:21 -0000 1.126 +++ model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java 19 Nov 2009 06:43:03 -0000 @@ -66,6 +66,7 @@ IMarker.LINE_NUMBER, IJavaModelMarker.ARGUMENTS, IJavaModelMarker.CATEGORY_ID, + IJavaModelMarker.PROMOTED_WARNING, }; public final static String[] JAVA_TASK_MARKER_ATTRIBUTE_NAMES = { IMarker.MESSAGE, @@ -734,6 +735,8 @@ allValues[index++] = new Integer(problem.getSourceLineNumber()); // line allValues[index++] = Util.getProblemArgumentsForMarker(problem.getArguments()); // arguments allValues[index++] = new Integer(problem.getCategoryID()); // category ID + allValues[index++] = new Boolean(problem.isPromotedWarning()); // IJavaModelMarker.PROMOTED_WARNING + // SOURCE_ID attribute for JDT problems if (managedLength > 0) allValues[index++] = JavaBuilder.SOURCE_ID; #P org.eclipse.jdt.ui Index: ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java,v retrieving revision 1.187 diff -u -r1.187 CompilationUnitDocumentProvider.java --- ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java 19 Feb 2009 08:09:20 -0000 1.187 +++ ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitDocumentProvider.java 19 Nov 2009 06:43:05 -0000 @@ -194,6 +194,7 @@ private int fLayer= IAnnotationAccessExtension.DEFAULT_LAYER; private boolean fIsQuickFixable; private boolean fIsQuickFixableStateSet= false; + private boolean fIsPromotedWarning; public ProblemAnnotation(IProblem problem, ICompilationUnit cu) { @@ -217,6 +218,8 @@ setType(JavaMarkerAnnotation.INFO_ANNOTATION_TYPE); fLayer= INFO_LAYER; } + fIsPromotedWarning = problem.isPromotedWarning(); + } /* @@ -396,6 +399,14 @@ Assert.isTrue(isQuickFixableStateSet()); return fIsQuickFixable; } + + /* + * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#isPromotedWarning() + * @since 3.6 + */ + public boolean isPromotedWarning() { + return fIsPromotedWarning; + } } /** Index: ui/org/eclipse/jdt/internal/ui/javaeditor/IJavaAnnotation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/IJavaAnnotation.java,v retrieving revision 1.16 diff -u -r1.16 IJavaAnnotation.java --- ui/org/eclipse/jdt/internal/ui/javaeditor/IJavaAnnotation.java 30 Jul 2009 12:23:04 -0000 1.16 +++ ui/org/eclipse/jdt/internal/ui/javaeditor/IJavaAnnotation.java 19 Nov 2009 06:43:05 -0000 @@ -105,6 +105,16 @@ boolean isProblem(); /** + * Tells whether this annotation is a problem annotation, specifically an + * error that was promoted up from a warning by the + * "Promote all warnings to errors" option. If this returns true, then + * {@link #isProblem()} is guaranteed to also return true. + * + * @return true if it is an error that was promoted up from a warning + */ + boolean isPromotedWarning(); + + /** * Returns the compilation unit corresponding to the document on which the annotation. * * @return the compilation unit or null if no corresponding compilation unit exists Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMarkerAnnotation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMarkerAnnotation.java,v retrieving revision 1.57 diff -u -r1.57 JavaMarkerAnnotation.java --- ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMarkerAnnotation.java 31 Dec 2008 21:13:20 -0000 1.57 +++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaMarkerAnnotation.java 19 Nov 2009 06:43:05 -0000 @@ -102,6 +102,17 @@ return WARNING_ANNOTATION_TYPE.equals(type) || ERROR_ANNOTATION_TYPE.equals(type); } + /* + * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#isPromotedWarning() + */ + public boolean isPromotedWarning() { + IMarker marker = getMarker(); + if (marker != null && marker.exists()) { + return marker.getAttribute(IJavaModelMarker.PROMOTED_WARNING, false); + } + return false; + } + /** * Overlays this annotation with the given javaAnnotation. * Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java,v retrieving revision 1.123 diff -u -r1.123 PreferencesMessages.java --- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 17 Nov 2009 07:50:05 -0000 1.123 +++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 19 Nov 2009 06:43:05 -0000 @@ -276,6 +276,7 @@ public static String ProblemSeveritiesConfigurationBlock_pb_redundant_null_check; public static String ProblemSeveritiesConfigurationBlock_pb_redundant_super_interface_label; public static String ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal; + public static String ProblemSeveritiesConfigurationBlock_promote_warnings_to_errors; public static String SourceAttachmentPropertyPage_error_title; public static String SourceAttachmentPropertyPage_error_message; public static String SourceAttachmentPropertyPage_invalid_container; Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties,v retrieving revision 1.496 diff -u -r1.496 PreferencesMessages.properties --- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 18 Nov 2009 09:53:20 -0000 1.496 +++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 19 Nov 2009 06:43:06 -0000 @@ -352,6 +352,7 @@ JavaBuildConfigurationBlock_needsbuild_title=Building Settings Changed JavaBuildConfigurationBlock_needsfullbuild_message=The Building settings have changed. A full rebuild is required for changes to take effect. Do the full build now? ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal=Treat errors like &fatal compiler errors (make compiled code not executable) +ProblemSeveritiesConfigurationBlock_promote_warnings_to_errors=Promote all warnings to errors JavaBuildConfigurationBlock_needsprojectbuild_message=The Building settings have changed. A rebuild of the project is required for changes to take effect. Build the project now? 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/') Index: ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java,v retrieving revision 1.56 diff -u -r1.56 ProblemSeveritiesConfigurationBlock.java --- ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java 23 Sep 2009 08:54:18 -0000 1.56 +++ ui/org/eclipse/jdt/internal/ui/preferences/ProblemSeveritiesConfigurationBlock.java 19 Nov 2009 06:43:06 -0000 @@ -105,6 +105,7 @@ private static final Key PREF_PB_SUPPRESS_WARNINGS= getJDTCoreKey(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS); private static final Key PREF_PB_UNHANDLED_WARNING_TOKEN= getJDTCoreKey(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN); private static final Key PREF_PB_FATAL_OPTIONAL_ERROR= getJDTCoreKey(JavaCore.COMPILER_PB_FATAL_OPTIONAL_ERROR); + private static final Key PREF_PB_PROMOTE_WARNINGS_TO_ERRS = getJDTCoreKey(JavaCore.COMPILER_PB_PROMOTE_WARNINGS_TO_ERRS); private static final Key PREF_PB_MISSING_HASHCODE_METHOD= getJDTCoreKey(JavaCore.COMPILER_PB_MISSING_HASHCODE_METHOD); private static final Key PREF_PB_DEAD_CODE= getJDTCoreKey(JavaCore.COMPILER_PB_DEAD_CODE); @@ -154,7 +155,7 @@ PREF_15_PB_AUTOBOXING_PROBLEM, PREF_15_PB_MISSING_OVERRIDE_ANNOTATION, PREF_16_PB_MISSING_OVERRIDE_ANNOTATION_FOR_INTERFACE_METHOD_IMPLEMENTATION, PREF_15_PB_ANNOTATION_SUPER_INTERFACE, PREF_15_PB_TYPE_PARAMETER_HIDING, PREF_15_PB_INCOMPLETE_ENUM_SWITCH, PREF_PB_MISSING_DEPRECATED_ANNOTATION, - PREF_15_PB_RAW_TYPE_REFERENCE, PREF_PB_FATAL_OPTIONAL_ERROR, + PREF_15_PB_RAW_TYPE_REFERENCE, PREF_PB_FATAL_OPTIONAL_ERROR, PREF_PB_PROMOTE_WARNINGS_TO_ERRS, PREF_PB_FORBIDDEN_REFERENCE, PREF_PB_DISCOURRAGED_REFERENCE, PREF_PB_SUPPRESS_WARNINGS, PREF_PB_UNHANDLED_WARNING_TOKEN, PREF_PB_COMPARING_IDENTICAL, PREF_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD, PREF_PB_MISSING_HASHCODE_METHOD, PREF_PB_DEAD_CODE @@ -483,6 +484,9 @@ label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_treat_optional_as_fatal; addCheckBox(composite, label, PREF_PB_FATAL_OPTIONAL_ERROR, enableDisableValues, 0); + label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_promote_warnings_to_errors; + addCheckBox(composite, label, PREF_PB_PROMOTE_WARNINGS_TO_ERRS, enableDisableValues, 0); + IDialogSettings section= JavaPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME); restoreSectionExpansionStates(section); Index: ui/org/eclipse/jdt/internal/ui/text/correction/ProblemLocation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ProblemLocation.java,v retrieving revision 1.16 diff -u -r1.16 ProblemLocation.java --- ui/org/eclipse/jdt/internal/ui/text/correction/ProblemLocation.java 14 Sep 2009 10:37:42 -0000 1.16 +++ ui/org/eclipse/jdt/internal/ui/text/correction/ProblemLocation.java 19 Nov 2009 06:43:07 -0000 @@ -33,6 +33,7 @@ private final int fLength; private final boolean fIsError; private final String fMarkerType; + private boolean fIsPromotedWarning; public ProblemLocation(int offset, int length, IJavaAnnotation annotation) { fId= annotation.getId(); @@ -40,7 +41,7 @@ fOffset= offset; fLength= length; fIsError= JavaMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType()); - + fIsPromotedWarning = annotation.isPromotedWarning(); String markerType= annotation.getMarkerType(); fMarkerType= markerType != null ? markerType : IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER; } @@ -98,6 +99,13 @@ public boolean isError() { return fIsError; } + + /* (non-Javadoc) + * @see org.eclipse.jdt.ui.text.java.IProblemLocation#isPromotedWarning() + */ + public boolean isPromotedWarning() { + return fIsPromotedWarning; + } /* (non-Javadoc) * @see org.eclipse.jdt.ui.text.java.IProblemLocation#getMarkerType() Index: ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java,v retrieving revision 1.14 diff -u -r1.14 SuppressWarningsSubProcessor.java --- ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java 24 Sep 2009 14:39:30 -0000 1.14 +++ ui/org/eclipse/jdt/internal/ui/text/correction/SuppressWarningsSubProcessor.java 19 Nov 2009 06:43:07 -0000 @@ -84,7 +84,8 @@ public static void addSuppressWarningsProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) { - if (problem.isError()) { + // @SuppressWarings is available only to warnings, and errors that were promoted up to warnings + if (problem.isError() && !problem.isPromotedWarning()) { return; } if (JavaCore.DISABLED.equals(context.getCompilationUnit().getJavaProject().getOption(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS, true))) { Index: ui/org/eclipse/jdt/internal/ui/text/spelling/CoreSpellingProblem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/CoreSpellingProblem.java,v retrieving revision 1.9 diff -u -r1.9 CoreSpellingProblem.java --- ui/org/eclipse/jdt/internal/ui/text/spelling/CoreSpellingProblem.java 11 Sep 2008 11:59:52 -0000 1.9 +++ ui/org/eclipse/jdt/internal/ui/text/spelling/CoreSpellingProblem.java 19 Nov 2009 06:43:07 -0000 @@ -155,6 +155,13 @@ public boolean isWarning() { return true; } + + /* + * @see org.eclipse.jdt.core.compiler.IProblem#isPromotedWarning() + */ + public boolean isPromotedWarning() { + return false; + } /* * @see org.eclipse.jdt.core.compiler.IProblem#setSourceStart(int) Index: ui/org/eclipse/jdt/ui/text/java/IProblemLocation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/IProblemLocation.java,v retrieving revision 1.14 diff -u -r1.14 IProblemLocation.java --- ui/org/eclipse/jdt/ui/text/java/IProblemLocation.java 18 Nov 2008 19:36:21 -0000 1.14 +++ ui/org/eclipse/jdt/ui/text/java/IProblemLocation.java 19 Nov 2009 06:43:07 -0000 @@ -73,6 +73,14 @@ boolean isError(); /** + * Returns if the problem is an error that was promoted up from a warning by the + * "Promote all warnings to errors" option + * + * @return true is the problem is an error that was promoted up from a warning + */ + boolean isPromotedWarning(); + + /** * Convenience method to evaluate the AST node covering this problem. * * @param astRoot The root node of the current AST