PY-60844: Cleanup PyTargetAwareAdditionalData

GitOrigin-RevId: 67f3c13bacb873413be0c9d392f1a1081db9362d
This commit is contained in:
Ilia Zakoulov
2023-06-01 13:38:38 +02:00
committed by intellij-monorepo-bot
parent b463626973
commit bf9fb5e834

View File

@@ -30,37 +30,26 @@ class PyTargetAwareAdditionalData private constructor(private val b: RemoteSdkPr
RemoteSdkProperties by b,
PyRemoteSdkAdditionalDataMarker {
/**
* The source of truth for the target configuration.
*/
private var targetState: ContributedConfigurationsList.ContributedStateBase? = null
/**
* The backing field for [targetEnvironmentConfiguration].
*/
private var _targetEnvironmentConfiguration: TargetEnvironmentConfiguration? = targetEnvironmentConfiguration
/**
* The target configuration.
*
* Note that [targetEnvironmentConfiguration] could be `null` even if [targetState] is not `null`, when there is no appropriate
* [TargetEnvironmentType] available for deserializing and handling [ContributedStateBase.innerState] of [targetState].
*/
override var targetEnvironmentConfiguration: TargetEnvironmentConfiguration?
get() = _targetEnvironmentConfiguration
override var targetEnvironmentConfiguration: TargetEnvironmentConfiguration? = targetEnvironmentConfiguration
set(value) {
_targetEnvironmentConfiguration = value
field = value
notifyTargetEnvironmentConfigurationChanged()
}
constructor(flavorAndData: PyFlavorAndData<*, *>, targetEnvironmentConfiguration: TargetEnvironmentConfiguration? = null) : this(
RemoteSdkPropertiesHolder(DEFAULT_PYCHARM_HELPERS_DIR_NAME), flavorAndData, targetEnvironmentConfiguration)
init {
this.targetEnvironmentConfiguration = targetEnvironmentConfiguration
}
override fun save(rootElement: Element) {
// store "interpeter paths" (i.e. `PYTHONPATH` elements)
super.save(rootElement)
@@ -71,9 +60,8 @@ class PyTargetAwareAdditionalData private constructor(private val b: RemoteSdkPr
}
override fun load(element: Element?) {
// clear the state
targetState = null
_targetEnvironmentConfiguration = null
// clear the state and environment configuration
targetEnvironmentConfiguration = null
// load "interpeter paths" (i.e. `PYTHONPATH` elements)
super.load(element)
if (element == null) {
@@ -92,9 +80,7 @@ class PyTargetAwareAdditionalData private constructor(private val b: RemoteSdkPr
}
loadedConfiguration.addLanguageRuntime(pythonLanguageRuntimeConfiguration)
}
targetState = loadedState
_targetEnvironmentConfiguration = loadedConfiguration
targetEnvironmentConfiguration = loadedConfiguration
}
/**
@@ -145,7 +131,6 @@ class PyTargetAwareAdditionalData private constructor(private val b: RemoteSdkPr
@JvmStatic
val PyTargetAwareAdditionalData.pathsRemovedByUser: Map<Path, String> get() = this.excludedPathFiles.asMappings
/**
* Loads target data if it exists in xml. Returns `null` otherwise.
* @see com.jetbrains.python.remote.PyRemoteSdkAdditionalData.loadRemote
@@ -162,6 +147,4 @@ class PyTargetAwareAdditionalData private constructor(private val b: RemoteSdkPr
return if (data.targetEnvironmentConfiguration != null) data else null
}
}
private sealed class DataOrFlavor
}
}