void (final String newName) { configureByFile(); TemplateManagerImpl.setTemplateTesting(getTestRootDisposable()); new RenameWrongRefHandler().invoke(getProject(), getEditor(), getFile(), null); final TemplateState state = TemplateManagerImpl.getTemplateState(getEditor()); assert state != null; final TextRange range = state.getCurrentVariableRange(); assert range != null; WriteCommandAction.writeCommandAction(getProject()) .run(() -> getEditor().getDocument().replaceString(range.getStartOffset(), range.getEndOffset(), newName)); state.gotoEnd(false); checkResultByFile(); }