StreamApiMigration: check for label not pointing to the statement (Fix for EA-96734 - NPE: TerminalBlock.extractOperation)

This commit is contained in:
Tagir Valeev
2017-02-13 16:14:55 +07:00
parent d4125e81c8
commit 05ccacfa5f
2 changed files with 13 additions and 1 deletions
@@ -59,7 +59,8 @@ class TerminalBlock {
if(statements.length == 1 && statements[0] instanceof PsiBlockStatement) {
statements = ((PsiBlockStatement)statements[0]).getCodeBlock().getStatements();
} else if(statements.length == 1 && statements[0] instanceof PsiLabeledStatement) {
statements = new PsiStatement[] {((PsiLabeledStatement)statements[0]).getStatement()};
PsiStatement statement = ((PsiLabeledStatement)statements[0]).getStatement();
statements = statement == null ? PsiStatement.EMPTY_ARRAY : new PsiStatement[] {statement};
} else break;
}
myStatements = statements;
@@ -0,0 +1,11 @@
// "Fix all 'Loop can be collapsed with Stream API' problems in file" "false"
import java.util.List;
public class Main {
void test(List<String> list) {
for(String l : li<caret>st) {
TEST:
}
}
}