mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
Cleanup PyCondaPackageService after convertion to Kotlin
GitOrigin-RevId: 1c0983527cf7d76c40b8f7135f139dd63ec453bd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
20f4cbe128
commit
6ec5aaa128
@@ -1,26 +1,19 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.packaging
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.components.RoamingType
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil
|
||||
import com.intellij.util.xmlb.annotations.Property
|
||||
import org.jetbrains.annotations.SystemDependent
|
||||
|
||||
@State(name = "PyCondaPackageService", storages = [Storage(value = "conda_packages.xml", roamingType = RoamingType.DISABLED)])
|
||||
class PyCondaPackageService : PersistentStateComponent<PyCondaPackageService?> {
|
||||
class PyCondaPackageService : PersistentStateComponent<PyCondaPackageService> {
|
||||
@Property
|
||||
var preferredCondaPath: @SystemDependent String? = null
|
||||
private set
|
||||
|
||||
override fun getState(): PyCondaPackageService? {
|
||||
return this
|
||||
}
|
||||
override fun getState(): PyCondaPackageService = this
|
||||
|
||||
override fun loadState(state: PyCondaPackageService) {
|
||||
XmlSerializerUtil.copyBean(state, this)
|
||||
@@ -29,8 +22,7 @@ class PyCondaPackageService : PersistentStateComponent<PyCondaPackageService?> {
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(PyCondaPackageService::class.java)
|
||||
|
||||
val instance: PyCondaPackageService
|
||||
get() = ApplicationManager.getApplication().getService(PyCondaPackageService::class.java)
|
||||
fun getInstance(): PyCondaPackageService = service<PyCondaPackageService>()
|
||||
|
||||
@JvmStatic
|
||||
fun getCondaExecutable(sdkPath: String?): @SystemDependent String? {
|
||||
@@ -42,8 +34,8 @@ class PyCondaPackageService : PersistentStateComponent<PyCondaPackageService?> {
|
||||
}
|
||||
}
|
||||
|
||||
val preferredCondaPath = instance.preferredCondaPath
|
||||
if (StringUtil.isNotEmpty(preferredCondaPath)) {
|
||||
val preferredCondaPath = getInstance().preferredCondaPath
|
||||
if (!preferredCondaPath.isNullOrEmpty()) {
|
||||
val forSdkPath = if (sdkPath == null) "" else " for $sdkPath"
|
||||
LOG.info("Using $preferredCondaPath as a conda executable$forSdkPath (specified as a preferred conda path)")
|
||||
return preferredCondaPath
|
||||
@@ -53,7 +45,7 @@ class PyCondaPackageService : PersistentStateComponent<PyCondaPackageService?> {
|
||||
}
|
||||
|
||||
fun onCondaEnvCreated(condaExecutable: @SystemDependent String) {
|
||||
instance.preferredCondaPath = condaExecutable
|
||||
getInstance().preferredCondaPath = condaExecutable
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user