void (String text, BiConsumer<? super MockVirtualMachine, ? super MockStackFrame> mockValues, String fileName, @Nullable String context) { String filteredText = text.replaceAll("/\\*\\w+\\*/", ""); configureFromFileText(fileName, filteredText); PsiFile file = getFile(); int offset = getEditor().getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); assertNotNull(context, element); MockVirtualMachine vm = new MockVirtualMachine(); MockStackFrame frame = new MockStackFrame(vm, element); mockValues.accept(vm, frame); Ref<DebuggerDfaRunner> runnerRef = Ref.create(); MockDebugProcess process = new MockDebugProcess(getProject(), vm, getTestRootDisposable()); SmartPsiElementPointer<PsiElement> pointer = SmartPointerManager.createPointer(element); process.getManagerThread().invokeAndWait(new DebuggerCommandImpl() { @Override protected void action() { ThreadReferenceProxyImpl threadProxy = ContainerUtil.getFirstItem(process.getVirtualMachineProxy().allThreads()); StackFrameProxyImpl frameProxy = new StackFrameProxyImpl(threadProxy, frame, 1); DebuggerDfaRunner runner = DfaAssist.createDfaRunner(frameProxy, pointer); runnerRef.set(runner); } }); DebuggerDfaRunner runner = runnerRef.get(); assertNotNull(context, runner); DfaResult dfaResult = runner.computeHints(); Map<PsiElement, DfaHint> hints = dfaResult.hints; String fileText = filteredText.replace("<caret>", ""); EntryStream<Integer, String> hintStream = EntryStream.of(hints) .mapKeys(ex -> ex.getTextRange().getEndOffset()) .mapValues(hint -> "/*" + hint + "*/"); EntryStream<Integer, String> unreachableStream = StreamEx.of(dfaResult.unreachable) .flatMapToEntry(range -> Map.of(range.getStartOffset(), "/*unreachable_start*/", range.getEndOffset(), "/*unreachable_end*/")); String result = hintStream .append(unreachableStream) .sorted(Map.Entry.comparingByKey()) .prepend(0, "") .append(fileText.length(), "") .chain(StreamEx::of) .pairMap((prev, next) -> StreamEx.of(fileText.substring(prev.getKey(), next.getKey()), next.getValue())) .flatMap(Function.identity()) .joining(); String expectedText = text.replace("<caret>", ""); assertEquals(context, expectedText, result); }