KTIJ-650 [Code completion]: test framework fix
This commit fixes test infrastructure issue. Usage of "COMPILER_ARGUMENTS" test-data-instruction resulted in side effect. Test cases following the one that used it got broken LanguageVersionSetting - LanguageFeature.MultiPlatformProjects escaped, languageVersion could be wrong. Why it happened KotlinProjectDescriptorWithFacet defines default values of (language-version, isMultiplatform) settings for the test-case. The values themselves are stored in KotlinFacetSettings and passed there only once. After every test-case (if it uses "COMPILER_ARGUMENTS") infrastructure calls KotlinLightCodeInsightFixtureTestCaseKt#rollbackCompilerOptions which resets mentioned values (among others) in KotlinFacetSettings. Instances of KotlinProjectDescriptorWithFacet are reused hence facet settings remained reset.
This commit is contained in:
+3
-3
@@ -23,9 +23,9 @@ abstract class AbstractKeywordCompletionTest : KotlinFixtureCompletionBaseTestCa
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getProjectDescriptor(): KotlinLightProjectDescriptor = when {
|
override fun getProjectDescriptor(): KotlinLightProjectDescriptor = when {
|
||||||
"LangLevel10" in fileName() -> KotlinProjectDescriptorWithFacet.KOTLIN_10
|
"LangLevel10" in fileName() -> KotlinProjectDescriptorWithFacet.KOTLIN_10.apply { replicateToFacetSettings() }
|
||||||
"LangLevel11" in fileName() -> KotlinProjectDescriptorWithFacet.KOTLIN_11
|
"LangLevel11" in fileName() -> KotlinProjectDescriptorWithFacet.KOTLIN_11.apply { replicateToFacetSettings() }
|
||||||
else -> KotlinProjectDescriptorWithFacet.KOTLIN_STABLE_WITH_MULTIPLATFORM
|
else -> KotlinProjectDescriptorWithFacet.KOTLIN_STABLE_WITH_MULTIPLATFORM.apply { replicateToFacetSettings() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun defaultInvocationCount() = 1
|
override fun defaultInvocationCount() = 1
|
||||||
|
|||||||
+17
-5
@@ -30,13 +30,25 @@ class KotlinProjectDescriptorWithFacet(
|
|||||||
private val languageVersion: LanguageVersion,
|
private val languageVersion: LanguageVersion,
|
||||||
private val multiPlatform: Boolean = false
|
private val multiPlatform: Boolean = false
|
||||||
) : KotlinLightProjectDescriptor() {
|
) : KotlinLightProjectDescriptor() {
|
||||||
|
|
||||||
|
private var facetConfig: KotlinFacetConfiguration? = null
|
||||||
|
|
||||||
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
|
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
|
||||||
configureKotlinFacet(module) {
|
configureKotlinFacet(module) {
|
||||||
settings.languageLevel = languageVersion
|
facetConfig = this
|
||||||
if (multiPlatform) {
|
toFacetConfig(this)
|
||||||
settings.compilerSettings = CompilerSettings().apply {
|
}
|
||||||
additionalArguments += " -Xmulti-platform"
|
}
|
||||||
}
|
|
||||||
|
fun replicateToFacetSettings() {
|
||||||
|
facetConfig?.let { toFacetConfig(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun toFacetConfig(configuration: KotlinFacetConfiguration) {
|
||||||
|
configuration.settings.languageLevel = languageVersion
|
||||||
|
if (multiPlatform) {
|
||||||
|
configuration.settings.compilerSettings = CompilerSettings().apply {
|
||||||
|
additionalArguments += " -Xmulti-platform"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user