8028318: [doclint] doclint will reject existing user-written doc comments using custom tags that follow the recommended rules

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2013-11-25 17:42:28 -08:00
parent 78520efca9
commit 7f2246bbef
4 changed files with 20 additions and 8 deletions

View File

@ -280,7 +280,7 @@ public class DocCommentParser {
try {
nextChar();
if (isIdentifierStart(ch)) {
Name name = readIdentifier();
Name name = readTagName();
TagParser tp = tagParsers.get(name);
if (tp == null) {
List<DCTree> content = blockContent();
@ -329,7 +329,7 @@ public class DocCommentParser {
try {
nextChar();
if (isIdentifierStart(ch)) {
Name name = readIdentifier();
Name name = readTagName();
skipWhitespace();
TagParser tp = tagParsers.get(name);
@ -905,6 +905,14 @@ public class DocCommentParser {
return names.fromChars(buf, start, bp - start);
}
protected Name readTagName() {
int start = bp;
nextChar();
while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '.'))
nextChar();
return names.fromChars(buf, start, bp - start);
}
protected boolean isJavaIdentifierStart(char ch) {
return Character.isJavaIdentifierStart(ch);
}

View File

@ -1,17 +1,18 @@
/*
* @test /nodynamiccopyright/
* @bug 8006248
* @bug 8006248 8028318
* @summary DocLint should report unknown tags
* @build DocLintTester
* @run main DocLintTester CustomTagTest.java
* @run main DocLintTester -XcustomTags: -ref CustomTagTest.out CustomTagTest.java
* @run main DocLintTester -XcustomTags:customTag -ref CustomTagTestWithOption.out CustomTagTest.java
* @run main DocLintTester -XcustomTags:customTag,anotherCustomTag -ref CustomTagTestWithOption.out CustomTagTest.java
* @run main DocLintTester -XcustomTags:customTag,custom.tag -ref CustomTagTestWithOption.out CustomTagTest.java
* @run main DocLintTester -XcustomTags:customTag,custom.tag,anotherCustomTag -ref CustomTagTestWithOption.out CustomTagTest.java
* @author bpatel
*/
/**
* @customTag Text for a custom tag.
* @custom.tag Text for another custom tag.
* @unknownTag Text for an unknown tag.
*/
public class CustomTagTest {

View File

@ -1,8 +1,11 @@
CustomTagTest.java:14: error: unknown tag: customTag
* @customTag Text for a custom tag.
^
CustomTagTest.java:15: error: unknown tag: unknownTag
CustomTagTest.java:15: error: unknown tag: custom.tag
* @custom.tag Text for another custom tag.
^
CustomTagTest.java:16: error: unknown tag: unknownTag
* @unknownTag Text for an unknown tag.
^
2 errors
3 errors

View File

@ -1,4 +1,4 @@
CustomTagTest.java:15: error: unknown tag: unknownTag
CustomTagTest.java:16: error: unknown tag: unknownTag
* @unknownTag Text for an unknown tag.
^
1 error