From ecca380b2345bd2a2f7040dd0a16d908ad5f45e9 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 4 Nov 2016 16:14:58 +0100 Subject: [PATCH 1/4] release the editor in a write-safe context (EA-90138 - assert: PsiDocumentManagerBase.commitAllDocuments) --- platform/platform-impl/src/com/intellij/ui/EditorTextField.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java index d516906618ec..a7da48ca76f2 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorTextField.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorTextField.java @@ -404,7 +404,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener, // and only then execute another removal from the hierarchy. Otherwise // swing goes nuts because of nested removals and indices get corrupted EditorEx editor = myEditor; - SwingUtilities.invokeLater(() -> releaseEditor(editor)); + ApplicationManager.getApplication().invokeLater(() -> releaseEditor(editor)); myEditor = null; } From 60276b4e0a413e54146d35e6a9ffce7c87c5b5e2 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 4 Nov 2016 16:19:33 +0100 Subject: [PATCH 2/4] navigate from switcher in a write-safe context (EA-89634 - assert: PsiDocumentManagerBase.commitDocument) --- .../src/com/intellij/ide/actions/Switcher.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java index f6659010eb0e..2f125cd57b33 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java @@ -22,6 +22,7 @@ import com.intellij.ide.ui.UISettings; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.impl.PresentationFactory; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.editor.markup.EffectType; import com.intellij.openapi.editor.markup.TextAttributes; @@ -70,13 +71,14 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.*; +import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.util.*; import java.util.List; -import static java.awt.event.InputEvent.*; +import static java.awt.event.InputEvent.CTRL_DOWN_MASK; import static java.awt.event.KeyEvent.*; import static javax.swing.KeyStroke.getKeyStroke; @@ -886,7 +888,8 @@ public class Switcher extends AnAction implements DumbAware { } else if (values[0] instanceof ToolWindow) { final ToolWindow toolWindow = (ToolWindow)values[0]; - IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(() -> toolWindow.activate(null, true, true)); + IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(() -> toolWindow.activate(null, true, true), + ModalityState.current()); } else { IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(() -> { @@ -916,7 +919,7 @@ public class Switcher extends AnAction implements DumbAware { } } } - }); + }, ModalityState.current()); } } From 0bbe457ea578cf17c38bb88752dfff373d424221 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 4 Nov 2016 16:24:43 +0100 Subject: [PATCH 3/4] don't commit documents synchronously in dom ui (EA-90158 - assert: PsiDocumentManagerBase.commitDocument) --- .../src/com/intellij/util/xml/ui/UndoHelper.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/UndoHelper.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/UndoHelper.java index 01592e908c3d..97f5cc09d8ff 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/UndoHelper.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/UndoHelper.java @@ -31,7 +31,6 @@ import java.util.Set; * @author peter */ public class UndoHelper { - private final Project myProject; private boolean myShowing; private final Set myCurrentDocuments = new HashSet<>(); private boolean myDirty; @@ -45,7 +44,6 @@ public class UndoHelper { }; public UndoHelper(final Project project, final Committable committable) { - myProject = project; final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project); CommandProcessor.getInstance().addCommandListener(new CommandAdapter() { @Override @@ -86,7 +84,6 @@ public class UndoHelper { } public final void setShowing(final boolean showing) { - commitAllDocuments(); myShowing = showing; } @@ -94,17 +91,6 @@ public class UndoHelper { return myShowing; } - public final void commitAllDocuments() { - final PsiDocumentManager manager = getDocumentManager(); - for (final Document document : myCurrentDocuments) { - manager.commitDocument(document); - } - } - - private PsiDocumentManager getDocumentManager() { - return PsiDocumentManager.getInstance(myProject); - } - public final void addWatchedDocument(final Document document) { stopListeningDocuments(); myCurrentDocuments.add(document); From 54c6d66720c7afd5d13369d7e72231f86e38834e Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 4 Nov 2016 16:26:45 +0100 Subject: [PATCH 4/4] JavaClassNameInsertHandler: avoid EA-89320 - ISE: OffsetMap.getOffset --- .../codeInsight/completion/JavaClassNameInsertHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameInsertHandler.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameInsertHandler.java index 4026930f4e6f..11c8589d8ae8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameInsertHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameInsertHandler.java @@ -93,7 +93,7 @@ class JavaClassNameInsertHandler implements InsertHandler