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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (-5 / +133 lines)
Lines 3318-3340 Link Here
3318
 * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=73995">73995</a>
3318
 * @see <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=73995">73995</a>
3319
 */
3319
 */
3320
public void testBug73995() {
3320
public void testBug73995() {
3321
	runConformTest(
3321
	runNegativeTest(
3322
		new String[] {
3322
		new String[] {
3323
			"X.java",
3323
			"X.java",
3324
			"public class X {\n" +
3324
			"public class X extends Base {\n" +
3325
				"	/**\n" +
3325
				"	/**\n" +
3326
				"	 *	@return {@link Object}     \n" +
3326
				"	 *	@return {@link Object}     \n" +
3327
				"	 */\n" +
3327
				"	 */\n" +
3328
				"	public int foo1() {return 0; }\n" +
3328
				"	public int foo1() {return 0; }\n" +
3329
				"	/** @return {@inheritedDoc} */\n" +
3329
				"	/** @return {@inheritDoc} */\n" +
3330
				"	public int foo2() {return 0; }\n" +
3330
				"	public int foo2() {return 0; }\n" +
3331
				"	/**\n" +
3331
				"	/**\n" +
3332
				"	 *	@return\n" +
3332
				"	 *	@return\n" +
3333
				"	 *		{@unknown_tag}\n" +
3333
				"	 *		{@unknown_tag}\n" +
3334
				"	 */\n" +
3334
				"	 */\n" +
3335
				"	public int foo3() {return 0; }\n" +
3335
				"	public int foo3() {return 0; }\n" +
3336
				"}\n"
3336
				"}\n" +
3337
		}
3337
				"class Base {\n" +
3338
				"/** return \"The foo2 value\" */" +
3339
				"public int foo2(){return 0;}\n" +
3340
				"}"
3341
		},
3342
		"----------\n" + 
3343
		"1. ERROR in X.java (at line 10)\n" + 
3344
		"	*		{@unknown_tag}\n" + 
3345
		"	 		  ^^^^^^^^^^^\n" + 
3346
		"Javadoc: Unexpected tag\n" + 
3347
		"----------\n"
3338
	);
3348
	);
3339
}
3349
}
3340
3350
Lines 8487-8490 Link Here
8487
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError
8497
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError
8488
	);
8498
	);
8489
}
8499
}
8500
/**
8501
 * @bug 267833:[javadoc] Custom tags should not be allowed for inline tags 
8502
 * @test Ensure that a warning is raised when customs tags are used as inline tags
8503
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=267833"
8504
 */
8505
public void testBug267833() {
8506
	runNegativeTest(
8507
		new String[] {
8508
			"X.java",
8509
			"/**\n" +
8510
			"* Invalid custom tag {@custom \"Invalid\"}   \n" +
8511
			"* @custom \"Valid\"\n" +
8512
			"*/\n" +
8513
			"public class X {\n" +
8514
			"}"
8515
		},
8516
		"----------\n" + 
8517
		"1. ERROR in X.java (at line 2)\n" + 
8518
		"	* Invalid custom tag {@custom \"Invalid\"}   \n" + 
8519
		"	                       ^^^^^^\n" + 
8520
		"Javadoc: Unexpected tag\n" + 
8521
		"----------\n"
8522
	);
8523
}
8524
/**
8525
 * Additional test for bug 267833
8526
 * @test Ensure that a warning is raised when block tags are used as inline tags. 
8527
 */
