List<PsiCodeBlock> (@NotNull PsiFile file) { List<PsiCodeBlock> blocks = new ArrayList<>(); file.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitCodeBlock(@NotNull PsiCodeBlock block) { blocks.add(block); super.visitCodeBlock(block); } }); return blocks; }