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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java (+330 lines)
Lines 357-362 Link Here
357
			options,
357
			options,
358
			null);
358
			null);
359
}
359
}
360
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=118217
361
public void test016() {
362
	Map options = getCompilerOptions();
363
	options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
364
	options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.ERROR);
365
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenDocumented, CompilerOptions.DISABLED);
366
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED);
367
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED);
368
	this.runNegativeTest(
369
			new String[] {
370
				"X.java",
371
				"public class X extends Parent implements Doable {\n" + 
372
				"	/**\n" + 
373
				"	 * @param value\n" + 
374
				"	 */\n" + 
375
				"	void foo(int value) { // X#foo(...)\n" + 
376
				"	}\n" + 
377
				"	void bar(int value) { // X#bar(...)\n" + 
378
				"	}\n" + 
379
				"\n" + 
380
				"	void top(int value) { /* X#top(...)*/}\n" + 
381
				"	void parent(int value) { /* X#parent(...) */}\n" + 
382
				"	public void doit(int value) { /* X#doit(...) */}\n" + 
383
				"}\n" + 
384
				"abstract class Top {\n" + 
385
				"	/**\n" + 
386
				"	 * @param value\n" + 
387
				"	 */\n" + 
388
				"	abstract void top(int value); // Top#top(...)\n" + 
389
				"}\n" + 
390
				"abstract class Parent extends Top {\n" + 
391
				"	/**\n" + 
392
				"	 * @param value\n" + 
393
				"	 */\n" + 
394
				"	void parent(int value) { /* Parent#parent(...) */}\n" + 
395
				"}\n" + 
396
				"interface Doable {\n" + 
397
				"	/**\n" + 
398
				"	 * @param value\n" + 
399
				"	 */\n" + 
400
				"	void doit (int value); // Doable#doit(...)\n" + 
401
				"}", // =================
402
			},
403
			"----------\n" + 
404
			"1. ERROR in X.java (at line 7)\n" + 
405
			"	void bar(int value) { // X#bar(...)\n" + 
406
			"	             ^^^^^\n" + 
407
			"The parameter value is never read\n" + 
408
			"----------\n",
409
			null /* classLib */,
410
			true /* shouldFlushOutputDirectory */,
411
			options);
412
}
413
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=118217 - variation
414
public void test017() {
415
	Map options = getCompilerOptions();
416
	options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.DISABLED);
417
	options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.ERROR);
418
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenDocumented, CompilerOptions.DISABLED);
419
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED);
420
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED);
421
	this.runNegativeTest(
422
			new String[] {
423
				"X.java",
424
				"public class X extends Parent implements Doable {\n" + 
425
				"	/**\n" + 
426
				"	 * @param value\n" + 
427
				"	 */\n" + 
428
				"	void foo(int value) { // X#foo(...)\n" + 
429
				"	}\n" + 
430
				"	void bar(int value) { // X#bar(...)\n" + 
431
				"	}\n" + 
432
				"\n" + 
433
				"	void top(int value) { /* X#top(...)*/}\n" + 
434
				"	void parent(int value) { /* X#parent(...) */}\n" + 
435
				"	public void doit(int value) { /* X#doit(...) */}\n" + 
436
				"}\n" + 
437
				"abstract class Top {\n" + 
438
				"	/**\n" + 
439
				"	 * @param value\n" + 
440
				"	 */\n" + 
441
				"	abstract void top(int value); // Top#top(...)\n" + 
442
				"}\n" + 
443
				"abstract class Parent extends Top {\n" + 
444
				"	/**\n" + 
445
				"	 * @param value\n" + 
446
				"	 */\n" + 
447
				"	void parent(int value) { /* Parent#parent(...) */}\n" + 
448
				"}\n" + 
449
				"interface Doable {\n" + 
450
				"	/**\n" + 
451
				"	 * @param value\n" + 
452
				"	 */\n" + 
453
				"	void doit (int value); // Doable#doit(...)\n" + 
454
				"}", // =================
455
			},
456
			"----------\n" + 
457
			"1. ERROR in X.java (at line 5)\n" + 
458
			"	void foo(int value) { // X#foo(...)\n" + 
459
			"	             ^^^^^\n" + 
460
			"The parameter value is never read\n" + 
461
			"----------\n" + 
462
			"2. ERROR in X.java (at line 7)\n" + 
463
			"	void bar(int value) { // X#bar(...)\n" + 
464
			"	             ^^^^^\n" + 
465
			"The parameter value is never read\n" + 
466
			"----------\n" + 
467
			"3. ERROR in X.java (at line 24)\n" + 
468
			"	void parent(int value) { /* Parent#parent(...) */}\n" + 
469
			"	                ^^^^^\n" + 
470
			"The parameter value is never read\n" + 
471
			"----------\n",
472
			null /* classLib */,
473
			true /* shouldFlushOutputDirectory */,
474
			options);
