use of com.intellij.psi.PsiLoopStatement in project intellij-community by JetBrains.
the class MigrateToStreamFix method applyFix.
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement element = descriptor.getPsiElement();
if (element instanceof PsiLoopStatement) {
PsiLoopStatement loopStatement = (PsiLoopStatement) element;
StreamSource source = StreamSource.tryCreate(loopStatement);
PsiStatement body = loopStatement.getBody();
if (body == null || source == null)
return;
TerminalBlock tb = TerminalBlock.from(source, body);
PsiElement result = myMigration.migrate(project, body, tb);
if (result != null) {
tb.operations().forEach(StreamApiMigrationInspection.Operation::cleanUp);
simplifyAndFormat(project, result);
}
}
}
Aggregations