View | Details | Raw Unified | Return to bug 245973
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/util/Util.java (-1 / +1 lines)
Lines 1321-1327 Link Here
1321
						}
1321
						}
1322
					}
1322
					}
1323
					if (showWarningToken) {
1323
					if (showWarningToken) {
1324
						long irritant = ProblemReporter.getIrritant(problem.getID());
1324
						int irritant = ProblemReporter.getIrritant(problem.getID());
1325
						if (irritant != 0) {
1325
						if (irritant != 0) {
1326
							String warningToken = CompilerOptions.warningTokenFromIrritant(irritant);
1326
							String warningToken = CompilerOptions.warningTokenFromIrritant(irritant);
1327
							if (warningToken != null) {
1327
							if (warningToken != null) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java (-7 / +9 lines)
Lines 21-26 Link Here
21
import org.eclipse.jdt.internal.compiler.CompilationResult;
21
import org.eclipse.jdt.internal.compiler.CompilationResult;
22
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
22
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
23
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
23
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
24
import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
24
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
25
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
25
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
26
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
26
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
27
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
Lines 60-73 Link Here
60
61
61
// irritant vs warning token - check To/From symmetry
62
// irritant vs warning token - check To/From symmetry
62
public void test001_irritant_warning_token() {
63
public void test001_irritant_warning_token() {
63
	String [] tokens = new String[64];
64
	Map matcher = new HashMap();
64
	Map matcher = new HashMap();
65
	long irritant;
65
	for (int group = 0; group < IrritantSet.GROUP_MAX; group++) {
66
	String token;
66
		for (int i = 0; i < 29; i++) {
67
	for (int i = 0; i < 64; i++) {
67
			int irritant = (group << IrritantSet.GROUP_SHIFT) + (1 << i);
68
		if ((token = tokens[i] = CompilerOptions.warningTokenFromIrritant(irritant = 1L << i)) != null) {
68
			String token = CompilerOptions.warningTokenFromIrritant(irritant);
69
			matcher.put(token, token);
69
			if (token != null) {
70
			assertTrue((irritant & CompilerOptions.warningTokenToIrritants(token)) != 0);
70
				matcher.put(token, token);
71
				assertTrue(CompilerOptions.warningTokenToIrritants(token) != null);
72
			}
71
		}
73
		}
72
	}
74
	}
73
	String [] allTokens = CompilerOptions.warningTokens;
75
	String [] allTokens = CompilerOptions.warningTokens;
(-)model/org/eclipse/jdt/core/CorrectionEngine.java (-1 / +1 lines)
Lines 460-466 Link Here
460
	 * @since 3.1
460
	 * @since 3.1
461
	 */
461
	 */
462
	public static String getWarningToken(int problemID){
462
	public static String getWarningToken(int problemID){
463
		long irritant = ProblemReporter.getIrritant(problemID);
463
		int irritant = ProblemReporter.getIrritant(problemID);
464
		if (irritant != 0) {
464
		if (irritant != 0) {
465
			return CompilerOptions.warningTokenFromIrritant(irritant);
465
			return CompilerOptions.warningTokenFromIrritant(irritant);
466
		}
466
		}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java (-12 / +14 lines)
Lines 15-20 Link Here
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
17
import org.eclipse.jdt.internal.compiler.impl.Constant;
17
import org.eclipse.jdt.internal.compiler.impl.Constant;
18
import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
18
import org.eclipse.jdt.internal.compiler.lookup.*;
19
import org.eclipse.jdt.internal.compiler.lookup.*;
19
20
20
/**
21
/**
Lines 177-183 Link Here
177
	}
178
	}
178
179
179
	public void recordSuppressWarnings(Scope scope, int startSuppresss, int endSuppress, boolean isSuppressingWarnings) {
180
	public void recordSuppressWarnings(Scope scope, int startSuppresss, int endSuppress, boolean isSuppressingWarnings) {
180
		long suppressWarningIrritants = 0;
181
		IrritantSet suppressWarningIrritants = null;
181
		MemberValuePair[] pairs = memberValuePairs();
182
		MemberValuePair[] pairs = memberValuePairs();
182
		pairLoop: for (int i = 0, length = pairs.length; i < length; i++) {
183
		pairLoop: for (int i = 0, length = pairs.length; i < length; i++) {
183
			MemberValuePair pair = pairs[i];
184
			MemberValuePair pair = pairs[i];
Lines 190-201 Link Here
190
						for (int j = 0, initsLength = inits.length; j < initsLength; j++) {
191
						for (int j = 0, initsLength = inits.length; j < initsLength; j++) {
191
							Constant cst = inits[j].constant;
192
							Constant cst = inits[j].constant;
192
							if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
193
							if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
193
								long irritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
194
								IrritantSet irritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
194
								if (irritants != 0) {
195
								if (irritants != null) {
195
									if ((suppressWarningIrritants & irritants) == irritants) {
196
									if (suppressWarningIrritants == null) {
196
										scope.problemReporter().unusedWarningToken(inits[j]);
197
										suppressWarningIrritants = new IrritantSet(irritants);
197
									} else {
198
									} else if (suppressWarningIrritants.set(irritants) == null) {
198
										suppressWarningIrritants |= irritants;
199
											scope.problemReporter().unusedWarningToken(inits[j]);
199
									}
200
									}
200
								} else {
201
								} else {
201
									scope.problemReporter().unhandledWarningToken(inits[j]);
202
									scope.problemReporter().unhandledWarningToken(inits[j]);
Lines 206-214 Link Here
206
				} else {
207
				} else {
207
					Constant cst = value.constant;
208
					Constant cst = value.constant;
208
					if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
209
					if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
209
						long irritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
210
						IrritantSet irritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
210
						if (irritants != 0) {
211
						if (irritants != null) {
211
							suppressWarningIrritants |= irritants;
212
							suppressWarningIrritants = new IrritantSet(irritants);
213
							// TODO: should check for unused warning token against enclosing annotation as well ?
212
						} else {
214
						} else {
213
							scope.problemReporter().unhandledWarningToken(value);
215
							scope.problemReporter().unhandledWarningToken(value);
214
						}
216
						}
Lines 217-223 Link Here
217
				break pairLoop;
219
				break pairLoop;
218
			}
220
			}
219
		}
221
		}
220
		if (isSuppressingWarnings && suppressWarningIrritants != 0) {
222
		if (isSuppressingWarnings && suppressWarningIrritants != null) {
221
			scope.referenceCompilationUnit().recordSuppressWarnings(suppressWarningIrritants, this, startSuppresss, endSuppress);
223
			scope.referenceCompilationUnit().recordSuppressWarnings(suppressWarningIrritants, this, startSuppresss, endSuppress);
222
		}
224
		}
223
	}
225
	}
Lines 307-313 Link Here
307
		long tagBits = detectStandardAnnotation(scope, annotationType, valueAttribute);
309
		long tagBits = detectStandardAnnotation(scope, annotationType, valueAttribute);
308
310
309
		// record annotation positions in the compilation result
311
		// record annotation positions in the compilation result
310
		scope.referenceCompilationUnit().recordSuppressWarnings(CompilerOptions.NonExternalizedString, null, this.sourceStart, this.declarationSourceEnd);
312
		scope.referenceCompilationUnit().recordSuppressWarnings(IrritantSet.NLS, null, this.sourceStart, this.declarationSourceEnd);
311
		if (this.recipient != null) {
313
		if (this.recipient != null) {
312
			if (tagBits != 0) {
314
			if (tagBits != 0) {
313
				// tag bits onto recipient
315
				// tag bits onto recipient
(-)compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-23 / +28 lines)
Lines 21-26 Link Here
21
import org.eclipse.jdt.internal.compiler.CompilationResult;
21
import org.eclipse.jdt.internal.compiler.CompilationResult;
22
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
22
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
23
import org.eclipse.jdt.internal.compiler.impl.Constant;
23
import org.eclipse.jdt.internal.compiler.impl.Constant;
24
import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
24
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
25
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
25
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
26
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
26
import org.eclipse.jdt.internal.compiler.lookup.ImportBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.ImportBinding;
Lines 72-78 Link Here
72
	private int stringLiteralsPtr;
73
	private int stringLiteralsPtr;
73
	private HashSetOfInt stringLiteralsStart;
74
	private HashSetOfInt stringLiteralsStart;
74
75
75
	long[] suppressWarningIrritants;  // irritant for suppressed warnings
76
	IrritantSet[] suppressWarningIrritants;  // irritant for suppressed warnings
76
	Annotation[] suppressWarningAnnotations;
77
	Annotation[] suppressWarningAnnotations;
77
	long[] suppressWarningScopePositions; // (start << 32) + end
78
	long[] suppressWarningScopePositions; // (start << 32) + end
78
	int suppressWarningsCount;
79
	int suppressWarningsCount;
Lines 210-216 Link Here
210
		int removed = 0;
211
		int removed = 0;
211
		CategorizedProblem[] problems = this.compilationResult.problems;
212
		CategorizedProblem[] problems = this.compilationResult.problems;
212
		int problemCount = this.compilationResult.problemCount;
213
		int problemCount = this.compilationResult.problemCount;
213
		long[] foundIrritants = new long[this.suppressWarningsCount];
214
		IrritantSet[] foundIrritants = new IrritantSet[this.suppressWarningsCount];
214
		CompilerOptions options = this.scope.compilerOptions();
215
		CompilerOptions options = this.scope.compilerOptions();
215
		boolean hasErrors = false;
216
		boolean hasErrors = false;
216
		nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) {
217
		nextProblem: for (int iProblem = 0, length = problemCount; iProblem < length; iProblem++) {
Lines 225-245 Link Here
225
			}
226
			}
226
			int start = problem.getSourceStart();
227
			int start = problem.getSourceStart();
227
			int end = problem.getSourceEnd();
228
			int end = problem.getSourceEnd();
228
			long irritant = ProblemReporter.getIrritant(problemID);
229
			int irritant = ProblemReporter.getIrritant(problemID);
229
			nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
230
			nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
230
				long position = this.suppressWarningScopePositions[iSuppress];
231
				long position = this.suppressWarningScopePositions[iSuppress];
231
				int startSuppress = (int) (position >>> 32);
232
				int startSuppress = (int) (position >>> 32);
232
				int endSuppress = (int) position;
233
				int endSuppress = (int) position;
233
				if (start < startSuppress) continue nextSuppress;
234
				if (start < startSuppress) continue nextSuppress;
234
				if (end > endSuppress) continue nextSuppress;
235
				if (end > endSuppress) continue nextSuppress;
235
				if ((irritant & this.suppressWarningIrritants[iSuppress]) == 0)
236
				if (!this.suppressWarningIrritants[iSuppress].isSet(irritant))
236
					continue nextSuppress;
237
					continue nextSuppress;
237
				// discard suppressed warning
238
				// discard suppressed warning
238
				removed++;
239
				removed++;
239
				problems[iProblem] = null;
240
				problems[iProblem] = null;
240
				if (this.compilationResult.problemsMap != null) this.compilationResult.problemsMap.remove(problem);
241
				if (this.compilationResult.problemsMap != null) this.compilationResult.problemsMap.remove(problem);
241
				if (this.compilationResult.firstErrors != null) this.compilationResult.firstErrors.remove(problem);
242
				if (this.compilationResult.firstErrors != null) this.compilationResult.firstErrors.remove(problem);
242
				foundIrritants[iSuppress] |= irritant;
243
				if (foundIrritants[iSuppress] == null){
244
					foundIrritants[iSuppress] = new IrritantSet(irritant);
245
				} else {
246
					foundIrritants[iSuppress].set(irritant);
247
				}
243
				continue nextProblem;
248
				continue nextProblem;
244
			}
249
			}
245
		}
250
		}
Lines 265-272 Link Here
265
				for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
270
				for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) {
266
					Annotation annotation = this.suppressWarningAnnotations[iSuppress];
271
					Annotation annotation = this.suppressWarningAnnotations[iSuppress];
267
					if (annotation == null) continue; // implicit annotation
272
					if (annotation == null) continue; // implicit annotation
268
					long irritants = this.suppressWarningIrritants[iSuppress];
273
					IrritantSet irritants = this.suppressWarningIrritants[iSuppress];
269
					if (unusedWarningTokenIsWarning && ~irritants == 0) continue; // @SuppressWarnings("all") also suppresses unused warning token
274
					if (unusedWarningTokenIsWarning && irritants.areAllSet()) continue; // @SuppressWarnings("all") also suppresses unused warning token
270
					if (irritants != foundIrritants[iSuppress]) { // mismatch, some warning tokens were unused
275
					if (irritants != foundIrritants[iSuppress]) { // mismatch, some warning tokens were unused
271
						MemberValuePair[] pairs = annotation.memberValuePairs();
276
						MemberValuePair[] pairs = annotation.memberValuePairs();
272
						pairLoop: for (int iPair = 0, pairCount = pairs.length; iPair < pairCount; iPair++) {
277
						pairLoop: for (int iPair = 0, pairCount = pairs.length; iPair < pairCount; iPair++) {
Lines 280-290 Link Here
280
										for (int iToken = 0, tokenCount = inits.length; iToken < tokenCount; iToken++) {
285
										for (int iToken = 0, tokenCount = inits.length; iToken < tokenCount; iToken++) {
281
											Constant cst = inits[iToken].constant;
286
											Constant cst = inits[iToken].constant;
282
											if (cst != Constant.NotAConstant && cst.typeID() == TypeIds.T_JavaLangString) {
287
											if (cst != Constant.NotAConstant && cst.typeID() == TypeIds.T_JavaLangString) {
283
												long tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
288
												IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
284
												if (tokenIrritants != 0
289
												if (tokenIrritants != null
285
														&& ~tokenIrritants != 0 // no complaint against @SuppressWarnings("all")
290
														&& !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
286
														&& options.getSeverity(tokenIrritants) != ProblemSeverities.Ignore // if irritant is effectevely enabled
291
														&& options.isAnyEnabled(tokenIrritants) // if irritant is effectevely enabled
287
														&& (foundIrritants[iSuppress] & tokenIrritants) == 0) { // if irritant had no matching problem
292
														&& (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
288
													if (unusedWarningTokenIsWarning) {
293
													if (unusedWarningTokenIsWarning) {
289
														int start = value.sourceStart, end = value.sourceEnd;
294
														int start = value.sourceStart, end = value.sourceEnd;
290
														nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
295
														nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
Lines 293-299 Link Here
293
															int endSuppress = (int) position;
298
															int endSuppress = (int) position;
294
															if (start < startSuppress) continue nextSuppress;
299
															if (start < startSuppress) continue nextSuppress;
295
															if (end > endSuppress) continue nextSuppress;
300
															if (end > endSuppress) continue nextSuppress;
296
															if (~this.suppressWarningIrritants[jSuppress] == 0) break pairLoop; // suppress all?
301
															if (this.suppressWarningIrritants[jSuppress].areAllSet()) break pairLoop; // suppress all?
297
														}
302
														}
298
													}
303
													}
299
													this.scope.problemReporter().unusedWarningToken(inits[iToken]);
304
													this.scope.problemReporter().unusedWarningToken(inits[iToken]);
Lines 304-314 Link Here
304
								} else {
309
								} else {
305
									Constant cst = value.constant;
310
									Constant cst = value.constant;
306
									if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
311
									if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
307
										long tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
312
										IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
308
										if (tokenIrritants != 0
313
										if (tokenIrritants != null
309
												&& ~tokenIrritants != 0 // no complaint against @SuppressWarnings("all")
314
												&& !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
310
												&& options.getSeverity(tokenIrritants) != ProblemSeverities.Ignore // if irritant is effectevely enabled
315
												&& options.isAnyEnabled(tokenIrritants) // if irritant is effectevely enabled
311
												&& (foundIrritants[iSuppress] & tokenIrritants) == 0) { // if irritant had no matching problem
316
												&& (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
312
											if (unusedWarningTokenIsWarning) {
317
											if (unusedWarningTokenIsWarning) {
313
												int start = value.sourceStart, end = value.sourceEnd;
318
												int start = value.sourceStart, end = value.sourceEnd;
314
												nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
319
												nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
Lines 317-323 Link Here
317
													int endSuppress = (int) position;
322
													int endSuppress = (int) position;
318
													if (start < startSuppress) continue nextSuppress;
323
													if (start < startSuppress) continue nextSuppress;
319
													if (end > endSuppress) continue nextSuppress;
324
													if (end > endSuppress) continue nextSuppress;
320
													if (~this.suppressWarningIrritants[jSuppress] == 0) break pairLoop; // suppress all?
325
													if (this.suppressWarningIrritants[jSuppress].areAllSet()) break pairLoop; // suppress all?
321
												}
326
												}
322
											}
327
											}
323
											this.scope.problemReporter().unusedWarningToken(value);
328
											this.scope.problemReporter().unusedWarningToken(value);
Lines 468-484 Link Here
468
		this.stringLiterals[this.stringLiteralsPtr++] = literal;
473
		this.stringLiterals[this.stringLiteralsPtr++] = literal;
469
	}
474
	}
470
475
471
	public void recordSuppressWarnings(long irritant, Annotation annotation, int scopeStart, int scopeEnd) {
476
	public void recordSuppressWarnings(IrritantSet irritants, Annotation annotation, int scopeStart, int scopeEnd) {
472
		if (this.suppressWarningIrritants == null) {
477
		if (this.suppressWarningIrritants == null) {
473
			this.suppressWarningIrritants = new long[3];
478
			this.suppressWarningIrritants = new IrritantSet[3];
474
			this.suppressWarningAnnotations = new Annotation[3];
479
			this.suppressWarningAnnotations = new Annotation[3];
475
			this.suppressWarningScopePositions = new long[3];
480
			this.suppressWarningScopePositions = new long[3];
476
		} else if (this.suppressWarningIrritants.length == this.suppressWarningsCount) {
481
		} else if (this.suppressWarningIrritants.length == this.suppressWarningsCount) {
477
			System.arraycopy(this.suppressWarningIrritants, 0,this.suppressWarningIrritants = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
482
			System.arraycopy(this.suppressWarningIrritants, 0,this.suppressWarningIrritants = new IrritantSet[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
478
			System.arraycopy(this.suppressWarningAnnotations, 0,this.suppressWarningAnnotations = new Annotation[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
483
			System.arraycopy(this.suppressWarningAnnotations, 0,this.suppressWarningAnnotations = new Annotation[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
479
			System.arraycopy(this.suppressWarningScopePositions, 0,this.suppressWarningScopePositions = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
484
			System.arraycopy(this.suppressWarningScopePositions, 0,this.suppressWarningScopePositions = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
480
		}
485
		}
481
		this.suppressWarningIrritants[this.suppressWarningsCount] = irritant;
486
		this.suppressWarningIrritants[this.suppressWarningsCount] = irritants;
482
		this.suppressWarningAnnotations[this.suppressWarningsCount] = annotation;
487
		this.suppressWarningAnnotations[this.suppressWarningsCount] = annotation;
483
		this.suppressWarningScopePositions[this.suppressWarningsCount++] = ((long)scopeStart<<32) + scopeEnd;
488
		this.suppressWarningScopePositions[this.suppressWarningsCount++] = ((long)scopeStart<<32) + scopeEnd;
484
	}
489
	}
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-1 / +1 lines)
Lines 381-387 Link Here
381
381
382
		// find out an option name controlling a given problemID
382
		// find out an option name controlling a given problemID
383
		private String getProblemOptionKey(int problemID) {
383
		private String getProblemOptionKey(int problemID) {
384
			long irritant = ProblemReporter.getIrritant(problemID);
384
			int irritant = ProblemReporter.getIrritant(problemID);
385
			return CompilerOptions.optionKeyFromIrritant(irritant);
385
			return CompilerOptions.optionKeyFromIrritant(irritant);
386
		}
386
		}
387
387
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-99 / +80 lines)
Lines 45-51 Link Here
45
	return leadProblemId << 8 | elaborationVariant; // leadProblemId comes into the higher order bytes
45
	return leadProblemId << 8 | elaborationVariant; // leadProblemId comes into the higher order bytes
46
}
46
}
47
47
48
public static long getIrritant(int problemID) {
48
public static int getIrritant(int problemID) {
49
	switch(problemID){
49
	switch(problemID){
50
50
51
		case IProblem.MaskedCatch :
51
		case IProblem.MaskedCatch :
Lines 336-441 Link Here
336
		// fatal problems even if optional are all falling into same category (not irritant based)
336
		// fatal problems even if optional are all falling into same category (not irritant based)
337
		if ((severity & ProblemSeverities.Fatal) != 0)
337
		if ((severity & ProblemSeverities.Fatal) != 0)
338
			break categorizeOnIrritant;
338
			break categorizeOnIrritant;
339
		long irritant = getIrritant(problemID);
339
		int irritant = getIrritant(problemID);
340
		int irritantInt = (int) irritant;
340
		switch (irritant) {
341
		if (irritantInt == irritant) {
341
			case CompilerOptions.MethodWithConstructorName :
342
			switch (irritantInt) {
342
			case CompilerOptions.AccessEmulation :
343
				case (int)CompilerOptions.MethodWithConstructorName:
343
			case CompilerOptions.AssertUsedAsAnIdentifier :
344
				case (int)CompilerOptions.AccessEmulation:
344
			case CompilerOptions.NonStaticAccessToStatic :
345
				case (int)CompilerOptions.AssertUsedAsAnIdentifier:
345
			case CompilerOptions.UnqualifiedFieldAccess :
346
				case (int)CompilerOptions.NonStaticAccessToStatic:
346
			case CompilerOptions.UndocumentedEmptyBlock :
347
				case (int)CompilerOptions.UnqualifiedFieldAccess:
347
			case CompilerOptions.IndirectStaticAccess :
348
				case (int)CompilerOptions.UndocumentedEmptyBlock:
348
			case CompilerOptions.FinalParameterBound :
349
				case (int)CompilerOptions.IndirectStaticAccess:
349
			case CompilerOptions.EnumUsedAsAnIdentifier :
350
					return CategorizedProblem.CAT_CODE_STYLE;
350
			case CompilerOptions.AnnotationSuperInterface :
351
351
			case CompilerOptions.AutoBoxing :
352
				case (int)CompilerOptions.MaskedCatchBlock:
352
			case CompilerOptions.MissingOverrideAnnotation :
353
				case (int)CompilerOptions.NoImplicitStringConversion:
353
			case CompilerOptions.MissingDeprecatedAnnotation :
354
				case (int)CompilerOptions.NoEffectAssignment:
354
			case CompilerOptions.ParameterAssignment :				
355
				case (int)CompilerOptions.AccidentalBooleanAssign:
355
				return CategorizedProblem.CAT_CODE_STYLE;
356
				case (int)CompilerOptions.EmptyStatement:
356
357
				case (int)CompilerOptions.FinallyBlockNotCompleting:
357
			case CompilerOptions.MaskedCatchBlock :
358
					return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
358
			case CompilerOptions.NoImplicitStringConversion :
359
359
			case CompilerOptions.NoEffectAssignment :
360
				case (int)CompilerOptions.OverriddenPackageDefaultMethod:
360
			case CompilerOptions.AccidentalBooleanAssign :
361
				case (int)CompilerOptions.IncompatibleNonInheritedInterfaceMethod:
361
			case CompilerOptions.EmptyStatement :
362
				case (int)CompilerOptions.LocalVariableHiding:
362
			case CompilerOptions.FinallyBlockNotCompleting :
363
				case (int)CompilerOptions.FieldHiding:
363
			case CompilerOptions.MissingSerialVersion :
364
					return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT;
364
			case CompilerOptions.VarargsArgumentNeedCast :
365
365
			case CompilerOptions.NullReference :
366
				case (int)CompilerOptions.UnusedLocalVariable:
366
			case CompilerOptions.PotentialNullReference :
367
				case (int)CompilerOptions.UnusedArgument:
367
			case CompilerOptions.RedundantNullCheck :
368
				case (int)CompilerOptions.UnusedImport:
368
			case CompilerOptions.IncompleteEnumSwitch :
369
				case (int)CompilerOptions.UnusedPrivateMember:
369
			case CompilerOptions.FallthroughCase :
370
				case (int)CompilerOptions.UnusedDeclaredThrownException:
370
			case CompilerOptions.OverridingMethodWithoutSuperInvocation :
371
				case (int)CompilerOptions.UnnecessaryTypeCheck:
371
			case CompilerOptions.ComparingIdentical :
372
				case (int)CompilerOptions.UnnecessaryElse:
372
			case CompilerOptions.MissingSynchronizedModifierInInheritedMethod :				
373
					return CategorizedProblem.CAT_UNNECESSARY_CODE;
373
				return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
374
374
			
375
				case (int)CompilerOptions.UsingDeprecatedAPI:
375
			case CompilerOptions.OverriddenPackageDefaultMethod :
376
					return CategorizedProblem.CAT_DEPRECATION;
376
			case CompilerOptions.IncompatibleNonInheritedInterfaceMethod :
377
377
			case CompilerOptions.LocalVariableHiding :
378
				case (int)CompilerOptions.NonExternalizedString:
378
			case CompilerOptions.FieldHiding :
379
					return CategorizedProblem.CAT_NLS;
379
			case CompilerOptions.TypeHiding :
380
380
				return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT;		
381
				case (int)CompilerOptions.Task:
381
382
					return CategorizedProblem.CAT_UNSPECIFIED; // TODO may want to improve
382
			case CompilerOptions.UnusedLocalVariable :
383
383
			case CompilerOptions.UnusedArgument :
384
				case (int)CompilerOptions.MissingJavadocComments:
384
			case CompilerOptions.UnusedImport :
385
				case (int)CompilerOptions.MissingJavadocTags:
385
			case CompilerOptions.UnusedPrivateMember :
386
				case (int)CompilerOptions.InvalidJavadoc:
386
			case CompilerOptions.UnusedDeclaredThrownException :
387
				case (int)(CompilerOptions.InvalidJavadoc | CompilerOptions.UsingDeprecatedAPI):
387
			case CompilerOptions.UnnecessaryTypeCheck :
388
					return CategorizedProblem.CAT_JAVADOC;
388
			case CompilerOptions.UnnecessaryElse :
389
389
			case CompilerOptions.UnhandledWarningToken :
390
				case (int)CompilerOptions.UncheckedTypeOperation:
390
			case CompilerOptions.UnusedWarningToken :
391
					return CategorizedProblem.CAT_UNCHECKED_RAW;
391
			case CompilerOptions.UnusedLabel :
392
			case CompilerOptions.RedundantSuperinterface :				
393
				return CategorizedProblem.CAT_UNNECESSARY_CODE;					
392
394
393
				default:
395
			case CompilerOptions.UsingDeprecatedAPI :
394
					break categorizeOnIrritant;
396
				return CategorizedProblem.CAT_DEPRECATION;
395
			}
396
		} else {
397
			irritantInt = (int)(irritant >>> 32);
398
			switch (irritantInt) {
399
				case (int)(CompilerOptions.FinalParameterBound >>> 32):
400
				case (int)(CompilerOptions.EnumUsedAsAnIdentifier >>> 32):
401
				case (int)(CompilerOptions.AnnotationSuperInterface >>> 32):
402
				case (int)(CompilerOptions.AutoBoxing >>> 32):
403
				case (int)(CompilerOptions.MissingOverrideAnnotation >>> 32):
404
				case (int)(CompilerOptions.MissingDeprecatedAnnotation >>> 32):
405
				case (int)(CompilerOptions.ParameterAssignment >>> 32):
406
					return CategorizedProblem.CAT_CODE_STYLE;
407
408
				case (int)(CompilerOptions.MissingSerialVersion >>> 32):
409
				case (int)(CompilerOptions.VarargsArgumentNeedCast >>> 32):
410
				case (int)(CompilerOptions.NullReference >>> 32):
411
				case (int)(CompilerOptions.PotentialNullReference >>> 32):
412
				case (int)(CompilerOptions.RedundantNullCheck >>> 32):
413
				case (int)(CompilerOptions.IncompleteEnumSwitch >>> 32):
414
				case (int)(CompilerOptions.FallthroughCase >>> 32):
415
				case (int)(CompilerOptions.OverridingMethodWithoutSuperInvocation >>> 32):
416
				case (int)(CompilerOptions.ComparingIdentical >>> 32):
417
				case (int)(CompilerOptions.MissingSynchronizedModifierInInheritedMethod >> 32):
418
					return CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM;
419
420
				case (int)(CompilerOptions.TypeHiding >>> 32):
421
					return CategorizedProblem.CAT_NAME_SHADOWING_CONFLICT;
422
423
				case (int)(CompilerOptions.UnhandledWarningToken >>> 32):
424
				case (int)(CompilerOptions.UnusedWarningToken >>> 32):
425
				case (int)(CompilerOptions.UnusedLabel >>> 32):
426
				case (int)(CompilerOptions.RedundantSuperinterface >>> 32):
427
					return CategorizedProblem.CAT_UNNECESSARY_CODE;
428
429
				case (int)(CompilerOptions.ForbiddenReference >>> 32):
430
				case (int)(CompilerOptions.DiscouragedReference >>> 32):
431
					return CategorizedProblem.CAT_RESTRICTION;
432
397
433
				case (int)(CompilerOptions.RawTypeReference >>> 32):
398
			case CompilerOptions.NonExternalizedString :
434
					return CategorizedProblem.CAT_UNCHECKED_RAW;
399
				return CategorizedProblem.CAT_NLS;
435
400
436
				default:
401
			case CompilerOptions.Task :
437
					break categorizeOnIrritant;
402
				return CategorizedProblem.CAT_UNSPECIFIED; // TODO may want to improve
438
			}
403
			
404
			case CompilerOptions.MissingJavadocComments :
405
			case CompilerOptions.MissingJavadocTags :
406
			case CompilerOptions.InvalidJavadoc :
407
			case CompilerOptions.InvalidJavadoc|CompilerOptions.UsingDeprecatedAPI :
408
				return CategorizedProblem.CAT_JAVADOC;					
409
410
			case CompilerOptions.UncheckedTypeOperation :
411
			case CompilerOptions.RawTypeReference :
412
				return CategorizedProblem.CAT_UNCHECKED_RAW;				
413
			
414
			case CompilerOptions.ForbiddenReference :
415
			case CompilerOptions.DiscouragedReference :
416
				return CategorizedProblem.CAT_RESTRICTION;
417
			
418
			default:
419
				break categorizeOnIrritant;
439
		}
420
		}
440
	}
421
	}
441
	// categorize fatal problems per ID
422
	// categorize fatal problems per ID
Lines 1163-1169 Link Here
1163
			}
1144
			}
1164
			break;
1145
			break;
1165
	}
1146
	}
1166
	long irritant = getIrritant(problemID);
1147
	int irritant = getIrritant(problemID);
1167
	if (irritant != 0) {
1148
	if (irritant != 0) {
1168
		if ((problemID & IProblem.Javadoc) != 0 && !this.options.docCommentSupport)
1149
		if ((problemID & IProblem.Javadoc) != 0 && !this.options.docCommentSupport)
1169
			return ProblemSeverities.Ignore;
1150
			return ProblemSeverities.Ignore;
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-643 / +715 lines)
Lines 159-356 Link Here
159
159
160
	/**
160
	/**
161
	 * Bit mask for configurable problems (error/warning threshold)
161
	 * Bit mask for configurable problems (error/warning threshold)
162
	 * Note: bitmask assumes 3 highest bits to denote irritant group (to allow storing 8 groups of 29 bits each
162
	 */
163
	 */
163
	public static final long MethodWithConstructorName = ASTNode.Bit1;
164
	// group 0
164
	public static final long OverriddenPackageDefaultMethod = ASTNode.Bit2;
165
	public static final int MethodWithConstructorName = IrritantSet.GROUP0 | ASTNode.Bit1;
165
	public static final long UsingDeprecatedAPI = ASTNode.Bit3;
166
	public static final int OverriddenPackageDefaultMethod = IrritantSet.GROUP0 | ASTNode.Bit2;
166
	public static final long MaskedCatchBlock = ASTNode.Bit4;
167
	public static final int UsingDeprecatedAPI = IrritantSet.GROUP0 | ASTNode.Bit3;
167
	public static final long UnusedLocalVariable = ASTNode.Bit5;
168
	public static final int MaskedCatchBlock = IrritantSet.GROUP0 | ASTNode.Bit4;
168
	public static final long UnusedArgument = ASTNode.Bit6;
169
	public static final int UnusedLocalVariable = IrritantSet.GROUP0 | ASTNode.Bit5;
169
	public static final long NoImplicitStringConversion = ASTNode.Bit7;
170
	public static final int UnusedArgument = IrritantSet.GROUP0 | ASTNode.Bit6;
170
	public static final long AccessEmulation = ASTNode.Bit8;
171
	public static final int NoImplicitStringConversion = IrritantSet.GROUP0 | ASTNode.Bit7;
171
	public static final long NonExternalizedString = ASTNode.Bit9;
172
	public static final int AccessEmulation = IrritantSet.GROUP0 | ASTNode.Bit8;
172
	public static final long AssertUsedAsAnIdentifier = ASTNode.Bit10;
173
	public static final int NonExternalizedString = IrritantSet.GROUP0 | ASTNode.Bit9;
173
	public static final long UnusedImport = ASTNode.Bit11;
174
	public static final int AssertUsedAsAnIdentifier = IrritantSet.GROUP0 | ASTNode.Bit10;
174
	public static final long NonStaticAccessToStatic = ASTNode.Bit12;
175
	public static final int UnusedImport = IrritantSet.GROUP0 | ASTNode.Bit11;
175
	public static final long Task = ASTNode.Bit13;
176
	public static final int NonStaticAccessToStatic = IrritantSet.GROUP0 | ASTNode.Bit12;
176
	public static final long NoEffectAssignment = ASTNode.Bit14;
177
	public static final int Task = IrritantSet.GROUP0 | ASTNode.Bit13;
177
	public static final long IncompatibleNonInheritedInterfaceMethod = ASTNode.Bit15;
178
	public static final int NoEffectAssignment = IrritantSet.GROUP0 | ASTNode.Bit14;
178
	public static final long UnusedPrivateMember = ASTNode.Bit16;
179
	public static final int IncompatibleNonInheritedInterfaceMethod = IrritantSet.GROUP0 | ASTNode.Bit15;
179
	public static final long LocalVariableHiding = ASTNode.Bit17;
180
	public static final int UnusedPrivateMember = IrritantSet.GROUP0 | ASTNode.Bit16;
180
	public static final long FieldHiding = ASTNode.Bit18;
181
	public static final int LocalVariableHiding = IrritantSet.GROUP0 | ASTNode.Bit17;
181
	public static final long AccidentalBooleanAssign = ASTNode.Bit19;
182
	public static final int FieldHiding = IrritantSet.GROUP0 | ASTNode.Bit18;
182
	public static final long EmptyStatement = ASTNode.Bit20;
183
	public static final int AccidentalBooleanAssign = IrritantSet.GROUP0 | ASTNode.Bit19;
183
	public static final long MissingJavadocComments  = ASTNode.Bit21;
184
	public static final int EmptyStatement = IrritantSet.GROUP0 | ASTNode.Bit20;
184
	public static final long MissingJavadocTags = ASTNode.Bit22;
185
	public static final int MissingJavadocComments  = IrritantSet.GROUP0 | ASTNode.Bit21;
185
	public static final long UnqualifiedFieldAccess = ASTNode.Bit23;
186
	public static final int MissingJavadocTags = IrritantSet.GROUP0 | ASTNode.Bit22;
186
	public static final long UnusedDeclaredThrownException = ASTNode.Bit24;
187
	public static final int UnqualifiedFieldAccess = IrritantSet.GROUP0 | ASTNode.Bit23;
187
	public static final long FinallyBlockNotCompleting = ASTNode.Bit25;
188
	public static final int UnusedDeclaredThrownException = IrritantSet.GROUP0 | ASTNode.Bit24;
188
	public static final long InvalidJavadoc = ASTNode.Bit26;
189
	public static final int FinallyBlockNotCompleting = IrritantSet.GROUP0 | ASTNode.Bit25;
189
	public static final long UnnecessaryTypeCheck = ASTNode.Bit27;
190
	public static final int InvalidJavadoc = IrritantSet.GROUP0 | ASTNode.Bit26;
190
	public static final long UndocumentedEmptyBlock = ASTNode.Bit28;
191
	public static final int UnnecessaryTypeCheck = IrritantSet.GROUP0 | ASTNode.Bit27;
191
	public static final long IndirectStaticAccess = ASTNode.Bit29;
192
	public static final int UndocumentedEmptyBlock = IrritantSet.GROUP0 | ASTNode.Bit28;
192
	public static final long UnnecessaryElse  = ASTNode.Bit30;
193
	public static final int IndirectStaticAccess = IrritantSet.GROUP0 | ASTNode.Bit29;
193
	public static final long UncheckedTypeOperation = ASTNode.Bit31;
194
	
194
	public static final long FinalParameterBound = ASTNode.Bit32L;
195
	// group 1
195
	public static final long MissingSerialVersion = ASTNode.Bit33L;
196
	public static final int UnnecessaryElse  = IrritantSet.GROUP1 | ASTNode.Bit1;
196
	public static final long EnumUsedAsAnIdentifier = ASTNode.Bit34L;
197
	public static final int UncheckedTypeOperation = IrritantSet.GROUP1 | ASTNode.Bit2;
197
	public static final long ForbiddenReference = ASTNode.Bit35L;
198
	public static final int FinalParameterBound = IrritantSet.GROUP1 | ASTNode.Bit3;
198
	public static final long VarargsArgumentNeedCast = ASTNode.Bit36L;
199
	public static final int MissingSerialVersion = IrritantSet.GROUP1 | ASTNode.Bit4;
199
	public static final long NullReference = ASTNode.Bit37L;
200
	public static final int EnumUsedAsAnIdentifier = IrritantSet.GROUP1 | ASTNode.Bit5;
200
	public static final long AutoBoxing = ASTNode.Bit38L;
201
	public static final int ForbiddenReference = IrritantSet.GROUP1 | ASTNode.Bit6;
201
	public static final long AnnotationSuperInterface = ASTNode.Bit39L;
202
	public static final int VarargsArgumentNeedCast = IrritantSet.GROUP1 | ASTNode.Bit7;
202
	public static final long TypeHiding = ASTNode.Bit40L;
203
	public static final int NullReference = IrritantSet.GROUP1 | ASTNode.Bit8;
203
	public static final long MissingOverrideAnnotation = ASTNode.Bit41L;
204
	public static final int AutoBoxing = IrritantSet.GROUP1 | ASTNode.Bit9;
204
	public static final long IncompleteEnumSwitch = ASTNode.Bit42L;
205
	public static final int AnnotationSuperInterface = IrritantSet.GROUP1 | ASTNode.Bit10;
205
	public static final long MissingDeprecatedAnnotation = ASTNode.Bit43L;
206
	public static final int TypeHiding = IrritantSet.GROUP1 | ASTNode.Bit11;
206
	public static final long DiscouragedReference = ASTNode.Bit44L;
207
	public static final int MissingOverrideAnnotation = IrritantSet.GROUP1 | ASTNode.Bit12;
207
	public static final long UnhandledWarningToken = ASTNode.Bit45L;
208
	public static final int IncompleteEnumSwitch = IrritantSet.GROUP1 | ASTNode.Bit13;
208
	public static final long RawTypeReference = ASTNode.Bit46L;
209
	public static final int MissingDeprecatedAnnotation = IrritantSet.GROUP1 | ASTNode.Bit14;
209
	public static final long UnusedLabel = ASTNode.Bit47L;
210
	public static final int DiscouragedReference = IrritantSet.GROUP1 | ASTNode.Bit15;
210
	public static final long ParameterAssignment = ASTNode.Bit48L;
211
	public static final int UnhandledWarningToken = IrritantSet.GROUP1 | ASTNode.Bit16;
211
	public static final long FallthroughCase = ASTNode.Bit49L;
212
	public static final int RawTypeReference = IrritantSet.GROUP1 | ASTNode.Bit17;
212
	public static final long OverridingMethodWithoutSuperInvocation = ASTNode.Bit50L;
213
	public static final int UnusedLabel = IrritantSet.GROUP1 | ASTNode.Bit18;
213
	public static final long PotentialNullReference = ASTNode.Bit51L;
214
	public static final int ParameterAssignment = IrritantSet.GROUP1 | ASTNode.Bit19;
214
	public static final long RedundantNullCheck = ASTNode.Bit52L;
215
	public static final int FallthroughCase = IrritantSet.GROUP1 | ASTNode.Bit20;
215
	public static final long MissingJavadocTagDescription = ASTNode.Bit53L;
216
	public static final int OverridingMethodWithoutSuperInvocation = IrritantSet.GROUP1 | ASTNode.Bit21;
216
	public static final long UnusedTypeArguments = ASTNode.Bit54L;
217
	public static final int PotentialNullReference = IrritantSet.GROUP1 | ASTNode.Bit22;
217
	public static final long UnusedWarningToken = ASTNode.Bit55L;
218
	public static final int RedundantNullCheck = IrritantSet.GROUP1 | ASTNode.Bit23;
218
	public static final long RedundantSuperinterface = ASTNode.Bit56L;
219
	public static final int MissingJavadocTagDescription = IrritantSet.GROUP1 | ASTNode.Bit24;
219
	public static final long ComparingIdentical = ASTNode.Bit57L;
220
	public static final int UnusedTypeArguments = IrritantSet.GROUP1 | ASTNode.Bit25;
220
	public static final long MissingSynchronizedModifierInInheritedMethod= ASTNode.Bit58L;
221
	public static final int UnusedWarningToken = IrritantSet.GROUP1 | ASTNode.Bit26;
221
222
	public static final int RedundantSuperinterface = IrritantSet.GROUP1 | ASTNode.Bit27;
223
	public static final int ComparingIdentical = IrritantSet.GROUP1 | ASTNode.Bit28;
224
	public static final int MissingSynchronizedModifierInInheritedMethod= IrritantSet.GROUP1 | ASTNode.Bit29;
225
226
	// group 2
227
	// NEXT IRRITANT GOES HERE (group1 is complete already)
228
	//	public static final int FirstInGroup2 = IrritantSet.GROUP2 | ASTNode.Bit1;
229
	
222
	// Map: String optionKey --> Long irritant>
230
	// Map: String optionKey --> Long irritant>
223
	private static Map OptionToIrritants;
231
	private static Map OptionToIrritants;
224
232
225
	// Default severity level for handlers
233
	// Severity level for handlers
226
	public long errorThreshold = 0;
234
	/** 
235
	 * Defaults defined at {@lnk IrritantSet#COMPILER_DEFAULT_ERRORS} 
236
	 * @see #resetDefaults()
237
	 */
238
	protected IrritantSet errorThreshold;
239
	/** 
240
	 * Defaults defined at {@lnk IrritantSet#COMPILER_DEFAULT_WARNINGS}
241
	 * @see #resetDefaults()
242
	 */
243
	protected IrritantSet warningThreshold;
244
	
245
	/**
246
	 * Default settings are to be defined in {@lnk CompilerOptions#resetDefaults()}
247
	 */
248
	
249
	/** Classfile debug information, may contain source file name, line numbers, local variable tables, etc... */
250
	public int produceDebugAttributes; 
251
	/** Compliance level for the compiler, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */
252
	public long complianceLevel;
253
	/** Java source level, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */
254
	public long sourceLevel;
255
	/** VM target level, refers to a JDK version, e.g. {lnk {@link ClassFileConstants#JDK1_4} */
256
	public long targetJDK;
257
	/** Source encoding format */
258
	public String defaultEncoding;
259
	/** Compiler trace verbosity */
260
	public boolean verbose;
261
	/** Indicates whether reference info is desired */
262
	public boolean produceReferenceInfo;	
263
	/** Indicates if unused/optimizable local variables need to be preserved (debugging purpose) */
264
	public boolean preserveAllLocalVariables;
265
	/** Indicates whether literal expressions are inlined at parse-time or not */
266
	public boolean parseLiteralExpressionsAsConstants;
267
	/** Max problems per compilation unit */
268
	public int maxProblemsPerUnit;
269
	/** Tags used to recognize tasks in comments */
270
	public char[][] taskTags;
271
	/** Respective priorities of recognized task tags */
272
	public char[][] taskPriorites;
273
	/** Indicate whether tag detection is case sensitive or not */
274
	public boolean isTaskCaseSensitive;
275
	/** Specify whether deprecation inside deprecated code is to be reported */
276
	public boolean reportDeprecationInsideDeprecatedCode;
277
	/** Specify whether override of deprecated method is to be reported */
278
	public boolean reportDeprecationWhenOverridingDeprecatedMethod;
279
	/** Specify if should report unused parameter when implementing abstract method */
280
	public boolean reportUnusedParameterWhenImplementingAbstract;
281
	/** Specify if should report unused parameter when overriding concrete method */
282
	public boolean reportUnusedParameterWhenOverridingConcrete;
283
	/** Specify if should report documented unused parameter (in javadoc) */
284
	public boolean reportUnusedParameterIncludeDocCommentReference;
285
	/** Specify if should reported unused declared thrown exception when overriding method */
286
	public boolean reportUnusedDeclaredThrownExceptionWhenOverriding;
287
	/** Specify if should reported unused declared thrown exception when documented in javadoc */
288
	public boolean reportUnusedDeclaredThrownExceptionIncludeDocCommentReference;
289
	/** Specify if should reported unused declared thrown exception when Exception or Throwable */
290
	public boolean reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable;
291
	/** Specify whether should report constructor/setter method parameter hiding */
292
	public boolean reportSpecialParameterHidingField;
293
	/** Master flag controlling whether doc comment should be processed */
294
	public boolean docCommentSupport;
295
	/** Specify if invalid javadoc shall be reported */
296
	public boolean reportInvalidJavadocTags;
297
	/** Only report invalid javadoc above a given level of visibility of associated construct */
298
	public int reportInvalidJavadocTagsVisibility;
299
	/** Specify if deprecated javadoc ref is allowed */
300
	public boolean reportInvalidJavadocTagsDeprecatedRef;
301
	/** Specify if non visible javadoc ref is allowed */
302
	public boolean reportInvalidJavadocTagsNotVisibleRef;
303
	/** Specify when to report missing javadoc tag description */
304
	public String reportMissingJavadocTagDescription;
305
	/** Only report missing javadoc tags above a given level of visibility of associated construct */
306
	public int reportMissingJavadocTagsVisibility;
307
	/** Specify if need to flag missing javadoc tags for overriding method */
308
	public boolean reportMissingJavadocTagsOverriding;
309
	/** Only report missing javadoc comment above a given level of visibility of associated construct */
310
	public int reportMissingJavadocCommentsVisibility;
311
	/** Specify if need to flag missing javadoc comment for overriding method */
312
	public boolean reportMissingJavadocCommentsOverriding;
313
	/** Indicate whether the JSR bytecode should be inlined to avoid its presence in classfile */
314
	public boolean inlineJsrBytecode;
315
	/** Indicate if @SuppressWarning annotation are activated */
316
	public boolean suppressWarnings;
317
	/** Specify if should treat optional error as fatal or just like warning */
318
	public boolean treatOptionalErrorAsFatal;
319
	/** Specify if parser should perform structural recovery in methods */
320
	public boolean performMethodsFullRecovery;
321
	/** Specify if parser perform statements recovery */
322
	public boolean performStatementsRecovery;
323
	/** Control whether annotation processing is enabled */
324
	public boolean processAnnotations;
325
	/** Store annotations */
326
	public boolean storeAnnotations;
327
	/** Indicate if annotation processing generates classfiles */
328
	public boolean generateClassFiles;
329
330
331
	// keep in sync with warningTokenToIrritant and warningTokenFromIrritant
332
	public final static String[] warningTokens = {
333
		"all", //$NON-NLS-1$
334
		"boxing", //$NON-NLS-1$
335
		"cast", //$NON-NLS-1$
336
		"dep-ann", //$NON-NLS-1$
337
		"deprecation", //$NON-NLS-1$
338
		"fallthrough", //$NON-NLS-1$
339
		"finally", //$NON-NLS-1$
340
		"hiding", //$NON-NLS-1$
341
		"incomplete-switch", //$NON-NLS-1$
342
		"nls", //$NON-NLS-1$
343
		"null", //$NON-NLS-1$
344
		"restriction", //$NON-NLS-1$
345
		"serial", //$NON-NLS-1$
346
		"static-access", //$NON-NLS-1$
347
		"super", //$NON-NLS-1$
348
		"synthetic-access", //$NON-NLS-1$
349
		"unchecked", //$NON-NLS-1$
350
		"unqualified-field-access", //$NON-NLS-1$
351
		"unused", //$NON-NLS-1$
352
	};
227
353
228
	public long warningThreshold =
354
	/**
229
		MethodWithConstructorName
355
	 * Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by
230
		| UsingDeprecatedAPI
356
	 * other master options (e.g. javadoc, deprecation, etc.).
231
		| MaskedCatchBlock
357
	 * This information is intended for grouping purpose (several problems governed by a rule)
232
		| OverriddenPackageDefaultMethod
358
	 */
233
		| UnusedImport
359
	public static String optionKeyFromIrritant(int irritant) {
234
		| NonStaticAccessToStatic
360
		// keep in sync with warningTokens and warningTokenToIrritant
235
		| NoEffectAssignment
361
		switch (irritant) {
236
		| IncompatibleNonInheritedInterfaceMethod
362
			case MethodWithConstructorName :
237
		| NoImplicitStringConversion
363
				return OPTION_ReportMethodWithConstructorName;
238
		| FinallyBlockNotCompleting
364
			case OverriddenPackageDefaultMethod  :
239
		| AssertUsedAsAnIdentifier
365
				return OPTION_ReportOverridingPackageDefaultMethod;
240
		| EnumUsedAsAnIdentifier
366
			case UsingDeprecatedAPI :
241
		| UncheckedTypeOperation
367
			case (InvalidJavadoc | UsingDeprecatedAPI) :
242
		| RawTypeReference
368
				return OPTION_ReportDeprecation;
243
		| MissingSerialVersion
369
			case MaskedCatchBlock  :
244
		| VarargsArgumentNeedCast
370
				return OPTION_ReportHiddenCatchBlock;
245
		| ForbiddenReference
371
			case UnusedLocalVariable :
246
		| DiscouragedReference
372
				return OPTION_ReportUnusedLocal;
247
		| AnnotationSuperInterface
373
			case UnusedArgument :
248
		| TypeHiding
374
				return OPTION_ReportUnusedParameter;
249
		| FinalParameterBound
375
			case NoImplicitStringConversion :
250
		| UnhandledWarningToken
376
				return OPTION_ReportNoImplicitStringConversion;
251
		| UnusedLocalVariable
377
			case AccessEmulation :
252
		| UnusedPrivateMember
378
				return OPTION_ReportSyntheticAccessEmulation;
253
		| UnusedLabel
379
			case NonExternalizedString :
254
		| UnusedTypeArguments
380
				return OPTION_ReportNonExternalizedStringLiteral;
255
		| NullReference
381
			case AssertUsedAsAnIdentifier :
256
		| UnusedWarningToken
382
				return OPTION_ReportAssertIdentifier;
257
		| ComparingIdentical
383
			case UnusedImport :
258
		| MissingSynchronizedModifierInInheritedMethod;
384
				return OPTION_ReportUnusedImport;
259
385
			case NonStaticAccessToStatic :
260
	// By default only lines and source attributes are generated.
386
				return OPTION_ReportNonStaticAccessToStatic;
261
	public int produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
387
			case Task :
262
388
				return OPTION_TaskTags;
263
	public long complianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4
389
			case NoEffectAssignment :
264
	public long sourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default
390
				return OPTION_ReportNoEffectAssignment;
265
	public long targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2
391
			case IncompatibleNonInheritedInterfaceMethod :
266
392
				return OPTION_ReportIncompatibleNonInheritedInterfaceMethod;
267
	// source encoding format
393
			case UnusedPrivateMember :
268
	public String defaultEncoding = null; // will use the platform default encoding
394
				return OPTION_ReportUnusedPrivateMember;
269
395
			case LocalVariableHiding :
270
	// print what unit is being processed
396
				return OPTION_ReportLocalVariableHiding;
271
	public boolean verbose = Compiler.DEBUG;
397
			case FieldHiding :
272
398
				return OPTION_ReportFieldHiding;
273
	// indicates if reference info is desired
399
			case AccidentalBooleanAssign :
274
	public boolean produceReferenceInfo = false;
400
				return OPTION_ReportPossibleAccidentalBooleanAssignment;
275
401
			case EmptyStatement :
276
	// indicates if unused/optimizable local variables need to be preserved (debugging purpose)
402
				return OPTION_ReportEmptyStatement;
277
	public boolean preserveAllLocalVariables = false;
403
			case MissingJavadocComments  :
278
404
				return OPTION_ReportMissingJavadocComments;
279
	// indicates whether literal expressions are inlined at parse-time or not
405
			case MissingJavadocTags :
280
	public boolean parseLiteralExpressionsAsConstants = true;
406
				return OPTION_ReportMissingJavadocTags;
281
407
			case UnqualifiedFieldAccess :
282
	// max problems per compilation unit
408
				return OPTION_ReportUnqualifiedFieldAccess;
283
	public int maxProblemsPerUnit = 100; // no more than 100 problems per default
409
			case UnusedDeclaredThrownException :
284
410
				return OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding;
285
	// tags used to recognize tasks in comments
411
			case FinallyBlockNotCompleting :
286
	public char[][] taskTags = null;
412
				return OPTION_ReportFinallyBlockNotCompletingNormally;
287
	public char[][] taskPriorites = null;
413
			case InvalidJavadoc :
288
	public boolean isTaskCaseSensitive = true;
414
				return OPTION_ReportInvalidJavadoc;
289
415
			case UnnecessaryTypeCheck :
290
	// deprecation report
416
				return OPTION_ReportUnnecessaryTypeCheck;
291
	public boolean reportDeprecationInsideDeprecatedCode = false;
417
			case UndocumentedEmptyBlock :
292
	public boolean reportDeprecationWhenOverridingDeprecatedMethod = false;
418
				return OPTION_ReportUndocumentedEmptyBlock;
293
419
			case IndirectStaticAccess :
294
	// unused parameters report
420
				return OPTION_ReportIndirectStaticAccess;
295
	public boolean reportUnusedParameterWhenImplementingAbstract = false;
421
			case UnnecessaryElse  :
296
	public boolean reportUnusedParameterWhenOverridingConcrete = false;
422
				return OPTION_ReportUnnecessaryElse;
297
	public boolean reportUnusedParameterIncludeDocCommentReference = true;
423
			case UncheckedTypeOperation :
298
424
				return OPTION_ReportUncheckedTypeOperation;
299
	// unused declaration of thrown exception
425
			case FinalParameterBound :
300
	public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false;
426
				return OPTION_ReportFinalParameterBound;
301
	public boolean reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = true;
427
			case MissingSerialVersion :
302
	public boolean reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = true;
428
				return OPTION_ReportMissingSerialVersion ;
303
429
			case EnumUsedAsAnIdentifier :
304
	// constructor/setter parameter hiding
430
				return OPTION_ReportEnumIdentifier;
305
	public boolean reportSpecialParameterHidingField = false;
431
			case ForbiddenReference :
306
432
				return OPTION_ReportForbiddenReference;
307
	// check javadoc comments tags
433
			case VarargsArgumentNeedCast :
308
	public int reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic;
434
				return OPTION_ReportVarargsArgumentNeedCast;
309
	public boolean reportInvalidJavadocTags = false;
435
			case NullReference :
310
	public boolean reportInvalidJavadocTagsDeprecatedRef = false;
436
				return OPTION_ReportNullReference;
311
	public boolean reportInvalidJavadocTagsNotVisibleRef = false;
437
			case PotentialNullReference :
312
	public String reportMissingJavadocTagDescription = RETURN_TAG;
438
				return OPTION_ReportPotentialNullReference;
313
439
			case RedundantNullCheck :
314
	// check missing javadoc tags
440
				return OPTION_ReportRedundantNullCheck;
315
	public int reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic;
441
			case AutoBoxing :
316
	public boolean reportMissingJavadocTagsOverriding = false;
442
				return OPTION_ReportAutoboxing;
317
443
			case AnnotationSuperInterface :
318
	// check missing javadoc comments
444
				return OPTION_ReportAnnotationSuperInterface;
319
	public int reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic;
445
			case TypeHiding :
320
	public boolean reportMissingJavadocCommentsOverriding = false;
446
				return OPTION_ReportTypeParameterHiding;
321
447
			case MissingOverrideAnnotation :
322
	// JSR bytecode inlining
448
				return OPTION_ReportMissingOverrideAnnotation;
323
	public boolean inlineJsrBytecode = false;
449
			case IncompleteEnumSwitch :
324
450
				return OPTION_ReportIncompleteEnumSwitch;
325
	// javadoc comment support
451
			case MissingDeprecatedAnnotation :
326
	public boolean docCommentSupport = false;
452
				return OPTION_ReportMissingDeprecatedAnnotation;
327
453
			case DiscouragedReference :
328
	// suppress warning annotation
454
				return OPTION_ReportDiscouragedReference;
329
	public boolean suppressWarnings = true;
455
			case UnhandledWarningToken :
330
456
				return OPTION_ReportUnhandledWarningToken;
331
	// treat optional error as fatal or just like warning?
457
			case RawTypeReference :
332
	public boolean treatOptionalErrorAsFatal = true;
458
				return OPTION_ReportRawTypeReference;
333
459
			case UnusedLabel :
334
	// parser perform statements recovery
460
				return OPTION_ReportUnusedLabel;
335
	public boolean performMethodsFullRecovery = true;
461
			case ParameterAssignment :
336
462
				return OPTION_ReportParameterAssignment;
337
	// parser perform statements recovery
463
			case FallthroughCase :
338
	public boolean performStatementsRecovery = true;
464
				return OPTION_ReportFallthroughCase;
465
			case OverridingMethodWithoutSuperInvocation :
466
				return OPTION_ReportOverridingMethodWithoutSuperInvocation;
467
			case MissingJavadocTagDescription :
468
				return OPTION_ReportMissingJavadocTagDescription;
469
			case UnusedTypeArguments :
470
				return OPTION_ReportUnusedTypeArgumentsForMethodInvocation;
471
			case UnusedWarningToken :
472
				return OPTION_ReportUnusedWarningToken;
473
			case RedundantSuperinterface :
474
				return OPTION_ReportRedundantSuperinterface;
475
			case ComparingIdentical :
476
				return OPTION_ReportComparingIdentical;
477
			case MissingSynchronizedModifierInInheritedMethod :
478
				return OPTION_ReportMissingSynchronizedOnInheritedMethod;
479
		}
480
		return null;
481
	}
339
482
340
	// store annotations
483
	public static long optionKeyToIrritant(String optionName) {
341
	public boolean storeAnnotations = false;
484
		if (OptionToIrritants == null) {
485
			int group = 0;
486
			for (int g = 0; g < 8; g++) {
487
				group <<= 1;
488
				int index = 0;
489
				for (int i = 0; i < 30; i++) {
490
					index <<= 1;
491
					int irritant = (group<<IrritantSet.GROUP_SHIFT)+index;
492
					String optionKey = optionKeyFromIrritant(irritant);
493
					if (optionKey == null) continue;
494
					OptionToIrritants.put(optionKey, new Integer(irritant));
495
				}
496
				
497
			}
498
		}
499
		Long irritant = (Long)OptionToIrritants.get(optionName);
500
		return irritant == null ? 0 : irritant.longValue();
501
	}
342
502
343
	// annotation processing
503
	public static String versionFromJdkLevel(long jdkLevel) {
344
	public boolean generateClassFiles = true;
504
		switch ((int)(jdkLevel>>16)) {
505
			case ClassFileConstants.MAJOR_VERSION_1_1 :
506
				if (jdkLevel == ClassFileConstants.JDK1_1)
507
					return VERSION_1_1;
508
				break;
509
			case ClassFileConstants.MAJOR_VERSION_1_2 :
510
				if (jdkLevel == ClassFileConstants.JDK1_2)
511
					return VERSION_1_2;
512
				break;
513
			case ClassFileConstants.MAJOR_VERSION_1_3 :
514
				if (jdkLevel == ClassFileConstants.JDK1_3)
515
					return VERSION_1_3;
516
				break;
517
			case ClassFileConstants.MAJOR_VERSION_1_4 :
518
				if (jdkLevel == ClassFileConstants.JDK1_4)
519
					return VERSION_1_4;
520
				break;
521
			case ClassFileConstants.MAJOR_VERSION_1_5 :
522
				if (jdkLevel == ClassFileConstants.JDK1_5)
523
					return VERSION_1_5;
524
				break;
525
			case ClassFileConstants.MAJOR_VERSION_1_6 :
526
				if (jdkLevel == ClassFileConstants.JDK1_6)
527
					return VERSION_1_6;
528
				break;
529
			case ClassFileConstants.MAJOR_VERSION_1_7 :
530
				if (jdkLevel == ClassFileConstants.JDK1_7)
531
					return VERSION_1_7;
532
				break;
533
		}
534
		return Util.EMPTY_STRING; // unknown version
535
	}
345
536
346
	// Enable annotation processing by default only in batch mode
537
	public static long versionToJdkLevel(Object versionID) {
347
	public boolean processAnnotations = false;
538
		if (versionID instanceof String) {
539
			String version = (String) versionID;
540
			// verification is optimized for all versions with same length and same "1." prefix
541
			if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') {
542
				switch (version.charAt(2)) {
543
					case '1':
544
						return ClassFileConstants.JDK1_1;
545
					case '2':
546
						return ClassFileConstants.JDK1_2;
547
					case '3':
548
						return ClassFileConstants.JDK1_3;
549
					case '4':
550
						return ClassFileConstants.JDK1_4;
551
					case '5':
552
						return ClassFileConstants.JDK1_5;
553
					case '6':
554
						return ClassFileConstants.JDK1_6;
555
					case '7':
556
						return ClassFileConstants.JDK1_7;
557
					default:
558
						return 0; // unknown
559
				}
560
			}
561
			if (VERSION_JSR14.equals(versionID)) {
562
				return ClassFileConstants.JDK1_4;
563
			}
564
			if (VERSION_CLDC1_1.equals(versionID)) {
565
				return ClassFileConstants.CLDC_1_1;
566
			}
567
		}
568
		return 0; // unknown
569
	}
570
571
	/**
572
	 * Return all warning option names for use as keys in compiler options maps.
573
	 * @return all warning option names
574
	 * TODO (maxime) revise for ensuring completeness
575
	 */
576
	public static String[] warningOptionNames() {
577
		String[] result = {
578
			OPTION_ReportAnnotationSuperInterface,
579
			OPTION_ReportAssertIdentifier,
580
			OPTION_ReportAutoboxing,
581
			OPTION_ReportDeprecation,
582
			OPTION_ReportDiscouragedReference,
583
			OPTION_ReportEmptyStatement,
584
			OPTION_ReportEnumIdentifier,
585
			OPTION_ReportFallthroughCase,
586
			OPTION_ReportFieldHiding,
587
			OPTION_ReportFinalParameterBound,
588
			OPTION_ReportFinallyBlockNotCompletingNormally,
589
			OPTION_ReportForbiddenReference,
590
			OPTION_ReportHiddenCatchBlock,
591
			OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
592
			OPTION_ReportIncompleteEnumSwitch,
593
			OPTION_ReportIndirectStaticAccess,
594
			OPTION_ReportInvalidJavadoc,
595
			OPTION_ReportLocalVariableHiding,
596
			OPTION_ReportMethodWithConstructorName,
597
			OPTION_ReportMissingDeprecatedAnnotation,
598
			OPTION_ReportMissingJavadocComments,
599
			OPTION_ReportMissingJavadocTagDescription,
600
			OPTION_ReportMissingJavadocTags,
601
			OPTION_ReportMissingOverrideAnnotation,
602
			OPTION_ReportMissingSerialVersion,
603
			OPTION_ReportNoEffectAssignment,
604
			OPTION_ReportNoImplicitStringConversion,
605
			OPTION_ReportNonExternalizedStringLiteral,
606
			OPTION_ReportNonStaticAccessToStatic,
607
			OPTION_ReportNullReference,
608
			OPTION_ReportPotentialNullReference,
609
			OPTION_ReportRedundantNullCheck,
610
			OPTION_ReportRedundantSuperinterface,
611
			OPTION_ReportOverridingPackageDefaultMethod,
612
			OPTION_ReportParameterAssignment,
613
			OPTION_ReportPossibleAccidentalBooleanAssignment,
614
			OPTION_ReportSyntheticAccessEmulation,
615
			OPTION_ReportTypeParameterHiding,
616
			OPTION_ReportUncheckedTypeOperation,
617
			OPTION_ReportUndocumentedEmptyBlock,
618
			OPTION_ReportUnnecessaryElse,
619
			OPTION_ReportUnnecessaryTypeCheck,
620
			OPTION_ReportUnqualifiedFieldAccess,
621
			OPTION_ReportUnusedDeclaredThrownException,
622
			OPTION_ReportUnusedImport,
623
			OPTION_ReportUnusedLocal,
624
			OPTION_ReportUnusedParameter,
625
			OPTION_ReportUnusedPrivateMember,
626
			OPTION_ReportVarargsArgumentNeedCast,
627
			OPTION_ReportUnhandledWarningToken,
628
			OPTION_ReportUnusedWarningToken,
629
			OPTION_ReportOverridingMethodWithoutSuperInvocation,
630
			OPTION_ReportUnusedTypeArgumentsForMethodInvocation,
631
		};
632
		return result;
633
	}
634
635
	/**
636
	 * For suppressable warnings
637
	 */
638
	public static String warningTokenFromIrritant(int irritant) {
639
		// keep in sync with warningTokens and warningTokenToIrritant
640
		switch (irritant) {
641
			case (InvalidJavadoc | UsingDeprecatedAPI) :
642
			case UsingDeprecatedAPI :
643
				return "deprecation"; //$NON-NLS-1$
644
			case FinallyBlockNotCompleting :
645
				return "finally"; //$NON-NLS-1$
646
			case FieldHiding :
647
			case LocalVariableHiding :
648
			case MaskedCatchBlock :
649
				return "hiding"; //$NON-NLS-1$
650
			case NonExternalizedString :
651
				return "nls"; //$NON-NLS-1$
652
			case UnnecessaryTypeCheck :
653
				return "cast"; //$NON-NLS-1$
654
			case UnusedLocalVariable :
655
			case UnusedArgument :
656
			case UnusedImport :
657
			case UnusedPrivateMember :
658
			case UnusedDeclaredThrownException :
659
				return "unused"; //$NON-NLS-1$
660
			case IndirectStaticAccess :
661
			case NonStaticAccessToStatic :
662
				return "static-access"; //$NON-NLS-1$
663
			case AccessEmulation :
664
				return "synthetic-access"; //$NON-NLS-1$
665
			case UnqualifiedFieldAccess :
666
				return "unqualified-field-access"; //$NON-NLS-1$
667
			case UncheckedTypeOperation :
668
				return "unchecked"; //$NON-NLS-1$
669
			case MissingSerialVersion :
670
				return "serial"; //$NON-NLS-1$
671
			case AutoBoxing :
672
				return "boxing"; //$NON-NLS-1$
673
			case TypeHiding :
674
				return "hiding"; //$NON-NLS-1$
675
			case IncompleteEnumSwitch :
676
				return "incomplete-switch"; //$NON-NLS-1$
677
			case MissingDeprecatedAnnotation :
678
				return "dep-ann"; //$NON-NLS-1$
679
			case RawTypeReference :
680
				return "unchecked"; //$NON-NLS-1$
681
			case UnusedLabel :
682
			case UnusedTypeArguments :
683
			case RedundantSuperinterface :
684
				return "unused"; //$NON-NLS-1$
685
			case DiscouragedReference :
686
			case ForbiddenReference :
687
				return "restriction"; //$NON-NLS-1$
688
			case NullReference :
689
			case PotentialNullReference :
690
			case RedundantNullCheck :
691
				return "null"; //$NON-NLS-1$
692
			case FallthroughCase :
693
				return "fallthrough"; //$NON-NLS-1$
694
			case OverridingMethodWithoutSuperInvocation :
695
				return "super"; //$NON-NLS-1$
696
		}
697
		return null;
698
	}
699
700
	public static IrritantSet warningTokenToIrritants(String warningToken) {
701
		// keep in sync with warningTokens and warningTokenFromIrritant
702
		if (warningToken == null || warningToken.length() == 0) return null;
703
		switch (warningToken.charAt(0)) {
704
			case 'a' :
705
				if ("all".equals(warningToken)) //$NON-NLS-1$
706
					return IrritantSet.ALL;
707
				break;
708
			case 'b' :
709
				if ("boxing".equals(warningToken)) //$NON-NLS-1$
710
					return IrritantSet.BOXING;
711
				break;
712
			case 'c' :
713
				if ("cast".equals(warningToken)) //$NON-NLS-1$
714
					return IrritantSet.CAST;
715
				break;
716
			case 'd' :
717
				if ("deprecation".equals(warningToken)) //$NON-NLS-1$
718
					return IrritantSet.DEPRECATION;
719
				if ("dep-ann".equals(warningToken)) //$NON-NLS-1$
720
					return IrritantSet.DEP_ANN;
721
				break;
722
			case 'f' :
723
				if ("fallthrough".equals(warningToken)) //$NON-NLS-1$
724
					return IrritantSet.FALLTHROUGH;
725
				if ("finally".equals(warningToken)) //$NON-NLS-1$
726
					return IrritantSet.FINALLY;
727
				break;
728
			case 'h' :
729
				if ("hiding".equals(warningToken)) //$NON-NLS-1$
730
					return IrritantSet.HIDING;
731
			case 'i' :
732
				if ("incomplete-switch".equals(warningToken)) //$NON-NLS-1$
733
					return IrritantSet.INCOMPLETE_SWITCH;
734
				break;
735
			case 'n' :
736
				if ("nls".equals(warningToken)) //$NON-NLS-1$
737
					return IrritantSet.NLS;
738
				if ("null".equals(warningToken)) //$NON-NLS-1$
739
					return IrritantSet.NULL;
740
				break;
741
			case 'r' :
742
				if ("restriction".equals(warningToken)) //$NON-NLS-1$
743
					return IrritantSet.RESTRICTION;
744
				break;
745
			case 's' :
746
				if ("serial".equals(warningToken)) //$NON-NLS-1$
747
					return IrritantSet.SERIAL;
748
				if ("static-access".equals(warningToken)) //$NON-NLS-1$
749
					return IrritantSet.STATIC_ACCESS;
750
				if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$
751
					return IrritantSet.SYNTHETIC_ACCESS;
752
				if ("super".equals(warningToken)) { //$NON-NLS-1$
753
					return IrritantSet.SUPER;
754
				}
755
				break;
756
			case 'u' :
757
				if ("unused".equals(warningToken)) //$NON-NLS-1$
758
					return IrritantSet.UNUSED;
759
				if ("unchecked".equals(warningToken)) //$NON-NLS-1$
760
					return IrritantSet.UNCHECKED;
761
				if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$
762
					return IrritantSet.UNQUALIFIED_FIELD_ACCESS;
763
				break;
764
		}
765
		return null;
766
	}
348
767
349
	/**
768
	/**
350
	 * Initializing the compiler options with defaults
769
	 * Initializing the compiler options with defaults
351
	 */
770
	 */
352
	public CompilerOptions(){
771
	public CompilerOptions(){
353
		// use default options
772
		this(null); // use default options
354
	}
773
	}
355
774
356
	/**
775
	/**
Lines 358-366 Link Here
358
	 * @param settings
777
	 * @param settings
359
	 */
778
	 */
360
	public CompilerOptions(Map settings){
779
	public CompilerOptions(Map settings){
361
780
		resetDefaults();
362
		if (settings == null) return;
781
		if (settings != null) {
363
		set(settings);
782
			set(settings);
783
		}
364
	}
784
	}
365
785
366
	/**
786
	/**
Lines 371-376 Link Here
371
		this.parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants;
791
		this.parseLiteralExpressionsAsConstants = parseLiteralExpressionsAsConstants;
372
	}
792
	}
373
793
794
	
374
	public Map getMap() {
795
	public Map getMap() {
375
		Map optionsMap = new HashMap(30);
796
		Map optionsMap = new HashMap(30);
376
		optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? GENERATE : DO_NOT_GENERATE);
797
		optionsMap.put(OPTION_LocalVariableAttribute, (this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? GENERATE : DO_NOT_GENERATE);
Lines 471-648 Link Here
471
		return optionsMap;
892
		return optionsMap;
472
	}
893
	}
473
894
474
	/**
895
	public int getSeverity(int irritant) {
475
	 * Return the most specific option key controlling this irritant. Note that in some case, some irritant is controlled by
896
		if (this.errorThreshold.isSet(irritant)) {
476
	 * other master options (e.g. javadoc, deprecation, etc.).
897
			if ((irritant & (IrritantSet.GROUP_MASK | UnusedWarningToken)) == UnusedWarningToken) {
477
	 * This information is intended for grouping purpose (several problems governed by a rule)
478
	 */
479
	public static String optionKeyFromIrritant(long irritant) {
480
		// keep in sync with warningTokens and warningTokenToIrritant
481
		int irritantInt = (int) irritant;
482
		if (irritantInt == irritant) {
483
			switch (irritantInt) {
484
				case (int) MethodWithConstructorName :
485
					return OPTION_ReportMethodWithConstructorName;
486
				case (int) OverriddenPackageDefaultMethod  :
487
					return OPTION_ReportOverridingPackageDefaultMethod;
488
				case (int) UsingDeprecatedAPI :
489
				case (int) (InvalidJavadoc | UsingDeprecatedAPI) :
490
					return OPTION_ReportDeprecation;
491
				case (int) MaskedCatchBlock  :
492
					return OPTION_ReportHiddenCatchBlock;
493
				case (int) UnusedLocalVariable :
494
					return OPTION_ReportUnusedLocal;
495
				case (int) UnusedArgument :
496
					return OPTION_ReportUnusedParameter;
497
				case (int) NoImplicitStringConversion :
498
					return OPTION_ReportNoImplicitStringConversion;
499
				case (int) AccessEmulation :
500
					return OPTION_ReportSyntheticAccessEmulation;
501
				case (int) NonExternalizedString :
502
					return OPTION_ReportNonExternalizedStringLiteral;
503
				case (int) AssertUsedAsAnIdentifier :
504
					return OPTION_ReportAssertIdentifier;
505
				case (int) UnusedImport :
506
					return OPTION_ReportUnusedImport;
507
				case (int) NonStaticAccessToStatic :
508
					return OPTION_ReportNonStaticAccessToStatic;
509
				case (int) Task :
510
					return OPTION_TaskTags;
511
				case (int) NoEffectAssignment :
512
					return OPTION_ReportNoEffectAssignment;
513
				case (int) IncompatibleNonInheritedInterfaceMethod :
514
					return OPTION_ReportIncompatibleNonInheritedInterfaceMethod;
515
				case (int) UnusedPrivateMember :
516
					return OPTION_ReportUnusedPrivateMember;
517
				case (int) LocalVariableHiding :
518
					return OPTION_ReportLocalVariableHiding;
519
				case (int) FieldHiding :
520
					return OPTION_ReportFieldHiding;
521
				case (int) AccidentalBooleanAssign :
522
					return OPTION_ReportPossibleAccidentalBooleanAssignment;
523
				case (int) EmptyStatement :
524
					return OPTION_ReportEmptyStatement;
525
				case (int) MissingJavadocComments  :
526
					return OPTION_ReportMissingJavadocComments;
527
				case (int) MissingJavadocTags :
528
					return OPTION_ReportMissingJavadocTags;
529
				case (int) UnqualifiedFieldAccess :
530
					return OPTION_ReportUnqualifiedFieldAccess;
531
				case (int) UnusedDeclaredThrownException :
532
					return OPTION_ReportUnusedDeclaredThrownExceptionWhenOverriding;
533
				case (int) FinallyBlockNotCompleting :
534
					return OPTION_ReportFinallyBlockNotCompletingNormally;
535
				case (int) InvalidJavadoc :
536
					return OPTION_ReportInvalidJavadoc;
537
				case (int) UnnecessaryTypeCheck :
538
					return OPTION_ReportUnnecessaryTypeCheck;
539
				case (int) UndocumentedEmptyBlock :
540
					return OPTION_ReportUndocumentedEmptyBlock;
541
				case (int) IndirectStaticAccess :
542
					return OPTION_ReportIndirectStaticAccess;
543
				case (int) UnnecessaryElse  :
544
					return OPTION_ReportUnnecessaryElse;
545
				case (int) UncheckedTypeOperation :
546
					return OPTION_ReportUncheckedTypeOperation;
547
				case (int) FinalParameterBound :
548
					return OPTION_ReportFinalParameterBound;
549
			}
550
		} else {
551
			irritantInt = (int)(irritant >>> 32);
552
			switch (irritantInt) {
553
				case (int)(MissingSerialVersion >>> 32) :
554
					return OPTION_ReportMissingSerialVersion ;
555
				case (int)(EnumUsedAsAnIdentifier >>> 32) :
556
					return OPTION_ReportEnumIdentifier;
557
				case (int)(ForbiddenReference >>> 32) :
558
					return OPTION_ReportForbiddenReference;
559
				case (int)(VarargsArgumentNeedCast >>> 32) :
560
					return OPTION_ReportVarargsArgumentNeedCast;
561
				case (int)(NullReference >>> 32) :
562
					return OPTION_ReportNullReference;
563
				case (int)(PotentialNullReference >>> 32) :
564
					return OPTION_ReportPotentialNullReference;
565
				case (int)(RedundantNullCheck >>> 32) :
566
					return OPTION_ReportRedundantNullCheck;
567
				case (int)(AutoBoxing >>> 32) :
568
					return OPTION_ReportAutoboxing;
569
				case (int)(AnnotationSuperInterface >>> 32) :
570
					return OPTION_ReportAnnotationSuperInterface;
571
				case (int)(TypeHiding >>> 32) :
572
					return OPTION_ReportTypeParameterHiding;
573
				case (int)(MissingOverrideAnnotation >>> 32) :
574
					return OPTION_ReportMissingOverrideAnnotation;
575
				case (int)(IncompleteEnumSwitch >>> 32) :
576
					return OPTION_ReportIncompleteEnumSwitch;
577
				case (int)(MissingDeprecatedAnnotation >>> 32) :
578
					return OPTION_ReportMissingDeprecatedAnnotation;
579
				case (int)(DiscouragedReference >>> 32) :
580
					return OPTION_ReportDiscouragedReference;
581
				case (int)(UnhandledWarningToken >>> 32) :
582
					return OPTION_ReportUnhandledWarningToken;
583
				case (int)(RawTypeReference >>> 32) :
584
					return OPTION_ReportRawTypeReference;
585
				case (int)(UnusedLabel >>> 32) :
586
					return OPTION_ReportUnusedLabel;
587
				case (int)(ParameterAssignment>>> 32) :
588
					return OPTION_ReportParameterAssignment;
589
				case (int)(FallthroughCase >>> 32) :
590
					return OPTION_ReportFallthroughCase;
591
				case (int)(OverridingMethodWithoutSuperInvocation >>> 32) :
592
					return OPTION_ReportOverridingMethodWithoutSuperInvocation;
593
				case (int)(MissingJavadocTagDescription >>> 32):
594
					return OPTION_ReportMissingJavadocTagDescription;
595
				case (int)(UnusedTypeArguments >>> 32):
596
					return OPTION_ReportUnusedTypeArgumentsForMethodInvocation;
597
				case (int)(UnusedWarningToken >>> 32) :
598
					return OPTION_ReportUnusedWarningToken;
599
				case (int)(RedundantSuperinterface >>> 32) :
600
					return OPTION_ReportRedundantSuperinterface;
601
				case (int)(ComparingIdentical >>> 32) :
602
					return OPTION_ReportComparingIdentical;
603
				case (int)(MissingSynchronizedModifierInInheritedMethod >>> 32) :
604
					return OPTION_ReportMissingSynchronizedOnInheritedMethod;
605
			}
606
		}
607
		return null;
608
	}
609
610
	public static long optionKeyToIrritant(String optionName) {
611
		if (OptionToIrritants == null) {
612
			long irritant = 0;
613
			for (int i = 0; i < 64; i++) {
614
				irritant <<= 1;
615
				String optionKey = optionKeyFromIrritant(irritant);
616
				if (optionKey == null) continue;
617
				OptionToIrritants.put(optionKey, new Long(irritant));
618
			}
619
		}
620
		Long irritant = (Long)OptionToIrritants.get(optionName);
621
		return irritant == null ? 0 : irritant.longValue();
622
	}
623
624
	public int getSeverity(long irritant) {
625
		if((this.errorThreshold & irritant) != 0) {
626
			if ((irritant & UnusedWarningToken) != 0) {
627
				return ProblemSeverities.Error | ProblemSeverities.Optional; // cannot be treated as fatal - codegen already occurred
898
				return ProblemSeverities.Error | ProblemSeverities.Optional; // cannot be treated as fatal - codegen already occurred
628
			}
899
			}
629
			return this.treatOptionalErrorAsFatal
900
			return this.treatOptionalErrorAsFatal
630
				? ProblemSeverities.Error | ProblemSeverities.Optional | ProblemSeverities.Fatal
901
				? ProblemSeverities.Error | ProblemSeverities.Optional | ProblemSeverities.Fatal
631
				: ProblemSeverities.Error | ProblemSeverities.Optional;
902
				: ProblemSeverities.Error | ProblemSeverities.Optional;
632
		}
903
		}
633
		if((this.warningThreshold & irritant) != 0)
904
		if (this.warningThreshold.isSet(irritant)) {
634
			return ProblemSeverities.Warning | ProblemSeverities.Optional;
905
			return ProblemSeverities.Warning | ProblemSeverities.Optional;
906
		}
635
		return ProblemSeverities.Ignore;
907
		return ProblemSeverities.Ignore;
636
	}
908
	}
637
909
638
	public String getSeverityString(long irritant) {
910
	public String getSeverityString(int irritant) {
639
		if((this.errorThreshold & irritant) != 0)
911
		if(this.errorThreshold.isSet(irritant))
640
			return ERROR;
912
			return ERROR;
641
		if((this.warningThreshold & irritant) != 0)
913
		if(this.warningThreshold.isSet(irritant))
642
			return WARNING;
914
			return WARNING;
643
		return IGNORE;
915
		return IGNORE;
644
	}
916
	}
645
646
	public String getVisibilityString(int level) {
917
	public String getVisibilityString(int level) {
647
		switch (level & ExtraCompilerModifiers.AccVisibilityMASK) {
918
		switch (level & ExtraCompilerModifiers.AccVisibilityMASK) {
648
			case ClassFileConstants.AccPublic:
919
			case ClassFileConstants.AccPublic:
Lines 656-661 Link Here
656
		}
927
		}
657
	}
928
	}
658
929
930
	public boolean isAnyEnabled(IrritantSet irritants) {
931
		return this.warningThreshold.isAnySet(irritants) || this.errorThreshold.isAnySet(irritants);
932
	}
933
934
	protected void resetDefaults() {
935
		// problem default severities defined on IrritantSet
936
		this.errorThreshold = new IrritantSet(IrritantSet.COMPILER_DEFAULT_ERRORS);
937
		this.warningThreshold = new IrritantSet(IrritantSet.COMPILER_DEFAULT_WARNINGS);
938
		
939
		// by default only lines and source attributes are generated.
940
		this.produceDebugAttributes = ClassFileConstants.ATTR_SOURCE | ClassFileConstants.ATTR_LINES;
941
		this.complianceLevel = ClassFileConstants.JDK1_4; // by default be compliant with 1.4
942
		this.sourceLevel = ClassFileConstants.JDK1_3; //1.3 source behavior by default
943
		this.targetJDK = ClassFileConstants.JDK1_2; // default generates for JVM1.2
944
945
		this.defaultEncoding = null; // will use the platform default encoding
946
947
		// print what unit is being processed
948
		this.verbose = Compiler.DEBUG;
949
950
		this.produceReferenceInfo = false; // no reference info by default
951
952
		// indicates if unused/optimizable local variables need to be preserved (debugging purpose)
953
		this.preserveAllLocalVariables = false;
954
955
		// indicates whether literal expressions are inlined at parse-time or not
956
		this.parseLiteralExpressionsAsConstants = true;
957
958
		// max problems per compilation unit
959
		this.maxProblemsPerUnit = 100; // no more than 100 problems per default
960
961
		// tags used to recognize tasks in comments
962
		this.taskTags = null;
963
		this.taskPriorites = null;
964
		this.isTaskCaseSensitive = true;
965
966
		// deprecation report
967
		this.reportDeprecationInsideDeprecatedCode = false;
968
		this.reportDeprecationWhenOverridingDeprecatedMethod = false;
969
		
970
		// unused parameters report
971
		this.reportUnusedParameterWhenImplementingAbstract = false;
972
		this.reportUnusedParameterWhenOverridingConcrete = false;
973
		this.reportUnusedParameterIncludeDocCommentReference = true;
974
		
975
		// unused declaration of thrown exception
976
		this.reportUnusedDeclaredThrownExceptionWhenOverriding = false;
977
		this.reportUnusedDeclaredThrownExceptionIncludeDocCommentReference = true;
978
		this.reportUnusedDeclaredThrownExceptionExemptExceptionAndThrowable = true;
979
		
980
		// constructor/setter parameter hiding
981
		this.reportSpecialParameterHidingField = false;
982
983
		// check javadoc comments tags
984
		this.reportInvalidJavadocTagsVisibility = ClassFileConstants.AccPublic;
985
		this.reportInvalidJavadocTags = false;
986
		this.reportInvalidJavadocTagsDeprecatedRef = false;
987
		this.reportInvalidJavadocTagsNotVisibleRef = false;
988
		this.reportMissingJavadocTagDescription = RETURN_TAG;
989
		
990
		// check missing javadoc tags
991
		this.reportMissingJavadocTagsVisibility = ClassFileConstants.AccPublic;
992
		this.reportMissingJavadocTagsOverriding = false;
993
994
		// check missing javadoc comments
995
		this.reportMissingJavadocCommentsVisibility = ClassFileConstants.AccPublic;
996
		this.reportMissingJavadocCommentsOverriding = false;
997
		
998
		// JSR bytecode inlining
999
		this.inlineJsrBytecode = false;
1000
1001
		// javadoc comment support
1002
		this.docCommentSupport = false;
1003
1004
		// suppress warning annotation
1005
		this.suppressWarnings = true;
1006
1007
		// treat optional error as fatal or just like warning?
1008
		this.treatOptionalErrorAsFatal = true;
1009
1010
		// parser perform statements recovery
1011
		this.performMethodsFullRecovery = true;
1012
1013
		// parser perform statements recovery
1014
		this.performStatementsRecovery = true;
1015
1016
		// store annotations
1017
		this.storeAnnotations = false;
1018
1019
		// annotation processing
1020
		this.generateClassFiles = true;
1021
1022
		// enable annotation processing by default only in batch mode
1023
		this.processAnnotations = false;
1024
	}
1025
659
	public void set(Map optionsMap) {
1026
	public void set(Map optionsMap) {
660
		Object optionValue;
1027
		Object optionValue;
661
		if ((optionValue = optionsMap.get(OPTION_LocalVariableAttribute)) != null) {
1028
		if ((optionValue = optionsMap.get(OPTION_LocalVariableAttribute)) != null) {
Lines 999-1007 Link Here
999
			}
1366
			}
1000
		}
1367
		}
1001
	}
1368
	}
1002
1003
	public String toString() {
1369
	public String toString() {
1004
1005
		StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$
1370
		StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$
1006
		buf.append("\n\t- local variables debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1371
		buf.append("\n\t- local variables debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_VARS) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1007
		buf.append("\n\t- line number debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_LINES) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1372
		buf.append("\n\t- line number debug attributes: ").append((this.produceDebugAttributes & ClassFileConstants.ATTR_LINES) != 0 ? "ON" : " OFF"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Lines 1092-1401 Link Here
1092
		buf.append("\n\t- missing synchronized on inherited method: ").append(getSeverityString(MissingSynchronizedModifierInInheritedMethod)); //$NON-NLS-1$
1457
		buf.append("\n\t- missing synchronized on inherited method: ").append(getSeverityString(MissingSynchronizedModifierInInheritedMethod)); //$NON-NLS-1$
1093
		return buf.toString();
1458
		return buf.toString();
1094
	}
1459
	}
1095
1460
	
1096
	void updateSeverity(long irritant, Object severityString) {
1461
	protected void updateSeverity(int irritant, Object severityString) {
1097
		if (ERROR.equals(severityString)) {
1462
		if (ERROR.equals(severityString)) {
1098
			this.errorThreshold |= irritant;
1463
			this.errorThreshold.set(irritant);
1099
			this.warningThreshold &= ~irritant;
1464
			this.warningThreshold.clear(irritant);
1100
		} else if (WARNING.equals(severityString)) {
1465
		} else if (WARNING.equals(severityString)) {
1101
			this.errorThreshold &= ~irritant;
1466
			this.errorThreshold.clear(irritant);
1102
			this.warningThreshold |= irritant;
1467
			this.warningThreshold.set(irritant);
1103
		} else if (IGNORE.equals(severityString)) {
1468
		} else if (IGNORE.equals(severityString)) {
1104
			this.errorThreshold &= ~irritant;
1469
			this.errorThreshold.clear(irritant);
1105
			this.warningThreshold &= ~irritant;
1470
			this.warningThreshold.clear(irritant);
1106
		}
1107
	}
1108
	public static long versionToJdkLevel(Object versionID) {
1109
		if (versionID instanceof String) {
1110
			String version = (String) versionID;
1111
			// verification is optimized for all versions with same length and same "1." prefix
1112
			if (version.length() == 3 && version.charAt(0) == '1' && version.charAt(1) == '.') {
1113
				switch (version.charAt(2)) {
1114
					case '1':
1115
						return ClassFileConstants.JDK1_1;
1116
					case '2':
1117
						return ClassFileConstants.JDK1_2;
1118
					case '3':
1119
						return ClassFileConstants.JDK1_3;
1120
					case '4':
1121
						return ClassFileConstants.JDK1_4;
1122
					case '5':
1123
						return ClassFileConstants.JDK1_5;
1124
					case '6':
1125
						return ClassFileConstants.JDK1_6;
1126
					case '7':
1127
						return ClassFileConstants.JDK1_7;
1128
					default:
1129
						return 0; // unknown
1130
				}
1131
			}
1132
			if (VERSION_JSR14.equals(versionID)) {
1133
				return ClassFileConstants.JDK1_4;
1134
			}
1135
			if (VERSION_CLDC1_1.equals(versionID)) {
1136
				return ClassFileConstants.CLDC_1_1;
1137
			}
1138
		}
1139
		return 0; // unknown
1140
	}
1141
1142
	public static String versionFromJdkLevel(long jdkLevel) {
1143
		switch ((int)(jdkLevel>>16)) {
1144
			case ClassFileConstants.MAJOR_VERSION_1_1 :
1145
				if (jdkLevel == ClassFileConstants.JDK1_1)
1146
					return VERSION_1_1;
1147
				break;
1148
			case ClassFileConstants.MAJOR_VERSION_1_2 :
1149
				if (jdkLevel == ClassFileConstants.JDK1_2)
1150
					return VERSION_1_2;
1151
				break;
1152
			case ClassFileConstants.MAJOR_VERSION_1_3 :
1153
				if (jdkLevel == ClassFileConstants.JDK1_3)
1154
					return VERSION_1_3;
1155
				break;
1156
			case ClassFileConstants.MAJOR_VERSION_1_4 :
1157
				if (jdkLevel == ClassFileConstants.JDK1_4)
1158
					return VERSION_1_4;
1159
				break;
1160
			case ClassFileConstants.MAJOR_VERSION_1_5 :
1161
				if (jdkLevel == ClassFileConstants.JDK1_5)
1162
					return VERSION_1_5;
1163
				break;
1164
			case ClassFileConstants.MAJOR_VERSION_1_6 :
1165
				if (jdkLevel == ClassFileConstants.JDK1_6)
1166
					return VERSION_1_6;
1167
				break;
1168
			case ClassFileConstants.MAJOR_VERSION_1_7 :
1169
				if (jdkLevel == ClassFileConstants.JDK1_7)
1170
					return VERSION_1_7;
1171
				break;
1172
		}
1173
		return Util.EMPTY_STRING; // unknown version
1174
	}
1175
1176
	/**
1177
	 * Return all warning option names for use as keys in compiler options maps.
1178
	 * @return all warning option names
1179
	 * TODO (maxime) revise for ensuring completeness
1180
	 */
1181
	public static String[] warningOptionNames() {
1182
		String[] result = {
1183
			OPTION_ReportAnnotationSuperInterface,
1184
			OPTION_ReportAssertIdentifier,
1185
			OPTION_ReportAutoboxing,
1186
			OPTION_ReportDeprecation,
1187
			OPTION_ReportDiscouragedReference,
1188
			OPTION_ReportEmptyStatement,
1189
			OPTION_ReportEnumIdentifier,
1190
			OPTION_ReportFallthroughCase,
1191
			OPTION_ReportFieldHiding,
1192
			OPTION_ReportFinalParameterBound,
1193
			OPTION_ReportFinallyBlockNotCompletingNormally,
1194
			OPTION_ReportForbiddenReference,
1195
			OPTION_ReportHiddenCatchBlock,
1196
			OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
1197
			OPTION_ReportIncompleteEnumSwitch,
1198
			OPTION_ReportIndirectStaticAccess,
1199
			OPTION_ReportInvalidJavadoc,
1200
			OPTION_ReportLocalVariableHiding,
1201
			OPTION_ReportMethodWithConstructorName,
1202
			OPTION_ReportMissingDeprecatedAnnotation,
1203
			OPTION_ReportMissingJavadocComments,
1204
			OPTION_ReportMissingJavadocTagDescription,
1205
			OPTION_ReportMissingJavadocTags,
1206
			OPTION_ReportMissingOverrideAnnotation,
1207
			OPTION_ReportMissingSerialVersion,
1208
			OPTION_ReportNoEffectAssignment,
1209
			OPTION_ReportNoImplicitStringConversion,
1210
			OPTION_ReportNonExternalizedStringLiteral,
1211
			OPTION_ReportNonStaticAccessToStatic,
1212
			OPTION_ReportNullReference,
1213
			OPTION_ReportPotentialNullReference,
1214
			OPTION_ReportRedundantNullCheck,
1215
			OPTION_ReportRedundantSuperinterface,
1216
			OPTION_ReportOverridingPackageDefaultMethod,
1217
			OPTION_ReportParameterAssignment,
1218
			OPTION_ReportPossibleAccidentalBooleanAssignment,
1219
			OPTION_ReportSyntheticAccessEmulation,
1220
			OPTION_ReportTypeParameterHiding,
1221
			OPTION_ReportUncheckedTypeOperation,
1222
			OPTION_ReportUndocumentedEmptyBlock,
1223
			OPTION_ReportUnnecessaryElse,
1224
			OPTION_ReportUnnecessaryTypeCheck,
1225
			OPTION_ReportUnqualifiedFieldAccess,
1226
			OPTION_ReportUnusedDeclaredThrownException,
1227
			OPTION_ReportUnusedImport,
1228
			OPTION_ReportUnusedLocal,
1229
			OPTION_ReportUnusedParameter,
1230
			OPTION_ReportUnusedPrivateMember,
1231
			OPTION_ReportVarargsArgumentNeedCast,
1232
			OPTION_ReportUnhandledWarningToken,
1233
			OPTION_ReportUnusedWarningToken,
1234
			OPTION_ReportOverridingMethodWithoutSuperInvocation,
1235
			OPTION_ReportUnusedTypeArgumentsForMethodInvocation,
1236
		};
1237
		return result;
1238
	}
1239
1240
	/**
1241
	 * For suppressable warnings
1242
	 */
1243
	public static String warningTokenFromIrritant(long irritant) {
1244
		// keep in sync with warningTokens and warningTokenToIrritant
1245
		int irritantInt = (int) irritant;
1246
		if (irritantInt == irritant) {
1247
			switch (irritantInt) {
1248
				case (int) (InvalidJavadoc | UsingDeprecatedAPI) :
1249
				case (int) UsingDeprecatedAPI :
1250
					return "deprecation"; //$NON-NLS-1$
1251
				case (int) FinallyBlockNotCompleting :
1252
					return "finally"; //$NON-NLS-1$
1253
				case (int) FieldHiding :
1254
				case (int) LocalVariableHiding :
1255
				case (int) MaskedCatchBlock :
1256
					return "hiding"; //$NON-NLS-1$
1257
				case (int) NonExternalizedString :
1258
					return "nls"; //$NON-NLS-1$
1259
				case (int) UnnecessaryTypeCheck :
1260
					return "cast"; //$NON-NLS-1$
1261
				case (int) UnusedLocalVariable :
1262
				case (int) UnusedArgument :
1263
				case (int) UnusedImport :
1264
				case (int) UnusedPrivateMember:
1265
				case (int) UnusedDeclaredThrownException:
1266
					return "unused"; //$NON-NLS-1$
1267
				case (int) IndirectStaticAccess :
1268
				case (int) NonStaticAccessToStatic :
1269
					return "static-access"; //$NON-NLS-1$
1270
				case (int) AccessEmulation :
1271
					return "synthetic-access"; //$NON-NLS-1$
1272
				case (int) UnqualifiedFieldAccess :
1273
					return "unqualified-field-access"; //$NON-NLS-1$
1274
				case (int) UncheckedTypeOperation :
1275
					return "unchecked"; //$NON-NLS-1$
1276
			}
1277
		} else {
1278
			irritantInt = (int)(irritant >>> 32);
1279
			switch (irritantInt) {
1280
				case (int)(MissingSerialVersion >>> 32) :
1281
					return "serial"; //$NON-NLS-1$
1282
				case (int)(AutoBoxing >>> 32) :
1283
					return "boxing"; //$NON-NLS-1$
1284
				case (int)(TypeHiding >>> 32) :
1285
					return "hiding"; //$NON-NLS-1$
1286
				case (int)(IncompleteEnumSwitch >>> 32) :
1287
					return "incomplete-switch"; //$NON-NLS-1$
1288
				case (int)(MissingDeprecatedAnnotation >>> 32) :
1289
					return "dep-ann"; //$NON-NLS-1$
1290
				case (int)(RawTypeReference >>> 32):
1291
					return "unchecked"; //$NON-NLS-1$
1292
				case (int) (UnusedLabel >>> 32):
1293
				case (int) (UnusedTypeArguments >>> 32) :
1294
				case (int) (RedundantSuperinterface >>> 32) :
1295
					return "unused"; //$NON-NLS-1$
1296
				case (int) (DiscouragedReference >>> 32) :
1297
				case (int) (ForbiddenReference >>> 32) :
1298
					return "restriction"; //$NON-NLS-1$
1299
				case (int) (NullReference >>> 32) :
1300
				case (int) (PotentialNullReference >>> 32) :
1301
				case (int) (RedundantNullCheck >>> 32) :
1302
					return "null"; //$NON-NLS-1$
1303
				case (int) (FallthroughCase >>> 32) :
1304
					return "fallthrough"; //$NON-NLS-1$
1305
				case (int) (OverridingMethodWithoutSuperInvocation >>> 32) :
1306
					return "super"; //$NON-NLS-1$
1307
			}
1308
		}
1309
		return null;
1310
	}
1311
	// keep in sync with warningTokenToIrritant and warningTokenFromIrritant
1312
	public final static String[] warningTokens = {
1313
		"all", //$NON-NLS-1$
1314
		"boxing", //$NON-NLS-1$
1315
		"cast", //$NON-NLS-1$
1316
		"dep-ann", //$NON-NLS-1$
1317
		"deprecation", //$NON-NLS-1$
1318
		"fallthrough", //$NON-NLS-1$
1319
		"finally", //$NON-NLS-1$
1320
		"hiding", //$NON-NLS-1$
1321
		"incomplete-switch", //$NON-NLS-1$
1322
		"nls", //$NON-NLS-1$
1323
		"null", //$NON-NLS-1$
1324
		"restriction", //$NON-NLS-1$
1325
		"serial", //$NON-NLS-1$
1326
		"static-access", //$NON-NLS-1$
1327
		"super", //$NON-NLS-1$
1328
		"synthetic-access", //$NON-NLS-1$
1329
		"unchecked", //$NON-NLS-1$
1330
		"unqualified-field-access", //$NON-NLS-1$
1331
		"unused", //$NON-NLS-1$
1332
	};
1333
	
1334
	public static long warningTokenToIrritants(String warningToken) {
1335
		// keep in sync with warningTokens and warningTokenFromIrritant
1336
		if (warningToken == null || warningToken.length() == 0) return 0;
1337
		switch (warningToken.charAt(0)) {
1338
			case 'a' :
1339
				if ("all".equals(warningToken)) //$NON-NLS-1$
1340
					return 0xFFFFFFFFFFFFFFFFl; // suppress all warnings
1341
				break;
1342
			case 'b' :
1343
				if ("boxing".equals(warningToken)) //$NON-NLS-1$
1344
					return AutoBoxing;
1345
				break;
1346
			case 'c' :
1347
				if ("cast".equals(warningToken)) //$NON-NLS-1$
1348
					return UnnecessaryTypeCheck;
1349
				break;
1350
			case 'd' :
1351
				if ("deprecation".equals(warningToken)) //$NON-NLS-1$
1352
					return UsingDeprecatedAPI;
1353
				if ("dep-ann".equals(warningToken)) //$NON-NLS-1$
1354
					return MissingDeprecatedAnnotation;
1355
				break;
1356
			case 'f' :
1357
				if ("fallthrough".equals(warningToken)) //$NON-NLS-1$
1358
					return FallthroughCase;
1359
				if ("finally".equals(warningToken)) //$NON-NLS-1$
1360
					return FinallyBlockNotCompleting;
1361
				break;
1362
			case 'h' :
1363
				if ("hiding".equals(warningToken)) //$NON-NLS-1$
1364
					return FieldHiding | LocalVariableHiding | MaskedCatchBlock | TypeHiding;
1365
			case 'i' :
1366
				if ("incomplete-switch".equals(warningToken)) //$NON-NLS-1$
1367
					return IncompleteEnumSwitch;
1368
				break;
1369
			case 'n' :
1370
				if ("nls".equals(warningToken)) //$NON-NLS-1$
1371
					return NonExternalizedString;
1372
				if ("null".equals(warningToken)) //$NON-NLS-1$
1373
					return NullReference | PotentialNullReference | RedundantNullCheck;
1374
				break;
1375
			case 'r' :
1376
				if ("restriction".equals(warningToken)) //$NON-NLS-1$
1377
					return DiscouragedReference | ForbiddenReference;
1378
				break;
1379
			case 's' :
1380
				if ("serial".equals(warningToken)) //$NON-NLS-1$
1381
					return MissingSerialVersion;
1382
				if ("static-access".equals(warningToken)) //$NON-NLS-1$
1383
					return IndirectStaticAccess | NonStaticAccessToStatic;
1384
				if ("synthetic-access".equals(warningToken)) //$NON-NLS-1$
1385
					return AccessEmulation;
1386
				if ("super".equals(warningToken)) { //$NON-NLS-1$
1387
					return OverridingMethodWithoutSuperInvocation;
1388
				}
1389
				break;
1390
			case 'u' :
1391
				if ("unused".equals(warningToken)) //$NON-NLS-1$
1392
					return UnusedLocalVariable | UnusedArgument | UnusedPrivateMember | UnusedDeclaredThrownException | UnusedLabel | UnusedImport | UnusedTypeArguments | RedundantSuperinterface;
1393
				if ("unchecked".equals(warningToken)) //$NON-NLS-1$
1394
					return UncheckedTypeOperation | RawTypeReference;
1395
				if ("unqualified-field-access".equals(warningToken)) //$NON-NLS-1$
1396
					return UnqualifiedFieldAccess;
1397
				break;
1398
		}
1471
		}
1399
		return 0;
1400
	}
1472
	}
1401
}
1473
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java (+255 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.jdt.internal.compiler.impl;
13
14
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
15
16
/**
17
 * Represent a set of irritant flags. Irritants are organized in up to 8 group
18
 * of 29, allowing for a maximum of 232 distinct irritants.
19
 */
20
public class IrritantSet {
21
22
	// Reserve two high bits for selecting the right bit pattern
23
	public final static int GROUP_MASK = ASTNode.Bit32 | ASTNode.Bit31 | ASTNode.Bit30;
24
	public final static int GROUP_SHIFT = 29;
25
	public final static int GROUP_MAX = 3; // can be increased up to 8
26
27
	// Group prefix for irritants
28
	public final static int GROUP0 = 0 << GROUP_SHIFT;
29
	public final static int GROUP1 = 1 << GROUP_SHIFT;
30
	public final static int GROUP2 = 2 << GROUP_SHIFT;
31
	// reveal subsequent groups as needed
32
	// public final static int GROUP3 = 3 << GROUP_SHIFT;
33
	// public final static int GROUP4 = 4 << GROUP_SHIFT;
34
	// public final static int GROUP5 = 5 << GROUP_SHIFT;
35
	// public final static int GROUP6 = 6 << GROUP_SHIFT;
36
	// public final static int GROUP7 = 7 << GROUP_SHIFT;
37
38
	// Predefine sets of irritants matching warning tokens
39
	public static final IrritantSet ALL = new IrritantSet(
40
			0xFFFFFFFF & ~GROUP_MASK);
41
	public static final IrritantSet BOXING = new IrritantSet(
42
			CompilerOptions.AutoBoxing);
43
	public static final IrritantSet CAST = new IrritantSet(
44
			CompilerOptions.UnnecessaryTypeCheck);
45
	public static final IrritantSet DEPRECATION = new IrritantSet(
46
			CompilerOptions.UsingDeprecatedAPI);
47
	public static final IrritantSet DEP_ANN = new IrritantSet(
48
			CompilerOptions.MissingDeprecatedAnnotation);
49
	public static final IrritantSet FALLTHROUGH = new IrritantSet(
50
			CompilerOptions.FallthroughCase);
51
	public static final IrritantSet FINALLY = new IrritantSet(
52
			CompilerOptions.FinallyBlockNotCompleting);
53
	public static final IrritantSet HIDING = new IrritantSet(
54
			CompilerOptions.MaskedCatchBlock); // further scenarii in static
55
												// initializer
56
	public static final IrritantSet INCOMPLETE_SWITCH = new IrritantSet(
57
			CompilerOptions.IncompleteEnumSwitch);
58
	public static final IrritantSet NLS = new IrritantSet(
59
			CompilerOptions.NonExternalizedString);
60
	public static final IrritantSet NULL = new IrritantSet(
61
			CompilerOptions.NullReference); // further scenarii in static
62
											// initializer
63
	public static final IrritantSet RESTRICTION = new IrritantSet(
64
			CompilerOptions.ForbiddenReference); // further scenarii in static
65
													// initializer
66
	public static final IrritantSet SERIAL = new IrritantSet(
67
			CompilerOptions.MissingSerialVersion);
68
	public static final IrritantSet STATIC_ACCESS = new IrritantSet(
69
			CompilerOptions.IndirectStaticAccess); // further scenarii in static
70
													// initializer
71
	public static final IrritantSet SYNTHETIC_ACCESS = new IrritantSet(
72
			CompilerOptions.AccessEmulation);
73
	public static final IrritantSet SUPER = new IrritantSet(
74
			CompilerOptions.OverridingMethodWithoutSuperInvocation);
75
	public static final IrritantSet UNUSED = new IrritantSet(
76
			CompilerOptions.UnusedLocalVariable); // further scenarii in static
77
													// initializer
78
	public static final IrritantSet UNCHECKED = new IrritantSet(
79
			CompilerOptions.UncheckedTypeOperation); // further scenarii in
80
														// static initializer
81
	public static final IrritantSet UNQUALIFIED_FIELD_ACCESS = new IrritantSet(
82
			CompilerOptions.UnqualifiedFieldAccess);
83
84
	public static final IrritantSet COMPILER_DEFAULT_ERRORS = new IrritantSet(0); // no optional error by default	
85
	public static final IrritantSet COMPILER_DEFAULT_WARNINGS = new IrritantSet(0); // see static initializer below
86
	static {
87
		COMPILER_DEFAULT_WARNINGS
88
			// group-0 warnings enabled by default
89
			.set(
90
				CompilerOptions.MethodWithConstructorName
91
				| CompilerOptions.OverriddenPackageDefaultMethod
92
				| CompilerOptions.UsingDeprecatedAPI
93
				| CompilerOptions.MaskedCatchBlock
94
				| CompilerOptions.UnusedLocalVariable
95
				| CompilerOptions.NoImplicitStringConversion
96
				| CompilerOptions.AssertUsedAsAnIdentifier
97
				| CompilerOptions.UnusedImport
98
				| CompilerOptions.NonStaticAccessToStatic
99
				| CompilerOptions.NoEffectAssignment
100
				| CompilerOptions.IncompatibleNonInheritedInterfaceMethod
101
				| CompilerOptions.UnusedPrivateMember
102
				| CompilerOptions.FinallyBlockNotCompleting)
103
			// group-1 warnings enabled by default
104
			.set(
105
				CompilerOptions.UncheckedTypeOperation
106
				| CompilerOptions.FinalParameterBound
107
				| CompilerOptions.MissingSerialVersion
108
				| CompilerOptions.EnumUsedAsAnIdentifier
109
				| CompilerOptions.ForbiddenReference
110
				| CompilerOptions.VarargsArgumentNeedCast
111
				| CompilerOptions.NullReference
112
				| CompilerOptions.AnnotationSuperInterface
113
				| CompilerOptions.TypeHiding
114
				| CompilerOptions.DiscouragedReference
115
				| CompilerOptions.UnhandledWarningToken
116
				| CompilerOptions.RawTypeReference
117
				| CompilerOptions.UnusedLabel
118
				| CompilerOptions.UnusedTypeArguments
119
				| CompilerOptions.UnusedWarningToken
120
				| CompilerOptions.ComparingIdentical
121
				| CompilerOptions.MissingSynchronizedModifierInInheritedMethod);
122
			// group-2 warnings enabled by default
123
			// next irritant goes here (group-1 is complete)						
124
			
125
		ALL.setAll();
126
		HIDING
127
			.set(CompilerOptions.FieldHiding)
128
			.set(CompilerOptions.LocalVariableHiding)
129
			.set(CompilerOptions.TypeHiding);
130
		NULL
131
			.set(CompilerOptions.PotentialNullReference)
132
			.set(CompilerOptions.RedundantNullCheck);
133
		RESTRICTION.set(CompilerOptions.DiscouragedReference);
134
		STATIC_ACCESS.set(CompilerOptions.NonStaticAccessToStatic);
135
		UNUSED
136
			.set(CompilerOptions.UnusedArgument)
137
			.set(CompilerOptions.UnusedPrivateMember)
138
			.set(CompilerOptions.UnusedDeclaredThrownException)
139
			.set(CompilerOptions.UnusedLabel)
140
			.set(CompilerOptions.UnusedImport)
141
			.set(CompilerOptions.UnusedTypeArguments)
142
			.set(CompilerOptions.RedundantSuperinterface);
143
		UNCHECKED.set(CompilerOptions.RawTypeReference);
144
	}
145
146
	// Internal state
147
	private int[] bits = new int[GROUP_MAX];
148
149
	/**
150
	 * Constructor with initial irritant set
151
	 */
152
	public IrritantSet(int singleGroupIrritants) {
153
		initialize(singleGroupIrritants);
154
	}
155
156
	/**
157
	 * Constructor with initial irritant set
158
	 */
159
	public IrritantSet(IrritantSet other) {
160
		initialize(other);
161
	}
162
163
	public boolean areAllSet() {
164
		for (int i = 0; i < GROUP_MAX; i++) {
165
			if (this.bits[i] != (0xFFFFFFFF & ~GROUP_MASK))
166
				return false;
167
		}
168
		return true;
169
	}
170
171
	public IrritantSet clear(int singleGroupIrritants) {
172
		int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT;
173
		this.bits[group] &= ~singleGroupIrritants;
174
		return this;
175
	}
176
177
	public IrritantSet clearAll() {
178
		for (int i = 0; i < GROUP_MAX; i++) {
179
			this.bits[i] = 0;
180
		}
181
		return this;
182
	}
183
184
	/**
185
	 * Initialize a set of irritants in one group
186
	 * 
187
	 * @param singleGroupIrritants
188
	 */
189
	public void initialize(int singleGroupIrritants) {
190
		if (singleGroupIrritants == 0)
191
			return;
192
		int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT;
193
		this.bits[group] = singleGroupIrritants & ~GROUP_MASK; // erase group information
194
	}
195
196
	public void initialize(IrritantSet other) {
197
		if (other == null)
198
			return;
199
		System.arraycopy(other.bits, 0, this.bits = new int[GROUP_MAX], 0, GROUP_MAX);
200
	}
201
202
	/**
203
	 * Returns true if any of the irritants in given other set is positionned in receiver
204
	 * @param other
205
	 */
206
	public boolean isAnySet(IrritantSet other) {
207
		if (other == null)
208
			return false;
209
		for (int i = 0; i < GROUP_MAX; i++) {
210
			if ((this.bits[i] & other.bits[i]) != 0)
211
				return true;
212
		}
213
		return false;
214
	}
215
216
	public boolean isSet(int singleGroupIrritants) {
217
		int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT;
218
		return (this.bits[group] & singleGroupIrritants) != 0;
219
	}
220
221
	public IrritantSet set(int singleGroupIrritants) {
222
		int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT;
223
		this.bits[group] |= (singleGroupIrritants & ~GROUP_MASK); // erase the group bits
224
		return this;
225
	}
226
227
	/**
228
	 * Return updated irritantSet or null if it was a no-op
229
	 * 
230
	 * @param other
231
	 */
232
	public IrritantSet set(IrritantSet other) {
233
		if (other == null)
234
			return this;
235
		boolean wasNoOp = true;
236
		for (int i = 0; i < GROUP_MAX; i++) {
237
			int otherIrritant = other.bits[i] & ~GROUP_MASK; // erase the
238
																	// group
239
																	// bits
240
			if ((this.bits[i] & otherIrritant) != otherIrritant) {
241
				wasNoOp = false;
242
				this.bits[i] |= otherIrritant;
243
			}
244
		}
245
		return wasNoOp ? null : this;
246
	}
247
	
248
	public IrritantSet setAll() {
249
		for (int i = 0; i < GROUP_MAX; i++) {
250
			this.bits[i] |= 0xFFFFFFFF & ~GROUP_MASK; // erase the group
251
															// bits;
252
		}
253
		return this;
254
	}
255
}
(-)src/org/eclipse/jdt/internal/compiler/as/ActionScriptSourceGenerator.java (-4 / +3 lines)
Lines 111-117 Link Here
111
import org.eclipse.jdt.internal.compiler.lookup.SignatureWrapper;
111
import org.eclipse.jdt.internal.compiler.lookup.SignatureWrapper;
112
import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding;
112
import org.eclipse.jdt.internal.compiler.lookup.SyntheticArgumentBinding;
113
import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
113
import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding;
114
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
115
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
114
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
116
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
115
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
117
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
116
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
Lines 1889-1895 Link Here
1889
				String errorMessage = Util.appendConstant(this.scriptOutput, constant);
1888
				String errorMessage = Util.appendConstant(this.scriptOutput, constant);
1890
				if (errorMessage != null) {
1889
				if (errorMessage != null) {
1891
//					reportError(scope, errorMessage, qualifiedNameReference);
1890
//					reportError(scope, errorMessage, qualifiedNameReference);
1892
					reportWarning(scope, "SHOULD BE ERROR - " + errorMessage, qualifiedNameReference);
1891
					reportWarning(scope, "SHOULD BE ERROR - " + errorMessage, qualifiedNameReference); //$NON-NLS-1$
1893
				}
1892
				}
1894
				return false;
1893
				return false;
1895
			}
1894
			}
Lines 1984-1990 Link Here
1984
			String errorMessage = Util.appendConstant(this.scriptOutput, singleNameReference.constant);
1983
			String errorMessage = Util.appendConstant(this.scriptOutput, singleNameReference.constant);
1985
			if (errorMessage != null) {
1984
			if (errorMessage != null) {
1986
//				reportError(scope, errorMessage, singleNameReference);
1985
//				reportError(scope, errorMessage, singleNameReference);
1987
				reportWarning(scope, "SHOULD BE ERROR - " + errorMessage, singleNameReference);
1986
				reportWarning(scope, "SHOULD BE ERROR - " + errorMessage, singleNameReference); //$NON-NLS-1$
1988
			}
1987
			}
1989
			return false;
1988
			return false;
1990
		}
1989
		}
Lines 2410-2416 Link Here
2410
							switch (synthetic.purpose) {
2409
							switch (synthetic.purpose) {
2411
								case SyntheticMethodBinding.FieldReadAccess:
2410
								case SyntheticMethodBinding.FieldReadAccess:
2412
									printIndent();
2411
									printIndent();
2413
									this.scriptOutput.append(argumentsCount == 0 ? "return " : "return arg0."); //$NON-NLS-1$
2412
									this.scriptOutput.append(argumentsCount == 0 ? "return " : "return arg0."); //$NON-NLS-1$  //$NON-NLS-2$
2414
									this.scriptOutput.append(synthetic.targetReadField.name);
2413
									this.scriptOutput.append(synthetic.targetReadField.name);
2415
									this.scriptOutput.append(";\n"); //$NON-NLS-1$
2414
									this.scriptOutput.append(";\n"); //$NON-NLS-1$
2416
									break;
2415
									break;
(-)src/org/eclipse/jdt/internal/compiler/as/CompilerOptions.java (-22 / +13 lines)
Lines 13-35 Link Here
13
import java.util.Map;
13
import java.util.Map;
14
14
15
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
15
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
16
import org.eclipse.jdt.internal.compiler.impl.IrritantSet;
16
17
17
public class CompilerOptions extends org.eclipse.jdt.internal.compiler.impl.CompilerOptions {
18
public class CompilerOptions extends org.eclipse.jdt.internal.compiler.impl.CompilerOptions {
19
	
18
	public static final String OPTION_ReportNonConstStaticFinalField = "org.eclipse.jdt.core.compiler.problem.as.nonConstStaticFinalField"; //$NON-NLS-1$
20
	public static final String OPTION_ReportNonConstStaticFinalField = "org.eclipse.jdt.core.compiler.problem.as.nonConstStaticFinalField"; //$NON-NLS-1$
19
	public static final long NonConstStaticFinalField = ASTNode.Bit57L;
21
	public static final int NonConstStaticFinalField = IrritantSet.GROUP2 + ASTNode.Bit15; // offset behind base compiler irritants
20
	public static final String OPTION_DisableWarnings = "org.eclipse.jdt.core.compiler.problem.disableWarnings"; //$NON-NLS-1$
22
	public static final String OPTION_DisableWarnings = "org.eclipse.jdt.core.compiler.problem.disableWarnings"; //$NON-NLS-1$
21
23
22
	// disable all warnings
24
	// disable all warnings
23
	public boolean disableWarnings = false;
25
	public boolean disableWarnings = false;
24
26
25
	public CompilerOptions() {
27
	public CompilerOptions() {
26
		this.warningThreshold |= NonConstStaticFinalField;
28
		super();
27
	}
29
	}
28
	public CompilerOptions(Map options) {
30
	public CompilerOptions(Map settings) {
29
		this();
31
		super(settings);
30
		if (options != null) {
32
	}
31
			set(options);
33
	
32
		}
34
	protected void resetDefaults() {
35
		super.resetDefaults();
36
		this.warningThreshold.set(NonConstStaticFinalField);
33
	}
37
	}
34
	
38
	
35
	public Map getMap() {
39
	public Map getMap() {
Lines 41-61 Link Here
41
45
42
	public void set(Map optionsMap) {
46
	public void set(Map optionsMap) {
43
		super.set(optionsMap);
47
		super.set(optionsMap);
44
		String optionValue;
48
		Object optionValue;
45
		if ((optionValue = (String) optionsMap.get(OPTION_ReportNonConstStaticFinalField)) != null) {
49
		if ((optionValue = optionsMap.get(CompilerOptions.OPTION_DisableWarnings)) != null) {
46
			// inlined (not visible) updateSeverity(NonConstStaticFinalField, optionValue);
47
			if (ERROR.equals(optionValue)) {
48
				this.errorThreshold |= NonConstStaticFinalField;
49
				this.warningThreshold &= ~NonConstStaticFinalField;
50
			} else if (WARNING.equals(optionValue)) {
51
				this.errorThreshold &= ~NonConstStaticFinalField;
52
				this.warningThreshold |= NonConstStaticFinalField;
53
			} else if (IGNORE.equals(optionValue)) {
54
				this.errorThreshold &= ~NonConstStaticFinalField;
55
				this.warningThreshold &= ~NonConstStaticFinalField;
56
			}
57
		}
58
		if ((optionValue = (String) optionsMap.get(CompilerOptions.OPTION_DisableWarnings)) != null) {
59
			if (ENABLED.equals(optionValue)) {
50
			if (ENABLED.equals(optionValue)) {
60
				this.disableWarnings = false;
51
				this.disableWarnings = false;
61
			} else if (DISABLED.equals(optionValue)) {
52
			} else if (DISABLED.equals(optionValue)) {

Return to bug 245973