From 402acf04ff9e04aa8c5f9676e65b8815dcdf7e73 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Sat, 2 Nov 2024 13:07:00 +0400 Subject: [PATCH] IJPL-164584 Skip DUMB_EMPTY_INDEX with no dumb checks 2 GitOrigin-RevId: cf36a279eb8c57beb85fe4c82b7318678fb7ab0f --- .../daemon/impl/DaemonRespondToChangesTest.java | 6 +++--- .../daemon/impl/LocalInspectionsInDumbModeTest.kt | 8 +++++--- .../com/intellij/java/codeInsight/ParameterInfoTest.java | 4 +++- .../postfix/templates/StreamPostfixTemplateTest.java | 8 ++++++++ .../fixtures/LightJavaCodeInsightFixtureTestCase.java | 9 +-------- .../testFramework/TestIndexingModeSupporter.java | 2 ++ .../kotlin/idea/test/JUnit3RunnerWithInners.java | 7 ++----- .../kotlin/idea/highlighter/DebugInfoHighlightingPass.kt | 5 ++++- 8 files changed, 28 insertions(+), 21 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java index 164e60530c49..13ac1dbec1cd 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java @@ -69,9 +69,7 @@ import com.intellij.openapi.fileTypes.PlainTextFileType; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.project.DumbAware; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.project.*; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl; import com.intellij.openapi.util.Disposer; @@ -1590,11 +1588,13 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { return new EditorBoundHighlightingPass(editor, psiFile, false) { @Override public void doCollectInformation(@NotNull ProgressIndicator progress) { + if (DumbService.isDumb(myProject)) throw IndexNotReadyException.create(); collected.add(SmartFac.this); } @Override public void doApplyInformationToEditor() { + if (DumbService.isDumb(myProject)) return; applied.add(SmartFac.this); } }; diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LocalInspectionsInDumbModeTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LocalInspectionsInDumbModeTest.kt index 6836aaeee35a..fc7bbf5406ef 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LocalInspectionsInDumbModeTest.kt +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/LocalInspectionsInDumbModeTest.kt @@ -170,9 +170,11 @@ class LocalInspectionsInDumbModeTest : DaemonAnalyzerTestCase() { """ configureByText(JavaFileType.INSTANCE, text) - // dumb infos contain a redundant suppression because it's not removed as java suppressor does not work in dumb mode - val initialDumbInfos = doHighlightingInDumbMode().map { it.description } - assertDoesntContain(initialDumbInfos, "Redundant suppression") + if (Registry.`is`("ide.dumb.mode.check.awareness")) { + // dumb infos contain a redundant suppression because it's not removed as java suppressor does not work in dumb mode + val initialDumbInfos = doHighlightingInDumbMode().map { it.description } + assertDoesntContain(initialDumbInfos, "Redundant suppression") + } // smart infos contain a redundant suppression, because suppression is in fact redundant, // and redundant suppressor for Java works in smart mode diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/ParameterInfoTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/ParameterInfoTest.java index 21176359a26e..cac05b32d890 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/ParameterInfoTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/ParameterInfoTest.java @@ -410,7 +410,9 @@ public class ParameterInfoTest extends AbstractParameterInfoTestCase { "}"; myFixture.configureByText(JavaFileType.INSTANCE, text.replace("/*caret*/", "")); - assertEmpty(myFixture.doHighlighting(HighlightSeverity.ERROR)); + if (!DumbService.isDumb(myFixture.getProject()) || Registry.is("ide.dumb.mode.check.awareness")) { + assertEmpty(myFixture.doHighlighting(HighlightSeverity.ERROR)); + } assertEquals("Collection<? super Object> c, Object... elements", parameterPresentation(-1)); } diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/StreamPostfixTemplateTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/StreamPostfixTemplateTest.java index 551170aff119..0ee7510e6b8d 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/StreamPostfixTemplateTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/template/postfix/templates/StreamPostfixTemplateTest.java @@ -15,12 +15,15 @@ */ package com.intellij.java.codeInsight.template.postfix.templates; +import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.util.registry.Registry; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.LightProjectDescriptor; import org.jetbrains.annotations.NotNull; public class StreamPostfixTemplateTest extends PostfixTemplateTestCase { + @Override protected @NotNull LightProjectDescriptor getProjectDescriptor() { return JAVA_8; @@ -41,6 +44,11 @@ public class StreamPostfixTemplateTest extends PostfixTemplateTestCase { } public void testInLambda() { + if (DumbService.isDumb(myFixture.getProject()) && + !Registry.is("ide.dumb.mode.check.awareness")) { + // See IDEA-362230 + return; + } doTest(); } diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java b/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java index 1d29d03994d1..d82748b6127e 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java @@ -10,7 +10,6 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.ContentEntry; import com.intellij.openapi.roots.LanguageLevelModuleExtension; import com.intellij.openapi.roots.ModifiableRootModel; -import com.intellij.openapi.util.registry.Registry; import com.intellij.pom.java.AcceptedLanguageLevelsSettings; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; @@ -206,13 +205,7 @@ public abstract class LightJavaCodeInsightFixtureTestCase extends UsefulTestCase @Override public void setIndexingMode(@NotNull IndexingMode mode) { - if (Registry.is("ide.dumb.mode.check.awareness") || - mode != IndexingMode.DUMB_EMPTY_INDEX) { - myIndexingMode = mode; - } - else { - myIndexingMode = IndexingMode.DUMB_FULL_INDEX; - } + myIndexingMode = mode; } @Override diff --git a/platform/testFramework/src/com/intellij/testFramework/TestIndexingModeSupporter.java b/platform/testFramework/src/com/intellij/testFramework/TestIndexingModeSupporter.java index aa41a0cff5a7..f2411c9072f6 100644 --- a/platform/testFramework/src/com/intellij/testFramework/TestIndexingModeSupporter.java +++ b/platform/testFramework/src/com/intellij/testFramework/TestIndexingModeSupporter.java @@ -155,6 +155,8 @@ public interface TestIndexingModeSupporter { static void addTest(@NotNull Class aClass, @NotNull TestIndexingModeSupporter.IndexingModeTestHandler handler, @NotNull TestSuite parentSuite) { + if (handler.getIndexingMode() == DUMB_EMPTY_INDEX && + !Registry.is("ide.dumb.mode.check.awareness")) return; if (handler.shouldIgnore(aClass)) return; try { TestSuite suite = handler.createTestSuite(); diff --git a/plugins/kotlin/base/test/test/org/jetbrains/kotlin/idea/test/JUnit3RunnerWithInners.java b/plugins/kotlin/base/test/test/org/jetbrains/kotlin/idea/test/JUnit3RunnerWithInners.java index d05f7b62adf5..830fe46dec2b 100644 --- a/plugins/kotlin/base/test/test/org/jetbrains/kotlin/idea/test/JUnit3RunnerWithInners.java +++ b/plugins/kotlin/base/test/test/org/jetbrains/kotlin/idea/test/JUnit3RunnerWithInners.java @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.idea.test; import com.intellij.openapi.util.registry.Registry; import com.intellij.testFramework.JUnit38AssumeSupportRunner; import com.intellij.testFramework.TestIndexingModeSupporter; +import com.intellij.util.ArrayUtil; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestResult; @@ -162,11 +163,7 @@ public class JUnit3RunnerWithInners extends Runner implements Filterable, Sortab if (indexingMode != null) { TestIndexingModeSupporter.@NotNull IndexingMode[] value = indexingMode.value(); if (!Registry.is("ide.dumb.mode.check.awareness")) { - for (int i = 0; i < value.length; i++) { - if (value[i] == TestIndexingModeSupporter.IndexingMode.DUMB_EMPTY_INDEX) { - value[i] = TestIndexingModeSupporter.IndexingMode.DUMB_FULL_INDEX; - } - } + return ArrayUtil.remove(value, TestIndexingModeSupporter.IndexingMode.DUMB_EMPTY_INDEX); } return value; } diff --git a/plugins/kotlin/highlighting/highlighting-k1/src/org/jetbrains/kotlin/idea/highlighter/DebugInfoHighlightingPass.kt b/plugins/kotlin/highlighting/highlighting-k1/src/org/jetbrains/kotlin/idea/highlighter/DebugInfoHighlightingPass.kt index a00fb5924699..54bae34204c4 100644 --- a/plugins/kotlin/highlighting/highlighting-k1/src/org/jetbrains/kotlin/idea/highlighter/DebugInfoHighlightingPass.kt +++ b/plugins/kotlin/highlighting/highlighting-k1/src/org/jetbrains/kotlin/idea/highlighter/DebugInfoHighlightingPass.kt @@ -10,7 +10,9 @@ import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.colors.TextAttributesKey import com.intellij.openapi.progress.ProcessCanceledException +import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project +import com.intellij.openapi.util.registry.Registry import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import org.jetbrains.kotlin.checkers.utils.DebugInfoUtil @@ -82,7 +84,8 @@ class DebugInfoHighlightingPass(file: KtFile, document: Document) : AbstractBind // Temporary workaround to ignore red code in library sources psiFile.shouldHighlightErrors() && (isUnitTestMode() || isApplicationInternalMode() && (KotlinIdePlugin.isSnapshot || KotlinIdePlugin.isDev)) && - RootKindFilter.projectAndLibrarySources.matches(psiFile) + RootKindFilter.projectAndLibrarySources.matches(psiFile) && + (!DumbService.isDumb(psiFile.project) || Registry.`is`("ide.dumb.mode.check.awareness")) return if (useDebugInfoPass) DebugInfoHighlightingPass(psiFile as KtFile, editor.document) else null }