8249633: doclint reports missing javadoc for JavaFX property methods that have a property description

Reviewed-by: hannesw
This commit is contained in:
Jonathan Gibbons 2021-01-06 19:26:17 +00:00
parent eef43be71c
commit 4f914e21c4
3 changed files with 72 additions and 10 deletions

View File

@ -46,6 +46,7 @@ import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
import jdk.javadoc.internal.doclets.toolkit.CommentUtils;
@ -507,7 +508,10 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
if (null == propertyMethod || null == commentSource) {
return;
}
DocCommentTree docTree = builder.utils.getDocCommentTree(propertyMethod);
Utils utils = builder.utils;
DocCommentTree docTree = utils.hasDocCommentTree(propertyMethod)
? utils.getDocCommentTree(propertyMethod)
: null;
/* The second condition is required for the property buckets. In
* this case the comment is at the property method (not at the field)

View File

@ -2637,14 +2637,16 @@ public class Utils {
}
public boolean hasBlockTag(Element element, DocTree.Kind kind, final String tagName) {
CommentHelper ch = getCommentHelper(element);
String tname = tagName != null && tagName.startsWith("@")
? tagName.substring(1)
: tagName;
for (DocTree dt : getBlockTags(element, kind)) {
if (dt.getKind() == kind) {
if (tname == null || ch.getTagName(dt).equals(tname)) {
return true;
if (hasDocCommentTree(element)) {
CommentHelper ch = getCommentHelper(element);
String tname = tagName != null && tagName.startsWith("@")
? tagName.substring(1)
: tagName;
for (DocTree dt : getBlockTags(element, kind)) {
if (dt.getKind() == kind) {
if (tname == null || ch.getTagName(dt).equals(tname)) {
return true;
}
}
}
}

View File

@ -25,7 +25,7 @@
* @test
* @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363
* 8167967 8172528 8175200 8178830 8182257 8186332 8182765 8025091
* 8203791 8184205
* 8203791 8184205 8249633
* @summary Test of the JavaFX doclet features.
* @library ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@ -33,6 +33,10 @@
* @run main TestJavaFX
*/
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import javadoc.tester.JavadocTester;
public class TestJavaFX extends JavadocTester {
@ -366,4 +370,56 @@ public class TestJavaFX extends JavadocTester {
// make sure the doclet indeed emits the warning
checkOutput(Output.OUT, true, "C.java:0: warning - invalid usage of tag <");
}
/*
* Verify that no warnings are produced on methods that may have synthesized comments.
*/
@Test
public void test5() throws IOException {
Path src5 = Files.createDirectories(Path.of("src5").resolve("pkg"));
Files.writeString(src5.resolve("MyClass.java"),
"""
package pkg;
// The following import not required with --disable-javafx-strict-checks
// import javafx.beans.property.*;
/**
* This is my class.
*/
public class MyClass {
/**
* This is my property that enables something
*/
private BooleanProperty something = new SimpleBooleanProperty(false);
public final boolean isSomething() {
return something.get();
}
public final void setSomething(boolean val) {
something.set(val);
}
public final BooleanProperty somethingProperty() {
return something;
}
/** Dummy declaration. */
public class BooleanProperty { }
}
""");
javadoc("-d", "out5",
"--javafx",
"--disable-javafx-strict-checks",
"-Xdoclint:all",
"--source-path", "src5",
"pkg");
checkExit(Exit.OK);
checkOutput(Output.OUT, false,
"warning",
"no comment");
}
}