8528
public void testBug267833_2() {
8529
	runNegativeTest(
8530
			new String[] {
8531
				"X.java",
8532
				"public class X {\n" +
8533
				"/** \n" +
8534
	 "* Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" +
8535
	 "* and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" +
8536
	 "* and more {@since 1.0}, {@serial 0L}, {@serialData data}, {@serialField field}" +
8537
	 "* @param i\n" +
8538
	 "* @return value\n" +
8539
	 "* @throws NullPointerException \n" +
8540
	 "*/\n" +
8541
	"public int foo(int i) {\n" +
8542
	"	return 0;\n" +
8543
	"}\n" +
8544
	"}\n"},
8545
	"----------\n" + 
8546
	"1. ERROR in X.java (at line 3)\n" + 
8547
	"	* Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + 
8548
	"	                ^^^\n" + 
8549
	"Javadoc: Unexpected tag\n" + 
8550
	"----------\n" + 
8551
	"2. ERROR in X.java (at line 3)\n" + 
8552
	"	* Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + 
8553
	"	                               ^^^^^^\n" + 
8554
	"Javadoc: Unexpected tag\n" + 
8555
	"----------\n" + 
8556
	"3. ERROR in X.java (at line 3)\n" + 
8557
	"	* Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + 
8558
	"	                                                ^^^^^\n" + 
8559
	"Javadoc: Unexpected tag\n" + 
8560
	"----------\n" + 
8561
	"4. ERROR in X.java (at line 3)\n" + 
8562
	"	* Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + 
8563
	"	                                                                ^^^^^\n" + 
8564
	"Javadoc: Unexpected tag\n" + 
8565
	"----------\n" + 
8566
	"5. ERROR in X.java (at line 3)\n" + 
8567
	"	* Description {@see value} , {@return value}, {@since value}, {@param i}, {@throws NullPointerException}\n" + 
8568
	"	                                                                            ^^^^^^\n" + 
8569
	"Javadoc: Unexpected tag\n" + 
8570
	"----------\n" + 
8571
	"6. ERROR in X.java (at line 4)\n" + 
8572
	"	* and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + 
8573
	"	             ^^^^^^\n" + 
8574
	"Javadoc: Unexpected tag\n" + 
8575
	"----------\n" + 
8576
	"7. ERROR in X.java (at line 4)\n" + 
8577
	"	* and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + 
8578
	"	                            ^^^^^^^^\n" + 
8579
	"Javadoc: Unexpected tag\n" + 
8580
	"----------\n" + 
8581
	"8. ERROR in X.java (at line 4)\n" + 
8582
	"	* and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + 
8583
	"	                                             ^^^^^^^^^^\n" + 
8584
	"Javadoc: Unexpected tag\n" + 
8585
	"----------\n" + 
8586
	"9. ERROR in X.java (at line 4)\n" + 
8587
	"	* and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + 
8588
	"	                                                            ^^^^^^^^^\n" + 
8589
	"Javadoc: Unexpected tag\n" + 
8590
	"----------\n" + 
8591
	"10. ERROR in X.java (at line 4)\n" + 
8592
	"	* and more {@author jay}, {@category cat}, {@deprecated}, {@exception Exception}, {@version 1.1}\n" + 
8593
	"	                                                                                    ^^^^^^^\n" + 
8594
	"Javadoc: Unexpected tag\n" + 
8595
	"----------\n" + 
8596
	"11. ERROR in X.java (at line 5)\n" + 
8597
	"	* and more {@since 1.0}, {@serial 0L}, {@serialData data}, {@serialField field}* @param i\n" + 
8598
	"	             ^^^^^\n" + 
8599
	"Javadoc: Unexpected tag\n" + 
8600
	"----------\n" + 
8601
	"12. ERROR in X.java (at line 5)\n" + 
8602
	"	* and more {@since 1.0}, {@serial 0L}, {@serialData data}, {@serialField field}* @param i\n" + 
8603
	"	                           ^^^^^^\n" + 
8604
	"Javadoc: Unexpected tag\n" + 
8605
	"----------\n" + 
8606
	"13. ERROR in X.java (at line 5)\n" + 
8607
	"	* and more {@since 1.0}, {@serial 0L}, {@serialData data}, {@serialField field}* @param i\n" + 
8608
	"	                                         ^^^^^^^^^^\n" + 
8609
	"Javadoc: Unexpected tag\n" + 
8610
	"----------\n" + 
8611
	"14. ERROR in X.java (at line 5)\n" + 
8612
	"	* and more {@since 1.0}, {@serial 0L}, {@serialData data}, {@serialField field}* @param i\n" + 
8613
	"	                                                             ^^^^^^^^^^^\n" + 
8614
	"Javadoc: Unexpected tag\n" + 
8615
	"----------\n");
8616
}
8617
8490
}
8618
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java (-30 / +27 lines)
Lines 508-520 Link Here
508
		boolean valid = false;
508
		boolean valid = false;