475
}
476
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=118217 - variation
477
public void test018() {
478
	Map options = getCompilerOptions();
479
	options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
480
	options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.ERROR);
481
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenDocumented, CompilerOptions.ENABLED);
482
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.DISABLED);
483
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.DISABLED);
484
	this.runNegativeTest(
485
			new String[] {
486
				"X.java",
487
				"public class X extends Parent implements Doable {\n" + 
488
				"	/**\n" + 
489
				"	 * @param value\n" + 
490
				"	 */\n" + 
491
				"	void foo(int value) { // X#foo(...)\n" + 
492
				"	}\n" + 
493
				"	void bar(int value) { // X#bar(...)\n" + 
494
				"	}\n" + 
495
				"\n" + 
496
				"	void top(int value) { /* X#top(...)*/}\n" + 
497
				"	void parent(int value) { /* X#parent(...) */}\n" + 
498
				"	public void doit(int value) { /* X#doit(...) */}\n" + 
499
				"}\n" + 
500
				"abstract class Top {\n" + 
501
				"	/**\n" + 
502
				"	 * @param value\n" + 
503
				"	 */\n" + 
504
				"	abstract void top(int value); // Top#top(...)\n" + 
505
				"}\n" + 
506
				"abstract class Parent extends Top {\n" + 
507
				"	/**\n" + 
508
				"	 * @param value\n" + 
509
				"	 */\n" + 
510
				"	void parent(int value) { /* Parent#parent(...) */}\n" + 
511
				"}\n" + 
512
				"interface Doable {\n" + 
513
				"	/**\n" + 
514
				"	 * @param value\n" + 
515
				"	 */\n" + 
516
				"	void doit (int value); // Doable#doit(...)\n" + 
517
				"}", // =================
518
			},
519
			"----------\n" + 
520
			"1. ERROR in X.java (at line 5)\n" + 
521
			"	void foo(int value) { // X#foo(...)\n" + 
522
			"	             ^^^^^\n" + 
523
			"The parameter value is never read\n" + 
524
			"----------\n" + 
525
			"2. ERROR in X.java (at line 7)\n" + 
526
			"	void bar(int value) { // X#bar(...)\n" + 
527
			"	             ^^^^^\n" + 
528
			"The parameter value is never read\n" + 
529
			"----------\n" + 
530
			"3. ERROR in X.java (at line 24)\n" + 
531
			"	void parent(int value) { /* Parent#parent(...) */}\n" + 
532
			"	                ^^^^^\n" + 
533
			"The parameter value is never read\n" + 
534
			"----------\n",
535
			null /* classLib */,
536
			true /* shouldFlushOutputDirectory */,
537
			options);
538
}
539
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=118217 - variation
540
public void test019() {
541
	Map options = getCompilerOptions();
542
	options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
543
	options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.ERROR);
