void (final Project project, final Collection<VirtualFile> folderPaths, final String outFile, final ProgressIndicator progressIndicator) { final HashSet<String> seenNames = new HashSet<>(); // Collect stuff ApplicationManager.getApplication().runReadAction(() -> { for (VirtualFile folder : folderPaths) { progressIndicator.setText2(SpellCheckerBundle.message("dictionary.generator.scanning.folder.title", folder.getPath())); final PsiManager manager = PsiManager.getInstance(project); processFolder(seenNames, manager, folder); } }); if (seenNames.isEmpty()) { LOG.info(" No new words was found."); return; } final StringBuilder builder = new StringBuilder(); // Sort names final ArrayList<String> names = new ArrayList<>(seenNames); Collections.sort(names); for (String name : names) { if (builder.length() > 0) { builder.append("\n"); } builder.append(name); } final File dictionaryFile = new File(outFile); FileUtil.createIfDoesntExist(dictionaryFile); try (FileWriter writer = new FileWriter(dictionaryFile.getPath())) { writer.write(builder.toString()); } catch (IOException e) { LOG.error(e); } }