8028318: [doclint] doclint will reject existing user-written doc comments using custom tags that follow the recommended rules
Reviewed-by: darcy
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Mon Nov 25 09:41:20 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Mon Nov 25 17:42:28 2013 -0800
@@ -280,7 +280,7 @@
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 @@
try {
nextChar();
if (isIdentifierStart(ch)) {
- Name name = readIdentifier();
+ Name name = readTagName();
skipWhitespace();
TagParser tp = tagParsers.get(name);
@@ -905,6 +905,14 @@
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);
}
--- a/langtools/test/tools/doclint/CustomTagTest.java Mon Nov 25 09:41:20 2013 -0800
+++ b/langtools/test/tools/doclint/CustomTagTest.java Mon Nov 25 17:42:28 2013 -0800
@@ -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 {
--- a/langtools/test/tools/doclint/CustomTagTest.out Mon Nov 25 09:41:20 2013 -0800
+++ b/langtools/test/tools/doclint/CustomTagTest.out Mon Nov 25 17:42:28 2013 -0800
@@ -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
--- a/langtools/test/tools/doclint/CustomTagTestWithOption.out Mon Nov 25 09:41:20 2013 -0800
+++ b/langtools/test/tools/doclint/CustomTagTestWithOption.out Mon Nov 25 17:42:28 2013 -0800
@@ -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