544
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenDocumented, CompilerOptions.ENABLED);
545
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.ENABLED);
546
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.ENABLED);
547
	this.runNegativeTest(
548
			new String[] {
549
				"X.java",
550
				"public class X extends Parent implements Doable {\n" + 
551
				"	/**\n" + 
552
				"	 * @param value\n" + 
553
				"	 */\n" + 
554
				"	void foo(int value) { // X#foo(...)\n" + 
555
				"	}\n" + 
556
				"	void bar(int value) { // X#bar(...)\n" + 
557
				"	}\n" + 
558
				"\n" + 
559
				"	void top(int value) { /* X#top(...)*/}\n" + 
560
				"	void parent(int value) { /* X#parent(...) */}\n" + 
561
				"	public void doit(int value) { /* X#doit(...) */}\n" + 
562
				"}\n" + 
563
				"abstract class Top {\n" + 
564
				"	/**\n" + 
565
				"	 * @param value\n" + 
566
				"	 */\n" + 
567
				"	abstract void top(int value); // Top#top(...)\n" + 
568
				"}\n" + 
569
				"abstract class Parent extends Top {\n" + 
570
				"	/**\n" + 
571
				"	 * @param value\n" + 
572
				"	 */\n" + 
573
				"	void parent(int value) { /* Parent#parent(...) */}\n" + 
574
				"}\n" + 
575
				"interface Doable {\n" + 
576
				"	/**\n" + 
577
				"	 * @param value\n" + 
578
				"	 */\n" + 
579
				"	void doit (int value); // Doable#doit(...)\n" + 
580
				"}", // =================
581
			},
582
			"----------\n" + 
583
			"1. ERROR in X.java (at line 5)\n" + 
584
			"	void foo(int value) { // X#foo(...)\n" + 
585
			"	             ^^^^^\n" + 
586
			"The parameter value is never read\n" + 
587
			"----------\n" + 
588
			"2. ERROR in X.java (at line 7)\n" + 
589
			"	void bar(int value) { // X#bar(...)\n" + 
590
			"	             ^^^^^\n" + 
591
			"The parameter value is never read\n" + 
592
			"----------\n" + 
593
			"3. ERROR in X.java (at line 10)\n" + 
594
			"	void top(int value) { /* X#top(...)*/}\n" + 
595
			"	             ^^^^^\n" + 
596
			"The parameter value is never read\n" + 
597
			"----------\n" + 
598
			"4. ERROR in X.java (at line 11)\n" + 
599
			"	void parent(int value) { /* X#parent(...) */}\n" + 
600
			"	                ^^^^^\n" + 
601
			"The parameter value is never read\n" + 
602
			"----------\n" + 
603
			"5. ERROR in X.java (at line 12)\n" + 
604
			"	public void doit(int value) { /* X#doit(...) */}\n" + 
605
			"	                     ^^^^^\n" + 
606
			"The parameter value is never read\n" + 
607
			"----------\n" + 
608
			"6. ERROR in X.java (at line 24)\n" + 
609
			"	void parent(int value) { /* Parent#parent(...) */}\n" + 
610
			"	                ^^^^^\n" + 
611
			"The parameter value is never read\n" + 
612
			"----------\n",
613
			null /* classLib */,
614
			true /* shouldFlushOutputDirectory */,
615
			options);
616
}
617
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=118217 - variation
618
public void test020() {
619
	Map options = getCompilerOptions();
620
	options.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);
621
	options.put(CompilerOptions.OPTION_ReportUnusedParameter, CompilerOptions.ERROR);
622
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenDocumented, CompilerOptions.ENABLED);
623
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete, CompilerOptions.ENABLED);
624
	options.put(CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract, CompilerOptions.ENABLED);
