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"
This commit is contained in:
Mikhail Glukhikh
2018-10-19 18:19:21 +03:00
parent 9653fe2fcf
commit 0678a56ca4
@@ -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())