diff --git a/plugins/grazie/src/test/kotlin/com/intellij/grazie/GrazieTestBase.kt b/plugins/grazie/src/test/kotlin/com/intellij/grazie/GrazieTestBase.kt index 0c39a5b0e532..af8ac8369d3a 100644 --- a/plugins/grazie/src/test/kotlin/com/intellij/grazie/GrazieTestBase.kt +++ b/plugins/grazie/src/test/kotlin/com/intellij/grazie/GrazieTestBase.kt @@ -1,6 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.grazie +import com.intellij.codeInspection.LocalInspectionTool import com.intellij.grazie.grammar.LanguageToolChecker import com.intellij.grazie.ide.inspection.grammar.GrazieInspection import com.intellij.grazie.jlanguage.Lang @@ -22,7 +23,7 @@ import kotlinx.coroutines.runBlocking abstract class GrazieTestBase : BasePlatformTestCase() { companion object { - val inspectionTools by lazy { arrayOf(GrazieInspection(), SpellCheckingInspection()) } + val inspectionTools: Array by lazy { arrayOf(GrazieInspection(), SpellCheckingInspection()) } val enabledLanguages = setOf(Lang.AMERICAN_ENGLISH, Lang.GERMANY_GERMAN, Lang.RUSSIAN, Lang.ITALIAN) val enabledRules = setOf("LanguageTool.EN.COMMA_WHICH", "LanguageTool.EN.UPPERCASE_SENTENCE_START") } diff --git a/spellchecker/src/META-INF/SpellCheckerPlugin.xml b/spellchecker/src/META-INF/SpellCheckerPlugin.xml index 795533594a82..487a3476c09a 100644 --- a/spellchecker/src/META-INF/SpellCheckerPlugin.xml +++ b/spellchecker/src/META-INF/SpellCheckerPlugin.xml @@ -24,7 +24,7 @@ + implementationClass="com.intellij.spellchecker.inspections.SpellCheckingInspection" dumbAware="true"/> diff --git a/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java b/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java index 40df512c4632..bf97345d711c 100644 --- a/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java +++ b/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java @@ -9,6 +9,8 @@ import com.intellij.lang.LanguageNamesValidation; import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.lang.refactoring.NamesValidator; import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.registry.Registry; import com.intellij.psi.PsiElement; @@ -29,7 +31,7 @@ import java.util.Set; import static com.intellij.codeInspection.options.OptPane.checkbox; import static com.intellij.codeInspection.options.OptPane.pane; -public final class SpellCheckingInspection extends LocalInspectionTool { +public final class SpellCheckingInspection extends LocalInspectionTool implements DumbAware { public static final String SPELL_CHECKING_INSPECTION_TOOL_NAME = "SpellCheckingInspection"; @Override @@ -45,8 +47,9 @@ public final class SpellCheckingInspection extends LocalInspectionTool { } private static SpellcheckingStrategy getSpellcheckingStrategy(@NotNull PsiElement element, @NotNull Language language) { + DumbService dumbService = DumbService.getInstance(element.getProject()); for (SpellcheckingStrategy strategy : LanguageSpellchecking.INSTANCE.allForLanguage(language)) { - if (strategy.isMyContext(element)) { + if (dumbService.isUsableInCurrentContext(strategy) && strategy.isMyContext(element)) { return strategy; } } diff --git a/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java b/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java index 6905e0880b64..fa8ec2e32b89 100644 --- a/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java +++ b/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java @@ -9,6 +9,7 @@ import com.intellij.lang.ParserDefinition; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType; +import com.intellij.openapi.project.PossiblyDumbAware; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; @@ -18,7 +19,7 @@ import com.intellij.spellchecker.DictionaryLayer; import com.intellij.spellchecker.DictionaryLayersProvider; import com.intellij.spellchecker.inspections.PlainTextSplitter; import com.intellij.spellchecker.inspections.SpellCheckingInspection; -import com.intellij.spellchecker.quickfixes.*; +import com.intellij.spellchecker.quickfixes.SpellCheckerQuickFixFactory; import com.intellij.spellchecker.settings.SpellCheckerSettings; import com.intellij.util.KeyedLazyInstance; import org.jetbrains.annotations.NotNull; @@ -32,8 +33,10 @@ import java.util.Set; *

* Register via extension point {@code com.intellij.spellchecker.support} * and override {@link #getTokenizer(PsiElement)} to skip/handle specific elements. + *

+ * Mark your strategy as {@link com.intellij.openapi.project.DumbAware} if it does not need indexes to perform */ -public class SpellcheckingStrategy { +public class SpellcheckingStrategy implements PossiblyDumbAware { protected final Tokenizer myCommentTokenizer = new CommentTokenizer(); public static final ExtensionPointName> EP_NAME =