Skip to content

Remove source level query from javadoc hint. #8417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,29 +198,25 @@ public boolean isSynthetic(TreePath path) throws NullPointerException {
while (path != null) {
if (isSynthetic(path.getCompilationUnit(), path.getLeaf()))
return true;
if (path.getParentPath() != null &&
path.getParentPath().getParentPath() != null &&
path.getParentPath().getParentPath().getLeaf().getKind() == Kind.NEW_CLASS) {
NewClassTree nct = (NewClassTree) path.getParentPath().getParentPath().getLeaf();
ClassTree body = nct.getClassBody();

if (body != null &&
(body.getExtendsClause() == path.getLeaf() ||
body.getImplementsClause().contains(path.getLeaf()))) {
return true;
}
}
if (path.getLeaf().getKind() == Kind.VARIABLE &&
path.getParentPath() != null &&
path.getParentPath().getLeaf().getKind() == Kind.METHOD &&
path.getParentPath().getParentPath() != null &&
path.getParentPath().getParentPath().getLeaf().getKind() == Kind.RECORD) {
JCMethodDecl m = (JCMethodDecl) path.getParentPath().getLeaf();
if ((m.mods.flags & Flags.COMPACT_RECORD_CONSTRUCTOR) != 0 && m.getParameters().contains(path.getLeaf())) {
return true;
if (path.getParentPath() != null && path.getParentPath().getParentPath() != null) {
TreePath grandpa = path.getParentPath().getParentPath();
if (grandpa.getLeaf().getKind() == Kind.NEW_CLASS) {
NewClassTree nct = (NewClassTree) grandpa.getLeaf();
ClassTree body = nct.getClassBody();
if (body != null &&
(body.getExtendsClause() == path.getLeaf() ||
body.getImplementsClause().contains(path.getLeaf()))) {
return true;
}
} else if (grandpa.getLeaf().getKind() == Kind.RECORD &&
path.getLeaf().getKind() == Kind.VARIABLE &&
path.getParentPath().getLeaf().getKind() == Kind.METHOD) {
JCMethodDecl m = (JCMethodDecl) path.getParentPath().getLeaf();
if ((m.mods.flags & Flags.COMPACT_RECORD_CONSTRUCTOR) != 0 && m.getParameters().contains(path.getLeaf())) {
return true;
}
}
}

path = path.getParentPath();
}

Expand Down
20 changes: 7 additions & 13 deletions java/javadoc/src/org/netbeans/modules/javadoc/hints/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.MethodTree;
import com.sun.source.tree.ThrowTree;
import com.sun.source.tree.Tree;
import com.sun.source.util.DocSourcePositions;
import com.sun.source.util.DocTreePath;
import com.sun.source.util.DocTreePathScanner;
import com.sun.source.util.TreePath;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
Expand All @@ -69,15 +67,13 @@
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Name;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import org.netbeans.api.java.source.CompilationInfo;
Expand All @@ -93,7 +89,6 @@
import org.netbeans.modules.html.editor.lib.api.model.HtmlTag;
import org.netbeans.modules.html.editor.lib.api.model.HtmlTagType;
import static org.netbeans.modules.javadoc.hints.Bundle.*;
import static org.netbeans.modules.javadoc.hints.JavadocUtilities.resolveSourceVersion;
import org.netbeans.spi.editor.hints.ErrorDescription;
import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
import org.netbeans.spi.java.hints.HintContext;
Expand All @@ -118,21 +113,21 @@
* @author Jan Pokorsky
* @author Ralph Benjamin Ruijs
*/
@NbBundle.Messages({"MISSING_RETURN_DESC=Missing @return tag.",
"# {0} - @param name", "MISSING_PARAM_DESC=Missing @param tag for {0}"})
@NbBundle.Messages({"MISSING_RETURN_DESC=Missing @return tag.",
"# {0} - @param name",
"MISSING_PARAM_DESC=Missing @param tag for {0}"})
final class Analyzer extends DocTreePathScanner<Void, List<ErrorDescription>> {

private static final HtmlModel model = HtmlModelFactory.getModel(HtmlVersion.XHTML5);

private final CompilationInfo javac;
private final FileObject file;
private final TreePath currentPath;
private final SourceVersion sourceVersion;
private final Access access;

private Deque<StartElementTree> tagStack = new LinkedList<>();
private Set<Element> foundParams = new HashSet<>();
private Set<TypeMirror> foundThrows = new HashSet<>();
private final Deque<StartElementTree> tagStack = new LinkedList<>();
private final Set<Element> foundParams = new HashSet<>();
private final Set<TypeMirror> foundThrows = new HashSet<>();
private TypeMirror returnType = null;
private boolean returnTypeFound = false;
private boolean foundInheritDoc = false;
Expand All @@ -143,7 +138,6 @@ final class Analyzer extends DocTreePathScanner<Void, List<ErrorDescription>> {
this.javac = javac;
this.file = javac.getFileObject();
this.currentPath = currentPath;
this.sourceVersion = resolveSourceVersion(javac.getFileObject());
this.access = access;
this.ctx = ctx;
}
Expand Down Expand Up @@ -814,7 +808,7 @@ private static HtmlTag getTag(Name tagName) {
return t.getTagClass() == HtmlTagType.HTML ? t : null;
}

private static final Set<String> NON_VOID_TAGS = new HashSet<>(Arrays.asList("menuitem", "noscript", "script", "style"));
private static final Set<String> NON_VOID_TAGS = Set.of("menuitem", "noscript", "script", "style");

private boolean isVoid(HtmlTag tag) {
return tag.isEmpty() && !NON_VOID_TAGS.contains(tag.getName());
Expand Down
Loading