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 111495 Details for
Bug 245973
[compiler] Problem irritant cannot exceed 64bit limit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
245973.txt (text/plain), 101.49 KB, created by
Philipe Mulet
on 2008-09-02 12:08:24 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2008-09-02 12:08:24 EDT
Size:
101.49 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java,v >retrieving revision 1.68 >diff -u -r1.68 Util.java >--- src/org/eclipse/jdt/core/tests/util/Util.java 28 Aug 2008 18:53:46 -0000 1.68 >+++ src/org/eclipse/jdt/core/tests/util/Util.java 2 Sep 2008 16:01:40 -0000 >@@ -1321,7 +1321,7 @@ > } > } > if (showWarningToken) { >- long irritant = ProblemReporter.getIrritant(problem.getID()); >+ int irritant = ProblemReporter.getIrritant(problem.getID()); > if (irritant != 0) { > String warningToken = CompilerOptions.warningTokenFromIrritant(irritant); > if (warningToken != null) { >Index: src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java,v >retrieving revision 1.19 >diff -u -r1.19 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 26 Aug 2008 11:52:58 -0000 1.19 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 2 Sep 2008 16:01:40 -0000 >@@ -21,6 +21,7 @@ > import org.eclipse.jdt.internal.compiler.CompilationResult; > import org.eclipse.jdt.internal.compiler.ICompilerRequestor; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >+import org.eclipse.jdt.internal.compiler.impl.IrritantSet; > import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; > import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; > import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; >@@ -60,14 +61,15 @@ > > // irritant vs warning token - check To/From symmetry > public void test001_irritant_warning_token() { >- String [] tokens = new String[64]; > Map matcher = new HashMap(); >- long irritant; >- String token; >- for (int i = 0; i < 64; i++) { >- if ((token = tokens[i] = CompilerOptions.warningTokenFromIrritant(irritant = 1L << i)) != null) { >- matcher.put(token, token); >- assertTrue((irritant & CompilerOptions.warningTokenToIrritants(token)) != 0); >+ for (int group = 0; group < IrritantSet.GROUP_MAX; group++) { >+ for (int i = 0; i < 29; i++) { >+ int irritant = (group << IrritantSet.GROUP_SHIFT) + (1 << i); >+ String token = CompilerOptions.warningTokenFromIrritant(irritant); >+ if (token != null) { >+ matcher.put(token, token); >+ assertTrue(CompilerOptions.warningTokenToIrritants(token) != null); >+ } > } > } > String [] allTokens = CompilerOptions.warningTokens; >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/core/CorrectionEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java,v >retrieving revision 1.54 >diff -u -r1.54 CorrectionEngine.java >--- model/org/eclipse/jdt/core/CorrectionEngine.java 27 Jun 2008 16:04:01 -0000 1.54 >+++ model/org/eclipse/jdt/core/CorrectionEngine.java 2 Sep 2008 16:01:47 -0000 >@@ -460,7 +460,7 @@ > * @since 3.1 > */ > public static String getWarningToken(int problemID){ >- long irritant = ProblemReporter.getIrritant(problemID); >+ int irritant = ProblemReporter.getIrritant(problemID); > if (irritant != 0) { > return CompilerOptions.warningTokenFromIrritant(irritant); > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java,v >retrieving revision 1.64 >diff -u -r1.64 Annotation.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 27 Jun 2008 16:03:54 -0000 1.64 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java 2 Sep 2008 16:01:45 -0000 >@@ -15,6 +15,7 @@ > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.impl.Constant; >+import org.eclipse.jdt.internal.compiler.impl.IrritantSet; > import org.eclipse.jdt.internal.compiler.lookup.*; > > /** >@@ -177,7 +178,7 @@ > } > > public void recordSuppressWarnings(Scope scope, int startSuppresss, int endSuppress, boolean isSuppressingWarnings) { >- long suppressWarningIrritants = 0; >+ IrritantSet suppressWarningIrritants = null; > MemberValuePair[] pairs = memberValuePairs(); > pairLoop: for (int i = 0, length = pairs.length; i < length; i++) { > MemberValuePair pair = pairs[i]; >@@ -190,12 +191,12 @@ > for (int j = 0, initsLength = inits.length; j < initsLength; j++) { > Constant cst = inits[j].constant; > if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) { >- long irritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); >- if (irritants != 0) { >- if ((suppressWarningIrritants & irritants) == irritants) { >- scope.problemReporter().unusedWarningToken(inits[j]); >- } else { >- suppressWarningIrritants |= irritants; >+ IrritantSet irritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); >+ if (irritants != null) { >+ if (suppressWarningIrritants == null) { >+ suppressWarningIrritants = new IrritantSet(irritants); >+ } else if (suppressWarningIrritants.set(irritants) == null) { >+ scope.problemReporter().unusedWarningToken(inits[j]); > } > } else { > scope.problemReporter().unhandledWarningToken(inits[j]); >@@ -206,9 +207,10 @@ > } else { > Constant cst = value.constant; > if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) { >- long irritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); >- if (irritants != 0) { >- suppressWarningIrritants |= irritants; >+ IrritantSet irritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); >+ if (irritants != null) { >+ suppressWarningIrritants = new IrritantSet(irritants); >+ // TODO: should check for unused warning token against enclosing annotation as well ? > } else { > scope.problemReporter().unhandledWarningToken(value); > } >@@ -217,7 +219,7 @@ > break pairLoop; > } > } >- if (isSuppressingWarnings && suppressWarningIrritants != 0) { >+ if (isSuppressingWarnings && suppressWarningIrritants != null) { > scope.referenceCompilationUnit().recordSuppressWarnings(suppressWarningIrritants, this, startSuppresss, endSuppress); > } > } >@@ -307,7 +309,7 @@ > long tagBits = detectStandardAnnotation(scope, annotationType, valueAttribute); > > // record annotation positions in the compilation result >- scope.referenceCompilationUnit().recordSuppressWarnings(CompilerOptions.NonExternalizedString, null, this.sourceStart, this.declarationSourceEnd); >+ scope.referenceCompilationUnit().recordSuppressWarnings(IrritantSet.NLS, null, this.sourceStart, this.declarationSourceEnd); > if (this.recipient != null) { > if (tagBits != 0) { > // tag bits onto recipient >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.80 >diff -u -r1.80 CompilationUnitDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 27 Jun 2008 16:03:55 -0000 1.80 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java 2 Sep 2008 16:01:45 -0000 >@@ -21,6 +21,7 @@ > import org.eclipse.jdt.internal.compiler.CompilationResult; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.impl.Constant; >+import org.eclipse.jdt.internal.compiler.impl.IrritantSet; > import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; > import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; > import org.eclipse.jdt.internal.compiler.lookup.ImportBinding; >@@ -72,7 +73,7 @@ > private int stringLiteralsPtr; > private HashSetOfInt stringLiteralsStart; > >- long[] suppressWarningIrritants; // irritant for suppressed warnings >+ IrritantSet[] suppressWarningIrritants; // irritant for suppressed warnings > Annotation[] suppressWarningAnnotations; > long[] suppressWarningScopePositions; // (start << 32) + end > int suppressWarningsCount; >@@ -210,7 +211,7 @@ > int removed = 0; > CategorizedProblem[] problems = this.compilationResult.problems; > int problemCount = this.compilationResult.problemCount; >- long[] foundIrritants = new long[this.suppressWarningsCount]; >+ IrritantSet[] foundIrritants = new IrritantSet[this.suppressWarningsCount]; > CompilerOptions options = this.scope.compilerOptions(); > boolean hasErrors = false; > nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) { >@@ -225,21 +226,25 @@ > } > int start = problem.getSourceStart(); > int end = problem.getSourceEnd(); >- long irritant = ProblemReporter.getIrritant(problemID); >+ int irritant = ProblemReporter.getIrritant(problemID); > nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) { > long position = this.suppressWarningScopePositions[iSuppress]; > int startSuppress = (int) (position >>> 32); > int endSuppress = (int) position; > if (start < startSuppress) continue nextSuppress; > if (end > endSuppress) continue nextSuppress; >- if ((irritant & this.suppressWarningIrritants[iSuppress]) == 0) >+ if (!this.suppressWarningIrritants[iSuppress].isSet(irritant)) > continue nextSuppress; > // discard suppressed warning > removed++; > problems[iProblem] = null; > if (this.compilationResult.problemsMap != null) this.compilationResult.problemsMap.remove(problem); > if (this.compilationResult.firstErrors != null) this.compilationResult.firstErrors.remove(problem); >- foundIrritants[iSuppress] |= irritant; >+ if (foundIrritants[iSuppress] == null){ >+ foundIrritants[iSuppress] = new IrritantSet(irritant); >+ } else { >+ foundIrritants[iSuppress].set(irritant); >+ } > continue nextProblem; > } > } >@@ -265,8 +270,8 @@ > for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) { > Annotation annotation = this.suppressWarningAnnotations[iSuppress]; > if (annotation == null) continue; // implicit annotation >- long irritants = this.suppressWarningIrritants[iSuppress]; >- if (unusedWarningTokenIsWarning && ~irritants == 0) continue; // @SuppressWarnings("all") also suppresses unused warning token >+ IrritantSet irritants = this.suppressWarningIrritants[iSuppress]; >+ if (unusedWarningTokenIsWarning && irritants.areAllSet()) continue; // @SuppressWarnings("all") also suppresses unused warning token > if (irritants != foundIrritants[iSuppress]) { // mismatch, some warning tokens were unused > MemberValuePair[] pairs = annotation.memberValuePairs(); > pairLoop: for (int iPair = 0, pairCount = pairs.length; iPair < pairCount; iPair++) { >@@ -280,11 +285,11 @@ > for (int iToken = 0, tokenCount = inits.length; iToken < tokenCount; iToken++) { > Constant cst = inits[iToken].constant; > if (cst != Constant.NotAConstant && cst.typeID() == TypeIds.T_JavaLangString) { >- long tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); >- if (tokenIrritants != 0 >- && ~tokenIrritants != 0 // no complaint against @SuppressWarnings("all") >- && options.getSeverity(tokenIrritants) != ProblemSeverities.Ignore // if irritant is effectevely enabled >- && (foundIrritants[iSuppress] & tokenIrritants) == 0) { // if irritant had no matching problem >+ IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); >+ if (tokenIrritants != null >+ && !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all") >+ && options.isAnyEnabled(tokenIrritants) // if irritant is effectevely enabled >+ && (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem > if (unusedWarningTokenIsWarning) { > int start = value.sourceStart, end = value.sourceEnd; > nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) { >@@ -293,7 +298,7 @@ > int endSuppress = (int) position; > if (start < startSuppress) continue nextSuppress; > if (end > endSuppress) continue nextSuppress; >- if (~this.suppressWarningIrritants[jSuppress] == 0) break pairLoop; // suppress all? >+ if (this.suppressWarningIrritants[jSuppress].areAllSet()) break pairLoop; // suppress all? > } > } > this.scope.problemReporter().unusedWarningToken(inits[iToken]); >@@ -304,11 +309,11 @@ > } else { > Constant cst = value.constant; > if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) { >- long tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); >- if (tokenIrritants != 0 >- && ~tokenIrritants != 0 // no complaint against @SuppressWarnings("all") >- && options.getSeverity(tokenIrritants) != ProblemSeverities.Ignore // if irritant is effectevely enabled >- && (foundIrritants[iSuppress] & tokenIrritants) == 0) { // if irritant had no matching problem >+ IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue()); >+ if (tokenIrritants != null >+ && !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all") >+ && options.isAnyEnabled(tokenIrritants) // if irritant is effectevely enabled >+ && (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem > if (unusedWarningTokenIsWarning) { > int start = value.sourceStart, end = value.sourceEnd; > nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) { >@@ -317,7 +322,7 @@ > int endSuppress = (int) position; > if (start < startSuppress) continue nextSuppress; > if (end > endSuppress) continue nextSuppress; >- if (~this.suppressWarningIrritants[jSuppress] == 0) break pairLoop; // suppress all? >+ if (this.suppressWarningIrritants[jSuppress].areAllSet()) break pairLoop; // suppress all? > } > } > this.scope.problemReporter().unusedWarningToken(value); >@@ -468,17 +473,17 @@ > this.stringLiterals[this.stringLiteralsPtr++] = literal; > } > >- public void recordSuppressWarnings(long irritant, Annotation annotation, int scopeStart, int scopeEnd) { >+ public void recordSuppressWarnings(IrritantSet irritants, Annotation annotation, int scopeStart, int scopeEnd) { > if (this.suppressWarningIrritants == null) { >- this.suppressWarningIrritants = new long[3]; >+ this.suppressWarningIrritants = new IrritantSet[3]; > this.suppressWarningAnnotations = new Annotation[3]; > this.suppressWarningScopePositions = new long[3]; > } else if (this.suppressWarningIrritants.length == this.suppressWarningsCount) { >- System.arraycopy(this.suppressWarningIrritants, 0,this.suppressWarningIrritants = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount); >+ System.arraycopy(this.suppressWarningIrritants, 0,this.suppressWarningIrritants = new IrritantSet[2*this.suppressWarningsCount], 0, this.suppressWarningsCount); > System.arraycopy(this.suppressWarningAnnotations, 0,this.suppressWarningAnnotations = new Annotation[2*this.suppressWarningsCount], 0, this.suppressWarningsCount); > System.arraycopy(this.suppressWarningScopePositions, 0,this.suppressWarningScopePositions = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount); > } >- this.suppressWarningIrritants[this.suppressWarningsCount] = irritant; >+ this.suppressWarningIrritants[this.suppressWarningsCount] = irritants; > this.suppressWarningAnnotations[this.suppressWarningsCount] = annotation; > this.suppressWarningScopePositions[this.suppressWarningsCount++] = ((long)scopeStart<<32) + scopeEnd; > } >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.331 >diff -u -r1.331 Main.java >--- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 26 Aug 2008 11:52:53 -0000 1.331 >+++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 2 Sep 2008 16:01:45 -0000 >@@ -381,7 +381,7 @@ > > // find out an option name controlling a given problemID > private String getProblemOptionKey(int problemID) { >- long irritant = ProblemReporter.getIrritant(problemID); >+ int irritant = ProblemReporter.getIrritant(problemID); > return CompilerOptions.optionKeyFromIrritant(irritant); > } > >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.375 >diff -u -r1.375 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 26 Aug 2008 11:52:53 -0000 1.375 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 2 Sep 2008 16:01:47 -0000 >@@ -45,7 +45,7 @@ > return leadProblemId << 8 | elaborationVariant; // leadProblemId comes into the higher order bytes > } > >-public static long getIrritant(int problemID) { >+public static int getIrritant(int problemID) { > switch(problemID){ > > case IProblem.MaskedCatch : >@@ -336,106 +336,87 @@ > // fatal problems even if optional are all falling into same category (not irritant based) > if ((severity & ProblemSeverities.Fatal) != 0) > break categorizeOnIrritant; >- long irritant = getIrritant(problemID); >- int irritantInt = (int) irritant; >- if (irritantInt == irritant) { >- switch (irritantInt) { >- case (int)CompilerOptions.MethodWithConstructorName: >- case (int)CompilerOptions.AccessEmulation: >- case (int)CompilerOptions.AssertUsedAsAnIdentifier: >- case (int)CompilerOptions.NonStaticAccessToStatic: >- case (int)CompilerOptions.UnqualifiedFieldAccess: >- case (int)CompilerOptions.UndocumentedEmptyBlock: >- case (int)CompilerOptions.IndirectStaticAccess: >- return CategorizedProblem.CAT_CODE_STYLE; >- >- case (int)CompilerOptions.MaskedCatchBlock: >- case (int)CompilerOptions.NoImplicitStringConversion: >- case (int)CompilerOptions.NoEffectAssignment: >- case (int)CompilerOptions.AccidentalBooleanAssign: >- case (int)CompilerOptions.EmptyStatement: >- case (int)CompilerOptions.FinallyBlockNotCompleting: >- return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM; >- >- case (int)CompilerOptions.OverriddenPackageDefaultMethod: >- case (int)CompilerOptions.IncompatibleNonInheritedInterfaceMethod: >- case (int)CompilerOptions.LocalVariableHiding: >- case (int)CompilerOptions.FieldHiding: >- return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT; >- >- case (int)CompilerOptions.UnusedLocalVariable: >- case (int)CompilerOptions.UnusedArgument: >- case (int)CompilerOptions.UnusedImport: >- case (int)CompilerOptions.UnusedPrivateMember: >- case (int)CompilerOptions.UnusedDeclaredThrownException: >- case (int)CompilerOptions.UnnecessaryTypeCheck: >- case (int)CompilerOptions.UnnecessaryElse: >- return CategorizedProblem.CAT_UNNECESSARY_CODE; >- >- case (int)CompilerOptions.UsingDeprecatedAPI: >- return CategorizedProblem.CAT_DEPRECATION; >- >- case (int)CompilerOptions.NonExternalizedString: >- return CategorizedProblem.CAT_NLS; >- >- case (int)CompilerOptions.Task: >- return CategorizedProblem.CAT_UNSPECIFIED; // TODO may want to improve >- >- case (int)CompilerOptions.MissingJavadocComments: >- case (int)CompilerOptions.MissingJavadocTags: >- case (int)CompilerOptions.InvalidJavadoc: >- case (int)(CompilerOptions.InvalidJavadoc | CompilerOptions.UsingDeprecatedAPI): >- return CategorizedProblem.CAT_JAVADOC; >- >- case (int)CompilerOptions.UncheckedTypeOperation: >- return CategorizedProblem.CAT_UNCHECKED_RAW; >+ int irritant = getIrritant(problemID); >+ switch (irritant) { >+ case CompilerOptions.MethodWithConstructorName : >+ case CompilerOptions.AccessEmulation : >+ case CompilerOptions.AssertUsedAsAnIdentifier : >+ case CompilerOptions.NonStaticAccessToStatic : >+ case CompilerOptions.UnqualifiedFieldAccess : >+ case CompilerOptions.UndocumentedEmptyBlock : >+ case CompilerOptions.IndirectStaticAccess : >+ case CompilerOptions.FinalParameterBound : >+ case CompilerOptions.EnumUsedAsAnIdentifier : >+ case CompilerOptions.AnnotationSuperInterface : >+ case CompilerOptions.AutoBoxing : >+ case CompilerOptions.MissingOverrideAnnotation : >+ case CompilerOptions.MissingDeprecatedAnnotation : >+ case CompilerOptions.ParameterAssignment : >+ return CategorizedProblem.CAT_CODE_STYLE; >+ >+ case CompilerOptions.MaskedCatchBlock : >+ case CompilerOptions.NoImplicitStringConversion : >+ case CompilerOptions.NoEffectAssignment : >+ case CompilerOptions.AccidentalBooleanAssign : >+ case CompilerOptions.EmptyStatement : >+ case CompilerOptions.FinallyBlockNotCompleting : >+ case CompilerOptions.MissingSerialVersion : >+ case CompilerOptions.VarargsArgumentNeedCast : >+ case CompilerOptions.NullReference : >+ case CompilerOptions.PotentialNullReference : >+ case CompilerOptions.RedundantNullCheck : >+ case CompilerOptions.IncompleteEnumSwitch : >+ case CompilerOptions.FallthroughCase : >+ case CompilerOptions.OverridingMethodWithoutSuperInvocation : >+ case CompilerOptions.ComparingIdentical : >+ case CompilerOptions.MissingSynchronizedModifierInInheritedMethod : >+ return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM; >+ >+ case CompilerOptions.OverriddenPackageDefaultMethod : >+ case CompilerOptions.IncompatibleNonInheritedInterfaceMethod : >+ case CompilerOptions.LocalVariableHiding : >+ case CompilerOptions.FieldHiding : >+ case CompilerOptions.TypeHiding : >+ return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT; >+ >+ case CompilerOptions.UnusedLocalVariable : >+ case CompilerOptions.UnusedArgument : >+ case CompilerOptions.UnusedImport : >+ case CompilerOptions.UnusedPrivateMember : >+ case CompilerOptions.UnusedDeclaredThrownException : >+ case CompilerOptions.UnnecessaryTypeCheck : >+ case CompilerOptions.UnnecessaryElse : >+ case CompilerOptions.UnhandledWarningToken : >+ case CompilerOptions.UnusedWarningToken : >+ case CompilerOptions.UnusedLabel : >+ case CompilerOptions.RedundantSuperinterface : >+ return CategorizedProblem.CAT_UNNECESSARY_CODE; > >- default: >- break categorizeOnIrritant; >- } >- } else { >- irritantInt = (int)(irritant >>> 32); >- switch (irritantInt) { >- case (int)(CompilerOptions.FinalParameterBound >>> 32): >- case (int)(CompilerOptions.EnumUsedAsAnIdentifier >>> 32): >- case (int)(CompilerOptions.AnnotationSuperInterface >>> 32): >- case (int)(CompilerOptions.AutoBoxing >>> 32): >- case (int)(CompilerOptions.MissingOverrideAnnotation >>> 32): >- case (int)(CompilerOptions.MissingDeprecatedAnnotation >>> 32): >- case (int)(CompilerOptions.ParameterAssignment >>> 32): >- return CategorizedProblem.CAT_CODE_STYLE; >- >- case (int)(CompilerOptions.MissingSerialVersion >>> 32): >- case (int)(CompilerOptions.VarargsArgumentNeedCast >>> 32): >- case (int)(CompilerOptions.NullReference >>> 32): >- case (int)(CompilerOptions.PotentialNullReference >>> 32): >- case (int)(CompilerOptions.RedundantNullCheck >>> 32): >- case (int)(CompilerOptions.IncompleteEnumSwitch >>> 32): >- case (int)(CompilerOptions.FallthroughCase >>> 32): >- case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32): >- case (int)(CompilerOptions.ComparingIdentical >>> 32): >- case (int)(CompilerOptions.MissingSynchronizedModifierInInheritedMethod >> 32): >- return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM; >- >- case (int)(CompilerOptions.TypeHiding >>> 32): >- return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT; >- >- case (int)(CompilerOptions.UnhandledWarningToken >>> 32): >- case (int)(CompilerOptions.UnusedWarningToken >>> 32): >- case (int)(CompilerOptions.UnusedLabel >>> 32): >- case (int)(CompilerOptions.RedundantSuperinterface >>> 32): >- return CategorizedProblem.CAT_UNNECESSARY_CODE; >- >- case (int)(CompilerOptions.ForbiddenReference >>> 32): >- case (int)(CompilerOptions.DiscouragedReference >>> 32): >- return CategorizedProblem.CAT_RESTRICTION; >+ case CompilerOptions.UsingDeprecatedAPI : >+ return CategorizedProblem.CAT_DEPRECATION; > >- case (int)(CompilerOptions.RawTypeReference >>> 32): >- return CategorizedProblem.CAT_UNCHECKED_RAW; >+ case CompilerOptions.NonExternalizedString : >+ return CategorizedProblem.CAT_NLS; > >- default: >- break categorizeOnIrritant; >- } >+ case CompilerOptions.Task : >+ return CategorizedProblem.CAT_UNSPECIFIED; // TODO may want to improve >+ >+ case CompilerOptions.MissingJavadocComments : >+ case CompilerOptions.MissingJavadocTags : >+ case CompilerOptions.InvalidJavadoc : >+ case CompilerOptions.InvalidJavadoc|CompilerOptions.UsingDeprecatedAPI : >+ return CategorizedProblem.CAT_JAVADOC; >+ >+ case CompilerOptions.UncheckedTypeOperation : >+ case CompilerOptions.RawTypeReference : >+ return CategorizedProblem.CAT_UNCHECKED_RAW; >+ >+ case CompilerOptions.ForbiddenReference : >+ case CompilerOptions.DiscouragedReference : >+ return CategorizedProblem.CAT_RESTRICTION; >+ >+ default: >+ break categorizeOnIrritant; > } > } > // categorize fatal problems per ID >@@ -1163,7 +1144,7 @@ > } > break; > } >- long irritant = getIrritant(problemID); >+ int irritant = getIrritant(problemID); > if (irritant != 0) { > if ((problemID & IProblem.Javadoc) != 0 && !this.options.docCommentSupport) > return ProblemSeverities.Ignore; >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.206 >diff -u -r1.206 CompilerOptions.java >--- compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 26 Aug 2008 11:52:52 -0000 1.206 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java 2 Sep 2008 16:01:46 -0000 >@@ -159,198 +159,617 @@ > > /** > * Bit mask for configurable problems (error/warning threshold) >+ * Note: bitmask assumes 3 highest bits to denote irritant group (to allow storing 8 groups of 29 bits each > */ >- public static final long MethodWithConstructorName = ASTNode.Bit1; >- public static final long OverriddenPackageDefaultMethod = ASTNode.Bit2; >- public static final long UsingDeprecatedAPI = ASTNode.Bit3; >- public static final long MaskedCatchBlock = ASTNode.Bit4; >- public static final long UnusedLocalVariable = ASTNode.Bit5; >- public static final long UnusedArgument = ASTNode.Bit6; >- public static final long NoImplicitStringConversion = ASTNode.Bit7; >- public static final long AccessEmulation = ASTNode.Bit8; >- public static final long NonExternalizedString = ASTNode.Bit9; >- public static final long AssertUsedAsAnIdentifier = ASTNode.Bit10; >- public static final long UnusedImport = ASTNode.Bit11; >- public static final long NonStaticAccessToStatic = ASTNode.Bit12; >- public static final long Task = ASTNode.Bit13; >- public static final long NoEffectAssignment = ASTNode.Bit14; >- public static final long IncompatibleNonInheritedInterfaceMethod = ASTNode.Bit15; >- public static final long UnusedPrivateMember = ASTNode.Bit16; >- public static final long LocalVariableHiding = ASTNode.Bit17; >- public static final long FieldHiding = ASTNode.Bit18; >- public static final long AccidentalBooleanAssign = ASTNode.Bit19; >- public static final long EmptyStatement = ASTNode.Bit20; >- public static final long MissingJavadocComments = ASTNode.Bit21; >- public static final long MissingJavadocTags = ASTNode.Bit22; >- public static final long UnqualifiedFieldAccess = ASTNode.Bit23; >- public static final long UnusedDeclaredThrownException = ASTNode.Bit24; >- public static final long FinallyBlockNotCompleting = ASTNode.Bit25; >- public static final long InvalidJavadoc = ASTNode.Bit26; >- public static final long UnnecessaryTypeCheck = ASTNode.Bit27; >- public static final long UndocumentedEmptyBlock = ASTNode.Bit28; >- public static final long IndirectStaticAccess = ASTNode.Bit29; >- public static final long UnnecessaryElse = ASTNode.Bit30; >- public static final long UncheckedTypeOperation = ASTNode.Bit31; >- public static final long FinalParameterBound = ASTNode.Bit32L; >- public static final long MissingSerialVersion = ASTNode.Bit33L; >- public static final long EnumUsedAsAnIdentifier = ASTNode.Bit34L; >- public static final long ForbiddenReference = ASTNode.Bit35L; >- public static final long VarargsArgumentNeedCast = ASTNode.Bit36L; >- public static final long NullReference = ASTNode.Bit37L; >- public static final long AutoBoxing = ASTNode.Bit38L; >- public static final long AnnotationSuperInterface = ASTNode.Bit39L; >- public static final long TypeHiding = ASTNode.Bit40L; >- public static final long MissingOverrideAnnotation = ASTNode.Bit41L; >- public static final long IncompleteEnumSwitch = ASTNode.Bit42L; >- public static final long MissingDeprecatedAnnotation = ASTNode.Bit43L; >- public static final long DiscouragedReference = ASTNode.Bit44L; >- public static final long UnhandledWarningToken = ASTNode.Bit45L; >- public static final long RawTypeReference = ASTNode.Bit46L; >- public static final long UnusedLabel = ASTNode.Bit47L; >- public static final long ParameterAssignment = ASTNode.Bit48L; >- public static final long FallthroughCase = ASTNode.Bit49L; >- public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L; >- public static final long PotentialNullReference = ASTNode.Bit51L; >- public static final long RedundantNullCheck = ASTNode.Bit52L; >- public static final long MissingJavadocTagDescription = ASTNode.Bit53L; >- public static final long UnusedTypeArguments = ASTNode.Bit54L; >- public static final long UnusedWarningToken = ASTNode.Bit55L; >- public static final long RedundantSuperinterface = ASTNode.Bit56L; >- public static final long ComparingIdentical = ASTNode.Bit57L; >- public static final long MissingSynchronizedModifierInInheritedMethod= ASTNode.Bit58L; >- >+ // group 0 >+ public static final int MethodWithConstructorName = IrritantSet.GROUP0 | ASTNode.Bit1; >+ public static final int OverriddenPackageDefaultMethod = IrritantSet.GROUP0 | ASTNode.Bit2; >+ public static final int UsingDeprecatedAPI = IrritantSet.GROUP0 | ASTNode.Bit3; >+ public static final int MaskedCatchBlock = IrritantSet.GROUP0 | ASTNode.Bit4; >+ public static final int UnusedLocalVariable = IrritantSet.GROUP0 | ASTNode.Bit5; >+ public static final int UnusedArgument = IrritantSet.GROUP0 | ASTNode.Bit6; >+ public static final int NoImplicitStringConversion = IrritantSet.GROUP0 | ASTNode.Bit7; >+ public static final int AccessEmulation = IrritantSet.GROUP0 | ASTNode.Bit8; >+ public static final int NonExternalizedString = IrritantSet.GROUP0 | ASTNode.Bit9; >+ public static final int AssertUsedAsAnIdentifier = IrritantSet.GROUP0 | ASTNode.Bit10; >+ public static final int UnusedImport = IrritantSet.GROUP0 | ASTNode.Bit11; >+ public static final int NonStaticAccessToStatic = IrritantSet.GROUP0 | ASTNode.Bit12; >+ public static final int Task = IrritantSet.GROUP0 | ASTNode.Bit13; >+ public static final int NoEffectAssignment = IrritantSet.GROUP0 | ASTNode.Bit14; >+ public static final int IncompatibleNonInheritedInterfaceMethod = IrritantSet.GROUP0 | ASTNode.Bit15; >+ public static final int UnusedPrivateMember = IrritantSet.GROUP0 | ASTNode.Bit16; >+ public static final int LocalVariableHiding = IrritantSet.GROUP0 | ASTNode.Bit17; >+ public static final int FieldHiding = IrritantSet.GROUP0 | ASTNode.Bit18; >+ public static final int AccidentalBooleanAssign = IrritantSet.GROUP0 | ASTNode.Bit19; >+ public static final int EmptyStatement = IrritantSet.GROUP0 | ASTNode.Bit20; >+ public static final int MissingJavadocComments = IrritantSet.GROUP0 | ASTNode.Bit21; >+ public static final int MissingJavadocTags = IrritantSet.GROUP0 | ASTNode.Bit22; >+ public static final int UnqualifiedFieldAccess = IrritantSet.GROUP0 | ASTNode.Bit23; >+ public static final int UnusedDeclaredThrownException = IrritantSet.GROUP0 | ASTNode.Bit24; >+ public static final int FinallyBlockNotCompleting = IrritantSet.GROUP0 | ASTNode.Bit25; >+ public static final int InvalidJavadoc = IrritantSet.GROUP0 | ASTNode.Bit26; >+ public static final int UnnecessaryTypeCheck = IrritantSet.GROUP0 | ASTNode.Bit27; >+ public static final int UndocumentedEmptyBlock = IrritantSet.GROUP0 | ASTNode.Bit28; >+ public static final int IndirectStaticAccess = IrritantSet.GROUP0 | ASTNode.Bit29; >+ >+ // group 1 >+ public static final int UnnecessaryElse = IrritantSet.GROUP1 | ASTNode.Bit1; >+ public static final int UncheckedTypeOperation = IrritantSet.GROUP1 | ASTNode.Bit2; >+ public static final int FinalParameterBound = IrritantSet.GROUP1 | ASTNode.Bit3; >+ public static final int MissingSerialVersion = IrritantSet.GROUP1 | ASTNode.Bit4; >+ public static final int EnumUsedAsAnIdentifier = IrritantSet.GROUP1 | ASTNode.Bit5; >+ public static final int ForbiddenReference = IrritantSet.GROUP1 | ASTNode.Bit6; >+ public static final int VarargsArgumentNeedCast = IrritantSet.GROUP1 | ASTNode.Bit7; >+ public static final int NullReference = IrritantSet.GROUP1 | ASTNode.Bit8; >+ public static final int AutoBoxing = IrritantSet.GROUP1 | ASTNode.Bit9; >+ public static final int AnnotationSuperInterface = IrritantSet.GROUP1 | ASTNode.Bit10; >+ public static final int TypeHiding = IrritantSet.GROUP1 | ASTNode.Bit11; >+ public static final int MissingOverrideAnnotation = IrritantSet.GROUP1 | ASTNode.Bit12; >+ public static final int IncompleteEnumSwitch = IrritantSet.GROUP1 | ASTNode.Bit13; >+ public static final int MissingDeprecatedAnnotation = IrritantSet.GROUP1 | ASTNode.Bit14; >+ public static final int DiscouragedReference = IrritantSet.GROUP1 | ASTNode.Bit15; >+ public static final int UnhandledWarningToken = IrritantSet.GROUP1 | ASTNode.Bit16; >+ public static final int RawTypeReference = IrritantSet.GROUP1 | ASTNode.Bit17; >+ public static final int UnusedLabel = IrritantSet.GROUP1 | ASTNode.Bit18; >+ public static final int ParameterAssignment = IrritantSet.GROUP1 | ASTNode.Bit19; >+ public static final int FallthroughCase = IrritantSet.GROUP1 | ASTNode.Bit20; >+ public static final int OverridingMethodWithoutSuperInvocation = IrritantSet.GROUP1 | ASTNode.Bit21; >+ public static final int PotentialNullReference = IrritantSet.GROUP1 | ASTNode.Bit22; >+ public static final int RedundantNullCheck = IrritantSet.GROUP1 | ASTNode.Bit23; >+ public static final int MissingJavadocTagDescription = IrritantSet.GROUP1 | ASTNode.Bit24; >+ public static final int UnusedTypeArguments = IrritantSet.GROUP1 | ASTNode.Bit25; >+ public static final int UnusedWarningToken = IrritantSet.GROUP1 | ASTNode.Bit26; >+ public static final int RedundantSuperinterface = IrritantSet.GROUP1 | ASTNode.Bit27; >+ public static final int ComparingIdentical = IrritantSet.GROUP1 | ASTNode.Bit28; >+ public static final int MissingSynchronizedModifierInInheritedMethod= IrritantSet.GROUP1 | ASTNode.Bit29; >+ >+ // group 2 >+ // NEXT IRRITANT GOES HERE (group1 is complete already) >+ // public static final int FirstInGroup2 = IrritantSet.GROUP2 | ASTNode.Bit1; >+ > // Map: String optionKey --> Long irritant> > private static Map OptionToIrritants; > >- // Default severity level for handlers >- public long errorThreshold = 0; >+ // Severity level for handlers >+ /** >+ * Defaults defined at {@lnk IrritantSet#COMPILER_DEFAULT_ERRORS} >+ * @see #resetDefaults() >+ */ >+ protected IrritantSet errorThreshold; >+ /** >+ * Defaults defined at {@lnk IrritantSet#COMPILER_DEFAULT_WARNINGS} >+ * @see #resetDefaults() >+ */ >+ protected IrritantSet warningThreshold; >+ >+ /** >+ * Default settings are to be defined in {@lnk CompilerOptions#resetDefaults()} >+ */ >+ >+ /** Classfile debug information, may contain source file name, line numbers, local variable tables, etc... */ >+ public int produceDebugAttributes; >+ /** Compliance level for the compiler, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */ >+ public long complianceLevel; >+ /** Java source level, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */ >+ public long sourceLevel; >+ /** VM target level, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */ >+ public long targetJDK; >+ /** Source encoding format */ >+ public String defaultEncoding; >+ /** Compiler trace verbosity */ >+ public boolean verbose; >+ /** Indicates whether reference info is desired */ >+ public boolean produceReferenceInfo; >+ /** Indicates if unused/optimizable local variables need to be preserved (debugging purpose) */ >+ public boolean preserveAllLocalVariables; >+ /** Indicates whether literal expressions are inlined at parse-time or not */ >+ public boolean parseLiteralExpressionsAsConstants; >+ /** Max problems per compilation unit */ >+ public int maxProblemsPerUnit; >+ /** Tags used to recognize tasks in comments */ >+ public char[][] taskTags; >+ /** Respective priorities of recognized task tags */ >+ public char[][] taskPriorites; >+ /** Indicate whether tag detection is case sensitive or not */ >+ public boolean isTaskCaseSensitive; >+ /** Specify whether deprecation inside deprecated code is to be reported */ >+ public boolean reportDeprecationInsideDeprecatedCode; >+ /** Specify whether override of deprecated method is to be reported */ >+ public boolean reportDeprecationWhenOverridingDeprecatedMethod; >+ /** Specify if should report unused parameter when implementing abstract method */ >+ public boolean reportUnusedParameterWhenImplementingAbstract; >+ /** Specify if should report unused parameter when overriding concrete method */ >+ public boolean reportUnusedParameterWhenOverridingConcrete; >+ /** Specify if should report documented unused parameter (in javadoc) */ >+ public boolean reportUnusedParameterIncludeDocCommentReference; >+ /** Specify if should reported unused declared thrown exception when overriding method */ >+ public boolean reportUnusedDeclaredThrownExceptionWhenOverriding; >+ /** Specify if should reported unused declared thrown exception when documented in javadoc */ >+ public boolean reportUnusedDeclaredThrownExceptionIncludeDocCommentReference; >+ /** Specify if should reported unused declared thrown exception when Exception or Throwable */ >+ public boolean reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable; >+ /** Specify whether should report constructor/setter method parameter hiding */ >+ public boolean reportSpecialParameterHidingField; >+ /** Master flag controlling whether doc comment should be processed */ >+ public boolean docCommentSupport; >+ /** Specify if invalid javadoc shall be reported */ >+ public boolean reportInvalidJavadocTags; >+ /** Only report invalid javadoc above a given level of visibility of associated construct */ >+ public int reportInvalidJavadocTagsVisibility; >+ /** Specify if deprecated javadoc ref is allowed */ >+ public boolean reportInvalidJavadocTagsDeprecatedRef; >+ /** Specify if non visible javadoc ref is allowed */ >+ public boolean reportInvalidJavadocTagsNotVisibleRef; >+ /** Specify when to report missing javadoc tag description */ >+ public String reportMissingJavadocTagDescription; >+ /** Only report missing javadoc tags above a given level of visibility of associated construct */ >+ public int reportMissingJavadocTagsVisibility; >+ /** Specify if need to flag missing javadoc tags for overriding method */ >+ public boolean reportMissingJavadocTagsOverriding; >+ /** Only report missing javadoc comment above a given level of visibility of associated construct */ >+ public int reportMissingJavadocCommentsVisibility; >+ /** Specify if need to flag missing javadoc comment for overriding method */ >+ 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 */ >+ public boolean suppressWarnings; >+ /** Specify if should treat optional error as fatal or just like warning */ >+ public boolean treatOptionalErrorAsFatal; >+ /** Specify if parser should perform structural recovery in methods */ >+ public boolean performMethodsFullRecovery; >+ /** Specify if parser perform statements recovery */ >+ public boolean performStatementsRecovery; >+ /** Control whether annotation processing is enabled */ >+ public boolean processAnnotations; >+ /** Store annotations */ >+ public boolean storeAnnotations; >+ /** Indicate if annotation processing generates classfiles */ >+ public boolean generateClassFiles; >+ >+ >+ // keep in sync with warningTokenToIrritant and warningTokenFromIrritant >+ public final static String[] warningTokens = { >+ "all", //$NON-NLS-1$ >+ "boxing", //$NON-NLS-1$ >+ "cast", //$NON-NLS-1$ >+ "dep-ann", //$NON-NLS-1$ >+ "deprecation", //$NON-NLS-1$ >+ "fallthrough", //$NON-NLS-1$ >+ "finally", //$NON-NLS-1$ >+ "hiding", //$NON-NLS-1$ >+ "incomplete-switch", //$NON-NLS-1$ >+ "nls", //$NON-NLS-1$ >+ "null", //$NON-NLS-1$ >+ "restriction", //$NON-NLS-1$ >+ "serial", //$NON-NLS-1$ >+ "static-access", //$NON-NLS-1$ >+ "super", //$NON-NLS-1$ >+ "synthetic-access", //$NON-NLS-1$ >+ "unchecked", //$NON-NLS-1$ >+ "unqualified-field-access", //$NON-NLS-1$ >+ "unused", //$NON-NLS-1$ >+ }; > >- public long warningThreshold = >- MethodWithConstructorName >- | UsingDeprecatedAPI >- | MaskedCatchBlock >- | OverriddenPackageDefaultMethod >- | UnusedImport >- | NonStaticAccessToStatic >- | NoEffectAssignment >- | IncompatibleNonInheritedInterfaceMethod >- | NoImplicitStringConversion >- | FinallyBlockNotCompleting >- | AssertUsedAsAnIdentifier >- | EnumUsedAsAnIdentifier >- | UncheckedTypeOperation >- | RawTypeReference >- | MissingSerialVersion >- | VarargsArgumentNeedCast >- | ForbiddenReference >- | DiscouragedReference >- | AnnotationSuperInterface >- | TypeHiding >- | FinalParameterBound >- | UnhandledWarningToken >- | UnusedLocalVariable >- | UnusedPrivateMember >- | UnusedLabel >- | UnusedTypeArguments >- | NullReference >- | UnusedWarningToken >- | ComparingIdentical >- | MissingSynchronizedModifierInInheritedMethod; >- >- // By default only lines and source attributes are generated. >- public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES; >- >- public long complianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4 >- public long sourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default >- public long targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2 >- >- // source encoding format >- public String defaultEncoding = null; // will use the platform default encoding >- >- // print what unit is being processed >- public boolean verbose = Compiler.DEBUG; >- >- // indicates if reference info is desired >- public boolean produceReferenceInfo = false; >- >- // indicates if unused/optimizable local variables need to be preserved (debugging purpose) >- public boolean preserveAllLocalVariables = false; >- >- // indicates whether literal expressions are inlined at parse-time or not >- public boolean parseLiteralExpressionsAsConstants = true; >- >- // max problems per compilation unit >- public int maxProblemsPerUnit = 100; // no more than 100 problems per default >- >- // tags used to recognize tasks in comments >- public char[][] taskTags = null; >- public char[][] taskPriorites = null; >- public boolean isTaskCaseSensitive = true; >- >- // deprecation report >- public boolean reportDeprecationInsideDeprecatedCode = false; >- public boolean reportDeprecationWhenOverridingDeprecatedMethod = false; >- >- // unused parameters report >- public boolean reportUnusedParameterWhenImplementingAbstract = false; >- public boolean reportUnusedParameterWhenOverridingConcrete = false; >- public boolean reportUnusedParameterIncludeDocCommentReference = true; >- >- // unused declaration of thrown exception >- public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false; >- public boolean reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = true; >- public boolean reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = true; >- >- // constructor/setter parameter hiding >- public boolean reportSpecialParameterHidingField = false; >- >- // check javadoc comments tags >- public int reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic; >- public boolean reportInvalidJavadocTags = false; >- public boolean reportInvalidJavadocTagsDeprecatedRef = false; >- public boolean reportInvalidJavadocTagsNotVisibleRef = false; >- public String reportMissingJavadocTagDescription = RETURN_TAG; >- >- // check missing javadoc tags >- public int reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic; >- public boolean reportMissingJavadocTagsOverriding = false; >- >- // check missing javadoc comments >- public int reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic; >- public boolean reportMissingJavadocCommentsOverriding = false; >- >- // JSR bytecode inlining >- public boolean inlineJsrBytecode = false; >- >- // javadoc comment support >- public boolean docCommentSupport = false; >- >- // suppress warning annotation >- public boolean suppressWarnings = true; >- >- // treat optional error as fatal or just like warning? >- public boolean treatOptionalErrorAsFatal = true; >- >- // parser perform statements recovery >- public boolean performMethodsFullRecovery = true; >- >- // parser perform statements recovery >- public boolean performStatementsRecovery = true; >+ /** >+ * Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by >+ * other master options (e.g. javadoc, deprecation, etc.). >+ * This information is intended for grouping purpose (several problems governed by a rule) >+ */ >+ public static String optionKeyFromIrritant(int irritant) { >+ // keep in sync with warningTokens and warningTokenToIrritant >+ switch (irritant) { >+ case MethodWithConstructorName : >+ return OPTION_ReportMethodWithConstructorName; >+ case OverriddenPackageDefaultMethod : >+ return OPTION_ReportOverridingPackageDefaultMethod; >+ case UsingDeprecatedAPI : >+ case (InvalidJavadoc | UsingDeprecatedAPI) : >+ return OPTION_ReportDeprecation; >+ case MaskedCatchBlock : >+ return OPTION_ReportHiddenCatchBlock; >+ case UnusedLocalVariable : >+ return OPTION_ReportUnusedLocal; >+ case UnusedArgument : >+ return OPTION_ReportUnusedParameter; >+ case NoImplicitStringConversion : >+ return OPTION_ReportNoImplicitStringConversion; >+ case AccessEmulation : >+ return OPTION_ReportSyntheticAccessEmulation; >+ case NonExternalizedString : >+ return OPTION_ReportNonExternalizedStringLiteral; >+ case AssertUsedAsAnIdentifier : >+ return OPTION_ReportAssertIdentifier; >+ case UnusedImport : >+ return OPTION_ReportUnusedImport; >+ case NonStaticAccessToStatic : >+ return OPTION_ReportNonStaticAccessToStatic; >+ case Task : >+ return OPTION_TaskTags; >+ case NoEffectAssignment : >+ return OPTION_ReportNoEffectAssignment; >+ case IncompatibleNonInheritedInterfaceMethod : >+ return OPTION_ReportIncompatibleNonInheritedInterfaceMethod; >+ case UnusedPrivateMember : >+ return OPTION_ReportUnusedPrivateMember; >+ case LocalVariableHiding : >+ return OPTION_ReportLocalVariableHiding; >+ case FieldHiding : >+ return OPTION_ReportFieldHiding; >+ case AccidentalBooleanAssign : >+ return OPTION_ReportPossibleAccidentalBooleanAssignment; >+ case EmptyStatement : >+ return OPTION_ReportEmptyStatement; >+ case MissingJavadocComments : >+ return OPTION_ReportMissingJavadocComments; >+ case MissingJavadocTags : >+ return OPTION_ReportMissingJavadocTags; >+ case UnqualifiedFieldAccess : >+ return OPTION_ReportUnqualifiedFieldAccess; >+ case UnusedDeclaredThrownException : >+ return OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding; >+ case FinallyBlockNotCompleting : >+ return OPTION_ReportFinallyBlockNotCompletingNormally; >+ case InvalidJavadoc : >+ return OPTION_ReportInvalidJavadoc; >+ case UnnecessaryTypeCheck : >+ return OPTION_ReportUnnecessaryTypeCheck; >+ case UndocumentedEmptyBlock : >+ return OPTION_ReportUndocumentedEmptyBlock; >+ case IndirectStaticAccess : >+ return OPTION_ReportIndirectStaticAccess; >+ case UnnecessaryElse : >+ return OPTION_ReportUnnecessaryElse; >+ case UncheckedTypeOperation : >+ return OPTION_ReportUncheckedTypeOperation; >+ case FinalParameterBound : >+ return OPTION_ReportFinalParameterBound; >+ case MissingSerialVersion : >+ return OPTION_ReportMissingSerialVersion ; >+ case EnumUsedAsAnIdentifier : >+ return OPTION_ReportEnumIdentifier; >+ case ForbiddenReference : >+ return OPTION_ReportForbiddenReference; >+ case VarargsArgumentNeedCast : >+ return OPTION_ReportVarargsArgumentNeedCast; >+ case NullReference : >+ return OPTION_ReportNullReference; >+ case PotentialNullReference : >+ return OPTION_ReportPotentialNullReference; >+ case RedundantNullCheck : >+ return OPTION_ReportRedundantNullCheck; >+ case AutoBoxing : >+ return OPTION_ReportAutoboxing; >+ case AnnotationSuperInterface : >+ return OPTION_ReportAnnotationSuperInterface; >+ case TypeHiding : >+ return OPTION_ReportTypeParameterHiding; >+ case MissingOverrideAnnotation : >+ return OPTION_ReportMissingOverrideAnnotation; >+ case IncompleteEnumSwitch : >+ return OPTION_ReportIncompleteEnumSwitch; >+ case MissingDeprecatedAnnotation : >+ return OPTION_ReportMissingDeprecatedAnnotation; >+ case DiscouragedReference : >+ return OPTION_ReportDiscouragedReference; >+ case UnhandledWarningToken : >+ return OPTION_ReportUnhandledWarningToken; >+ case RawTypeReference : >+ return OPTION_ReportRawTypeReference; >+ case UnusedLabel : >+ return OPTION_ReportUnusedLabel; >+ case ParameterAssignment : >+ return OPTION_ReportParameterAssignment; >+ case FallthroughCase : >+ return OPTION_ReportFallthroughCase; >+ case OverridingMethodWithoutSuperInvocation : >+ return OPTION_ReportOverridingMethodWithoutSuperInvocation; >+ case MissingJavadocTagDescription : >+ return OPTION_ReportMissingJavadocTagDescription; >+ case UnusedTypeArguments : >+ return OPTION_ReportUnusedTypeArgumentsForMethodInvocation; >+ case UnusedWarningToken : >+ return OPTION_ReportUnusedWarningToken; >+ case RedundantSuperinterface : >+ return OPTION_ReportRedundantSuperinterface; >+ case ComparingIdentical : >+ return OPTION_ReportComparingIdentical; >+ case MissingSynchronizedModifierInInheritedMethod : >+ return OPTION_ReportMissingSynchronizedOnInheritedMethod; >+ } >+ return null; >+ } > >- // store annotations >- public boolean storeAnnotations = false; >+ public static long optionKeyToIrritant(String optionName) { >+ if (OptionToIrritants == null) { >+ int group = 0; >+ for (int g = 0; g < 8; g++) { >+ group <<= 1; >+ int index = 0; >+ for (int i = 0; i < 30; i++) { >+ index <<= 1; >+ int irritant = (group<<IrritantSet.GROUP_SHIFT)+index; >+ String optionKey = optionKeyFromIrritant(irritant); >+ if (optionKey == null) continue; >+ OptionToIrritants.put(optionKey, new Integer(irritant)); >+ } >+ >+ } >+ } >+ Long irritant = (Long)OptionToIrritants.get(optionName); >+ return irritant == null ? 0 : irritant.longValue(); >+ } > >- // annotation processing >- public boolean generateClassFiles = true; >+ public static String versionFromJdkLevel(long jdkLevel) { >+ switch ((int)(jdkLevel>>16)) { >+ case ClassFileConstants.MAJOR_VERSION_1_1 : >+ if (jdkLevel == ClassFileConstants.JDK1_1) >+ return VERSION_1_1; >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_2 : >+ if (jdkLevel == ClassFileConstants.JDK1_2) >+ return VERSION_1_2; >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_3 : >+ if (jdkLevel == ClassFileConstants.JDK1_3) >+ return VERSION_1_3; >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_4 : >+ if (jdkLevel == ClassFileConstants.JDK1_4) >+ return VERSION_1_4; >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_5 : >+ if (jdkLevel == ClassFileConstants.JDK1_5) >+ return VERSION_1_5; >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_6 : >+ if (jdkLevel == ClassFileConstants.JDK1_6) >+ return VERSION_1_6; >+ break; >+ case ClassFileConstants.MAJOR_VERSION_1_7 : >+ if (jdkLevel == ClassFileConstants.JDK1_7) >+ return VERSION_1_7; >+ break; >+ } >+ return Util.EMPTY_STRING; // unknown version >+ } > >- // Enable annotation processing by default only in batch mode >- public boolean processAnnotations = false; >+ public static long versionToJdkLevel(Object versionID) { >+ if (versionID instanceof String) { >+ String version = (String) versionID; >+ // verification is optimized for all versions with same length and same "1." prefix >+ if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') { >+ switch (version.charAt(2)) { >+ case '1': >+ return ClassFileConstants.JDK1_1; >+ case '2': >+ return ClassFileConstants.JDK1_2; >+ case '3': >+ return ClassFileConstants.JDK1_3; >+ case '4': >+ return ClassFileConstants.JDK1_4; >+ case '5': >+ return ClassFileConstants.JDK1_5; >+ case '6': >+ return ClassFileConstants.JDK1_6; >+ case '7': >+ return ClassFileConstants.JDK1_7; >+ default: >+ return 0; // unknown >+ } >+ } >+ if (VERSION_JSR14.equals(versionID)) { >+ return ClassFileConstants.JDK1_4; >+ } >+ if (VERSION_CLDC1_1.equals(versionID)) { >+ return ClassFileConstants.CLDC_1_1; >+ } >+ } >+ return 0; // unknown >+ } >+ >+ /** >+ * Return all warning option names for use as keys in compiler options maps. >+ * @return all warning option names >+ * TODO (maxime) revise for ensuring completeness >+ */ >+ public static String[] warningOptionNames() { >+ String[] result = { >+ OPTION_ReportAnnotationSuperInterface, >+ OPTION_ReportAssertIdentifier, >+ OPTION_ReportAutoboxing, >+ OPTION_ReportDeprecation, >+ OPTION_ReportDiscouragedReference, >+ OPTION_ReportEmptyStatement, >+ OPTION_ReportEnumIdentifier, >+ OPTION_ReportFallthroughCase, >+ OPTION_ReportFieldHiding, >+ OPTION_ReportFinalParameterBound, >+ OPTION_ReportFinallyBlockNotCompletingNormally, >+ OPTION_ReportForbiddenReference, >+ OPTION_ReportHiddenCatchBlock, >+ OPTION_ReportIncompatibleNonInheritedInterfaceMethod, >+ OPTION_ReportIncompleteEnumSwitch, >+ OPTION_ReportIndirectStaticAccess, >+ OPTION_ReportInvalidJavadoc, >+ OPTION_ReportLocalVariableHiding, >+ OPTION_ReportMethodWithConstructorName, >+ OPTION_ReportMissingDeprecatedAnnotation, >+ OPTION_ReportMissingJavadocComments, >+ OPTION_ReportMissingJavadocTagDescription, >+ OPTION_ReportMissingJavadocTags, >+ OPTION_ReportMissingOverrideAnnotation, >+ OPTION_ReportMissingSerialVersion, >+ OPTION_ReportNoEffectAssignment, >+ OPTION_ReportNoImplicitStringConversion, >+ OPTION_ReportNonExternalizedStringLiteral, >+ OPTION_ReportNonStaticAccessToStatic, >+ OPTION_ReportNullReference, >+ OPTION_ReportPotentialNullReference, >+ OPTION_ReportRedundantNullCheck, >+ OPTION_ReportRedundantSuperinterface, >+ OPTION_ReportOverridingPackageDefaultMethod, >+ OPTION_ReportParameterAssignment, >+ OPTION_ReportPossibleAccidentalBooleanAssignment, >+ OPTION_ReportSyntheticAccessEmulation, >+ OPTION_ReportTypeParameterHiding, >+ OPTION_ReportUncheckedTypeOperation, >+ OPTION_ReportUndocumentedEmptyBlock, >+ OPTION_ReportUnnecessaryElse, >+ OPTION_ReportUnnecessaryTypeCheck, >+ OPTION_ReportUnqualifiedFieldAccess, >+ OPTION_ReportUnusedDeclaredThrownException, >+ OPTION_ReportUnusedImport, >+ OPTION_ReportUnusedLocal, >+ OPTION_ReportUnusedParameter, >+ OPTION_ReportUnusedPrivateMember, >+ OPTION_ReportVarargsArgumentNeedCast, >+ OPTION_ReportUnhandledWarningToken, >+ OPTION_ReportUnusedWarningToken, >+ OPTION_ReportOverridingMethodWithoutSuperInvocation, >+ OPTION_ReportUnusedTypeArgumentsForMethodInvocation, >+ }; >+ return result; >+ } >+ >+ /** >+ * For suppressable warnings >+ */ >+ public static String warningTokenFromIrritant(int irritant) { >+ // keep in sync with warningTokens and warningTokenToIrritant >+ switch (irritant) { >+ case (InvalidJavadoc | UsingDeprecatedAPI) : >+ case UsingDeprecatedAPI : >+ return "deprecation"; //$NON-NLS-1$ >+ case FinallyBlockNotCompleting : >+ return "finally"; //$NON-NLS-1$ >+ case FieldHiding : >+ case LocalVariableHiding : >+ case MaskedCatchBlock : >+ return "hiding"; //$NON-NLS-1$ >+ case NonExternalizedString : >+ return "nls"; //$NON-NLS-1$ >+ case UnnecessaryTypeCheck : >+ return "cast"; //$NON-NLS-1$ >+ case UnusedLocalVariable : >+ case UnusedArgument : >+ case UnusedImport : >+ case UnusedPrivateMember : >+ case UnusedDeclaredThrownException : >+ return "unused"; //$NON-NLS-1$ >+ case IndirectStaticAccess : >+ case NonStaticAccessToStatic : >+ return "static-access"; //$NON-NLS-1$ >+ case AccessEmulation : >+ return "synthetic-access"; //$NON-NLS-1$ >+ case UnqualifiedFieldAccess : >+ return "unqualified-field-access"; //$NON-NLS-1$ >+ case UncheckedTypeOperation : >+ return "unchecked"; //$NON-NLS-1$ >+ case MissingSerialVersion : >+ return "serial"; //$NON-NLS-1$ >+ case AutoBoxing : >+ return "boxing"; //$NON-NLS-1$ >+ case TypeHiding : >+ return "hiding"; //$NON-NLS-1$ >+ case IncompleteEnumSwitch : >+ return "incomplete-switch"; //$NON-NLS-1$ >+ case MissingDeprecatedAnnotation : >+ return "dep-ann"; //$NON-NLS-1$ >+ case RawTypeReference : >+ return "unchecked"; //$NON-NLS-1$ >+ case UnusedLabel : >+ case UnusedTypeArguments : >+ case RedundantSuperinterface : >+ return "unused"; //$NON-NLS-1$ >+ case DiscouragedReference : >+ case ForbiddenReference : >+ return "restriction"; //$NON-NLS-1$ >+ case NullReference : >+ case PotentialNullReference : >+ case RedundantNullCheck : >+ return "null"; //$NON-NLS-1$ >+ case FallthroughCase : >+ return "fallthrough"; //$NON-NLS-1$ >+ case OverridingMethodWithoutSuperInvocation : >+ return "super"; //$NON-NLS-1$ >+ } >+ return null; >+ } >+ >+ public static IrritantSet warningTokenToIrritants(String warningToken) { >+ // keep in sync with warningTokens and warningTokenFromIrritant >+ if (warningToken == null || warningToken.length() == 0) return null; >+ switch (warningToken.charAt(0)) { >+ case 'a' : >+ if ("all".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.ALL; >+ break; >+ case 'b' : >+ if ("boxing".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.BOXING; >+ break; >+ case 'c' : >+ if ("cast".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.CAST; >+ break; >+ case 'd' : >+ if ("deprecation".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.DEPRECATION; >+ if ("dep-ann".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.DEP_ANN; >+ break; >+ case 'f' : >+ if ("fallthrough".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.FALLTHROUGH; >+ if ("finally".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.FINALLY; >+ break; >+ case 'h' : >+ if ("hiding".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.HIDING; >+ case 'i' : >+ if ("incomplete-switch".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.INCOMPLETE_SWITCH; >+ break; >+ case 'n' : >+ if ("nls".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.NLS; >+ if ("null".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.NULL; >+ break; >+ case 'r' : >+ if ("restriction".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.RESTRICTION; >+ break; >+ case 's' : >+ if ("serial".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.SERIAL; >+ if ("static-access".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.STATIC_ACCESS; >+ if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.SYNTHETIC_ACCESS; >+ if ("super".equals(warningToken)) { //$NON-NLS-1$ >+ return IrritantSet.SUPER; >+ } >+ break; >+ case 'u' : >+ if ("unused".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.UNUSED; >+ if ("unchecked".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.UNCHECKED; >+ if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$ >+ return IrritantSet.UNQUALIFIED_FIELD_ACCESS; >+ break; >+ } >+ return null; >+ } > > /** > * Initializing the compiler options with defaults > */ > public CompilerOptions(){ >- // use default options >+ this(null); // use default options > } > > /** >@@ -358,9 +777,10 @@ > * @param settings > */ > public CompilerOptions(Map settings){ >- >- if (settings == null) return; >- set(settings); >+ resetDefaults(); >+ if (settings != null) { >+ set(settings); >+ } > } > > /** >@@ -371,6 +791,7 @@ > this.parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants; > } > >+ > public Map getMap() { > Map optionsMap = new HashMap(30); > optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? GENERATE : DO_NOT_GENERATE); >@@ -471,178 +892,28 @@ > return optionsMap; > } > >- /** >- * Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by >- * other master options (e.g. javadoc, deprecation, etc.). >- * This information is intended for grouping purpose (several problems governed by a rule) >- */ >- public static String optionKeyFromIrritant(long irritant) { >- // keep in sync with warningTokens and warningTokenToIrritant >- int irritantInt = (int) irritant; >- if (irritantInt == irritant) { >- switch (irritantInt) { >- case (int) MethodWithConstructorName : >- return OPTION_ReportMethodWithConstructorName; >- case (int) OverriddenPackageDefaultMethod : >- return OPTION_ReportOverridingPackageDefaultMethod; >- case (int) UsingDeprecatedAPI : >- case (int) (InvalidJavadoc | UsingDeprecatedAPI) : >- return OPTION_ReportDeprecation; >- case (int) MaskedCatchBlock : >- return OPTION_ReportHiddenCatchBlock; >- case (int) UnusedLocalVariable : >- return OPTION_ReportUnusedLocal; >- case (int) UnusedArgument : >- return OPTION_ReportUnusedParameter; >- case (int) NoImplicitStringConversion : >- return OPTION_ReportNoImplicitStringConversion; >- case (int) AccessEmulation : >- return OPTION_ReportSyntheticAccessEmulation; >- case (int) NonExternalizedString : >- return OPTION_ReportNonExternalizedStringLiteral; >- case (int) AssertUsedAsAnIdentifier : >- return OPTION_ReportAssertIdentifier; >- case (int) UnusedImport : >- return OPTION_ReportUnusedImport; >- case (int) NonStaticAccessToStatic : >- return OPTION_ReportNonStaticAccessToStatic; >- case (int) Task : >- return OPTION_TaskTags; >- case (int) NoEffectAssignment : >- return OPTION_ReportNoEffectAssignment; >- case (int) IncompatibleNonInheritedInterfaceMethod : >- return OPTION_ReportIncompatibleNonInheritedInterfaceMethod; >- case (int) UnusedPrivateMember : >- return OPTION_ReportUnusedPrivateMember; >- case (int) LocalVariableHiding : >- return OPTION_ReportLocalVariableHiding; >- case (int) FieldHiding : >- return OPTION_ReportFieldHiding; >- case (int) AccidentalBooleanAssign : >- return OPTION_ReportPossibleAccidentalBooleanAssignment; >- case (int) EmptyStatement : >- return OPTION_ReportEmptyStatement; >- case (int) MissingJavadocComments : >- return OPTION_ReportMissingJavadocComments; >- case (int) MissingJavadocTags : >- return OPTION_ReportMissingJavadocTags; >- case (int) UnqualifiedFieldAccess : >- return OPTION_ReportUnqualifiedFieldAccess; >- case (int) UnusedDeclaredThrownException : >- return OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding; >- case (int) FinallyBlockNotCompleting : >- return OPTION_ReportFinallyBlockNotCompletingNormally; >- case (int) InvalidJavadoc : >- return OPTION_ReportInvalidJavadoc; >- case (int) UnnecessaryTypeCheck : >- return OPTION_ReportUnnecessaryTypeCheck; >- case (int) UndocumentedEmptyBlock : >- return OPTION_ReportUndocumentedEmptyBlock; >- case (int) IndirectStaticAccess : >- return OPTION_ReportIndirectStaticAccess; >- case (int) UnnecessaryElse : >- return OPTION_ReportUnnecessaryElse; >- case (int) UncheckedTypeOperation : >- return OPTION_ReportUncheckedTypeOperation; >- case (int) FinalParameterBound : >- return OPTION_ReportFinalParameterBound; >- } >- } else { >- irritantInt = (int)(irritant >>> 32); >- switch (irritantInt) { >- case (int)(MissingSerialVersion >>> 32) : >- return OPTION_ReportMissingSerialVersion ; >- case (int)(EnumUsedAsAnIdentifier >>> 32) : >- return OPTION_ReportEnumIdentifier; >- case (int)(ForbiddenReference >>> 32) : >- return OPTION_ReportForbiddenReference; >- case (int)(VarargsArgumentNeedCast >>> 32) : >- return OPTION_ReportVarargsArgumentNeedCast; >- case (int)(NullReference >>> 32) : >- return OPTION_ReportNullReference; >- case (int)(PotentialNullReference >>> 32) : >- return OPTION_ReportPotentialNullReference; >- case (int)(RedundantNullCheck >>> 32) : >- return OPTION_ReportRedundantNullCheck; >- case (int)(AutoBoxing >>> 32) : >- return OPTION_ReportAutoboxing; >- case (int)(AnnotationSuperInterface >>> 32) : >- return OPTION_ReportAnnotationSuperInterface; >- case (int)(TypeHiding >>> 32) : >- return OPTION_ReportTypeParameterHiding; >- case (int)(MissingOverrideAnnotation >>> 32) : >- return OPTION_ReportMissingOverrideAnnotation; >- case (int)(IncompleteEnumSwitch >>> 32) : >- return OPTION_ReportIncompleteEnumSwitch; >- case (int)(MissingDeprecatedAnnotation >>> 32) : >- return OPTION_ReportMissingDeprecatedAnnotation; >- case (int)(DiscouragedReference >>> 32) : >- return OPTION_ReportDiscouragedReference; >- case (int)(UnhandledWarningToken >>> 32) : >- return OPTION_ReportUnhandledWarningToken; >- case (int)(RawTypeReference >>> 32) : >- return OPTION_ReportRawTypeReference; >- case (int)(UnusedLabel >>> 32) : >- return OPTION_ReportUnusedLabel; >- case (int)(ParameterAssignment>>> 32) : >- return OPTION_ReportParameterAssignment; >- case (int)(FallthroughCase >>> 32) : >- return OPTION_ReportFallthroughCase; >- case (int)(OverridingMethodWithoutSuperInvocation >>> 32) : >- return OPTION_ReportOverridingMethodWithoutSuperInvocation; >- case (int)(MissingJavadocTagDescription >>> 32): >- return OPTION_ReportMissingJavadocTagDescription; >- case (int)(UnusedTypeArguments >>> 32): >- return OPTION_ReportUnusedTypeArgumentsForMethodInvocation; >- case (int)(UnusedWarningToken >>> 32) : >- return OPTION_ReportUnusedWarningToken; >- case (int)(RedundantSuperinterface >>> 32) : >- return OPTION_ReportRedundantSuperinterface; >- case (int)(ComparingIdentical >>> 32) : >- return OPTION_ReportComparingIdentical; >- case (int)(MissingSynchronizedModifierInInheritedMethod >>> 32) : >- return OPTION_ReportMissingSynchronizedOnInheritedMethod; >- } >- } >- return null; >- } >- >- public static long optionKeyToIrritant(String optionName) { >- if (OptionToIrritants == null) { >- long irritant = 0; >- for (int i = 0; i < 64; i++) { >- irritant <<= 1; >- String optionKey = optionKeyFromIrritant(irritant); >- if (optionKey == null) continue; >- OptionToIrritants.put(optionKey, new Long(irritant)); >- } >- } >- Long irritant = (Long)OptionToIrritants.get(optionName); >- return irritant == null ? 0 : irritant.longValue(); >- } >- >- public int getSeverity(long irritant) { >- if((this.errorThreshold & irritant) != 0) { >- if ((irritant & UnusedWarningToken) != 0) { >+ public int getSeverity(int irritant) { >+ if (this.errorThreshold.isSet(irritant)) { >+ if ((irritant & (IrritantSet.GROUP_MASK | UnusedWarningToken)) == UnusedWarningToken) { > return ProblemSeverities.Error | ProblemSeverities.Optional; // cannot be treated as fatal - codegen already occurred > } > return this.treatOptionalErrorAsFatal > ? ProblemSeverities.Error | ProblemSeverities.Optional | ProblemSeverities.Fatal > : ProblemSeverities.Error | ProblemSeverities.Optional; > } >- if((this.warningThreshold & irritant) != 0) >+ if (this.warningThreshold.isSet(irritant)) { > return ProblemSeverities.Warning | ProblemSeverities.Optional; >+ } > return ProblemSeverities.Ignore; > } > >- public String getSeverityString(long irritant) { >- if((this.errorThreshold & irritant) != 0) >+ public String getSeverityString(int irritant) { >+ if(this.errorThreshold.isSet(irritant)) > return ERROR; >- if((this.warningThreshold & irritant) != 0) >+ if(this.warningThreshold.isSet(irritant)) > return WARNING; > return IGNORE; > } >- > public String getVisibilityString(int level) { > switch (level & ExtraCompilerModifiers.AccVisibilityMASK) { > case ClassFileConstants.AccPublic: >@@ -656,6 +927,102 @@ > } > } > >+ public boolean isAnyEnabled(IrritantSet irritants) { >+ return this.warningThreshold.isAnySet(irritants) || this.errorThreshold.isAnySet(irritants); >+ } >+ >+ protected void resetDefaults() { >+ // problem default severities defined on IrritantSet >+ this.errorThreshold = new IrritantSet(IrritantSet.COMPILER_DEFAULT_ERRORS); >+ this.warningThreshold = new IrritantSet(IrritantSet.COMPILER_DEFAULT_WARNINGS); >+ >+ // by default only lines and source attributes are generated. >+ this.produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES; >+ this.complianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4 >+ this.sourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default >+ this.targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2 >+ >+ this.defaultEncoding = null; // will use the platform default encoding >+ >+ // print what unit is being processed >+ this.verbose = Compiler.DEBUG; >+ >+ this.produceReferenceInfo = false; // no reference info by default >+ >+ // indicates if unused/optimizable local variables need to be preserved (debugging purpose) >+ this.preserveAllLocalVariables = false; >+ >+ // indicates whether literal expressions are inlined at parse-time or not >+ this.parseLiteralExpressionsAsConstants = true; >+ >+ // max problems per compilation unit >+ this.maxProblemsPerUnit = 100; // no more than 100 problems per default >+ >+ // tags used to recognize tasks in comments >+ this.taskTags = null; >+ this.taskPriorites = null; >+ this.isTaskCaseSensitive = true; >+ >+ // deprecation report >+ this.reportDeprecationInsideDeprecatedCode = false; >+ this.reportDeprecationWhenOverridingDeprecatedMethod = false; >+ >+ // unused parameters report >+ this.reportUnusedParameterWhenImplementingAbstract = false; >+ this.reportUnusedParameterWhenOverridingConcrete = false; >+ this.reportUnusedParameterIncludeDocCommentReference = true; >+ >+ // unused declaration of thrown exception >+ this.reportUnusedDeclaredThrownExceptionWhenOverriding = false; >+ this.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = true; >+ this.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = true; >+ >+ // constructor/setter parameter hiding >+ this.reportSpecialParameterHidingField = false; >+ >+ // check javadoc comments tags >+ this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic; >+ this.reportInvalidJavadocTags = false; >+ this.reportInvalidJavadocTagsDeprecatedRef = false; >+ this.reportInvalidJavadocTagsNotVisibleRef = false; >+ this.reportMissingJavadocTagDescription = RETURN_TAG; >+ >+ // check missing javadoc tags >+ this.reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic; >+ this.reportMissingJavadocTagsOverriding = false; >+ >+ // check missing javadoc comments >+ this.reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic; >+ this.reportMissingJavadocCommentsOverriding = false; >+ >+ // JSR bytecode inlining >+ this.inlineJsrBytecode = false; >+ >+ // javadoc comment support >+ this.docCommentSupport = false; >+ >+ // suppress warning annotation >+ this.suppressWarnings = true; >+ >+ // treat optional error as fatal or just like warning? >+ this.treatOptionalErrorAsFatal = true; >+ >+ // parser perform statements recovery >+ this.performMethodsFullRecovery = true; >+ >+ // parser perform statements recovery >+ this.performStatementsRecovery = true; >+ >+ // store annotations >+ this.storeAnnotations = false; >+ >+ // annotation processing >+ this.generateClassFiles = true; >+ >+ // enable annotation processing by default only in batch mode >+ this.processAnnotations = false; >+ } >+ > public void set(Map optionsMap) { > Object optionValue; > if ((optionValue = optionsMap.get(OPTION_LocalVariableAttribute)) != null) { >@@ -999,9 +1366,7 @@ > } > } > } >- > public String toString() { >- > StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$ > buf.append("\n\t- local variables debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > buf.append("\n\t- line number debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_LINES) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >@@ -1092,310 +1457,17 @@ > buf.append("\n\t- missing synchronized on inherited method: ").append(getSeverityString(MissingSynchronizedModifierInInheritedMethod)); //$NON-NLS-1$ > return buf.toString(); > } >- >- void updateSeverity(long irritant, Object severityString) { >+ >+ protected void updateSeverity(int irritant, Object severityString) { > if (ERROR.equals(severityString)) { >- this.errorThreshold |= irritant; >- this.warningThreshold &= ~irritant; >+ this.errorThreshold.set(irritant); >+ this.warningThreshold.clear(irritant); > } else if (WARNING.equals(severityString)) { >- this.errorThreshold &= ~irritant; >- this.warningThreshold |= irritant; >+ this.errorThreshold.clear(irritant); >+ this.warningThreshold.set(irritant); > } else if (IGNORE.equals(severityString)) { >- this.errorThreshold &= ~irritant; >- this.warningThreshold &= ~irritant; >- } >- } >- public static long versionToJdkLevel(Object versionID) { >- if (versionID instanceof String) { >- String version = (String) versionID; >- // verification is optimized for all versions with same length and same "1." prefix >- if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') { >- switch (version.charAt(2)) { >- case '1': >- return ClassFileConstants.JDK1_1; >- case '2': >- return ClassFileConstants.JDK1_2; >- case '3': >- return ClassFileConstants.JDK1_3; >- case '4': >- return ClassFileConstants.JDK1_4; >- case '5': >- return ClassFileConstants.JDK1_5; >- case '6': >- return ClassFileConstants.JDK1_6; >- case '7': >- return ClassFileConstants.JDK1_7; >- default: >- return 0; // unknown >- } >- } >- if (VERSION_JSR14.equals(versionID)) { >- return ClassFileConstants.JDK1_4; >- } >- if (VERSION_CLDC1_1.equals(versionID)) { >- return ClassFileConstants.CLDC_1_1; >- } >- } >- return 0; // unknown >- } >- >- public static String versionFromJdkLevel(long jdkLevel) { >- switch ((int)(jdkLevel>>16)) { >- case ClassFileConstants.MAJOR_VERSION_1_1 : >- if (jdkLevel == ClassFileConstants.JDK1_1) >- return VERSION_1_1; >- break; >- case ClassFileConstants.MAJOR_VERSION_1_2 : >- if (jdkLevel == ClassFileConstants.JDK1_2) >- return VERSION_1_2; >- break; >- case ClassFileConstants.MAJOR_VERSION_1_3 : >- if (jdkLevel == ClassFileConstants.JDK1_3) >- return VERSION_1_3; >- break; >- case ClassFileConstants.MAJOR_VERSION_1_4 : >- if (jdkLevel == ClassFileConstants.JDK1_4) >- return VERSION_1_4; >- break; >- case ClassFileConstants.MAJOR_VERSION_1_5 : >- if (jdkLevel == ClassFileConstants.JDK1_5) >- return VERSION_1_5; >- break; >- case ClassFileConstants.MAJOR_VERSION_1_6 : >- if (jdkLevel == ClassFileConstants.JDK1_6) >- return VERSION_1_6; >- break; >- case ClassFileConstants.MAJOR_VERSION_1_7 : >- if (jdkLevel == ClassFileConstants.JDK1_7) >- return VERSION_1_7; >- break; >- } >- return Util.EMPTY_STRING; // unknown version >- } >- >- /** >- * Return all warning option names for use as keys in compiler options maps. >- * @return all warning option names >- * TODO (maxime) revise for ensuring completeness >- */ >- public static String[] warningOptionNames() { >- String[] result = { >- OPTION_ReportAnnotationSuperInterface, >- OPTION_ReportAssertIdentifier, >- OPTION_ReportAutoboxing, >- OPTION_ReportDeprecation, >- OPTION_ReportDiscouragedReference, >- OPTION_ReportEmptyStatement, >- OPTION_ReportEnumIdentifier, >- OPTION_ReportFallthroughCase, >- OPTION_ReportFieldHiding, >- OPTION_ReportFinalParameterBound, >- OPTION_ReportFinallyBlockNotCompletingNormally, >- OPTION_ReportForbiddenReference, >- OPTION_ReportHiddenCatchBlock, >- OPTION_ReportIncompatibleNonInheritedInterfaceMethod, >- OPTION_ReportIncompleteEnumSwitch, >- OPTION_ReportIndirectStaticAccess, >- OPTION_ReportInvalidJavadoc, >- OPTION_ReportLocalVariableHiding, >- OPTION_ReportMethodWithConstructorName, >- OPTION_ReportMissingDeprecatedAnnotation, >- OPTION_ReportMissingJavadocComments, >- OPTION_ReportMissingJavadocTagDescription, >- OPTION_ReportMissingJavadocTags, >- OPTION_ReportMissingOverrideAnnotation, >- OPTION_ReportMissingSerialVersion, >- OPTION_ReportNoEffectAssignment, >- OPTION_ReportNoImplicitStringConversion, >- OPTION_ReportNonExternalizedStringLiteral, >- OPTION_ReportNonStaticAccessToStatic, >- OPTION_ReportNullReference, >- OPTION_ReportPotentialNullReference, >- OPTION_ReportRedundantNullCheck, >- OPTION_ReportRedundantSuperinterface, >- OPTION_ReportOverridingPackageDefaultMethod, >- OPTION_ReportParameterAssignment, >- OPTION_ReportPossibleAccidentalBooleanAssignment, >- OPTION_ReportSyntheticAccessEmulation, >- OPTION_ReportTypeParameterHiding, >- OPTION_ReportUncheckedTypeOperation, >- OPTION_ReportUndocumentedEmptyBlock, >- OPTION_ReportUnnecessaryElse, >- OPTION_ReportUnnecessaryTypeCheck, >- OPTION_ReportUnqualifiedFieldAccess, >- OPTION_ReportUnusedDeclaredThrownException, >- OPTION_ReportUnusedImport, >- OPTION_ReportUnusedLocal, >- OPTION_ReportUnusedParameter, >- OPTION_ReportUnusedPrivateMember, >- OPTION_ReportVarargsArgumentNeedCast, >- OPTION_ReportUnhandledWarningToken, >- OPTION_ReportUnusedWarningToken, >- OPTION_ReportOverridingMethodWithoutSuperInvocation, >- OPTION_ReportUnusedTypeArgumentsForMethodInvocation, >- }; >- return result; >- } >- >- /** >- * For suppressable warnings >- */ >- public static String warningTokenFromIrritant(long irritant) { >- // keep in sync with warningTokens and warningTokenToIrritant >- int irritantInt = (int) irritant; >- if (irritantInt == irritant) { >- switch (irritantInt) { >- case (int) (InvalidJavadoc | UsingDeprecatedAPI) : >- case (int) UsingDeprecatedAPI : >- return "deprecation"; //$NON-NLS-1$ >- case (int) FinallyBlockNotCompleting : >- return "finally"; //$NON-NLS-1$ >- case (int) FieldHiding : >- case (int) LocalVariableHiding : >- case (int) MaskedCatchBlock : >- return "hiding"; //$NON-NLS-1$ >- case (int) NonExternalizedString : >- return "nls"; //$NON-NLS-1$ >- case (int) UnnecessaryTypeCheck : >- return "cast"; //$NON-NLS-1$ >- case (int) UnusedLocalVariable : >- case (int) UnusedArgument : >- case (int) UnusedImport : >- case (int) UnusedPrivateMember: >- case (int) UnusedDeclaredThrownException: >- return "unused"; //$NON-NLS-1$ >- case (int) IndirectStaticAccess : >- case (int) NonStaticAccessToStatic : >- return "static-access"; //$NON-NLS-1$ >- case (int) AccessEmulation : >- return "synthetic-access"; //$NON-NLS-1$ >- case (int) UnqualifiedFieldAccess : >- return "unqualified-field-access"; //$NON-NLS-1$ >- case (int) UncheckedTypeOperation : >- return "unchecked"; //$NON-NLS-1$ >- } >- } else { >- irritantInt = (int)(irritant >>> 32); >- switch (irritantInt) { >- case (int)(MissingSerialVersion >>> 32) : >- return "serial"; //$NON-NLS-1$ >- case (int)(AutoBoxing >>> 32) : >- return "boxing"; //$NON-NLS-1$ >- case (int)(TypeHiding >>> 32) : >- return "hiding"; //$NON-NLS-1$ >- case (int)(IncompleteEnumSwitch >>> 32) : >- return "incomplete-switch"; //$NON-NLS-1$ >- case (int)(MissingDeprecatedAnnotation >>> 32) : >- return "dep-ann"; //$NON-NLS-1$ >- case (int)(RawTypeReference >>> 32): >- return "unchecked"; //$NON-NLS-1$ >- case (int) (UnusedLabel >>> 32): >- case (int) (UnusedTypeArguments >>> 32) : >- case (int) (RedundantSuperinterface >>> 32) : >- return "unused"; //$NON-NLS-1$ >- case (int) (DiscouragedReference >>> 32) : >- case (int) (ForbiddenReference >>> 32) : >- return "restriction"; //$NON-NLS-1$ >- case (int) (NullReference >>> 32) : >- case (int) (PotentialNullReference >>> 32) : >- case (int) (RedundantNullCheck >>> 32) : >- return "null"; //$NON-NLS-1$ >- case (int) (FallthroughCase >>> 32) : >- return "fallthrough"; //$NON-NLS-1$ >- case (int) (OverridingMethodWithoutSuperInvocation >>> 32) : >- return "super"; //$NON-NLS-1$ >- } >- } >- return null; >- } >- // keep in sync with warningTokenToIrritant and warningTokenFromIrritant >- public final static String[] warningTokens = { >- "all", //$NON-NLS-1$ >- "boxing", //$NON-NLS-1$ >- "cast", //$NON-NLS-1$ >- "dep-ann", //$NON-NLS-1$ >- "deprecation", //$NON-NLS-1$ >- "fallthrough", //$NON-NLS-1$ >- "finally", //$NON-NLS-1$ >- "hiding", //$NON-NLS-1$ >- "incomplete-switch", //$NON-NLS-1$ >- "nls", //$NON-NLS-1$ >- "null", //$NON-NLS-1$ >- "restriction", //$NON-NLS-1$ >- "serial", //$NON-NLS-1$ >- "static-access", //$NON-NLS-1$ >- "super", //$NON-NLS-1$ >- "synthetic-access", //$NON-NLS-1$ >- "unchecked", //$NON-NLS-1$ >- "unqualified-field-access", //$NON-NLS-1$ >- "unused", //$NON-NLS-1$ >- }; >- >- public static long warningTokenToIrritants(String warningToken) { >- // keep in sync with warningTokens and warningTokenFromIrritant >- if (warningToken == null || warningToken.length() == 0) return 0; >- switch (warningToken.charAt(0)) { >- case 'a' : >- if ("all".equals(warningToken)) //$NON-NLS-1$ >- return 0xFFFFFFFFFFFFFFFFl; // suppress all warnings >- break; >- case 'b' : >- if ("boxing".equals(warningToken)) //$NON-NLS-1$ >- return AutoBoxing; >- break; >- case 'c' : >- if ("cast".equals(warningToken)) //$NON-NLS-1$ >- return UnnecessaryTypeCheck; >- break; >- case 'd' : >- if ("deprecation".equals(warningToken)) //$NON-NLS-1$ >- return UsingDeprecatedAPI; >- if ("dep-ann".equals(warningToken)) //$NON-NLS-1$ >- return MissingDeprecatedAnnotation; >- break; >- case 'f' : >- if ("fallthrough".equals(warningToken)) //$NON-NLS-1$ >- return FallthroughCase; >- if ("finally".equals(warningToken)) //$NON-NLS-1$ >- return FinallyBlockNotCompleting; >- break; >- case 'h' : >- if ("hiding".equals(warningToken)) //$NON-NLS-1$ >- return FieldHiding | LocalVariableHiding | MaskedCatchBlock | TypeHiding; >- case 'i' : >- if ("incomplete-switch".equals(warningToken)) //$NON-NLS-1$ >- return IncompleteEnumSwitch; >- break; >- case 'n' : >- if ("nls".equals(warningToken)) //$NON-NLS-1$ >- return NonExternalizedString; >- if ("null".equals(warningToken)) //$NON-NLS-1$ >- return NullReference | PotentialNullReference | RedundantNullCheck; >- break; >- case 'r' : >- if ("restriction".equals(warningToken)) //$NON-NLS-1$ >- return DiscouragedReference | ForbiddenReference; >- break; >- case 's' : >- if ("serial".equals(warningToken)) //$NON-NLS-1$ >- return MissingSerialVersion; >- if ("static-access".equals(warningToken)) //$NON-NLS-1$ >- return IndirectStaticAccess | NonStaticAccessToStatic; >- if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$ >- return AccessEmulation; >- if ("super".equals(warningToken)) { //$NON-NLS-1$ >- return OverridingMethodWithoutSuperInvocation; >- } >- break; >- case 'u' : >- if ("unused".equals(warningToken)) //$NON-NLS-1$ >- return UnusedLocalVariable | UnusedArgument | UnusedPrivateMember | UnusedDeclaredThrownException | UnusedLabel | UnusedImport | UnusedTypeArguments | RedundantSuperinterface; >- if ("unchecked".equals(warningToken)) //$NON-NLS-1$ >- return UncheckedTypeOperation | RawTypeReference; >- if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$ >- return UnqualifiedFieldAccess; >- break; >+ this.errorThreshold.clear(irritant); >+ this.warningThreshold.clear(irritant); > } >- return 0; > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java >diff -N compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,255 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.internal.compiler.impl; >+ >+import org.eclipse.jdt.internal.compiler.ast.ASTNode; >+ >+/** >+ * Represent a set of irritant flags. Irritants are organized in up to 8 group >+ * of 29, allowing for a maximum of 232 distinct irritants. >+ */ >+public class IrritantSet { >+ >+ // Reserve two high bits for selecting the right bit pattern >+ public final static int GROUP_MASK = ASTNode.Bit32 | ASTNode.Bit31 | ASTNode.Bit30; >+ public final static int GROUP_SHIFT = 29; >+ public final static int GROUP_MAX = 3; // can be increased up to 8 >+ >+ // Group prefix for irritants >+ public final static int GROUP0 = 0 << GROUP_SHIFT; >+ public final static int GROUP1 = 1 << GROUP_SHIFT; >+ public final static int GROUP2 = 2 << GROUP_SHIFT; >+ // reveal subsequent groups as needed >+ // public final static int GROUP3 = 3 << GROUP_SHIFT; >+ // public final static int GROUP4 = 4 << GROUP_SHIFT; >+ // public final static int GROUP5 = 5 << GROUP_SHIFT; >+ // public final static int GROUP6 = 6 << GROUP_SHIFT; >+ // public final static int GROUP7 = 7 << GROUP_SHIFT; >+ >+ // Predefine sets of irritants matching warning tokens >+ public static final IrritantSet ALL = new IrritantSet( >+ 0xFFFFFFFF & ~GROUP_MASK); >+ public static final IrritantSet BOXING = new IrritantSet( >+ CompilerOptions.AutoBoxing); >+ public static final IrritantSet CAST = new IrritantSet( >+ CompilerOptions.UnnecessaryTypeCheck); >+ public static final IrritantSet DEPRECATION = new IrritantSet( >+ CompilerOptions.UsingDeprecatedAPI); >+ public static final IrritantSet DEP_ANN = new IrritantSet( >+ CompilerOptions.MissingDeprecatedAnnotation); >+ public static final IrritantSet FALLTHROUGH = new IrritantSet( >+ CompilerOptions.FallthroughCase); >+ public static final IrritantSet FINALLY = new IrritantSet( >+ CompilerOptions.FinallyBlockNotCompleting); >+ public static final IrritantSet HIDING = new IrritantSet( >+ CompilerOptions.MaskedCatchBlock); // further scenarii in static >+ // initializer >+ public static final IrritantSet INCOMPLETE_SWITCH = new IrritantSet( >+ CompilerOptions.IncompleteEnumSwitch); >+ public static final IrritantSet NLS = new IrritantSet( >+ CompilerOptions.NonExternalizedString); >+ public static final IrritantSet NULL = new IrritantSet( >+ CompilerOptions.NullReference); // further scenarii in static >+ // initializer >+ public static final IrritantSet RESTRICTION = new IrritantSet( >+ CompilerOptions.ForbiddenReference); // further scenarii in static >+ // initializer >+ public static final IrritantSet SERIAL = new IrritantSet( >+ CompilerOptions.MissingSerialVersion); >+ public static final IrritantSet STATIC_ACCESS = new IrritantSet( >+ CompilerOptions.IndirectStaticAccess); // further scenarii in static >+ // initializer >+ public static final IrritantSet SYNTHETIC_ACCESS = new IrritantSet( >+ CompilerOptions.AccessEmulation); >+ public static final IrritantSet SUPER = new IrritantSet( >+ CompilerOptions.OverridingMethodWithoutSuperInvocation); >+ public static final IrritantSet UNUSED = new IrritantSet( >+ CompilerOptions.UnusedLocalVariable); // further scenarii in static >+ // initializer >+ public static final IrritantSet UNCHECKED = new IrritantSet( >+ CompilerOptions.UncheckedTypeOperation); // further scenarii in >+ // static initializer >+ public static final IrritantSet UNQUALIFIED_FIELD_ACCESS = new IrritantSet( >+ CompilerOptions.UnqualifiedFieldAccess); >+ >+ public static final IrritantSet COMPILER_DEFAULT_ERRORS = new IrritantSet(0); // no optional error by default >+ public static final IrritantSet COMPILER_DEFAULT_WARNINGS = new IrritantSet(0); // see static initializer below >+ static { >+ COMPILER_DEFAULT_WARNINGS >+ // group-0 warnings enabled by default >+ .set( >+ CompilerOptions.MethodWithConstructorName >+ | CompilerOptions.OverriddenPackageDefaultMethod >+ | CompilerOptions.UsingDeprecatedAPI >+ | CompilerOptions.MaskedCatchBlock >+ | CompilerOptions.UnusedLocalVariable >+ | CompilerOptions.NoImplicitStringConversion >+ | CompilerOptions.AssertUsedAsAnIdentifier >+ | CompilerOptions.UnusedImport >+ | CompilerOptions.NonStaticAccessToStatic >+ | CompilerOptions.NoEffectAssignment >+ | CompilerOptions.IncompatibleNonInheritedInterfaceMethod >+ | CompilerOptions.UnusedPrivateMember >+ | CompilerOptions.FinallyBlockNotCompleting) >+ // group-1 warnings enabled by default >+ .set( >+ CompilerOptions.UncheckedTypeOperation >+ | CompilerOptions.FinalParameterBound >+ | CompilerOptions.MissingSerialVersion >+ | CompilerOptions.EnumUsedAsAnIdentifier >+ | CompilerOptions.ForbiddenReference >+ | CompilerOptions.VarargsArgumentNeedCast >+ | CompilerOptions.NullReference >+ | CompilerOptions.AnnotationSuperInterface >+ | CompilerOptions.TypeHiding >+ | CompilerOptions.DiscouragedReference >+ | CompilerOptions.UnhandledWarningToken >+ | CompilerOptions.RawTypeReference >+ | CompilerOptions.UnusedLabel >+ | CompilerOptions.UnusedTypeArguments >+ | CompilerOptions.UnusedWarningToken >+ | CompilerOptions.ComparingIdentical >+ | CompilerOptions.MissingSynchronizedModifierInInheritedMethod); >+ // group-2 warnings enabled by default >+ // next irritant goes here (group-1 is complete) >+ >+ ALL.setAll(); >+ HIDING >+ .set(CompilerOptions.FieldHiding) >+ .set(CompilerOptions.LocalVariableHiding) >+ .set(CompilerOptions.TypeHiding); >+ NULL >+ .set(CompilerOptions.PotentialNullReference) >+ .set(CompilerOptions.RedundantNullCheck); >+ RESTRICTION.set(CompilerOptions.DiscouragedReference); >+ STATIC_ACCESS.set(CompilerOptions.NonStaticAccessToStatic); >+ UNUSED >+ .set(CompilerOptions.UnusedArgument) >+ .set(CompilerOptions.UnusedPrivateMember) >+ .set(CompilerOptions.UnusedDeclaredThrownException) >+ .set(CompilerOptions.UnusedLabel) >+ .set(CompilerOptions.UnusedImport) >+ .set(CompilerOptions.UnusedTypeArguments) >+ .set(CompilerOptions.RedundantSuperinterface); >+ UNCHECKED.set(CompilerOptions.RawTypeReference); >+ } >+ >+ // Internal state >+ private int[] bits = new int[GROUP_MAX]; >+ >+ /** >+ * Constructor with initial irritant set >+ */ >+ public IrritantSet(int singleGroupIrritants) { >+ initialize(singleGroupIrritants); >+ } >+ >+ /** >+ * Constructor with initial irritant set >+ */ >+ public IrritantSet(IrritantSet other) { >+ initialize(other); >+ } >+ >+ public boolean areAllSet() { >+ for (int i = 0; i < GROUP_MAX; i++) { >+ if (this.bits[i] != (0xFFFFFFFF & ~GROUP_MASK)) >+ return false; >+ } >+ return true; >+ } >+ >+ public IrritantSet clear(int singleGroupIrritants) { >+ int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT; >+ this.bits[group] &= ~singleGroupIrritants; >+ return this; >+ } >+ >+ public IrritantSet clearAll() { >+ for (int i = 0; i < GROUP_MAX; i++) { >+ this.bits[i] = 0; >+ } >+ return this; >+ } >+ >+ /** >+ * Initialize a set of irritants in one group >+ * >+ * @param singleGroupIrritants >+ */ >+ public void initialize(int singleGroupIrritants) { >+ if (singleGroupIrritants == 0) >+ return; >+ int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT; >+ this.bits[group] = singleGroupIrritants & ~GROUP_MASK; // erase group information >+ } >+ >+ public void initialize(IrritantSet other) { >+ if (other == null) >+ return; >+ System.arraycopy(other.bits, 0, this.bits = new int[GROUP_MAX], 0, GROUP_MAX); >+ } >+ >+ /** >+ * Returns true if any of the irritants in given other set is positionned in receiver >+ * @param other >+ */ >+ public boolean isAnySet(IrritantSet other) { >+ if (other == null) >+ return false; >+ for (int i = 0; i < GROUP_MAX; i++) { >+ if ((this.bits[i] & other.bits[i]) != 0) >+ return true; >+ } >+ return false; >+ } >+ >+ public boolean isSet(int singleGroupIrritants) { >+ int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT; >+ return (this.bits[group] & singleGroupIrritants) != 0; >+ } >+ >+ public IrritantSet set(int singleGroupIrritants) { >+ int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT; >+ this.bits[group] |= (singleGroupIrritants & ~GROUP_MASK); // erase the group bits >+ return this; >+ } >+ >+ /** >+ * Return updated irritantSet or null if it was a no-op >+ * >+ * @param other >+ */ >+ public IrritantSet set(IrritantSet other) { >+ if (other == null) >+ return this; >+ boolean wasNoOp = true; >+ for (int i = 0; i < GROUP_MAX; i++) { >+ int otherIrritant = other.bits[i] & ~GROUP_MASK; // erase the >+ // group >+ // bits >+ if ((this.bits[i] & otherIrritant) != otherIrritant) { >+ wasNoOp = false; >+ this.bits[i] |= otherIrritant; >+ } >+ } >+ return wasNoOp ? null : this; >+ } >+ >+ public IrritantSet setAll() { >+ for (int i = 0; i < GROUP_MAX; i++) { >+ this.bits[i] |= 0xFFFFFFFF & ~GROUP_MASK; // erase the group >+ // bits; >+ } >+ return this; >+ } >+} >#P org.eclipse.jdt.compiler.as >Index: src/org/eclipse/jdt/internal/compiler/as/ActionScriptSourceGenerator.java >=================================================================== >RCS file: /cvsroot/eclipse/e4-incubator/jdt/org.eclipse.jdt.compiler.as/src/org/eclipse/jdt/internal/compiler/as/ActionScriptSourceGenerator.java,v >retrieving revision 1.19 >diff -u -r1.19 ActionScriptSourceGenerator.java >--- src/org/eclipse/jdt/internal/compiler/as/ActionScriptSourceGenerator.java 27 Aug 2008 15:03:30 -0000 1.19 >+++ src/org/eclipse/jdt/internal/compiler/as/ActionScriptSourceGenerator.java 2 Sep 2008 16:02:06 -0000 >@@ -111,7 +111,6 @@ > import org.eclipse.jdt.internal.compiler.lookup.SignatureWrapper; > import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding; > import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding; >-import org.eclipse.jdt.internal.compiler.lookup.TagBits; > import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; > import org.eclipse.jdt.internal.compiler.lookup.TypeIds; >@@ -1889,7 +1888,7 @@ > String errorMessage = Util.appendConstant(this.scriptOutput, constant); > if (errorMessage != null) { > // reportError(scope, errorMessage, qualifiedNameReference); >- reportWarning(scope, "SHOULD BE ERROR - " + errorMessage, qualifiedNameReference); >+ reportWarning(scope, "SHOULD BE ERROR - " + errorMessage, qualifiedNameReference); //$NON-NLS-1$ > } > return false; > } >@@ -1984,7 +1983,7 @@ > String errorMessage = Util.appendConstant(this.scriptOutput, singleNameReference.constant); > if (errorMessage != null) { > // reportError(scope, errorMessage, singleNameReference); >- reportWarning(scope, "SHOULD BE ERROR - " + errorMessage, singleNameReference); >+ reportWarning(scope, "SHOULD BE ERROR - " + errorMessage, singleNameReference); //$NON-NLS-1$ > } > return false; > } >@@ -2410,7 +2409,7 @@ > switch (synthetic.purpose) { > case SyntheticMethodBinding.FieldReadAccess: > printIndent(); >- this.scriptOutput.append(argumentsCount == 0 ? "return " : "return arg0."); //$NON-NLS-1$ >+ this.scriptOutput.append(argumentsCount == 0 ? "return " : "return arg0."); //$NON-NLS-1$ //$NON-NLS-2$ > this.scriptOutput.append(synthetic.targetReadField.name); > this.scriptOutput.append(";\n"); //$NON-NLS-1$ > break; >Index: src/org/eclipse/jdt/internal/compiler/as/CompilerOptions.java >=================================================================== >RCS file: /cvsroot/eclipse/e4-incubator/jdt/org.eclipse.jdt.compiler.as/src/org/eclipse/jdt/internal/compiler/as/CompilerOptions.java,v >retrieving revision 1.2 >diff -u -r1.2 CompilerOptions.java >--- src/org/eclipse/jdt/internal/compiler/as/CompilerOptions.java 27 Aug 2008 15:03:31 -0000 1.2 >+++ src/org/eclipse/jdt/internal/compiler/as/CompilerOptions.java 2 Sep 2008 16:02:06 -0000 >@@ -13,23 +13,27 @@ > import java.util.Map; > > import org.eclipse.jdt.internal.compiler.ast.ASTNode; >+import org.eclipse.jdt.internal.compiler.impl.IrritantSet; > > public class CompilerOptions extends org.eclipse.jdt.internal.compiler.impl.CompilerOptions { >+ > public static final String OPTION_ReportNonConstStaticFinalField = "org.eclipse.jdt.core.compiler.problem.as.nonConstStaticFinalField"; //$NON-NLS-1$ >- public static final long NonConstStaticFinalField = ASTNode.Bit57L; >+ public static final int NonConstStaticFinalField = IrritantSet.GROUP2 + ASTNode.Bit15; // offset behind base compiler irritants > public static final String OPTION_DisableWarnings = "org.eclipse.jdt.core.compiler.problem.disableWarnings"; //$NON-NLS-1$ > > // disable all warnings > public boolean disableWarnings = false; > > public CompilerOptions() { >- this.warningThreshold |= NonConstStaticFinalField; >+ super(); > } >- public CompilerOptions(Map options) { >- this(); >- if (options != null) { >- set(options); >- } >+ public CompilerOptions(Map settings) { >+ super(settings); >+ } >+ >+ protected void resetDefaults() { >+ super.resetDefaults(); >+ this.warningThreshold.set(NonConstStaticFinalField); > } > > public Map getMap() { >@@ -41,21 +45,8 @@ > > public void set(Map optionsMap) { > super.set(optionsMap); >- String optionValue; >- if ((optionValue = (String) optionsMap.get(OPTION_ReportNonConstStaticFinalField)) != null) { >- // inlined (not visible) updateSeverity(NonConstStaticFinalField, optionValue); >- if (ERROR.equals(optionValue)) { >- this.errorThreshold |= NonConstStaticFinalField; >- this.warningThreshold &= ~NonConstStaticFinalField; >- } else if (WARNING.equals(optionValue)) { >- this.errorThreshold &= ~NonConstStaticFinalField; >- this.warningThreshold |= NonConstStaticFinalField; >- } else if (IGNORE.equals(optionValue)) { >- this.errorThreshold &= ~NonConstStaticFinalField; >- this.warningThreshold &= ~NonConstStaticFinalField; >- } >- } >- if ((optionValue = (String) optionsMap.get(CompilerOptions.OPTION_DisableWarnings)) != null) { >+ Object optionValue; >+ if ((optionValue = optionsMap.get(CompilerOptions.OPTION_DisableWarnings)) != null) { > if (ENABLED.equals(optionValue)) { > this.disableWarnings = false; > } else if (DISABLED.equals(optionValue)) {
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
Actions:
View
|
Diff
Attachments on
bug 245973
: 111495