@Override
  public InplaceRefactoring doRename(@NotNull PsiElement elementToRename,
                                     @NotNull Editor editor,
                                     @Nullable DataContext dataContext) {
    Component contextComponent = ObjectUtils.notNull(dataContext != null ? PlatformCoreDataKeys.CONTEXT_COMPONENT.getData(dataContext) : null, editor.getComponent());
    String newName = dataContext != null ? PsiElementRenameHandler.DEFAULT_NAME.getData(dataContext) : null;
    PsiElement newElementToRename = null;
    if (elementToRename instanceof PsiNameIdentifierOwner) {
      final RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(elementToRename);
      if (processor.isInplaceRenameSupported()) {
        final StartMarkAction startMarkAction = StartMarkAction.canStart(editor);
        if (startMarkAction == null || (newElementToRename = processor.substituteElementToRename(elementToRename, editor)) == elementToRename) {
          processor.substituteElementToRename(elementToRename, editor, new Pass<>() {
            @Override
            public void pass(PsiElement element) {
              final MemberInplaceRenamer renamer = createMemberRenamer(element, (PsiNameIdentifierOwner)elementToRename, editor);
              List<String> names = dataContext == null ? null : PsiElementRenameHandler.NAME_SUGGESTIONS.getData(dataContext);
              boolean startedRename = renamer.performInplaceRename(names);
              if (!startedRename) {
                performDialogRename(elementToRename, editor, createDataContext(contextComponent, newName, elementToRename), renamer.myInitialName);
              }
            }
          });
          return null;
        }
        else {
          final InplaceRefactoring inplaceRefactoring = editor.getUserData(InplaceRefactoring.INPLACE_RENAMER);
          if (inplaceRefactoring != null && inplaceRefactoring.getClass() == MemberInplaceRenamer.class) {
            final TemplateState templateState = TemplateManagerImpl.getTemplateState(InjectedLanguageEditorUtil.getTopLevelEditor(editor));
            if (templateState != null) {
              templateState.gotoEnd(true);
            }
          }
        }
      }
    }
    performDialogRename(elementToRename, editor, createDataContext(contextComponent, newName, newElementToRename), null);
    return null;
  }
@Override
  public InplaceRefactoring doRename(@NotNull PsiElement elementToRename,
                                     @NotNull Editor editor,
                                     @Nullable DataContext dataContext)