Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 160128 Details for
Bug 295551
Add option to automatically promote all warnings to errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch - core part
bug_295551_patch1.txt (text/plain), 15.57 KB, created by
Stephan Herrmann
on 2010-02-24 16:56:09 EST
(
hide
)
Description:
Proposed patch - core part
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2010-02-24 16:56:09 EST
Size:
15.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v >retrieving revision 1.350 >diff -u -r1.350 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 21 Feb 2010 03:35:51 -0000 1.350 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 24 Feb 2010 21:48:45 -0000 >@@ -11,6 +11,7 @@ > * Tom Tromey - Contribution for bug 159641 > * Benjamin Muskalla - Contribution for bug 239066 > * Stephan Herrmann - Contribution for bug 236385 >+ * Stephan Herrmann - Contribution for bug 295551 > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.batch; > >@@ -3339,9 +3340,14 @@ > setSeverity(CompilerOptions.OPTION_ReportMissingSerialVersion, severity, isEnabling); > return; > } else if (token.equals("suppress")) {//$NON-NLS-1$ >- this.options.put( >- CompilerOptions.OPTION_SuppressWarnings, >- isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED); >+ if (severity == ProblemSeverities.Warning || isEnabling) >+ this.options.put( >+ CompilerOptions.OPTION_SuppressWarnings, >+ isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED); >+ if (severity == ProblemSeverities.Error || !isEnabling) >+ this.options.put( >+ CompilerOptions.OPTION_SuppressOptionalErrors, >+ isEnabling ? CompilerOptions.ENABLED : CompilerOptions.DISABLED); > return; > } else if (token.equals("static-access")) { //$NON-NLS-1$ > setSeverity(CompilerOptions.OPTION_ReportNonStaticAccessToStatic, severity, isEnabling); >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 24 Feb 2010 21:48:46 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann - Contribution for bug 295551 > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -217,7 +218,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() && !options.suppressOptionalErrors) { > 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.229 >diff -u -r1.229 CompilerOptions.java >--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 13 Jan 2010 15:13:44 -0000 1.229 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 24 Feb 2010 21:48:50 -0000 >@@ -9,6 +9,7 @@ > * IBM Corporation - initial API and implementation > * Benjamin Muskalla - Contribution for bug 239066 > * Stephan Herrmann - Contribution for bug 236385 >+ * Stephan Herrmann - Contribution for bug 295551 > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.impl; > >@@ -112,6 +113,7 @@ > public static final String OPTION_ReportForbiddenReference = "org.eclipse.jdt.core.compiler.problem.forbiddenReference"; //$NON-NLS-1$ > public static final String OPTION_ReportDiscouragedReference = "org.eclipse.jdt.core.compiler.problem.discouragedReference"; //$NON-NLS-1$ > public static final String OPTION_SuppressWarnings = "org.eclipse.jdt.core.compiler.problem.suppressWarnings"; //$NON-NLS-1$ >+ public static final String OPTION_SuppressOptionalErrors = "org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors"; //$NON-NLS-1$ > public static final String OPTION_ReportUnhandledWarningToken = "org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"; //$NON-NLS-1$ > 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$ >@@ -320,8 +322,10 @@ > public boolean reportMissingJavadocCommentsOverriding; > /** Indicate whether the JSR bytecode should be inlined to avoid its presence in classfile */ > public boolean inlineJsrBytecode; >- /** Indicate if @SuppressWarning annotation are activated */ >+ /** Indicate if @SuppressWarning annotations are activated */ > public boolean suppressWarnings; >+ /** Indicate if @SuppressWarning annotations should also suppress optional errors */ >+ public boolean suppressOptionalErrors; > /** Specify if should treat optional error as fatal or just like warning */ > public boolean treatOptionalErrorAsFatal; > /** Specify if parser should perform structural recovery in methods */ >@@ -884,6 +888,7 @@ > optionsMap.put(OPTION_ReportPotentialNullReference, getSeverityString(PotentialNullReference)); > optionsMap.put(OPTION_ReportRedundantNullCheck, getSeverityString(RedundantNullCheck)); > optionsMap.put(OPTION_SuppressWarnings, this.suppressWarnings ? ENABLED : DISABLED); >+ optionsMap.put(OPTION_SuppressOptionalErrors, this.suppressOptionalErrors ? ENABLED : DISABLED); > optionsMap.put(OPTION_ReportUnhandledWarningToken, getSeverityString(UnhandledWarningToken)); > optionsMap.put(OPTION_ReportUnusedWarningToken, getSeverityString(UnusedWarningToken)); > optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment)); >@@ -1014,6 +1019,9 @@ > // suppress warning annotation > this.suppressWarnings = true; > >+ // suppress also optional errors >+ this.suppressOptionalErrors = false; >+ > // treat optional error as non fatal > this.treatOptionalErrorAsFatal = false; > >@@ -1225,6 +1233,13 @@ > this.suppressWarnings = false; > } > } >+ if ((optionValue = optionsMap.get(OPTION_SuppressOptionalErrors)) != null) { >+ if (ENABLED.equals(optionValue)) { >+ this.suppressOptionalErrors = true; >+ } else if (DISABLED.equals(optionValue)) { >+ this.suppressOptionalErrors = false; >+ } >+ } > if ((optionValue = optionsMap.get(OPTION_FatalOptionalError)) != null) { > if (ENABLED.equals(optionValue)) { > this.treatOptionalErrorAsFatal = true; >@@ -1482,6 +1497,7 @@ > buf.append("\n\t- missing @Deprecated annotation: ").append(getSeverityString(MissingDeprecatedAnnotation)); //$NON-NLS-1$ > buf.append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); //$NON-NLS-1$ > buf.append("\n\t- suppress warnings: ").append(this.suppressWarnings ? ENABLED : DISABLED); //$NON-NLS-1$ >+ buf.append("\n\t- suppress optional errors: ").append(this.suppressOptionalErrors ? ENABLED : DISABLED); //$NON-NLS-1$ > buf.append("\n\t- unhandled warning token: ").append(getSeverityString(UnhandledWarningToken)); //$NON-NLS-1$ > 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$ >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.647 >diff -u -r1.647 JavaCore.java >--- model/org/eclipse/jdt/core/JavaCore.java 13 Jan 2010 15:13:42 -0000 1.647 >+++ model/org/eclipse/jdt/core/JavaCore.java 24 Feb 2010 21:49:02 -0000 >@@ -82,6 +82,7 @@ > * IBM Corporation - added getOptionForConfigurableSeverity(int) > * Benjamin Muskalla - added COMPILER_PB_MISSING_SYNCHRONIZED_ON_INHERITED_METHOD > * Stephan Herrmann - added COMPILER_PB_UNUSED_OBJECT_ALLOCATION >+ * Stephan Herrmann - added COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS > *******************************************************************************/ > > package org.eclipse.jdt.core; >@@ -1420,6 +1421,21 @@ > */ > public static final String COMPILER_PB_SUPPRESS_WARNINGS = PLUGIN_ID + ".compiler.problem.suppressWarnings"; //$NON-NLS-1$ > /** >+ * Compiler option ID: Further Determining the Effect of <code>@SuppressWarnings</code> if also >+ * <code>COMPILER_PB_SUPPRESS_WARNINGS</code> is enabled. >+ * <p>When enabled, the <code>@SuppressWarnings</code> annotation can additionally be used to suppress >+ * optional compiler diagnostics that have been configured as <code>ERROR</code>. >+ * <p>When disabled, all <code>@SupressWarnings</code> annotations only affects warnings. >+ * <dl> >+ * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors"</code></dd> >+ * <dt>Possible values:</dt><dd><code>{ "enabled", "disabled" }</code></dd> >+ * <dt>Default:</dt><dd><code>"disabled"</code></dd> >+ * </dl> >+ * @since 3.6 >+ * @category CompilerOptionID >+ */ >+ public static final String COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS = PLUGIN_ID + ".compiler.problem.suppressOptionalErrors"; //$NON-NLS-1$ >+ /** > * Compiler option ID: Reporting Unhandled Warning Token for <code>@SuppressWarnings</code>. > * <p>When enabled, the compiler will issue an error or a warning when encountering a token > * it cannot handle inside a <code>@SuppressWarnings</code> annotation. >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.210 >diff -u -r1.210 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 5 Feb 2010 09:03:34 -0000 1.210 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 24 Feb 2010 21:49:16 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann - Contribution for bug 295551 > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -9304,4 +9305,102 @@ > expectedOutput, > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551 >+public void test280() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ String testFiles [] = new String[] { >+ "A.java", >+ "public class A {\n" + >+ " @SuppressWarnings(\"unused\")\n" + >+ " private int i;\n" + // problem configured as warning but still suppressed >+ "}\n" >+ }; >+ runConformTest( >+ testFiles, >+ null, >+ null, >+ true, >+ null, >+ customOptions, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551 >+public void test281() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED); // this option overrides the next >+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ String testFiles [] = new String[] { >+ "A.java", >+ "public class A {\n" + >+ " @SuppressWarnings(\"unused\")\n" + >+ " private int i;\n" + >+ "}\n" >+ }; >+ String expectedErrorString = >+ "----------\n" + >+ "1. ERROR in A.java (at line 3)\n" + >+ " private int i;\n" + >+ " ^\n" + >+ "The field A.i is never read locally\n" + >+ "----------\n"; >+ runNegativeTest( >+ true, >+ testFiles, >+ null, >+ customOptions, >+ expectedErrorString, >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551 >+public void test282() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ String testFiles [] = new String[] { >+ "A.java", >+ "import java.util.Map;\n" + >+ "public class A {\n" + >+ " @SuppressWarnings({\"rawtypes\", \"unused\"})\n" + //suppress a warning and an error >+ " private Map i;\n" + >+ "}\n" >+ }; >+ runConformTest( >+ testFiles, >+ null, >+ null, >+ true, >+ null, >+ customOptions, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=295551 >+public void test283() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.ERROR); >+ customOptions.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ String testFiles [] = new String[] { >+ "A.java", >+ "public class A {\n" + >+ " @SuppressWarnings(\"all\")\n" + >+ " private void i;\n" + // cannot suppress mandatory error >+ "}\n" >+ }; >+ String expectedErrorString = >+ "----------\n" + >+ "1. ERROR in A.java (at line 3)\n" + >+ " private void i;\n" + >+ " ^\n" + >+ "void is an invalid type for the variable i\n" + >+ "----------\n"; >+ runNegativeTest( >+ true, >+ testFiles, >+ null, >+ customOptions, >+ expectedErrorString, >+ JavacTestOptions.SKIP); >+} > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v >retrieving revision 1.202 >diff -u -r1.202 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 13 Jan 2010 15:13:36 -0000 1.202 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 24 Feb 2010 21:49:32 -0000 >@@ -9,6 +9,7 @@ > * IBM Corporation - initial API and implementation > * Benjamin Muskalla - Contribution for bug 239066 > * Stephan Herrmann - Contribution for bug 236385 >+ * Stephan Herrmann - Contribution for bug 295551 > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -1843,6 +1844,7 @@ > " <option key=\"org.eclipse.jdt.core.compiler.problem.redundantSuperinterface\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\n" + >+ " <option key=\"org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors\" value=\"disabled\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.suppressWarnings\" value=\"enabled\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation\" value=\"ignore\"/>\n" + > " <option key=\"org.eclipse.jdt.core.compiler.problem.tasks\" value=\"warning\"/>\n" +
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
Olivier_Thomann
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 295551
:
152561
|
152562
|
153402
| 160128 |
160217
|
160223