Skip to content

Commit

Permalink
Remove recipe execution cycles
Browse files Browse the repository at this point in the history
Also corrected two illegal test cases (a single `_` is not a legal Java identifier).

See: openrewrite/rewrite#3921
  • Loading branch information
knutwannheden committed Jan 18, 2024
1 parent 62c22af commit ee05113
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

public class AtomicPrimitiveEqualsUsesGet extends Recipe {

public static final Set<String> ATOMIC_PRIMITIVE_TYPES = new HashSet<>(Arrays.asList(
private static final Set<String> ATOMIC_PRIMITIVE_TYPES = new HashSet<>(Arrays.asList(
"java.util.concurrent.atomic.AtomicBoolean",
"java.util.concurrent.atomic.AtomicInteger",
"java.util.concurrent.atomic.AtomicLong"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public String getDescription() {

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return Preconditions.check(new UsesMethod<>(STRING_BUILDER_APPEND), new JavaIsoVisitor<ExecutionContext>() {
return Preconditions.check(new UsesMethod<>(STRING_BUILDER_APPEND), Repeat.repeatUntilStable(new JavaIsoVisitor<ExecutionContext>() {
@Override
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
J.MethodInvocation m = super.visitMethodInvocation(method, ctx);
Expand Down Expand Up @@ -116,7 +116,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu

return m;
}
});
}));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,4 @@ protected boolean shouldSimplifyEqualsOn(@Nullable J j) {
}
};
}

@Override
public boolean causesAnotherCycle() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,5 @@ private boolean hasElseWithComment(J.If.Else else_) {
}
};
}

@Override
public boolean causesAnotherCycle() {
return true;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,4 @@ public Duration getEstimatedEffortPerOccurrence() {
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new UnnecessaryParenthesesVisitor<>();
}

@Override
public boolean causesAnotherCycle() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.ExpectedToFail;
import org.openrewrite.DocumentExample;
import org.openrewrite.Issue;
import org.openrewrite.Recipe;
Expand Down Expand Up @@ -307,15 +306,15 @@ public int testFoo() {

@Issue("https://github.com/openrewrite/rewrite-static-analysis/issues/103")
@Test
void doNotRenameUnderscoreOnly() {
void doNotRenameUnderscoresOnly() {
rewriteRun(
//language=java
java(
"""
class Test {
public int testFoo() {
int _ = 20;
return _;
int __ = 20;
return __;
}
}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,15 @@ class A {

@Issue("https://github.com/openrewrite/rewrite-static-analysis/issues/103")
@Test
void doNotRenameUnderscoreOnly() {
void doNotRenameUnderscoresOnly() {
rewriteRun(
//language=java
java(
"""
class A {
private boolean _;
private boolean __;
public boolean method() {
return _;
return __;
}
}
"""
Expand Down

0 comments on commit ee05113

Please sign in to comment.