void (final boolean actualCode) { Project project = getProject(); assertNotNull(project); EditorAction action = (EditorAction)ActionManager.getInstance().getAction(IdeActions.ACTION_EXPAND_LIVE_TEMPLATE_BY_TAB); action.actionPerformed(myFixture.getEditor(), DataManager.getInstance().getDataContext()); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); UIUtil.dispatchAllInvocationEvents(); WriteCommandAction.runWriteCommandAction(getProject(), () -> { TemplateState state = TemplateManagerImpl.getTemplateState(myFixture.getEditor()); Editor editor = InjectedLanguageUtil.getTopLevelEditor(myFixture.getEditor()); while (state != null && !state.isFinished()) { if (actualCode) { actualTabStops.add(editor.getCaretModel().getOffset()); } state.nextTab(); } if (actualCode) { actualTabStops.add(editor.getCaretModel().getOffset()); } CodeStyleManager.getInstance(project).reformat(myFixture.getFile()); }); }