509
		switch (firstChar) {
509
		switch (firstChar) {
510
			case 'a':
510
			case 'a':
511
				if (length == TAG_AUTHOR_LENGTH && CharOperation.equals(TAG_AUTHOR, tagName, 0, length)) {
511
				if (!this.inlineTagStarted && length == TAG_AUTHOR_LENGTH && CharOperation.equals(TAG_AUTHOR, tagName, 0, length)) {
512
					this.tagValue = TAG_AUTHOR_VALUE;
512
					this.tagValue = TAG_AUTHOR_VALUE;
513
					this.tagWaitingForDescription = this.tagValue;
513
					this.tagWaitingForDescription = this.tagValue;
514
				}
514
				}
515
				break;
515
				break;
516
			case 'c':
516
			case 'c':
517
				if (length == TAG_CATEGORY_LENGTH && CharOperation.equals(TAG_CATEGORY, tagName, 0, length)) {
517
				if (!this.inlineTagStarted && length == TAG_CATEGORY_LENGTH && CharOperation.equals(TAG_CATEGORY, tagName, 0, length)) {
518
					this.tagValue = TAG_CATEGORY_VALUE;
518
					this.tagValue = TAG_CATEGORY_VALUE;
519
					valid = parseIdentifierTag(false); // TODO (frederic) reconsider parameter value when @category will be significant in spec
519
					valid = parseIdentifierTag(false); // TODO (frederic) reconsider parameter value when @category will be significant in spec
520
				} else if (length == TAG_CODE_LENGTH && this.inlineTagStarted && CharOperation.equals(TAG_CODE, tagName, 0, length)) {
520
				} else if (length == TAG_CODE_LENGTH && this.inlineTagStarted && CharOperation.equals(TAG_CODE, tagName, 0, length)) {
Lines 523-529 Link Here
523
				}
523
				}
524
				break;
524
				break;
525
			case 'd':
525
			case 'd':
526
				if (length == TAG_DEPRECATED_LENGTH && CharOperation.equals(TAG_DEPRECATED, tagName, 0, length)) {
526
				if (!this.inlineTagStarted && length == TAG_DEPRECATED_LENGTH && CharOperation.equals(TAG_DEPRECATED, tagName, 0, length)) {
527
					this.deprecated = true;
527
					this.deprecated = true;
528
					valid = true;
528
					valid = true;
529
					this.tagValue = TAG_DEPRECATED_VALUE;
529
					this.tagValue = TAG_DEPRECATED_VALUE;
Lines 536-542 Link Here
536
				}
536
				}
537
				break;
537
				break;
538
			case 'e':
538
			case 'e':
539
				if (length == TAG_EXCEPTION_LENGTH && CharOperation.equals(TAG_EXCEPTION, tagName, 0, length)) {
539
				if (!this.inlineTagStarted && length == TAG_EXCEPTION_LENGTH && CharOperation.equals(TAG_EXCEPTION, tagName, 0, length)) {
540
					this.tagValue = TAG_EXCEPTION_VALUE;
540
					this.tagValue = TAG_EXCEPTION_VALUE;
541
					valid = parseThrows();
541
					valid = parseThrows();
542
				}
542
				}
Lines 595-640 Link Here
595
				}
595
				}
596
				break;
596
				break;
597
			case 'p':
597
			case 'p':
598
				if (length == TAG_PARAM_LENGTH && CharOperation.equals(TAG_PARAM, tagName, 0, length)) {
598
				if (!this.inlineTagStarted && length == TAG_PARAM_LENGTH && CharOperation.equals(TAG_PARAM, tagName, 0, length)) {
599
					this.tagValue = TAG_PARAM_VALUE;
599
					this.tagValue = TAG_PARAM_VALUE;
600
					valid = parseParam();
600
					valid = parseParam();
601
				}
601
				}
602
				break;
602
				break;
603
			case 'r':
603
			case 'r':
604
				if (length == TAG_RETURN_LENGTH && CharOperation.equals(TAG_RETURN, tagName, 0, length)) {
604
				if (!this.inlineTagStarted && length == TAG_RETURN_LENGTH && CharOperation.equals(TAG_RETURN, tagName, 0, length)) {
605
					this.tagValue = TAG_RETURN_VALUE;
605
					this.tagValue = TAG_RETURN_VALUE;
606
					valid = parseReturn();
606
					valid = parseReturn();
607
				}
607
				}
