List<PsiVariable> (@NotNull PsiStatement statement) { List<PsiVariable> variables = new ArrayList<>(); statement.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitClass(final @NotNull PsiClass aClass) {} @Override public void visitVariable(@NotNull PsiVariable variable) { variables.add(variable); super.visitVariable(variable); } }); return variables; }