void (@NotNull AnActionEvent e) { VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); if (files == null) { return; } List<VirtualFile> filesToProcess = getFilesWithBom(files); if (filesToProcess.isEmpty()) return; List<VirtualFile> filesUnableToProcess = new ArrayList<>(); new Task.Backgroundable(getEventProject(e), IdeBundle.message("removing.BOM"), true, PerformInBackgroundOption.DEAF) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(false); for (int i = 0; i < filesToProcess.size(); i++) { ProgressManager.checkCanceled(); VirtualFile virtualFile = filesToProcess.get(i); indicator.setFraction(i*1.0/filesToProcess.size()); indicator.setText2(StringUtil.shortenPathWithEllipsis(virtualFile.getPresentableUrl(), 40)); byte[] bom = virtualFile.getBOM(); if (bom != null) { if (isBOMMandatory(virtualFile) ) { filesUnableToProcess.add(virtualFile); } else { doRemoveBOM(virtualFile, bom); } } } if (!filesUnableToProcess.isEmpty()) { String title = IdeBundle.message("notification.title.was.unable.to.remove.bom.in", filesUnableToProcess.size()); String msg = IdeBundle.message("notification.content.mandatory.bom.br", filesUnableToProcess.size(), StringUtil.join(filesUnableToProcess, VirtualFile::getName, "<br/> ")); NotificationGroup group = NotificationGroupManager.getInstance().getNotificationGroup("Failed to remove BOM"); Notifications.Bus.notify(group.createNotification(title, msg, NotificationType.ERROR)); } } }.queue(); }