void (@NotNull AnActionEvent e) { final Project p = e.getProject(); final String file = Messages.showInputDialog(p, "Enter path to the file comments will be extracted to", "Comments File Path", Messages.getQuestionIcon()); if (file == null) { return; } try (final PrintStream stream = new PrintStream(file)){ stream.println("Comments in " + p.getName()); ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> { final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); ProjectRootManager.getInstance(p).getFileIndex().iterateContent(fileOrDir -> { if (fileOrDir.isDirectory()) { indicator.setText("Extracting comments"); indicator.setText2(fileOrDir.getPresentableUrl()); } scanCommentsInFile(p, fileOrDir); return true; }); indicator.setText2(""); int count = 1; for (CommentDescriptor descriptor : myComments.values()) { stream.println("#" + count + " ---------------------------------------------------------------"); descriptor.print(stream); stream.println(); count++; } }, "Generating Comments", true, p); } catch (Throwable e1) { LOG.error(e1); Messages.showErrorDialog(p, "Error writing? " + e1.getMessage(), "Problem writing"); } }