625
	this.runNegativeTest(
626
			new String[] {
627
				"X.java",
628
				"public class X extends Parent implements Doable {\n" + 
629
				"	/** @param value */\n" + 
630
				"	void foo(int value) { // X#foo(...)\n" + 
631
				"	}\n" + 
632
				"	void bar(int value) { // X#bar(...)\n" + 
633
				"	}\n" + 
634
				"\n" + 
635
				"	/** @param value */\n" + 
636
				"	void top(int value) { /* X#top(...)*/}\n" + 
637
				"	/** @param value */\n" + 
638
				"	void parent(int value) { /* X#parent(...) */}\n" + 
639
				"	/** @param value */\n" + 
640
				"	public void doit(int value) { /* X#doit(...) */}\n" + 
641
				"}\n" + 
642
				"abstract class Top {\n" + 
643
				"	/** @param value */\n" + 
644
				"	abstract void top(int value); // Top#top(...)\n" + 
645
				"}\n" + 
646
				"abstract class Parent extends Top {\n" + 
647
				"	/** @param value */\n" + 
648
				"	void parent(int value) { /* Parent#parent(...) */}\n" + 
649
				"}\n" + 
650
				"interface Doable {\n" + 
651
				"	/** @param value */\n" + 
652
				"	void doit (int value); // Doable#doit(...)\n" + 
653
				"}", // =================
654
			},
655
			"----------\n" + 
656
			"1. ERROR in X.java (at line 3)\n" + 
657
			"	void foo(int value) { // X#foo(...)\n" + 
658
			"	             ^^^^^\n" + 
659
			"The parameter value is never read\n" + 
660
			"----------\n" + 
661
			"2. ERROR in X.java (at line 5)\n" + 
662
			"	void bar(int value) { // X#bar(...)\n" + 
663
			"	             ^^^^^\n" + 
664
			"The parameter value is never read\n" + 
665
			"----------\n" + 
666
			"3. ERROR in X.java (at line 9)\n" + 
667
			"	void top(int value) { /* X#top(...)*/}\n" + 
668
			"	             ^^^^^\n" + 
669
			"The parameter value is never read\n" + 
670
			"----------\n" + 
671
			"4. ERROR in X.java (at line 11)\n" + 
672
			"	void parent(int value) { /* X#parent(...) */}\n" + 
673
			"	                ^^^^^\n" + 
674
			"The parameter value is never read\n" + 
675
			"----------\n" + 
676
			"5. ERROR in X.java (at line 13)\n" + 
677
			"	public void doit(int value) { /* X#doit(...) */}\n" + 
678
			"	                     ^^^^^\n" + 
679
			"The parameter value is never read\n" + 
680
			"----------\n" + 
681
			"6. ERROR in X.java (at line 21)\n" + 
682
			"	void parent(int value) { /* Parent#parent(...) */}\n" + 
683
			"	                ^^^^^\n" + 
684
			"The parameter value is never read\n" + 
685
			"----------\n",
686
			null /* classLib */,
687
			true /* shouldFlushOutputDirectory */,
688
			options);
689
}
360
public static Class testClass() {
690
public static Class testClass() {
361
	return LocalVariableTest.class;
691
	return LocalVariableTest.class;
362
}
692
}
(-)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 (+17 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
	 *    Note: this option has no effect until the doc comment support is enabled according to the 
2013
	 *    option "org.eclipse.jdt.core.compiler.doc.comment.support".
2014
	 *     - option id:         "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenDocumented"
2015
	 *     - possible values:   { "enabled", "disabled" }
2016
	 *     - default:           "disabled"
2017
	 *
2001
	 * COMPILER / Reporting Unused Import
2018
	 * COMPILER / Reporting Unused Import
2002
	 *    When enabled, the compiler will issue an error or a warning for unused import
2019
	 *    When enabled, the compiler will issue an error or a warning for unused import
2003
	 *    reference
2020
	 *    reference
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (+11 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;
Lines 972-977 Link Here
972
		buf.append("\n\t- report deprecation when overriding deprecated method : ").append(this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED); //$NON-NLS-1$
982
		buf.append("\n\t- report deprecation when overriding deprecated method : ").append(this.reportDeprecationWhenOverridingDeprecatedMethod ? ENABLED : DISABLED); //$NON-NLS-1$
973
		buf.append("\n\t- report unused parameter when implementing abstract method : ").append(this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); //$NON-NLS-1$
983
		buf.append("\n\t- report unused parameter when implementing abstract method : ").append(this.reportUnusedParameterWhenImplementingAbstract ? ENABLED : DISABLED); //$NON-NLS-1$
974
		buf.append("\n\t- report unused parameter when overriding concrete method : ").append(this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); //$NON-NLS-1$
984
		buf.append("\n\t- report unused parameter when overriding concrete method : ").append(this.reportUnusedParameterWhenOverridingConcrete ? ENABLED : DISABLED); //$NON-NLS-1$
985
		buf.append("\n\t- report unused parameter when documented : ").append(this.reportUnusedParameterWhenDocumented ? ENABLED : DISABLED); //$NON-NLS-1$
975
		buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$
986
		buf.append("\n\t- report constructor/setter parameter hiding existing field : ").append(this.reportSpecialParameterHidingField ? ENABLED : DISABLED); //$NON-NLS-1$
976
		buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$
987
		buf.append("\n\t- inline JSR bytecode : ").append(this.inlineJsrBytecode ? ENABLED : DISABLED); //$NON-NLS-1$
977
		buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); //$NON-NLS-1$
988
		buf.append("\n\t- unsafe type operation: ").append(getSeverityString(UncheckedTypeOperation)); //$NON-NLS-1$

Return to bug 118217