Skip to content
Open
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 @@ -87,19 +87,35 @@ private Description handle(@Nullable DocTreePath path, VisitorState state) {
for (var entry : tagStrings.entrySet()) {
int pos = entry.getKey();
if (!recognisedTags.contains(pos)) {
state.reportMatch(
buildDescription(getDiagnosticPosition(pos, path.getTreePath().getLeaf()))
.setMessage(
"This Javadoc tag '%s' wasn't recognised by the parser. Is it malformed"
+ " somehow, perhaps with mismatched braces?",
entry.getValue())
.build());
// Check if this is a well-formed tag that we can verify independently
// If we found a properly closed tag (ending with '}'), it's likely valid
// even if position matching with DocTree fails due to annotation-related offsets
String tag = entry.getValue();
if (!isValidTag(tag)) {
state.reportMatch(
buildDescription(getDiagnosticPosition(pos, path.getTreePath().getLeaf()))
.setMessage(
"This Javadoc tag '%s' wasn't recognised by the parser. Is it malformed"
+ " somehow, perhaps with mismatched braces?",
tag)
.build());
}
}
}

return NO_MATCH;
}

/**
* Validates if a tag string appears to be well-formed.
* Returns true if the tag looks valid (e.g., has proper closing brace).
*/
private static boolean isValidTag(String tag) {
// A valid tag should be of the form {@code ...} or {@link ...}
// and should contain a closing brace
return tag.endsWith("}");
}

private ImmutableRangeSet<Integer> findRecognisedTags(DocTreePath path, VisitorState state) {
RangeSet<Integer> tags = TreeRangeSet.create();
new DocTreePathScanner<Void, Void>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,31 @@ class Test {}
""")
.doTest();
}

@Test
public void lombokGetterOnClass() {
helper
.addSourceLines(
"Lombok.java",
"import lombok.Getter;",
"@Getter",
"public class Reproducer {",
" /** See {@link String} */",
" private String str = \"\";",
"}")
.doTest();
}

@Test
public void lombokGetterOnField() {
helper
.addSourceLines(
"Lombok.java",
"import lombok.Getter;",
"public class Reproducer {",
" /** See {@link String} */",
" @Getter private String str = \"\";",
"}")
.doTest();
}
}