Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
/ jdk16 Public archive

Commit

Permalink
8249633: doclint reports missing javadoc for JavaFX property methods …
Browse files Browse the repository at this point in the history
…that have a property description

Reviewed-by: hannesw
  • Loading branch information
jonathan-gibbons committed Jan 6, 2021
1 parent eef43be commit 4f914e2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
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;

Expand Down Expand Up @@ -507,7 +508,10 @@ private void addToPropertiesMap(Element propertyMethod,
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2637,14 +2637,16 @@ public boolean hasBlockTag(Element element, DocTree.Kind kind) {
}

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;
}
}
}
}
Expand Down
58 changes: 57 additions & 1 deletion test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
* @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
* @build javadoc.tester.*
* @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 {
Expand Down Expand Up @@ -366,4 +370,56 @@ public void test4() {
// 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");
}
}

1 comment on commit 4f914e2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.