From 0678a56ca425cba6a335eb7cb5209102b2110209 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 19 Oct 2018 18:19:21 +0300 Subject: [PATCH] Add workaround for tests to avoid problems with UnusedSymbolInspection #KT-27664 Fixed In particular, this should solve "Could not initialized UnusedSymbolInspection" and "Modifications during highlighting are not allowed" --- .../idea/test/KotlinLightCodeInsightFixtureTestCase.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt b/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt index f6999a1b321..f4861475a48 100644 --- a/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt +++ b/idea/idea-test-framework/test/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt @@ -40,6 +40,7 @@ import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerSettings import org.jetbrains.kotlin.idea.facet.KotlinFacet import org.jetbrains.kotlin.idea.facet.configureFacet import org.jetbrains.kotlin.idea.facet.getOrCreateFacet +import org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.COMPILER_ARGUMENTS_DIRECTIVE import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.JVM_TARGET_DIRECTIVE import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.LANGUAGE_VERSION_DIRECTIVE @@ -63,6 +64,12 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix override fun setUp() { super.setUp() + // We do it here to avoid possible initialization problems + // UnusedSymbolInspection() calls IDEA UnusedDeclarationInspection() in static initializer, + // which in turn registers some extensions provoking "modifications aren't allowed during highlighting" + // when done lazily + UnusedSymbolInspection() + (StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities() VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())