TerminalBlock () { PsiStatement single = getSingleStatement(); if (single instanceof PsiIfStatement) { PsiIfStatement ifStatement = (PsiIfStatement)single; PsiExpression condition = ifStatement.getCondition(); if(ifStatement.getElseBranch() == null && condition != null) { PsiStatement thenBranch = ifStatement.getThenBranch(); if(thenBranch != null) { return fromCondition(condition, false, thenBranch); } } } if(myStatements.length >= 1) { PsiStatement first = myStatements[0]; // extract filter with negation if(first instanceof PsiIfStatement ifStatement) { PsiExpression condition = ifStatement.getCondition(); if(condition == null) return null; PsiStatement branch = ifStatement.getThenBranch(); if(branch instanceof PsiBlockStatement) { PsiStatement[] statements = ((PsiBlockStatement)branch).getCodeBlock().getStatements(); if(statements.length == 1) branch = statements[0]; } if(!(branch instanceof PsiContinueStatement) || ((PsiContinueStatement)branch).getLabelIdentifier() != null) return null; PsiStatement[] statements; if(ifStatement.getElseBranch() != null) { statements = myStatements.clone(); statements[0] = ifStatement.getElseBranch(); } else { statements = Arrays.copyOfRange(myStatements, 1, myStatements.length); } return fromCondition(condition, true, statements); } } return null; }