void (@NotNull final VirtualFile file) { ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(List.of(file)); if (status.hasReadonlyFiles()) { return; } Consumer<@NotNull ProgressIndicator> runnable = (indicator) -> { indicator.setText(myProgressText); try { new ProcessingTask(indicator).performFileProcessing(file); } catch (IndexNotReadyException e) { LOG.warn(e); return; } if (myPostRunnable != null) { ApplicationManager.getApplication().invokeLater(myPostRunnable); } }; if (ApplicationManager.getApplication().isHeadlessEnvironment()) { ProgressManager.getInstance().run(new Task.Modal(myProject, getProgressTitle(), true) { @Override public void run(@NotNull ProgressIndicator indicator) { runnable.accept(indicator); } }); } else { ProgressManager.getInstance().run(new Task.Backgroundable(myProject, getProgressTitle(), true) { @Override public void run(@NotNull ProgressIndicator indicator) { runnable.accept(indicator); } }); } }