mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Python: move sdk-specific code to sdk.
GitOrigin-RevId: 6fae443546bf490f90608f17f5b32528786978a0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d1706ef57c
commit
4618dc40b0
@@ -1,8 +1,11 @@
|
||||
package com.jetbrains.python.sdk
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.writeAction
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
|
||||
/**
|
||||
* Each [Sdk] has [PythonSdkAdditionalData]. Use this method to get it.
|
||||
@@ -38,4 +41,15 @@ fun Sdk.getOrCreateAdditionalData(): PythonSdkAdditionalData {
|
||||
}
|
||||
}
|
||||
return newData
|
||||
}
|
||||
|
||||
@Internal
|
||||
/**
|
||||
* Saves SDK to the project table if there is no sdk with same name
|
||||
*/
|
||||
suspend fun Sdk.persist(): Unit = writeAction {
|
||||
if (ProjectJdkTable.getInstance().findJdk(name) == null) { // Saving 2 SDKs with same name is an error
|
||||
getOrCreateAdditionalData() // additional data is always required
|
||||
ProjectJdkTable.getInstance().addJdk(this)
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import com.intellij.openapi.module.ModuleUtil
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.progress.Task
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
@@ -565,15 +564,4 @@ val Sdk.sdkSeemsValid: Boolean
|
||||
val pythonSdkAdditionalData = getOrCreateAdditionalData()
|
||||
if (pythonSdkAdditionalData is PyRemoteSdkAdditionalData) return true
|
||||
return pythonSdkAdditionalData.flavorAndData.sdkSeemsValid(this, targetEnvConfiguration)
|
||||
}
|
||||
|
||||
@Internal
|
||||
/**
|
||||
* Saves SDK to the project table if there is no sdk with same name
|
||||
*/
|
||||
suspend fun Sdk.persist(): Unit = writeAction {
|
||||
if (ProjectJdkTable.getInstance().findJdk(name) == null) { // Saving 2 SDKs with same name is an error
|
||||
getOrCreateAdditionalData() // additional data is always required
|
||||
ProjectJdkTable.getInstance().addJdk(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user