Search in sources :

Example 1 with PsiLoopStatement

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);
        }
    }
}
Also used : PsiStatement(com.intellij.psi.PsiStatement) StreamSource(com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.StreamSource) PsiLoopStatement(com.intellij.psi.PsiLoopStatement) PsiElement(com.intellij.psi.PsiElement)

Aggregations

StreamSource (com.intellij.codeInspection.streamMigration.StreamApiMigrationInspection.StreamSource)1 PsiElement (com.intellij.psi.PsiElement)1 PsiLoopStatement (com.intellij.psi.PsiLoopStatement)1 PsiStatement (com.intellij.psi.PsiStatement)1