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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (-2 / +109 lines)
Lines 3083-3089 Link Here
3083
			"}\n"
3083
			"}\n"
3084
		};
3084
		};
3085
		reportInvalidJavadoc = CompilerOptions.WARNING;
3085
		reportInvalidJavadoc = CompilerOptions.WARNING;
3086
		reportMissingJavadocDescription = CompilerOptions.ALL_TAGS;
3086
		reportMissingJavadocDescription = CompilerOptions.ALL_STANDARD_TAGS;
3087
		runNegativeTest(units,
3087
		runNegativeTest(units,
3088
				"----------\n" + 
3088
				"----------\n" + 
3089
				"1. WARNING in X.java (at line 2)\n" + 
3089
				"1. WARNING in X.java (at line 2)\n" + 
Lines 3180-3186 Link Here
3180
			"}\n"
3180
			"}\n"
3181
		};
3181
		};
3182
		reportInvalidJavadoc = CompilerOptions.WARNING;
3182
		reportInvalidJavadoc = CompilerOptions.WARNING;
3183
		reportMissingJavadocDescription = CompilerOptions.ALL_TAGS;
3183
		reportMissingJavadocDescription = CompilerOptions.ALL_STANDARD_TAGS;
3184
		runConformTest(units);
3184
		runConformTest(units);
3185
	}
3185
	}
3186
	public void testBug73352c() {
3186
	public void testBug73352c() {
Lines 6936-6939 Link Here
6936
				"Javadoc: Malformed reference (missing end space separator)\n" + 
6936
				"Javadoc: Malformed reference (missing end space separator)\n" + 
6937
				"----------\n");
6937
				"----------\n");
6938
	}
6938
	}
6939
	/**
6940
	 * @bug 222902: [Javadoc] Missing description should not be warned in some cases
6941
	 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=222902"
6942
	 */
6943
	public void testBug222902() {
6944
		String[] units = new String[] {
6945
			"X.java",			
6946
			"/**\n" +
6947
			" * @author\n" +
6948
			" * {@code}\n" +
6949
			" * @deprecated\n" +
6950
			" * {@literal}\n" +
6951
			" * @since\n" +
6952
			" * @version\n" +
6953
			" * @generated\n" + // should not get a warning for missing description on non-standard tag
6954
			" * @code\n" + // should not get a warning for non-inlined tag @code
6955
			" * @literal\n" + // should not get a warning for non-inlined tag @literal
6956
			"*/\n" +
6957
			"public class X {\n" +
6958
			"	/**\n" +
6959
			"	 * @param  aParam\n" +
6960
			"	 * @return\n" +
6961
			"	 * @throws NullPointerException\n" +
6962
			"	 * @exception NullPointerException\n" +
6963
			"	 */\n" +
6964
			"	public String foo(String aParam) {\n" +
6965
			"		return new String();\n" +
6966
			"	}\n" +
6967
			"	/**\n" +
6968
			"	 * @serial\n" +
6969
			"	 * @serialData\n" +
6970
			"	 * @serialField\n" +
6971
			"	 */\n" +
6972
			"	Object field;\n" +
6973
			"}\n"
6974
		};
6975
		reportInvalidJavadoc = CompilerOptions.WARNING;
6976
		reportMissingJavadocDescription = CompilerOptions.ALL_STANDARD_TAGS;
6977
		runNegativeTest(units,
6978
			"----------\n" + 
6979
			"1. WARNING in X.java (at line 2)\n" + 
6980
			"	* @author\n" + 
6981
			"	   ^^^^^^\n" + 
6982
			"Javadoc: Description expected after @author\n" + 
6983
			"----------\n" + 
6984
			"2. WARNING in X.java (at line 3)\n" + 
6985
			"	* {@code}\n" + 
6986
			"	    ^^^^\n" + 
6987
			"Javadoc: Description expected after @code\n" + 
6988
			"----------\n" + 
6989
			"3. WARNING in X.java (at line 4)\n" + 
6990
			"	* @deprecated\n" + 
6991
			"	   ^^^^^^^^^^\n" + 
6992
			"Javadoc: Description expected after @deprecated\n" + 
6993
			"----------\n" + 
6994
			"4. WARNING in X.java (at line 5)\n" + 
6995
			"	* {@literal}\n" + 
6996
			"	    ^^^^^^^\n" + 
6997
			"Javadoc: Description expected after @literal\n" + 
6998
			"----------\n" + 
6999
			"5. WARNING in X.java (at line 6)\n" + 
7000
			"	* @since\n" + 
7001
			"	   ^^^^^\n" + 
7002
			"Javadoc: Description expected after @since\n" + 
7003
			"----------\n" + 
7004
			"6. WARNING in X.java (at line 7)\n" + 
7005
			"	* @version\n" + 
7006
			"	   ^^^^^^^\n" + 
7007
			"Javadoc: Description expected after @version\n" + 
7008
			"----------\n" + 
7009
			"7. WARNING in X.java (at line 14)\n" + 
7010
			"	* @param  aParam\n" + 
7011
			"	          ^^^^^^\n" + 
7012
			"Javadoc: Description expected after this reference\n" + 
7013
			"----------\n" + 
7014
			"8. WARNING in X.java (at line 15)\n" + 
7015
			"	* @return\n" + 
7016
			"	   ^^^^^^\n" + 
7017
			"Javadoc: Description expected after @return\n" + 
7018
			"----------\n" + 
7019
			"9. WARNING in X.java (at line 16)\n" + 
7020
			"	* @throws NullPointerException\n" + 
7021
			"	          ^^^^^^^^^^^^^^^^^^^^\n" + 
7022
			"Javadoc: Description expected after this reference\n" + 
7023
			"----------\n" + 
7024
			"10. WARNING in X.java (at line 17)\n" + 
7025
			"	* @exception NullPointerException\n" + 
7026
			"	             ^^^^^^^^^^^^^^^^^^^^\n" + 
7027
			"Javadoc: Description expected after this reference\n" + 
7028
			"----------\n" + 
7029
			"11. WARNING in X.java (at line 23)\n" + 
7030
			"	* @serial\n" + 
7031
			"	   ^^^^^^\n" + 
7032
			"Javadoc: Description expected after @serial\n" + 
7033
			"----------\n" + 
7034
			"12. WARNING in X.java (at line 24)\n" + 
7035
			"	* @serialData\n" + 
7036
			"	   ^^^^^^^^^^\n" + 
7037
			"Javadoc: Description expected after @serialData\n" + 
7038
			"----------\n" + 
7039
			"13. WARNING in X.java (at line 25)\n" + 
7040
			"	* @serialField\n" + 
7041
			"	   ^^^^^^^^^^^\n" + 
7042
			"Javadoc: Description expected after @serialField\n" + 
7043
			"----------\n"
7044
		);
7045
	}	
