IJPL-574 allow to register inspections as dumbAware without explicit dumbAware tag

GitOrigin-RevId: 3258a8c890dd5682f55eec44e52ec8d2e1a6cfde
This commit is contained in:
Max Medvedev
2024-08-13 18:41:06 +02:00
committed by intellij-monorepo-bot
parent d32dcd749b
commit 6ef95206ea
5 changed files with 10 additions and 4 deletions

View File

@@ -16,6 +16,11 @@ import java.util.regex.Pattern;
/**
* Base class for local inspections.
* <p/>
* You can make your inspection dumb-aware by marking it with {@link com.intellij.openapi.project.DumbAware DumbAware} interface.
* Such an inspection must not use indexes during its inference, or it must be prepared to catch
* {@link com.intellij.openapi.project.IndexNotReadyException IndexNotReadyException}.
* In this case, the inspection shall just silently catch it and not report any warnings.
*
* @see <a href="https://plugins.jetbrains.com/docs/intellij/code-inspections.html">Code Inspections (IntelliJ Platform Docs)</a>
* @see GlobalInspectionTool

View File

@@ -54,7 +54,7 @@ public class LocalInspectionToolWrapper extends InspectionToolWrapper<LocalInspe
}
public boolean isDumbAware() {
return myEP == null ? getTool().isDumbAware() : myEP.dumbAware;
return getTool().isDumbAware();
}
public static @Nullable InspectionToolWrapper<?, ?> findTool2RunInBatch(@NotNull Project project,

View File

@@ -105,7 +105,8 @@ final class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
List<? extends LocalInspectionToolWrapper> activeToolWrappers;
List<? extends LocalInspectionToolWrapper> disabledSmartOnlyToolWrappers;
if (isDumbMode()) {
activeToolWrappers = ContainerUtil.filter(toolWrappers, wrapper -> wrapper.isDumbAware());
activeToolWrappers = toolWrappers.stream().parallel().filter(wrapper -> wrapper.isDumbAware()).toList();
if (activeToolWrappers.isEmpty()) {
disabledSmartOnlyToolWrappers = toolWrappers;
}

View File

@@ -46,7 +46,7 @@
<!-- getDisplayName is overridden in GrazieInspection itself! Placeholder is required to suppress validation. -->
<localInspection bundle="messages.GrazieBundle" groupKey="grazie.group.name" enabledByDefault="true" shortName="GrazieInspection"
implementationClass="com.intellij.grazie.ide.inspection.grammar.GrazieInspection"
level="GRAMMAR_ERROR" key="grazie.grammar.inspection.grammar.text" dumbAware="true"/>
level="GRAMMAR_ERROR" key="grazie.grammar.inspection.grammar.text"/>
<localInspection bundle="messages.GrazieBundle" groupKey="grazie.group.name" enabledByDefault="true" shortName="LanguageDetectionInspection"
implementationClass="com.intellij.grazie.ide.inspection.detection.LanguageDetectionInspection"

View File

@@ -24,7 +24,7 @@
<localInspection shortName="SpellCheckingInspection" bundle="messages.SpellCheckerBundle"
key="spellchecking.inspection.name" groupKey="proofread" enabledByDefault="true" level="TYPO"
language=""
implementationClass="com.intellij.spellchecker.inspections.SpellCheckingInspection" dumbAware="true"/>
implementationClass="com.intellij.spellchecker.inspections.SpellCheckingInspection"/>
<nameSuggestionProvider id="DictionarySuggestionProvider" implementation="com.intellij.spellchecker.quickfixes.DictionarySuggestionProvider" order="first"/>
<severitiesProvider implementation="com.intellij.spellchecker.SpellCheckerSeveritiesProvider"/>