From c98e03bcb7f55200ec12040627515df5d09dc366 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 16 Nov 2016 17:43:11 +0100 Subject: [PATCH] skip word selectioners that require indices in dumb mode (EA-91632 - INRE: FileBasedIndexImpl.handleDumbMode) --- .../editorActions/SelectWordUtil.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordUtil.java index 7c3f5738a74b..9026286d2778 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/SelectWordUtil.java @@ -23,6 +23,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.actions.EditorActionUtil; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.util.TextRange; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; @@ -259,10 +260,7 @@ public class SelectWordUtil { } long stamp = editor.getDocument().getModificationStamp(); for (ExtendWordSelectionHandler selectioner : availableSelectioners) { - List ranges = selectioner.select(element, text, cursorOffset, editor); - if (stamp != editor.getDocument().getModificationStamp()) { - throw new AssertionError("Selectioner " + selectioner + " has changed the document"); - } + List ranges = askSelectioner(element, text, cursorOffset, editor, stamp, selectioner); if (ranges == null) continue; for (TextRange range : ranges) { @@ -275,6 +273,25 @@ public class SelectWordUtil { return stop; } + @Nullable + private static List askSelectioner(@NotNull PsiElement element, + CharSequence text, + int cursorOffset, + Editor editor, + long stamp, + ExtendWordSelectionHandler selectioner) { + try { + List ranges = selectioner.select(element, text, cursorOffset, editor); + if (stamp != editor.getDocument().getModificationStamp()) { + throw new AssertionError("Selectioner " + selectioner + " has changed the document"); + } + return ranges; + } + catch (IndexNotReadyException e) { + return null; + } + } + public static void addWordHonoringEscapeSequences(CharSequence editorText, TextRange literalTextRange, int cursorOffset,