List<PsiStatement> (PsiFile file, int offset) { PsiElement pos = file.findElementAt(offset); PsiStatement statement = PsiTreeUtil.getParentOfType(pos, PsiStatement.class, false, PsiMember.class, PsiCodeBlock.class); if (statement == null) return Collections.emptyList(); return StreamEx.iterate(statement, LoopModel::isAllowedStatement, st -> PsiTreeUtil.getNextSiblingOfType(st, PsiStatement.class)).toList(); }