Lines 159-356
Link Here
|
159 |
|
159 |
|
160 |
/** |
160 |
/** |
161 |
* Bit mask for configurable problems (error/warning threshold) |
161 |
* Bit mask for configurable problems (error/warning threshold) |
|
|
162 |
* Note: bitmask assumes 3 highest bits to denote irritant group (to allow storing 8 groups of 29 bits each |
162 |
*/ |
163 |
*/ |
163 |
public static final long MethodWithConstructorName = ASTNode.Bit1; |
164 |
// group 0 |
164 |
public static final long OverriddenPackageDefaultMethod = ASTNode.Bit2; |
165 |
public static final int MethodWithConstructorName = IrritantSet.GROUP0 | ASTNode.Bit1; |
165 |
public static final long UsingDeprecatedAPI = ASTNode.Bit3; |
166 |
public static final int OverriddenPackageDefaultMethod = IrritantSet.GROUP0 | ASTNode.Bit2; |
166 |
public static final long MaskedCatchBlock = ASTNode.Bit4; |
167 |
public static final int UsingDeprecatedAPI = IrritantSet.GROUP0 | ASTNode.Bit3; |
167 |
public static final long UnusedLocalVariable = ASTNode.Bit5; |
168 |
public static final int MaskedCatchBlock = IrritantSet.GROUP0 | ASTNode.Bit4; |
168 |
public static final long UnusedArgument = ASTNode.Bit6; |
169 |
public static final int UnusedLocalVariable = IrritantSet.GROUP0 | ASTNode.Bit5; |
169 |
public static final long NoImplicitStringConversion = ASTNode.Bit7; |
170 |
public static final int UnusedArgument = IrritantSet.GROUP0 | ASTNode.Bit6; |
170 |
public static final long AccessEmulation = ASTNode.Bit8; |
171 |
public static final int NoImplicitStringConversion = IrritantSet.GROUP0 | ASTNode.Bit7; |
171 |
public static final long NonExternalizedString = ASTNode.Bit9; |
172 |
public static final int AccessEmulation = IrritantSet.GROUP0 | ASTNode.Bit8; |
172 |
public static final long AssertUsedAsAnIdentifier = ASTNode.Bit10; |
173 |
public static final int NonExternalizedString = IrritantSet.GROUP0 | ASTNode.Bit9; |
173 |
public static final long UnusedImport = ASTNode.Bit11; |
174 |
public static final int AssertUsedAsAnIdentifier = IrritantSet.GROUP0 | ASTNode.Bit10; |
174 |
public static final long NonStaticAccessToStatic = ASTNode.Bit12; |
175 |
public static final int UnusedImport = IrritantSet.GROUP0 | ASTNode.Bit11; |
175 |
public static final long Task = ASTNode.Bit13; |
176 |
public static final int NonStaticAccessToStatic = IrritantSet.GROUP0 | ASTNode.Bit12; |
176 |
public static final long NoEffectAssignment = ASTNode.Bit14; |
177 |
public static final int Task = IrritantSet.GROUP0 | ASTNode.Bit13; |
177 |
public static final long IncompatibleNonInheritedInterfaceMethod = ASTNode.Bit15; |
178 |
public static final int NoEffectAssignment = IrritantSet.GROUP0 | ASTNode.Bit14; |
178 |
public static final long UnusedPrivateMember = ASTNode.Bit16; |
179 |
public static final int IncompatibleNonInheritedInterfaceMethod = IrritantSet.GROUP0 | ASTNode.Bit15; |
179 |
public static final long LocalVariableHiding = ASTNode.Bit17; |
180 |
public static final int UnusedPrivateMember = IrritantSet.GROUP0 | ASTNode.Bit16; |
180 |
public static final long FieldHiding = ASTNode.Bit18; |
181 |
public static final int LocalVariableHiding = IrritantSet.GROUP0 | ASTNode.Bit17; |
181 |
public static final long AccidentalBooleanAssign = ASTNode.Bit19; |
182 |
public static final int FieldHiding = IrritantSet.GROUP0 | ASTNode.Bit18; |
182 |
public static final long EmptyStatement = ASTNode.Bit20; |
183 |
public static final int AccidentalBooleanAssign = IrritantSet.GROUP0 | ASTNode.Bit19; |
183 |
public static final long MissingJavadocComments = ASTNode.Bit21; |
184 |
public static final int EmptyStatement = IrritantSet.GROUP0 | ASTNode.Bit20; |
184 |
public static final long MissingJavadocTags = ASTNode.Bit22; |
185 |
public static final int MissingJavadocComments = IrritantSet.GROUP0 | ASTNode.Bit21; |
185 |
public static final long UnqualifiedFieldAccess = ASTNode.Bit23; |
186 |
public static final int MissingJavadocTags = IrritantSet.GROUP0 | ASTNode.Bit22; |
186 |
public static final long UnusedDeclaredThrownException = ASTNode.Bit24; |
187 |
public static final int UnqualifiedFieldAccess = IrritantSet.GROUP0 | ASTNode.Bit23; |
187 |
public static final long FinallyBlockNotCompleting = ASTNode.Bit25; |
188 |
public static final int UnusedDeclaredThrownException = IrritantSet.GROUP0 | ASTNode.Bit24; |
188 |
public static final long InvalidJavadoc = ASTNode.Bit26; |
189 |
public static final int FinallyBlockNotCompleting = IrritantSet.GROUP0 | ASTNode.Bit25; |
189 |
public static final long UnnecessaryTypeCheck = ASTNode.Bit27; |
190 |
public static final int InvalidJavadoc = IrritantSet.GROUP0 | ASTNode.Bit26; |
190 |
public static final long UndocumentedEmptyBlock = ASTNode.Bit28; |
191 |
public static final int UnnecessaryTypeCheck = IrritantSet.GROUP0 | ASTNode.Bit27; |
191 |
public static final long IndirectStaticAccess = ASTNode.Bit29; |
192 |
public static final int UndocumentedEmptyBlock = IrritantSet.GROUP0 | ASTNode.Bit28; |
192 |
public static final long UnnecessaryElse = ASTNode.Bit30; |
193 |
public static final int IndirectStaticAccess = IrritantSet.GROUP0 | ASTNode.Bit29; |
193 |
public static final long UncheckedTypeOperation = ASTNode.Bit31; |
194 |
|
194 |
public static final long FinalParameterBound = ASTNode.Bit32L; |
195 |
// group 1 |
195 |
public static final long MissingSerialVersion = ASTNode.Bit33L; |
196 |
public static final int UnnecessaryElse = IrritantSet.GROUP1 | ASTNode.Bit1; |
196 |
public static final long EnumUsedAsAnIdentifier = ASTNode.Bit34L; |
197 |
public static final int UncheckedTypeOperation = IrritantSet.GROUP1 | ASTNode.Bit2; |
197 |
public static final long ForbiddenReference = ASTNode.Bit35L; |
198 |
public static final int FinalParameterBound = IrritantSet.GROUP1 | ASTNode.Bit3; |
198 |
public static final long VarargsArgumentNeedCast = ASTNode.Bit36L; |
199 |
public static final int MissingSerialVersion = IrritantSet.GROUP1 | ASTNode.Bit4; |
199 |
public static final long NullReference = ASTNode.Bit37L; |
200 |
public static final int EnumUsedAsAnIdentifier = IrritantSet.GROUP1 | ASTNode.Bit5; |
200 |
public static final long AutoBoxing = ASTNode.Bit38L; |
201 |
public static final int ForbiddenReference = IrritantSet.GROUP1 | ASTNode.Bit6; |
201 |
public static final long AnnotationSuperInterface = ASTNode.Bit39L; |
202 |
public static final int VarargsArgumentNeedCast = IrritantSet.GROUP1 | ASTNode.Bit7; |
202 |
public static final long TypeHiding = ASTNode.Bit40L; |
203 |
public static final int NullReference = IrritantSet.GROUP1 | ASTNode.Bit8; |
203 |
public static final long MissingOverrideAnnotation = ASTNode.Bit41L; |
204 |
public static final int AutoBoxing = IrritantSet.GROUP1 | ASTNode.Bit9; |
204 |
public static final long IncompleteEnumSwitch = ASTNode.Bit42L; |
205 |
public static final int AnnotationSuperInterface = IrritantSet.GROUP1 | ASTNode.Bit10; |
205 |
public static final long MissingDeprecatedAnnotation = ASTNode.Bit43L; |
206 |
public static final int TypeHiding = IrritantSet.GROUP1 | ASTNode.Bit11; |
206 |
public static final long DiscouragedReference = ASTNode.Bit44L; |
207 |
public static final int MissingOverrideAnnotation = IrritantSet.GROUP1 | ASTNode.Bit12; |
207 |
public static final long UnhandledWarningToken = ASTNode.Bit45L; |
208 |
public static final int IncompleteEnumSwitch = IrritantSet.GROUP1 | ASTNode.Bit13; |
208 |
public static final long RawTypeReference = ASTNode.Bit46L; |
209 |
public static final int MissingDeprecatedAnnotation = IrritantSet.GROUP1 | ASTNode.Bit14; |
209 |
public static final long UnusedLabel = ASTNode.Bit47L; |
210 |
public static final int DiscouragedReference = IrritantSet.GROUP1 | ASTNode.Bit15; |
210 |
public static final long ParameterAssignment = ASTNode.Bit48L; |
211 |
public static final int UnhandledWarningToken = IrritantSet.GROUP1 | ASTNode.Bit16; |
211 |
public static final long FallthroughCase = ASTNode.Bit49L; |
212 |
public static final int RawTypeReference = IrritantSet.GROUP1 | ASTNode.Bit17; |
212 |
public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L; |
213 |
public static final int UnusedLabel = IrritantSet.GROUP1 | ASTNode.Bit18; |
213 |
public static final long PotentialNullReference = ASTNode.Bit51L; |
214 |
public static final int ParameterAssignment = IrritantSet.GROUP1 | ASTNode.Bit19; |
214 |
public static final long RedundantNullCheck = ASTNode.Bit52L; |
215 |
public static final int FallthroughCase = IrritantSet.GROUP1 | ASTNode.Bit20; |
215 |
public static final long MissingJavadocTagDescription = ASTNode.Bit53L; |
216 |
public static final int OverridingMethodWithoutSuperInvocation = IrritantSet.GROUP1 | ASTNode.Bit21; |
216 |
public static final long UnusedTypeArguments = ASTNode.Bit54L; |
217 |
public static final int PotentialNullReference = IrritantSet.GROUP1 | ASTNode.Bit22; |
217 |
public static final long UnusedWarningToken = ASTNode.Bit55L; |
218 |
public static final int RedundantNullCheck = IrritantSet.GROUP1 | ASTNode.Bit23; |
218 |
public static final long RedundantSuperinterface = ASTNode.Bit56L; |
219 |
public static final int MissingJavadocTagDescription = IrritantSet.GROUP1 | ASTNode.Bit24; |
219 |
public static final long ComparingIdentical = ASTNode.Bit57L; |
220 |
public static final int UnusedTypeArguments = IrritantSet.GROUP1 | ASTNode.Bit25; |
220 |
public static final long MissingSynchronizedModifierInInheritedMethod= ASTNode.Bit58L; |
221 |
public static final int UnusedWarningToken = IrritantSet.GROUP1 | ASTNode.Bit26; |
221 |
|
222 |
public static final int RedundantSuperinterface = IrritantSet.GROUP1 | ASTNode.Bit27; |
|
|
223 |
public static final int ComparingIdentical = IrritantSet.GROUP1 | ASTNode.Bit28; |
224 |
public static final int MissingSynchronizedModifierInInheritedMethod= IrritantSet.GROUP1 | ASTNode.Bit29; |
225 |
|
226 |
// group 2 |
227 |
// NEXT IRRITANT GOES HERE (group1 is complete already) |
228 |
// public static final int FirstInGroup2 = IrritantSet.GROUP2 | ASTNode.Bit1; |
229 |
|
222 |
// Map: String optionKey --> Long irritant> |
230 |
// Map: String optionKey --> Long irritant> |
223 |
private static Map OptionToIrritants; |
231 |
private static Map OptionToIrritants; |
224 |
|
232 |
|
225 |
// Default severity level for handlers |
233 |
// Severity level for handlers |
226 |
public long errorThreshold = 0; |
234 |
/** |
|
|
235 |
* Defaults defined at {@lnk IrritantSet#COMPILER_DEFAULT_ERRORS} |
236 |
* @see #resetDefaults() |
237 |
*/ |
238 |
protected IrritantSet errorThreshold; |
239 |
/** |
240 |
* Defaults defined at {@lnk IrritantSet#COMPILER_DEFAULT_WARNINGS} |
241 |
* @see #resetDefaults() |
242 |
*/ |
243 |
protected IrritantSet warningThreshold; |
244 |
|
245 |
/** |
246 |
* Default settings are to be defined in {@lnk CompilerOptions#resetDefaults()} |
247 |
*/ |
248 |
|
249 |
/** Classfile debug information, may contain source file name, line numbers, local variable tables, etc... */ |
250 |
public int produceDebugAttributes; |
251 |
/** Compliance level for the compiler, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */ |
252 |
public long complianceLevel; |
253 |
/** Java source level, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */ |
254 |
public long sourceLevel; |
255 |
/** VM target level, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */ |
256 |
public long targetJDK; |
257 |
/** Source encoding format */ |
258 |
public String defaultEncoding; |
259 |
/** Compiler trace verbosity */ |
260 |
public boolean verbose; |
261 |
/** Indicates whether reference info is desired */ |
262 |
public boolean produceReferenceInfo; |
263 |
/** Indicates if unused/optimizable local variables need to be preserved (debugging purpose) */ |
264 |
public boolean preserveAllLocalVariables; |
265 |
/** Indicates whether literal expressions are inlined at parse-time or not */ |
266 |
public boolean parseLiteralExpressionsAsConstants; |
267 |
/** Max problems per compilation unit */ |
268 |
public int maxProblemsPerUnit; |
269 |
/** Tags used to recognize tasks in comments */ |
270 |
public char[][] taskTags; |
271 |
/** Respective priorities of recognized task tags */ |
272 |
public char[][] taskPriorites; |
273 |
/** Indicate whether tag detection is case sensitive or not */ |
274 |
public boolean isTaskCaseSensitive; |
275 |
/** Specify whether deprecation inside deprecated code is to be reported */ |
276 |
public boolean reportDeprecationInsideDeprecatedCode; |
277 |
/** Specify whether override of deprecated method is to be reported */ |
278 |
public boolean reportDeprecationWhenOverridingDeprecatedMethod; |
279 |
/** Specify if should report unused parameter when implementing abstract method */ |
280 |
public boolean reportUnusedParameterWhenImplementingAbstract; |
281 |
/** Specify if should report unused parameter when overriding concrete method */ |
282 |
public boolean reportUnusedParameterWhenOverridingConcrete; |
283 |
/** Specify if should report documented unused parameter (in javadoc) */ |
284 |
public boolean reportUnusedParameterIncludeDocCommentReference; |
285 |
/** Specify if should reported unused declared thrown exception when overriding method */ |
286 |
public boolean reportUnusedDeclaredThrownExceptionWhenOverriding; |
287 |
/** Specify if should reported unused declared thrown exception when documented in javadoc */ |
288 |
public boolean reportUnusedDeclaredThrownExceptionIncludeDocCommentReference; |
289 |
/** Specify if should reported unused declared thrown exception when Exception or Throwable */ |
290 |
public boolean reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable; |
291 |
/** Specify whether should report constructor/setter method parameter hiding */ |
292 |
public boolean reportSpecialParameterHidingField; |
293 |
/** Master flag controlling whether doc comment should be processed */ |
294 |
public boolean docCommentSupport; |
295 |
/** Specify if invalid javadoc shall be reported */ |
296 |
public boolean reportInvalidJavadocTags; |
297 |
/** Only report invalid javadoc above a given level of visibility of associated construct */ |
298 |
public int reportInvalidJavadocTagsVisibility; |
299 |
/** Specify if deprecated javadoc ref is allowed */ |
300 |
public boolean reportInvalidJavadocTagsDeprecatedRef; |
301 |
/** Specify if non visible javadoc ref is allowed */ |
302 |
public boolean reportInvalidJavadocTagsNotVisibleRef; |
303 |
/** Specify when to report missing javadoc tag description */ |
304 |
public String reportMissingJavadocTagDescription; |
305 |
/** Only report missing javadoc tags above a given level of visibility of associated construct */ |
306 |
public int reportMissingJavadocTagsVisibility; |
307 |
/** Specify if need to flag missing javadoc tags for overriding method */ |
308 |
public boolean reportMissingJavadocTagsOverriding; |
309 |
/** Only report missing javadoc comment above a given level of visibility of associated construct */ |
310 |
public int reportMissingJavadocCommentsVisibility; |
311 |
/** Specify if need to flag missing javadoc comment for overriding method */ |
312 |
public boolean reportMissingJavadocCommentsOverriding; |
313 |
/** Indicate whether the JSR bytecode should be inlined to avoid its presence in classfile */ |
314 |
public boolean inlineJsrBytecode; |
315 |
/** Indicate if @SuppressWarning annotation are activated */ |
316 |
public boolean suppressWarnings; |
317 |
/** Specify if should treat optional error as fatal or just like warning */ |
318 |
public boolean treatOptionalErrorAsFatal; |
319 |
/** Specify if parser should perform structural recovery in methods */ |
320 |
public boolean performMethodsFullRecovery; |
321 |
/** Specify if parser perform statements recovery */ |
322 |
public boolean performStatementsRecovery; |
323 |
/** Control whether annotation processing is enabled */ |
324 |
public boolean processAnnotations; |
325 |
/** Store annotations */ |
326 |
public boolean storeAnnotations; |
327 |
/** Indicate if annotation processing generates classfiles */ |
328 |
public boolean generateClassFiles; |
329 |
|
330 |
|
331 |
// keep in sync with warningTokenToIrritant and warningTokenFromIrritant |
332 |
public final static String[] warningTokens = { |
333 |
"all", //$NON-NLS-1$ |
334 |
"boxing", //$NON-NLS-1$ |
335 |
"cast", //$NON-NLS-1$ |
336 |
"dep-ann", //$NON-NLS-1$ |
337 |
"deprecation", //$NON-NLS-1$ |
338 |
"fallthrough", //$NON-NLS-1$ |
339 |
"finally", //$NON-NLS-1$ |
340 |
"hiding", //$NON-NLS-1$ |
341 |
"incomplete-switch", //$NON-NLS-1$ |
342 |
"nls", //$NON-NLS-1$ |
343 |
"null", //$NON-NLS-1$ |
344 |
"restriction", //$NON-NLS-1$ |
345 |
"serial", //$NON-NLS-1$ |
346 |
"static-access", //$NON-NLS-1$ |
347 |
"super", //$NON-NLS-1$ |
348 |
"synthetic-access", //$NON-NLS-1$ |
349 |
"unchecked", //$NON-NLS-1$ |
350 |
"unqualified-field-access", //$NON-NLS-1$ |
351 |
"unused", //$NON-NLS-1$ |
352 |
}; |
227 |
|
353 |
|
228 |
public long warningThreshold = |
354 |
/** |
229 |
MethodWithConstructorName |
355 |
* Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by |
230 |
| UsingDeprecatedAPI |
356 |
* other master options (e.g. javadoc, deprecation, etc.). |
231 |
| MaskedCatchBlock |
357 |
* This information is intended for grouping purpose (several problems governed by a rule) |
232 |
| OverriddenPackageDefaultMethod |
358 |
*/ |
233 |
| UnusedImport |
359 |
public static String optionKeyFromIrritant(int irritant) { |
234 |
| NonStaticAccessToStatic |
360 |
// keep in sync with warningTokens and warningTokenToIrritant |
235 |
| NoEffectAssignment |
361 |
switch (irritant) { |
236 |
| IncompatibleNonInheritedInterfaceMethod |
362 |
case MethodWithConstructorName : |
237 |
| NoImplicitStringConversion |
363 |
return OPTION_ReportMethodWithConstructorName; |
238 |
| FinallyBlockNotCompleting |
364 |
case OverriddenPackageDefaultMethod : |
239 |
| AssertUsedAsAnIdentifier |
365 |
return OPTION_ReportOverridingPackageDefaultMethod; |
240 |
| EnumUsedAsAnIdentifier |
366 |
case UsingDeprecatedAPI : |
241 |
| UncheckedTypeOperation |
367 |
case (InvalidJavadoc | UsingDeprecatedAPI) : |
242 |
| RawTypeReference |
368 |
return OPTION_ReportDeprecation; |
243 |
| MissingSerialVersion |
369 |
case MaskedCatchBlock : |
244 |
| VarargsArgumentNeedCast |
370 |
return OPTION_ReportHiddenCatchBlock; |
245 |
| ForbiddenReference |
371 |
case UnusedLocalVariable : |
246 |
| DiscouragedReference |
372 |
return OPTION_ReportUnusedLocal; |
247 |
| AnnotationSuperInterface |
373 |
case UnusedArgument : |
248 |
| TypeHiding |
374 |
return OPTION_ReportUnusedParameter; |
249 |
| FinalParameterBound |
375 |
case NoImplicitStringConversion : |
250 |
| UnhandledWarningToken |
376 |
return OPTION_ReportNoImplicitStringConversion; |
251 |
| UnusedLocalVariable |
377 |
case AccessEmulation : |
252 |
| UnusedPrivateMember |
378 |
return OPTION_ReportSyntheticAccessEmulation; |
253 |
| UnusedLabel |
379 |
case NonExternalizedString : |
254 |
| UnusedTypeArguments |
380 |
return OPTION_ReportNonExternalizedStringLiteral; |
255 |
| NullReference |
381 |
case AssertUsedAsAnIdentifier : |
256 |
| UnusedWarningToken |
382 |
return OPTION_ReportAssertIdentifier; |
257 |
| ComparingIdentical |
383 |
case UnusedImport : |
258 |
| MissingSynchronizedModifierInInheritedMethod; |
384 |
return OPTION_ReportUnusedImport; |
259 |
|
385 |
case NonStaticAccessToStatic : |
260 |
// By default only lines and source attributes are generated. |
386 |
return OPTION_ReportNonStaticAccessToStatic; |
261 |
public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES; |
387 |
case Task : |
262 |
|
388 |
return OPTION_TaskTags; |
263 |
public long complianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4 |
389 |
case NoEffectAssignment : |
264 |
public long sourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default |
390 |
return OPTION_ReportNoEffectAssignment; |
265 |
public long targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2 |
391 |
case IncompatibleNonInheritedInterfaceMethod : |
266 |
|
392 |
return OPTION_ReportIncompatibleNonInheritedInterfaceMethod; |
267 |
// source encoding format |
393 |
case UnusedPrivateMember : |
268 |
public String defaultEncoding = null; // will use the platform default encoding |
394 |
return OPTION_ReportUnusedPrivateMember; |
269 |
|
395 |
case LocalVariableHiding : |
270 |
// print what unit is being processed |
396 |
return OPTION_ReportLocalVariableHiding; |
271 |
public boolean verbose = Compiler.DEBUG; |
397 |
case FieldHiding : |
272 |
|
398 |
return OPTION_ReportFieldHiding; |
273 |
// indicates if reference info is desired |
399 |
case AccidentalBooleanAssign : |
274 |
public boolean produceReferenceInfo = false; |
400 |
return OPTION_ReportPossibleAccidentalBooleanAssignment; |
275 |
|
401 |
case EmptyStatement : |
276 |
// indicates if unused/optimizable local variables need to be preserved (debugging purpose) |
402 |
return OPTION_ReportEmptyStatement; |
277 |
public boolean preserveAllLocalVariables = false; |
403 |
case MissingJavadocComments : |
278 |
|
404 |
return OPTION_ReportMissingJavadocComments; |
279 |
// indicates whether literal expressions are inlined at parse-time or not |
405 |
case MissingJavadocTags : |
280 |
public boolean parseLiteralExpressionsAsConstants = true; |
406 |
return OPTION_ReportMissingJavadocTags; |
281 |
|
407 |
case UnqualifiedFieldAccess : |
282 |
// max problems per compilation unit |
408 |
return OPTION_ReportUnqualifiedFieldAccess; |
283 |
public int maxProblemsPerUnit = 100; // no more than 100 problems per default |
409 |
case UnusedDeclaredThrownException : |
284 |
|
410 |
return OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding; |
285 |
// tags used to recognize tasks in comments |
411 |
case FinallyBlockNotCompleting : |
286 |
public char[][] taskTags = null; |
412 |
return OPTION_ReportFinallyBlockNotCompletingNormally; |
287 |
public char[][] taskPriorites = null; |
413 |
case InvalidJavadoc : |
288 |
public boolean isTaskCaseSensitive = true; |
414 |
return OPTION_ReportInvalidJavadoc; |
289 |
|
415 |
case UnnecessaryTypeCheck : |
290 |
// deprecation report |
416 |
return OPTION_ReportUnnecessaryTypeCheck; |
291 |
public boolean reportDeprecationInsideDeprecatedCode = false; |
417 |
case UndocumentedEmptyBlock : |
292 |
public boolean reportDeprecationWhenOverridingDeprecatedMethod = false; |
418 |
return OPTION_ReportUndocumentedEmptyBlock; |
293 |
|
419 |
case IndirectStaticAccess : |
294 |
// unused parameters report |
420 |
return OPTION_ReportIndirectStaticAccess; |
295 |
public boolean reportUnusedParameterWhenImplementingAbstract = false; |
421 |
case UnnecessaryElse : |
296 |
public boolean reportUnusedParameterWhenOverridingConcrete = false; |
422 |
return OPTION_ReportUnnecessaryElse; |
297 |
public boolean reportUnusedParameterIncludeDocCommentReference = true; |
423 |
case UncheckedTypeOperation : |
298 |
|
424 |
return OPTION_ReportUncheckedTypeOperation; |
299 |
// unused declaration of thrown exception |
425 |
case FinalParameterBound : |
300 |
public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false; |
426 |
return OPTION_ReportFinalParameterBound; |
301 |
public boolean reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = true; |
427 |
case MissingSerialVersion : |
302 |
public boolean reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = true; |
428 |
return OPTION_ReportMissingSerialVersion ; |
303 |
|
429 |
case EnumUsedAsAnIdentifier : |
304 |
// constructor/setter parameter hiding |
430 |
return OPTION_ReportEnumIdentifier; |
305 |
public boolean reportSpecialParameterHidingField = false; |
431 |
case ForbiddenReference : |
306 |
|
432 |
return OPTION_ReportForbiddenReference; |
307 |
// check javadoc comments tags |
433 |
case VarargsArgumentNeedCast : |
308 |
public int reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic; |
434 |
return OPTION_ReportVarargsArgumentNeedCast; |
309 |
public boolean reportInvalidJavadocTags = false; |
435 |
case NullReference : |
310 |
public boolean reportInvalidJavadocTagsDeprecatedRef = false; |
436 |
return OPTION_ReportNullReference; |
311 |
public boolean reportInvalidJavadocTagsNotVisibleRef = false; |
437 |
case PotentialNullReference : |
312 |
public String reportMissingJavadocTagDescription = RETURN_TAG; |
438 |
return OPTION_ReportPotentialNullReference; |
313 |
|
439 |
case RedundantNullCheck : |
314 |
// check missing javadoc tags |
440 |
return OPTION_ReportRedundantNullCheck; |
315 |
public int reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic; |
441 |
case AutoBoxing : |
316 |
public boolean reportMissingJavadocTagsOverriding = false; |
442 |
return OPTION_ReportAutoboxing; |
317 |
|
443 |
case AnnotationSuperInterface : |
318 |
// check missing javadoc comments |
444 |
return OPTION_ReportAnnotationSuperInterface; |
319 |
public int reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic; |
445 |
case TypeHiding : |
320 |
public boolean reportMissingJavadocCommentsOverriding = false; |
446 |
return OPTION_ReportTypeParameterHiding; |
321 |
|
447 |
case MissingOverrideAnnotation : |
322 |
// JSR bytecode inlining |
448 |
return OPTION_ReportMissingOverrideAnnotation; |
323 |
public boolean inlineJsrBytecode = false; |
449 |
case IncompleteEnumSwitch : |
324 |
|
450 |
return OPTION_ReportIncompleteEnumSwitch; |
325 |
// javadoc comment support |
451 |
case MissingDeprecatedAnnotation : |
326 |
public boolean docCommentSupport = false; |
452 |
return OPTION_ReportMissingDeprecatedAnnotation; |
327 |
|
453 |
case DiscouragedReference : |
328 |
// suppress warning annotation |
454 |
return OPTION_ReportDiscouragedReference; |
329 |
public boolean suppressWarnings = true; |
455 |
case UnhandledWarningToken : |
330 |
|
456 |
return OPTION_ReportUnhandledWarningToken; |
331 |
// treat optional error as fatal or just like warning? |
457 |
case RawTypeReference : |
332 |
public boolean treatOptionalErrorAsFatal = true; |
458 |
return OPTION_ReportRawTypeReference; |
333 |
|
459 |
case UnusedLabel : |
334 |
// parser perform statements recovery |
460 |
return OPTION_ReportUnusedLabel; |
335 |
public boolean performMethodsFullRecovery = true; |
461 |
case ParameterAssignment : |
336 |
|
462 |
return OPTION_ReportParameterAssignment; |
337 |
// parser perform statements recovery |
463 |
case FallthroughCase : |
338 |
public boolean performStatementsRecovery = true; |
464 |
return OPTION_ReportFallthroughCase; |
|
|
465 |
case OverridingMethodWithoutSuperInvocation : |
466 |
return OPTION_ReportOverridingMethodWithoutSuperInvocation; |
467 |
case MissingJavadocTagDescription : |
468 |
return OPTION_ReportMissingJavadocTagDescription; |
469 |
case UnusedTypeArguments : |
470 |
return OPTION_ReportUnusedTypeArgumentsForMethodInvocation; |
471 |
case UnusedWarningToken : |
472 |
return OPTION_ReportUnusedWarningToken; |
473 |
case RedundantSuperinterface : |
474 |
return OPTION_ReportRedundantSuperinterface; |
475 |
case ComparingIdentical : |
476 |
return OPTION_ReportComparingIdentical; |
477 |
case MissingSynchronizedModifierInInheritedMethod : |
478 |
return OPTION_ReportMissingSynchronizedOnInheritedMethod; |
479 |
} |
480 |
return null; |
481 |
} |
339 |
|
482 |
|
340 |
// store annotations |
483 |
public static long optionKeyToIrritant(String optionName) { |
341 |
public boolean storeAnnotations = false; |
484 |
if (OptionToIrritants == null) { |
|
|
485 |
int group = 0; |
486 |
for (int g = 0; g < 8; g++) { |
487 |
group <<= 1; |
488 |
int index = 0; |
489 |
for (int i = 0; i < 30; i++) { |
490 |
index <<= 1; |
491 |
int irritant = (group<<IrritantSet.GROUP_SHIFT)+index; |
492 |
String optionKey = optionKeyFromIrritant(irritant); |
493 |
if (optionKey == null) continue; |
494 |
OptionToIrritants.put(optionKey, new Integer(irritant)); |
495 |
} |
496 |
|
497 |
} |
498 |
} |
499 |
Long irritant = (Long)OptionToIrritants.get(optionName); |
500 |
return irritant == null ? 0 : irritant.longValue(); |
501 |
} |
342 |
|
502 |
|
343 |
// annotation processing |
503 |
public static String versionFromJdkLevel(long jdkLevel) { |
344 |
public boolean generateClassFiles = true; |
504 |
switch ((int)(jdkLevel>>16)) { |
|
|
505 |
case ClassFileConstants.MAJOR_VERSION_1_1 : |
506 |
if (jdkLevel == ClassFileConstants.JDK1_1) |
507 |
return VERSION_1_1; |
508 |
break; |
509 |
case ClassFileConstants.MAJOR_VERSION_1_2 : |
510 |
if (jdkLevel == ClassFileConstants.JDK1_2) |
511 |
return VERSION_1_2; |
512 |
break; |
513 |
case ClassFileConstants.MAJOR_VERSION_1_3 : |
514 |
if (jdkLevel == ClassFileConstants.JDK1_3) |
515 |
return VERSION_1_3; |
516 |
break; |
517 |
case ClassFileConstants.MAJOR_VERSION_1_4 : |
518 |
if (jdkLevel == ClassFileConstants.JDK1_4) |
519 |
return VERSION_1_4; |
520 |
break; |
521 |
case ClassFileConstants.MAJOR_VERSION_1_5 : |
522 |
if (jdkLevel == ClassFileConstants.JDK1_5) |
523 |
return VERSION_1_5; |
524 |
break; |
525 |
case ClassFileConstants.MAJOR_VERSION_1_6 : |
526 |
if (jdkLevel == ClassFileConstants.JDK1_6) |
527 |
return VERSION_1_6; |
528 |
break; |
529 |
case ClassFileConstants.MAJOR_VERSION_1_7 : |
530 |
if (jdkLevel == ClassFileConstants.JDK1_7) |
531 |
return VERSION_1_7; |
532 |
break; |
533 |
} |
534 |
return Util.EMPTY_STRING; // unknown version |
535 |
} |
345 |
|
536 |
|
346 |
// Enable annotation processing by default only in batch mode |
537 |
public static long versionToJdkLevel(Object versionID) { |
347 |
public boolean processAnnotations = false; |
538 |
if (versionID instanceof String) { |
|
|
539 |
String version = (String) versionID; |
540 |
// verification is optimized for all versions with same length and same "1." prefix |
541 |
if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') { |
542 |
switch (version.charAt(2)) { |
543 |
case '1': |
544 |
return ClassFileConstants.JDK1_1; |
545 |
case '2': |
546 |
return ClassFileConstants.JDK1_2; |
547 |
case '3': |
548 |
return ClassFileConstants.JDK1_3; |
549 |
case '4': |
550 |
return ClassFileConstants.JDK1_4; |
551 |
case '5': |
552 |
return ClassFileConstants.JDK1_5; |
553 |
case '6': |
554 |
return ClassFileConstants.JDK1_6; |
555 |
case '7': |
556 |
return ClassFileConstants.JDK1_7; |
557 |
default: |
558 |
return 0; // unknown |
559 |
} |
560 |
} |
561 |
if (VERSION_JSR14.equals(versionID)) { |
562 |
return ClassFileConstants.JDK1_4; |
563 |
} |
564 |
if (VERSION_CLDC1_1.equals(versionID)) { |
565 |
return ClassFileConstants.CLDC_1_1; |
566 |
} |
567 |
} |
568 |
return 0; // unknown |
569 |
} |
570 |
|
571 |
/** |
572 |
* Return all warning option names for use as keys in compiler options maps. |
573 |
* @return all warning option names |
574 |
* TODO (maxime) revise for ensuring completeness |
575 |
*/ |
576 |
public static String[] warningOptionNames() { |
577 |
String[] result = { |
578 |
OPTION_ReportAnnotationSuperInterface, |
579 |
OPTION_ReportAssertIdentifier, |
580 |
OPTION_ReportAutoboxing, |
581 |
OPTION_ReportDeprecation, |
582 |
OPTION_ReportDiscouragedReference, |
583 |
OPTION_ReportEmptyStatement, |
584 |
OPTION_ReportEnumIdentifier, |
585 |
OPTION_ReportFallthroughCase, |
586 |
OPTION_ReportFieldHiding, |
587 |
OPTION_ReportFinalParameterBound, |
588 |
OPTION_ReportFinallyBlockNotCompletingNormally, |
589 |
OPTION_ReportForbiddenReference, |
590 |
OPTION_ReportHiddenCatchBlock, |
591 |
OPTION_ReportIncompatibleNonInheritedInterfaceMethod, |
592 |
OPTION_ReportIncompleteEnumSwitch, |
593 |
OPTION_ReportIndirectStaticAccess, |
594 |
OPTION_ReportInvalidJavadoc, |
595 |
OPTION_ReportLocalVariableHiding, |
596 |
OPTION_ReportMethodWithConstructorName, |
597 |
OPTION_ReportMissingDeprecatedAnnotation, |
598 |
OPTION_ReportMissingJavadocComments, |
599 |
OPTION_ReportMissingJavadocTagDescription, |
600 |
OPTION_ReportMissingJavadocTags, |
601 |
OPTION_ReportMissingOverrideAnnotation, |
602 |
OPTION_ReportMissingSerialVersion, |
603 |
OPTION_ReportNoEffectAssignment, |
604 |
OPTION_ReportNoImplicitStringConversion, |
605 |
OPTION_ReportNonExternalizedStringLiteral, |
606 |
OPTION_ReportNonStaticAccessToStatic, |
607 |
OPTION_ReportNullReference, |
608 |
OPTION_ReportPotentialNullReference, |
609 |
OPTION_ReportRedundantNullCheck, |
610 |
OPTION_ReportRedundantSuperinterface, |
611 |
OPTION_ReportOverridingPackageDefaultMethod, |
612 |
OPTION_ReportParameterAssignment, |
613 |
OPTION_ReportPossibleAccidentalBooleanAssignment, |
614 |
OPTION_ReportSyntheticAccessEmulation, |
615 |
OPTION_ReportTypeParameterHiding, |
616 |
OPTION_ReportUncheckedTypeOperation, |
617 |
OPTION_ReportUndocumentedEmptyBlock, |
618 |
OPTION_ReportUnnecessaryElse, |
619 |
OPTION_ReportUnnecessaryTypeCheck, |
620 |
OPTION_ReportUnqualifiedFieldAccess, |
621 |
OPTION_ReportUnusedDeclaredThrownException, |
622 |
OPTION_ReportUnusedImport, |
623 |
OPTION_ReportUnusedLocal, |
624 |
OPTION_ReportUnusedParameter, |
625 |
OPTION_ReportUnusedPrivateMember, |
626 |
OPTION_ReportVarargsArgumentNeedCast, |
627 |
OPTION_ReportUnhandledWarningToken, |
628 |
OPTION_ReportUnusedWarningToken, |
629 |
OPTION_ReportOverridingMethodWithoutSuperInvocation, |
630 |
OPTION_ReportUnusedTypeArgumentsForMethodInvocation, |
631 |
}; |
632 |
return result; |
633 |
} |
634 |
|
635 |
/** |
636 |
* For suppressable warnings |
637 |
*/ |
638 |
public static String warningTokenFromIrritant(int irritant) { |
639 |
// keep in sync with warningTokens and warningTokenToIrritant |
640 |
switch (irritant) { |
641 |
case (InvalidJavadoc | UsingDeprecatedAPI) : |
642 |
case UsingDeprecatedAPI : |
643 |
return "deprecation"; //$NON-NLS-1$ |
644 |
case FinallyBlockNotCompleting : |
645 |
return "finally"; //$NON-NLS-1$ |
646 |
case FieldHiding : |
647 |
case LocalVariableHiding : |
648 |
case MaskedCatchBlock : |
649 |
return "hiding"; //$NON-NLS-1$ |
650 |
case NonExternalizedString : |
651 |
return "nls"; //$NON-NLS-1$ |
652 |
case UnnecessaryTypeCheck : |
653 |
return "cast"; //$NON-NLS-1$ |
654 |
case UnusedLocalVariable : |
655 |
case UnusedArgument : |
656 |
case UnusedImport : |
657 |
case UnusedPrivateMember : |
658 |
case UnusedDeclaredThrownException : |
659 |
return "unused"; //$NON-NLS-1$ |
660 |
case IndirectStaticAccess : |
661 |
case NonStaticAccessToStatic : |
662 |
return "static-access"; //$NON-NLS-1$ |
663 |
case AccessEmulation : |
664 |
return "synthetic-access"; //$NON-NLS-1$ |
665 |
case UnqualifiedFieldAccess : |
666 |
return "unqualified-field-access"; //$NON-NLS-1$ |
667 |
case UncheckedTypeOperation : |
668 |
return "unchecked"; //$NON-NLS-1$ |
669 |
case MissingSerialVersion : |
670 |
return "serial"; //$NON-NLS-1$ |
671 |
case AutoBoxing : |
672 |
return "boxing"; //$NON-NLS-1$ |
673 |
case TypeHiding : |
674 |
return "hiding"; //$NON-NLS-1$ |
675 |
case IncompleteEnumSwitch : |
676 |
return "incomplete-switch"; //$NON-NLS-1$ |
677 |
case MissingDeprecatedAnnotation : |
678 |
return "dep-ann"; //$NON-NLS-1$ |
679 |
case RawTypeReference : |
680 |
return "unchecked"; //$NON-NLS-1$ |
681 |
case UnusedLabel : |
682 |
case UnusedTypeArguments : |
683 |
case RedundantSuperinterface : |
684 |
return "unused"; //$NON-NLS-1$ |
685 |
case DiscouragedReference : |
686 |
case ForbiddenReference : |
687 |
return "restriction"; //$NON-NLS-1$ |
688 |
case NullReference : |
689 |
case PotentialNullReference : |
690 |
case RedundantNullCheck : |
691 |
return "null"; //$NON-NLS-1$ |
692 |
case FallthroughCase : |
693 |
return "fallthrough"; //$NON-NLS-1$ |
694 |
case OverridingMethodWithoutSuperInvocation : |
695 |
return "super"; //$NON-NLS-1$ |
696 |
} |
697 |
return null; |
698 |
} |
699 |
|
700 |
public static IrritantSet warningTokenToIrritants(String warningToken) { |
701 |
// keep in sync with warningTokens and warningTokenFromIrritant |
702 |
if (warningToken == null || warningToken.length() == 0) return null; |
703 |
switch (warningToken.charAt(0)) { |
704 |
case 'a' : |
705 |
if ("all".equals(warningToken)) //$NON-NLS-1$ |
706 |
return IrritantSet.ALL; |
707 |
break; |
708 |
case 'b' : |
709 |
if ("boxing".equals(warningToken)) //$NON-NLS-1$ |
710 |
return IrritantSet.BOXING; |
711 |
break; |
712 |
case 'c' : |
713 |
if ("cast".equals(warningToken)) //$NON-NLS-1$ |
714 |
return IrritantSet.CAST; |
715 |
break; |
716 |
case 'd' : |
717 |
if ("deprecation".equals(warningToken)) //$NON-NLS-1$ |
718 |
return IrritantSet.DEPRECATION; |
719 |
if ("dep-ann".equals(warningToken)) //$NON-NLS-1$ |
720 |
return IrritantSet.DEP_ANN; |
721 |
break; |
722 |
case 'f' : |
723 |
if ("fallthrough".equals(warningToken)) //$NON-NLS-1$ |
724 |
return IrritantSet.FALLTHROUGH; |
725 |
if ("finally".equals(warningToken)) //$NON-NLS-1$ |
726 |
return IrritantSet.FINALLY; |
727 |
break; |
728 |
case 'h' : |
729 |
if ("hiding".equals(warningToken)) //$NON-NLS-1$ |
730 |
return IrritantSet.HIDING; |
731 |
case 'i' : |
732 |
if ("incomplete-switch".equals(warningToken)) //$NON-NLS-1$ |
733 |
return IrritantSet.INCOMPLETE_SWITCH; |
734 |
break; |
735 |
case 'n' : |
736 |
if ("nls".equals(warningToken)) //$NON-NLS-1$ |
737 |
return IrritantSet.NLS; |
738 |
if ("null".equals(warningToken)) //$NON-NLS-1$ |
739 |
return IrritantSet.NULL; |
740 |
break; |
741 |
case 'r' : |
742 |
if ("restriction".equals(warningToken)) //$NON-NLS-1$ |
743 |
return IrritantSet.RESTRICTION; |
744 |
break; |
745 |
case 's' : |
746 |
if ("serial".equals(warningToken)) //$NON-NLS-1$ |
747 |
return IrritantSet.SERIAL; |
748 |
if ("static-access".equals(warningToken)) //$NON-NLS-1$ |
749 |
return IrritantSet.STATIC_ACCESS; |
750 |
if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$ |
751 |
return IrritantSet.SYNTHETIC_ACCESS; |
752 |
if ("super".equals(warningToken)) { //$NON-NLS-1$ |
753 |
return IrritantSet.SUPER; |
754 |
} |
755 |
break; |
756 |
case 'u' : |
757 |
if ("unused".equals(warningToken)) //$NON-NLS-1$ |
758 |
return IrritantSet.UNUSED; |
759 |
if ("unchecked".equals(warningToken)) //$NON-NLS-1$ |
760 |
return IrritantSet.UNCHECKED; |
761 |
if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$ |
762 |
return IrritantSet.UNQUALIFIED_FIELD_ACCESS; |
763 |
break; |
764 |
} |
765 |
return null; |
766 |
} |
348 |
|
767 |
|
349 |
/** |
768 |
/** |
350 |
* Initializing the compiler options with defaults |
769 |
* Initializing the compiler options with defaults |
351 |
*/ |
770 |
*/ |
352 |
public CompilerOptions(){ |
771 |
public CompilerOptions(){ |
353 |
// use default options |
772 |
this(null); // use default options |
354 |
} |
773 |
} |
355 |
|
774 |
|
356 |
/** |
775 |
/** |
Lines 358-366
Link Here
|
358 |
* @param settings |
777 |
* @param settings |
359 |
*/ |
778 |
*/ |
360 |
public CompilerOptions(Map settings){ |
779 |
public CompilerOptions(Map settings){ |
361 |
|
780 |
resetDefaults(); |
362 |
if (settings == null) return; |
781 |
if (settings != null) { |
363 |
set(settings); |
782 |
set(settings); |
|
|
783 |
} |
364 |
} |
784 |
} |
365 |
|
785 |
|
366 |
/** |
786 |
/** |
Lines 371-376
Link Here
|
371 |
this.parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants; |
791 |
this.parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants; |
372 |
} |
792 |
} |
373 |
|
793 |
|
|
|
794 |
|
374 |
public Map getMap() { |
795 |
public Map getMap() { |
375 |
Map optionsMap = new HashMap(30); |
796 |
Map optionsMap = new HashMap(30); |
376 |
optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? GENERATE : DO_NOT_GENERATE); |
797 |
optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? GENERATE : DO_NOT_GENERATE); |
Lines 471-648
Link Here
|
471 |
return optionsMap; |
892 |
return optionsMap; |
472 |
} |
893 |
} |
473 |
|
894 |
|
474 |
/** |
895 |
public int getSeverity(int irritant) { |
475 |
* Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by |
896 |
if (this.errorThreshold.isSet(irritant)) { |
476 |
* other master options (e.g. javadoc, deprecation, etc.). |
897 |
if ((irritant & (IrritantSet.GROUP_MASK | UnusedWarningToken)) == UnusedWarningToken) { |
477 |
* This information is intended for grouping purpose (several problems governed by a rule) |
|
|
478 |
*/ |
479 |
public static String optionKeyFromIrritant(long irritant) { |
480 |
// keep in sync with warningTokens and warningTokenToIrritant |
481 |
int irritantInt = (int) irritant; |
482 |
if (irritantInt == irritant) { |
483 |
switch (irritantInt) { |
484 |
case (int) MethodWithConstructorName : |
485 |
return OPTION_ReportMethodWithConstructorName; |
486 |
case (int) OverriddenPackageDefaultMethod : |
487 |
return OPTION_ReportOverridingPackageDefaultMethod; |
488 |
case (int) UsingDeprecatedAPI : |
489 |
case (int) (InvalidJavadoc | UsingDeprecatedAPI) : |
490 |
return OPTION_ReportDeprecation; |
491 |
case (int) MaskedCatchBlock : |
492 |
return OPTION_ReportHiddenCatchBlock; |
493 |
case (int) UnusedLocalVariable : |
494 |
return OPTION_ReportUnusedLocal; |
495 |
case (int) UnusedArgument : |
496 |
return OPTION_ReportUnusedParameter; |
497 |
case (int) NoImplicitStringConversion : |
498 |
return OPTION_ReportNoImplicitStringConversion; |
499 |
case (int) AccessEmulation : |
500 |
return OPTION_ReportSyntheticAccessEmulation; |
501 |
case (int) NonExternalizedString : |
502 |
return OPTION_ReportNonExternalizedStringLiteral; |
503 |
case (int) AssertUsedAsAnIdentifier : |
504 |
return OPTION_ReportAssertIdentifier; |
505 |
case (int) UnusedImport : |
506 |
return OPTION_ReportUnusedImport; |
507 |
case (int) NonStaticAccessToStatic : |
508 |
return OPTION_ReportNonStaticAccessToStatic; |
509 |
case (int) Task : |
510 |
return OPTION_TaskTags; |
511 |
case (int) NoEffectAssignment : |
512 |
return OPTION_ReportNoEffectAssignment; |
513 |
case (int) IncompatibleNonInheritedInterfaceMethod : |
514 |
return OPTION_ReportIncompatibleNonInheritedInterfaceMethod; |
515 |
case (int) UnusedPrivateMember : |
516 |
return OPTION_ReportUnusedPrivateMember; |
517 |
case (int) LocalVariableHiding : |
518 |
return OPTION_ReportLocalVariableHiding; |
519 |
case (int) FieldHiding : |
520 |
return OPTION_ReportFieldHiding; |
521 |
case (int) AccidentalBooleanAssign : |
522 |
return OPTION_ReportPossibleAccidentalBooleanAssignment; |
523 |
case (int) EmptyStatement : |
524 |
return OPTION_ReportEmptyStatement; |
525 |
case (int) MissingJavadocComments : |
526 |
return OPTION_ReportMissingJavadocComments; |
527 |
case (int) MissingJavadocTags : |
528 |
return OPTION_ReportMissingJavadocTags; |
529 |
case (int) UnqualifiedFieldAccess : |
530 |
return OPTION_ReportUnqualifiedFieldAccess; |
531 |
case (int) UnusedDeclaredThrownException : |
532 |
return OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding; |
533 |
case (int) FinallyBlockNotCompleting : |
534 |
return OPTION_ReportFinallyBlockNotCompletingNormally; |
535 |
case (int) InvalidJavadoc : |
536 |
return OPTION_ReportInvalidJavadoc; |
537 |
case (int) UnnecessaryTypeCheck : |
538 |
return OPTION_ReportUnnecessaryTypeCheck; |
539 |
case (int) UndocumentedEmptyBlock : |
540 |
return OPTION_ReportUndocumentedEmptyBlock; |
541 |
case (int) IndirectStaticAccess : |
542 |
return OPTION_ReportIndirectStaticAccess; |
543 |
case (int) UnnecessaryElse : |
544 |
return OPTION_ReportUnnecessaryElse; |
545 |
case (int) UncheckedTypeOperation : |
546 |
return OPTION_ReportUncheckedTypeOperation; |
547 |
case (int) FinalParameterBound : |
548 |
return OPTION_ReportFinalParameterBound; |
549 |
} |
550 |
} else { |
551 |
irritantInt = (int)(irritant >>> 32); |
552 |
switch (irritantInt) { |
553 |
case (int)(MissingSerialVersion >>> 32) : |
554 |
return OPTION_ReportMissingSerialVersion ; |
555 |
case (int)(EnumUsedAsAnIdentifier >>> 32) : |
556 |
return OPTION_ReportEnumIdentifier; |
557 |
case (int)(ForbiddenReference >>> 32) : |
558 |
return OPTION_ReportForbiddenReference; |
559 |
case (int)(VarargsArgumentNeedCast >>> 32) : |
560 |
return OPTION_ReportVarargsArgumentNeedCast; |
561 |
case (int)(NullReference >>> 32) : |
562 |
return OPTION_ReportNullReference; |
563 |
case (int)(PotentialNullReference >>> 32) : |
564 |
return OPTION_ReportPotentialNullReference; |
565 |
case (int)(RedundantNullCheck >>> 32) : |
566 |
return OPTION_ReportRedundantNullCheck; |
567 |
case (int)(AutoBoxing >>> 32) : |
568 |
return OPTION_ReportAutoboxing; |
569 |
case (int)(AnnotationSuperInterface >>> 32) : |
570 |
return OPTION_ReportAnnotationSuperInterface; |
571 |
case (int)(TypeHiding >>> 32) : |
572 |
return OPTION_ReportTypeParameterHiding; |
573 |
case (int)(MissingOverrideAnnotation >>> 32) : |
574 |
return OPTION_ReportMissingOverrideAnnotation; |
575 |
case (int)(IncompleteEnumSwitch >>> 32) : |
576 |
return OPTION_ReportIncompleteEnumSwitch; |
577 |
case (int)(MissingDeprecatedAnnotation >>> 32) : |
578 |
return OPTION_ReportMissingDeprecatedAnnotation; |
579 |
case (int)(DiscouragedReference >>> 32) : |
580 |
return OPTION_ReportDiscouragedReference; |
581 |
case (int)(UnhandledWarningToken >>> 32) : |
582 |
return OPTION_ReportUnhandledWarningToken; |
583 |
case (int)(RawTypeReference >>> 32) : |
584 |
return OPTION_ReportRawTypeReference; |
585 |
case (int)(UnusedLabel >>> 32) : |
586 |
return OPTION_ReportUnusedLabel; |
587 |
case (int)(ParameterAssignment>>> 32) : |
588 |
return OPTION_ReportParameterAssignment; |
589 |
case (int)(FallthroughCase >>> 32) : |
590 |
return OPTION_ReportFallthroughCase; |
591 |
case (int)(OverridingMethodWithoutSuperInvocation >>> 32) : |
592 |
return OPTION_ReportOverridingMethodWithoutSuperInvocation; |
593 |
case (int)(MissingJavadocTagDescription >>> 32): |
594 |
return OPTION_ReportMissingJavadocTagDescription; |
595 |
case (int)(UnusedTypeArguments >>> 32): |
596 |
return OPTION_ReportUnusedTypeArgumentsForMethodInvocation; |
597 |
case (int)(UnusedWarningToken >>> 32) : |
598 |
return OPTION_ReportUnusedWarningToken; |
599 |
case (int)(RedundantSuperinterface >>> 32) : |
600 |
return OPTION_ReportRedundantSuperinterface; |
601 |
case (int)(ComparingIdentical >>> 32) : |
602 |
return OPTION_ReportComparingIdentical; |
603 |
case (int)(MissingSynchronizedModifierInInheritedMethod >>> 32) : |
604 |
return OPTION_ReportMissingSynchronizedOnInheritedMethod; |
605 |
} |
606 |
} |
607 |
return null; |
608 |
} |
609 |
|
610 |
public static long optionKeyToIrritant(String optionName) { |
611 |
if (OptionToIrritants == null) { |
612 |
long irritant = 0; |
613 |
for (int i = 0; i < 64; i++) { |
614 |
irritant <<= 1; |
615 |
String optionKey = optionKeyFromIrritant(irritant); |
616 |
if (optionKey == null) continue; |
617 |
OptionToIrritants.put(optionKey, new Long(irritant)); |
618 |
} |
619 |
} |
620 |
Long irritant = (Long)OptionToIrritants.get(optionName); |
621 |
return irritant == null ? 0 : irritant.longValue(); |
622 |
} |
623 |
|
624 |
public int getSeverity(long irritant) { |
625 |
if((this.errorThreshold & irritant) != 0) { |
626 |
if ((irritant & UnusedWarningToken) != 0) { |
627 |
return ProblemSeverities.Error | ProblemSeverities.Optional; // cannot be treated as fatal - codegen already occurred |
898 |
return ProblemSeverities.Error | ProblemSeverities.Optional; // cannot be treated as fatal - codegen already occurred |
628 |
} |
899 |
} |
629 |
return this.treatOptionalErrorAsFatal |
900 |
return this.treatOptionalErrorAsFatal |
630 |
? ProblemSeverities.Error | ProblemSeverities.Optional | ProblemSeverities.Fatal |
901 |
? ProblemSeverities.Error | ProblemSeverities.Optional | ProblemSeverities.Fatal |
631 |
: ProblemSeverities.Error | ProblemSeverities.Optional; |
902 |
: ProblemSeverities.Error | ProblemSeverities.Optional; |
632 |
} |
903 |
} |
633 |
if((this.warningThreshold & irritant) != 0) |
904 |
if (this.warningThreshold.isSet(irritant)) { |
634 |
return ProblemSeverities.Warning | ProblemSeverities.Optional; |
905 |
return ProblemSeverities.Warning | ProblemSeverities.Optional; |
|
|
906 |
} |
635 |
return ProblemSeverities.Ignore; |
907 |
return ProblemSeverities.Ignore; |
636 |
} |
908 |
} |
637 |
|
909 |
|
638 |
public String getSeverityString(long irritant) { |
910 |
public String getSeverityString(int irritant) { |
639 |
if((this.errorThreshold & irritant) != 0) |
911 |
if(this.errorThreshold.isSet(irritant)) |
640 |
return ERROR; |
912 |
return ERROR; |
641 |
if((this.warningThreshold & irritant) != 0) |
913 |
if(this.warningThreshold.isSet(irritant)) |
642 |
return WARNING; |
914 |
return WARNING; |
643 |
return IGNORE; |
915 |
return IGNORE; |
644 |
} |
916 |
} |
645 |
|
|
|
646 |
public String getVisibilityString(int level) { |
917 |
public String getVisibilityString(int level) { |
647 |
switch (level & ExtraCompilerModifiers.AccVisibilityMASK) { |
918 |
switch (level & ExtraCompilerModifiers.AccVisibilityMASK) { |
648 |
case ClassFileConstants.AccPublic: |
919 |
case ClassFileConstants.AccPublic: |
Lines 656-661
Link Here
|
656 |
} |
927 |
} |
657 |
} |
928 |
} |
658 |
|
929 |
|
|
|
930 |
public boolean isAnyEnabled(IrritantSet irritants) { |
931 |
return this.warningThreshold.isAnySet(irritants) || this.errorThreshold.isAnySet(irritants); |
932 |
} |
933 |
|
934 |
protected void resetDefaults() { |
935 |
// problem default severities defined on IrritantSet |
936 |
this.errorThreshold = new IrritantSet(IrritantSet.COMPILER_DEFAULT_ERRORS); |
937 |
this.warningThreshold = new IrritantSet(IrritantSet.COMPILER_DEFAULT_WARNINGS); |
938 |
|
939 |
// by default only lines and source attributes are generated. |
940 |
this.produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES; |
941 |
this.complianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4 |
942 |
this.sourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default |
943 |
this.targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2 |
944 |
|
945 |
this.defaultEncoding = null; // will use the platform default encoding |
946 |
|
947 |
// print what unit is being processed |
948 |
this.verbose = Compiler.DEBUG; |
949 |
|
950 |
this.produceReferenceInfo = false; // no reference info by default |
951 |
|
952 |
// indicates if unused/optimizable local variables need to be preserved (debugging purpose) |
953 |
this.preserveAllLocalVariables = false; |
954 |
|
955 |
// indicates whether literal expressions are inlined at parse-time or not |
956 |
this.parseLiteralExpressionsAsConstants = true; |
957 |
|
958 |
// max problems per compilation unit |
959 |
this.maxProblemsPerUnit = 100; // no more than 100 problems per default |
960 |
|
961 |
// tags used to recognize tasks in comments |
962 |
this.taskTags = null; |
963 |
this.taskPriorites = null; |
964 |
this.isTaskCaseSensitive = true; |
965 |
|
966 |
// deprecation report |
967 |
this.reportDeprecationInsideDeprecatedCode = false; |
968 |
this.reportDeprecationWhenOverridingDeprecatedMethod = false; |
969 |
|
970 |
// unused parameters report |
971 |
this.reportUnusedParameterWhenImplementingAbstract = false; |
972 |
this.reportUnusedParameterWhenOverridingConcrete = false; |
973 |
this.reportUnusedParameterIncludeDocCommentReference = true; |
974 |
|
975 |
// unused declaration of thrown exception |
976 |
this.reportUnusedDeclaredThrownExceptionWhenOverriding = false; |
977 |
this.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = true; |
978 |
this.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = true; |
979 |
|
980 |
// constructor/setter parameter hiding |
981 |
this.reportSpecialParameterHidingField = false; |
982 |
|
983 |
// check javadoc comments tags |
984 |
this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic; |
985 |
this.reportInvalidJavadocTags = false; |
986 |
this.reportInvalidJavadocTagsDeprecatedRef = false; |
987 |
this.reportInvalidJavadocTagsNotVisibleRef = false; |
988 |
this.reportMissingJavadocTagDescription = RETURN_TAG; |
989 |
|
990 |
// check missing javadoc tags |
991 |
this.reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic; |
992 |
this.reportMissingJavadocTagsOverriding = false; |
993 |
|
994 |
// check missing javadoc comments |
995 |
this.reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic; |
996 |
this.reportMissingJavadocCommentsOverriding = false; |
997 |
|
998 |
// JSR bytecode inlining |
999 |
this.inlineJsrBytecode = false; |
1000 |
|
1001 |
// javadoc comment support |
1002 |
this.docCommentSupport = false; |
1003 |
|
1004 |
// suppress warning annotation |
1005 |
this.suppressWarnings = true; |
1006 |
|
1007 |
// treat optional error as fatal or just like warning? |
1008 |
this.treatOptionalErrorAsFatal = true; |
1009 |
|
1010 |
// parser perform statements recovery |
1011 |
this.performMethodsFullRecovery = true; |
1012 |
|
1013 |
// parser perform statements recovery |
1014 |
this.performStatementsRecovery = true; |
1015 |
|
1016 |
// store annotations |
1017 |
this.storeAnnotations = false; |
1018 |
|
1019 |
// annotation processing |
1020 |
this.generateClassFiles = true; |
1021 |
|
1022 |
// enable annotation processing by default only in batch mode |
1023 |
this.processAnnotations = false; |
1024 |
} |
1025 |
|
659 |
public void set(Map optionsMap) { |
1026 |
public void set(Map optionsMap) { |
660 |
Object optionValue; |
1027 |
Object optionValue; |
661 |
if ((optionValue = optionsMap.get(OPTION_LocalVariableAttribute)) != null) { |
1028 |
if ((optionValue = optionsMap.get(OPTION_LocalVariableAttribute)) != null) { |
Lines 999-1007
Link Here
|
999 |
} |
1366 |
} |
1000 |
} |
1367 |
} |
1001 |
} |
1368 |
} |
1002 |
|
|
|
1003 |
public String toString() { |
1369 |
public String toString() { |
1004 |
|
|
|
1005 |
StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$ |
1370 |
StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$ |
1006 |
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$ |
1371 |
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$ |
1007 |
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$ |
1372 |
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$ |
Lines 1092-1401
Link Here
|
1092 |
buf.append("\n\t- missing synchronized on inherited method: ").append(getSeverityString(MissingSynchronizedModifierInInheritedMethod)); //$NON-NLS-1$ |
1457 |
buf.append("\n\t- missing synchronized on inherited method: ").append(getSeverityString(MissingSynchronizedModifierInInheritedMethod)); //$NON-NLS-1$ |
1093 |
return buf.toString(); |
1458 |
return buf.toString(); |
1094 |
} |
1459 |
} |
1095 |
|
1460 |
|
1096 |
void updateSeverity(long irritant, Object severityString) { |
1461 |
protected void updateSeverity(int irritant, Object severityString) { |
1097 |
if (ERROR.equals(severityString)) { |
1462 |
if (ERROR.equals(severityString)) { |
1098 |
this.errorThreshold |= irritant; |
1463 |
this.errorThreshold.set(irritant); |
1099 |
this.warningThreshold &= ~irritant; |
1464 |
this.warningThreshold.clear(irritant); |
1100 |
} else if (WARNING.equals(severityString)) { |
1465 |
} else if (WARNING.equals(severityString)) { |
1101 |
this.errorThreshold &= ~irritant; |
1466 |
this.errorThreshold.clear(irritant); |
1102 |
this.warningThreshold |= irritant; |
1467 |
this.warningThreshold.set(irritant); |
1103 |
} else if (IGNORE.equals(severityString)) { |
1468 |
} else if (IGNORE.equals(severityString)) { |
1104 |
this.errorThreshold &= ~irritant; |
1469 |
this.errorThreshold.clear(irritant); |
1105 |
this.warningThreshold &= ~irritant; |
1470 |
this.warningThreshold.clear(irritant); |
1106 |
} |
|
|
1107 |
} |
1108 |
public static long versionToJdkLevel(Object versionID) { |
1109 |
if (versionID instanceof String) { |
1110 |
String version = (String) versionID; |
1111 |
// verification is optimized for all versions with same length and same "1." prefix |
1112 |
if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') { |
1113 |
switch (version.charAt(2)) { |
1114 |
case '1': |
1115 |
return ClassFileConstants.JDK1_1; |
1116 |
case '2': |
1117 |
return ClassFileConstants.JDK1_2; |
1118 |
case '3': |
1119 |
return ClassFileConstants.JDK1_3; |
1120 |
case '4': |
1121 |
return ClassFileConstants.JDK1_4; |
1122 |
case '5': |
1123 |
return ClassFileConstants.JDK1_5; |
1124 |
case '6': |
1125 |
return ClassFileConstants.JDK1_6; |
1126 |
case '7': |
1127 |
return ClassFileConstants.JDK1_7; |
1128 |
default: |
1129 |
return 0; // unknown |
1130 |
} |
1131 |
} |
1132 |
if (VERSION_JSR14.equals(versionID)) { |
1133 |
return ClassFileConstants.JDK1_4; |
1134 |
} |
1135 |
if (VERSION_CLDC1_1.equals(versionID)) { |
1136 |
return ClassFileConstants.CLDC_1_1; |
1137 |
} |
1138 |
} |
1139 |
return 0; // unknown |
1140 |
} |
1141 |
|
1142 |
public static String versionFromJdkLevel(long jdkLevel) { |
1143 |
switch ((int)(jdkLevel>>16)) { |
1144 |
case ClassFileConstants.MAJOR_VERSION_1_1 : |
1145 |
if (jdkLevel == ClassFileConstants.JDK1_1) |
1146 |
return VERSION_1_1; |
1147 |
break; |
1148 |
case ClassFileConstants.MAJOR_VERSION_1_2 : |
1149 |
if (jdkLevel == ClassFileConstants.JDK1_2) |
1150 |
return VERSION_1_2; |
1151 |
break; |
1152 |
case ClassFileConstants.MAJOR_VERSION_1_3 : |
1153 |
if (jdkLevel == ClassFileConstants.JDK1_3) |
1154 |
return VERSION_1_3; |
1155 |
break; |
1156 |
case ClassFileConstants.MAJOR_VERSION_1_4 : |
1157 |
if (jdkLevel == ClassFileConstants.JDK1_4) |
1158 |
return VERSION_1_4; |
1159 |
break; |
1160 |
case ClassFileConstants.MAJOR_VERSION_1_5 : |
1161 |
if (jdkLevel == ClassFileConstants.JDK1_5) |
1162 |
return VERSION_1_5; |
1163 |
break; |
1164 |
case ClassFileConstants.MAJOR_VERSION_1_6 : |
1165 |
if (jdkLevel == ClassFileConstants.JDK1_6) |
1166 |
return VERSION_1_6; |
1167 |
break; |
1168 |
case ClassFileConstants.MAJOR_VERSION_1_7 : |
1169 |
if (jdkLevel == ClassFileConstants.JDK1_7) |
1170 |
return VERSION_1_7; |
1171 |
break; |
1172 |
} |
1173 |
return Util.EMPTY_STRING; // unknown version |
1174 |
} |
1175 |
|
1176 |
/** |
1177 |
* Return all warning option names for use as keys in compiler options maps. |
1178 |
* @return all warning option names |
1179 |
* TODO (maxime) revise for ensuring completeness |
1180 |
*/ |
1181 |
public static String[] warningOptionNames() { |
1182 |
String[] result = { |
1183 |
OPTION_ReportAnnotationSuperInterface, |
1184 |
OPTION_ReportAssertIdentifier, |
1185 |
OPTION_ReportAutoboxing, |
1186 |
OPTION_ReportDeprecation, |
1187 |
OPTION_ReportDiscouragedReference, |
1188 |
OPTION_ReportEmptyStatement, |
1189 |
OPTION_ReportEnumIdentifier, |
1190 |
OPTION_ReportFallthroughCase, |
1191 |
OPTION_ReportFieldHiding, |
1192 |
OPTION_ReportFinalParameterBound, |
1193 |
OPTION_ReportFinallyBlockNotCompletingNormally, |
1194 |
OPTION_ReportForbiddenReference, |
1195 |
OPTION_ReportHiddenCatchBlock, |
1196 |
OPTION_ReportIncompatibleNonInheritedInterfaceMethod, |
1197 |
OPTION_ReportIncompleteEnumSwitch, |
1198 |
OPTION_ReportIndirectStaticAccess, |
1199 |
OPTION_ReportInvalidJavadoc, |
1200 |
OPTION_ReportLocalVariableHiding, |
1201 |
OPTION_ReportMethodWithConstructorName, |
1202 |
OPTION_ReportMissingDeprecatedAnnotation, |
1203 |
OPTION_ReportMissingJavadocComments, |
1204 |
OPTION_ReportMissingJavadocTagDescription, |
1205 |
OPTION_ReportMissingJavadocTags, |
1206 |
OPTION_ReportMissingOverrideAnnotation, |
1207 |
OPTION_ReportMissingSerialVersion, |
1208 |
OPTION_ReportNoEffectAssignment, |
1209 |
OPTION_ReportNoImplicitStringConversion, |
1210 |
OPTION_ReportNonExternalizedStringLiteral, |
1211 |
OPTION_ReportNonStaticAccessToStatic, |
1212 |
OPTION_ReportNullReference, |
1213 |
OPTION_ReportPotentialNullReference, |
1214 |
OPTION_ReportRedundantNullCheck, |
1215 |
OPTION_ReportRedundantSuperinterface, |
1216 |
OPTION_ReportOverridingPackageDefaultMethod, |
1217 |
OPTION_ReportParameterAssignment, |
1218 |
OPTION_ReportPossibleAccidentalBooleanAssignment, |
1219 |
OPTION_ReportSyntheticAccessEmulation, |
1220 |
OPTION_ReportTypeParameterHiding, |
1221 |
OPTION_ReportUncheckedTypeOperation, |
1222 |
OPTION_ReportUndocumentedEmptyBlock, |
1223 |
OPTION_ReportUnnecessaryElse, |
1224 |
OPTION_ReportUnnecessaryTypeCheck, |
1225 |
OPTION_ReportUnqualifiedFieldAccess, |
1226 |
OPTION_ReportUnusedDeclaredThrownException, |
1227 |
OPTION_ReportUnusedImport, |
1228 |
OPTION_ReportUnusedLocal, |
1229 |
OPTION_ReportUnusedParameter, |
1230 |
OPTION_ReportUnusedPrivateMember, |
1231 |
OPTION_ReportVarargsArgumentNeedCast, |
1232 |
OPTION_ReportUnhandledWarningToken, |
1233 |
OPTION_ReportUnusedWarningToken, |
1234 |
OPTION_ReportOverridingMethodWithoutSuperInvocation, |
1235 |
OPTION_ReportUnusedTypeArgumentsForMethodInvocation, |
1236 |
}; |
1237 |
return result; |
1238 |
} |
1239 |
|
1240 |
/** |
1241 |
* For suppressable warnings |
1242 |
*/ |
1243 |
public static String warningTokenFromIrritant(long irritant) { |
1244 |
// keep in sync with warningTokens and warningTokenToIrritant |
1245 |
int irritantInt = (int) irritant; |
1246 |
if (irritantInt == irritant) { |
1247 |
switch (irritantInt) { |
1248 |
case (int) (InvalidJavadoc | UsingDeprecatedAPI) : |
1249 |
case (int) UsingDeprecatedAPI : |
1250 |
return "deprecation"; //$NON-NLS-1$ |
1251 |
case (int) FinallyBlockNotCompleting : |
1252 |
return "finally"; //$NON-NLS-1$ |
1253 |
case (int) FieldHiding : |
1254 |
case (int) LocalVariableHiding : |
1255 |
case (int) MaskedCatchBlock : |
1256 |
return "hiding"; //$NON-NLS-1$ |
1257 |
case (int) NonExternalizedString : |
1258 |
return "nls"; //$NON-NLS-1$ |
1259 |
case (int) UnnecessaryTypeCheck : |
1260 |
return "cast"; //$NON-NLS-1$ |
1261 |
case (int) UnusedLocalVariable : |
1262 |
case (int) UnusedArgument : |
1263 |
case (int) UnusedImport : |
1264 |
case (int) UnusedPrivateMember: |
1265 |
case (int) UnusedDeclaredThrownException: |
1266 |
return "unused"; //$NON-NLS-1$ |
1267 |
case (int) IndirectStaticAccess : |
1268 |
case (int) NonStaticAccessToStatic : |
1269 |
return "static-access"; //$NON-NLS-1$ |
1270 |
case (int) AccessEmulation : |
1271 |
return "synthetic-access"; //$NON-NLS-1$ |
1272 |
case (int) UnqualifiedFieldAccess : |
1273 |
return "unqualified-field-access"; //$NON-NLS-1$ |
1274 |
case (int) UncheckedTypeOperation : |
1275 |
return "unchecked"; //$NON-NLS-1$ |
1276 |
} |
1277 |
} else { |
1278 |
irritantInt = (int)(irritant >>> 32); |
1279 |
switch (irritantInt) { |
1280 |
case (int)(MissingSerialVersion >>> 32) : |
1281 |
return "serial"; //$NON-NLS-1$ |
1282 |
case (int)(AutoBoxing >>> 32) : |
1283 |
return "boxing"; //$NON-NLS-1$ |
1284 |
case (int)(TypeHiding >>> 32) : |
1285 |
return "hiding"; //$NON-NLS-1$ |
1286 |
case (int)(IncompleteEnumSwitch >>> 32) : |
1287 |
return "incomplete-switch"; //$NON-NLS-1$ |
1288 |
case (int)(MissingDeprecatedAnnotation >>> 32) : |
1289 |
return "dep-ann"; //$NON-NLS-1$ |
1290 |
case (int)(RawTypeReference >>> 32): |
1291 |
return "unchecked"; //$NON-NLS-1$ |
1292 |
case (int) (UnusedLabel >>> 32): |
1293 |
case (int) (UnusedTypeArguments >>> 32) : |
1294 |
case (int) (RedundantSuperinterface >>> 32) : |
1295 |
return "unused"; //$NON-NLS-1$ |
1296 |
case (int) (DiscouragedReference >>> 32) : |
1297 |
case (int) (ForbiddenReference >>> 32) : |
1298 |
return "restriction"; //$NON-NLS-1$ |
1299 |
case (int) (NullReference >>> 32) : |
1300 |
case (int) (PotentialNullReference >>> 32) : |
1301 |
case (int) (RedundantNullCheck >>> 32) : |
1302 |
return "null"; //$NON-NLS-1$ |
1303 |
case (int) (FallthroughCase >>> 32) : |
1304 |
return "fallthrough"; //$NON-NLS-1$ |
1305 |
case (int) (OverridingMethodWithoutSuperInvocation >>> 32) : |
1306 |
return "super"; //$NON-NLS-1$ |
1307 |
} |
1308 |
} |
1309 |
return null; |
1310 |
} |
1311 |
// keep in sync with warningTokenToIrritant and warningTokenFromIrritant |
1312 |
public final static String[] warningTokens = { |
1313 |
"all", //$NON-NLS-1$ |
1314 |
"boxing", //$NON-NLS-1$ |
1315 |
"cast", //$NON-NLS-1$ |
1316 |
"dep-ann", //$NON-NLS-1$ |
1317 |
"deprecation", //$NON-NLS-1$ |
1318 |
"fallthrough", //$NON-NLS-1$ |
1319 |
"finally", //$NON-NLS-1$ |
1320 |
"hiding", //$NON-NLS-1$ |
1321 |
"incomplete-switch", //$NON-NLS-1$ |
1322 |
"nls", //$NON-NLS-1$ |
1323 |
"null", //$NON-NLS-1$ |
1324 |
"restriction", //$NON-NLS-1$ |
1325 |
"serial", //$NON-NLS-1$ |
1326 |
"static-access", //$NON-NLS-1$ |
1327 |
"super", //$NON-NLS-1$ |
1328 |
"synthetic-access", //$NON-NLS-1$ |
1329 |
"unchecked", //$NON-NLS-1$ |
1330 |
"unqualified-field-access", //$NON-NLS-1$ |
1331 |
"unused", //$NON-NLS-1$ |
1332 |
}; |
1333 |
|
1334 |
public static long warningTokenToIrritants(String warningToken) { |
1335 |
// keep in sync with warningTokens and warningTokenFromIrritant |
1336 |
if (warningToken == null || warningToken.length() == 0) return 0; |
1337 |
switch (warningToken.charAt(0)) { |
1338 |
case 'a' : |
1339 |
if ("all".equals(warningToken)) //$NON-NLS-1$ |
1340 |
return 0xFFFFFFFFFFFFFFFFl; // suppress all warnings |
1341 |
break; |
1342 |
case 'b' : |
1343 |
if ("boxing".equals(warningToken)) //$NON-NLS-1$ |
1344 |
return AutoBoxing; |
1345 |
break; |
1346 |
case 'c' : |
1347 |
if ("cast".equals(warningToken)) //$NON-NLS-1$ |
1348 |
return UnnecessaryTypeCheck; |
1349 |
break; |
1350 |
case 'd' : |
1351 |
if ("deprecation".equals(warningToken)) //$NON-NLS-1$ |
1352 |
return UsingDeprecatedAPI; |
1353 |
if ("dep-ann".equals(warningToken)) //$NON-NLS-1$ |
1354 |
return MissingDeprecatedAnnotation; |
1355 |
break; |
1356 |
case 'f' : |
1357 |
if ("fallthrough".equals(warningToken)) //$NON-NLS-1$ |
1358 |
return FallthroughCase; |
1359 |
if ("finally".equals(warningToken)) //$NON-NLS-1$ |
1360 |
return FinallyBlockNotCompleting; |
1361 |
break; |
1362 |
case 'h' : |
1363 |
if ("hiding".equals(warningToken)) //$NON-NLS-1$ |
1364 |
return FieldHiding | LocalVariableHiding | MaskedCatchBlock | TypeHiding; |
1365 |
case 'i' : |
1366 |
if ("incomplete-switch".equals(warningToken)) //$NON-NLS-1$ |
1367 |
return IncompleteEnumSwitch; |
1368 |
break; |
1369 |
case 'n' : |
1370 |
if ("nls".equals(warningToken)) //$NON-NLS-1$ |
1371 |
return NonExternalizedString; |
1372 |
if ("null".equals(warningToken)) //$NON-NLS-1$ |
1373 |
return NullReference | PotentialNullReference | RedundantNullCheck; |
1374 |
break; |
1375 |
case 'r' : |
1376 |
if ("restriction".equals(warningToken)) //$NON-NLS-1$ |
1377 |
return DiscouragedReference | ForbiddenReference; |
1378 |
break; |
1379 |
case 's' : |
1380 |
if ("serial".equals(warningToken)) //$NON-NLS-1$ |
1381 |
return MissingSerialVersion; |
1382 |
if ("static-access".equals(warningToken)) //$NON-NLS-1$ |
1383 |
return IndirectStaticAccess | NonStaticAccessToStatic; |
1384 |
if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$ |
1385 |
return AccessEmulation; |
1386 |
if ("super".equals(warningToken)) { //$NON-NLS-1$ |
1387 |
return OverridingMethodWithoutSuperInvocation; |
1388 |
} |
1389 |
break; |
1390 |
case 'u' : |
1391 |
if ("unused".equals(warningToken)) //$NON-NLS-1$ |
1392 |
return UnusedLocalVariable | UnusedArgument | UnusedPrivateMember | UnusedDeclaredThrownException | UnusedLabel | UnusedImport | UnusedTypeArguments | RedundantSuperinterface; |
1393 |
if ("unchecked".equals(warningToken)) //$NON-NLS-1$ |
1394 |
return UncheckedTypeOperation | RawTypeReference; |
1395 |
if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$ |
1396 |
return UnqualifiedFieldAccess; |
1397 |
break; |
1398 |
} |
1471 |
} |
1399 |
return 0; |
|
|
1400 |
} |
1472 |
} |
1401 |
} |
1473 |
} |