mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't commit documents in code insight action update, commit when actions are invoked
This commit is contained in:
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
+2
-4
@@ -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;
|
||||
|
||||
-3
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
-3
@@ -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; //?
|
||||
|
||||
Reference in New Issue
Block a user