6939
}
7046
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java (+16 lines)
Lines 52-57 Link Here
52
	public static final int TAG_INHERITDOC_LENGTH = TAG_INHERITDOC.length;
52
	public static final int TAG_INHERITDOC_LENGTH = TAG_INHERITDOC.length;
53
	public static final int TAG_VALUE_LENGTH = TAG_VALUE.length;
53
	public static final int TAG_VALUE_LENGTH = TAG_VALUE.length;
54
	public static final int TAG_CATEGORY_LENGTH = TAG_CATEGORY.length;
54
	public static final int TAG_CATEGORY_LENGTH = TAG_CATEGORY.length;
55
	public static final int TAG_AUTHOR_LENGTH = TAG_AUTHOR.length;
56
	public static final int TAG_SERIAL_LENGTH = TAG_SERIAL.length;
57
	public static final int TAG_SERIAL_DATA_LENGTH = TAG_SERIAL_DATA.length;
58
	public static final int TAG_SERIAL_FIELD_LENGTH = TAG_SERIAL_FIELD.length;
59
	public static final int TAG_SINCE_LENGTH = TAG_SINCE.length;
60
	public static final int TAG_VERSION_LENGTH = TAG_VERSION.length;
61
	public static final int TAG_CODE_LENGTH = TAG_CODE.length;
62
	public static final int TAG_LITERAL_LENGTH = TAG_LITERAL.length;
55
63
56
64
57
	// tags value
65
	// tags value
Lines 67-72 Link Here
67
	public static final int TAG_INHERITDOC_VALUE = 9;
75
	public static final int TAG_INHERITDOC_VALUE = 9;
68
	public static final int TAG_VALUE_VALUE = 10;
76
	public static final int TAG_VALUE_VALUE = 10;
69
	public static final int TAG_CATEGORY_VALUE = 11;
77
	public static final int TAG_CATEGORY_VALUE = 11;
78
	public static final int TAG_AUTHOR_VALUE = 12;
79
	public static final int TAG_SERIAL_VALUE = 13;
80
	public static final int TAG_SERIAL_DATA_VALUE = 14;
81
	public static final int TAG_SERIAL_FIELD_VALUE = 15;
82
	public static final int TAG_SINCE_VALUE = 16;
83
	public static final int TAG_VERSION_VALUE = 17;
84
	public static final int TAG_CODE_VALUE = 18;
85
	public static final int TAG_LITERAL_VALUE = 19;
70
	public static final int TAG_OTHERS_VALUE = 100;
86
	public static final int TAG_OTHERS_VALUE = 100;
71
	
87
	
