Skip to content

Commit

Permalink
Do not register a conflict for qualified method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Aug 18, 2024
1 parent 41135d4 commit 8e001a9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method,
new JavaIsoVisitor<AtomicBoolean>() {
@Override
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, AtomicBoolean atomicBoolean) {
if (method.getName().getSimpleName().equals(newMethodName)) {
if (method.getName().getSimpleName().equals(newMethodName) && method.getSelect() == null) {
skip.set(true);
}
return super.visitMethodInvocation(method, atomicBoolean);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void tests() {

@Test
@Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/258")
void removeTestPrefixWithClashingMethod() {
void ignoreWhenStaticImportConflicts() {
rewriteRun(
//language=java
java(
Expand All @@ -345,4 +345,36 @@ void testOf() {
)
);
}

@Test
@Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/258")
void removeOnQualifiedMethodDespiteConflict() {
rewriteRun(
//language=java
java(
"""
import org.junit.jupiter.api.Test;
import java.util.List;
class FooTest {
@Test
void testOf() {
List.of();
}
}
""",
"""
import org.junit.jupiter.api.Test;
import java.util.List;
class FooTest {
@Test
void of() {
List.of();
}
}
"""
)
);
}
}

0 comments on commit 8e001a9

Please sign in to comment.