BatchExecutionResult (@NotNull ActionContext context, @NotNull ModCommand command) { Project project = context.project(); if (command instanceof ModNothing) { return Result.NOTHING; } if (command instanceof ModUpdateFileText upd) { return executeUpdate(project, upd) ? Result.SUCCESS : Result.ABORT; } if (command instanceof ModCreateFile create) { return executeCreate(project, create) ? Result.SUCCESS : Result.ABORT; } if (command instanceof ModDeleteFile deleteFile) { return executeDelete(project, deleteFile) ? Result.SUCCESS : Result.ABORT; } if (command instanceof ModCompositeCommand cmp) { BatchExecutionResult result = Result.NOTHING; for (ModCommand subCommand : cmp.commands()) { result = result.compose(doExecuteInBatch(context, subCommand)); if (result == Result.ABORT || result instanceof Error) break; } return result; } if (command instanceof ModChooseAction chooser) { return executeChooseInBatch(context, chooser); } if (command instanceof ModChooseMember member) { ModCommand nextCommand = ProgressManager.getInstance().runProcessWithProgressSynchronously( () -> ReadAction.nonBlocking(() -> member.nextCommand().apply(member.defaultSelection())).executeSynchronously(), member.title(), true, context.project()); executeInBatch(context, nextCommand); } if (command instanceof ModNavigate || command instanceof ModHighlight || command instanceof ModCopyToClipboard || command instanceof ModRenameSymbol || command instanceof ModStartTemplate || command instanceof ModUpdateInspectionOptions) { return Result.INTERACTIVE; } if (command instanceof ModShowConflicts showConflicts) { if (showConflicts.conflicts().isEmpty()) { return executeInBatch(context, showConflicts.nextStep()); } return Result.CONFLICTS; } if (command instanceof ModDisplayMessage message) { if (message.kind() == ModDisplayMessage.MessageKind.ERROR) { return new Error(message.messageText()); } return Result.INTERACTIVE; } throw new IllegalArgumentException("Unknown command: " + command); }