boolean () { final int offset = myFixture.getCaretOffset(); PsiElement element = myFixture.getFile().findElementAt(offset); // Duplicates the logic of MoveHandler#invoke(), since it doesn't allow to check // whether MoveHandlerDelegate#tryMove() returns true or false without actually // invoking it. while (element != null) { if (PyMoveSymbolDelegate.isMovableLocalFunctionOrMethod(element)) { return true; } final TextRange range = element.getTextRange(); if (range != null) { final int relative = offset - range.getStartOffset(); final PsiReference reference = element.findReferenceAt(relative); if (reference != null) { final PsiElement refElement = reference.resolve(); if (refElement != null && PyMoveSymbolDelegate.isMovableLocalFunctionOrMethod(myFixture.getElementAtCaret())) { return true; } } } element = element.getParent(); } return false; }