diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java index 502dc1152ad8..0659c00a7673 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java @@ -61,7 +61,6 @@ import com.intellij.psi.javadoc.PsiDocComment; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.*; import com.intellij.util.Consumer; -import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; @@ -618,8 +617,6 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil { @Nullable public static PsiClass getContextClass(Project project, Editor editor, PsiFile file, boolean allowInterface) { - PsiDocumentManager.getInstance(project).commitAllDocuments(); - int offset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); do { diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallAction.java b/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallAction.java index 62881172e102..2cd9218c4be7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallAction.java @@ -36,7 +36,7 @@ public class GenerateSuperMethodCallAction extends BaseCodeInsightAction { if (!(file instanceof PsiJavaFile)) { return false; } - PsiMethod method = GenerateSuperMethodCallHandler.canInsertSuper(project, editor, file); + PsiMethod method = GenerateSuperMethodCallHandler.canInsertSuper(editor, file); if (method == null) { return false; } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java b/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java index d88bb8d5e3e7..359787b0e909 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/actions/GenerateSuperMethodCallHandler.java @@ -37,7 +37,7 @@ public class GenerateSuperMethodCallHandler implements CodeInsightActionHandler @Override public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (!CodeInsightUtilBase.prepareEditorForWrite(editor)) return; - PsiMethod method = canInsertSuper(project, editor, file); + PsiMethod method = canInsertSuper(editor, file); try { PsiMethod template = (PsiMethod)method.copy(); @@ -65,9 +65,7 @@ public class GenerateSuperMethodCallHandler implements CodeInsightActionHandler return true; } - public static PsiMethod canInsertSuper(Project project, Editor editor, PsiFile file) { - PsiDocumentManager.getInstance(project).commitAllDocuments(); - + public static PsiMethod canInsertSuper(Editor editor, PsiFile file) { int offset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); if (element == null) return null; diff --git a/java/java-impl/src/com/intellij/testIntegration/BaseGenerateTestSupportMethodAction.java b/java/java-impl/src/com/intellij/testIntegration/BaseGenerateTestSupportMethodAction.java index a37429ca0d09..e235ffb606f6 100644 --- a/java/java-impl/src/com/intellij/testIntegration/BaseGenerateTestSupportMethodAction.java +++ b/java/java-impl/src/com/intellij/testIntegration/BaseGenerateTestSupportMethodAction.java @@ -39,7 +39,6 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.ui.components.JBList; import com.intellij.util.Consumer; -import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -115,8 +114,6 @@ public class BaseGenerateTestSupportMethodAction extends BaseGenerateAction { protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (file instanceof PsiCompiledElement) return false; - PsiDocumentManager.getInstance(project).commitAllDocuments(); - PsiClass targetClass = getTargetClass(editor, file); return targetClass != null && isValidForClass(targetClass); } diff --git a/java/openapi/src/com/intellij/codeInsight/generation/actions/BaseGenerateAction.java b/java/openapi/src/com/intellij/codeInsight/generation/actions/BaseGenerateAction.java index 8a74db72ed52..05f198bb0c1e 100644 --- a/java/openapi/src/com/intellij/codeInsight/generation/actions/BaseGenerateAction.java +++ b/java/openapi/src/com/intellij/codeInsight/generation/actions/BaseGenerateAction.java @@ -74,8 +74,6 @@ public class BaseGenerateAction extends CodeInsightAction implements GenerateAct if (!(file instanceof PsiJavaFile)) return false; if (file instanceof PsiCompiledElement) return false; - PsiDocumentManager.getInstance(project).commitAllDocuments(); - PsiClass targetClass = getTargetClass(editor, file); return targetClass != null && isValidForClass(targetClass); } diff --git a/platform/lang-api/src/com/intellij/codeInsight/actions/CodeInsightAction.java b/platform/lang-api/src/com/intellij/codeInsight/actions/CodeInsightAction.java index a17df5d15cf9..a0f6099a78c4 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/actions/CodeInsightAction.java +++ b/platform/lang-api/src/com/intellij/codeInsight/actions/CodeInsightAction.java @@ -23,6 +23,7 @@ import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.actionSystem.DocCommandGroupId; import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiUtilBase; import org.jetbrains.annotations.NotNull; @@ -75,7 +76,7 @@ public abstract class CodeInsightAction extends AnAction { public void beforeActionPerformedUpdate(@NotNull AnActionEvent e) { Project project = e.getProject(); if (project != null) { - getEditor(e.getDataContext(), project, false); // ensure documents are committed + PsiDocumentManager.getInstance(project).commitAllDocuments(); } super.beforeActionPerformedUpdate(e); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GrBaseGenerateAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GrBaseGenerateAction.java index a6e0dd3c864b..be78ca25b78a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GrBaseGenerateAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GrBaseGenerateAction.java @@ -21,7 +21,6 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiCompiledElement; -import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.GroovyFileType; @@ -40,8 +39,6 @@ public abstract class GrBaseGenerateAction extends BaseGenerateAction { if (file instanceof PsiCompiledElement) return false; if (!GroovyFileType.GROOVY_FILE_TYPE.equals(file.getFileType())) return false; - PsiDocumentManager.getInstance(project).commitAllDocuments(); - PsiClass targetClass = getTargetClass(editor, file); if (targetClass == null) return false; if (targetClass.isInterface()) return false; //?