IntentionAction (@NotNull Collection<? extends IntentionAction> actions, @Nullable ActionContext context, @NotNull Supplier<String> infoSupplier) { String[] steps = myExpectedText.split("\\|->"); CommonIntentionAction found = null; Collection<? extends CommonIntentionAction> commonActions = actions; for (int i = 0; i < steps.length; i++) { String curStep = steps[i]; found = ContainerUtil.find(commonActions, t -> { String text = getActionText(context, t); return myExactMatch ? text.equals(curStep) : text.startsWith(curStep); }); if (i == steps.length - 1) break; if (context == null) { fail("Action context is not supplied"); } if (found == null) { fail(exceptionHeader(curStep) + " not found\nAvailable actions: " + commonActions.stream().map(act -> getActionText(context, act)).collect(Collectors.joining(", ", "[", "]\n")) + infoSupplier.get()); } ModCommandAction action = found.asModCommandAction(); if (action == null) { fail(exceptionHeader(curStep) + " is not ModCommandAction"); } ModCommand command = action.perform(context); if (!(command instanceof ModChooseAction chooseAction)) { fail(exceptionHeader(curStep) + " does not produce a chooser"); return null; } commonActions = chooseAction.actions(); } IntentionAction result = found == null ? null : found.asIntention(); String lastStep = steps[steps.length - 1]; if(myShouldPresent) { if(result == null) { fail(exceptionHeader(lastStep) + " not found\nAvailable actions: " + actions.stream().map(IntentionAction::getText).collect(Collectors.joining(", ", "[", "]\n")) + infoSupplier.get()); } else if(myHighlightType != null) { result = IntentionActionDelegate.unwrap(result); ProblemHighlightType actualType = QuickFixWrapper.getHighlightType(result); if (actualType == null) { fail(exceptionHeader(lastStep) + " is not a LocalQuickFix, but " + result.getClass().getName() + "\nExpected LocalQuickFix with ProblemHighlightType=" + myHighlightType + "\n" + infoSupplier.get()); } if(actualType != myHighlightType) { fail(exceptionHeader(lastStep) + " has wrong ProblemHighlightType.\nExpected: " + myHighlightType + "\nActual: " + actualType + "\n" + infoSupplier.get()); } } } else if(result != null) { fail(exceptionHeader(lastStep) + " is present, but should not\n" + infoSupplier.get()); } return result; }