mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
StreamToLoop: VoidBlockLambdaFunctionHelper: recreate body if invalid (fixes EA-97022 - PIEAE: CompositePsiElement.getContainingFile)
This commit is contained in:
@@ -667,6 +667,9 @@ abstract class FunctionHelper {
|
||||
|
||||
void transform(StreamToLoopReplacementContext context, String... argumentValues) {
|
||||
super.transform(context, argumentValues);
|
||||
if(!myBody.isValid()) {
|
||||
myBody = ((PsiLambdaExpression)context.createExpression("()->"+myBody.getText())).getBody();
|
||||
}
|
||||
List<PsiReturnStatement> returns = getReturns(myBody);
|
||||
String continueStatement = "continue;";
|
||||
returns.forEach(ret -> ret.replace(context.createStatement(continueStatement)));
|
||||
|
||||
@@ -74,4 +74,11 @@ public class Main {
|
||||
}
|
||||
System.out.println(count);
|
||||
}
|
||||
|
||||
void test(List<String> list) {
|
||||
for (String x : list) {
|
||||
if (x.isEmpty()) continue;
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,4 +48,11 @@ public class Main {
|
||||
System.out.println("In flatmap: "+l);
|
||||
})).count());
|
||||
}
|
||||
|
||||
void test(List<String> list) {
|
||||
list.forEach(x -> {
|
||||
if(x.isEmpty()) return;
|
||||
System.out.println(x);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user