提交 562e9975 编写于 作者: J jjg

8002154: [doclint] doclint should check for issues which are errors in javadoc

Reviewed-by: bpatel
上级 b2489b93
...@@ -730,6 +730,10 @@ public class Checker extends DocTreePathScanner<Void, Void> { ...@@ -730,6 +730,10 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override @Override
public Void visitReference(ReferenceTree tree, Void ignore) { public Void visitReference(ReferenceTree tree, Void ignore) {
String sig = tree.getSignature();
if (sig.contains("<") || sig.contains(">"))
env.messages.error(REFERENCE, tree, "dc.type.arg.not.allowed");
Element e = env.trees.getElement(getCurrentPath()); Element e = env.trees.getElement(getCurrentPath());
if (e == null) if (e == null)
env.messages.error(REFERENCE, tree, "dc.ref.not.found"); env.messages.error(REFERENCE, tree, "dc.ref.not.found");
......
...@@ -67,6 +67,7 @@ dc.tag.self.closing = self-closing element not allowed ...@@ -67,6 +67,7 @@ dc.tag.self.closing = self-closing element not allowed
dc.tag.start.unmatched = end tag missing: </{0}> dc.tag.start.unmatched = end tag missing: </{0}>
dc.tag.unknown = unknown tag: {0} dc.tag.unknown = unknown tag: {0}
dc.text.not.allowed = text not allowed in <{0}> element dc.text.not.allowed = text not allowed in <{0}> element
dc.type.arg.not.allowed = type arguments not allowed here
dc.unexpected.comment=documentation comment not expected here dc.unexpected.comment=documentation comment not expected here
dc.value.not.allowed.here='{@value}' not allowed here dc.value.not.allowed.here='{@value}' not allowed here
dc.value.not.a.constant=value does not refer to a constant dc.value.not.a.constant=value does not refer to a constant
......
/* /*
* @test /nodynamiccopyright/ * @test /nodynamiccopyright/
* @bug 8004832 8020556 * @bug 8004832 8020556 8002154
* @summary Add new doclint package * @summary Add new doclint package
* @build DocLintTester * @build DocLintTester
* @run main DocLintTester -Xmsgs:-reference ReferenceTest.java * @run main DocLintTester -Xmsgs:-reference ReferenceTest.java
...@@ -54,5 +54,13 @@ public class ReferenceTest { ...@@ -54,5 +54,13 @@ public class ReferenceTest {
* @throws T description * @throws T description
*/ */
public <T extends Throwable> void valid_throws_generic() throws T { } public <T extends Throwable> void valid_throws_generic() throws T { }
/**
* {@link java.util.List<String>}
* {@link java.util.List<String>#equals}
* @see java.util.List<String>
* @see java.util.List<String>#equals
*/
public void invalid_type_args() { }
} }
...@@ -25,6 +25,18 @@ ReferenceTest.java:43: error: invalid use of @return ...@@ -25,6 +25,18 @@ ReferenceTest.java:43: error: invalid use of @return
ReferenceTest.java:48: error: exception not thrown: java.lang.Exception ReferenceTest.java:48: error: exception not thrown: java.lang.Exception
* @throws Exception description * @throws Exception description
^ ^
8 errors ReferenceTest.java:59: error: type arguments not allowed here
* {@link java.util.List<String>}
^
ReferenceTest.java:60: error: type arguments not allowed here
* {@link java.util.List<String>#equals}
^
ReferenceTest.java:61: error: type arguments not allowed here
* @see java.util.List<String>
^
ReferenceTest.java:62: error: type arguments not allowed here
* @see java.util.List<String>#equals
^
12 errors
1 warning 1 warning
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册