private static void addDeclarations(PsiDeclarationStatement statement,
                                      Collection<? super String> declaredVariables) {
    final PsiElement[] elements = statement.getDeclaredElements();
    for (final PsiElement element : elements) {
      if (element instanceof PsiVariable variable) {
        final String name = variable.getName();
        declaredVariables.add(name);
      }
    }
  }
private static void addDeclarations(PsiDeclarationStatement statement,
                                      Collection<? super String> declaredVariables)