608
				break;
608
				break;
609
			case 's':
609
			case 's':
610
				if (length == TAG_SEE_LENGTH && CharOperation.equals(TAG_SEE, tagName, 0, length)) {
610
				if (!this.inlineTagStarted) {
611
					if (this.inlineTagStarted) {
611
					if (length == TAG_SEE_LENGTH && CharOperation.equals(TAG_SEE, tagName, 0, length)) {
612
						// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=53290
613
						// Cannot have @see inside inline comment
614
						valid = false;
615
						if (this.reportProblems) {
616
							this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd);
617
						}
618
					} else {
619
						this.tagValue = TAG_SEE_VALUE;
612
						this.tagValue = TAG_SEE_VALUE;
620
						valid = parseReference();
613
						valid = parseReference();
621
					}
614
					} else if (length == TAG_SERIAL_LENGTH && CharOperation.equals(TAG_SERIAL, tagName, 0, length)) {
622
				} else if (length == TAG_SERIAL_LENGTH && CharOperation.equals(TAG_SERIAL, tagName, 0, length)) {
615
						this.tagValue = TAG_SERIAL_VALUE;
623
					this.tagValue = TAG_SERIAL_VALUE;
616
						this.tagWaitingForDescription = this.tagValue;
624
					this.tagWaitingForDescription = this.tagValue;
617
					} else if (length == TAG_SERIAL_DATA_LENGTH && CharOperation.equals(TAG_SERIAL_DATA, tagName, 0, length)) {
625
				} else if (length == TAG_SERIAL_DATA_LENGTH && CharOperation.equals(TAG_SERIAL_DATA, tagName, 0, length)) {
618
						this.tagValue = TAG_SERIAL_DATA_VALUE;
626
					this.tagValue = TAG_SERIAL_DATA_VALUE;
619
						this.tagWaitingForDescription = this.tagValue;
627
					this.tagWaitingForDescription = this.tagValue;
620
					} else if (length == TAG_SERIAL_FIELD_LENGTH && CharOperation.equals(TAG_SERIAL_FIELD, tagName, 0, length)) {
628
				} else if (length == TAG_SERIAL_FIELD_LENGTH && CharOperation.equals(TAG_SERIAL_FIELD, tagName, 0, length)) {
621
						this.tagValue = TAG_SERIAL_FIELD_VALUE;
629
					this.tagValue = TAG_SERIAL_FIELD_VALUE;
622
						this.tagWaitingForDescription = this.tagValue;
630
					this.tagWaitingForDescription = this.tagValue;
623
					} else if (length == TAG_SINCE_LENGTH && CharOperation.equals(TAG_SINCE, tagName, 0, length)) {
631
				} else if (length == TAG_SINCE_LENGTH && CharOperation.equals(TAG_SINCE, tagName, 0, length)) {
624
						this.tagValue = TAG_SINCE_VALUE;
632
					this.tagValue = TAG_SINCE_VALUE;
625
						this.tagWaitingForDescription = this.tagValue;
633
					this.tagWaitingForDescription = this.tagValue;
626
					}					
634
				}
627
				}
635
				break;
628
				break;
636
			case 't':
629
			case 't':
637
				if (length == TAG_THROWS_LENGTH && CharOperation.equals(TAG_THROWS, tagName, 0, length)) {
630
				if (!this.inlineTagStarted && length == TAG_THROWS_LENGTH && CharOperation.equals(TAG_THROWS, tagName, 0, length)) {
638
					this.tagValue = TAG_THROWS_VALUE;
631
					this.tagValue = TAG_THROWS_VALUE;
639
					valid = parseThrows();
632
					valid = parseThrows();
640
				}
633
				}
Lines 664-670 Link Here
664
							if (this.reportProblems) this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd);
657
							if (this.reportProblems) this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd);
665
						}
658
						}
666
					}
659
					}
