Skip to content
Draft
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 @@ -26,6 +26,7 @@
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.Javadoc;
import org.openrewrite.staticanalysis.java.JavaFileChecker;

import java.time.Duration;
import java.util.ArrayList;
Expand All @@ -48,7 +49,9 @@ public class ReplaceDeprecatedRuntimeExecMethods extends Recipe {

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return Preconditions.check(new UsesJavaVersion<>(18), new JavaIsoVisitor<ExecutionContext>() {
return Preconditions.check(
Preconditions.and(new UsesJavaVersion<>(18), new JavaFileChecker<>()),
new JavaIsoVisitor<ExecutionContext>() {
@Override
protected JavadocVisitor<ExecutionContext> getJavadocVisitor() {
return new JavadocVisitor<ExecutionContext>(this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.java.Assertions.version;
import static org.openrewrite.kotlin.Assertions.kotlin;

class ReplaceDeprecatedRuntimeExecMethodsTest implements RewriteTest {
@Override
Expand Down Expand Up @@ -297,6 +298,23 @@ void method() throws IOException {
);
}

@Test
void doNotChangeKotlinFiles() {
rewriteRun(
version(
//language=kotlin
kotlin(
"""
class A {
fun method() {
val process = Runtime.getRuntime().exec("ls -a")
}
}
"""
), 18)
);
}

@Test
void javadoc() {
rewriteRun(
Expand Down
Loading