1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.impl;
13 import java.io.ByteArrayInputStream;
14 import java.io.InputStreamReader;
15 import java.io.UnsupportedEncodingException;
16 import java.util.HashMap;
19 import org.eclipse.jdt.core.compiler.CharOperation;
20 import org.eclipse.jdt.internal.compiler.Compiler;
21 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
22 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
23 import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
24 import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
26 public class CompilerOptions implements ProblemReasons, ProblemSeverities, ClassFileConstants {
31 public static final String OPTION_LocalVariableAttribute = "org.eclipse.jdt.core.compiler.debug.localVariable"; //$NON-NLS-1$
32 public static final String OPTION_LineNumberAttribute = "org.eclipse.jdt.core.compiler.debug.lineNumber"; //$NON-NLS-1$
33 public static final String OPTION_SourceFileAttribute = "org.eclipse.jdt.core.compiler.debug.sourceFile"; //$NON-NLS-1$
34 public static final String OPTION_PreserveUnusedLocal = "org.eclipse.jdt.core.compiler.codegen.unusedLocal"; //$NON-NLS-1$
35 public static final String OPTION_DocCommentSupport= "org.eclipse.jdt.core.compiler.doc.comment.support"; //$NON-NLS-1$
36 public static final String OPTION_ReportMethodWithConstructorName = "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
37 public static final String OPTION_ReportOverridingPackageDefaultMethod = "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
38 public static final String OPTION_ReportDeprecation = "org.eclipse.jdt.core.compiler.problem.deprecation"; //$NON-NLS-1$
39 public static final String OPTION_ReportDeprecationInDeprecatedCode = "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
40 public static final String OPTION_ReportDeprecationWhenOverridingDeprecatedMethod = "org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod"; //$NON-NLS-1$
41 public static final String OPTION_ReportHiddenCatchBlock = "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
42 public static final String OPTION_ReportUnusedLocal = "org.eclipse.jdt.core.compiler.problem.unusedLocal"; //$NON-NLS-1$
43 public static final String OPTION_ReportUnusedParameter = "org.eclipse.jdt.core.compiler.problem.unusedParameter"; //$NON-NLS-1$
44 public static final String OPTION_ReportUnusedParameterWhenImplementingAbstract = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
45 public static final String OPTION_ReportUnusedParameterWhenOverridingConcrete = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
46 public static final String OPTION_ReportUnusedImport = "org.eclipse.jdt.core.compiler.problem.unusedImport"; //$NON-NLS-1$
47 public static final String OPTION_ReportSyntheticAccessEmulation = "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
48 public static final String OPTION_ReportNoEffectAssignment = "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"; //$NON-NLS-1$
49 public static final String OPTION_ReportLocalVariableHiding = "org.eclipse.jdt.core.compiler.problem.localVariableHiding"; //$NON-NLS-1$
50 public static final String OPTION_ReportSpecialParameterHidingField = "org.eclipse.jdt.core.compiler.problem.specialParameterHidingField"; //$NON-NLS-1$
51 public static final String OPTION_ReportFieldHiding = "org.eclipse.jdt.core.compiler.problem.fieldHiding"; //$NON-NLS-1$
52 public static final String OPTION_ReportPossibleAccidentalBooleanAssignment = "org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment"; //$NON-NLS-1$
53 public static final String OPTION_ReportNonExternalizedStringLiteral = "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
54 public static final String OPTION_ReportIncompatibleNonInheritedInterfaceMethod = "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
55 public static final String OPTION_ReportUnusedPrivateMember = "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
56 public static final String OPTION_ReportNoImplicitStringConversion = "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
57 public static final String OPTION_ReportAssertIdentifier = "org.eclipse.jdt.core.compiler.problem.assertIdentifier"; //$NON-NLS-1$
58 public static final String OPTION_ReportEnumIdentifier = "org.eclipse.jdt.core.compiler.problem.enumIdentifier"; //$NON-NLS-1$
59 public static final String OPTION_ReportNonStaticAccessToStatic = "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
60 public static final String OPTION_ReportIndirectStaticAccess = "org.eclipse.jdt.core.compiler.problem.indirectStaticAccess"; //$NON-NLS-1$
61 public static final String OPTION_ReportEmptyStatement = "org.eclipse.jdt.core.compiler.problem.emptyStatement"; //$NON-NLS-1$
62 public static final String OPTION_ReportUnnecessaryTypeCheck = "org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck"; //$NON-NLS-1$
63 public static final String OPTION_ReportUnnecessaryElse = "org.eclipse.jdt.core.compiler.problem.unnecessaryElse"; //$NON-NLS-1$
64 public static final String OPTION_ReportUndocumentedEmptyBlock = "org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock"; //$NON-NLS-1$
65 public static final String OPTION_ReportInvalidJavadoc = "org.eclipse.jdt.core.compiler.problem.invalidJavadoc"; //$NON-NLS-1$
66 public static final String OPTION_ReportInvalidJavadocTags = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTags"; //$NON-NLS-1$
67 public static final String OPTION_ReportInvalidJavadocTagsDeprecatedRef = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef"; //$NON-NLS-1$
68 public static final String OPTION_ReportInvalidJavadocTagsNotVisibleRef = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef"; //$NON-NLS-1$
69 public static final String OPTION_ReportInvalidJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$
70 public static final String OPTION_ReportMissingJavadocTags = "org.eclipse.jdt.core.compiler.problem.missingJavadocTags"; //$NON-NLS-1$
71 public static final String OPTION_ReportMissingJavadocTagsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility"; //$NON-NLS-1$
72 public static final String OPTION_ReportMissingJavadocTagsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding"; //$NON-NLS-1$
73 public static final String OPTION_ReportMissingJavadocComments = "org.eclipse.jdt.core.compiler.problem.missingJavadocComments"; //$NON-NLS-1$
74 public static final String OPTION_ReportMissingJavadocCommentsVisibility = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility"; //$NON-NLS-1$
75 public static final String OPTION_ReportMissingJavadocCommentsOverriding = "org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding"; //$NON-NLS-1$
76 public static final String OPTION_ReportFinallyBlockNotCompletingNormally = "org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally"; //$NON-NLS-1$
77 public static final String OPTION_ReportUnusedDeclaredThrownException = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException"; //$NON-NLS-1$
78 public static final String OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding = "org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding"; //$NON-NLS-1$
79 public static final String OPTION_ReportUnqualifiedFieldAccess = "org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess"; //$NON-NLS-1$
80 public static final String OPTION_ReportUnsafeTypeOperation = "org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation"; //$NON-NLS-1$
81 public static final String OPTION_ReportFinalParameterBound = "org.eclipse.jdt.core.compiler.problem.finalParameterBound"; //$NON-NLS-1$
82 public static final String OPTION_ReportMissingSerialVersion = "org.eclipse.jdt.core.compiler.problem.missingSerialVersion"; //$NON-NLS-1$
83 public static final String OPTION_ReportVarargsArgumentNeedCast = "org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast"; //$NON-NLS-1$
84 public static final String OPTION_Source = "org.eclipse.jdt.core.compiler.source"; //$NON-NLS-1$
85 public static final String OPTION_TargetPlatform = "org.eclipse.jdt.core.compiler.codegen.targetPlatform"; //$NON-NLS-1$
86 public static final String OPTION_Compliance = "org.eclipse.jdt.core.compiler.compliance"; //$NON-NLS-1$
87 public static final String OPTION_Encoding = "org.eclipse.jdt.core.encoding"; //$NON-NLS-1$
88 public static final String OPTION_MaxProblemPerUnit = "org.eclipse.jdt.core.compiler.maxProblemPerUnit"; //$NON-NLS-1$
89 public static final String OPTION_TaskTags = "org.eclipse.jdt.core.compiler.taskTags"; //$NON-NLS-1$
90 public static final String OPTION_TaskPriorities = "org.eclipse.jdt.core.compiler.taskPriorities"; //$NON-NLS-1$
91 public static final String OPTION_TaskCaseSensitive = "org.eclipse.jdt.core.compiler.taskCaseSensitive"; //$NON-NLS-1$
92 public static final String OPTION_InlineJsr = "org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode"; //$NON-NLS-1$
93 public static final String OPTION_ReportInconsistentNullCheck = "org.eclipse.jdt.core.compiler.problem.inconsistentNullCheck"; //$NON-NLS-1$
94 public static final String OPTION_ReportForbiddenReference = "org.eclipse.jdt.core.compiler.problem.forbiddenReference"; //$NON-NLS-1$
95 public static final String OPTION_ImportRestrictionInclude = "org.eclipse.jdt.core.compiler.accessRestriction.import.include"; //$NON-NLS-1$
96 public static final String OPTION_ImportRestrictionExclude = "org.eclipse.jdt.core.compiler.accessRestriction.import.exclude"; //$NON-NLS-1$
97 public static final String OPTION_ExportRestrictionInclude = "org.eclipse.jdt.core.compiler.accessRestriction.export.include"; //$NON-NLS-1$
98 public static final String OPTION_ExportRestrictionExclude = "org.eclipse.jdt.core.compiler.accessRestriction.export.exclude"; //$NON-NLS-1$
100 // Backward compatibility
101 public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
102 public static final String OPTION_ReportMissingAnnotation = "org.eclipse.jdt.core.compiler.problem.missingAnnotation"; //$NON-NLS-1$
103 public static final String OPTION_ReportMissingJavadoc = "org.eclipse.jdt.core.compiler.problem.missingJavadoc"; //$NON-NLS-1$
105 /* should surface ??? */
106 public static final String OPTION_PrivateConstructorAccess = "org.eclipse.jdt.core.compiler.codegen.constructorAccessEmulation"; //$NON-NLS-1$
109 * Possible values for configurable options
111 public static final String GENERATE = "generate";//$NON-NLS-1$
112 public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
113 public static final String PRESERVE = "preserve"; //$NON-NLS-1$
114 public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
115 public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
116 public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
117 public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
118 public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
119 public static final String VERSION_1_5 = "1.5"; //$NON-NLS-1$
120 public static final String ERROR = "error"; //$NON-NLS-1$
121 public static final String WARNING = "warning"; //$NON-NLS-1$
122 public static final String IGNORE = "ignore"; //$NON-NLS-1$
123 public static final String ENABLED = "enabled"; //$NON-NLS-1$
124 public static final String DISABLED = "disabled"; //$NON-NLS-1$
125 public static final String PUBLIC = "public"; //$NON-NLS-1$
126 public static final String PROTECTED = "protected"; //$NON-NLS-1$
127 public static final String DEFAULT = "default"; //$NON-NLS-1$
128 public static final String PRIVATE = "private"; //$NON-NLS-1$
131 * Bit mask for configurable problems (error/warning threshold)
133 public static final long MethodWithConstructorName = ASTNode.Bit1;
134 public static final long OverriddenPackageDefaultMethod = ASTNode.Bit2;
135 public static final long UsingDeprecatedAPI = ASTNode.Bit3;
136 public static final long MaskedCatchBlock = ASTNode.Bit4;
137 public static final long UnusedLocalVariable = ASTNode.Bit5;
138 public static final long UnusedArgument = ASTNode.Bit6;
139 public static final long NoImplicitStringConversion = ASTNode.Bit7;
140 public static final long AccessEmulation = ASTNode.Bit8;
141 public static final long NonExternalizedString = ASTNode.Bit9;
142 public static final long AssertUsedAsAnIdentifier = ASTNode.Bit10;
143 public static final long UnusedImport = ASTNode.Bit11;
144 public static final long NonStaticAccessToStatic = ASTNode.Bit12;
145 public static final long Task = ASTNode.Bit13;
146 public static final long NoEffectAssignment = ASTNode.Bit14;
147 public static final long IncompatibleNonInheritedInterfaceMethod = ASTNode.Bit15;
148 public static final long UnusedPrivateMember = ASTNode.Bit16;
149 public static final long LocalVariableHiding = ASTNode.Bit17;
150 public static final long FieldHiding = ASTNode.Bit18;
151 public static final long AccidentalBooleanAssign = ASTNode.Bit19;
152 public static final long EmptyStatement = ASTNode.Bit20;
153 public static final long MissingJavadocComments = ASTNode.Bit21;
154 public static final long MissingJavadocTags = ASTNode.Bit22;
155 public static final long UnqualifiedFieldAccess = ASTNode.Bit23;
156 public static final long UnusedDeclaredThrownException = ASTNode.Bit24;
157 public static final long FinallyBlockNotCompleting = ASTNode.Bit25;
158 public static final long InvalidJavadoc = ASTNode.Bit26;
159 public static final long UnnecessaryTypeCheck = ASTNode.Bit27;
160 public static final long UndocumentedEmptyBlock = ASTNode.Bit28;
161 public static final long IndirectStaticAccess = ASTNode.Bit29;
162 public static final long UnnecessaryElse = ASTNode.Bit30;
163 public static final long UnsafeTypeOperation = ASTNode.Bit31;
164 public static final long FinalParameterBound = ASTNode.Bit32L;
165 public static final long MissingSerialVersion = ASTNode.Bit33L;
166 public static final long EnumUsedAsAnIdentifier = ASTNode.Bit34L;
167 public static final long ForbiddenReference = ASTNode.Bit35L;
168 public static final long VarargsArgumentNeedCast = ASTNode.Bit36L;
169 public static final long InconsistentNullCheck = ASTNode.Bit37L;
171 // Default severity level for handlers
172 public long errorThreshold = 0;
174 public long warningThreshold =
175 MethodWithConstructorName
178 | OverriddenPackageDefaultMethod
180 | NonStaticAccessToStatic
182 | IncompatibleNonInheritedInterfaceMethod
183 | NoImplicitStringConversion
184 | FinallyBlockNotCompleting
185 | AssertUsedAsAnIdentifier
186 | EnumUsedAsAnIdentifier
187 | UnsafeTypeOperation
188 | MissingSerialVersion
189 | VarargsArgumentNeedCast
191 /*| InconsistentNullCheck*/;
194 public static final int Source = 1; // SourceFileAttribute
195 public static final int Lines = 2; // LineNumberAttribute
196 public static final int Vars = 4; // LocalVariableTableAttribute
198 // By default only lines and source attributes are generated.
199 public int produceDebugAttributes = Lines | Source;
201 public long complianceLevel = JDK1_4; // by default be compliant with 1.4
202 public long sourceLevel = JDK1_3; //1.3 source behavior by default
203 public long targetJDK = JDK1_2; // default generates for JVM1.2
205 // toggle private access emulation for 1.2 (constr. accessor has extra arg on constructor) or 1.3 (make private constructor default access when access needed)
206 public boolean isPrivateConstructorAccessChangingVisibility = false; // by default, follows 1.2
208 // source encoding format
209 public String defaultEncoding = null; // will use the platform default encoding
211 // print what unit is being processed
212 public boolean verbose = Compiler.DEBUG;
214 // indicates if reference info is desired
215 public boolean produceReferenceInfo = false;
217 // indicates if unused/optimizable local variables need to be preserved (debugging purpose)
218 public boolean preserveAllLocalVariables = false;
220 // indicates whether literal expressions are inlined at parse-time or not
221 public boolean parseLiteralExpressionsAsConstants = true;
223 // max problems per compilation unit
224 public int maxProblemsPerUnit = 100; // no more than 100 problems per default
226 // access restrictions
227 public char[][] importRestrictionInclude;
228 public char[][] importRestrictionExclude;
229 public char[][] exportRestrictionInclude;
230 public char[][] exportRestrictionExclude;
232 // tags used to recognize tasks in comments
233 public char[][] taskTags = null;
234 public char[][] taskPriorites = null;
235 public boolean isTaskCaseSensitive = true;
237 // deprecation report
238 public boolean reportDeprecationInsideDeprecatedCode = false;
239 public boolean reportDeprecationWhenOverridingDeprecatedMethod = false;
241 // unused parameters report
242 public boolean reportUnusedParameterWhenImplementingAbstract = false;
243 public boolean reportUnusedParameterWhenOverridingConcrete = false;
245 // unused declaration of thrown exception
246 public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false;
248 // constructor/setter parameter hiding
249 public boolean reportSpecialParameterHidingField = false;
251 // check javadoc comments tags
252 public int reportInvalidJavadocTagsVisibility = AccPrivate;
253 public boolean reportInvalidJavadocTags = true;
254 public boolean reportInvalidJavadocTagsDeprecatedRef = true;
255 public boolean reportInvalidJavadocTagsNotVisibleRef = true;
257 // check missing javadoc tags
258 public int reportMissingJavadocTagsVisibility = AccPrivate;
259 public boolean reportMissingJavadocTagsOverriding = true;
261 // check missing javadoc comments
262 public int reportMissingJavadocCommentsVisibility = AccPublic;
263 public boolean reportMissingJavadocCommentsOverriding = true;
265 // JSR bytecode inlining
266 public boolean inlineJsrBytecode = false;
268 // javadoc comment support
269 public boolean docCommentSupport = false;
273 * Initializing the compiler options with defaults
275 public CompilerOptions(){
276 // use default options
280 * Initializing the compiler options with external settings
283 public CompilerOptions(Map settings){
285 if (settings == null) return;
289 public Map getMap() {
290 Map optionsMap = new HashMap(30);
291 optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & Vars) != 0 ? GENERATE : DO_NOT_GENERATE);
292 optionsMap.put(OPTION_LineNumberAttribute, (this.produceDebugAttributes & Lines) != 0 ? GENERATE : DO_NOT_GENERATE);
293 optionsMap.put(OPTION_SourceFileAttribute, (this.produceDebugAttributes & Source) != 0 ? GENERATE : DO_NOT_GENERATE);
294 optionsMap.put(OPTION_PreserveUnusedLocal, this.preserveAllLocalVariables ? PRESERVE : OPTIMIZE_OUT);
295 optionsMap.put(OPTION_DocCommentSupport, this.docCommentSupport ? ENABLED : DISABLED);
296 optionsMap.put(OPTION_ReportMethodWithConstructorName, getSeverityString(MethodWithConstructorName));
297 optionsMap.put(OPTION_ReportOverridingPackageDefaultMethod, getSeverityString(OverriddenPackageDefaultMethod));
298 optionsMap.put(OPTION_ReportDeprecation, getSeverityString(UsingDeprecatedAPI));
299 optionsMap.put(OPTION_ReportDeprecationInDeprecatedCode, this.reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED);
300 optionsMap.put(OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED);
301 optionsMap.put(OPTION_ReportHiddenCatchBlock, getSeverityString(MaskedCatchBlock));
302 optionsMap.put(OPTION_ReportUnusedLocal, getSeverityString(UnusedLocalVariable));
303 optionsMap.put(OPTION_ReportUnusedParameter, getSeverityString(UnusedArgument));
304 optionsMap.put(OPTION_ReportUnusedImport, getSeverityString(UnusedImport));
305 optionsMap.put(OPTION_ReportSyntheticAccessEmulation, getSeverityString(AccessEmulation));
306 optionsMap.put(OPTION_ReportNoEffectAssignment, getSeverityString(NoEffectAssignment));
307 optionsMap.put(OPTION_ReportNonExternalizedStringLiteral, getSeverityString(NonExternalizedString));
308 optionsMap.put(OPTION_ReportNoImplicitStringConversion, getSeverityString(NoImplicitStringConversion));
309 optionsMap.put(OPTION_ReportNonStaticAccessToStatic, getSeverityString(NonStaticAccessToStatic));
310 optionsMap.put(OPTION_ReportIndirectStaticAccess, getSeverityString(IndirectStaticAccess));
311 optionsMap.put(OPTION_ReportIncompatibleNonInheritedInterfaceMethod, getSeverityString(IncompatibleNonInheritedInterfaceMethod));
312 optionsMap.put(OPTION_ReportUnusedPrivateMember, getSeverityString(UnusedPrivateMember));
313 optionsMap.put(OPTION_ReportLocalVariableHiding, getSeverityString(LocalVariableHiding));
314 optionsMap.put(OPTION_ReportFieldHiding, getSeverityString(FieldHiding));
315 optionsMap.put(OPTION_ReportPossibleAccidentalBooleanAssignment, getSeverityString(AccidentalBooleanAssign));
316 optionsMap.put(OPTION_ReportEmptyStatement, getSeverityString(EmptyStatement));
317 optionsMap.put(OPTION_ReportAssertIdentifier, getSeverityString(AssertUsedAsAnIdentifier));
318 optionsMap.put(OPTION_ReportEnumIdentifier, getSeverityString(EnumUsedAsAnIdentifier));
319 optionsMap.put(OPTION_ReportUndocumentedEmptyBlock, getSeverityString(UndocumentedEmptyBlock));
320 optionsMap.put(OPTION_ReportUnnecessaryTypeCheck, getSeverityString(UnnecessaryTypeCheck));
321 optionsMap.put(OPTION_ReportUnnecessaryElse, getSeverityString(UnnecessaryElse));
322 optionsMap.put(OPTION_ReportInvalidJavadoc, getSeverityString(InvalidJavadoc));
323 optionsMap.put(OPTION_ReportInvalidJavadocTagsVisibility, getVisibilityString(this.reportInvalidJavadocTagsVisibility));
324 optionsMap.put(OPTION_ReportInvalidJavadocTags, this.reportInvalidJavadocTags ? ENABLED : DISABLED);
325 optionsMap.put(OPTION_ReportInvalidJavadocTagsDeprecatedRef, this.reportInvalidJavadocTagsDeprecatedRef ? ENABLED : DISABLED);
326 optionsMap.put(OPTION_ReportInvalidJavadocTagsNotVisibleRef, this.reportInvalidJavadocTagsNotVisibleRef ? ENABLED : DISABLED);
327 optionsMap.put(OPTION_ReportMissingJavadocTags, getSeverityString(MissingJavadocTags));
328 optionsMap.put(OPTION_ReportMissingJavadocTagsVisibility, getVisibilityString(this.reportMissingJavadocTagsVisibility));
329 optionsMap.put(OPTION_ReportMissingJavadocTagsOverriding, this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED);
330 optionsMap.put(OPTION_ReportMissingJavadocComments, getSeverityString(MissingJavadocComments));
331 optionsMap.put(OPTION_ReportMissingJavadocCommentsVisibility, getVisibilityString(this.reportMissingJavadocCommentsVisibility));
332 optionsMap.put(OPTION_ReportMissingJavadocCommentsOverriding, this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED);
333 optionsMap.put(OPTION_ReportFinallyBlockNotCompletingNormally, getSeverityString(FinallyBlockNotCompleting));
334 optionsMap.put(OPTION_ReportUnusedDeclaredThrownException, getSeverityString(UnusedDeclaredThrownException));
335 optionsMap.put(OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding, this.reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED);
336 optionsMap.put(OPTION_ReportUnqualifiedFieldAccess, getSeverityString(UnqualifiedFieldAccess));
337 optionsMap.put(OPTION_ReportUnsafeTypeOperation, getSeverityString(UnsafeTypeOperation));
338 optionsMap.put(OPTION_ReportFinalParameterBound, getSeverityString(FinalParameterBound));
339 optionsMap.put(OPTION_ReportMissingSerialVersion, getSeverityString(MissingSerialVersion));
340 optionsMap.put(OPTION_ReportForbiddenReference, getSeverityString(ForbiddenReference));
341 optionsMap.put(OPTION_ReportVarargsArgumentNeedCast, getSeverityString(VarargsArgumentNeedCast));
342 optionsMap.put(OPTION_Compliance, versionFromJdkLevel(this.complianceLevel));
343 optionsMap.put(OPTION_Source, versionFromJdkLevel(this.sourceLevel));
344 optionsMap.put(OPTION_TargetPlatform, versionFromJdkLevel(this.targetJDK));
345 if (this.defaultEncoding != null) {
346 optionsMap.put(OPTION_Encoding, this.defaultEncoding);
348 optionsMap.put(OPTION_TaskTags, this.taskTags == null ? "" : new String(CharOperation.concatWith(this.taskTags,','))); //$NON-NLS-1$
349 optionsMap.put(OPTION_TaskPriorities, this.taskPriorites == null ? "" : new String(CharOperation.concatWith(this.taskPriorites,','))); //$NON-NLS-1$
350 optionsMap.put(OPTION_TaskCaseSensitive, this.isTaskCaseSensitive ? ENABLED : DISABLED);
351 optionsMap.put(OPTION_ReportUnusedParameterWhenImplementingAbstract, this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED);
352 optionsMap.put(OPTION_ReportUnusedParameterWhenOverridingConcrete, this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED);
353 optionsMap.put(OPTION_ReportSpecialParameterHidingField, this.reportSpecialParameterHidingField ? ENABLED : DISABLED);
354 optionsMap.put(OPTION_MaxProblemPerUnit, String.valueOf(this.maxProblemsPerUnit));
355 optionsMap.put(OPTION_InlineJsr, this.inlineJsrBytecode ? ENABLED : DISABLED);
356 optionsMap.put(OPTION_ImportRestrictionInclude, this.importRestrictionInclude == null ? "" : new String(CharOperation.concatWith(this.importRestrictionInclude,','))); //$NON-NLS-1$
357 optionsMap.put(OPTION_ImportRestrictionExclude, this.importRestrictionExclude == null ? "" : new String(CharOperation.concatWith(this.importRestrictionExclude,','))); //$NON-NLS-1$
358 optionsMap.put(OPTION_ImportRestrictionInclude, this.exportRestrictionInclude == null ? "" : new String(CharOperation.concatWith(this.exportRestrictionInclude,','))); //$NON-NLS-1$
359 optionsMap.put(OPTION_ExportRestrictionExclude, this.exportRestrictionExclude == null ? "" : new String(CharOperation.concatWith(this.exportRestrictionExclude,','))); //$NON-NLS-1$
360 optionsMap.put(OPTION_ReportInconsistentNullCheck, getSeverityString(InconsistentNullCheck));
364 public int getSeverity(long irritant) {
365 if((this.warningThreshold & irritant) != 0)
367 if((this.errorThreshold & irritant) != 0)
372 public String getSeverityString(long irritant) {
373 if((this.warningThreshold & irritant) != 0)
375 if((this.errorThreshold & irritant) != 0)
380 public String getVisibilityString(int level) {
393 public void set(Map optionsMap) {
396 if ((optionValue = optionsMap.get(OPTION_LocalVariableAttribute)) != null) {
397 if (GENERATE.equals(optionValue)) {
398 this.produceDebugAttributes |= Vars;
399 } else if (DO_NOT_GENERATE.equals(optionValue)) {
400 this.produceDebugAttributes &= ~Vars;
403 if ((optionValue = optionsMap.get(OPTION_LineNumberAttribute)) != null) {
404 if (GENERATE.equals(optionValue)) {
405 this.produceDebugAttributes |= Lines;
406 } else if (DO_NOT_GENERATE.equals(optionValue)) {
407 this.produceDebugAttributes &= ~Lines;
410 if ((optionValue = optionsMap.get(OPTION_SourceFileAttribute)) != null) {
411 if (GENERATE.equals(optionValue)) {
412 this.produceDebugAttributes |= Source;
413 } else if (DO_NOT_GENERATE.equals(optionValue)) {
414 this.produceDebugAttributes &= ~Source;
417 if ((optionValue = optionsMap.get(OPTION_PreserveUnusedLocal)) != null) {
418 if (PRESERVE.equals(optionValue)) {
419 this.preserveAllLocalVariables = true;
420 } else if (OPTIMIZE_OUT.equals(optionValue)) {
421 this.preserveAllLocalVariables = false;
424 if ((optionValue = optionsMap.get(OPTION_ReportDeprecationInDeprecatedCode)) != null) {
425 if (ENABLED.equals(optionValue)) {
426 this.reportDeprecationInsideDeprecatedCode = true;
427 } else if (DISABLED.equals(optionValue)) {
428 this.reportDeprecationInsideDeprecatedCode = false;
431 if ((optionValue = optionsMap.get(OPTION_ReportDeprecationWhenOverridingDeprecatedMethod)) != null) {
432 if (ENABLED.equals(optionValue)) {
433 this.reportDeprecationWhenOverridingDeprecatedMethod = true;
434 } else if (DISABLED.equals(optionValue)) {
435 this.reportDeprecationWhenOverridingDeprecatedMethod = false;
438 if ((optionValue = optionsMap.get(OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding)) != null) {
439 if (ENABLED.equals(optionValue)) {
440 this.reportUnusedDeclaredThrownExceptionWhenOverriding = true;
441 } else if (DISABLED.equals(optionValue)) {
442 this.reportUnusedDeclaredThrownExceptionWhenOverriding = false;
445 if ((optionValue = optionsMap.get(OPTION_Compliance)) != null) {
446 long level = versionToJdkLevel(optionValue);
447 if (level != 0) this.complianceLevel = level;
449 if ((optionValue = optionsMap.get(OPTION_Source)) != null) {
450 long level = versionToJdkLevel(optionValue);
451 if (level != 0) this.sourceLevel = level;
453 if ((optionValue = optionsMap.get(OPTION_TargetPlatform)) != null) {
454 long level = versionToJdkLevel(optionValue);
455 if (level != 0) this.targetJDK = level;
456 if (this.targetJDK >= JDK1_5) this.inlineJsrBytecode = true; // forced in 1.5 mode
458 if ((optionValue = optionsMap.get(OPTION_Encoding)) != null) {
459 if (optionValue instanceof String) {
460 this.defaultEncoding = null;
461 String stringValue = (String) optionValue;
462 if (stringValue.length() > 0){
464 new InputStreamReader(new ByteArrayInputStream(new byte[0]), stringValue);
465 this.defaultEncoding = stringValue;
466 } catch(UnsupportedEncodingException e){
467 // ignore unsupported encoding
472 if ((optionValue = optionsMap.get(OPTION_PrivateConstructorAccess)) != null) {
473 long level = versionToJdkLevel(optionValue);
474 if (level >= JDK1_3) this.isPrivateConstructorAccessChangingVisibility = true;
476 if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameterWhenImplementingAbstract)) != null) {
477 if (ENABLED.equals(optionValue)) {
478 this.reportUnusedParameterWhenImplementingAbstract = true;
479 } else if (DISABLED.equals(optionValue)) {
480 this.reportUnusedParameterWhenImplementingAbstract = false;
483 if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameterWhenOverridingConcrete)) != null) {
484 if (ENABLED.equals(optionValue)) {
485 this.reportUnusedParameterWhenOverridingConcrete = true;
486 } else if (DISABLED.equals(optionValue)) {
487 this.reportUnusedParameterWhenOverridingConcrete = false;
490 if ((optionValue = optionsMap.get(OPTION_ReportSpecialParameterHidingField)) != null) {
491 if (ENABLED.equals(optionValue)) {
492 this.reportSpecialParameterHidingField = true;
493 } else if (DISABLED.equals(optionValue)) {
494 this.reportSpecialParameterHidingField = false;
497 if ((optionValue = optionsMap.get(OPTION_MaxProblemPerUnit)) != null) {
498 if (optionValue instanceof String) {
499 String stringValue = (String) optionValue;
501 int val = Integer.parseInt(stringValue);
502 if (val >= 0) this.maxProblemsPerUnit = val;
503 } catch(NumberFormatException e){
504 // ignore ill-formatted limit
508 if ((optionValue = optionsMap.get(OPTION_TaskTags)) != null) {
509 if (optionValue instanceof String) {
510 String stringValue = (String) optionValue;
511 if (stringValue.length() == 0) {
512 this.taskTags = null;
514 this.taskTags = CharOperation.splitAndTrimOn(',', stringValue.toCharArray());
518 if ((optionValue = optionsMap.get(OPTION_TaskPriorities)) != null) {
519 if (optionValue instanceof String) {
520 String stringValue = (String) optionValue;
521 if (stringValue.length() == 0) {
522 this.taskPriorites = null;
524 this.taskPriorites = CharOperation.splitAndTrimOn(',', stringValue.toCharArray());
528 if ((optionValue = optionsMap.get(OPTION_TaskCaseSensitive)) != null) {
529 if (ENABLED.equals(optionValue)) {
530 this.isTaskCaseSensitive = true;
531 } else if (DISABLED.equals(optionValue)) {
532 this.isTaskCaseSensitive = false;
535 if ((optionValue = optionsMap.get(OPTION_ImportRestrictionInclude)) != null) {
536 if (optionValue instanceof String) {
537 String stringValue = (String) optionValue;
538 if (stringValue.length() == 0) {
539 this.importRestrictionInclude = null;
541 this.importRestrictionInclude = CharOperation.splitAndTrimOn(',', stringValue.toCharArray());
545 if ((optionValue = optionsMap.get(OPTION_ImportRestrictionExclude)) != null) {
546 if (optionValue instanceof String) {
547 String stringValue = (String) optionValue;
548 if (stringValue.length() == 0) {
549 this.importRestrictionExclude = null;
551 this.importRestrictionExclude = CharOperation.splitAndTrimOn(',', stringValue.toCharArray());
555 if ((optionValue = optionsMap.get(OPTION_ExportRestrictionInclude)) != null) {
556 if (optionValue instanceof String) {
557 String stringValue = (String) optionValue;
558 if (stringValue.length() == 0) {
559 this.exportRestrictionInclude = null;
561 this.exportRestrictionInclude = CharOperation.splitAndTrimOn(',', stringValue.toCharArray());
565 if ((optionValue = optionsMap.get(OPTION_ExportRestrictionExclude)) != null) {
566 if (optionValue instanceof String) {
567 String stringValue = (String) optionValue;
568 if (stringValue.length() == 0) {
569 this.exportRestrictionExclude = null;
571 this.exportRestrictionExclude = CharOperation.splitAndTrimOn(',', stringValue.toCharArray());
575 if ((optionValue = optionsMap.get(OPTION_InlineJsr)) != null) {
576 if (this.targetJDK < JDK1_5) { // only optional if target < 1.5 (inlining on from 1.5 on)
577 if (ENABLED.equals(optionValue)) {
578 this.inlineJsrBytecode = true;
579 } else if (DISABLED.equals(optionValue)) {
580 this.inlineJsrBytecode = false;
584 if ((optionValue = optionsMap.get(OPTION_ReportMethodWithConstructorName)) != null) updateSeverity(MethodWithConstructorName, optionValue);
585 if ((optionValue = optionsMap.get(OPTION_ReportOverridingPackageDefaultMethod)) != null) updateSeverity(OverriddenPackageDefaultMethod, optionValue);
586 if ((optionValue = optionsMap.get(OPTION_ReportDeprecation)) != null) updateSeverity(UsingDeprecatedAPI, optionValue);
587 if ((optionValue = optionsMap.get(OPTION_ReportHiddenCatchBlock)) != null) updateSeverity(MaskedCatchBlock, optionValue);
588 if ((optionValue = optionsMap.get(OPTION_ReportUnusedLocal)) != null) updateSeverity(UnusedLocalVariable, optionValue);
589 if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameter)) != null) updateSeverity(UnusedArgument, optionValue);
590 if ((optionValue = optionsMap.get(OPTION_ReportUnusedImport)) != null) updateSeverity(UnusedImport, optionValue);
591 if ((optionValue = optionsMap.get(OPTION_ReportUnusedPrivateMember)) != null) updateSeverity(UnusedPrivateMember, optionValue);
592 if ((optionValue = optionsMap.get(OPTION_ReportUnusedDeclaredThrownException)) != null) updateSeverity(UnusedDeclaredThrownException, optionValue);
593 if ((optionValue = optionsMap.get(OPTION_ReportNoImplicitStringConversion)) != null) updateSeverity(NoImplicitStringConversion, optionValue);
594 if ((optionValue = optionsMap.get(OPTION_ReportSyntheticAccessEmulation)) != null) updateSeverity(AccessEmulation, optionValue);
595 if ((optionValue = optionsMap.get(OPTION_ReportLocalVariableHiding)) != null) updateSeverity(LocalVariableHiding, optionValue);
596 if ((optionValue = optionsMap.get(OPTION_ReportFieldHiding)) != null) updateSeverity(FieldHiding, optionValue);
597 if ((optionValue = optionsMap.get(OPTION_ReportPossibleAccidentalBooleanAssignment)) != null) updateSeverity(AccidentalBooleanAssign, optionValue);
598 if ((optionValue = optionsMap.get(OPTION_ReportEmptyStatement)) != null) updateSeverity(EmptyStatement, optionValue);
599 if ((optionValue = optionsMap.get(OPTION_ReportNonExternalizedStringLiteral)) != null) updateSeverity(NonExternalizedString, optionValue);
600 if ((optionValue = optionsMap.get(OPTION_ReportAssertIdentifier)) != null) updateSeverity(AssertUsedAsAnIdentifier, optionValue);
601 if ((optionValue = optionsMap.get(OPTION_ReportEnumIdentifier)) != null) updateSeverity(EnumUsedAsAnIdentifier, optionValue);
602 if ((optionValue = optionsMap.get(OPTION_ReportNonStaticAccessToStatic)) != null) updateSeverity(NonStaticAccessToStatic, optionValue);
603 if ((optionValue = optionsMap.get(OPTION_ReportIndirectStaticAccess)) != null) updateSeverity(IndirectStaticAccess, optionValue);
604 if ((optionValue = optionsMap.get(OPTION_ReportIncompatibleNonInheritedInterfaceMethod)) != null) updateSeverity(IncompatibleNonInheritedInterfaceMethod, optionValue);
605 if ((optionValue = optionsMap.get(OPTION_ReportUndocumentedEmptyBlock)) != null) updateSeverity(UndocumentedEmptyBlock, optionValue);
606 if ((optionValue = optionsMap.get(OPTION_ReportUnnecessaryTypeCheck)) != null) updateSeverity(UnnecessaryTypeCheck, optionValue);
607 if ((optionValue = optionsMap.get(OPTION_ReportUnnecessaryElse)) != null) updateSeverity(UnnecessaryElse, optionValue);
608 if ((optionValue = optionsMap.get(OPTION_ReportFinallyBlockNotCompletingNormally)) != null) updateSeverity(FinallyBlockNotCompleting, optionValue);
609 if ((optionValue = optionsMap.get(OPTION_ReportUnqualifiedFieldAccess)) != null) updateSeverity(UnqualifiedFieldAccess, optionValue);
610 if ((optionValue = optionsMap.get(OPTION_ReportNoEffectAssignment)) != null) updateSeverity(NoEffectAssignment, optionValue);
611 if ((optionValue = optionsMap.get(OPTION_ReportUnsafeTypeOperation)) != null) updateSeverity(UnsafeTypeOperation, optionValue);
612 if ((optionValue = optionsMap.get(OPTION_ReportFinalParameterBound)) != null) updateSeverity(FinalParameterBound, optionValue);
613 if ((optionValue = optionsMap.get(OPTION_ReportMissingSerialVersion)) != null) updateSeverity(MissingSerialVersion, optionValue);
614 if ((optionValue = optionsMap.get(OPTION_ReportForbiddenReference)) != null) updateSeverity(ForbiddenReference, optionValue);
615 if ((optionValue = optionsMap.get(OPTION_ReportVarargsArgumentNeedCast)) != null) updateSeverity(VarargsArgumentNeedCast, optionValue);
616 if ((optionValue = optionsMap.get(OPTION_ReportInconsistentNullCheck)) != null) updateSeverity(InconsistentNullCheck, optionValue);
619 if ((optionValue = optionsMap.get(OPTION_DocCommentSupport)) != null) {
620 if (ENABLED.equals(optionValue)) {
621 this.docCommentSupport = true;
622 } else if (DISABLED.equals(optionValue)) {
623 this.docCommentSupport = false;
626 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadoc)) != null) {
627 updateSeverity(InvalidJavadoc, optionValue);
629 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTagsVisibility)) != null) {
630 if (PUBLIC.equals(optionValue)) {
631 this.reportInvalidJavadocTagsVisibility = AccPublic;
632 } else if (PROTECTED.equals(optionValue)) {
633 this.reportInvalidJavadocTagsVisibility = AccProtected;
634 } else if (DEFAULT.equals(optionValue)) {
635 this.reportInvalidJavadocTagsVisibility = AccDefault;
636 } else if (PRIVATE.equals(optionValue)) {
637 this.reportInvalidJavadocTagsVisibility = AccPrivate;
640 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTags)) != null) {
641 if (ENABLED.equals(optionValue)) {
642 this.reportInvalidJavadocTags = true;
643 } else if (DISABLED.equals(optionValue)) {
644 this.reportInvalidJavadocTags = false;
647 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTagsDeprecatedRef)) != null) {
648 if (ENABLED.equals(optionValue)) {
649 this.reportInvalidJavadocTagsDeprecatedRef = true;
650 } else if (DISABLED.equals(optionValue)) {
651 this.reportInvalidJavadocTagsDeprecatedRef = false;
654 if ((optionValue = optionsMap.get(OPTION_ReportInvalidJavadocTagsNotVisibleRef)) != null) {
655 if (ENABLED.equals(optionValue)) {
656 this.reportInvalidJavadocTagsNotVisibleRef = true;
657 } else if (DISABLED.equals(optionValue)) {
658 this.reportInvalidJavadocTagsNotVisibleRef = false;
661 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTags)) != null) {
662 updateSeverity(MissingJavadocTags, optionValue);
664 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTagsVisibility)) != null) {
665 if (PUBLIC.equals(optionValue)) {
666 this.reportMissingJavadocTagsVisibility = AccPublic;
667 } else if (PROTECTED.equals(optionValue)) {
668 this.reportMissingJavadocTagsVisibility = AccProtected;
669 } else if (DEFAULT.equals(optionValue)) {
670 this.reportMissingJavadocTagsVisibility = AccDefault;
671 } else if (PRIVATE.equals(optionValue)) {
672 this.reportMissingJavadocTagsVisibility = AccPrivate;
675 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocTagsOverriding)) != null) {
676 if (ENABLED.equals(optionValue)) {
677 this.reportMissingJavadocTagsOverriding = true;
678 } else if (DISABLED.equals(optionValue)) {
679 this.reportMissingJavadocTagsOverriding = false;
682 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocComments)) != null) {
683 updateSeverity(MissingJavadocComments, optionValue);
685 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocCommentsVisibility)) != null) {
686 if (PUBLIC.equals(optionValue)) {
687 this.reportMissingJavadocCommentsVisibility = AccPublic;
688 } else if (PROTECTED.equals(optionValue)) {
689 this.reportMissingJavadocCommentsVisibility = AccProtected;
690 } else if (DEFAULT.equals(optionValue)) {
691 this.reportMissingJavadocCommentsVisibility = AccDefault;
692 } else if (PRIVATE.equals(optionValue)) {
693 this.reportMissingJavadocCommentsVisibility = AccPrivate;
696 if ((optionValue = optionsMap.get(OPTION_ReportMissingJavadocCommentsOverriding)) != null) {
697 if (ENABLED.equals(optionValue)) {
698 this.reportMissingJavadocCommentsOverriding = true;
699 } else if (DISABLED.equals(optionValue)) {
700 this.reportMissingJavadocCommentsOverriding = false;
705 public String toString() {
707 StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$
708 buf.append("\n\t- local variables debug attributes: ").append((this.produceDebugAttributes & Vars) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
709 buf.append("\n\t- line number debug attributes: ").append((this.produceDebugAttributes & Lines) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
710 buf.append("\n\t- source debug attributes: ").append((this.produceDebugAttributes & Source) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
711 buf.append("\n\t- preserve all local variables: ").append(this.preserveAllLocalVariables ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
712 buf.append("\n\t- method with constructor name: ").append(getSeverityString(MethodWithConstructorName)); //$NON-NLS-1$
713 buf.append("\n\t- overridden package default method: ").append(getSeverityString(OverriddenPackageDefaultMethod)); //$NON-NLS-1$
714 buf.append("\n\t- deprecation: ").append(getSeverityString(UsingDeprecatedAPI)); //$NON-NLS-1$
715 buf.append("\n\t- masked catch block: ").append(getSeverityString(MaskedCatchBlock)); //$NON-NLS-1$
716 buf.append("\n\t- unused local variable: ").append(getSeverityString(UnusedLocalVariable)); //$NON-NLS-1$
717 buf.append("\n\t- unused parameter: ").append(getSeverityString(UnusedArgument)); //$NON-NLS-1$
718 buf.append("\n\t- unused import: ").append(getSeverityString(UnusedImport)); //$NON-NLS-1$
719 buf.append("\n\t- synthetic access emulation: ").append(getSeverityString(AccessEmulation)); //$NON-NLS-1$
720 buf.append("\n\t- assignment with no effect: ").append(getSeverityString(NoEffectAssignment)); //$NON-NLS-1$
721 buf.append("\n\t- non externalized string: ").append(getSeverityString(NonExternalizedString)); //$NON-NLS-1$
722 buf.append("\n\t- static access receiver: ").append(getSeverityString(NonStaticAccessToStatic)); //$NON-NLS-1$
723 buf.append("\n\t- indirect static access: ").append(getSeverityString(IndirectStaticAccess)); //$NON-NLS-1$
724 buf.append("\n\t- incompatible non inherited interface method: ").append(getSeverityString(IncompatibleNonInheritedInterfaceMethod)); //$NON-NLS-1$
725 buf.append("\n\t- unused private member: ").append(getSeverityString(UnusedPrivateMember)); //$NON-NLS-1$
726 buf.append("\n\t- local variable hiding another variable: ").append(getSeverityString(LocalVariableHiding)); //$NON-NLS-1$
727 buf.append("\n\t- field hiding another variable: ").append(getSeverityString(FieldHiding)); //$NON-NLS-1$
728 buf.append("\n\t- possible accidental boolean assignment: ").append(getSeverityString(AccidentalBooleanAssign)); //$NON-NLS-1$
729 buf.append("\n\t- superfluous semicolon: ").append(getSeverityString(EmptyStatement)); //$NON-NLS-1$
730 buf.append("\n\t- uncommented empty block: ").append(getSeverityString(UndocumentedEmptyBlock)); //$NON-NLS-1$
731 buf.append("\n\t- unnecessary type check: ").append(getSeverityString(UnnecessaryTypeCheck)); //$NON-NLS-1$
732 buf.append("\n\t- javadoc comment support: ").append(this.docCommentSupport ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
733 buf.append("\n\t\t+ invalid javadoc: ").append(getSeverityString(InvalidJavadoc)); //$NON-NLS-1$
734 buf.append("\n\t\t+ report invalid javadoc tags: ").append(this.reportInvalidJavadocTags ? ENABLED : DISABLED); //$NON-NLS-1$
735 buf.append("\n\t\t\t* deprecated references: ").append(this.reportInvalidJavadocTagsDeprecatedRef ? ENABLED : DISABLED); //$NON-NLS-1$
736 buf.append("\n\t\t\t* not visble references: ").append(this.reportInvalidJavadocTagsNotVisibleRef ? ENABLED : DISABLED); //$NON-NLS-1$
737 buf.append("\n\t\t+ visibility level to report invalid javadoc tags: ").append(getVisibilityString(this.reportInvalidJavadocTagsVisibility)); //$NON-NLS-1$
738 buf.append("\n\t\t+ missing javadoc tags: ").append(getSeverityString(MissingJavadocTags)); //$NON-NLS-1$
739 buf.append("\n\t\t+ visibility level to report missing javadoc tags: ").append(getVisibilityString(this.reportMissingJavadocTagsVisibility)); //$NON-NLS-1$
740 buf.append("\n\t\t+ report missing javadoc tags in overriding methods: ").append(this.reportMissingJavadocTagsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
741 buf.append("\n\t\t+ missing javadoc comments: ").append(getSeverityString(MissingJavadocComments)); //$NON-NLS-1$
742 buf.append("\n\t\t+ visibility level to report missing javadoc comments: ").append(getVisibilityString(this.reportMissingJavadocCommentsVisibility)); //$NON-NLS-1$
743 buf.append("\n\t\t+ report missing javadoc comments in overriding methods: ").append(this.reportMissingJavadocCommentsOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
744 buf.append("\n\t- finally block not completing normally: ").append(getSeverityString(FinallyBlockNotCompleting)); //$NON-NLS-1$
745 buf.append("\n\t- unused declared thrown exception: ").append(getSeverityString(UnusedDeclaredThrownException)); //$NON-NLS-1$
746 buf.append("\n\t- unused declared thrown exception when overriding: ").append(this.reportUnusedDeclaredThrownExceptionWhenOverriding ? ENABLED : DISABLED); //$NON-NLS-1$
747 buf.append("\n\t- unnecessary else: ").append(getSeverityString(UnnecessaryElse)); //$NON-NLS-1$
748 buf.append("\n\t- JDK compliance level: "+ versionFromJdkLevel(this.complianceLevel)); //$NON-NLS-1$
749 buf.append("\n\t- JDK source level: "+ versionFromJdkLevel(this.sourceLevel)); //$NON-NLS-1$
750 buf.append("\n\t- JDK target level: "+ versionFromJdkLevel(this.targetJDK)); //$NON-NLS-1$
751 buf.append("\n\t- private constructor access: ").append(this.isPrivateConstructorAccessChangingVisibility ? "extra argument" : "make default access"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
752 buf.append("\n\t- verbose : ").append(this.verbose ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
753 buf.append("\n\t- produce reference info : ").append(this.produceReferenceInfo ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
754 buf.append("\n\t- parse literal expressions as constants : ").append(this.parseLiteralExpressionsAsConstants ? "ON" : "OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
755 buf.append("\n\t- encoding : ").append(this.defaultEncoding == null ? "<default>" : this.defaultEncoding); //$NON-NLS-1$ //$NON-NLS-2$
756 buf.append("\n\t- task tags: ").append(this.taskTags == null ? "" : new String(CharOperation.concatWith(this.taskTags,','))); //$NON-NLS-1$ //$NON-NLS-2$
757 buf.append("\n\t- task priorities : ").append(this.taskPriorites == null ? "" : new String(CharOperation.concatWith(this.taskPriorites,','))); //$NON-NLS-1$ //$NON-NLS-2$
758 buf.append("\n\t- report deprecation inside deprecated code : ").append(this.reportDeprecationInsideDeprecatedCode ? ENABLED : DISABLED); //$NON-NLS-1$
759 buf.append("\n\t- report deprecation when overriding deprecated method : ").append(this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED); //$NON-NLS-1$
760 buf.append("\n\t- report unused parameter when implementing abstract method : ").append(this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); //$NON-NLS-1$
761 buf.append("\n\t- report unused parameter when overriding concrete method : ").append(this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); //$NON-NLS-1$
762 buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$
763 buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$
764 buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UnsafeTypeOperation)); //$NON-NLS-1$
765 buf.append("\n\t- final bound for type parameter: ").append(getSeverityString(FinalParameterBound)); //$NON-NLS-1$
766 buf.append("\n\t- missing serialVersionUID: ").append(getSeverityString(MissingSerialVersion)); //$NON-NLS-1$
767 buf.append("\n\t- varargs argument need cast: ").append(getSeverityString(VarargsArgumentNeedCast)); //$NON-NLS-1$
768 buf.append("\n\t- forbidden reference to type with access restriction: ").append(getSeverityString(ForbiddenReference)); //$NON-NLS-1$
769 buf.append("\n\t- import access restriction includes: ").append(this.importRestrictionInclude == null ? "" : new String(CharOperation.concatWith(this.importRestrictionInclude,','))); //$NON-NLS-1$ //$NON-NLS-2$
770 buf.append("\n\t- import access restriction excludes: ").append(this.importRestrictionExclude == null ? "" : new String(CharOperation.concatWith(this.importRestrictionExclude,','))); //$NON-NLS-1$ //$NON-NLS-2$
771 buf.append("\n\t- export access restriction includes: ").append(this.exportRestrictionInclude == null ? "" : new String(CharOperation.concatWith(this.exportRestrictionInclude,','))); //$NON-NLS-1$ //$NON-NLS-2$
772 buf.append("\n\t- export access restriction excludes: ").append(this.exportRestrictionExclude == null ? "" : new String(CharOperation.concatWith(this.exportRestrictionExclude,','))); //$NON-NLS-1$ //$NON-NLS-2$
773 buf.append("\n\t- inconsistent null check: ").append(getSeverityString(InconsistentNullCheck)); //$NON-NLS-1$
774 return buf.toString();
777 void updateSeverity(long irritant, Object severityString) {
778 if (ERROR.equals(severityString)) {
779 this.errorThreshold |= irritant;
780 this.warningThreshold &= ~irritant;
781 } else if (WARNING.equals(severityString)) {
782 this.errorThreshold &= ~irritant;
783 this.warningThreshold |= irritant;
784 } else if (IGNORE.equals(severityString)) {
785 this.errorThreshold &= ~irritant;
786 this.warningThreshold &= ~irritant;
789 public static long versionToJdkLevel(Object versionID) {
790 if (VERSION_1_1.equals(versionID)) {
792 } else if (VERSION_1_2.equals(versionID)) {
794 } else if (VERSION_1_3.equals(versionID)) {
796 } else if (VERSION_1_4.equals(versionID)) {
798 } else if (VERSION_1_5.equals(versionID)) {
804 public static String versionFromJdkLevel(long jdkLevel) {
805 if (jdkLevel == JDK1_1) {
807 } else if (jdkLevel == JDK1_2) {
809 } else if (jdkLevel == JDK1_3) {
811 } else if (jdkLevel == JDK1_4) {
813 } else if (jdkLevel == JDK1_5) {
816 return ""; // unknown version //$NON-NLS-1$