Kotlin Facet: Avoid reparse of additional arguments during analysis
This commit is contained in:
@@ -25,7 +25,6 @@ import com.intellij.openapi.roots.ProjectFileIndex
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.cli.common.arguments.Argument
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JvmCompilerArgumentsHolder
|
||||
@@ -111,17 +110,10 @@ val Module.languageVersionSettings: LanguageVersionSettings
|
||||
this
|
||||
)
|
||||
|
||||
val arguments = facetSettings.compilerArguments
|
||||
if (arguments != null) {
|
||||
facetSettings.compilerSettings?.let { compilerSettings ->
|
||||
parseCommandLineArguments(compilerSettings.additionalArgumentsAsList, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
return LanguageVersionSettingsImpl(
|
||||
languageVersion,
|
||||
ApiVersion.createByLanguageVersion(apiVersion),
|
||||
arguments?.configureAnalysisFlags().orEmpty(),
|
||||
facetSettings.mergedCompilerArguments?.configureAnalysisFlags().orEmpty(),
|
||||
extraLanguageFeatures
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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<out Version : TargetPlatformVersion>(
|
||||
@@ -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?
|
||||
|
||||
@@ -316,6 +316,7 @@ class KotlinFacetEditorGeneralTab(
|
||||
}
|
||||
}
|
||||
}
|
||||
updateMergedArguments()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,5 +238,7 @@ fun parseCompilerArgumentsToFacet(
|
||||
with(compilerArguments::class.java.newInstance()) {
|
||||
copyFieldsSatisfying(this, compilerArguments) { exposeAsAdditionalArgument(it) || it.name in ignoredFields }
|
||||
}
|
||||
|
||||
updateMergedArguments()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user