public void doInvoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { final PsiElement element = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); PyFunction problemFunction = PsiTreeUtil.getParentOfType(element, PyFunction.class); if (problemFunction == null) return; final PyClass containingClass = problemFunction.getContainingClass(); if (containingClass == null) return; final List<UsageInfo> usages = PyRefactoringUtil.findUsages(problemFunction, false); final PyDecoratorList decoratorList = problemFunction.getDecoratorList(); if (decoratorList != null) { final PyDecorator decorator = decoratorList.findDecorator(PyNames.STATICMETHOD); if (decorator != null) decorator.delete(); } final PsiElement copy = problemFunction.copy(); problemFunction.delete(); file.addAfter(copy, containingClass); for (UsageInfo usage : usages) { final PsiElement usageElement = usage.getElement(); if (usageElement instanceof PyReferenceExpression) { PyUtil.removeQualifier((PyReferenceExpression) usageElement); } } }