void (@NotNull final Project project, final Editor editor, final PsiFile file, final DataContext dataContext) { PsiElement element = PsiElementRenameHandler.getElement(dataContext); if (element == null) { if (LookupManager.getActiveLookup(editor) != null) { final PsiElement elementUnderCaret = file.findElementAt(editor.getCaretModel().getOffset()); if (elementUnderCaret != null) { final PsiElement parent = elementUnderCaret.getParent(); if (parent instanceof PsiReference) { element = ((PsiReference)parent).resolve(); } else { element = PsiTreeUtil.getParentOfType(elementUnderCaret, PsiNamedElement.class); } } if (element == null) return; } else { return; } } editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); if (checkAvailable(element, editor, dataContext)) { doRename(element, editor, dataContext); } }