From e71bc7d89c836b4a765c832cadb1cf340c20c967 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 17 Jul 2015 10:26:58 +0200 Subject: [PATCH] instead of complicated DumbAware checking, just don't run inspections in dumb mode (EA-70824 - assert: DumbServiceImpl.waitForSmartMode) --- .../codeInspection/InspectionEngine.java | 26 +++++------------ .../daemon/impl/LocalInspectionsPass.java | 28 ++++++++----------- .../WholeFileLocalInspectionsPassFactory.java | 1 - 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/InspectionEngine.java b/platform/analysis-impl/src/com/intellij/codeInspection/InspectionEngine.java index 3c3260de600b..3d2ead488783 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/InspectionEngine.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/InspectionEngine.java @@ -30,8 +30,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.DumbService; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Conditions; import com.intellij.openapi.util.ProperTextRange; @@ -117,7 +115,7 @@ public class InspectionEngine { Divider.divideInsideAndOutside(file, range.getStartOffset(), range.getEndOffset(), range, elements, new ArrayList(), Collections.emptyList(), Collections.emptyList(), true, Conditions.alwaysTrue()); - MultiMap toolToLanguages = getToolsForElements(toolWrappers, DumbService.isDumb(file.getProject()), elements, Collections.emptyList()); + MultiMap toolToLanguages = getToolsForElements(toolWrappers, elements, Collections.emptyList()); List>> entries = new ArrayList>>(toolToLanguages.entrySet()); Processor>> processor = new Processor>>() { @Override @@ -236,7 +234,6 @@ public class InspectionEngine { @NotNull public static MultiMap getToolsForElements(@NotNull List toolWrappers, - boolean checkDumbAwareness, @NotNull List inside, @NotNull List outside) { Set languages = new SmartHashSet(); @@ -261,29 +258,20 @@ public class InspectionEngine { ProgressManager.checkCanceled(); String language = wrapper.getLanguage(); if (language == null) { - InspectionProfileEntry tool = wrapper.getTool(); - if (!checkDumbAwareness || tool instanceof DumbAware) { - toolToLanguages.put(wrapper, null); - } + toolToLanguages.put(wrapper, null); continue; } Language lang = langIds.get(language); if (lang != null) { - InspectionProfileEntry tool = wrapper.getTool(); - if (!checkDumbAwareness || tool instanceof DumbAware) { - toolToLanguages.putValue(wrapper, language); - if (wrapper.applyToDialects()) { - for (Language dialect : lang.getDialects()) { - toolToLanguages.putValue(wrapper, dialect.getID()); - } + toolToLanguages.putValue(wrapper, language); + if (wrapper.applyToDialects()) { + for (Language dialect : lang.getDialects()) { + toolToLanguages.putValue(wrapper, dialect.getID()); } } } else if (wrapper.applyToDialects() && dialects.contains(language)) { - InspectionProfileEntry tool = wrapper.getTool(); - if (!checkDumbAwareness || tool instanceof DumbAware) { - toolToLanguages.putValue(wrapper, language); - } + toolToLanguages.putValue(wrapper, language); } } return toolToLanguages; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index 2d7520bb42e6..0187fb379978 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -44,8 +44,6 @@ import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.DumbService; import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; @@ -73,7 +71,7 @@ import java.util.concurrent.ConcurrentMap; /** * @author max */ -public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass implements DumbAware { +public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.LocalInspectionsPass"); public static final TextRange EMPTY_PRIORITY_RANGE = TextRange.EMPTY_RANGE; private static final Condition FILE_FILTER = new Condition() { @@ -141,7 +139,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(getFile())) return; final InspectionManager iManager = InspectionManager.getInstance(myProject); final InspectionProfileWrapper profile = myProfileWrapper; - inspect(getInspectionTools(profile), iManager, true, true, DumbService.isDumb(myProject), progress); + inspect(getInspectionTools(profile), iManager, true, true, progress); } finally { disposeDescriptors(); @@ -156,7 +154,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass @NotNull final InspectionManager iManager, @NotNull final List toolWrappers) { final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); - inspect(new ArrayList(toolWrappers), iManager, false, false, false, progress); + inspect(new ArrayList(toolWrappers), iManager, false, false, progress); addDescriptorsFromInjectedResults(iManager, context); List resultList = result.get(getFile()); if (resultList == null) return; @@ -218,7 +216,6 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass @NotNull final InspectionManager iManager, final boolean isOnTheFly, boolean failFastOnAcquireReadAction, - boolean checkDumbAwareness, @NotNull final ProgressIndicator progress) { myFailFastOnAcquireReadAction = failFastOnAcquireReadAction; if (toolWrappers.isEmpty()) return; @@ -228,15 +225,15 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass Divider.divideInsideAndOutside(getFile(), myRestrictRange.getStartOffset(), myRestrictRange.getEndOffset(), myPriorityRange, inside, new ArrayList(), outside, new ArrayList(), true, FILE_FILTER); - MultiMap toolToLanguages = InspectionEngine.getToolsForElements(toolWrappers, checkDumbAwareness, inside, outside); + MultiMap toolToLanguages = InspectionEngine.getToolsForElements(toolWrappers, inside, outside); setProgressLimit(toolToLanguages.size() * 2L); final LocalInspectionToolSession session = new LocalInspectionToolSession(getFile(), myRestrictRange.getStartOffset(), myRestrictRange.getEndOffset()); List init = - visitPriorityElementsAndInit(toolToLanguages, iManager, isOnTheFly, progress, inside, session, toolWrappers, checkDumbAwareness); + visitPriorityElementsAndInit(toolToLanguages, iManager, isOnTheFly, progress, inside, session, toolWrappers); visitRestElementsAndCleanup(progress, outside, session, init); - inspectInjectedPsi(outside, isOnTheFly, progress, iManager, false, checkDumbAwareness, toolWrappers); + inspectInjectedPsi(outside, isOnTheFly, progress, iManager, false, toolWrappers); progress.checkCanceled(); @@ -251,8 +248,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass @NotNull final ProgressIndicator indicator, @NotNull final List elements, @NotNull final LocalInspectionToolSession session, - @NotNull List wrappers, - boolean checkDumbAwareness) { + @NotNull List wrappers) { final List init = new ArrayList(); List>> entries = new ArrayList>>(toolToLanguages.entrySet()); Processor>> processor = @@ -264,7 +260,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass }; boolean result = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(entries, indicator, myFailFastOnAcquireReadAction, processor); if (!result) throw new ProcessCanceledException(); - inspectInjectedPsi(elements, isOnTheFly, indicator, iManager, true, checkDumbAwareness, wrappers); + inspectInjectedPsi(elements, isOnTheFly, indicator, iManager, true, wrappers); return init; } @@ -337,7 +333,6 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass @NotNull final ProgressIndicator indicator, @NotNull final InspectionManager iManager, final boolean inVisibleRange, - final boolean checkDumbAwareness, @NotNull final List wrappers) { final Set injected = new THashSet(); for (PsiElement element : elements) { @@ -352,7 +347,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass Processor processor = new Processor() { @Override public boolean process(final PsiFile injectedPsi) { - doInspectInjectedPsi(injectedPsi, onTheFly, indicator, iManager, inVisibleRange, wrappers, checkDumbAwareness); + doInspectInjectedPsi(injectedPsi, onTheFly, indicator, iManager, inVisibleRange, wrappers); return true; } }; @@ -676,8 +671,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass @NotNull final ProgressIndicator indicator, @NotNull InspectionManager iManager, final boolean inVisibleRange, - @NotNull List wrappers, - boolean checkDumbAwareness) { + @NotNull List wrappers) { final PsiElement host = InjectedLanguageManager.getInstance(injectedPsi.getProject()).getInjectionHost(injectedPsi); final List elements = getElementsFrom(injectedPsi); @@ -685,7 +679,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass return; } MultiMap toolToLanguages = - InspectionEngine.getToolsForElements(wrappers, checkDumbAwareness, elements, Collections.emptyList()); + InspectionEngine.getToolsForElements(wrappers, elements, Collections.emptyList()); for (final Map.Entry> pair : toolToLanguages.entrySet()) { indicator.checkCanceled(); final LocalInspectionToolWrapper wrapper = pair.getKey(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java index 05f859b8694d..45b5825a2548 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java @@ -124,7 +124,6 @@ public class WholeFileLocalInspectionsPassFactory extends AbstractProjectCompone @NotNull ProgressIndicator indicator, @NotNull InspectionManager iManager, boolean inVisibleRange, - boolean checkDumbAwareness, @NotNull List wrappers) { // already inspected in LIP }