HashSet<String> (@NotNull PsiDeclarationStatement statement) { HashSet<String> variableNames = new HashSet<>(); Arrays.stream(statement.getDeclaredElements()).forEach(element -> { if (element instanceof PsiLocalVariable) { variableNames.add(((PsiLocalVariable)element).getName()); } }); return variableNames; }