667
				} else if (length == TAG_VERSION_LENGTH && CharOperation.equals(TAG_VERSION, tagName, 0, length)) {
660
				} else if (!this.inlineTagStarted && length == TAG_VERSION_LENGTH && CharOperation.equals(TAG_VERSION, tagName, 0, length)) {
668
					this.tagValue = TAG_VERSION_VALUE;
661
					this.tagValue = TAG_VERSION_VALUE;
669
					this.tagWaitingForDescription = this.tagValue;
662
					this.tagWaitingForDescription = this.tagValue;
670
				} else {
663
				} else {
Lines 679-684 Link Here
679
		if (this.tagValue != TAG_OTHERS_VALUE && !this.inlineTagStarted) {
672
		if (this.tagValue != TAG_OTHERS_VALUE && !this.inlineTagStarted) {
680
			this.lastBlockTagValue = this.tagValue;
673
			this.lastBlockTagValue = this.tagValue;
681
		}
674
		}
675
		if (this.inlineTagStarted && this.reportProblems
676
				&& (this.tagValue >= JAVADOC_TAG_TYPE.length || JAVADOC_TAG_TYPE[this.tagValue] != TAG_TYPE_INLINE)) {
677
				this.sourceParser.problemReporter().javadocUnexpectedTag(this.tagSourceStart, this.tagSourceEnd);
678
		}
682
		return valid;
679
		return valid;
683
	}
680
	}
684
681
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java (+27 lines)
Lines 170-175 Link Here
170
	public final static int BLOCK_TAGS_LENGTH = BLOCK_TAGS.length;
170
	public final static int BLOCK_TAGS_LENGTH = BLOCK_TAGS.length;
171
	public final static int ALL_TAGS_LENGTH = BLOCK_TAGS_LENGTH+INLINE_TAGS_LENGTH;
171
	public final static int ALL_TAGS_LENGTH = BLOCK_TAGS_LENGTH+INLINE_TAGS_LENGTH;
172
172
173
	public final static short TAG_TYPE_NONE = 0;
174
	public final static short TAG_TYPE_INLINE = 1;
175
	public final static short TAG_TYPE_BLOCK = 2;
176
	
177
	public static final short[] JAVADOC_TAG_TYPE = {
178
		TAG_TYPE_NONE, 		// NO_TAG_VALUE = 0;
179
		TAG_TYPE_BLOCK,		// TAG_DEPRECATED_VALUE = 1;
180
		TAG_TYPE_BLOCK,		// TAG_PARAM_VALUE = 2;
181
		TAG_TYPE_BLOCK,		// TAG_RETURN_VALUE = 3;
182
		TAG_TYPE_BLOCK,		// TAG_THROWS_VALUE = 4;
183
		TAG_TYPE_BLOCK,		// TAG_EXCEPTION_VALUE = 5;
184
		TAG_TYPE_BLOCK,		// TAG_SEE_VALUE = 6;
185
		TAG_TYPE_INLINE,	// TAG_LINK_VALUE = 7;
186
		TAG_TYPE_INLINE,	// TAG_LINKPLAIN_VALUE = 8;
187
		TAG_TYPE_INLINE,	// TAG_INHERITDOC_VALUE = 9;
188
		TAG_TYPE_INLINE,	// TAG_VALUE_VALUE = 10;
189
		TAG_TYPE_BLOCK,		// TAG_CATEGORY_VALUE = 11;
190
		TAG_TYPE_BLOCK,		// TAG_AUTHOR_VALUE = 12;
191
		TAG_TYPE_BLOCK,		// TAG_SERIAL_VALUE = 13;
192
		TAG_TYPE_BLOCK,		// TAG_SERIAL_DATA_VALUE = 14;
193
		TAG_TYPE_BLOCK,		// TAG_SERIAL_FIELD_VALUE = 15;
194
		TAG_TYPE_BLOCK,		// TAG_SINCE_VALUE = 16;
195
		TAG_TYPE_BLOCK,		// TAG_VERSION_VALUE = 17;
196
		TAG_TYPE_INLINE,	// TAG_CODE_VALUE = 18;
197
		TAG_TYPE_INLINE,	// TAG_LITERAL_VALUE = 19;
198
		TAG_TYPE_INLINE		// TAG_DOC_ROOT_VALUE = 20;
199
	};
173
	/*
200
	/*
174
	 * Tags usage
201
	 * Tags usage
175
	 */
202
	 */

Return to bug 267833