0001: /*******************************************************************************
0002: * Copyright (c) 2000, 2007 IBM Corporation and others.
0003: * All rights reserved. This program and the accompanying materials
0004: * are made available under the terms of the Eclipse Public License v1.0
0005: * which accompanies this distribution, and is available at
0006: * http://www.eclipse.org/legal/epl-v10.html
0007: *
0008: * Contributors:
0009: * IBM Corporation - initial API and implementation
0010: *******************************************************************************/package org.eclipse.jdt.internal.compiler.impl;
0011:
0012: import java.io.ByteArrayInputStream;
0013: import java.io.InputStreamReader;
0014: import java.io.UnsupportedEncodingException;
0015: import java.util.HashMap;
0016: import java.util.Map;
0017:
0018: import org.eclipse.jdt.core.compiler.CharOperation;
0019: import org.eclipse.jdt.internal.compiler.Compiler;
0020: import org.eclipse.jdt.internal.compiler.ast.ASTNode;
0021: import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
0022: import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
0023: import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
0024: import org.eclipse.jdt.internal.compiler.util.Util;
0025:
0026: public class CompilerOptions {
0027:
0028: /**
0029: * Option IDs
0030: */
0031: public static final String OPTION_LocalVariableAttribute = "org.eclipse.jdt.core.compiler.debug.localVariable"; //$NON-NLS-1$
0032: public static final String OPTION_LineNumberAttribute = "org.eclipse.jdt.core.compiler.debug.lineNumber"; //$NON-NLS-1$
0033: public static final String OPTION_SourceFileAttribute = "org.eclipse.jdt.core.compiler.debug.sourceFile"; //$NON-NLS-1$
0034: public static final String OPTION_PreserveUnusedLocal = "org.eclipse.jdt.core.compiler.codegen.unusedLocal"; //$NON-NLS-1$
0035: public static final String OPTION_DocCommentSupport = "org.eclipse.jdt.core.compiler.doc.comment.support"; //$NON-NLS-1$
0036: public static final String OPTION_ReportMethodWithConstructorName = "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
0037: public static final String OPTION_ReportOverridingPackageDefaultMethod = "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
0038: public static final String OPTION_ReportDeprecation = "org.eclipse.jdt.core.compiler.problem.deprecation"; //$NON-NLS-1$
0039: public static final String OPTION_ReportDeprecationInDeprecatedCode = "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
0040: public static final String OPTION_ReportDeprecationWhenOverridingDeprecatedMethod = "org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod"; //$NON-NLS-1$
0041: public static final String OPTION_ReportHiddenCatchBlock = "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
0042: public static final String OPTION_ReportUnusedLocal = "org.eclipse.jdt.core.compiler.problem.unusedLocal"; //$NON-NLS-1$
0043: public static final String OPTION_ReportUnusedParameter = "org.eclipse.jdt.core.compiler.problem.unusedParameter"; //$NON-NLS-1$
0044: public static final String OPTION_ReportUnusedParameterWhenImplementingAbstract = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
0045: public static final String OPTION_ReportUnusedParameterWhenOverridingConcrete = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
0046: public static final String OPTION_ReportUnusedParameterIncludeDocCommentReference = "org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference"; //$NON-NLS-1$
0047: public static final String OPTION_ReportUnusedImport = "org.eclipse.jdt.core.compiler.problem.unusedImport"; //$NON-NLS-1$
0048: public static final String OPTION_ReportSyntheticAccessEmulation = "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
0049: public static final String OPTION_ReportNoEffectAssignment = "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"; //$NON-NLS-1$
0050: public static final String OPTION_ReportLocalVariableHiding = "org.eclipse.jdt.core.compiler.problem.localVariableHiding"; //$NON-NLS-1$
0051: public static final String OPTION_ReportSpecialParameterHidingField = "org.eclipse.jdt.core.compiler.problem.specialParameterHidingField"; //$NON-NLS-1$
0052: public static final String OPTION_ReportFieldHiding = "org.eclipse.jdt.core.compiler.problem.fieldHiding"; //$NON-NLS-1$
0053: public static final String OPTION_ReportTypeParameterHiding = "org.eclipse.jdt.core.compiler.problem.typeParameterHiding"; //$NON-NLS-1$
0054: public static final String OPTION_ReportPossibleAccidentalBooleanAssignment = "org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment"; //$NON-NLS-1$
0055: public static final String OPTION_ReportNonExternalizedStringLiteral = "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
0056: public static final String OPTION_ReportIncompatibleNonInheritedInterfaceMethod = "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
0057: public static final String OPTION_ReportUnusedPrivateMember = "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
0058: public static final String OPTION_ReportNoImplicitStringConversion = "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
0059: public static final String OPTION_ReportAssertIdentifier = "org.eclipse.jdt.core.compiler.problem.assertIdentifier"; //$NON-NLS-1$
0060: public static final String OPTION_ReportEnumIdentifier = "org.eclipse.jdt.core.compiler.problem.enumIdentifier"; //$NON-NLS-1$
0061: public static final String OPTION_ReportNonStaticAccessToStatic = "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
0062: public static final String OPTION_ReportIndirectStaticAccess = "org.eclipse.jdt.core.compiler.problem.indirectStaticAccess"; //$NON-NLS-1$
0063: public static final String OPTION_ReportEmptyStatement = "org.eclipse.jdt.core.compiler.problem.emptyStatement"; //$NON-NLS-1$
0064: public static final String OPTION_ReportUnnecessaryTypeCheck = "org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck"; //$NON-NLS-1$
0065: public static final String OPTION_ReportUnnecessaryElse = "org.eclipse.jdt.core.compiler.problem.unnecessaryElse"; //$NON-NLS-1$
0066: public static final String OPTION_ReportUndocumentedEmptyBlock = "org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock"; //$NON-NLS-1$
0067: public static final String OPTION_ReportInvalidJavadoc = "org.eclipse.jdt.core.compiler.problem.invalidJavadoc"; //$NON-NLS-1$
0068: public static final String OPTION_ReportInvalidJavadocTags = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTags"; //$NON-NLS-1$
0069: public static final String OPTION_ReportInvalidJavadocTagsDeprecatedRef = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef"; //$NON-NLS-1$
0070: public static final String OPTION_ReportInvalidJavadocTagsNotVisibleRef = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef"; //$NON-NLS-1$
0071: public static final String OPTION_ReportInvalidJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$
0072: public static final String OPTION_ReportMissingJavadocTags = "org.eclipse.jdt.core.compiler.problem.missingJavadocTags"; //$NON-NLS-1$
0073: public static final String OPTION_ReportMissingJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility"; //$NON-NLS-1$
0074: public static final String OPTION_ReportMissingJavadocTagsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding"; //$NON-NLS-1$
0075: public static final String OPTION_ReportMissingJavadocComments = "org.eclipse.jdt.core.compiler.problem.missingJavadocComments"; //$NON-NLS-1$
0076: public static final String OPTION_ReportMissingJavadocCommentsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility"; //$NON-NLS-1$
0077: public static final String OPTION_ReportMissingJavadocCommentsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding"; //$NON-NLS-1$
0078: public static final String OPTION_ReportFinallyBlockNotCompletingNormally = "org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally"; //$NON-NLS-1$
0079: public static final String OPTION_ReportUnusedDeclaredThrownException = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException"; //$NON-NLS-1$
0080: public static final String OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding"; //$NON-NLS-1$
0081: public static final String OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference"; //$NON-NLS-1$
0082: public static final String OPTION_ReportUnqualifiedFieldAccess = "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$
0083: public static final String OPTION_ReportUncheckedTypeOperation = "org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation"; //$NON-NLS-1$
0084: public static final String OPTION_ReportRawTypeReference = "org.eclipse.jdt.core.compiler.problem.rawTypeReference"; //$NON-NLS-1$
0085: public static final String OPTION_ReportFinalParameterBound = "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; //$NON-NLS-1$
0086: public static final String OPTION_ReportMissingSerialVersion = "org.eclipse.jdt.core.compiler.problem.missingSerialVersion"; //$NON-NLS-1$
0087: public static final String OPTION_ReportVarargsArgumentNeedCast = "org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast"; //$NON-NLS-1$
0088: public static final String OPTION_Source = "org.eclipse.jdt.core.compiler.source"; //$NON-NLS-1$
0089: public static final String OPTION_TargetPlatform = "org.eclipse.jdt.core.compiler.codegen.targetPlatform"; //$NON-NLS-1$
0090: public static final String OPTION_Compliance = "org.eclipse.jdt.core.compiler.compliance"; //$NON-NLS-1$
0091: public static final String OPTION_Encoding = "org.eclipse.jdt.core.encoding"; //$NON-NLS-1$
0092: public static final String OPTION_MaxProblemPerUnit = "org.eclipse.jdt.core.compiler.maxProblemPerUnit"; //$NON-NLS-1$
0093: public static final String OPTION_TaskTags = "org.eclipse.jdt.core.compiler.taskTags"; //$NON-NLS-1$
0094: public static final String OPTION_TaskPriorities = "org.eclipse.jdt.core.compiler.taskPriorities"; //$NON-NLS-1$
0095: public static final String OPTION_TaskCaseSensitive = "org.eclipse.jdt.core.compiler.taskCaseSensitive"; //$NON-NLS-1$
0096: public static final String OPTION_InlineJsr = "org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode"; //$NON-NLS-1$
0097: public static final String OPTION_ReportNullReference = "org.eclipse.jdt.core.compiler.problem.nullReference"; //$NON-NLS-1$
0098: public static final String OPTION_ReportPotentialNullReference = "org.eclipse.jdt.core.compiler.problem.potentialNullReference"; //$NON-NLS-1$
0099: public static final String OPTION_ReportRedundantNullCheck = "org.eclipse.jdt.core.compiler.problem.redundantNullCheck"; //$NON-NLS-1$
0100: public static final String OPTION_ReportAutoboxing = "org.eclipse.jdt.core.compiler.problem.autoboxing"; //$NON-NLS-1$
0101: public static final String OPTION_ReportAnnotationSuperInterface = "org.eclipse.jdt.core.compiler.problem.annotationSuperInterface"; //$NON-NLS-1$
0102: public static final String OPTION_ReportMissingOverrideAnnotation = "org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation"; //$NON-NLS-1$
0103: public static final String OPTION_ReportMissingDeprecatedAnnotation = "org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation"; //$NON-NLS-1$
0104: public static final String OPTION_ReportIncompleteEnumSwitch = "org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch"; //$NON-NLS-1$
0105: public static final String OPTION_ReportForbiddenReference = "org.eclipse.jdt.core.compiler.problem.forbiddenReference"; //$NON-NLS-1$
0106: public static final String OPTION_ReportDiscouragedReference = "org.eclipse.jdt.core.compiler.problem.discouragedReference"; //$NON-NLS-1$
0107: public static final String OPTION_SuppressWarnings = "org.eclipse.jdt.core.compiler.problem.suppressWarnings"; //$NON-NLS-1$
0108: public static final String OPTION_ReportUnhandledWarningToken = "org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"; //$NON-NLS-1$
0109: public static final String OPTION_ReportUnusedLabel = "org.eclipse.jdt.core.compiler.problem.unusedLabel"; //$NON-NLS-1$
0110: public static final String OPTION_FatalOptionalError = "org.eclipse.jdt.core.compiler.problem.fatalOptionalError"; //$NON-NLS-1$
0111: public static final String OPTION_ReportParameterAssignment = "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
0112: public static final String OPTION_ReportFallthroughCase = "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$
0113: public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation = "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
0114: public static final String OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; //$NON-NLS-1$
0115: public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
0116:
0117: // Backward compatibility
0118: public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
0119: public static final String OPTION_ReportMissingAnnotation = "org.eclipse.jdt.core.compiler.problem.missingAnnotation"; //$NON-NLS-1$
0120: public static final String OPTION_ReportMissingJavadoc = "org.eclipse.jdt.core.compiler.problem.missingJavadoc"; //$NON-NLS-1$
0121:
0122: /**
0123: * Possible values for configurable options
0124: */
0125: public static final String GENERATE = "generate";//$NON-NLS-1$
0126: public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
0127: public static final String PRESERVE = "preserve"; //$NON-NLS-1$
0128: public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
0129: public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
0130: public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
0131: public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
0132: public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
0133: public static final String VERSION_JSR14 = "jsr14"; //$NON-NLS-1$
0134: public static final String VERSION_CLDC1_1 = "cldc1.1"; //$NON-NLS-1$
0135: public static final String VERSION_1_5 = "1.5"; //$NON-NLS-1$
0136: public static final String VERSION_1_6 = "1.6"; //$NON-NLS-1$
0137: public static final String VERSION_1_7 = "1.7"; //$NON-NLS-1$
0138: public static final String ERROR = "error"; //$NON-NLS-1$
0139: public static final String WARNING = "warning"; //$NON-NLS-1$
0140: public static final String IGNORE = "ignore"; //$NON-NLS-1$
0141: public static final String ENABLED = "enabled"; //$NON-NLS-1$
0142: public static final String DISABLED = "disabled"; //$NON-NLS-1$
0143: public static final String PUBLIC = "public"; //$NON-NLS-1$
0144: public static final String PROTECTED = "protected"; //$NON-NLS-1$
0145: public static final String DEFAULT = "default"; //$NON-NLS-1$
0146: public static final String PRIVATE = "private"; //$NON-NLS-1$
0147:
0148: /**
0149: * Bit mask for configurable problems (error/warning threshold)
0150: */
0151: public static final long MethodWithConstructorName = ASTNode.Bit1;
0152: public static final long OverriddenPackageDefaultMethod = ASTNode.Bit2;
0153: public static final long UsingDeprecatedAPI = ASTNode.Bit3;
0154: public static final long MaskedCatchBlock = ASTNode.Bit4;
0155: public static final long UnusedLocalVariable = ASTNode.Bit5;
0156: public static final long UnusedArgument = ASTNode.Bit6;
0157: public static final long NoImplicitStringConversion = ASTNode.Bit7;
0158: public static final long AccessEmulation = ASTNode.Bit8;
0159: public static final long NonExternalizedString = ASTNode.Bit9;
0160: public static final long AssertUsedAsAnIdentifier = ASTNode.Bit10;
0161: public static final long UnusedImport = ASTNode.Bit11;
0162: public static final long NonStaticAccessToStatic = ASTNode.Bit12;
0163: public static final long Task = ASTNode.Bit13;
0164: public static final long NoEffectAssignment = ASTNode.Bit14;
0165: public static final long IncompatibleNonInheritedInterfaceMethod = ASTNode.Bit15;
0166: public static final long UnusedPrivateMember = ASTNode.Bit16;
0167: public static final long LocalVariableHiding = ASTNode.Bit17;
0168: public static final long FieldHiding = ASTNode.Bit18;
0169: public static final long AccidentalBooleanAssign = ASTNode.Bit19;
0170: public static final long EmptyStatement = ASTNode.Bit20;
0171: public static final long MissingJavadocComments = ASTNode.Bit21;
0172: public static final long MissingJavadocTags = ASTNode.Bit22;
0173: public static final long UnqualifiedFieldAccess = ASTNode.Bit23;
0174: public static final long UnusedDeclaredThrownException = ASTNode.Bit24;
0175: public static final long FinallyBlockNotCompleting = ASTNode.Bit25;
0176: public static final long InvalidJavadoc = ASTNode.Bit26;
0177: public static final long UnnecessaryTypeCheck = ASTNode.Bit27;
0178: public static final long UndocumentedEmptyBlock = ASTNode.Bit28;
0179: public static final long IndirectStaticAccess = ASTNode.Bit29;
0180: public static final long UnnecessaryElse = ASTNode.Bit30;
0181: public static final long UncheckedTypeOperation = ASTNode.Bit31;
0182: public static final long FinalParameterBound = ASTNode.Bit32L;
0183: public static final long MissingSerialVersion = ASTNode.Bit33L;
0184: public static final long EnumUsedAsAnIdentifier = ASTNode.Bit34L;
0185: public static final long ForbiddenReference = ASTNode.Bit35L;
0186: public static final long VarargsArgumentNeedCast = ASTNode.Bit36L;
0187: public static final long NullReference = ASTNode.Bit37L;
0188: public static final long AutoBoxing = ASTNode.Bit38L;
0189: public static final long AnnotationSuperInterface = ASTNode.Bit39L;
0190: public static final long TypeHiding = ASTNode.Bit40L;
0191: public static final long MissingOverrideAnnotation = ASTNode.Bit41L;
0192: public static final long IncompleteEnumSwitch = ASTNode.Bit42L;
0193: public static final long MissingDeprecatedAnnotation = ASTNode.Bit43L;
0194: public static final long DiscouragedReference = ASTNode.Bit44L;
0195: public static final long UnhandledWarningToken = ASTNode.Bit45L;
0196: public static final long RawTypeReference = ASTNode.Bit46L;
0197: public static final long UnusedLabel = ASTNode.Bit47L;
0198: public static final long ParameterAssignment = ASTNode.Bit48L;
0199: public static final long FallthroughCase = ASTNode.Bit49L;
0200: public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L;
0201: public static final long PotentialNullReference = ASTNode.Bit51L;
0202: public static final long RedundantNullCheck = ASTNode.Bit52L;
0203:
0204: // Map: String optionKey --> Long irritant>
0205: private static Map OptionToIrritants;
0206:
0207: // Default severity level for handlers
0208: public long errorThreshold = 0;
0209:
0210: public long warningThreshold = MethodWithConstructorName
0211: | UsingDeprecatedAPI | MaskedCatchBlock
0212: | OverriddenPackageDefaultMethod | UnusedImport
0213: | NonStaticAccessToStatic | NoEffectAssignment
0214: | IncompatibleNonInheritedInterfaceMethod
0215: | NoImplicitStringConversion | FinallyBlockNotCompleting
0216: | AssertUsedAsAnIdentifier | EnumUsedAsAnIdentifier
0217: | UncheckedTypeOperation | RawTypeReference
0218: | MissingSerialVersion | VarargsArgumentNeedCast
0219: | ForbiddenReference | DiscouragedReference
0220: | AnnotationSuperInterface | TypeHiding
0221: | FinalParameterBound | UnhandledWarningToken
0222: | UnusedLocalVariable | UnusedPrivateMember | UnusedLabel
0223: /*| NullReference -- keep JavaCore#getDefaultOptions comment in sync */;
0224:
0225: // By default only lines and source attributes are generated.
0226: public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE
0227: | ClassFileConstants.ATTR_LINES;
0228:
0229: public long complianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4
0230: public long sourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default
0231: public long targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2
0232:
0233: // source encoding format
0234: public String defaultEncoding = null; // will use the platform default encoding
0235:
0236: // print what unit is being processed
0237: public boolean verbose = Compiler.DEBUG;
0238:
0239: // indicates if reference info is desired
0240: public boolean produceReferenceInfo = false;
0241:
0242: // indicates if unused/optimizable local variables need to be preserved (debugging purpose)
0243: public boolean preserveAllLocalVariables = false;
0244:
0245: // indicates whether literal expressions are inlined at parse-time or not
0246: public boolean parseLiteralExpressionsAsConstants = true;
0247:
0248: // max problems per compilation unit
0249: public int maxProblemsPerUnit = 100; // no more than 100 problems per default
0250:
0251: // tags used to recognize tasks in comments
0252: public char[][] taskTags = null;
0253: public char[][] taskPriorites = null;
0254: public boolean isTaskCaseSensitive = true;
0255:
0256: // deprecation report
0257: public boolean reportDeprecationInsideDeprecatedCode = false;
0258: public boolean reportDeprecationWhenOverridingDeprecatedMethod = false;
0259:
0260: // unused parameters report
0261: public boolean reportUnusedParameterWhenImplementingAbstract = false;
0262: public boolean reportUnusedParameterWhenOverridingConcrete = false;
0263: public boolean reportUnusedParameterIncludeDocCommentReference = true;
0264:
0265: // unused declaration of thrown exception
0266: public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false;
0267: public boolean reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = true;
0268:
0269: // constructor/setter parameter hiding
0270: public boolean reportSpecialParameterHidingField = false;
0271:
0272: // check javadoc comments tags
0273: public int reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic;
0274: public boolean reportInvalidJavadocTags = false;
0275: public boolean reportInvalidJavadocTagsDeprecatedRef = false;
0276: public boolean reportInvalidJavadocTagsNotVisibleRef = false;
0277:
0278: // check missing javadoc tags
0279: public int reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic;
0280: public boolean reportMissingJavadocTagsOverriding = false;
0281:
0282: // check missing javadoc comments
0283: public int reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic;
0284: public boolean reportMissingJavadocCommentsOverriding = false;
0285:
0286: // JSR bytecode inlining
0287: public boolean inlineJsrBytecode = false;
0288:
0289: // javadoc comment support
0290: public boolean docCommentSupport = false;
0291:
0292: // suppress warning annotation
0293: public boolean suppressWarnings = true;
0294:
0295: // treat optional error as fatal or just like warning?
0296: public boolean treatOptionalErrorAsFatal = true;
0297:
0298: // parser perform statements recovery
0299: public boolean performMethodsFullRecovery = true;
0300:
0301: // parser perform statements recovery
0302: public boolean performStatementsRecovery = true;
0303:
0304: // store annotations
0305: public boolean storeAnnotations = false;
0306:
0307: // annotation processing
0308: public boolean generateClassFiles = true;
0309:
0310: // Enable annotation processing by default only in batch mode
0311: public boolean processAnnotations = false;
0312:
0313: /**
0314: * Initializing the compiler options with defaults
0315: */
0316: public CompilerOptions() {
0317: // use default options
0318: }
0319:
0320: /**
0321: * Initializing the compiler options with external settings
0322: * @param settings
0323: */
0324: public CompilerOptions(Map settings) {
0325:
0326: if (settings == null)
0327: return;
0328: set(settings);
0329: }
0330:
0331: /**
0332: * @deprecated used to preserve 3.1 and 3.2M4 compatibility of some Compiler constructors
0333: */
0334: public CompilerOptions(Map settings,
0335: boolean parseLiteralExpressionsAsConstants) {
0336: this (settings);
0337: this .parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants;
0338: }
0339:
0340: public Map getMap() {
0341: Map optionsMap = new HashMap(30);
0342: optionsMap
0343: .put(
0344: OPTION_LocalVariableAttribute,
0345: (this .produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? GENERATE
0346: : DO_NOT_GENERATE);
0347: optionsMap
0348: .put(
0349: OPTION_LineNumberAttribute,
0350: (this .produceDebugAttributes & ClassFileConstants.ATTR_LINES) != 0 ? GENERATE
0351: : DO_NOT_GENERATE);
0352: optionsMap
0353: .put(
0354: OPTION_SourceFileAttribute,
0355: (this .produceDebugAttributes & ClassFileConstants.ATTR_SOURCE) != 0 ? GENERATE
0356: : DO_NOT_GENERATE);
0357: optionsMap.put(OPTION_PreserveUnusedLocal,
0358: this .preserveAllLocalVariables ? PRESERVE
0359: : OPTIMIZE_OUT);
0360: optionsMap.put(OPTION_DocCommentSupport,
0361: this .docCommentSupport ? ENABLED : DISABLED);
0362: optionsMap.put(OPTION_ReportMethodWithConstructorName,
0363: getSeverityString(MethodWithConstructorName));
0364: optionsMap.put(OPTION_ReportOverridingPackageDefaultMethod,
0365: getSeverityString(OverriddenPackageDefaultMethod));
0366: optionsMap.put(OPTION_ReportDeprecation,
0367: getSeverityString(UsingDeprecatedAPI));
0368: optionsMap.put(OPTION_ReportDeprecationInDeprecatedCode,
0369: this .reportDeprecationInsideDeprecatedCode ? ENABLED
0370: : DISABLED);
0371: optionsMap
0372: .put(
0373: OPTION_ReportDeprecationWhenOverridingDeprecatedMethod,
0374: this .reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED
0375: : DISABLED);
0376: optionsMap.put(OPTION_ReportHiddenCatchBlock,
0377: getSeverityString(MaskedCatchBlock));
0378: optionsMap.put(OPTION_ReportUnusedLocal,
0379: getSeverityString(UnusedLocalVariable));
0380: optionsMap.put(OPTION_ReportUnusedParameter,
0381: getSeverityString(UnusedArgument));
0382: optionsMap.put(OPTION_ReportUnusedImport,
0383: getSeverityString(UnusedImport));
0384: optionsMap.put(OPTION_ReportSyntheticAccessEmulation,
0385: getSeverityString(AccessEmulation));
0386: optionsMap.put(OPTION_ReportNoEffectAssignment,
0387: getSeverityString(NoEffectAssignment));
0388: optionsMap.put(OPTION_ReportNonExternalizedStringLiteral,
0389: getSeverityString(NonExternalizedString));
0390: optionsMap.put(OPTION_ReportNoImplicitStringConversion,
0391: getSeverityString(NoImplicitStringConversion));
0392: optionsMap.put(OPTION_ReportNonStaticAccessToStatic,
0393: getSeverityString(NonStaticAccessToStatic));
0394: optionsMap.put(OPTION_ReportIndirectStaticAccess,
0395: getSeverityString(IndirectStaticAccess));
0396: optionsMap
0397: .put(
0398: OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
0399: getSeverityString(IncompatibleNonInheritedInterfaceMethod));
0400: optionsMap.put(OPTION_ReportUnusedPrivateMember,
0401: getSeverityString(UnusedPrivateMember));
0402: optionsMap.put(OPTION_ReportLocalVariableHiding,
0403: getSeverityString(LocalVariableHiding));
0404: optionsMap.put(OPTION_ReportFieldHiding,
0405: getSeverityString(FieldHiding));
0406: optionsMap.put(OPTION_ReportTypeParameterHiding,
0407: getSeverityString(TypeHiding));
0408: optionsMap.put(
0409: OPTION_ReportPossibleAccidentalBooleanAssignment,
0410: getSeverityString(AccidentalBooleanAssign));
0411: optionsMap.put(OPTION_ReportEmptyStatement,
0412: getSeverityString(EmptyStatement));
0413: optionsMap.put(OPTION_ReportAssertIdentifier,
0414: getSeverityString(AssertUsedAsAnIdentifier));
0415: optionsMap.put(OPTION_ReportEnumIdentifier,
0416: getSeverityString(EnumUsedAsAnIdentifier));
0417: optionsMap.put(OPTION_ReportUndocumentedEmptyBlock,
0418: getSeverityString(UndocumentedEmptyBlock));
0419: optionsMap.put(OPTION_ReportUnnecessaryTypeCheck,
0420: getSeverityString(UnnecessaryTypeCheck));
0421: optionsMap.put(OPTION_ReportUnnecessaryElse,
0422: getSeverityString(UnnecessaryElse));
0423: optionsMap.put(OPTION_ReportAutoboxing,
0424: getSeverityString(AutoBoxing));
0425: optionsMap.put(OPTION_ReportAnnotationSuperInterface,
0426: getSeverityString(AnnotationSuperInterface));
0427: optionsMap.put(OPTION_ReportIncompleteEnumSwitch,
0428: getSeverityString(IncompleteEnumSwitch));
0429: optionsMap.put(OPTION_ReportInvalidJavadoc,
0430: getSeverityString(InvalidJavadoc));
0431: optionsMap
0432: .put(
0433: OPTION_ReportInvalidJavadocTagsVisibility,
0434: getVisibilityString(this .reportInvalidJavadocTagsVisibility));
0435: optionsMap.put(OPTION_ReportInvalidJavadocTags,
0436: this .reportInvalidJavadocTags ? ENABLED : DISABLED);
0437: optionsMap.put(OPTION_ReportInvalidJavadocTagsDeprecatedRef,
0438: this .reportInvalidJavadocTagsDeprecatedRef ? ENABLED
0439: : DISABLED);
0440: optionsMap.put(OPTION_ReportInvalidJavadocTagsNotVisibleRef,
0441: this .reportInvalidJavadocTagsNotVisibleRef ? ENABLED
0442: : DISABLED);
0443: optionsMap.put(OPTION_ReportMissingJavadocTags,
0444: getSeverityString(MissingJavadocTags));
0445: optionsMap
0446: .put(
0447: OPTION_ReportMissingJavadocTagsVisibility,
0448: getVisibilityString(this .reportMissingJavadocTagsVisibility));
0449: optionsMap.put(OPTION_ReportMissingJavadocTagsOverriding,
0450: this .reportMissingJavadocTagsOverriding ? ENABLED
0451: : DISABLED);
0452: optionsMap.put(OPTION_ReportMissingJavadocComments,
0453: getSeverityString(MissingJavadocComments));
0454: optionsMap
0455: .put(
0456: OPTION_ReportMissingJavadocCommentsVisibility,
0457: getVisibilityString(this .reportMissingJavadocCommentsVisibility));
0458: optionsMap.put(OPTION_ReportMissingJavadocCommentsOverriding,
0459: this .reportMissingJavadocCommentsOverriding ? ENABLED
0460: : DISABLED);
0461: optionsMap.put(OPTION_ReportFinallyBlockNotCompletingNormally,
0462: getSeverityString(FinallyBlockNotCompleting));
0463: optionsMap.put(OPTION_ReportUnusedDeclaredThrownException,
0464: getSeverityString(UnusedDeclaredThrownException));
0465: optionsMap
0466: .put(
0467: OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding,
0468: this .reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED
0469: : DISABLED);
0470: optionsMap
0471: .put(
0472: OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference,
0473: this .reportUnusedDeclaredThrownExceptionIncludeDocCommentReference ? ENABLED
0474: : DISABLED);
0475: optionsMap.put(OPTION_ReportUnqualifiedFieldAccess,
0476: getSeverityString(UnqualifiedFieldAccess));
0477: optionsMap.put(OPTION_ReportUncheckedTypeOperation,
0478: getSeverityString(UncheckedTypeOperation));
0479: optionsMap.put(OPTION_ReportRawTypeReference,
0480: getSeverityString(RawTypeReference));
0481: optionsMap.put(OPTION_ReportFinalParameterBound,
0482: getSeverityString(FinalParameterBound));
0483: optionsMap.put(OPTION_ReportMissingSerialVersion,
0484: getSeverityString(MissingSerialVersion));
0485: optionsMap.put(OPTION_ReportForbiddenReference,
0486: getSeverityString(ForbiddenReference));
0487: optionsMap.put(OPTION_ReportDiscouragedReference,
0488: getSeverityString(DiscouragedReference));
0489: optionsMap.put(OPTION_ReportVarargsArgumentNeedCast,
0490: getSeverityString(VarargsArgumentNeedCast));
0491: optionsMap.put(OPTION_ReportMissingOverrideAnnotation,
0492: getSeverityString(MissingOverrideAnnotation));
0493: optionsMap.put(OPTION_ReportMissingDeprecatedAnnotation,
0494: getSeverityString(MissingDeprecatedAnnotation));
0495: optionsMap.put(OPTION_ReportIncompleteEnumSwitch,
0496: getSeverityString(IncompleteEnumSwitch));
0497: optionsMap.put(OPTION_ReportUnusedLabel,
0498: getSeverityString(UnusedLabel));
0499: optionsMap.put(OPTION_Compliance,
0500: versionFromJdkLevel(this .complianceLevel));
0501: optionsMap.put(OPTION_Source,
0502: versionFromJdkLevel(this .sourceLevel));
0503: optionsMap.put(OPTION_TargetPlatform,
0504: versionFromJdkLevel(this .targetJDK));
0505: optionsMap.put(OPTION_FatalOptionalError,
0506: this .treatOptionalErrorAsFatal ? ENABLED : DISABLED);
0507: if (this .defaultEncoding != null) {
0508: optionsMap.put(OPTION_Encoding, this .defaultEncoding);
0509: }
0510: optionsMap.put(OPTION_TaskTags,
0511: this .taskTags == null ? Util.EMPTY_STRING : new String(
0512: CharOperation.concatWith(this .taskTags, ',')));
0513: optionsMap.put(OPTION_TaskPriorities,
0514: this .taskPriorites == null ? Util.EMPTY_STRING
0515: : new String(CharOperation.concatWith(
0516: this .taskPriorites, ',')));
0517: optionsMap.put(OPTION_TaskCaseSensitive,
0518: this .isTaskCaseSensitive ? ENABLED : DISABLED);
0519: optionsMap
0520: .put(
0521: OPTION_ReportUnusedParameterWhenImplementingAbstract,
0522: this .reportUnusedParameterWhenImplementingAbstract ? ENABLED
0523: : DISABLED);
0524: optionsMap
0525: .put(
0526: OPTION_ReportUnusedParameterWhenOverridingConcrete,
0527: this .reportUnusedParameterWhenOverridingConcrete ? ENABLED
0528: : DISABLED);
0529: optionsMap
0530: .put(
0531: OPTION_ReportUnusedParameterIncludeDocCommentReference,
0532: this .reportUnusedParameterIncludeDocCommentReference ? ENABLED
0533: : DISABLED);
0534: optionsMap.put(OPTION_ReportSpecialParameterHidingField,
0535: this .reportSpecialParameterHidingField ? ENABLED
0536: : DISABLED);
0537: optionsMap.put(OPTION_MaxProblemPerUnit, String
0538: .valueOf(this .maxProblemsPerUnit));
0539: optionsMap.put(OPTION_InlineJsr,
0540: this .inlineJsrBytecode ? ENABLED : DISABLED);
0541: optionsMap.put(OPTION_ReportNullReference,
0542: getSeverityString(NullReference));
0543: optionsMap.put(OPTION_ReportPotentialNullReference,
0544: getSeverityString(PotentialNullReference));
0545: optionsMap.put(OPTION_ReportRedundantNullCheck,
0546: getSeverityString(RedundantNullCheck));
0547: optionsMap.put(OPTION_SuppressWarnings,
0548: this .suppressWarnings ? ENABLED : DISABLED);
0549: optionsMap.put(OPTION_ReportUnhandledWarningToken,
0550: getSeverityString(UnhandledWarningToken));
0551: optionsMap.put(OPTION_ReportParameterAssignment,
0552: getSeverityString(ParameterAssignment));
0553: optionsMap.put(OPTION_ReportFallthroughCase,
0554: getSeverityString(FallthroughCase));
0555: optionsMap
0556: .put(
0557: OPTION_ReportOverridingMethodWithoutSuperInvocation,
0558: getSeverityString(OverridingMethodWithoutSuperInvocation));
0559: optionsMap.put(OPTION_GenerateClassFiles,
0560: this .generateClassFiles ? ENABLED : DISABLED);
0561: optionsMap.put(OPTION_Process_Annotations,
0562: this .processAnnotations ? ENABLED : DISABLED);
0563: return optionsMap;
0564: }
0565:
0566: /**
0567: * Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by
0568: * other master options (e.g. javadoc, deprecation, etc.).
0569: * This information is intended for grouping purpose (several problems governed by a rule)
0570: */
0571: public static String optionKeyFromIrritant(long irritant) {
0572: // keep in sync with warningTokens and warningTokenToIrritant
0573: int irritantInt = (int) irritant;
0574: if (irritantInt == irritant) {
0575: switch (irritantInt) {
0576: case (int) MethodWithConstructorName:
0577: return OPTION_ReportMethodWithConstructorName;
0578: case (int) OverriddenPackageDefaultMethod:
0579: return OPTION_ReportOverridingPackageDefaultMethod;
0580: case (int) UsingDeprecatedAPI:
0581: case (int) (InvalidJavadoc | UsingDeprecatedAPI):
0582: return OPTION_ReportDeprecation;
0583: case (int) MaskedCatchBlock:
0584: return OPTION_ReportHiddenCatchBlock;
0585: case (int) UnusedLocalVariable:
0586: return OPTION_ReportUnusedLocal;
0587: case (int) UnusedArgument:
0588: return OPTION_ReportUnusedParameter;
0589: case (int) NoImplicitStringConversion:
0590: return OPTION_ReportNoImplicitStringConversion;
0591: case (int) AccessEmulation:
0592: return OPTION_ReportSyntheticAccessEmulation;
0593: case (int) NonExternalizedString:
0594: return OPTION_ReportNonExternalizedStringLiteral;
0595: case (int) AssertUsedAsAnIdentifier:
0596: return OPTION_ReportAssertIdentifier;
0597: case (int) UnusedImport:
0598: return OPTION_ReportUnusedImport;
0599: case (int) NonStaticAccessToStatic:
0600: return OPTION_ReportNonStaticAccessToStatic;
0601: case (int) Task:
0602: return OPTION_TaskTags;
0603: case (int) NoEffectAssignment:
0604: return OPTION_ReportNoEffectAssignment;
0605: case (int) IncompatibleNonInheritedInterfaceMethod:
0606: return OPTION_ReportIncompatibleNonInheritedInterfaceMethod;
0607: case (int) UnusedPrivateMember:
0608: return OPTION_ReportUnusedPrivateMember;
0609: case (int) LocalVariableHiding:
0610: return OPTION_ReportLocalVariableHiding;
0611: case (int) FieldHiding:
0612: return OPTION_ReportFieldHiding;
0613: case (int) AccidentalBooleanAssign:
0614: return OPTION_ReportPossibleAccidentalBooleanAssignment;
0615: case (int) EmptyStatement:
0616: return OPTION_ReportEmptyStatement;
0617: case (int) MissingJavadocComments:
0618: return OPTION_ReportMissingJavadocComments;
0619: case (int) MissingJavadocTags:
0620: return OPTION_ReportMissingJavadocTags;
0621: case (int) UnqualifiedFieldAccess:
0622: return OPTION_ReportUnqualifiedFieldAccess;
0623: case (int) UnusedDeclaredThrownException:
0624: return OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding;
0625: case (int) FinallyBlockNotCompleting:
0626: return OPTION_ReportFinallyBlockNotCompletingNormally;
0627: case (int) InvalidJavadoc:
0628: return OPTION_ReportInvalidJavadoc;
0629: case (int) UnnecessaryTypeCheck:
0630: return OPTION_ReportUnnecessaryTypeCheck;
0631: case (int) UndocumentedEmptyBlock:
0632: return OPTION_ReportUndocumentedEmptyBlock;
0633: case (int) IndirectStaticAccess:
0634: return OPTION_ReportIndirectStaticAccess;
0635: case (int) UnnecessaryElse:
0636: return OPTION_ReportUnnecessaryElse;
0637: case (int) UncheckedTypeOperation:
0638: return OPTION_ReportUncheckedTypeOperation;
0639: case (int) FinalParameterBound:
0640: return OPTION_ReportFinalParameterBound;
0641: }
0642: } else {
0643: irritantInt = (int) (irritant >>> 32);
0644: switch (irritantInt) {
0645: case (int) (MissingSerialVersion >>> 32):
0646: return OPTION_ReportMissingSerialVersion;
0647: case (int) (EnumUsedAsAnIdentifier >>> 32):
0648: return OPTION_ReportEnumIdentifier;
0649: case (int) (ForbiddenReference >>> 32):
0650: return OPTION_ReportForbiddenReference;
0651: case (int) (VarargsArgumentNeedCast >>> 32):
0652: return OPTION_ReportVarargsArgumentNeedCast;
0653: case (int) (NullReference >>> 32):
0654: return OPTION_ReportNullReference;
0655: case (int) (PotentialNullReference >>> 32):
0656: return OPTION_ReportPotentialNullReference;
0657: case (int) (RedundantNullCheck >>> 32):
0658: return OPTION_ReportRedundantNullCheck;
0659: case (int) (AutoBoxing >>> 32):
0660: return OPTION_ReportAutoboxing;
0661: case (int) (AnnotationSuperInterface >>> 32):
0662: return OPTION_ReportAnnotationSuperInterface;
0663: case (int) (TypeHiding >>> 32):
0664: return OPTION_ReportTypeParameterHiding;
0665: case (int) (MissingOverrideAnnotation >>> 32):
0666: return OPTION_ReportMissingOverrideAnnotation;
0667: case (int) (IncompleteEnumSwitch >>> 32):
0668: return OPTION_ReportIncompleteEnumSwitch;
0669: case (int) (MissingDeprecatedAnnotation >>> 32):
0670: return OPTION_ReportMissingDeprecatedAnnotation;
0671: case (int) (DiscouragedReference >>> 32):
0672: return OPTION_ReportDiscouragedReference;
0673: case (int) (UnhandledWarningToken >>> 32):
0674: return OPTION_ReportUnhandledWarningToken;
0675: case (int) (RawTypeReference >>> 32):
0676: return OPTION_ReportRawTypeReference;
0677: case (int) (UnusedLabel >>> 32):
0678: return OPTION_ReportUnusedLabel;
0679: case (int) (ParameterAssignment >>> 32):
0680: return OPTION_ReportParameterAssignment;
0681: case (int) (FallthroughCase >>> 32):
0682: return OPTION_ReportFallthroughCase;
0683: case (int) (OverridingMethodWithoutSuperInvocation >>> 32):
0684: return OPTION_ReportOverridingMethodWithoutSuperInvocation;
0685: }
0686: }
0687: return null;
0688: }
0689:
0690: public static long optionKeyToIrritant(String optionName) {
0691: if (OptionToIrritants == null) {
0692: long irritant = 0;
0693: for (int i = 0; i < 64; i++) {
0694: irritant <<= 1;
0695: String optionKey = optionKeyFromIrritant(irritant);
0696: if (optionKey == null)
0697: continue;
0698: OptionToIrritants.put(optionKey, new Long(irritant));
0699: }
0700: }
0701: Long irritant = (Long) OptionToIrritants.get(optionName);
0702: return irritant == null ? 0 : irritant.longValue();
0703: }
0704:
0705: public int getSeverity(long irritant) {
0706: if ((this .errorThreshold & irritant) != 0) {
0707: return this .treatOptionalErrorAsFatal ? ProblemSeverities.Error
0708: | ProblemSeverities.Optional
0709: | ProblemSeverities.Fatal
0710: : ProblemSeverities.Error
0711: | ProblemSeverities.Optional;
0712: }
0713: if ((this .warningThreshold & irritant) != 0)
0714: return ProblemSeverities.Warning
0715: | ProblemSeverities.Optional;
0716: return ProblemSeverities.Ignore;
0717: }
0718:
0719: public String getSeverityString(long irritant) {
0720: if ((this .warningThreshold & irritant) != 0)
0721: return WARNING;
0722: if ((this .errorThreshold & irritant) != 0)
0723: return ERROR;
0724: return IGNORE;
0725: }
0726:
0727: public String getVisibilityString(int level) {
0728: switch (level & ExtraCompilerModifiers.AccVisibilityMASK) {
0729: case ClassFileConstants.AccPublic:
0730: return PUBLIC;
0731: case ClassFileConstants.AccProtected:
0732: return PROTECTED;
0733: case ClassFileConstants.AccPrivate:
0734: return PRIVATE;
0735: default:
0736: return DEFAULT;
0737: }
0738: }
0739:
0740: public void set(Map optionsMap) {
0741:
0742: Object optionValue;
0743: if ((optionValue = optionsMap
0744: .get(OPTION_LocalVariableAttribute)) != null) {
0745: if (GENERATE.equals(optionValue)) {
0746: this .produceDebugAttributes |= ClassFileConstants.ATTR_VARS;
0747: } else if (DO_NOT_GENERATE.equals(optionValue)) {
0748: this .produceDebugAttributes &= ~ClassFileConstants.ATTR_VARS;
0749: }
0750: }
0751: if ((optionValue = optionsMap.get(OPTION_LineNumberAttribute)) != null) {
0752: if (GENERATE.equals(optionValue)) {
0753: this .produceDebugAttributes |= ClassFileConstants.ATTR_LINES;
0754: } else if (DO_NOT_GENERATE.equals(optionValue)) {
0755: this .produceDebugAttributes &= ~ClassFileConstants.ATTR_LINES;
0756: }
0757: }
0758: if ((optionValue = optionsMap.get(OPTION_SourceFileAttribute)) != null) {
0759: if (GENERATE.equals(optionValue)) {
0760: this .produceDebugAttributes |= ClassFileConstants.ATTR_SOURCE;
0761: } else if (DO_NOT_GENERATE.equals(optionValue)) {
0762: this .produceDebugAttributes &= ~ClassFileConstants.ATTR_SOURCE;
0763: }
0764: }
0765: if ((optionValue = optionsMap.get(OPTION_PreserveUnusedLocal)) != null) {
0766: if (PRESERVE.equals(optionValue)) {
0767: this .preserveAllLocalVariables = true;
0768: } else if (OPTIMIZE_OUT.equals(optionValue)) {
0769: this .preserveAllLocalVariables = false;
0770: }
0771: }
0772: if ((optionValue = optionsMap
0773: .get(OPTION_ReportDeprecationInDeprecatedCode)) != null) {
0774: if (ENABLED.equals(optionValue)) {
0775: this .reportDeprecationInsideDeprecatedCode = true;
0776: } else if (DISABLED.equals(optionValue)) {
0777: this .reportDeprecationInsideDeprecatedCode = false;
0778: }
0779: }
0780: if ((optionValue = optionsMap
0781: .get(OPTION_ReportDeprecationWhenOverridingDeprecatedMethod)) != null) {
0782: if (ENABLED.equals(optionValue)) {
0783: this .reportDeprecationWhenOverridingDeprecatedMethod = true;
0784: } else if (DISABLED.equals(optionValue)) {
0785: this .reportDeprecationWhenOverridingDeprecatedMethod = false;
0786: }
0787: }
0788: if ((optionValue = optionsMap
0789: .get(OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding)) != null) {
0790: if (ENABLED.equals(optionValue)) {
0791: this .reportUnusedDeclaredThrownExceptionWhenOverriding = true;
0792: } else if (DISABLED.equals(optionValue)) {
0793: this .reportUnusedDeclaredThrownExceptionWhenOverriding = false;
0794: }
0795: }
0796: if ((optionValue = optionsMap
0797: .get(OPTION_ReportUnusedDeclaredThrownExceptionIncludeDocCommentReference)) != null) {
0798: if (ENABLED.equals(optionValue)) {
0799: this .reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = true;
0800: } else if (DISABLED.equals(optionValue)) {
0801: this .reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = false;
0802: }
0803: }
0804: if ((optionValue = optionsMap.get(OPTION_Compliance)) != null) {
0805: long level = versionToJdkLevel(optionValue);
0806: if (level != 0)
0807: this .complianceLevel = level;
0808: }
0809: if ((optionValue = optionsMap.get(OPTION_Source)) != null) {
0810: long level = versionToJdkLevel(optionValue);
0811: if (level != 0)
0812: this .sourceLevel = level;
0813: }
0814: if ((optionValue = optionsMap.get(OPTION_TargetPlatform)) != null) {
0815: long level = versionToJdkLevel(optionValue);
0816: if (level != 0)
0817: this .targetJDK = level;
0818: if (this .targetJDK >= ClassFileConstants.JDK1_5)
0819: this .inlineJsrBytecode = true; // forced from 1.5 mode on
0820: }
0821: if ((optionValue = optionsMap.get(OPTION_Encoding)) != null) {
0822: if (optionValue instanceof String) {
0823: this .defaultEncoding = null;
0824: String stringValue = (String) optionValue;
0825: if (stringValue.length() > 0) {
0826: try {
0827: new InputStreamReader(new ByteArrayInputStream(
0828: new byte[0]), stringValue);
0829: this .defaultEncoding = stringValue;
0830: } catch (UnsupportedEncodingException e) {
0831: // ignore unsupported encoding
0832: }
0833: }
0834: }
0835: }
0836: if ((optionValue = optionsMap
0837: .get(OPTION_ReportUnusedParameterWhenImplementingAbstract)) != null) {
0838: if (ENABLED.equals(optionValue)) {
0839: this .reportUnusedParameterWhenImplementingAbstract = true;
0840: } else if (DISABLED.equals(optionValue)) {
0841: this .reportUnusedParameterWhenImplementingAbstract = false;
0842: }
0843: }
0844: if ((optionValue = optionsMap
0845: .get(OPTION_ReportUnusedParameterWhenOverridingConcrete)) != null) {
0846: if (ENABLED.equals(optionValue)) {
0847: this .reportUnusedParameterWhenOverridingConcrete = true;
0848: } else if (DISABLED.equals(optionValue)) {
0849: this .reportUnusedParameterWhenOverridingConcrete = false;
0850: }
0851: }
0852: if ((optionValue = optionsMap
0853: .get(OPTION_ReportUnusedParameterIncludeDocCommentReference)) != null) {
0854: if (ENABLED.equals(optionValue)) {
0855: this .reportUnusedParameterIncludeDocCommentReference = true;
0856: } else if (DISABLED.equals(optionValue)) {
0857: this .reportUnusedParameterIncludeDocCommentReference = false;
0858: }
0859: }
0860: if ((optionValue = optionsMap
0861: .get(OPTION_ReportSpecialParameterHidingField)) != null) {
0862: if (ENABLED.equals(optionValue)) {
0863: this .reportSpecialParameterHidingField = true;
0864: } else if (DISABLED.equals(optionValue)) {
0865: this .reportSpecialParameterHidingField = false;
0866: }
0867: }
0868: if ((optionValue = optionsMap.get(OPTION_MaxProblemPerUnit)) != null) {
0869: if (optionValue instanceof String) {
0870: String stringValue = (String) optionValue;
0871: try {
0872: int val = Integer.parseInt(stringValue);
0873: if (val >= 0)
0874: this .maxProblemsPerUnit = val;
0875: } catch (NumberFormatException e) {
0876: // ignore ill-formatted limit
0877: }
0878: }
0879: }
0880: if ((optionValue = optionsMap.get(OPTION_TaskTags)) != null) {
0881: if (optionValue instanceof String) {
0882: String stringValue = (String) optionValue;
0883: if (stringValue.length() == 0) {
0884: this .taskTags = null;
0885: } else {
0886: this .taskTags = CharOperation.splitAndTrimOn(',',
0887: stringValue.toCharArray());
0888: }
0889: }
0890: }
0891: if ((optionValue = optionsMap.get(OPTION_TaskPriorities)) != null) {
0892: if (optionValue instanceof String) {
0893: String stringValue = (String) optionValue;
0894: if (stringValue.length() == 0) {
0895: this .taskPriorites = null;
0896: } else {
0897: this .taskPriorites = CharOperation.splitAndTrimOn(
0898: ',', stringValue.toCharArray());
0899: }
0900: }
0901: }
0902: if ((optionValue = optionsMap.get(OPTION_TaskCaseSensitive)) != null) {
0903: if (ENABLED.equals(optionValue)) {
0904: this .isTaskCaseSensitive = true;
0905: } else if (DISABLED.equals(optionValue)) {
0906: this .isTaskCaseSensitive = false;
0907: }
0908: }
0909: if ((optionValue = optionsMap.get(OPTION_InlineJsr)) != null) {
0910: if (this .targetJDK < ClassFileConstants.JDK1_5) { // only optional if target < 1.5 (inlining on from 1.5 on)
0911: if (ENABLED.equals(optionValue)) {
0912: this .inlineJsrBytecode = true;
0913: } else if (DISABLED.equals(optionValue)) {
0914: this .inlineJsrBytecode = false;
0915: }
0916: }
0917: }
0918: if ((optionValue = optionsMap.get(OPTION_SuppressWarnings)) != null) {
0919: if (ENABLED.equals(optionValue)) {
0920: this .suppressWarnings = true;
0921: } else if (DISABLED.equals(optionValue)) {
0922: this .suppressWarnings = false;
0923: }
0924: }
0925: if ((optionValue = optionsMap.get(OPTION_FatalOptionalError)) != null) {
0926: if (ENABLED.equals(optionValue)) {
0927: this .treatOptionalErrorAsFatal = true;
0928: } else if (DISABLED.equals(optionValue)) {
0929: this .treatOptionalErrorAsFatal = false;
0930: }
0931: }
0932: if ((optionValue = optionsMap
0933: .get(OPTION_ReportMethodWithConstructorName)) != null)
0934: updateSeverity(MethodWithConstructorName, optionValue);
0935: if ((optionValue = optionsMap
0936: .get(OPTION_ReportOverridingPackageDefaultMethod)) != null)
0937: updateSeverity(OverriddenPackageDefaultMethod, optionValue);
0938: if ((optionValue = optionsMap.get(OPTION_ReportDeprecation)) != null)
0939: updateSeverity(UsingDeprecatedAPI, optionValue);
0940: if ((optionValue = optionsMap
0941: .get(OPTION_ReportHiddenCatchBlock)) != null)
0942: updateSeverity(MaskedCatchBlock, optionValue);
0943: if ((optionValue = optionsMap.get(OPTION_ReportUnusedLocal)) != null)
0944: updateSeverity(UnusedLocalVariable, optionValue);
0945: if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameter)) != null)
0946: updateSeverity(UnusedArgument, optionValue);
0947: if ((optionValue = optionsMap.get(OPTION_ReportUnusedImport)) != null)
0948: updateSeverity(UnusedImport, optionValue);
0949: if ((optionValue = optionsMap
0950: .get(OPTION_ReportUnusedPrivateMember)) != null)
0951: updateSeverity(UnusedPrivateMember, optionValue);
0952: if ((optionValue = optionsMap
0953: .get(OPTION_ReportUnusedDeclaredThrownException)) != null)
0954: updateSeverity(UnusedDeclaredThrownException, optionValue);
0955: if ((optionValue = optionsMap
0956: .get(OPTION_ReportNoImplicitStringConversion)) != null)
0957: updateSeverity(NoImplicitStringConversion, optionValue);
0958: if ((optionValue = optionsMap
0959: .get(OPTION_ReportSyntheticAccessEmulation)) != null)
0960: updateSeverity(AccessEmulation, optionValue);
0961: if ((optionValue = optionsMap
0962: .get(OPTION_ReportLocalVariableHiding)) != null)
0963: updateSeverity(LocalVariableHiding, optionValue);
0964: if ((optionValue = optionsMap.get(OPTION_ReportFieldHiding)) != null)
0965: updateSeverity(FieldHiding, optionValue);
0966: if ((optionValue = optionsMap
0967: .get(OPTION_ReportTypeParameterHiding)) != null)
0968: updateSeverity(TypeHiding, optionValue);
0969: if ((optionValue = optionsMap
0970: .get(OPTION_ReportPossibleAccidentalBooleanAssignment)) != null)
0971: updateSeverity(AccidentalBooleanAssign, optionValue);
0972: if ((optionValue = optionsMap.get(OPTION_ReportEmptyStatement)) != null)
0973: updateSeverity(EmptyStatement, optionValue);
0974: if ((optionValue = optionsMap
0975: .get(OPTION_ReportNonExternalizedStringLiteral)) != null)
0976: updateSeverity(NonExternalizedString, optionValue);
0977: if ((optionValue = optionsMap
0978: .get(OPTION_ReportAssertIdentifier)) != null)
0979: updateSeverity(AssertUsedAsAnIdentifier, optionValue);
0980: if ((optionValue = optionsMap.get(OPTION_ReportEnumIdentifier)) != null)
0981: updateSeverity(EnumUsedAsAnIdentifier, optionValue);
0982: if ((optionValue = optionsMap
0983: .get(OPTION_ReportNonStaticAccessToStatic)) != null)
0984: updateSeverity(NonStaticAccessToStatic, optionValue);
0985: if ((optionValue = optionsMap
0986: .get(OPTION_ReportIndirectStaticAccess)) != null)
0987: updateSeverity(IndirectStaticAccess, optionValue);
0988: if ((optionValue = optionsMap
0989: .get(OPTION_ReportIncompatibleNonInheritedInterfaceMethod)) != null)
0990: updateSeverity(IncompatibleNonInheritedInterfaceMethod,
0991: optionValue);
0992: if ((optionValue = optionsMap
0993: .get(OPTION_ReportUndocumentedEmptyBlock)) != null)
0994: updateSeverity(UndocumentedEmptyBlock, optionValue);
0995: if ((optionValue = optionsMap
0996: .get(OPTION_ReportUnnecessaryTypeCheck)) != null)
0997: updateSeverity(UnnecessaryTypeCheck, optionValue);
0998: if ((optionValue = optionsMap.get(OPTION_ReportUnnecessaryElse)) != null)
0999: updateSeverity(UnnecessaryElse, optionValue);
1000: if ((optionValue = optionsMap
1001: .get(OPTION_ReportFinallyBlockNotCompletingNormally)) != null)
1002: updateSeverity(FinallyBlockNotCompleting, optionValue);
1003: if ((optionValue = optionsMap
1004: .get(OPTION_ReportUnqualifiedFieldAccess)) != null)
1005: updateSeverity(UnqualifiedFieldAccess, optionValue);
1006: if ((optionValue = optionsMap
1007: .get(OPTION_ReportNoEffectAssignment)) != null)
1008: updateSeverity(NoEffectAssignment, optionValue);
1009: if ((optionValue = optionsMap
1010: .get(OPTION_ReportUncheckedTypeOperation)) != null)
1011: updateSeverity(UncheckedTypeOperation, optionValue);
1012: if ((optionValue = optionsMap
1013: .get(OPTION_ReportRawTypeReference)) != null)
1014: updateSeverity(RawTypeReference, optionValue);
1015: if ((optionValue = optionsMap
1016: .get(OPTION_ReportFinalParameterBound)) != null)
1017: updateSeverity(FinalParameterBound, optionValue);
1018: if ((optionValue = optionsMap
1019: .get(OPTION_ReportMissingSerialVersion)) != null)
1020: updateSeverity(MissingSerialVersion, optionValue);
1021: if ((optionValue = optionsMap
1022: .get(OPTION_ReportForbiddenReference)) != null)
1023: updateSeverity(ForbiddenReference, optionValue);
1024: if ((optionValue = optionsMap
1025: .get(OPTION_ReportDiscouragedReference)) != null)
1026: updateSeverity(DiscouragedReference, optionValue);
1027: if ((optionValue = optionsMap
1028: .get(OPTION_ReportVarargsArgumentNeedCast)) != null)
1029: updateSeverity(VarargsArgumentNeedCast, optionValue);
1030: if ((optionValue = optionsMap.get(OPTION_ReportNullReference)) != null)
1031: updateSeverity(NullReference, optionValue);
1032: if ((optionValue = optionsMap
1033: .get(OPTION_ReportPotentialNullReference)) != null)
1034: updateSeverity(PotentialNullReference, optionValue);
1035: if ((optionValue = optionsMap
1036: .get(OPTION_ReportRedundantNullCheck)) != null)
1037: updateSeverity(RedundantNullCheck, optionValue);
1038: if ((optionValue = optionsMap.get(OPTION_ReportAutoboxing)) != null)
1039: updateSeverity(AutoBoxing, optionValue);
1040: if ((optionValue = optionsMap
1041: .get(OPTION_ReportAnnotationSuperInterface)) != null)
1042: updateSeverity(AnnotationSuperInterface, optionValue);
1043: if ((optionValue = optionsMap
1044: .get(OPTION_ReportMissingOverrideAnnotation)) != null)
1045: updateSeverity(MissingOverrideAnnotation, optionValue);
1046: if ((optionValue = optionsMap
1047: .get(OPTION_ReportMissingDeprecatedAnnotation)) != null)
1048: updateSeverity(MissingDeprecatedAnnotation, optionValue);
1049: if ((optionValue = optionsMap
1050: .get(OPTION_ReportIncompleteEnumSwitch)) != null)
1051: updateSeverity(IncompleteEnumSwitch, optionValue);
1052: if ((optionValue = optionsMap
1053: .get(OPTION_ReportUnhandledWarningToken)) != null)
1054: updateSeverity(UnhandledWarningToken, optionValue);
1055: if ((optionValue = optionsMap.get(OPTION_ReportUnusedLabel)) != null)
1056: updateSeverity(UnusedLabel, optionValue);
1057: if ((optionValue = optionsMap
1058: .get(OPTION_ReportParameterAssignment)) != null)
1059: updateSeverity(ParameterAssignment, optionValue);
1060: if ((optionValue = optionsMap.get(OPTION_ReportFallthroughCase)) != null)
1061: updateSeverity(FallthroughCase, optionValue);
1062: if ((optionValue = optionsMap
1063: .get(OPTION_ReportOverridingMethodWithoutSuperInvocation)) != null)
1064: updateSeverity(OverridingMethodWithoutSuperInvocation,
1065: optionValue);
1066:
1067: // Javadoc options
1068: if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
1069: if (ENABLED.equals(optionValue)) {
1070: this .docCommentSupport = true;
1071: } else if (DISABLED.equals(optionValue)) {
1072: this .docCommentSupport = false;
1073: }
1074: }
1075: if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadoc)) != null) {
1076: updateSeverity(InvalidJavadoc, optionValue);
1077: }
1078: if ((optionValue = optionsMap
1079: .get(OPTION_ReportInvalidJavadocTagsVisibility)) != null) {
1080: if (PUBLIC.equals(optionValue)) {
1081: this .reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic;
1082: } else if (PROTECTED.equals(optionValue)) {
1083: this .reportInvalidJavadocTagsVisibility = ClassFileConstants.AccProtected;
1084: } else if (DEFAULT.equals(optionValue)) {
1085: this .reportInvalidJavadocTagsVisibility = ClassFileConstants.AccDefault;
1086: } else if (PRIVATE.equals(optionValue)) {
1087: this .reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPrivate;
1088: }
1089: }
1090: if ((optionValue = optionsMap
1091: .get(OPTION_ReportInvalidJavadocTags)) != null) {
1092: if (ENABLED.equals(optionValue)) {
1093: this .reportInvalidJavadocTags = true;
1094: } else if (DISABLED.equals(optionValue)) {
1095: this .reportInvalidJavadocTags = false;
1096: }
1097: }
1098: if ((optionValue = optionsMap
1099: .get(OPTION_ReportInvalidJavadocTagsDeprecatedRef)) != null) {
1100: if (ENABLED.equals(optionValue)) {
1101: this .reportInvalidJavadocTagsDeprecatedRef = true;
1102: } else if (DISABLED.equals(optionValue)) {
1103: this .reportInvalidJavadocTagsDeprecatedRef = false;
1104: }
1105: }
1106: if ((optionValue = optionsMap
1107: .get(OPTION_ReportInvalidJavadocTagsNotVisibleRef)) != null) {
1108: if (ENABLED.equals(optionValue)) {
1109: this .reportInvalidJavadocTagsNotVisibleRef = true;
1110: } else if (DISABLED.equals(optionValue)) {
1111: this .reportInvalidJavadocTagsNotVisibleRef = false;
1112: }
1113: }
1114: if ((optionValue = optionsMap
1115: .get(OPTION_ReportMissingJavadocTags)) != null) {
1116: updateSeverity(MissingJavadocTags, optionValue);
1117: }
1118: if ((optionValue = optionsMap
1119: .get(OPTION_ReportMissingJavadocTagsVisibility)) != null) {
1120: if (PUBLIC.equals(optionValue)) {
1121: this .reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic;
1122: } else if (PROTECTED.equals(optionValue)) {
1123: this .reportMissingJavadocTagsVisibility = ClassFileConstants.AccProtected;
1124: } else if (DEFAULT.equals(optionValue)) {
1125: this .reportMissingJavadocTagsVisibility = ClassFileConstants.AccDefault;
1126: } else if (PRIVATE.equals(optionValue)) {
1127: this .reportMissingJavadocTagsVisibility = ClassFileConstants.AccPrivate;
1128: }
1129: }
1130: if ((optionValue = optionsMap
1131: .get(OPTION_ReportMissingJavadocTagsOverriding)) != null) {
1132: if (ENABLED.equals(optionValue)) {
1133: this .reportMissingJavadocTagsOverriding = true;
1134: } else if (DISABLED.equals(optionValue)) {
1135: this .reportMissingJavadocTagsOverriding = false;
1136: }
1137: }
1138: if ((optionValue = optionsMap
1139: .get(OPTION_ReportMissingJavadocComments)) != null) {
1140: updateSeverity(MissingJavadocComments, optionValue);
1141: }
1142: if ((optionValue = optionsMap
1143: .get(OPTION_ReportMissingJavadocCommentsVisibility)) != null) {
1144: if (PUBLIC.equals(optionValue)) {
1145: this .reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic;
1146: } else if (PROTECTED.equals(optionValue)) {
1147: this .reportMissingJavadocCommentsVisibility = ClassFileConstants.AccProtected;
1148: } else if (DEFAULT.equals(optionValue)) {
1149: this .reportMissingJavadocCommentsVisibility = ClassFileConstants.AccDefault;
1150: } else if (PRIVATE.equals(optionValue)) {
1151: this .reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPrivate;
1152: }
1153: }
1154: if ((optionValue = optionsMap
1155: .get(OPTION_ReportMissingJavadocCommentsOverriding)) != null) {
1156: if (ENABLED.equals(optionValue)) {
1157: this .reportMissingJavadocCommentsOverriding = true;
1158: } else if (DISABLED.equals(optionValue)) {
1159: this .reportMissingJavadocCommentsOverriding = false;
1160: }
1161: }
1162: if ((optionValue = optionsMap.get(OPTION_GenerateClassFiles)) != null) {
1163: if (ENABLED.equals(optionValue)) {
1164: this .generateClassFiles = true;
1165: } else if (DISABLED.equals(optionValue)) {
1166: this .generateClassFiles = false;
1167: }
1168: }
1169: if ((optionValue = optionsMap.get(OPTION_Process_Annotations)) != null) {
1170: if (ENABLED.equals(optionValue)) {
1171: this .processAnnotations = true;
1172: this .storeAnnotations = true; // annotation processing requires annotation to be stored
1173: this .docCommentSupport = true; // annotation processing requires javadoc processing
1174: } else if (DISABLED.equals(optionValue)) {
1175: this .processAnnotations = false;
1176: this .storeAnnotations = false;
1177: }
1178: }
1179: }
1180:
1181: public String toString() {
1182:
1183: StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$
1184: buf
1185: .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$
1186: buf
1187: .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$
1188: buf
1189: .append("\n\t- source debug attributes: ").append((this .produceDebugAttributes & ClassFileConstants.ATTR_SOURCE) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1190: buf
1191: .append("\n\t- preserve all local variables: ").append(this .preserveAllLocalVariables ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1192: buf
1193: .append("\n\t- method with constructor name: ").append(getSeverityString(MethodWithConstructorName)); //$NON-NLS-1$
1194: buf
1195: .append("\n\t- overridden package default method: ").append(getSeverityString(OverriddenPackageDefaultMethod)); //$NON-NLS-1$
1196: buf
1197: .append("\n\t- deprecation: ").append(getSeverityString(UsingDeprecatedAPI)); //$NON-NLS-1$
1198: buf
1199: .append("\n\t- masked catch block: ").append(getSeverityString(MaskedCatchBlock)); //$NON-NLS-1$
1200: buf
1201: .append("\n\t- unused local variable: ").append(getSeverityString(UnusedLocalVariable)); //$NON-NLS-1$
1202: buf
1203: .append("\n\t- unused parameter: ").append(getSeverityString(UnusedArgument)); //$NON-NLS-1$
1204: buf
1205: .append("\n\t- unused import: ").append(getSeverityString(UnusedImport)); //$NON-NLS-1$
1206: buf
1207: .append("\n\t- synthetic access emulation: ").append(getSeverityString(AccessEmulation)); //$NON-NLS-1$
1208: buf
1209: .append("\n\t- assignment with no effect: ").append(getSeverityString(NoEffectAssignment)); //$NON-NLS-1$
1210: buf
1211: .append("\n\t- non externalized string: ").append(getSeverityString(NonExternalizedString)); //$NON-NLS-1$
1212: buf
1213: .append("\n\t- static access receiver: ").append(getSeverityString(NonStaticAccessToStatic)); //$NON-NLS-1$
1214: buf
1215: .append("\n\t- indirect static access: ").append(getSeverityString(IndirectStaticAccess)); //$NON-NLS-1$
1216: buf
1217: .append(
1218: "\n\t- incompatible non inherited interface method: ").append(getSeverityString(IncompatibleNonInheritedInterfaceMethod)); //$NON-NLS-1$
1219: buf
1220: .append("\n\t- unused private member: ").append(getSeverityString(UnusedPrivateMember)); //$NON-NLS-1$
1221: buf
1222: .append(
1223: "\n\t- local variable hiding another variable: ").append(getSeverityString(LocalVariableHiding)); //$NON-NLS-1$
1224: buf
1225: .append("\n\t- field hiding another variable: ").append(getSeverityString(FieldHiding)); //$NON-NLS-1$
1226: buf
1227: .append("\n\t- type hiding another type: ").append(getSeverityString(TypeHiding)); //$NON-NLS-1$
1228: buf
1229: .append(
1230: "\n\t- possible accidental boolean assignment: ").append(getSeverityString(AccidentalBooleanAssign)); //$NON-NLS-1$
1231: buf
1232: .append("\n\t- superfluous semicolon: ").append(getSeverityString(EmptyStatement)); //$NON-NLS-1$
1233: buf
1234: .append("\n\t- uncommented empty block: ").append(getSeverityString(UndocumentedEmptyBlock)); //$NON-NLS-1$
1235: buf
1236: .append("\n\t- unnecessary type check: ").append(getSeverityString(UnnecessaryTypeCheck)); //$NON-NLS-1$
1237: buf
1238: .append("\n\t- javadoc comment support: ").append(this .docCommentSupport ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1239: buf
1240: .append("\n\t\t+ invalid javadoc: ").append(getSeverityString(InvalidJavadoc)); //$NON-NLS-1$
1241: buf
1242: .append("\n\t\t+ report invalid javadoc tags: ").append(this .reportInvalidJavadocTags ? ENABLED : DISABLED); //$NON-NLS-1$
1243: buf
1244: .append("\n\t\t\t* deprecated references: ").append(this .reportInvalidJavadocTagsDeprecatedRef ? ENABLED : DISABLED); //$NON-NLS-1$
1245: buf
1246: .append("\n\t\t\t* not visible references: ").append(this .reportInvalidJavadocTagsNotVisibleRef ? ENABLED : DISABLED); //$NON-NLS-1$
1247: buf
1248: .append(
1249: "\n\t\t+ visibility level to report invalid javadoc tags: ").append(getVisibilityString(this .reportInvalidJavadocTagsVisibility)); //$NON-NLS-1$
1250: buf
1251: .append("\n\t\t+ missing javadoc tags: ").append(getSeverityString(MissingJavadocTags)); //$NON-NLS-1$
1252: buf
1253: .append(
1254: "\n\t\t+ visibility level to report missing javadoc tags: ").append(getVisibilityString(this .reportMissingJavadocTagsVisibility)); //$NON-NLS-1$
1255: buf
1256: .append(
1257: "\n\t\t+ report missing javadoc tags in overriding methods: ").append(this .reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
1258: buf
1259: .append("\n\t\t+ missing javadoc comments: ").append(getSeverityString(MissingJavadocComments)); //$NON-NLS-1$
1260: buf
1261: .append(
1262: "\n\t\t+ visibility level to report missing javadoc comments: ").append(getVisibilityString(this .reportMissingJavadocCommentsVisibility)); //$NON-NLS-1$
1263: buf
1264: .append(
1265: "\n\t\t+ report missing javadoc comments in overriding methods: ").append(this .reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
1266: buf
1267: .append("\n\t- finally block not completing normally: ").append(getSeverityString(FinallyBlockNotCompleting)); //$NON-NLS-1$
1268: buf
1269: .append(
1270: "\n\t- report unused declared thrown exception: ").append(getSeverityString(UnusedDeclaredThrownException)); //$NON-NLS-1$
1271: buf
1272: .append(
1273: "\n\t- report unused declared thrown exception when overriding: ").append(this .reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
1274: buf
1275: .append(
1276: "\n\t- report unused declared thrown exception include doc comment reference: ").append(this .reportUnusedDeclaredThrownExceptionIncludeDocCommentReference ? ENABLED : DISABLED); //$NON-NLS-1$
1277: buf
1278: .append("\n\t- unnecessary else: ").append(getSeverityString(UnnecessaryElse)); //$NON-NLS-1$
1279: buf
1280: .append("\n\t- JDK compliance level: " + versionFromJdkLevel(this .complianceLevel)); //$NON-NLS-1$
1281: buf
1282: .append("\n\t- JDK source level: " + versionFromJdkLevel(this .sourceLevel)); //$NON-NLS-1$
1283: buf
1284: .append("\n\t- JDK target level: " + versionFromJdkLevel(this .targetJDK)); //$NON-NLS-1$
1285: buf
1286: .append("\n\t- verbose : ").append(this .verbose ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1287: buf
1288: .append("\n\t- produce reference info : ").append(this .produceReferenceInfo ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1289: buf
1290: .append(
1291: "\n\t- parse literal expressions as constants : ").append(this .parseLiteralExpressionsAsConstants ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1292: buf
1293: .append("\n\t- encoding : ").append(this .defaultEncoding == null ? "<default>" : this .defaultEncoding); //$NON-NLS-1$ //$NON-NLS-2$
1294: buf
1295: .append("\n\t- task tags: ").append(this .taskTags == null ? Util.EMPTY_STRING : new String(CharOperation.concatWith(this .taskTags, ','))); //$NON-NLS-1$
1296: buf
1297: .append("\n\t- task priorities : ").append(this .taskPriorites == null ? Util.EMPTY_STRING : new String(CharOperation.concatWith(this .taskPriorites, ','))); //$NON-NLS-1$
1298: buf
1299: .append(
1300: "\n\t- report deprecation inside deprecated code : ").append(this .reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED); //$NON-NLS-1$
1301: buf
1302: .append(
1303: "\n\t- report deprecation when overriding deprecated method : ").append(this .reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED); //$NON-NLS-1$
1304: buf
1305: .append(
1306: "\n\t- report unused parameter when implementing abstract method : ").append(this .reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); //$NON-NLS-1$
1307: buf
1308: .append(
1309: "\n\t- report unused parameter when overriding concrete method : ").append(this .reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); //$NON-NLS-1$
1310: buf
1311: .append(
1312: "\n\t- report unused parameter include doc comment reference : ").append(this .reportUnusedParameterIncludeDocCommentReference ? ENABLED : DISABLED); //$NON-NLS-1$
1313: buf
1314: .append(
1315: "\n\t- report constructor/setter parameter hiding existing field : ").append(this .reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$
1316: buf
1317: .append("\n\t- inline JSR bytecode : ").append(this .inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$
1318: buf
1319: .append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); //$NON-NLS-1$
1320: buf
1321: .append("\n\t- unsafe raw type: ").append(getSeverityString(RawTypeReference)); //$NON-NLS-1$
1322: buf
1323: .append("\n\t- final bound for type parameter: ").append(getSeverityString(FinalParameterBound)); //$NON-NLS-1$
1324: buf
1325: .append("\n\t- missing serialVersionUID: ").append(getSeverityString(MissingSerialVersion)); //$NON-NLS-1$
1326: buf
1327: .append("\n\t- varargs argument need cast: ").append(getSeverityString(VarargsArgumentNeedCast)); //$NON-NLS-1$
1328: buf
1329: .append(
1330: "\n\t- forbidden reference to type with access restriction: ").append(getSeverityString(ForbiddenReference)); //$NON-NLS-1$
1331: buf
1332: .append(
1333: "\n\t- discouraged reference to type with access restriction: ").append(getSeverityString(DiscouragedReference)); //$NON-NLS-1$
1334: buf
1335: .append("\n\t- null reference: ").append(getSeverityString(NullReference)); //$NON-NLS-1$
1336: buf
1337: .append("\n\t- potential null reference: ").append(getSeverityString(PotentialNullReference)); //$NON-NLS-1$
1338: buf
1339: .append("\n\t- redundant null check: ").append(getSeverityString(RedundantNullCheck)); //$NON-NLS-1$
1340: buf
1341: .append("\n\t- autoboxing: ").append(getSeverityString(AutoBoxing)); //$NON-NLS-1$
1342: buf
1343: .append("\n\t- annotation super interface: ").append(getSeverityString(AnnotationSuperInterface)); //$NON-NLS-1$
1344: buf
1345: .append("\n\t- missing @Override annotation: ").append(getSeverityString(MissingOverrideAnnotation)); //$NON-NLS-1$
1346: buf
1347: .append("\n\t- missing @Deprecated annotation: ").append(getSeverityString(MissingDeprecatedAnnotation)); //$NON-NLS-1$
1348: buf
1349: .append("\n\t- incomplete enum switch: ").append(getSeverityString(IncompleteEnumSwitch)); //$NON-NLS-1$
1350: buf
1351: .append("\n\t- suppress warnings: ").append(this .suppressWarnings ? ENABLED : DISABLED); //$NON-NLS-1$
1352: buf
1353: .append("\n\t- unhandled warning token: ").append(getSeverityString(UnhandledWarningToken)); //$NON-NLS-1$
1354: buf
1355: .append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$
1356: buf
1357: .append("\n\t- treat optional error as fatal: ").append(this .treatOptionalErrorAsFatal ? ENABLED : DISABLED); //$NON-NLS-1$
1358: buf
1359: .append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$
1360: buf
1361: .append("\n\t- generate class files: ").append(this .generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
1362: buf
1363: .append("\n\t- process annotations: ").append(this .processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
1364: return buf.toString();
1365: }
1366:
1367: void updateSeverity(long irritant, Object severityString) {
1368: if (ERROR.equals(severityString)) {
1369: this .errorThreshold |= irritant;
1370: this .warningThreshold &= ~irritant;
1371: } else if (WARNING.equals(severityString)) {
1372: this .errorThreshold &= ~irritant;
1373: this .warningThreshold |= irritant;
1374: } else if (IGNORE.equals(severityString)) {
1375: this .errorThreshold &= ~irritant;
1376: this .warningThreshold &= ~irritant;
1377: }
1378: }
1379:
1380: public static long versionToJdkLevel(Object versionID) {
1381: if (versionID instanceof String) {
1382: String version = (String) versionID;
1383: // verification is optimized for all versions with same length and same "1." prefix
1384: if (version.length() == 3 && version.charAt(0) == '1'
1385: && version.charAt(1) == '.') {
1386: switch (version.charAt(2)) {
1387: case '1':
1388: return ClassFileConstants.JDK1_1;
1389: case '2':
1390: return ClassFileConstants.JDK1_2;
1391: case '3':
1392: return ClassFileConstants.JDK1_3;
1393: case '4':
1394: return ClassFileConstants.JDK1_4;
1395: case '5':
1396: return ClassFileConstants.JDK1_5;
1397: case '6':
1398: return ClassFileConstants.JDK1_6;
1399: case '7':
1400: return ClassFileConstants.JDK1_7;
1401: default:
1402: return 0; // unknown
1403: }
1404: }
1405: if (VERSION_JSR14.equals(versionID)) {
1406: return ClassFileConstants.JDK1_4;
1407: }
1408: if (VERSION_CLDC1_1.equals(versionID)) {
1409: return ClassFileConstants.CLDC_1_1;
1410: }
1411: }
1412: return 0; // unknown
1413: }
1414:
1415: public static String versionFromJdkLevel(long jdkLevel) {
1416: switch ((int) (jdkLevel >> 16)) {
1417: case ClassFileConstants.MAJOR_VERSION_1_1:
1418: if (jdkLevel == ClassFileConstants.JDK1_1)
1419: return VERSION_1_1;
1420: break;
1421: case ClassFileConstants.MAJOR_VERSION_1_2:
1422: if (jdkLevel == ClassFileConstants.JDK1_2)
1423: return VERSION_1_2;
1424: break;
1425: case ClassFileConstants.MAJOR_VERSION_1_3:
1426: if (jdkLevel == ClassFileConstants.JDK1_3)
1427: return VERSION_1_3;
1428: break;
1429: case ClassFileConstants.MAJOR_VERSION_1_4:
1430: if (jdkLevel == ClassFileConstants.JDK1_4)
1431: return VERSION_1_4;
1432: break;
1433: case ClassFileConstants.MAJOR_VERSION_1_5:
1434: if (jdkLevel == ClassFileConstants.JDK1_5)
1435: return VERSION_1_5;
1436: break;
1437: case ClassFileConstants.MAJOR_VERSION_1_6:
1438: if (jdkLevel == ClassFileConstants.JDK1_6)
1439: return VERSION_1_6;
1440: break;
1441: case ClassFileConstants.MAJOR_VERSION_1_7:
1442: if (jdkLevel == ClassFileConstants.JDK1_7)
1443: return VERSION_1_7;
1444: break;
1445: }
1446: return Util.EMPTY_STRING; // unknown version
1447: }
1448:
1449: /**
1450: * Return all warning option names for use as keys in compiler options maps.
1451: * @return all warning option names
1452: * TODO (maxime) revise for ensuring completeness
1453: */
1454: public static String[] warningOptionNames() {
1455: String[] result = { OPTION_ReportAnnotationSuperInterface,
1456: OPTION_ReportAssertIdentifier, OPTION_ReportAutoboxing,
1457: OPTION_ReportDeprecation,
1458: OPTION_ReportDiscouragedReference,
1459: OPTION_ReportEmptyStatement,
1460: OPTION_ReportEnumIdentifier,
1461: OPTION_ReportFallthroughCase, OPTION_ReportFieldHiding,
1462: OPTION_ReportFinalParameterBound,
1463: OPTION_ReportFinallyBlockNotCompletingNormally,
1464: OPTION_ReportForbiddenReference,
1465: OPTION_ReportHiddenCatchBlock,
1466: OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
1467: OPTION_ReportIncompleteEnumSwitch,
1468: OPTION_ReportIndirectStaticAccess,
1469: OPTION_ReportInvalidJavadoc,
1470: OPTION_ReportLocalVariableHiding,
1471: OPTION_ReportMethodWithConstructorName,
1472: OPTION_ReportMissingDeprecatedAnnotation,
1473: OPTION_ReportMissingJavadocComments,
1474: OPTION_ReportMissingJavadocTags,
1475: OPTION_ReportMissingOverrideAnnotation,
1476: OPTION_ReportMissingSerialVersion,
1477: OPTION_ReportNoEffectAssignment,
1478: OPTION_ReportNoImplicitStringConversion,
1479: OPTION_ReportNonExternalizedStringLiteral,
1480: OPTION_ReportNonStaticAccessToStatic,
1481: OPTION_ReportNullReference,
1482: OPTION_ReportPotentialNullReference,
1483: OPTION_ReportRedundantNullCheck,
1484: OPTION_ReportOverridingPackageDefaultMethod,
1485: OPTION_ReportParameterAssignment,
1486: OPTION_ReportPossibleAccidentalBooleanAssignment,
1487: OPTION_ReportSyntheticAccessEmulation,
1488: OPTION_ReportTypeParameterHiding,
1489: OPTION_ReportUncheckedTypeOperation,
1490: OPTION_ReportUndocumentedEmptyBlock,
1491: OPTION_ReportUnnecessaryElse,
1492: OPTION_ReportUnnecessaryTypeCheck,
1493: OPTION_ReportUnqualifiedFieldAccess,
1494: OPTION_ReportUnusedDeclaredThrownException,
1495: OPTION_ReportUnusedImport, OPTION_ReportUnusedLocal,
1496: OPTION_ReportUnusedParameter,
1497: OPTION_ReportUnusedPrivateMember,
1498: OPTION_ReportVarargsArgumentNeedCast,
1499: OPTION_ReportUnhandledWarningToken,
1500: OPTION_ReportOverridingMethodWithoutSuperInvocation };
1501: return result;
1502: }
1503:
1504: public static String warningTokenFromIrritant(long irritant) {
1505: // keep in sync with warningTokens and warningTokenToIrritant
1506: int irritantInt = (int) irritant;
1507: if (irritantInt == irritant) {
1508: switch (irritantInt) {
1509: case (int) (InvalidJavadoc | UsingDeprecatedAPI):
1510: case (int) UsingDeprecatedAPI:
1511: return "deprecation"; //$NON-NLS-1$
1512: case (int) FinallyBlockNotCompleting:
1513: return "finally"; //$NON-NLS-1$
1514: case (int) FieldHiding:
1515: case (int) LocalVariableHiding:
1516: case (int) MaskedCatchBlock:
1517: return "hiding"; //$NON-NLS-1$
1518: case (int) NonExternalizedString:
1519: return "nls"; //$NON-NLS-1$
1520: case (int) UnnecessaryTypeCheck:
1521: return "cast"; //$NON-NLS-1$
1522: case (int) UnusedLocalVariable:
1523: case (int) UnusedArgument:
1524: case (int) UnusedImport:
1525: case (int) UnusedPrivateMember:
1526: case (int) UnusedDeclaredThrownException:
1527: return "unused"; //$NON-NLS-1$
1528: case (int) IndirectStaticAccess:
1529: case (int) NonStaticAccessToStatic:
1530: return "static-access"; //$NON-NLS-1$
1531: case (int) AccessEmulation:
1532: return "synthetic-access"; //$NON-NLS-1$
1533: case (int) UnqualifiedFieldAccess:
1534: return "unqualified-field-access"; //$NON-NLS-1$
1535: case (int) UncheckedTypeOperation:
1536: return "unchecked"; //$NON-NLS-1$
1537: }
1538: } else {
1539: irritantInt = (int) (irritant >>> 32);
1540: switch (irritantInt) {
1541: case (int) (MissingSerialVersion >>> 32):
1542: return "serial"; //$NON-NLS-1$
1543: case (int) (AutoBoxing >>> 32):
1544: return "boxing"; //$NON-NLS-1$
1545: case (int) (TypeHiding >>> 32):
1546: return "hiding"; //$NON-NLS-1$
1547: case (int) (IncompleteEnumSwitch >>> 32):
1548: return "incomplete-switch"; //$NON-NLS-1$
1549: case (int) (MissingDeprecatedAnnotation >>> 32):
1550: return "dep-ann"; //$NON-NLS-1$
1551: case (int) (RawTypeReference >>> 32):
1552: return "unchecked"; //$NON-NLS-1$
1553: case (int) (UnusedLabel >>> 32):
1554: return "unused"; //$NON-NLS-1$
1555: case (int) (DiscouragedReference >>> 32):
1556: case (int) (ForbiddenReference >>> 32):
1557: return "restriction"; //$NON-NLS-1$
1558: case (int) (NullReference >>> 32):
1559: case (int) (PotentialNullReference >>> 32):
1560: case (int) (RedundantNullCheck >>> 32):
1561: return "null"; //$NON-NLS-1$
1562: case (int) (FallthroughCase >>> 32):
1563: return "fallthrough"; //$NON-NLS-1$
1564: case (int) (OverridingMethodWithoutSuperInvocation >>> 32):
1565: return "super"; //$NON-NLS-1$
1566: }
1567: }
1568: return null;
1569: }
1570:
1571: // keep in sync with warningTokenToIrritant and warningTokenFromIrritant
1572: public final static String[] warningTokens = { "all", //$NON-NLS-1$
1573: "boxing", //$NON-NLS-1$
1574: "cast", //$NON-NLS-1$
1575: "dep-ann", //$NON-NLS-1$
1576: "deprecation", //$NON-NLS-1$
1577: "fallthrough", //$NON-NLS-1$
1578: "finally", //$NON-NLS-1$
1579: "hiding", //$NON-NLS-1$
1580: "incomplete-switch", //$NON-NLS-1$
1581: "nls", //$NON-NLS-1$
1582: "null", //$NON-NLS-1$
1583: "restriction", //$NON-NLS-1$
1584: "serial", //$NON-NLS-1$
1585: "static-access", //$NON-NLS-1$
1586: "super", //$NON-NLS-1$
1587: "synthetic-access", //$NON-NLS-1$
1588: "unchecked", //$NON-NLS-1$
1589: "unqualified-field-access", //$NON-NLS-1$
1590: "unused", //$NON-NLS-1$
1591: };
1592:
1593: public static long warningTokenToIrritant(String warningToken) {
1594: // keep in sync with warningTokens and warningTokenFromIrritant
1595: if (warningToken == null || warningToken.length() == 0)
1596: return 0;
1597: switch (warningToken.charAt(0)) {
1598: case 'a':
1599: if ("all".equals(warningToken)) //$NON-NLS-1$
1600: return 0xFFFFFFFFFFFFFFFFl; // suppress all warnings
1601: break;
1602: case 'b':
1603: if ("boxing".equals(warningToken)) //$NON-NLS-1$
1604: return AutoBoxing;
1605: break;
1606: case 'c':
1607: if ("cast".equals(warningToken)) //$NON-NLS-1$
1608: return UnnecessaryTypeCheck;
1609: break;
1610: case 'd':
1611: if ("deprecation".equals(warningToken)) //$NON-NLS-1$
1612: return UsingDeprecatedAPI;
1613: if ("dep-ann".equals(warningToken)) //$NON-NLS-1$
1614: return MissingDeprecatedAnnotation;
1615: break;
1616: case 'f':
1617: if ("fallthrough".equals(warningToken)) //$NON-NLS-1$
1618: return FallthroughCase;
1619: if ("finally".equals(warningToken)) //$NON-NLS-1$
1620: return FinallyBlockNotCompleting;
1621: break;
1622: case 'h':
1623: if ("hiding".equals(warningToken)) //$NON-NLS-1$
1624: return FieldHiding | LocalVariableHiding
1625: | MaskedCatchBlock | TypeHiding;
1626: case 'i':
1627: if ("incomplete-switch".equals(warningToken)) //$NON-NLS-1$
1628: return IncompleteEnumSwitch;
1629: break;
1630: case 'n':
1631: if ("nls".equals(warningToken)) //$NON-NLS-1$
1632: return NonExternalizedString;
1633: if ("null".equals(warningToken)) //$NON-NLS-1$
1634: return NullReference | PotentialNullReference
1635: | RedundantNullCheck;
1636: break;
1637: case 'r':
1638: if ("restriction".equals(warningToken)) //$NON-NLS-1$
1639: return DiscouragedReference | ForbiddenReference;
1640: break;
1641: case 's':
1642: if ("serial".equals(warningToken)) //$NON-NLS-1$
1643: return MissingSerialVersion;
1644: if ("static-access".equals(warningToken)) //$NON-NLS-1$
1645: return IndirectStaticAccess | NonStaticAccessToStatic;
1646: if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$
1647: return AccessEmulation;
1648: if ("super".equals(warningToken)) { //$NON-NLS-1$
1649: return OverridingMethodWithoutSuperInvocation;
1650: }
1651: break;
1652: case 'u':
1653: if ("unused".equals(warningToken)) //$NON-NLS-1$
1654: return UnusedLocalVariable | UnusedArgument
1655: | UnusedPrivateMember
1656: | UnusedDeclaredThrownException | UnusedLabel
1657: | UnusedImport;
1658: if ("unchecked".equals(warningToken)) //$NON-NLS-1$
1659: return UncheckedTypeOperation | RawTypeReference;
1660: if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$
1661: return UnqualifiedFieldAccess;
1662: break;
1663: }
1664: return 0;
1665: }
1666: }
|