private static Set<String> calculateTopLevelDeclarations(
    PsiStatement statement) {
    final Set<String> out = new HashSet<>();
    if (statement instanceof PsiDeclarationStatement) {
      addDeclarations((PsiDeclarationStatement)statement, out);
    }
    else if (statement instanceof PsiBlockStatement blockStatement) {
      final PsiCodeBlock block = blockStatement.getCodeBlock();
      final PsiStatement[] statements = block.getStatements();
      for (PsiStatement statement1 : statements) {
        if (statement1 instanceof PsiDeclarationStatement) {
          addDeclarations((PsiDeclarationStatement)statement1, out);
        }
      }
    }
    return out;
  }
private static Set<String> calculateTopLevelDeclarations(
    PsiStatement statement)