72
	// tags expected positions
88
	// tags expected positions
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java (-2 / +21 lines)
Lines 483-497 Link Here
483
		this.scanner.currentPosition = this.tagSourceEnd+1;
483
		this.scanner.currentPosition = this.tagSourceEnd+1;
484
	
484
	
485
		// Decide which parse to perform depending on tag name
485
		// Decide which parse to perform depending on tag name
486
		this.tagValue = NO_TAG_VALUE;
486
		this.tagValue = TAG_OTHERS_VALUE;
487
		boolean alreadyParsedTag = false;
487
		boolean alreadyParsedTag = false;
488
		switch (token) {
488
		switch (token) {
489
			case TerminalTokens.TokenNameIdentifier :
489
			case TerminalTokens.TokenNameIdentifier :
490
				switch (tagName[0]) {
490
				switch (tagName[0]) {
491
					case 'a':
492
						if (length == TAG_AUTHOR_LENGTH && CharOperation.equals(TAG_AUTHOR, tagName)) {
493
							this.tagValue = TAG_AUTHOR_VALUE;
494
						}
495
						break;
491
					case 'c':
496
					case 'c':
492
						if (length == TAG_CATEGORY_LENGTH && CharOperation.equals(TAG_CATEGORY, tagName)) {
497
						if (length == TAG_CATEGORY_LENGTH && CharOperation.equals(TAG_CATEGORY, tagName)) {
493
							this.tagValue = TAG_CATEGORY_VALUE;
498
							this.tagValue = TAG_CATEGORY_VALUE;
494
							valid = parseIdentifierTag(false); // TODO (frederic) reconsider parameter value when @category will be significant in spec
499
							valid = parseIdentifierTag(false); // TODO (frederic) reconsider parameter value when @category will be significant in spec
500
						} else if (length == TAG_CODE_LENGTH && this.inlineTagStarted && CharOperation.equals(TAG_CODE, tagName)) {
501
							this.tagValue = TAG_CODE_VALUE;
495
						}
502
						}
496
						break;
503
						break;
497
					case 'd':
504
					case 'd':
Lines 547-552 Link Here
547
								}
554
								}
548
							}
555
							}
549
							alreadyParsedTag = true;
556
							alreadyParsedTag = true;
557
						} else if (length == TAG_LITERAL_LENGTH && this.inlineTagStarted && CharOperation.equals(TAG_LITERAL, tagName)) {
558
							this.tagValue = TAG_LITERAL_VALUE;
550
						}
559
						}
551
						break;
560
						break;
552
					case 'p':
561
					case 'p':
Lines 570-575 Link Here
570
								valid = parseReference();
579
								valid = parseReference();
571
							}
580
							}
572
							alreadyParsedTag = true;
581
							alreadyParsedTag = true;
582
						} else if (length == TAG_SERIAL_LENGTH && CharOperation.equals(TAG_SERIAL, tagName)) {
583
							this.tagValue = TAG_SERIAL_VALUE;
584
						} else if (length == TAG_SERIAL_DATA_LENGTH && CharOperation.equals(TAG_SERIAL_DATA, tagName)) {
585
							this.tagValue = TAG_SERIAL_DATA_VALUE;
586
						} else if (length == TAG_SERIAL_FIELD_LENGTH && CharOperation.equals(TAG_SERIAL_FIELD, tagName)) {
587
							this.tagValue = TAG_SERIAL_FIELD_VALUE;
588
						} else if (length == TAG_SINCE_LENGTH && CharOperation.equals(TAG_SINCE, tagName)) {
589
							this.tagValue = TAG_SINCE_VALUE;
573
						}
590
						}
574
						break;
591
						break;
575
					case 'v':
592
					case 'v':
Lines 598-603 Link Here
598
								}
615
								}
599
							}
616
							}
600
							alreadyParsedTag = true;
617
							alreadyParsedTag = true;
618
						} else if (length == TAG_VERSION_LENGTH && CharOperation.equals(TAG_VERSION, tagName)) {
619
							this.tagValue = TAG_VERSION_VALUE;
601
						} else {
620
						} else {
602
							createTag();
621
							createTag();
603
						}
622
						}
Lines 627-633 Link Here
627
				break;
646
				break;
628
		}
647
		}
629
		this.textStart = this.index;
648
		this.textStart = this.index;
630
		if (! alreadyParsedTag && this.reportProblems && verifyEndLine(this.scanner.currentPosition)) {
649
		if (this.tagValue != TAG_OTHERS_VALUE && ! alreadyParsedTag && this.reportProblems && verifyEndLine(this.scanner.currentPosition)) {
631
			this.sourceParser.problemReporter().javadocMissingTagDescription(tagName, this.tagSourceStart, this.tagSourceEnd, this.sourceParser.modifiers);
650
			this.sourceParser.problemReporter().javadocMissingTagDescription(tagName, this.tagSourceStart, this.tagSourceEnd, this.sourceParser.modifiers);
632
			return false;
651
			return false;
633
		}
652
		}
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-1 / +1 lines)
Lines 1135-1141 Link Here
1135
			}
