@Internal public class IfStatementRewriter extends Object implements CodeRewriter
This rewriter only deals with functions without return values. Functions with return values
should have been converted by ReturnValueRewriter. Also, this rewriter will not extract
blocks containing return statements for correctness.
Before
public class Example {
int b;
public void myFun(int a) {
if (a > 0) {
b = a * 2;
System.out.println(b);
} else {
b = a * 3;
System.out.println(b);
}
}
}
After
public class Example {
int b;
public void myFun(int a) {
if (a > 0) {
myFun_trueFilter1(a);
} else {
myFun_falseFilter2(a);
}
}
void myFun_trueFilter1(int a) {
b = a * 2;
System.out.println(b);
}
void myFun_falseFilter2(int a) {
b = a * 3;
System.out.println(b);
}
}
public IfStatementRewriter(String code, long maxMethodLength)
public String rewrite()
rewrite 在接口中 CodeRewriterCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.