diff --git a/rewrite-java-test/src/test/java/org/openrewrite/java/search/FindTypesTest.java b/rewrite-java-test/src/test/java/org/openrewrite/java/search/FindTypesTest.java index 5db9f118a71..55f4d06de00 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/java/search/FindTypesTest.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/java/search/FindTypesTest.java @@ -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"); + } + } + """ + ) + ); + } } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/JavadocPrinter.java b/rewrite-java/src/main/java/org/openrewrite/java/JavadocPrinter.java index 01c35f7a801..320f1cd7803 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/JavadocPrinter.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/JavadocPrinter.java @@ -464,18 +464,6 @@ public Space visitSpace(Space space, Space.Location loc, PrintOutputCapture
p
return space;
}
- @Override
- public 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) {
beforeSyntax(Space.EMPTY, lineBreak.getMarkers(), null, p);
p.append(lineBreak.getMargin());