1135
			}
1136
			break;
1136
			break;
1137
		case IProblem.JavadocMissingTagDescription:
1137
		case IProblem.JavadocMissingTagDescription:
1138
			if (! CompilerOptions.ALL_TAGS.equals(this.options.reportMissingJavadocTagDescription)) {
1138
			if (! CompilerOptions.ALL_STANDARD_TAGS.equals(this.options.reportMissingJavadocTagDescription)) {
1139
				return ProblemSeverities.Ignore;
1139
				return ProblemSeverities.Ignore;
1140
			}
1140
			}
1141
			break;
1141
			break;
(-)model/org/eclipse/jdt/core/JavaCore.java (-3 / +10 lines)
Lines 1090-1101 Link Here
1090
	public static final String COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$
1090
	public static final String COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY = PLUGIN_ID + ".compiler.problem.invalidJavadocTagsVisibility"; //$NON-NLS-1$
1091
	/**
1091
	/**
1092
	 * Compiler option ID: Reporting missing tag description.
1092
	 * Compiler option ID: Reporting missing tag description.
1093
	 * <p>When enabled, the compiler will report a warning or an error for any Javadoc missing a required description.
1093
	 * <p>When enabled, the compiler will report a warning or an error for any Javadoc tag missing a required description.
1094
	 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_INVALID_JAVADOC}.
1094
	 * <p>The severity of the problem is controlled with option {@link #COMPILER_PB_INVALID_JAVADOC}.
1095
	 * <p>This option is NOT dependent from the Report errors in tags option.
1095
	 * <p>This option is NOT dependent from the Report errors in tags option.
1096
	 * <p>The initial set of standard tags is a subset of the <a href="http://java.sun.com/javase/6/docs/technotes/tools/windows/javadoc.html#javadoctags">Javadoc tags</a>
1097
	 *       that have a description, text or label. This set may grow in the future. User defined tags are thus not included in the standard tags.
1096
	 * <dl>
1098
	 * <dl>
1097
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription"</code></dd>
1099
	 * <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription"</code></dd>
1098
	 * <dt>Possible values:</dt><dd><code>{ "return_tag", "all_tags", "no_tag" }</code></dd>
1100
	 * <dt>Possible values:</dt><dd><code>{ "return_tag", "all_standard_tags", "no_tag" }</code></dd>
1099
	 * <dt>Default:</dt><dd><code>"return_tag"</code></dd>
1101
	 * <dt>Default:</dt><dd><code>"return_tag"</code></dd>
1100
	 * </dl>
1102
	 * </dl>
1101
	 * @since 3.4
1103
	 * @since 3.4
Lines 2135-2141 Link Here
2135
	 * @since 3.4
2137
	 * @since 3.4
2136
	 * @category OptionValue
2138
	 * @category OptionValue
2137
	 */
2139
	 */
2138
	public static final String COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_TAGS = CompilerOptions.ALL_TAGS;
2140
	public static final String COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_STANDARD_TAGS = CompilerOptions.ALL_STANDARD_TAGS;
2141
	/**
2142
	 * @deprecated use {@link #COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_STANDARD_TAGS} instead
2143
	 * TODO: remove before 3.4M6
2144
	 */
2145
	public static final String COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_TAGS = CompilerOptions.ALL_STANDARD_TAGS;
2139
	// end configurable option values }
2146
	// end configurable option values }
2140
2147
2141
	/**
2148
	/**
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (-1 / +1 lines)
Lines 152-158 Link Here
152
	public static final String PRIVATE = "private";	//$NON-NLS-1$
152
	public static final String PRIVATE = "private";	//$NON-NLS-1$
153
	public static final String RETURN_TAG = "return_tag";	//$NON-NLS-1$
153
	public static final String RETURN_TAG = "return_tag";	//$NON-NLS-1$
154
	public static final String NO_TAG = "no_tag";	//$NON-NLS-1$
154
	public static final String NO_TAG = "no_tag";	//$NON-NLS-1$
155
	public static final String ALL_TAGS = "all_tags";	//$NON-NLS-1$
155
	public static final String ALL_STANDARD_TAGS = "all_standard_tags";	//$NON-NLS-1$
156
156
157
	/**
157
	/**
158
	 * Bit mask for configurable problems (error/warning threshold)
158
	 * Bit mask for configurable problems (error/warning threshold)

Return to bug 222902