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

Reviewed-by: bpatel
This commit is contained in:
Jonathan Gibbons 2013-09-24 13:48:12 -07:00
parent e762b2997d
commit 48d1808d53
4 changed files with 27 additions and 2 deletions

View File

@ -730,6 +730,10 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override
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());
if (e == null)
env.messages.error(REFERENCE, tree, "dc.ref.not.found");

View File

@ -67,6 +67,7 @@ dc.tag.self.closing = self-closing element not allowed
dc.tag.start.unmatched = end tag missing: </{0}>
dc.tag.unknown = unknown tag: {0}
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.value.not.allowed.here='{@value}' not allowed here
dc.value.not.a.constant=value does not refer to a constant

View File

@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
* @bug 8004832 8020556
* @bug 8004832 8020556 8002154
* @summary Add new doclint package
* @build DocLintTester
* @run main DocLintTester -Xmsgs:-reference ReferenceTest.java
@ -54,5 +54,13 @@ public class ReferenceTest {
* @throws T description
*/
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() { }
}

View File

@ -25,6 +25,18 @@ ReferenceTest.java:43: error: invalid use of @return
ReferenceTest.java:48: error: exception not thrown: java.lang.Exception
* @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