void (@NotNull CodeInsightTestFixture fixture, @NotNull String answersFilePath, @Nullable Set<String> acceptableKeyNames) { Editor editor = fixture.getEditor(); CaretModel caretModel = editor.getCaretModel(); List<Integer> offs = ContainerUtil.map(caretModel.getAllCarets(), Caret::getOffset); List<Integer> caretsOffsets = offs.isEmpty() ? List.of(-1) : offs; caretModel.removeSecondaryCarets(); CharSequence documentSequence = InjectedLanguageEditorUtil.getTopLevelEditor(editor).getDocument().getCharsSequence(); IdentifierHighlighterPassFactory.doWithHighlightingEnabled(fixture.getProject(), fixture.getProjectDisposable(), () -> { for (Integer caretsOffset : caretsOffsets) { if (caretsOffset != -1) { caretModel.moveToOffset(caretsOffset); } UsefulTestCase.assertSameLinesWithFile( answersFilePath, renderTextWithHighlightingInfos(fixture.doHighlighting(), documentSequence, acceptableKeyNames), () -> "Failed at:\n " + documentSequence.subSequence(0, caretsOffset) + "<caret>" + documentSequence.subSequence(caretsOffset, documentSequence.length()) + "\n"); }}); }