You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using error_prone_refaster-2.24.1.jar and error_prone_core-2.24.1-with-dependencies.jar to refactor code. I noticed that the block do not get applied in some cases. I'll explain with an example. Here the class that I want to refactor:
import java.util.*;
public class RefasterExample {
public void method1() {
if (true) System.out.println("bad");
if (true) { System.out.println("good"); }
}
public void method2() {
if (true) Arrays.asList("bad");
if (true) { Arrays.asList("good"); }
}
}
However, it only matches the "good" line of method1:
@@ -3,5 +3,5 @@
public void method1() {
if (true) System.out.println("bad");
- if (true) { System.out.println("good"); }
+ if (true) { System.out.println("debug: " + "good"); }
}
When adding a return to the match, the template fails to match altogether. Adding a return to optimizedMethod, but not to match leads to an exception (not sure whether it's worth investigating, as adding the return there does not make much sense).
However, an expression template matches single statements without braces, e.g.,
I'm using
error_prone_refaster-2.24.1.jar
anderror_prone_core-2.24.1-with-dependencies.jar
to refactor code. I noticed that the block do not get applied in some cases. I'll explain with an example. Here the class that I want to refactor:I tried the following template:
However, it only matches the "good" line of method1:
When adding a
return
to thematch
, the template fails to match altogether. Adding areturn
tooptimizedMethod
, but not tomatch
leads to an exception (not sure whether it's worth investigating, as adding the return there does not make much sense).However, an expression template matches single statements without braces, e.g.,
leads to the expected result:
The text was updated successfully, but these errors were encountered: