mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
Python: Remove unused symbols
GitOrigin-RevId: ec2bd2dda3f215a6c318afa70adbccc8627bd586
This commit is contained in:
committed by
intellij-monorepo-bot
parent
58d1b83ea3
commit
fe54db7b3c
@@ -9,24 +9,9 @@ class Python internal constructor(val pyenvDefinition: String,
|
|||||||
object Pythons {
|
object Pythons {
|
||||||
private val allPythons: ArrayList<Python> = ArrayList()
|
private val allPythons: ArrayList<Python> = ArrayList()
|
||||||
|
|
||||||
@Synchronized
|
|
||||||
internal fun createPython(pyenvDefinition: String, name: String, revision: String, packages: List<String>): Python {
|
|
||||||
return Python(pyenvDefinition, name, revision, packages).also {
|
|
||||||
allPythons.add(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun getPythons(): List<Python> {
|
fun getPythons(): List<Python> {
|
||||||
return allPythons.toList()
|
return allPythons.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
val BlackJobLibTenserFlowPython311 = createPython("3.11.7",
|
|
||||||
"black-joblib-tenserflow",
|
|
||||||
"1",
|
|
||||||
listOf("black == 23.1.0", "joblib", "tensorflow"))
|
|
||||||
val CondaWithPyTorch = createPython("Miniconda3-latest",
|
|
||||||
"conda-pytorch",
|
|
||||||
"1",
|
|
||||||
listOf("pytorch"))
|
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,6 @@ private val arch: String = System.getProperty("os.arch").lowercase().let { arch
|
|||||||
|
|
||||||
private const val pyEnvUrl = "https://github.com/pyenv/pyenv/archive/master.zip"
|
private const val pyEnvUrl = "https://github.com/pyenv/pyenv/archive/master.zip"
|
||||||
private const val pyEnvWinUrl = "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1"
|
private const val pyEnvWinUrl = "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1"
|
||||||
private val spaceUrl = "https://jetbrains.team/p/pyqa/packages/files/pythons"
|
|
||||||
private val pipOptions = arrayOf("--trusted-host", "pypi.python.org", "--trusted-host", "pypi.org", "--trusted-host", "files.pythonhosted.org")
|
private val pipOptions = arrayOf("--trusted-host", "pypi.python.org", "--trusted-host", "pypi.org", "--trusted-host", "files.pythonhosted.org")
|
||||||
val Python.directoryName: String
|
val Python.directoryName: String
|
||||||
get() = "$pyenvDefinition-$name-$revision-$os-$arch"
|
get() = "$pyenvDefinition-$name-$revision-$os-$arch"
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
||||||
package com.intellij.python.community.impl.huggingFace.annotation
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.ApiStatus
|
|
||||||
|
|
||||||
@ApiStatus.Internal @JvmInline value class HuggingFaceModelIdentifier(val value: String)
|
|
||||||
@ApiStatus.Internal @JvmInline value class HuggingFaceDatasetIdentifier(val value: String)
|
|
||||||
@ApiStatus.Internal @JvmInline value class HuggingFaceEntityIdentifier(val value: String)
|
|
||||||
@@ -30,7 +30,7 @@ object HuggingFaceCardsUsageCollector: CounterUsagesCollector() { // PY-70535 P
|
|||||||
|
|
||||||
enum class ActiveFileType { PY, IPYNB }
|
enum class ActiveFileType { PY, IPYNB }
|
||||||
enum class ModelChoiceEntryPointType { CONTEXT_MENU } // will be extended later
|
enum class ModelChoiceEntryPointType { CONTEXT_MENU } // will be extended later
|
||||||
enum class ModelChoiceDialogClosedResultType { USE_MODEL, CANCEL, CLOSE }
|
enum class ModelChoiceDialogClosedResultType { USE_MODEL, CLOSE }
|
||||||
enum class CacheManagementActionSource { CONTEXT_MENU, TOOLBAR }
|
enum class CacheManagementActionSource { CONTEXT_MENU, TOOLBAR }
|
||||||
enum class DialogWindowResult { OK, CANCEL }
|
enum class DialogWindowResult { OK, CANCEL }
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
package com.intellij.python.community.impl.huggingFace.service
|
package com.intellij.python.community.impl.huggingFace.service
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.application.EDT
|
|
||||||
import com.intellij.openapi.components.Service
|
import com.intellij.openapi.components.Service
|
||||||
import com.intellij.openapi.components.service
|
import com.intellij.openapi.components.service
|
||||||
import com.intellij.platform.util.coroutines.childScope
|
import com.intellij.platform.util.coroutines.childScope
|
||||||
@@ -14,13 +13,10 @@ import org.jetbrains.annotations.ApiStatus
|
|||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
class HuggingFaceCoroutine(coroutineScope: CoroutineScope) {
|
class HuggingFaceCoroutine(coroutineScope: CoroutineScope) {
|
||||||
val ioScope = coroutineScope.childScope(context = Dispatchers.IO)
|
val ioScope = coroutineScope.childScope(context = Dispatchers.IO)
|
||||||
val edtScope = coroutineScope.childScope(context = Dispatchers.EDT)
|
|
||||||
|
|
||||||
object Utils {
|
object Utils {
|
||||||
val ioScope: CoroutineScope
|
val ioScope: CoroutineScope
|
||||||
get() = ApplicationManager.getApplication().service<HuggingFaceCoroutine>().ioScope
|
get() = ApplicationManager.getApplication().service<HuggingFaceCoroutine>().ioScope
|
||||||
|
|
||||||
val edtScope: CoroutineScope
|
|
||||||
get() = ApplicationManager.getApplication().service<HuggingFaceCoroutine>().edtScope
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,138 +0,0 @@
|
|||||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
||||||
// Licensed under the terms of the Eclipse Public License (EPL).
|
|
||||||
package com.jetbrains.python.console.pydev
|
|
||||||
|
|
||||||
import com.intellij.openapi.diagnostic.Logger
|
|
||||||
import com.intellij.openapi.progress.EmptyProgressIndicator
|
|
||||||
import com.intellij.openapi.progress.ProcessCanceledException
|
|
||||||
import com.intellij.openapi.progress.ProgressIndicator
|
|
||||||
import com.intellij.openapi.progress.ProgressManager
|
|
||||||
import com.intellij.util.net.NetUtils
|
|
||||||
import org.apache.xmlrpc.*
|
|
||||||
import java.net.MalformedURLException
|
|
||||||
import java.net.URL
|
|
||||||
import java.util.*
|
|
||||||
import java.util.concurrent.Semaphore
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subclass of XmlRpcClient that will monitor the process so that if the process is destroyed, we stop waiting
|
|
||||||
* for messages from it.
|
|
||||||
|
|
||||||
* @author Fabio
|
|
||||||
*/
|
|
||||||
class PydevXmlRpcClient
|
|
||||||
/**
|
|
||||||
* Constructor (see fields description)
|
|
||||||
*/
|
|
||||||
@Throws(MalformedURLException::class)
|
|
||||||
constructor(private val process: Process, hostname: String?, port: Int) : IPydevXmlRpcClient {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal xml-rpc client (responsible for the actual communication with the server)
|
|
||||||
*/
|
|
||||||
private val impl: XmlRpcClient
|
|
||||||
private val requestSynchronizer = Semaphore(1, true)
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
|
||||||
XmlRpc.setDefaultInputEncoding("UTF8") //even though it uses UTF anyway
|
|
||||||
impl = XmlRpcClientLite(hostname ?: NetUtils.getLocalHostString(), port)
|
|
||||||
impl.maxThreads = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(process: Process, port: Int) : this(process = process, hostname = null, port = port)
|
|
||||||
|
|
||||||
|
|
||||||
override fun execute(command: String, args: Array<Any>): Any {
|
|
||||||
return execute(command, args, TIME_LIMIT)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes a command in the server.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Within this method, we should be careful about being able to return if the server dies.
|
|
||||||
* If we wanted to have a timeout, this would be the place to add it.
|
|
||||||
|
|
||||||
* @return the result from executing the given command in the server.
|
|
||||||
*/
|
|
||||||
@Throws(XmlRpcException::class)
|
|
||||||
override fun execute(command: String, args: Array<Any>, timeoutMillis: Long): Any {
|
|
||||||
|
|
||||||
val result = arrayOf<Any?>(null)
|
|
||||||
val started = System.currentTimeMillis()
|
|
||||||
/* Try to leave at least 'MIN_TIME_SLICE' time for actual execution
|
|
||||||
if not possible then divide the wait times evenly
|
|
||||||
*/
|
|
||||||
val semTimeout = maxOf(timeoutMillis - MIN_TIME_SLICE, MIN_TIME_SLICE / 2)
|
|
||||||
val progress = ProgressManager.getInstance().progressIndicator ?: EmptyProgressIndicator()
|
|
||||||
try {
|
|
||||||
if (!requestSynchronizer.tryAcquireWithIndicator(progress, timeoutMillis = semTimeout)) {
|
|
||||||
throw XmlRpcException(-1, "Timeout while connecting to server")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e: ProcessCanceledException) {
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
//make an async call so that we can keep track of not actually having an answer.
|
|
||||||
try {
|
|
||||||
impl.executeAsync(command, Vector(listOf(*args)), object : AsyncCallback {
|
|
||||||
|
|
||||||
override fun handleError(error: Exception, url: URL, method: String) {
|
|
||||||
requestSynchronizer.release()
|
|
||||||
result[0] = makeError(error.message ?: "Unknown Error")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun handleResult(recievedResult: Any, url: URL, method: String) {
|
|
||||||
requestSynchronizer.release()
|
|
||||||
result[0] = recievedResult
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
catch (t: Throwable) { // Should not show but just in case!
|
|
||||||
requestSynchronizer.release()
|
|
||||||
throw t
|
|
||||||
}
|
|
||||||
|
|
||||||
//busy loop waiting for the answer (or having the console die).
|
|
||||||
while (result[0] == null && System.currentTimeMillis() - started < timeoutMillis) {
|
|
||||||
progress.checkCanceled()
|
|
||||||
val exitValue = process.waitFor(10, TimeUnit.MILLISECONDS)
|
|
||||||
if (exitValue) {
|
|
||||||
result[0] = makeError(String.format("Console already exited with value: %s while waiting for an answer.\n", true))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result[0] ?: throw XmlRpcException(-1, "Timeout while connecting to server")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun makeError(error: String): Array<Any> {
|
|
||||||
return arrayOf(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Semaphore.tryAcquireWithIndicator(indicator: ProgressIndicator,
|
|
||||||
timeoutMillis: Long = TIME_LIMIT,
|
|
||||||
pollIntervalMillis: Long = 50): Boolean {
|
|
||||||
indicator.checkCanceled()
|
|
||||||
val started = System.currentTimeMillis()
|
|
||||||
while (!this.tryAcquire(1, pollIntervalMillis, java.util.concurrent.TimeUnit.MILLISECONDS)) {
|
|
||||||
indicator.checkCanceled()
|
|
||||||
if (System.currentTimeMillis() - started >= timeoutMillis) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ItelliJ Logging
|
|
||||||
*/
|
|
||||||
private val LOG = Logger.getInstance(PydevXmlRpcClient::class.java.name)
|
|
||||||
private const val MIN_TIME_SLICE: Long = 1000
|
|
||||||
private const val TIME_LIMIT: Long = 40000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -43,14 +43,6 @@ object PyDocumentationLink {
|
|||||||
return HtmlChunk.link("${DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL}$LINK_TYPE_CLASS", content)
|
return HtmlChunk.link("${DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL}$LINK_TYPE_CLASS", content)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun toParameterPossibleClass(@NlsSafe type: String, anchor: PsiElement, context: TypeEvalContext): HtmlChunk {
|
|
||||||
return when (PyTypeParser.getTypeByName(anchor, type, context)) {
|
|
||||||
is PyClassType -> HtmlChunk.link("${DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL}$LINK_TYPE_PARAM", type)
|
|
||||||
else -> HtmlChunk.text(type)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun toPossibleClass(typeName: @Nls String, anchor: PsiElement, context: TypeEvalContext): HtmlChunk =
|
fun toPossibleClass(typeName: @Nls String, anchor: PsiElement, context: TypeEvalContext): HtmlChunk =
|
||||||
when (val type = PyTypeParser.getTypeByName(anchor, typeName, context)) {
|
when (val type = PyTypeParser.getTypeByName(anchor, typeName, context)) {
|
||||||
|
|||||||
@@ -14,7 +14,4 @@ object PythonRestBundle : DynamicBundle(BUNDLE) {
|
|||||||
@Nls
|
@Nls
|
||||||
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = getMessage(key, *params)
|
fun message(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = getMessage(key, *params)
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun messagePointer(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any)
|
|
||||||
= getLazyMessage(key, *params)
|
|
||||||
}
|
}
|
||||||
@@ -118,14 +118,6 @@ fun waitForPythonConsoleServerToBeStarted(process: Process) {
|
|||||||
PydevConsoleRunnerImpl.getRemotePortFromProcess(process)
|
PydevConsoleRunnerImpl.getRemotePortFromProcess(process)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createPythonConsoleScriptInServerMode(serverPort: Int,
|
|
||||||
helpersAwareTargetRequest: HelpersAwareTargetEnvironmentRequest): PythonExecution {
|
|
||||||
val pythonScriptExecution = prepareHelperScriptExecution(PythonHelper.CONSOLE, helpersAwareTargetRequest)
|
|
||||||
pythonScriptExecution.addParameter(getOptionString(MODE_OPTION, MODE_OPTION_SERVER_VALUE))
|
|
||||||
pythonScriptExecution.addParameter(getOptionString(PORT_OPTION, serverPort))
|
|
||||||
return pythonScriptExecution
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ideServerPort the host and port where the IDE being Python
|
* @param ideServerPort the host and port where the IDE being Python
|
||||||
* Console frontend listens for the connection
|
* Console frontend listens for the connection
|
||||||
|
|||||||
@@ -167,23 +167,6 @@ open class PydevConsoleRunnerFactory : PythonConsoleRunnerFactory() {
|
|||||||
return SystemProperties.getUserHome()
|
return SystemProperties.getUserHome()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createSetupFragment(module: Module?,
|
|
||||||
workingDir: String?,
|
|
||||||
pathMapper: PathMapper?,
|
|
||||||
settingsProvider: PyConsoleSettings): Array<String> {
|
|
||||||
var customStartScript = settingsProvider.customStartScript
|
|
||||||
if (customStartScript.isNotBlank()) {
|
|
||||||
customStartScript = "\n" + customStartScript
|
|
||||||
}
|
|
||||||
var pythonPath = PythonCommandLineState.collectPythonPath(module, settingsProvider.shouldAddContentRoots(),
|
|
||||||
settingsProvider.shouldAddSourceRoots())
|
|
||||||
if (pathMapper != null) {
|
|
||||||
pythonPath = pathMapper.convertToRemote(pythonPath)
|
|
||||||
}
|
|
||||||
val selfPathAppend = constructPyPathAndWorkingDirCommand(pythonPath, workingDir, customStartScript)
|
|
||||||
return arrayOf(selfPathAppend)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun makeStartWithEmptyLine(line: String): String {
|
private fun makeStartWithEmptyLine(line: String): String {
|
||||||
if (line.startsWith("\n") || line.isBlank()) return line
|
if (line.startsWith("\n") || line.isBlank()) return line
|
||||||
return "\n" + line
|
return "\n" + line
|
||||||
|
|||||||
@@ -148,16 +148,6 @@ fun findPythonSdkAndModule(project: Project, contextModule: Module?): Pair<Sdk?,
|
|||||||
return Pair.create(sdk, module)
|
return Pair.create(sdk, module)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun constructPyPathAndWorkingDirCommand(pythonPath: MutableCollection<String>,
|
|
||||||
workingDir: String?,
|
|
||||||
command: String): String {
|
|
||||||
if (workingDir != null) {
|
|
||||||
pythonPath.add(workingDir)
|
|
||||||
}
|
|
||||||
val path = pythonPath.joinToString(separator = ", ", transform = String::toStringLiteral)
|
|
||||||
return command.replace(PydevConsoleRunnerImpl.WORKING_DIR_AND_PYTHON_PATHS, path)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun constructPyPathAndWorkingDirCommand(pythonPath: MutableCollection<Function<TargetEnvironment, String>>,
|
fun constructPyPathAndWorkingDirCommand(pythonPath: MutableCollection<Function<TargetEnvironment, String>>,
|
||||||
workingDirFunction: TargetEnvironmentFunction<String>?,
|
workingDirFunction: TargetEnvironmentFunction<String>?,
|
||||||
command: String): TargetEnvironmentFunction<String> {
|
command: String): TargetEnvironmentFunction<String> {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import com.intellij.ui.content.Content
|
|||||||
import com.intellij.ui.content.ContentFactory
|
import com.intellij.ui.content.ContentFactory
|
||||||
import com.intellij.ui.content.ContentManager
|
import com.intellij.ui.content.ContentManager
|
||||||
import com.intellij.ui.dsl.builder.panel
|
import com.intellij.ui.dsl.builder.panel
|
||||||
import com.intellij.xdebugger.XDebuggerManager
|
|
||||||
import com.jetbrains.python.PyBundle
|
import com.jetbrains.python.PyBundle
|
||||||
import com.jetbrains.python.console.PydevConsoleCommunication
|
import com.jetbrains.python.console.PydevConsoleCommunication
|
||||||
import com.jetbrains.python.debugger.PyDebugProcess
|
import com.jetbrains.python.debugger.PyDebugProcess
|
||||||
@@ -153,15 +152,6 @@ class PyDataView(private val project: Project) : DumbAware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFrameAccessor(handler: ProcessHandler): PyFrameAccessor? {
|
|
||||||
for (process in XDebuggerManager.getInstance(project).getDebugProcesses(PyDebugProcess::class.java)) {
|
|
||||||
if (Comparing.equal(handler, process.processHandler)) {
|
|
||||||
return process
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun closeDisconnectedFromConsoleTabs() {
|
fun closeDisconnectedFromConsoleTabs() {
|
||||||
closeTabs { frameAccessor: PyFrameAccessor? ->
|
closeTabs { frameAccessor: PyFrameAccessor? ->
|
||||||
frameAccessor is PydevConsoleCommunication && !isConnected(frameAccessor)
|
frameAccessor is PydevConsoleCommunication && !isConnected(frameAccessor)
|
||||||
|
|||||||
@@ -2,13 +2,10 @@
|
|||||||
package com.jetbrains.python.newProject.steps
|
package com.jetbrains.python.newProject.steps
|
||||||
|
|
||||||
import com.intellij.ide.IdeBundle
|
import com.intellij.ide.IdeBundle
|
||||||
import com.intellij.ide.impl.ProjectUtil
|
|
||||||
import com.intellij.ide.impl.ProjectUtil.getUserHomeProjectDir
|
|
||||||
import com.intellij.ide.util.projectWizard.AbstractNewProjectStep
|
import com.intellij.ide.util.projectWizard.AbstractNewProjectStep
|
||||||
import com.intellij.ide.util.projectWizard.WebProjectSettingsStepWrapper
|
import com.intellij.ide.util.projectWizard.WebProjectSettingsStepWrapper
|
||||||
import com.intellij.ide.util.projectWizard.WebProjectTemplate
|
import com.intellij.ide.util.projectWizard.WebProjectTemplate
|
||||||
import com.intellij.openapi.GitRepositoryInitializer
|
import com.intellij.openapi.GitRepositoryInitializer
|
||||||
import com.intellij.openapi.application.PathManager
|
|
||||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
|
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
|
||||||
import com.intellij.openapi.observable.properties.PropertyGraph
|
import com.intellij.openapi.observable.properties.PropertyGraph
|
||||||
import com.intellij.openapi.observable.util.bindBooleanStorage
|
import com.intellij.openapi.observable.util.bindBooleanStorage
|
||||||
@@ -27,7 +24,6 @@ import com.intellij.ui.dsl.builder.Align
|
|||||||
import com.intellij.ui.dsl.builder.bindSelected
|
import com.intellij.ui.dsl.builder.bindSelected
|
||||||
import com.intellij.ui.dsl.builder.bindText
|
import com.intellij.ui.dsl.builder.bindText
|
||||||
import com.intellij.ui.dsl.builder.panel
|
import com.intellij.ui.dsl.builder.panel
|
||||||
import com.intellij.util.PlatformUtils
|
|
||||||
import com.intellij.util.SystemProperties
|
import com.intellij.util.SystemProperties
|
||||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||||
import com.jetbrains.python.PyBundle.message
|
import com.jetbrains.python.PyBundle.message
|
||||||
@@ -39,7 +35,6 @@ import com.jetbrains.python.sdk.PyLazySdk
|
|||||||
import com.jetbrains.python.sdk.add.v2.PythonAddNewEnvironmentPanel
|
import com.jetbrains.python.sdk.add.v2.PythonAddNewEnvironmentPanel
|
||||||
import com.jetbrains.python.util.ShowingMessageErrorSync
|
import com.jetbrains.python.util.ShowingMessageErrorSync
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import java.io.File
|
|
||||||
import java.nio.file.InvalidPathException
|
import java.nio.file.InvalidPathException
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import javax.swing.JPanel
|
import javax.swing.JPanel
|
||||||
@@ -169,14 +164,6 @@ class PythonProjectSpecificSettingsStep<T : PyNewProjectSettings>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun getBaseDir(): File {
|
|
||||||
if (PlatformUtils.isDataSpell() && Path.of(ProjectUtil.getBaseDir()).startsWith(PathManager.getConfigDir())) {
|
|
||||||
return File(getUserHomeProjectDir())
|
|
||||||
}
|
|
||||||
return File(ProjectUtil.getBaseDir())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateHint(): String =
|
private fun updateHint(): String =
|
||||||
try {
|
try {
|
||||||
val projectPath = Path.of(projectLocation.get(), projectName.get())
|
val projectPath = Path.of(projectLocation.get(), projectName.get())
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ abstract class PythonRepositoryManager(val project: Project, val sdk: Sdk) {
|
|||||||
abstract fun allPackages(): List<String>
|
abstract fun allPackages(): List<String>
|
||||||
|
|
||||||
abstract fun packagesFromRepository(repository: PyPackageRepository): List<String>
|
abstract fun packagesFromRepository(repository: PyPackageRepository): List<String>
|
||||||
suspend fun addRepository(repository: PyPackageRepository) { TODO() }
|
|
||||||
suspend fun removeRepository(repository: PyPackageRepository) { TODO() }
|
|
||||||
abstract suspend fun getPackageDetails(pkg: PythonPackageSpecification): PythonPackageDetails
|
abstract suspend fun getPackageDetails(pkg: PythonPackageSpecification): PythonPackageDetails
|
||||||
abstract suspend fun getLatestVersion(spec: PythonPackageSpecification): PyPackageVersion?
|
abstract suspend fun getLatestVersion(spec: PythonPackageSpecification): PyPackageVersion?
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,7 @@ import com.jetbrains.python.packaging.toolwindow.packages.PyPackageSearchTextFie
|
|||||||
import com.jetbrains.python.packaging.toolwindow.packages.PyPackagesListController
|
import com.jetbrains.python.packaging.toolwindow.packages.PyPackagesListController
|
||||||
import com.jetbrains.python.packaging.toolwindow.ui.PyPackagesUiComponents
|
import com.jetbrains.python.packaging.toolwindow.ui.PyPackagesUiComponents
|
||||||
import com.jetbrains.python.packaging.utils.PyPackageCoroutine
|
import com.jetbrains.python.packaging.utils.PyPackageCoroutine
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
import java.awt.Dimension
|
import java.awt.Dimension
|
||||||
import java.awt.event.ActionEvent
|
import java.awt.event.ActionEvent
|
||||||
@@ -204,15 +202,6 @@ class PyPackagingToolWindowPanel(private val project: Project) : SimpleToolWindo
|
|||||||
packagingScope.cancel()
|
packagingScope.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal suspend fun recreateModulePanel() {
|
|
||||||
val newPanel = createLeftPanel()
|
|
||||||
withContext(Dispatchers.Main) {
|
|
||||||
leftPanel = newPanel
|
|
||||||
splitter?.firstComponent = leftPanel
|
|
||||||
splitter?.repaint()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun selectPackageName(name: String) {
|
fun selectPackageName(name: String) {
|
||||||
this.packageListController.selectPackage(name)
|
this.packageListController.selectPackage(name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
||||||
package com.jetbrains.python.refactoring.surround.surrounders.expressions
|
|
||||||
|
|
||||||
import com.intellij.openapi.util.NlsSafe
|
|
||||||
import com.jetbrains.python.psi.PyExpression
|
|
||||||
import com.jetbrains.python.psi.PyForStatement
|
|
||||||
import com.jetbrains.python.psi.PyStatement
|
|
||||||
import com.jetbrains.python.psi.PyStatementListContainer
|
|
||||||
|
|
||||||
class PyForExpressionSurrounder : PyExpressionAsConditionSurrounder() {
|
|
||||||
@NlsSafe
|
|
||||||
override fun getTemplateDescription(): String = "for e in expr"
|
|
||||||
|
|
||||||
override fun getTextToGenerate(): String = "for i in expr:\n pass"
|
|
||||||
|
|
||||||
override fun getCondition(statement: PyStatement?): PyExpression? {
|
|
||||||
return (statement as? PyForStatement)?.forPart?.source
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getStatementListContainer(statement: PyStatement?): PyStatementListContainer? {
|
|
||||||
return (statement as? PyForStatement)?.forPart
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,6 @@
|
|||||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package com.jetbrains.python.requirements
|
package com.jetbrains.python.requirements
|
||||||
|
|
||||||
import com.intellij.execution.process.ProcessOutput
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
|
||||||
import com.intellij.openapi.projectRoots.Sdk
|
|
||||||
import com.jetbrains.python.sdk.PySdkUtil
|
|
||||||
import com.jetbrains.python.sdk.PythonSdkType
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import java.io.File
|
|
||||||
import java.time.LocalDateTime
|
|
||||||
|
|
||||||
const val PLATFORM_RELEASE = "platform_release"
|
const val PLATFORM_RELEASE = "platform_release"
|
||||||
const val PYTHON_VERSION = "python_version"
|
const val PYTHON_VERSION = "python_version"
|
||||||
const val PYTHON_FULL_VERSION = "python_full_version"
|
const val PYTHON_FULL_VERSION = "python_full_version"
|
||||||
@@ -19,76 +9,3 @@ const val PACKAGE_VERSION = "package_version"
|
|||||||
|
|
||||||
val VERSION_VARIABLES = listOf(IMPLEMENTATION_VERSION, PLATFORM_RELEASE, PYTHON_FULL_VERSION, PYTHON_VERSION, PACKAGE_VERSION)
|
val VERSION_VARIABLES = listOf(IMPLEMENTATION_VERSION, PLATFORM_RELEASE, PYTHON_FULL_VERSION, PYTHON_VERSION, PACKAGE_VERSION)
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class PythonInfo(
|
|
||||||
var osName: String? = null,
|
|
||||||
var sysPlatform: String? = null,
|
|
||||||
var platformMachine: String? = null,
|
|
||||||
var platformPythonImplementation: String? = null,
|
|
||||||
var platformRelease: String? = null,
|
|
||||||
var platformSystem: String? = null,
|
|
||||||
var platformVersion: String? = null,
|
|
||||||
var pythonVersion: String? = null,
|
|
||||||
var pythonFullVersion: String? = null,
|
|
||||||
var implementationName: String? = null,
|
|
||||||
var implementationVersion: String? = null,
|
|
||||||
var extra: String? = null
|
|
||||||
) {
|
|
||||||
val map: Map<String, String?>
|
|
||||||
get() {
|
|
||||||
return mapOf(
|
|
||||||
"os_name" to osName,
|
|
||||||
"sys_platform" to sysPlatform,
|
|
||||||
"platform_machine" to platformMachine,
|
|
||||||
"platform_python_implementation" to platformPythonImplementation,
|
|
||||||
"platform_release" to platformRelease,
|
|
||||||
"platform_system" to platformSystem,
|
|
||||||
"platform_version" to platformVersion,
|
|
||||||
"python_version" to pythonVersion,
|
|
||||||
"python_full_version" to pythonFullVersion,
|
|
||||||
"implementation_name" to implementationName,
|
|
||||||
"implementation_version" to implementationVersion,
|
|
||||||
"extra" to extra
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val markersCache = mutableMapOf<String, Pair<PythonInfo, LocalDateTime>>()
|
|
||||||
|
|
||||||
fun getPythonInfo(sdk: Sdk): PythonInfo {
|
|
||||||
val cached = markersCache[sdk.name]
|
|
||||||
if (cached != null) {
|
|
||||||
val actual = cached.second.plusDays(1).isAfter(LocalDateTime.now())
|
|
||||||
if (actual) {
|
|
||||||
return cached.first
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val scriptResource = object {}.javaClass.getResource("/python_info.py")
|
|
||||||
val code = scriptResource?.readText()
|
|
||||||
val result = code?.let { execPythonCode(sdk, it) } ?: return PythonInfo()
|
|
||||||
val pythonInfo = Json.decodeFromString<PythonInfo>(result)
|
|
||||||
markersCache[sdk.name] = pythonInfo to LocalDateTime.now()
|
|
||||||
|
|
||||||
return pythonInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
fun execPythonCode(sdk: Sdk, code: String): String? {
|
|
||||||
if (sdk.sdkType !is PythonSdkType) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
val pythonPath = sdk.homePath ?: return null
|
|
||||||
|
|
||||||
val output = ApplicationManager.getApplication()
|
|
||||||
.executeOnPooledThread<ProcessOutput> {
|
|
||||||
return@executeOnPooledThread PySdkUtil.getProcessOutput(
|
|
||||||
File(pythonPath).parent,
|
|
||||||
listOf(sdk.homePath, "-c", code).toTypedArray(),
|
|
||||||
5000
|
|
||||||
)
|
|
||||||
}.get() ?: return null
|
|
||||||
if (output.exitCode != 0 || output.isTimeout || output.isCancelled) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return output.stdout
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -40,18 +40,6 @@ class RequirementsFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvide
|
|||||||
return getPythonSdk(this)
|
return getPythonSdk(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enabledRequirements(): List<Requirement> {
|
|
||||||
val sdk = sdk ?: return emptyList()
|
|
||||||
return requirements().filter {
|
|
||||||
it.enabled(getPythonInfo(sdk).map)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun disabledRequirements(): List<Requirement> {
|
|
||||||
val sdk = sdk ?: return requirements()
|
|
||||||
return requirements().filter { !it.enabled(getPythonInfo(sdk).map) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "Requirements File"
|
return "Requirements File"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.jetbrains.python.requirements.psi.NameReq
|
|||||||
import com.jetbrains.python.requirements.psi.UriReference
|
import com.jetbrains.python.requirements.psi.UriReference
|
||||||
|
|
||||||
open class RequirementsInspectionVisitor(val holder: ProblemsHolder,
|
open class RequirementsInspectionVisitor(val holder: ProblemsHolder,
|
||||||
val onTheFly: Boolean,
|
|
||||||
val session: LocalInspectionToolSession) : PsiElementVisitor() {
|
val session: LocalInspectionToolSession) : PsiElementVisitor() {
|
||||||
|
|
||||||
override fun visitElement(element: PsiElement) {
|
override fun visitElement(element: PsiElement) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class UnsatisfiedRequirementInspection : LocalInspectionTool() {
|
|||||||
private class UnsatisfiedRequirementInspectionVisitor(holder: ProblemsHolder,
|
private class UnsatisfiedRequirementInspectionVisitor(holder: ProblemsHolder,
|
||||||
onTheFly: Boolean,
|
onTheFly: Boolean,
|
||||||
session: LocalInspectionToolSession) : RequirementsInspectionVisitor(
|
session: LocalInspectionToolSession) : RequirementsInspectionVisitor(
|
||||||
holder, onTheFly, session) {
|
holder, session) {
|
||||||
override fun visitRequirementsFile(element: RequirementsFile) {
|
override fun visitRequirementsFile(element: RequirementsFile) {
|
||||||
val module = ModuleUtilCore.findModuleForPsiElement(element)
|
val module = ModuleUtilCore.findModuleForPsiElement(element)
|
||||||
val requirementsPath = PyPackageRequirementsSettings.getInstance(module).requirementsPath
|
val requirementsPath = PyPackageRequirementsSettings.getInstance(module).requirementsPath
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
||||||
package com.jetbrains.python.run
|
|
||||||
|
|
||||||
import com.intellij.execution.ExecutionException
|
|
||||||
import com.intellij.openapi.diagnostic.ControlFlowException
|
|
||||||
import com.intellij.openapi.util.NlsContexts
|
|
||||||
import org.jetbrains.annotations.ApiStatus
|
|
||||||
import javax.swing.event.HyperlinkEvent
|
|
||||||
import javax.swing.event.HyperlinkListener
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The exception implements [ControlFlowException] to skip the logging (see `org.jetbrains.concurrency.Promises.errorIfNotMessage`).
|
|
||||||
*/
|
|
||||||
@ApiStatus.Internal
|
|
||||||
internal class ExecutionExceptionWithHyperlink(s: @NlsContexts.DialogMessage String, private val hyperlinkActivatedCallback: Runnable)
|
|
||||||
: ExecutionException(s), HyperlinkListener, ControlFlowException {
|
|
||||||
override fun hyperlinkUpdate(e: HyperlinkEvent) {
|
|
||||||
if (e.eventType == HyperlinkEvent.EventType.ACTIVATED) {
|
|
||||||
hyperlinkActivatedCallback.run()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The exception implements [ControlFlowException] to skip the logging (see `org.jetbrains.concurrency.Promises.errorIfNotMessage`).
|
|
||||||
*/
|
|
||||||
@ApiStatus.Internal
|
|
||||||
internal class RuntimeExceptionWithHyperlink(s: @NlsContexts.DialogMessage String, private val hyperlinkActivatedCallback: Runnable)
|
|
||||||
: RuntimeException(s), HyperlinkListener, ControlFlowException {
|
|
||||||
override fun hyperlinkUpdate(e: HyperlinkEvent) {
|
|
||||||
if (e.eventType == HyperlinkEvent.EventType.ACTIVATED) {
|
|
||||||
hyperlinkActivatedCallback.run()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +1,10 @@
|
|||||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package com.jetbrains.python.run
|
package com.jetbrains.python.run
|
||||||
|
|
||||||
import com.intellij.execution.target.RunConfigurationTargetEnvironmentAdjuster
|
|
||||||
import com.intellij.openapi.options.SettingsEditor
|
|
||||||
import com.intellij.openapi.util.registry.Registry
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class PyRunConfigurationTargetOptions : PyRunConfigurationEditorExtension {
|
class PyRunConfigurationTargetOptions : PyRunConfigurationEditorExtension {
|
||||||
private val factoriesCache = WeakHashMap<RunConfigurationTargetEnvironmentAdjuster, PyRunConfigurationEditorFactory>()
|
|
||||||
|
|
||||||
override fun accepts(configuration: AbstractPythonRunConfiguration<out AbstractPythonRunConfiguration<*>>): PyRunConfigurationEditorFactory? {
|
override fun accepts(configuration: AbstractPythonRunConfiguration<out AbstractPythonRunConfiguration<*>>): PyRunConfigurationEditorFactory? {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RunConfigurationsTargetOptionsFactory(private val adjuster: RunConfigurationTargetEnvironmentAdjuster) : PyRunConfigurationEditorFactory {
|
|
||||||
override fun createEditor(configuration: AbstractPythonRunConfiguration<*>): SettingsEditor<AbstractPythonRunConfiguration<*>> {
|
|
||||||
val adjuster = RunConfigurationTargetEnvironmentAdjuster.Factory.findTargetEnvironmentRequestAdjuster(configuration.sdk!!)!!
|
|
||||||
val runConfigurationEditor = adjuster.createAdditionalRunConfigurationUI(configuration) { configuration.sdk }
|
|
||||||
return runConfigurationEditor as SettingsEditor<AbstractPythonRunConfiguration<*>>
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
if (this === other) return true
|
|
||||||
if (javaClass != other?.javaClass) return false
|
|
||||||
|
|
||||||
other as RunConfigurationsTargetOptionsFactory
|
|
||||||
|
|
||||||
return adjuster == other.adjuster
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return adjuster.hashCode()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,6 @@ import com.intellij.openapi.actionSystem.AnAction
|
|||||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.project.DumbAware
|
import com.intellij.openapi.project.DumbAware
|
||||||
import com.intellij.openapi.project.DumbAwareAction
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.projectRoots.Sdk
|
import com.intellij.openapi.projectRoots.Sdk
|
||||||
import com.jetbrains.python.PyBundle
|
import com.jetbrains.python.PyBundle
|
||||||
@@ -21,7 +20,6 @@ import com.jetbrains.python.run.PythonInterpreterTargetEnvironmentFactory
|
|||||||
import com.jetbrains.python.run.allowCreationTargetOfThisType
|
import com.jetbrains.python.run.allowCreationTargetOfThisType
|
||||||
import com.jetbrains.python.sdk.ModuleOrProject.ModuleAndProject
|
import com.jetbrains.python.sdk.ModuleOrProject.ModuleAndProject
|
||||||
import com.jetbrains.python.sdk.ModuleOrProject.ProjectOnly
|
import com.jetbrains.python.sdk.ModuleOrProject.ProjectOnly
|
||||||
import com.jetbrains.python.sdk.add.PyAddSdkDialog
|
|
||||||
import com.jetbrains.python.sdk.add.collector.PythonNewInterpreterAddedCollector
|
import com.jetbrains.python.sdk.add.collector.PythonNewInterpreterAddedCollector
|
||||||
import com.jetbrains.python.sdk.add.v2.PythonAddLocalInterpreterDialog
|
import com.jetbrains.python.sdk.add.v2.PythonAddLocalInterpreterDialog
|
||||||
import com.jetbrains.python.sdk.add.v2.PythonAddLocalInterpreterPresenter
|
import com.jetbrains.python.sdk.add.v2.PythonAddLocalInterpreterPresenter
|
||||||
@@ -93,27 +91,6 @@ private class AddInterpreterOnTargetAction(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddInterpreterAction(val project: Project, val module: Module, private val currentSdk: Sdk?)
|
|
||||||
: DumbAwareAction(PyBundle.messagePointer("python.sdk.popup.add.interpreter")) {
|
|
||||||
|
|
||||||
override fun actionPerformed(e: AnActionEvent) {
|
|
||||||
val model = PyConfigurableInterpreterList.getInstance(project).model
|
|
||||||
|
|
||||||
PyAddSdkDialog.show(
|
|
||||||
project,
|
|
||||||
module,
|
|
||||||
model.sdks.asList(),
|
|
||||||
Consumer {
|
|
||||||
if (it != null && model.findSdk(it.name) == null) {
|
|
||||||
model.addSdk(it)
|
|
||||||
model.apply()
|
|
||||||
switchToSdk(module, it, currentSdk)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun switchToSdk(module: Module, sdk: Sdk, currentSdk: Sdk?) {
|
fun switchToSdk(module: Module, sdk: Sdk, currentSdk: Sdk?) {
|
||||||
val project = module.project
|
val project = module.project
|
||||||
(sdk.sdkType as PythonSdkType).setupSdkPaths(sdk)
|
(sdk.sdkType as PythonSdkType).setupSdkPaths(sdk)
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ import com.intellij.util.ui.showingScope
|
|||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import org.jetbrains.annotations.ApiStatus
|
import org.jetbrains.annotations.ApiStatus
|
||||||
import org.jetbrains.annotations.Nls
|
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
import javax.swing.JLabel
|
|
||||||
import javax.swing.JToggleButton
|
import javax.swing.JToggleButton
|
||||||
import javax.swing.text.JTextComponent
|
import javax.swing.text.JTextComponent
|
||||||
|
|
||||||
@@ -38,18 +36,6 @@ fun Cell<JTextComponent>.bindText(flow: MutableStateFlow<String>) = apply {
|
|||||||
bindImpl(flow, { text(it) }, Pair({ component.text }, flow))
|
bindImpl(flow, { text(it) }, Pair({ component.text }, flow))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as [bindText] but for r/o labels:
|
|
||||||
* ```kotlin
|
|
||||||
* val f:Flow<String>
|
|
||||||
* label("..").bindLabelText(f)
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
fun Cell<JLabel>.bindLabelText(flow: Flow<@Nls String>) = apply {
|
|
||||||
bindImpl(flow, { component.text = it })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds checkbox to a [Flow] making changing its `selected` state on each event
|
* Binds checkbox to a [Flow] making changing its `selected` state on each event
|
||||||
* ```kotlin
|
* ```kotlin
|
||||||
|
|||||||
Reference in New Issue
Block a user