boolean () { try { PsiCodeBlock block = JavaPsiFacade.getElementFactory(myProject).createCodeBlock(); block.addRange(myElements[0], myElements[myElements.length - 1]); ControlFlow flow = ControlFlowFactory.getControlFlow(block, new LocalsControlFlowPolicy(block), ControlFlowOptions.NO_CONST_EVALUATE); return ControlFlowUtil.canCompleteNormally(flow, 0, flow.getSize()); } catch (AnalysisCanceledException e) { //check incomplete code as simple as possible PsiElement lastElement = myElements[myElements.length - 1]; if (!(lastElement instanceof PsiReturnStatement || lastElement instanceof PsiBreakStatement || lastElement instanceof PsiContinueStatement)) { return true; } return false; } }