TemplateStateBase (@NotNull Editor editor) { UserDataHolder stateHolder = InjectedLanguageEditorUtil.getTopLevelEditor(editor); TemplateStateBase templateState = stateHolder.getUserData(TEMPLATE_STATE_KEY); if (templateState != null && templateState.isDisposed()) { setTemplateState(stateHolder, null); return null; } return templateState; }