From d39c78f5af867382837a1606728b9c31a68e9604 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Tue, 15 Aug 2017 16:09:21 +0300 Subject: [PATCH] Kotlin Facet: Avoid reparse of additional arguments during analysis Original commit: 78b1fb2e933eb68b7f665cb672bbe36ed17472ea --- .../kotlin/config/KotlinFacetSettings.kt | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt index a63e6412787..d3a23e559eb 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -19,10 +19,7 @@ package org.jetbrains.kotlin.config import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments -import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments -import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments -import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.* import org.jetbrains.kotlin.utils.DescriptionAware sealed class TargetPlatformKind( @@ -83,13 +80,35 @@ class KotlinFacetSettings { var version = CURRENT_VERSION var useProjectSettings: Boolean = true + var mergedCompilerArguments: CommonCompilerArguments? = null + private set + + // TODO: Workaround for unwanted facet settings modification on code analysis + // To be replaced with proper API for settings update (see BaseKotlinCompilerSettings as an example) + fun updateMergedArguments() { + val compilerArguments = compilerArguments + val compilerSettings = compilerSettings + + mergedCompilerArguments = if (compilerArguments != null) { + copyBean(compilerArguments).apply { + if (compilerSettings != null) { + parseCommandLineArguments(compilerSettings.additionalArgumentsAsList, this) + } + } + } + else null + } + var compilerArguments: CommonCompilerArguments? = null set(value) { field = value?.unfrozen() as CommonCompilerArguments? + updateMergedArguments() } + var compilerSettings: CompilerSettings? = null set(value) { field = value?.unfrozen() as CompilerSettings? + updateMergedArguments() } var languageLevel: LanguageVersion?