changeset 2203:a78f51d6bd5e

8028318: [doclint] doclint will reject existing user-written doc comments using custom tags that follow the recommended rules Reviewed-by: darcy
author jjg
date Mon, 25 Nov 2013 17:42:28 -0800
parents 7ef88faaa16c
children 3ea55d523981
files src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java test/tools/doclint/CustomTagTest.java test/tools/doclint/CustomTagTest.out test/tools/doclint/CustomTagTestWithOption.out
diffstat 4 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Mon Nov 25 09:41:20 2013 -0800
+++ b/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/test/tools/doclint/CustomTagTest.java	Mon Nov 25 09:41:20 2013 -0800
+++ b/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/test/tools/doclint/CustomTagTest.out	Mon Nov 25 09:41:20 2013 -0800
+++ b/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/test/tools/doclint/CustomTagTestWithOption.out	Mon Nov 25 09:41:20 2013 -0800
+++ b/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