Skip to content

Commit

Permalink
ShortenFullyQualifiedTypeReferences should not modify Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Apr 22, 2023
1 parent ca1cdbd commit 5eed2ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@ class T {
);
}

@Test
void dontModifyJavadoc() {
rewriteRun(
java(
"""
/**
* See {@link java.util.List}.
*
* @see java.util.List
*/
class T {
}
"""
)
);
}

@Test
void conflictExistingImport() {
rewriteRun(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaSourceFile;
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.Space;

import java.time.Duration;
import java.util.HashMap;
Expand Down Expand Up @@ -99,6 +100,12 @@ public J visitImport(J.Import impoort, ExecutionContext ctx) {
return impoort;
}

@Override
public Space visitSpace(Space space, Space.Location loc, ExecutionContext ctx) {
// stop recursion into Javadoc comments
return space;
}

@Override
public J visitFieldAccess(J.FieldAccess fieldAccess, ExecutionContext ctx) {
JavaType type = fieldAccess.getType();
Expand Down

0 comments on commit 5eed2ba

Please sign in to comment.