void () { PsiDocumentManager.getInstance(myProject).commitAllDocuments(); PsiElement[] elements = getPatternElements(); if (elements.length != 0) { PsiFile psiFile = elements[0].getContainingFile(); if (psiFile != null) { ExtractMethodSnapshot.SNAPSHOT_KEY.set(psiFile, mySnapshot); try { Editor editor = getEditor(psiFile, true); ExtractMethodHandler.invokeOnElements(myProject, editor, psiFile, elements); return; } finally { ExtractMethodSnapshot.SNAPSHOT_KEY.set(psiFile, null); } } } Messages.showErrorDialog(myProject, JavaRefactoringBundle.message("can.t.restore.context.for.method.extraction"), JavaRefactoringBundle.message("failed.to.re.run.refactoring")); }