backport: 25.0.2
This commit is contained in:
parent
a4483cee0e
commit
ebd08a4913
20 changed files with 123 additions and 98 deletions
|
@ -17,6 +17,13 @@ Changelog structure reference:
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [25.0.2]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Project
|
||||||
|
- ZLS settings not scrollable in the language server list
|
||||||
|
|
||||||
## [25.0.1]
|
## [25.0.1]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -25,6 +25,7 @@ package com.falsepattern.zigbrains.project.toolchain.base
|
||||||
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider
|
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider
|
||||||
import com.falsepattern.zigbrains.project.toolchain.ui.ImmutableElementPanel
|
import com.falsepattern.zigbrains.project.toolchain.ui.ImmutableElementPanel
|
||||||
import com.falsepattern.zigbrains.project.toolchain.zigToolchainList
|
import com.falsepattern.zigbrains.project.toolchain.zigToolchainList
|
||||||
|
import com.falsepattern.zigbrains.shared.ui.UUIDComboBoxDriver.Companion.wrapModal
|
||||||
import com.intellij.openapi.ui.NamedConfigurable
|
import com.intellij.openapi.ui.NamedConfigurable
|
||||||
import com.intellij.openapi.util.Key
|
import com.intellij.openapi.util.Key
|
||||||
import com.intellij.openapi.util.NlsContexts
|
import com.intellij.openapi.util.NlsContexts
|
||||||
|
@ -37,7 +38,7 @@ abstract class ZigToolchainConfigurable<T: ZigToolchain>(
|
||||||
val uuid: UUID,
|
val uuid: UUID,
|
||||||
tc: T,
|
tc: T,
|
||||||
val data: ZigProjectConfigurationProvider.IUserDataBridge?,
|
val data: ZigProjectConfigurationProvider.IUserDataBridge?,
|
||||||
val modal: Boolean
|
private val modal: Boolean
|
||||||
): NamedConfigurable<UUID>() {
|
): NamedConfigurable<UUID>() {
|
||||||
var toolchain: T = tc
|
var toolchain: T = tc
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -64,7 +65,7 @@ abstract class ZigToolchainConfigurable<T: ZigToolchain>(
|
||||||
views.forEach { it.attach(this@panel) }
|
views.forEach { it.attach(this@panel) }
|
||||||
}.withMinimumWidth(20)
|
}.withMinimumWidth(20)
|
||||||
views.forEach { it.reset(toolchain) }
|
views.forEach { it.reset(toolchain) }
|
||||||
return p
|
return wrapModal(p, modal)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getEditableObject(): UUID? {
|
override fun getEditableObject(): UUID? {
|
||||||
|
|
|
@ -24,15 +24,15 @@ package com.falsepattern.zigbrains.project.toolchain.downloader
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.ZigBrainsBundle
|
import com.falsepattern.zigbrains.ZigBrainsBundle
|
||||||
import com.falsepattern.zigbrains.project.toolchain.local.LocalZigToolchain
|
import com.falsepattern.zigbrains.project.toolchain.local.LocalZigToolchain
|
||||||
import com.falsepattern.zigbrains.project.toolchain.local.getSuggestedLocalToolchainPath
|
import com.falsepattern.zigbrains.project.toolchain.local.suggestedLocalToolchainPath
|
||||||
import com.falsepattern.zigbrains.shared.downloader.Downloader
|
import com.falsepattern.zigbrains.shared.downloader.Downloader
|
||||||
import java.awt.Component
|
import java.awt.Component
|
||||||
|
|
||||||
class LocalToolchainDownloader(component: Component) : Downloader<LocalZigToolchain, ZigVersionInfo>(component) {
|
class LocalToolchainDownloader(component: Component) : Downloader<LocalZigToolchain, ZigVersionInfo>(component) {
|
||||||
override val windowTitle get() = ZigBrainsBundle.message("settings.toolchain.downloader.title")
|
override val windowTitle get() = ZigBrainsBundle.message("settings.toolchain.downloader.title")
|
||||||
override val versionInfoFetchTitle get() = ZigBrainsBundle.message("settings.toolchain.downloader.progress.fetch")
|
override val versionInfoFetchTitle get() = ZigBrainsBundle.message("settings.toolchain.downloader.progress.fetch")
|
||||||
|
override val suggestedPath get() = suggestedLocalToolchainPath
|
||||||
override fun downloadProgressTitle(version: ZigVersionInfo) = ZigBrainsBundle.message("settings.toolchain.downloader.progress.install", version.version.rawVersion)
|
override fun downloadProgressTitle(version: ZigVersionInfo) = ZigBrainsBundle.message("settings.toolchain.downloader.progress.install", version.version.rawVersion)
|
||||||
override fun localSelector() = LocalToolchainSelector(component)
|
override fun localSelector() = LocalToolchainSelector(component)
|
||||||
override suspend fun downloadVersionList() = ZigVersionInfo.downloadVersionList()
|
override suspend fun downloadVersionList() = ZigVersionInfo.downloadVersionList()
|
||||||
override fun getSuggestedPath() = getSuggestedLocalToolchainPath()
|
|
||||||
}
|
}
|
|
@ -75,8 +75,8 @@ class LocalZigToolchainPanel() : ImmutableNamedElementPanelBase<LocalZigToolchai
|
||||||
).also { Disposer.register(this, it) }
|
).also { Disposer.register(this, it) }
|
||||||
private var debounce: Job? = null
|
private var debounce: Job? = null
|
||||||
|
|
||||||
override fun attach(p: Panel): Unit = with(p) {
|
override fun attach(panel: Panel): Unit = with(panel) {
|
||||||
super.attach(p)
|
super.attach(panel)
|
||||||
row(ZigBrainsBundle.message("settings.toolchain.local.path.label")) {
|
row(ZigBrainsBundle.message("settings.toolchain.local.path.label")) {
|
||||||
cell(pathToToolchain).resizableColumn().align(AlignX.FILL)
|
cell(pathToToolchain).resizableColumn().align(AlignX.FILL)
|
||||||
}
|
}
|
||||||
|
@ -89,23 +89,23 @@ class LocalZigToolchainPanel() : ImmutableNamedElementPanelBase<LocalZigToolchai
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isModified(toolchain: LocalZigToolchain): Boolean {
|
override fun isModified(elem: LocalZigToolchain): Boolean {
|
||||||
val name = nameFieldValue ?: return false
|
val name = nameFieldValue ?: return false
|
||||||
val location = this.pathToToolchain.text.ifBlank { null }?.toNioPathOrNull() ?: return false
|
val location = this.pathToToolchain.text.ifBlank { null }?.toNioPathOrNull() ?: return false
|
||||||
val std = if (stdFieldOverride.isSelected) pathToStd.text.ifBlank { null }?.toNioPathOrNull() else null
|
val std = if (stdFieldOverride.isSelected) pathToStd.text.ifBlank { null }?.toNioPathOrNull() else null
|
||||||
return name != toolchain.name || toolchain.location != location || toolchain.std != std
|
return name != elem.name || elem.location != location || elem.std != std
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply(toolchain: LocalZigToolchain): LocalZigToolchain? {
|
override fun apply(elem: LocalZigToolchain): LocalZigToolchain? {
|
||||||
val location = this.pathToToolchain.text.ifBlank { null }?.toNioPathOrNull() ?: return null
|
val location = this.pathToToolchain.text.ifBlank { null }?.toNioPathOrNull() ?: return null
|
||||||
val std = if (stdFieldOverride.isSelected) pathToStd.text.ifBlank { null }?.toNioPathOrNull() else null
|
val std = if (stdFieldOverride.isSelected) pathToStd.text.ifBlank { null }?.toNioPathOrNull() else null
|
||||||
return toolchain.copy(location = location, std = std, name = nameFieldValue ?: "")
|
return elem.copy(location = location, std = std, name = nameFieldValue ?: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset(toolchain: LocalZigToolchain?) {
|
override fun reset(elem: LocalZigToolchain?) {
|
||||||
nameFieldValue = toolchain?.name ?: ""
|
nameFieldValue = elem?.name ?: ""
|
||||||
this.pathToToolchain.text = toolchain?.location?.pathString ?: ""
|
this.pathToToolchain.text = elem?.location?.pathString ?: ""
|
||||||
val std = toolchain?.std
|
val std = elem?.std
|
||||||
if (std != null) {
|
if (std != null) {
|
||||||
stdFieldOverride.isSelected = true
|
stdFieldOverride.isSelected = true
|
||||||
pathToStd.text = std.pathString
|
pathToStd.text = std.pathString
|
||||||
|
|
|
@ -28,18 +28,18 @@ import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvid
|
||||||
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchain
|
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchain
|
||||||
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainConfigurable
|
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainConfigurable
|
||||||
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainProvider
|
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainProvider
|
||||||
|
import com.falsepattern.zigbrains.shared.downloader.homePath
|
||||||
|
import com.falsepattern.zigbrains.shared.downloader.xdgDataHome
|
||||||
import com.falsepattern.zigbrains.shared.ui.renderPathNameComponent
|
import com.falsepattern.zigbrains.shared.ui.renderPathNameComponent
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.UserDataHolder
|
import com.intellij.openapi.util.UserDataHolder
|
||||||
import com.intellij.openapi.util.io.toNioPathOrNull
|
import com.intellij.openapi.util.io.toNioPathOrNull
|
||||||
import com.intellij.ui.SimpleColoredComponent
|
import com.intellij.ui.SimpleColoredComponent
|
||||||
import com.intellij.util.system.OS
|
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.io.path.isDirectory
|
|
||||||
import kotlin.io.path.pathString
|
import kotlin.io.path.pathString
|
||||||
|
|
||||||
class LocalZigToolchainProvider: ZigToolchainProvider {
|
class LocalZigToolchainProvider: ZigToolchainProvider {
|
||||||
|
@ -93,7 +93,7 @@ class LocalZigToolchainProvider: ZigToolchainProvider {
|
||||||
Env.empty
|
Env.empty
|
||||||
}
|
}
|
||||||
val pathToolchains = env.findAllExecutablesOnPATH("zig").mapNotNull { it.parent }
|
val pathToolchains = env.findAllExecutablesOnPATH("zig").mapNotNull { it.parent }
|
||||||
val wellKnown = getWellKnown().asFlow().flatMapConcat { dir ->
|
val wellKnown = wellKnown.asFlow().flatMapConcat { dir ->
|
||||||
runCatching {
|
runCatching {
|
||||||
Files.newDirectoryStream(dir).use { stream ->
|
Files.newDirectoryStream(dir).use { stream ->
|
||||||
stream.toList().filterNotNull().asFlow()
|
stream.toList().filterNotNull().asFlow()
|
||||||
|
@ -112,8 +112,8 @@ class LocalZigToolchainProvider: ZigToolchainProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSuggestedLocalToolchainPath(): Path? {
|
val suggestedLocalToolchainPath: Path? by lazy {
|
||||||
return getWellKnown().getOrNull(0)
|
wellKnown.getOrNull(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,18 +130,12 @@ fun getSuggestedLocalToolchainPath(): Path? {
|
||||||
*
|
*
|
||||||
* and HOME is the user home path
|
* and HOME is the user home path
|
||||||
*/
|
*/
|
||||||
private fun getWellKnown(): List<Path> {
|
private val wellKnown: List<Path> by lazy {
|
||||||
val home = System.getProperty("user.home")?.toNioPathOrNull() ?: return emptyList()
|
|
||||||
val xdgDataHome = when(OS.CURRENT) {
|
|
||||||
OS.macOS -> home.resolve("Library")
|
|
||||||
OS.Windows -> System.getenv("LOCALAPPDATA")?.toNioPathOrNull()
|
|
||||||
else -> System.getenv("XDG_DATA_HOME")?.toNioPathOrNull() ?: home.resolve(Path.of(".local", "share"))
|
|
||||||
}
|
|
||||||
val res = ArrayList<Path>()
|
val res = ArrayList<Path>()
|
||||||
if (xdgDataHome != null && xdgDataHome.isDirectory()) {
|
xdgDataHome?.let {
|
||||||
res.add(xdgDataHome.resolve("zig"))
|
res.add(it.resolve("zig"))
|
||||||
res.add(xdgDataHome.resolve("zigup"))
|
res.add(it.resolve("zigup"))
|
||||||
}
|
}
|
||||||
res.add(home.resolve(".zig"))
|
homePath?.let { res.add(it.resolve(".zig")) }
|
||||||
return res
|
res
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.intellij.openapi.Disposable
|
||||||
import com.intellij.ui.dsl.builder.Panel
|
import com.intellij.ui.dsl.builder.Panel
|
||||||
|
|
||||||
interface ImmutableElementPanel<T>: Disposable {
|
interface ImmutableElementPanel<T>: Disposable {
|
||||||
fun attach(p: Panel)
|
fun attach(panel: Panel)
|
||||||
fun isModified(elem: T): Boolean
|
fun isModified(elem: T): Boolean
|
||||||
/**
|
/**
|
||||||
* Returned object must be the exact same class as the provided one.
|
* Returned object must be the exact same class as the provided one.
|
||||||
|
|
|
@ -34,7 +34,7 @@ abstract class ImmutableNamedElementPanelBase<T>: ImmutableElementPanel<T> {
|
||||||
get() = nameField.text.ifBlank { null }
|
get() = nameField.text.ifBlank { null }
|
||||||
set(value) {nameField.text = value ?: ""}
|
set(value) {nameField.text = value ?: ""}
|
||||||
|
|
||||||
override fun attach(p: Panel): Unit = with(p) {
|
override fun attach(panel: Panel): Unit = with(panel) {
|
||||||
row(ZigBrainsBundle.message("settings.toolchain.base.name.label")) {
|
row(ZigBrainsBundle.message("settings.toolchain.base.name.label")) {
|
||||||
cell(nameField).resizableColumn().align(AlignX.FILL)
|
cell(nameField).resizableColumn().align(AlignX.FILL)
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class ZigToolchainEditor(private val sharedState: ZigProjectConfigurationProvide
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun attach(p: Panel): Unit = with(p) {
|
override fun attach(panel: Panel): Unit = with(panel) {
|
||||||
row(ZigBrainsBundle.message(
|
row(ZigBrainsBundle.message(
|
||||||
if (sharedState.getUserData(PROJECT_KEY)?.isDefault == true)
|
if (sharedState.getUserData(PROJECT_KEY)?.isDefault == true)
|
||||||
"settings.toolchain.editor.toolchain-default.label"
|
"settings.toolchain.editor.toolchain-default.label"
|
||||||
|
@ -75,7 +75,7 @@ class ZigToolchainEditor(private val sharedState: ZigProjectConfigurationProvide
|
||||||
views.addAll(createZigToolchainExtensionPanels(sharedState, PanelState.ProjectEditor))
|
views.addAll(createZigToolchainExtensionPanels(sharedState, PanelState.ProjectEditor))
|
||||||
myViews = views
|
myViews = views
|
||||||
}
|
}
|
||||||
views.forEach { it.attach(p) }
|
views.forEach { it.attach(panel) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSelection(uuid: UUID?) {
|
override fun onSelection(uuid: UUID?) {
|
||||||
|
|
|
@ -76,10 +76,10 @@ abstract class Downloader<T, V: VersionInfo>(val component: Component) {
|
||||||
|
|
||||||
protected abstract val windowTitle: String
|
protected abstract val windowTitle: String
|
||||||
protected abstract val versionInfoFetchTitle: @NlsContexts.ProgressTitle String
|
protected abstract val versionInfoFetchTitle: @NlsContexts.ProgressTitle String
|
||||||
|
protected abstract val suggestedPath: Path?
|
||||||
protected abstract fun downloadProgressTitle(version: V): @NlsContexts.ProgressTitle String
|
protected abstract fun downloadProgressTitle(version: V): @NlsContexts.ProgressTitle String
|
||||||
protected abstract fun localSelector(): LocalSelector<T>
|
protected abstract fun localSelector(): LocalSelector<T>
|
||||||
protected abstract suspend fun downloadVersionList(): List<V>
|
protected abstract suspend fun downloadVersionList(): List<V>
|
||||||
protected abstract fun getSuggestedPath(): Path?
|
|
||||||
|
|
||||||
@RequiresEdt
|
@RequiresEdt
|
||||||
private fun selectVersion(info: List<V>, selector: LocalSelector<T>): Pair<Path, V>? {
|
private fun selectVersion(info: List<V>, selector: LocalSelector<T>): Pair<Path, V>? {
|
||||||
|
@ -131,7 +131,7 @@ abstract class Downloader<T, V: VersionInfo>(val component: Component) {
|
||||||
})
|
})
|
||||||
var archiveSizeCell: Cell<*>? = null
|
var archiveSizeCell: Cell<*>? = null
|
||||||
fun detect(item: V) {
|
fun detect(item: V) {
|
||||||
outputPath.text = getSuggestedPath()?.resolve(item.version.rawVersion)?.pathString ?: ""
|
outputPath.text = suggestedPath?.resolve(item.version.rawVersion)?.pathString ?: ""
|
||||||
val size = item.dist.size
|
val size = item.dist.size
|
||||||
val sizeMb = size / (1024f * 1024f)
|
val sizeMb = size / (1024f * 1024f)
|
||||||
archiveSizeCell?.comment?.text = ZigBrainsBundle.message("settings.shared.downloader.archive-size.text", "%.2fMB".format(sizeMb))
|
archiveSizeCell?.comment?.text = ZigBrainsBundle.message("settings.shared.downloader.archive-size.text", "%.2fMB".format(sizeMb))
|
||||||
|
|
|
@ -41,11 +41,13 @@ import com.intellij.ui.components.textFieldWithBrowseButton
|
||||||
import com.intellij.ui.dsl.builder.AlignX
|
import com.intellij.ui.dsl.builder.AlignX
|
||||||
import com.intellij.ui.dsl.builder.panel
|
import com.intellij.ui.dsl.builder.panel
|
||||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||||
|
import com.intellij.util.system.OS
|
||||||
import java.awt.Component
|
import java.awt.Component
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import javax.swing.Icon
|
import javax.swing.Icon
|
||||||
import javax.swing.event.DocumentEvent
|
import javax.swing.event.DocumentEvent
|
||||||
|
import kotlin.io.path.isDirectory
|
||||||
import kotlin.io.path.pathString
|
import kotlin.io.path.pathString
|
||||||
|
|
||||||
abstract class LocalSelector<T>(val component: Component) {
|
abstract class LocalSelector<T>(val component: Component) {
|
||||||
|
@ -135,4 +137,16 @@ abstract class LocalSelector<T>(val component: Component) {
|
||||||
val errorIcon: Icon,
|
val errorIcon: Icon,
|
||||||
val errorText: String,
|
val errorText: String,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val homePath: Path? by lazy {
|
||||||
|
System.getProperty("user.home")?.toNioPathOrNull()?.takeIf { it.isDirectory() }
|
||||||
|
}
|
||||||
|
|
||||||
|
val xdgDataHome: Path? by lazy {
|
||||||
|
when(OS.CURRENT) {
|
||||||
|
OS.macOS -> homePath?.resolve("Library")
|
||||||
|
OS.Windows -> System.getenv("LOCALAPPDATA")?.toNioPathOrNull()
|
||||||
|
else -> System.getenv("XDG_DATA_HOME")?.toNioPathOrNull() ?: homePath?.resolve(Path.of(".local", "share"))
|
||||||
|
}?.takeIf { it.isDirectory() }
|
||||||
}
|
}
|
|
@ -24,8 +24,11 @@ package com.falsepattern.zigbrains.shared.ui
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.shared.UUIDMapSerializable
|
import com.falsepattern.zigbrains.shared.UUIDMapSerializable
|
||||||
import com.intellij.openapi.ui.NamedConfigurable
|
import com.intellij.openapi.ui.NamedConfigurable
|
||||||
|
import com.intellij.ui.components.JBScrollPane
|
||||||
import java.awt.Component
|
import java.awt.Component
|
||||||
|
import java.awt.Dimension
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import javax.swing.JComponent
|
||||||
|
|
||||||
interface UUIDComboBoxDriver<T> {
|
interface UUIDComboBoxDriver<T> {
|
||||||
val theMap: UUIDMapSerializable.Converting<T, *, *>
|
val theMap: UUIDMapSerializable.Converting<T, *, *>
|
||||||
|
@ -34,4 +37,15 @@ interface UUIDComboBoxDriver<T> {
|
||||||
fun createComboBox(model: ZBModel<T>): ZBComboBox<T>
|
fun createComboBox(model: ZBModel<T>): ZBComboBox<T>
|
||||||
suspend fun resolvePseudo(context: Component, elem: ListElem.Pseudo<T>): UUID?
|
suspend fun resolvePseudo(context: Component, elem: ListElem.Pseudo<T>): UUID?
|
||||||
fun createNamedConfigurable(uuid: UUID, elem: T): NamedConfigurable<UUID>
|
fun createNamedConfigurable(uuid: UUID, elem: T): NamedConfigurable<UUID>
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun wrapModal(component: JComponent, modal: Boolean): JComponent {
|
||||||
|
if (modal) {
|
||||||
|
component.preferredSize = Dimension(640, 480)
|
||||||
|
return component
|
||||||
|
} else {
|
||||||
|
return JBScrollPane(component)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -161,7 +161,7 @@ abstract class UUIDMapSelector<T>(val driver: UUIDComboBoxDriver<T>): Disposable
|
||||||
|
|
||||||
protected fun attachComboBoxRow(row: Row): Unit = with(row) {
|
protected fun attachComboBoxRow(row: Row): Unit = with(row) {
|
||||||
cell(comboBox).resizableColumn().align(AlignX.FILL)
|
cell(comboBox).resizableColumn().align(AlignX.FILL)
|
||||||
button(ZigBrainsBundle.message("settings.toolchain.editor.toolchain.edit-button.name")) { e ->
|
button(ZigBrainsBundle.message("settings.toolchain.editor.toolchain.edit-button.name")) {
|
||||||
zigCoroutineScope.launchWithEDT(comboBox.asContextElement()) {
|
zigCoroutineScope.launchWithEDT(comboBox.asContextElement()) {
|
||||||
var selectedUUID = comboBox.selectedUUID ?: return@launchWithEDT
|
var selectedUUID = comboBox.selectedUUID ?: return@launchWithEDT
|
||||||
val elem = driver.theMap[selectedUUID] ?: return@launchWithEDT
|
val elem = driver.theMap[selectedUUID] ?: return@launchWithEDT
|
||||||
|
|
|
@ -250,16 +250,16 @@ abstract class ZBCellRenderer<T>(val getModel: () -> ZBModel<T>) : ColoredListCe
|
||||||
}
|
}
|
||||||
|
|
||||||
fun renderPathNameComponent(path: String, name: String?, nameFallback: String, component: SimpleColoredComponent, isSuggestion: Boolean, isSelected: Boolean) {
|
fun renderPathNameComponent(path: String, name: String?, nameFallback: String, component: SimpleColoredComponent, isSuggestion: Boolean, isSelected: Boolean) {
|
||||||
val path = presentDetectedPath(path)
|
val thePath = presentDetectedPath(path)
|
||||||
val primary: String
|
val primary: String
|
||||||
var secondary: String?
|
var secondary: String?
|
||||||
val tooltip: String?
|
val tooltip: String?
|
||||||
if (isSuggestion) {
|
if (isSuggestion) {
|
||||||
primary = path
|
primary = thePath
|
||||||
secondary = name
|
secondary = name
|
||||||
} else {
|
} else {
|
||||||
primary = name ?: nameFallback
|
primary = name ?: nameFallback
|
||||||
secondary = path
|
secondary = thePath
|
||||||
}
|
}
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
tooltip = secondary
|
tooltip = secondary
|
||||||
|
@ -277,12 +277,12 @@ fun renderPathNameComponent(path: String, name: String?, nameFallback: String, c
|
||||||
|
|
||||||
fun presentDetectedPath(home: String, maxLength: Int = 50, suffixLength: Int = 30): String {
|
fun presentDetectedPath(home: String, maxLength: Int = 50, suffixLength: Int = 30): String {
|
||||||
//for macOS, let's try removing Bundle internals
|
//for macOS, let's try removing Bundle internals
|
||||||
var home = home
|
var theHome = home
|
||||||
home = StringUtil.trimEnd(home, "/Contents/Home") //NON-NLS
|
theHome = StringUtil.trimEnd(theHome, "/Contents/Home") //NON-NLS
|
||||||
home = StringUtil.trimEnd(home, "/Contents/MacOS") //NON-NLS
|
theHome = StringUtil.trimEnd(theHome, "/Contents/MacOS") //NON-NLS
|
||||||
home = FileUtil.getLocationRelativeToUserHome(home, false)
|
theHome = FileUtil.getLocationRelativeToUserHome(theHome, false)
|
||||||
home = StringUtil.shortenTextWithEllipsis(home, maxLength, suffixLength)
|
theHome = StringUtil.shortenTextWithEllipsis(theHome, maxLength, suffixLength)
|
||||||
return home
|
return theHome
|
||||||
}
|
}
|
||||||
|
|
||||||
private val EMPTY_ICON = EmptyIcon.create(1, 16)
|
private val EMPTY_ICON = EmptyIcon.create(1, 16)
|
|
@ -1,7 +1,7 @@
|
||||||
pluginName=ZigBrains
|
pluginName=ZigBrains
|
||||||
pluginRepositoryUrl=https://github.com/FalsePattern/ZigBrains
|
pluginRepositoryUrl=https://github.com/FalsePattern/ZigBrains
|
||||||
|
|
||||||
pluginVersion=25.0.1
|
pluginVersion=25.0.2
|
||||||
|
|
||||||
pluginSinceBuild=242
|
pluginSinceBuild=242
|
||||||
pluginUntilBuild=242.*
|
pluginUntilBuild=242.*
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ZLSSettingsPanel() : ImmutableElementPanel<ZLSSettings> {
|
||||||
private val build_runner_path = ExtendableTextField()
|
private val build_runner_path = ExtendableTextField()
|
||||||
private val global_cache_path = ExtendableTextField()
|
private val global_cache_path = ExtendableTextField()
|
||||||
|
|
||||||
override fun attach(p: Panel): Unit = with(p) {
|
override fun attach(panel: Panel): Unit = with(panel) {
|
||||||
fancyRow(
|
fancyRow(
|
||||||
"settings.zls-config-path.label",
|
"settings.zls-config-path.label",
|
||||||
"settings.zls-config-path.tooltip"
|
"settings.zls-config-path.tooltip"
|
||||||
|
|
|
@ -22,14 +22,14 @@
|
||||||
|
|
||||||
package com.falsepattern.zigbrains.lsp.zls
|
package com.falsepattern.zigbrains.lsp.zls
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.shared.ui.UUIDComboBoxDriver.Companion.wrapModal
|
||||||
import com.intellij.openapi.ui.NamedConfigurable
|
import com.intellij.openapi.ui.NamedConfigurable
|
||||||
import com.intellij.openapi.util.NlsContexts
|
import com.intellij.openapi.util.NlsContexts
|
||||||
import com.intellij.ui.dsl.builder.panel
|
import com.intellij.ui.dsl.builder.panel
|
||||||
import java.awt.Dimension
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
|
|
||||||
class ZLSConfigurable(val uuid: UUID, zls: ZLSVersion): NamedConfigurable<UUID>() {
|
class ZLSConfigurable(val uuid: UUID, zls: ZLSVersion, private val modal: Boolean): NamedConfigurable<UUID>() {
|
||||||
var zls: ZLSVersion = zls
|
var zls: ZLSVersion = zls
|
||||||
set(value) {
|
set(value) {
|
||||||
zlsInstallations[uuid] = value
|
zlsInstallations[uuid] = value
|
||||||
|
@ -59,8 +59,7 @@ class ZLSConfigurable(val uuid: UUID, zls: ZLSVersion): NamedConfigurable<UUID>(
|
||||||
val p = panel {
|
val p = panel {
|
||||||
view.attach(this@panel)
|
view.attach(this@panel)
|
||||||
}
|
}
|
||||||
p.preferredSize = Dimension(640, 480)
|
return wrapModal(p, modal)
|
||||||
return p
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getDisplayName(): @NlsContexts.ConfigurableName String? {
|
override fun getDisplayName(): @NlsContexts.ConfigurableName String? {
|
||||||
|
|
|
@ -63,8 +63,8 @@ class ZLSPanel() : ImmutableNamedElementPanelBase<ZLSVersion>() {
|
||||||
private var settingsPanel: ZLSSettingsPanel? = null
|
private var settingsPanel: ZLSSettingsPanel? = null
|
||||||
private var debounce: Job? = null
|
private var debounce: Job? = null
|
||||||
|
|
||||||
override fun attach(p: Panel): Unit = with(p) {
|
override fun attach(panel: Panel): Unit = with(panel) {
|
||||||
super.attach(p)
|
super.attach(panel)
|
||||||
row(ZLSBundle.message("settings.panel.path.label")) {
|
row(ZLSBundle.message("settings.panel.path.label")) {
|
||||||
cell(pathToZLS).resizableColumn().align(AlignX.FILL)
|
cell(pathToZLS).resizableColumn().align(AlignX.FILL)
|
||||||
}
|
}
|
||||||
|
@ -72,27 +72,27 @@ class ZLSPanel() : ImmutableNamedElementPanelBase<ZLSVersion>() {
|
||||||
cell(zlsVersion)
|
cell(zlsVersion)
|
||||||
}
|
}
|
||||||
val sp = ZLSSettingsPanel()
|
val sp = ZLSSettingsPanel()
|
||||||
p.collapsibleGroup(ZLSBundle.message("settings.panel.settings.group.label"), indent = false) {
|
panel.collapsibleGroup(ZLSBundle.message("settings.panel.settings.group.label"), indent = false) {
|
||||||
sp.attach(this@collapsibleGroup)
|
sp.attach(this@collapsibleGroup)
|
||||||
}
|
}
|
||||||
settingsPanel = sp
|
settingsPanel = sp
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isModified(version: ZLSVersion): Boolean {
|
override fun isModified(elem: ZLSVersion): Boolean {
|
||||||
val name = nameFieldValue ?: return false
|
val name = nameFieldValue ?: return false
|
||||||
val path = this.pathToZLS.text.ifBlank { null }?.toNioPathOrNull() ?: return false
|
val path = this.pathToZLS.text.ifBlank { null }?.toNioPathOrNull() ?: return false
|
||||||
return name != version.name || version.path != path || settingsPanel?.isModified(version.settings) == true
|
return name != elem.name || elem.path != path || settingsPanel?.isModified(elem.settings) == true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply(version: ZLSVersion): ZLSVersion? {
|
override fun apply(elem: ZLSVersion): ZLSVersion? {
|
||||||
val path = this.pathToZLS.text.ifBlank { null }?.toNioPathOrNull() ?: return null
|
val path = this.pathToZLS.text.ifBlank { null }?.toNioPathOrNull() ?: return null
|
||||||
return version.copy(path = path, name = nameFieldValue ?: "", settings = settingsPanel?.apply(version.settings) ?: version.settings)
|
return elem.copy(path = path, name = nameFieldValue ?: "", settings = settingsPanel?.apply(elem.settings) ?: elem.settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset(version: ZLSVersion?) {
|
override fun reset(elem: ZLSVersion?) {
|
||||||
nameFieldValue = version?.name ?: ""
|
nameFieldValue = elem?.name ?: ""
|
||||||
this.pathToZLS.text = version?.path?.pathString ?: ""
|
this.pathToZLS.text = elem?.path?.pathString ?: ""
|
||||||
settingsPanel?.reset(version?.settings)
|
settingsPanel?.reset(elem?.settings)
|
||||||
dispatchUpdateUI()
|
dispatchUpdateUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ package com.falsepattern.zigbrains.lsp.zls.downloader
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.lsp.ZLSBundle
|
import com.falsepattern.zigbrains.lsp.ZLSBundle
|
||||||
import com.falsepattern.zigbrains.lsp.zls.ZLSVersion
|
import com.falsepattern.zigbrains.lsp.zls.ZLSVersion
|
||||||
import com.falsepattern.zigbrains.lsp.zls.ui.getSuggestedZLSPath
|
import com.falsepattern.zigbrains.lsp.zls.ui.suggestedZLSPath
|
||||||
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider
|
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider
|
||||||
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider.IUserDataBridge
|
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider.IUserDataBridge
|
||||||
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainConfigurable
|
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainConfigurable
|
||||||
|
@ -34,6 +34,7 @@ import java.awt.Component
|
||||||
class ZLSDownloader(component: Component, private val data: IUserDataBridge?) : Downloader<ZLSVersion, ZLSVersionInfo>(component) {
|
class ZLSDownloader(component: Component, private val data: IUserDataBridge?) : Downloader<ZLSVersion, ZLSVersionInfo>(component) {
|
||||||
override val windowTitle get() = ZLSBundle.message("settings.downloader.title")
|
override val windowTitle get() = ZLSBundle.message("settings.downloader.title")
|
||||||
override val versionInfoFetchTitle get() = ZLSBundle.message("settings.downloader.progress.fetch")
|
override val versionInfoFetchTitle get() = ZLSBundle.message("settings.downloader.progress.fetch")
|
||||||
|
override val suggestedPath get() = suggestedZLSPath
|
||||||
override fun downloadProgressTitle(version: ZLSVersionInfo) = ZLSBundle.message("settings.downloader.progress.install", version.version.rawVersion)
|
override fun downloadProgressTitle(version: ZLSVersionInfo) = ZLSBundle.message("settings.downloader.progress.install", version.version.rawVersion)
|
||||||
override fun localSelector() = ZLSLocalSelector(component)
|
override fun localSelector() = ZLSLocalSelector(component)
|
||||||
override suspend fun downloadVersionList(): List<ZLSVersionInfo> {
|
override suspend fun downloadVersionList(): List<ZLSVersionInfo> {
|
||||||
|
@ -41,5 +42,4 @@ class ZLSDownloader(component: Component, private val data: IUserDataBridge?) :
|
||||||
val project = data?.getUserData(ZigProjectConfigurationProvider.PROJECT_KEY)
|
val project = data?.getUserData(ZigProjectConfigurationProvider.PROJECT_KEY)
|
||||||
return ZLSVersionInfo.downloadVersionInfoFor(toolchain, project)
|
return ZLSVersionInfo.downloadVersionInfoFor(toolchain, project)
|
||||||
}
|
}
|
||||||
override fun getSuggestedPath() = getSuggestedZLSPath()
|
|
||||||
}
|
}
|
|
@ -33,14 +33,14 @@ import com.falsepattern.zigbrains.lsp.zls.zlsInstallations
|
||||||
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider
|
import com.falsepattern.zigbrains.project.settings.ZigProjectConfigurationProvider
|
||||||
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainConfigurable.Companion.TOOLCHAIN_KEY
|
import com.falsepattern.zigbrains.project.toolchain.base.ZigToolchainConfigurable.Companion.TOOLCHAIN_KEY
|
||||||
import com.falsepattern.zigbrains.shared.UUIDMapSerializable
|
import com.falsepattern.zigbrains.shared.UUIDMapSerializable
|
||||||
|
import com.falsepattern.zigbrains.shared.downloader.homePath
|
||||||
|
import com.falsepattern.zigbrains.shared.downloader.xdgDataHome
|
||||||
import com.falsepattern.zigbrains.shared.ui.*
|
import com.falsepattern.zigbrains.shared.ui.*
|
||||||
import com.falsepattern.zigbrains.shared.ui.ListElem.One.Actual
|
import com.falsepattern.zigbrains.shared.ui.ListElem.One.Actual
|
||||||
import com.falsepattern.zigbrains.shared.withUniqueName
|
import com.falsepattern.zigbrains.shared.withUniqueName
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.ui.NamedConfigurable
|
import com.intellij.openapi.ui.NamedConfigurable
|
||||||
import com.intellij.openapi.util.SystemInfo
|
import com.intellij.openapi.util.SystemInfo
|
||||||
import com.intellij.openapi.util.io.toNioPathOrNull
|
|
||||||
import com.intellij.util.system.OS
|
|
||||||
import com.intellij.util.text.SemVer
|
import com.intellij.util.text.SemVer
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
@ -67,10 +67,6 @@ sealed interface ZLSDriver: UUIDComboBoxDriver<ZLSVersion> {
|
||||||
return ZLSComboBox(model)
|
return ZLSComboBox(model)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createNamedConfigurable(uuid: UUID, elem: ZLSVersion): NamedConfigurable<UUID> {
|
|
||||||
return ZLSConfigurable(uuid, elem)
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun resolvePseudo(
|
override suspend fun resolvePseudo(
|
||||||
context: Component,
|
context: Component,
|
||||||
elem: ListElem.Pseudo<ZLSVersion>
|
elem: ListElem.Pseudo<ZLSVersion>
|
||||||
|
@ -93,6 +89,10 @@ sealed interface ZLSDriver: UUIDComboBoxDriver<ZLSVersion> {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun createNamedConfigurable(uuid: UUID, elem: ZLSVersion): NamedConfigurable<UUID> {
|
||||||
|
return ZLSConfigurable(uuid, elem, false)
|
||||||
|
}
|
||||||
|
|
||||||
override val data: ZigProjectConfigurationProvider.IUserDataBridge?
|
override val data: ZigProjectConfigurationProvider.IUserDataBridge?
|
||||||
get() = null
|
get() = null
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,10 @@ sealed interface ZLSDriver: UUIDComboBoxDriver<ZLSVersion> {
|
||||||
res.add(suggestZLSVersions(project, data, toolchainVersion).asPending())
|
res.add(suggestZLSVersions(project, data, toolchainVersion).asPending())
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun createNamedConfigurable(uuid: UUID, elem: ZLSVersion): NamedConfigurable<UUID> {
|
||||||
|
return ZLSConfigurable(uuid, elem, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,16 +146,16 @@ private fun suggestZLSVersions(project: Project? = null, data: ZigProjectConfigu
|
||||||
emitIfCompatible(path, toolchainVersion)
|
emitIfCompatible(path, toolchainVersion)
|
||||||
}
|
}
|
||||||
val exe = if (SystemInfo.isWindows) "zls.exe" else "zls"
|
val exe = if (SystemInfo.isWindows) "zls.exe" else "zls"
|
||||||
getWellKnownZLS().forEach { wellKnown ->
|
wellKnownZLS.forEach { wellKnown ->
|
||||||
runCatching {
|
runCatching {
|
||||||
Files.newDirectoryStream(wellKnown).use { stream ->
|
Files.newDirectoryStream(wellKnown).use { stream ->
|
||||||
stream.asSequence().filterNotNull().forEach { dir ->
|
stream.asSequence().filterNotNull().forEach streamForEach@{ dir ->
|
||||||
val path = dir.resolve(exe)
|
val path = dir.resolve(exe)
|
||||||
if (!path.isRegularFile() || !path.isExecutable()) {
|
if (!path.isRegularFile() || !path.isExecutable()) {
|
||||||
return@forEach
|
return@streamForEach
|
||||||
}
|
}
|
||||||
if (existing.any { it.path == path }) {
|
if (existing.any { it.path == path }) {
|
||||||
return@forEach
|
return@streamForEach
|
||||||
}
|
}
|
||||||
emitIfCompatible(path, toolchainVersion)
|
emitIfCompatible(path, toolchainVersion)
|
||||||
}
|
}
|
||||||
|
@ -188,8 +192,8 @@ private fun numericVersionEquals(a: SemVer, b: SemVer): Boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getSuggestedZLSPath(): Path? {
|
val suggestedZLSPath: Path? by lazy {
|
||||||
return getWellKnownZLS().getOrNull(0)
|
wellKnownZLS.getOrNull(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,17 +209,9 @@ fun getSuggestedZLSPath(): Path? {
|
||||||
*
|
*
|
||||||
* and HOME is the user home path
|
* and HOME is the user home path
|
||||||
*/
|
*/
|
||||||
private fun getWellKnownZLS(): List<Path> {
|
private val wellKnownZLS: List<Path> by lazy {
|
||||||
val home = System.getProperty("user.home")?.toNioPathOrNull() ?: return emptyList()
|
|
||||||
val xdgDataHome = when(OS.CURRENT) {
|
|
||||||
OS.macOS -> home.resolve("Library")
|
|
||||||
OS.Windows -> System.getenv("LOCALAPPDATA")?.toNioPathOrNull()
|
|
||||||
else -> System.getenv("XDG_DATA_HOME")?.toNioPathOrNull() ?: home.resolve(Path.of(".local", "share"))
|
|
||||||
}
|
|
||||||
val res = ArrayList<Path>()
|
val res = ArrayList<Path>()
|
||||||
if (xdgDataHome != null && xdgDataHome.isDirectory()) {
|
xdgDataHome?.let { res.add(it.resolve("zls")) }
|
||||||
res.add(xdgDataHome.resolve("zls"))
|
homePath?.let { res.add(it.resolve(".zls")) }
|
||||||
}
|
res
|
||||||
res.add(home.resolve(".zls"))
|
|
||||||
return res
|
|
||||||
}
|
}
|
|
@ -55,21 +55,21 @@ class ZLSEditor<T: ZigToolchain>(private val sharedState: ZigProjectConfiguratio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isModified(toolchain: T): Boolean {
|
override fun isModified(elem: T): Boolean {
|
||||||
if (isEmpty)
|
if (isEmpty)
|
||||||
return false
|
return false
|
||||||
return toolchain.zlsUUID != selectedUUID
|
return elem.zlsUUID != selectedUUID
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply(toolchain: T): T {
|
override fun apply(elem: T): T {
|
||||||
return toolchain.withZLS(selectedUUID)
|
return elem.withZLS(selectedUUID)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset(toolchain: T?) {
|
override fun reset(elem: T?) {
|
||||||
selectedUUID = toolchain?.zlsUUID
|
selectedUUID = elem?.zlsUUID
|
||||||
zigCoroutineScope.launch {
|
zigCoroutineScope.launch {
|
||||||
listChanged()
|
listChanged()
|
||||||
selectedUUID = toolchain?.zlsUUID
|
selectedUUID = elem?.zlsUUID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue