View | Details | Raw Unified | Return to bug 118217 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/JavadocSingleNameReference.java (-2 / +5 lines)
Lines 25-41 Link Here
25
	}
25
	}
26
26
27
	public void resolve(BlockScope scope) {
27
	public void resolve(BlockScope scope) {
28
		resolve(scope, true);
28
		resolve(scope, true, !scope.compilerOptions().reportUnusedParameterWhenDocumented);
29
	}
29
	}
30
30
31
	/**
31
	/**
32
	 * Resolve without warnings
32
	 * Resolve without warnings
33
	 */
33
	 */
34
	public void resolve(BlockScope scope, boolean warn) {
34
	public void resolve(BlockScope scope, boolean warn, boolean considerParamRefAsUsage) {
35
		
35
		
36
		LocalVariableBinding variableBinding = scope.findVariable(this.token);
36
		LocalVariableBinding variableBinding = scope.findVariable(this.token);
37
		if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) {
37
		if (variableBinding != null && variableBinding.isValidBinding() && ((variableBinding.tagBits & TagBits.IsArgument) != 0)) {
38
			this.binding = variableBinding;
38
			this.binding = variableBinding;
39
			if (considerParamRefAsUsage) {
40
				variableBinding.useFlag = LocalVariableBinding.USED;
41
			}
39
			return;
42
			return;
40
		}
43
		}
41
		if (warn) {
44
		if (warn) {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Javadoc.java (-13 / +14 lines)
Lines 309-315 Link Here
309
		}
309
		}
310
310
311
		// @param tags
311
		// @param tags
312
		resolveParamTags(methScope, reportMissing);
312
		boolean considerParamRefAsUsage = !methScope.compilerOptions().reportUnusedParameterWhenDocumented;
313
		resolveParamTags(methScope, reportMissing, considerParamRefAsUsage);
313
		resolveTypeParameterTags(methScope, reportMissing);
314
		resolveTypeParameterTags(methScope, reportMissing);
314
315
315
		// @return tags
316
		// @return tags
Lines 339-345 Link Here
339
		// Resolve param tags with invalid syntax
340
		// Resolve param tags with invalid syntax
340
		int length = this.invalidParameters == null ? 0 : this.invalidParameters.length;
341
		int length = this.invalidParameters == null ? 0 : this.invalidParameters.length;
341
		for (int i = 0; i < length; i++) {
342
		for (int i = 0; i < length; i++) {
342
			this.invalidParameters[i].resolve(methScope, false);
343
			this.invalidParameters[i].resolve(methScope, false, false);
343
		}
344
		}
344
	}
345
	}
345
	
346
	
Lines 445-470 Link Here
445
	/*
446
	/*
446
	 * Resolve @param tags while method scope
447
	 * Resolve @param tags while method scope
447
	 */
448
	 */
