void (@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) { int offset = editor.getCaretModel().getOffset(); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); final PsiElement position = file.findElementAt(offset); PsiElement element = position; while (true) { if (element == null || element instanceof PsiFile) { String message = RefactoringBundle .getCannotRefactorMessage(getInvalidPositionMessage()); CommonRefactoringUtil.showErrorHint(project, editor, message, getTitle(), getHelpId()); return; } if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return; if (acceptsElement(element)) { invoke(project, new PsiElement[]{position}, dataContext); return; } element = element.getParent(); } }