List<PsiFile> (@NotNull Collection<PsiFile> files, @NotNull PsiDirectory directory, @Nullable Map<PsiFile, String> relativePaths, @Nullable String className) { SkipOverwriteChoice choice = SkipOverwriteChoice.OVERWRITE; List<PsiFile> filesToProcess = new ArrayList<>(); for (PsiFile file : files) { final String relativePath = relativePaths != null ? relativePaths.get(file) : null; final PsiDirectory targetDirectory = buildRelativeDir(directory, relativePath).getTargetDirectory(); final String fileName = getNewFileName(file, className); final PsiFile existingFile = targetDirectory != null ? targetDirectory.findFile(fileName) : null; if (existingFile != null) { if (choice != SkipOverwriteChoice.SKIP_ALL && choice != SkipOverwriteChoice.OVERWRITE_ALL) { String message = ExecutionBundle.message("copy.classes.command.name"); choice = SkipOverwriteChoice.askUser(targetDirectory, fileName, message, files.size() > 1); } } if (existingFile == null || choice == SkipOverwriteChoice.OVERWRITE || choice == SkipOverwriteChoice.OVERWRITE_ALL) { if (existingFile != file) filesToProcess.add(file); } } return filesToProcess; }