448
	private void resolveParamTags(MethodScope methScope, boolean reportMissing) {
449
	private void resolveParamTags(MethodScope scope, boolean reportMissing, boolean considerParamRefAsUsage) {
449
		AbstractMethodDeclaration md = methScope.referenceMethod();
450
		AbstractMethodDeclaration methodDecl = scope.referenceMethod();
450
		int paramTagsSize = this.paramReferences == null ? 0 : this.paramReferences.length;
451
		int paramTagsSize = this.paramReferences == null ? 0 : this.paramReferences.length;
451
452
452
		// If no referenced method (field initializer for example) then report a problem for each param tag
453
		// If no referenced method (field initializer for example) then report a problem for each param tag
453
		if (md == null) {
454
		if (methodDecl == null) {
454
			for (int i = 0; i < paramTagsSize; i++) {
455
			for (int i = 0; i < paramTagsSize; i++) {
455
				JavadocSingleNameReference param = this.paramReferences[i];
456
				JavadocSingleNameReference param = this.paramReferences[i];
456
				methScope.problemReporter().javadocUnexpectedTag(param.tagSourceStart, param.tagSourceEnd);
457
				scope.problemReporter().javadocUnexpectedTag(param.tagSourceStart, param.tagSourceEnd);
457
			}
458
			}
458
			return;
459
			return;
459
		}
460
		}
460
		
461
		
461
		// If no param tags then report a problem for each method argument
462
		// If no param tags then report a problem for each method argument
462
		int argumentsSize = md.arguments == null ? 0 : md.arguments.length;
463
		int argumentsSize = methodDecl.arguments == null ? 0 : methodDecl.arguments.length;
463
		if (paramTagsSize == 0) {
464
		if (paramTagsSize == 0) {
464
			if (reportMissing) {
465
			if (reportMissing) {
465
				for (int i = 0; i < argumentsSize; i++) {
466
				for (int i = 0; i < argumentsSize; i++) {
466
					Argument arg = md.arguments[i];
467
					Argument arg = methodDecl.arguments[i];
467
					methScope.problemReporter().javadocMissingParamTag(arg.name, arg.sourceStart, arg.sourceEnd, md.binding.modifiers);
468
					scope.problemReporter().javadocMissingParamTag(arg.name, arg.sourceStart, arg.sourceEnd, methodDecl.binding.modifiers);
468
				}
469
				}
469
			}
470
			}
470
		} else {
471
		} else {
Lines 474-486 Link Here
474
			// Scan all @param tags
475
			// Scan all @param tags
475
			for (int i = 0; i < paramTagsSize; i++) {
476
			for (int i = 0; i < paramTagsSize; i++) {
476
				JavadocSingleNameReference param = this.paramReferences[i];
477
				JavadocSingleNameReference param = this.paramReferences[i];
477
				param.resolve(methScope);
478
				param.resolve(scope, true, considerParamRefAsUsage);
478
				if (param.binding != null && param.binding.isValidBinding()) {
479
				if (param.binding != null && param.binding.isValidBinding()) {
479
					// Verify duplicated tags
480
					// Verify duplicated tags
480
					boolean found = false;
481
					boolean found = false;
481
					for (int j = 0; j < maxBindings && !found; j++) {
482
					for (int j = 0; j < maxBindings && !found; j++) {
482
						if (bindings[j] == param.binding) {
483
						if (bindings[j] == param.binding) {
483
							methScope.problemReporter().javadocDuplicatedParamTag(param.token, param.sourceStart, param.sourceEnd, md.binding.modifiers);
484
							scope.problemReporter().javadocDuplicatedParamTag(param.token, param.sourceStart, param.sourceEnd, methodDecl.binding.modifiers);
484
							found = true;
485
							found = true;
485
						}
486
						}
486
					}
487
					}
Lines 493-499 Link Here
493
			// Look for undocumented arguments
494
			// Look for undocumented arguments
494
			if (reportMissing) {
495
			if (reportMissing) {
495
				for (int i = 0; i < argumentsSize; i++) {
496
				for (int i = 0; i < argumentsSize; i++) {
496
					Argument arg = md.arguments[i];
497
					Argument arg = methodDecl.arguments[i];
497
					boolean found = false;
498
					boolean found = false;
498
					for (int j = 0; j < maxBindings && !found; j++) {
499
					for (int j = 0; j < maxBindings && !found; j++) {
499
						LocalVariableBinding binding = bindings[j];
500
						LocalVariableBinding binding = bindings[j];
Lines 502-508 Link Here
502
						}
503
						}
503
					}
504
					}
504
					if (!found) {
505
					if (!found) {
505
						methScope.problemReporter().javadocMissingParamTag(arg.name, arg.sourceStart, arg.sourceEnd, md.binding.modifiers);
506
						scope.problemReporter().javadocMissingParamTag(arg.name, arg.sourceStart, arg.sourceEnd, methodDecl.binding.modifiers);
506
					}
507
					}
507
				}
508
				}
508
			}
509
			}
(-)model/org/eclipse/jdt/core/JavaCore.java (+15 lines)
Lines 66-71 Link Here
66
 *     IBM Corporation - added the following constants:
66
 *     IBM Corporation - added the following constants:
67
 *                                 COMPILER_PB_POTENTIAL_NULL_REFERENCE
67
 *                                 COMPILER_PB_POTENTIAL_NULL_REFERENCE
68
 *                                 COMPILER_PB_REDUNDANT_NULL_CHECK
68
 *                                 COMPILER_PB_REDUNDANT_NULL_CHECK
69
 *     IBM Corporation - added the following constants:
70
 *                                 COMPILER_PB_UNUSED_PARAMETER_WHEN_DOCUMENTED
69
 *******************************************************************************/
71
 *******************************************************************************/
70
package org.eclipse.jdt.core;
72
package org.eclipse.jdt.core;
71
73
Lines 287-292 Link Here
287
	/**
289
	/**
288
	 * Possible  configurable option ID.
290
	 * Possible  configurable option ID.
289
	 * @see #getDefaultOptions()
291
	 * @see #getDefaultOptions()
292
	 * @since 3.3
293
	 */
294
	public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_DOCUMENTED = PLUGIN_ID + ".compiler.problem.unusedParameterWhenDocumented"; //$NON-NLS-1$
295
	/**
296
	 * Possible  configurable option ID.
297
	 * @see #getDefaultOptions()
290
	 * @since 2.0
298
	 * @since 2.0
291
	 */
299
	 */
292
	public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$
300
	public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$
Lines 1998-2003 Link Here
1998
	 *     - possible values:   { "enabled", "disabled" }
2006
	 *     - possible values:   { "enabled", "disabled" }
1999
	 *     - default:           "disabled"
2007
	 *     - default:           "disabled"
2000
	 *
2008
	 *
2009
	 * COMPILER / Reporting Unused Parameter which is Documented by @param Clause
2010
	 *    When enabled, the compiler will still report unused parameters which are documented by @param clauses.
2011
	 *    The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
2012
	 *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenDocumented"
2013
	 *     - possible values:   { "enabled", "disabled" }
2014
	 *     - default:           "disabled"
2015
	 *
2001
	 * COMPILER / Reporting Unused Import
2016
	 * COMPILER / Reporting Unused Import
2002
	 *    When enabled, the compiler will issue an error or a warning for unused import
2017
	 *    When enabled, the compiler will issue an error or a warning for unused import
2003
	 *    reference
2018
	 *    reference
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (+10 lines)
Lines 43-48 Link Here
43
	public static final String OPTION_ReportUnusedLocal = "org.eclipse.jdt.core.compiler.problem.unusedLocal"; //$NON-NLS-1$
43
	public static final String OPTION_ReportUnusedLocal = "org.eclipse.jdt.core.compiler.problem.unusedLocal"; //$NON-NLS-1$
44
	public static final String OPTION_ReportUnusedParameter = "org.eclipse.jdt.core.compiler.problem.unusedParameter"; //$NON-NLS-1$
44
	public static final String OPTION_ReportUnusedParameter = "org.eclipse.jdt.core.compiler.problem.unusedParameter"; //$NON-NLS-1$
45
	public static final String OPTION_ReportUnusedParameterWhenImplementingAbstract = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
45
	public static final String OPTION_ReportUnusedParameterWhenImplementingAbstract = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
46
	public static final String OPTION_ReportUnusedParameterWhenDocumented = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenDocumented"; //$NON-NLS-1$
46
	public static final String OPTION_ReportUnusedParameterWhenOverridingConcrete = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
47
	public static final String OPTION_ReportUnusedParameterWhenOverridingConcrete = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
47
	public static final String OPTION_ReportUnusedImport = "org.eclipse.jdt.core.compiler.problem.unusedImport"; //$NON-NLS-1$
48
	public static final String OPTION_ReportUnusedImport = "org.eclipse.jdt.core.compiler.problem.unusedImport"; //$NON-NLS-1$
48
	public static final String OPTION_ReportSyntheticAccessEmulation = "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
49
	public static final String OPTION_ReportSyntheticAccessEmulation = "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
Lines 270-275 Link Here
270
	// unused parameters report
271
	// unused parameters report
271
	public boolean reportUnusedParameterWhenImplementingAbstract = false;
272
	public boolean reportUnusedParameterWhenImplementingAbstract = false;
272
	public boolean reportUnusedParameterWhenOverridingConcrete = false;
273
	public boolean reportUnusedParameterWhenOverridingConcrete = false;
274
	public boolean reportUnusedParameterWhenDocumented = false;
273
275
274
	// unused declaration of thrown exception
276
	// unused declaration of thrown exception
275
	public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false;
277
	public boolean reportUnusedDeclaredThrownExceptionWhenOverriding = false;
Lines 418-423 Link Here
418
		optionsMap.put(OPTION_TaskCaseSensitive, this.isTaskCaseSensitive ? ENABLED : DISABLED);
420
		optionsMap.put(OPTION_TaskCaseSensitive, this.isTaskCaseSensitive ? ENABLED : DISABLED);
419
		optionsMap.put(OPTION_ReportUnusedParameterWhenImplementingAbstract, this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED);
421
		optionsMap.put(OPTION_ReportUnusedParameterWhenImplementingAbstract, this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED);
420
		optionsMap.put(OPTION_ReportUnusedParameterWhenOverridingConcrete, this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED);
422
		optionsMap.put(OPTION_ReportUnusedParameterWhenOverridingConcrete, this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED);
423
		optionsMap.put(OPTION_ReportUnusedParameterWhenDocumented, this.reportUnusedParameterWhenDocumented ? ENABLED : DISABLED);
421
		optionsMap.put(OPTION_ReportSpecialParameterHidingField, this.reportSpecialParameterHidingField ? ENABLED : DISABLED);
424
		optionsMap.put(OPTION_ReportSpecialParameterHidingField, this.reportSpecialParameterHidingField ? ENABLED : DISABLED);
422
		optionsMap.put(OPTION_MaxProblemPerUnit, String.valueOf(this.maxProblemsPerUnit));
425
		optionsMap.put(OPTION_MaxProblemPerUnit, String.valueOf(this.maxProblemsPerUnit));
423
		optionsMap.put(OPTION_InlineJsr, this.inlineJsrBytecode ? ENABLED : DISABLED);
426
		optionsMap.put(OPTION_InlineJsr, this.inlineJsrBytecode ? ENABLED : DISABLED);
Lines 697-702 Link Here
697
				this.reportUnusedParameterWhenOverridingConcrete = false;
700
				this.reportUnusedParameterWhenOverridingConcrete = false;
698
			}
701
			}
699
		}
702
		}
703
		if ((optionValue = optionsMap.get(OPTION_ReportUnusedParameterWhenDocumented)) != null) {
704
			if (ENABLED.equals(optionValue)) {
705
				this.reportUnusedParameterWhenDocumented = true;
706
			} else if (DISABLED.equals(optionValue)) {
707
				this.reportUnusedParameterWhenDocumented = false;
708
			}
709
		}		
700
		if ((optionValue = optionsMap.get(OPTION_ReportSpecialParameterHidingField)) != null) {
710
		if ((optionValue = optionsMap.get(OPTION_ReportSpecialParameterHidingField)) != null) {
701
			if (ENABLED.equals(optionValue)) {
711
			if (ENABLED.equals(optionValue)) {
702
				this.reportSpecialParameterHidingField = true;
712
				this.reportSpecialParameterHidingField = true;

Return to bug 118217