Skip to content
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

Fixing duplicate search markers in javaDocs #4503

Merged
merged 1 commit into from
Sep 19, 2024
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 @@ -425,4 +425,36 @@ class B {
java(a1)
);
}

@Test
void javadocComment() {

rewriteRun(
spec -> spec.recipe(new FindTypes("java.lang.String", true)),
java(
"""
public class A {
/**
* JavaDoc comment with {{@link String#trim()}}
* JavaDoc comment with String#trim()
*/
public static String replaceFoo(String string) {
return string.replaceAll("foo", "bar");
}
}
""",
"""
public class A {
/**
* JavaDoc comment with {{@link ~~>String#trim()}}
* JavaDoc comment with String#trim()
*/
public static /*~~>*/String replaceFoo(/*~~>*/String string) {
return string.replaceAll("foo", "bar");
}
}
"""
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,6 @@ public Space visitSpace(Space space, Space.Location loc, PrintOutputCapture<P> p
return space;
}

@Override
public <M extends Marker> M visitMarker(Marker marker, PrintOutputCapture<P> p) {
if (marker instanceof SearchResult) {
String description = ((SearchResult) marker).getDescription();
p.append("~~")
.append(description == null ? "" : "(" + description + ")~~")
.append(">");
}
//noinspection unchecked
return (M) marker;
}

private void visitLineBreak(Javadoc.LineBreak lineBreak, PrintOutputCapture<P> p) {
beforeSyntax(Space.EMPTY, lineBreak.getMarkers(), null, p);
p.append(lineBreak.getMargin());
Expand Down
Loading