backport: 20.2.0
This commit is contained in:
parent
062aeaaa97
commit
b4cb04dcde
30 changed files with 116 additions and 69 deletions
|
@ -17,6 +17,13 @@ Changelog structure reference:
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [20.2.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Zig
|
||||||
|
- Live template support
|
||||||
|
|
||||||
## [20.1.3]
|
## [20.1.3]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.9.22" apply false
|
kotlin("jvm") version "1.9.22" apply false
|
||||||
kotlin("plugin.serialization") version "1.9.22" apply false
|
kotlin("plugin.serialization") version "1.9.22" apply false
|
||||||
id("org.jetbrains.intellij.platform") version "2.1.0"
|
id("org.jetbrains.intellij.platform") version "2.2.1"
|
||||||
id("org.jetbrains.changelog") version "2.2.1"
|
id("org.jetbrains.changelog") version "2.2.1"
|
||||||
id("org.jetbrains.grammarkit") version "2022.3.2.2" apply false
|
id("org.jetbrains.grammarkit") version "2022.3.2.2" apply false
|
||||||
idea
|
idea
|
||||||
|
@ -93,11 +93,6 @@ allprojects {
|
||||||
defaultRepositories()
|
defaultRepositories()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
|
||||||
intellijPlatform {
|
|
||||||
instrumentationTools()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.lsp4j.jsonrpc.MessageConsumer
|
||||||
import org.eclipse.lsp4j.jsonrpc.debug.messages.DebugResponseMessage
|
import org.eclipse.lsp4j.jsonrpc.debug.messages.DebugResponseMessage
|
||||||
import org.eclipse.lsp4j.jsonrpc.messages.Message
|
import org.eclipse.lsp4j.jsonrpc.messages.Message
|
||||||
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest
|
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest
|
||||||
|
import java.io.InputStream
|
||||||
import java.lang.RuntimeException
|
import java.lang.RuntimeException
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import java.util.Base64
|
import java.util.Base64
|
||||||
|
@ -73,7 +74,7 @@ class WinDAPDriver(handler: Handler) : DAPDriver<IDebugProtocolServer, WinDAPDri
|
||||||
handshakeFinished.acquire()
|
handshakeFinished.acquire()
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class WinDAPDebuggerClient: DAPDriver<IDebugProtocolServer, WinDAPDriver.WinDAPDebuggerClient>.DAPDebuggerClient() {
|
inner class WinDAPDebuggerClient: DAPDriver<IDebugProtocolServer, WinDAPDebuggerClient>.DAPDebuggerClient() {
|
||||||
override fun output(args: OutputEventArguments) {
|
override fun output(args: OutputEventArguments) {
|
||||||
if ("telemetry" == args.category)
|
if ("telemetry" == args.category)
|
||||||
return
|
return
|
||||||
|
@ -92,7 +93,7 @@ class WinDAPDriver(handler: Handler) : DAPDriver<IDebugProtocolServer, WinDAPDri
|
||||||
val hasher = MessageDigest.getInstance("SHA-256")
|
val hasher = MessageDigest.getInstance("SHA-256")
|
||||||
hasher.update(handshake.value.encodeToByteArray())
|
hasher.update(handshake.value.encodeToByteArray())
|
||||||
val inflater = Inflater(true)
|
val inflater = Inflater(true)
|
||||||
val coconut = DAPDebuggerClient::class.java.getResourceAsStream("/coconut.jpg").use { it.readAllBytes() } ?: throw RuntimeException("No coconut")
|
val coconut = DAPDebuggerClient::class.java.getResourceAsStream("/coconut.jpg")?.use(InputStream::readAllBytes) ?: throw RuntimeException("No coconut")
|
||||||
inflater.setInput(coconut, coconut.size - 80, 77)
|
inflater.setInput(coconut, coconut.size - 80, 77)
|
||||||
inflater.finished()
|
inflater.finished()
|
||||||
val b = ByteArray(1)
|
val b = ByteArray(1)
|
||||||
|
|
|
@ -65,10 +65,10 @@ object DirenvCmd {
|
||||||
return emptyEnv
|
return emptyEnv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runOutput.output.isBlank()) {
|
return if (runOutput.output.isBlank()) {
|
||||||
return emptyEnv
|
emptyEnv
|
||||||
} else {
|
} else {
|
||||||
return Env(Json.decodeFromString<Map<String, String>>(runOutput.output))
|
Env(Json.decodeFromString<Map<String, String>>(runOutput.output))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class ZigLanguageServerFactory: LanguageServerFactory, LanguageServerEnablementS
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isEnabled(project: Project): Boolean {
|
override fun isEnabled(project: Project): Boolean {
|
||||||
return (project.getUserData(ENABLED_KEY) ?: true) && project.zlsSettings.validate()
|
return (project.getUserData(ENABLED_KEY) != false) && project.zlsSettings.validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setEnabled(enabled: Boolean, project: Project) {
|
override fun setEnabled(enabled: Boolean, project: Project) {
|
||||||
|
|
|
@ -224,7 +224,7 @@ class FilePathConfigurable(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CheckboxConfigurable(
|
open class CheckboxConfigurable(
|
||||||
@Transient private val serializedName: String,
|
@Transient private val serializedName: String,
|
||||||
@Transient @Nls private val label: String,
|
@Transient @Nls private val label: String,
|
||||||
var value: Boolean
|
var value: Boolean
|
||||||
|
@ -274,10 +274,17 @@ class CheckboxConfigurable(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ColoredConfigurable(serializedName: String) = CheckboxConfigurable(serializedName, ZigBrainsBundle.message("exec.option.label.colored-terminal"), true)
|
class ColoredConfigurable(serializedName: String): CheckboxConfigurable(serializedName, ZigBrainsBundle.message("exec.option.label.colored-terminal"), true) {
|
||||||
|
override fun clone(): ColoredConfigurable {
|
||||||
|
return super.clone() as ColoredConfigurable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun DirenvConfigurable(serializedName: String, project: Project) =
|
class DirenvConfigurable(serializedName: String, project: Project): CheckboxConfigurable(serializedName, ZigBrainsBundle.message("exec.option.label.direnv"), project.zigProjectSettings.state.direnv) {
|
||||||
CheckboxConfigurable(serializedName, ZigBrainsBundle.message("exec.option.label.direnv"), project.zigProjectSettings.state.direnv)
|
override fun clone(): DirenvConfigurable {
|
||||||
|
return super.clone() as DirenvConfigurable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class OptimizationConfigurable(
|
class OptimizationConfigurable(
|
||||||
@Transient private val serializedName: String,
|
@Transient private val serializedName: String,
|
||||||
|
|
|
@ -24,7 +24,6 @@ package com.falsepattern.zigbrains.project.execution.base
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.ZigBrainsBundle
|
import com.falsepattern.zigbrains.ZigBrainsBundle
|
||||||
import com.falsepattern.zigbrains.direnv.DirenvCmd
|
import com.falsepattern.zigbrains.direnv.DirenvCmd
|
||||||
import com.falsepattern.zigbrains.project.toolchain.AbstractZigToolchain
|
|
||||||
import com.intellij.execution.ExecutionException
|
import com.intellij.execution.ExecutionException
|
||||||
import com.intellij.execution.Executor
|
import com.intellij.execution.Executor
|
||||||
import com.intellij.execution.configurations.ConfigurationFactory
|
import com.intellij.execution.configurations.ConfigurationFactory
|
||||||
|
|
|
@ -34,7 +34,7 @@ abstract class ZigTopLevelLineMarker: RunLineMarkerContributor() {
|
||||||
private fun getParentIfTopLevel(element: PsiElement): PsiElement? {
|
private fun getParentIfTopLevel(element: PsiElement): PsiElement? {
|
||||||
var parent = getDeclaration(element)
|
var parent = getDeclaration(element)
|
||||||
|
|
||||||
var nestingLevel = 0;
|
var nestingLevel = 0
|
||||||
while (parent != null && parent !is PsiFile) {
|
while (parent != null && parent !is PsiFile) {
|
||||||
if (parent.elementType == ZigTypes.CONTAINER_DECLARATION) {
|
if (parent.elementType == ZigTypes.CONTAINER_DECLARATION) {
|
||||||
if (nestingLevel != 0)
|
if (nestingLevel != 0)
|
||||||
|
@ -54,7 +54,7 @@ abstract class ZigTopLevelLineMarker: RunLineMarkerContributor() {
|
||||||
|
|
||||||
override fun getInfo(element: PsiElement): Info? {
|
override fun getInfo(element: PsiElement): Info? {
|
||||||
if (!elementMatches(element))
|
if (!elementMatches(element))
|
||||||
return null;
|
return null
|
||||||
val actions = ExecutorAction.getActions(0)
|
val actions = ExecutorAction.getActions(0)
|
||||||
return Info(getIcon(element), actions, null)
|
return Info(getIcon(element), actions, null)
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,10 @@ class ZigExecConfigBuild(project: Project, factory: ConfigurationFactory): ZigEx
|
||||||
|
|
||||||
override fun getConfigurables(): List<ZigConfigurable<*>> {
|
override fun getConfigurables(): List<ZigConfigurable<*>> {
|
||||||
val baseCfg = super.getConfigurables() + listOf(buildSteps, extraArgs, colored)
|
val baseCfg = super.getConfigurables() + listOf(buildSteps, extraArgs, colored)
|
||||||
if (ZBFeatures.debug()) {
|
return if (ZBFeatures.debug()) {
|
||||||
return baseCfg + listOf(exePath, exeArgs)
|
baseCfg + listOf(exePath, exeArgs)
|
||||||
} else {
|
} else {
|
||||||
return baseCfg
|
baseCfg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,5 +25,4 @@ package com.falsepattern.zigbrains.project.execution.build
|
||||||
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
||||||
import com.intellij.execution.runners.ExecutionEnvironment
|
import com.intellij.execution.runners.ExecutionEnvironment
|
||||||
|
|
||||||
class ZigProfileStateBuild(environment: ExecutionEnvironment, configuration: ZigExecConfigBuild) : ZigProfileState<ZigExecConfigBuild>(environment, configuration) {
|
class ZigProfileStateBuild(environment: ExecutionEnvironment, configuration: ZigExecConfigBuild) : ZigProfileState<ZigExecConfigBuild>(environment, configuration)
|
||||||
}
|
|
|
@ -25,5 +25,4 @@ package com.falsepattern.zigbrains.project.execution.run
|
||||||
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
||||||
import com.intellij.execution.runners.ExecutionEnvironment
|
import com.intellij.execution.runners.ExecutionEnvironment
|
||||||
|
|
||||||
class ZigProfileStateRun(environment: ExecutionEnvironment, configuration: ZigExecConfigRun) : ZigProfileState<ZigExecConfigRun>(environment, configuration) {
|
class ZigProfileStateRun(environment: ExecutionEnvironment, configuration: ZigExecConfigRun) : ZigProfileState<ZigExecConfigRun>(environment, configuration)
|
||||||
}
|
|
|
@ -25,5 +25,4 @@ package com.falsepattern.zigbrains.project.execution.test
|
||||||
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
||||||
import com.intellij.execution.runners.ExecutionEnvironment
|
import com.intellij.execution.runners.ExecutionEnvironment
|
||||||
|
|
||||||
class ZigProfileStateTest(environment: ExecutionEnvironment, configuration: ZigExecConfigTest) : ZigProfileState<ZigExecConfigTest>(environment, configuration) {
|
class ZigProfileStateTest(environment: ExecutionEnvironment, configuration: ZigExecConfigTest) : ZigProfileState<ZigExecConfigTest>(environment, configuration)
|
||||||
}
|
|
|
@ -28,13 +28,11 @@ import com.falsepattern.zigbrains.project.settings.ZigProjectSettings
|
||||||
import com.falsepattern.zigbrains.project.settings.zigProjectSettings
|
import com.falsepattern.zigbrains.project.settings.zigProjectSettings
|
||||||
import com.falsepattern.zigbrains.project.template.ZigInitTemplate
|
import com.falsepattern.zigbrains.project.template.ZigInitTemplate
|
||||||
import com.falsepattern.zigbrains.project.template.ZigProjectTemplate
|
import com.falsepattern.zigbrains.project.template.ZigProjectTemplate
|
||||||
import com.falsepattern.zigbrains.shared.coroutine.withEDTContext
|
|
||||||
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
||||||
import com.intellij.notification.Notification
|
import com.intellij.notification.Notification
|
||||||
import com.intellij.notification.NotificationType
|
import com.intellij.notification.NotificationType
|
||||||
import com.intellij.openapi.GitRepositoryInitializer
|
import com.intellij.openapi.GitRepositoryInitializer
|
||||||
import com.intellij.openapi.application.writeAction
|
import com.intellij.openapi.application.writeAction
|
||||||
import com.intellij.openapi.progress.coroutineToIndicator
|
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.vfs.VfsUtil
|
import com.intellij.openapi.vfs.VfsUtil
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
|
@ -42,11 +40,7 @@ import com.intellij.openapi.vfs.toNioPathOrNull
|
||||||
import com.intellij.platform.util.progress.reportProgress
|
import com.intellij.platform.util.progress.reportProgress
|
||||||
import com.intellij.util.ResourceUtil
|
import com.intellij.util.ResourceUtil
|
||||||
import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
|
import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
|
||||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
|
||||||
import com.intellij.util.concurrency.annotations.RequiresWriteLock
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
|
|
||||||
@JvmRecord
|
@JvmRecord
|
||||||
data class ZigProjectConfigurationData(
|
data class ZigProjectConfigurationData(
|
||||||
|
@ -141,7 +135,7 @@ private suspend fun createGitIgnoreFile(project: Project, projectDir: VirtualFil
|
||||||
writeAction {
|
writeAction {
|
||||||
ZigProjectConfigurationData::class.java.getResourceAsStream("/fileTemplates/internal/gitignore")?.use {
|
ZigProjectConfigurationData::class.java.getResourceAsStream("/fileTemplates/internal/gitignore")?.use {
|
||||||
val file = projectDir.createChildData(requestor, ".gitignore")
|
val file = projectDir.createChildData(requestor, ".gitignore")
|
||||||
file.setCharset(Charsets.UTF_8)
|
file.charset = Charsets.UTF_8
|
||||||
file.setBinaryContent(it.readAllBytes())
|
file.setBinaryContent(it.readAllBytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,17 +48,17 @@ class ZigProcessHandler : KillableColoredProcessHandler, ColoredTextAcceptor {
|
||||||
|
|
||||||
private val VT100_CHARS = CharArray(256).apply {
|
private val VT100_CHARS = CharArray(256).apply {
|
||||||
this.fill(' ')
|
this.fill(' ')
|
||||||
this[0x6A] = '┘';
|
this[0x6A] = '┘'
|
||||||
this[0x6B] = '┐';
|
this[0x6B] = '┐'
|
||||||
this[0x6C] = '┌';
|
this[0x6C] = '┌'
|
||||||
this[0x6D] = '└';
|
this[0x6D] = '└'
|
||||||
this[0x6E] = '┼';
|
this[0x6E] = '┼'
|
||||||
this[0x71] = '─';
|
this[0x71] = '─'
|
||||||
this[0x74] = '├';
|
this[0x74] = '├'
|
||||||
this[0x75] = '┤';
|
this[0x75] = '┤'
|
||||||
this[0x76] = '┴';
|
this[0x76] = '┴'
|
||||||
this[0x77] = '┬';
|
this[0x77] = '┬'
|
||||||
this[0x78] = '│';
|
this[0x78] = '│'
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val VT100_BEGIN_SEQ = "\u001B(0"
|
private const val VT100_BEGIN_SEQ = "\u001B(0"
|
||||||
|
|
|
@ -25,7 +25,6 @@ package com.falsepattern.zigbrains.project.run
|
||||||
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
import com.falsepattern.zigbrains.project.execution.base.ZigProfileState
|
||||||
import com.falsepattern.zigbrains.project.settings.zigProjectSettings
|
import com.falsepattern.zigbrains.project.settings.zigProjectSettings
|
||||||
import com.falsepattern.zigbrains.project.toolchain.AbstractZigToolchain
|
import com.falsepattern.zigbrains.project.toolchain.AbstractZigToolchain
|
||||||
import com.falsepattern.zigbrains.shared.coroutine.withEDTContext
|
|
||||||
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
||||||
import com.intellij.execution.ExecutionException
|
import com.intellij.execution.ExecutionException
|
||||||
import com.intellij.execution.configurations.RunProfileState
|
import com.intellij.execution.configurations.RunProfileState
|
||||||
|
|
|
@ -27,7 +27,6 @@ import com.falsepattern.zigbrains.direnv.DirenvCmd
|
||||||
import com.falsepattern.zigbrains.project.toolchain.LocalZigToolchain
|
import com.falsepattern.zigbrains.project.toolchain.LocalZigToolchain
|
||||||
import com.falsepattern.zigbrains.project.toolchain.ZigToolchainProvider
|
import com.falsepattern.zigbrains.project.toolchain.ZigToolchainProvider
|
||||||
import com.falsepattern.zigbrains.shared.coroutine.launchWithEDT
|
import com.falsepattern.zigbrains.shared.coroutine.launchWithEDT
|
||||||
import com.falsepattern.zigbrains.shared.coroutine.withEDTContext
|
|
||||||
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
|
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
|
||||||
|
|
|
@ -28,9 +28,6 @@ interface ZigStepDiscoveryListener {
|
||||||
suspend fun errorReload(type: ErrorType, details: String?) {}
|
suspend fun errorReload(type: ErrorType, details: String?) {}
|
||||||
suspend fun timeoutReload(seconds: Int) {}
|
suspend fun timeoutReload(seconds: Int) {}
|
||||||
|
|
||||||
companion object {
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class ErrorType {
|
enum class ErrorType {
|
||||||
MissingToolchain,
|
MissingToolchain,
|
||||||
MissingBuildZig,
|
MissingBuildZig,
|
||||||
|
|
|
@ -44,7 +44,7 @@ class ZigStepDiscoveryService(private val project: Project) {
|
||||||
private val reloading = AtomicBoolean(false)
|
private val reloading = AtomicBoolean(false)
|
||||||
private val reloadScheduled = AtomicBoolean(false)
|
private val reloadScheduled = AtomicBoolean(false)
|
||||||
private val reloadMutex = Mutex()
|
private val reloadMutex = Mutex()
|
||||||
private var CURRENT_TIMEOUT_SEC = DEFAULT_TIMEOUT_SEC
|
private var currentTimeoutSec = DEFAULT_TIMEOUT_SEC
|
||||||
private val listeners = ArrayList<ZigStepDiscoveryListener>()
|
private val listeners = ArrayList<ZigStepDiscoveryListener>()
|
||||||
private val listenerMutex = Mutex()
|
private val listenerMutex = Mutex()
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@ class ZigStepDiscoveryService(private val project: Project) {
|
||||||
val result = zig.callWithArgs(
|
val result = zig.callWithArgs(
|
||||||
project.guessProjectDir()?.toNioPathOrNull(),
|
project.guessProjectDir()?.toNioPathOrNull(),
|
||||||
"build", "-l",
|
"build", "-l",
|
||||||
timeoutMillis = CURRENT_TIMEOUT_SEC * 1000L
|
timeoutMillis = currentTimeoutSec * 1000L
|
||||||
)
|
)
|
||||||
if (result.checkSuccess(LOG)) {
|
if (result.checkSuccess(LOG)) {
|
||||||
CURRENT_TIMEOUT_SEC = DEFAULT_TIMEOUT_SEC
|
currentTimeoutSec = DEFAULT_TIMEOUT_SEC
|
||||||
val lines = result.stdoutLines
|
val lines = result.stdoutLines
|
||||||
val steps = ArrayList<Pair<String, String?>>()
|
val steps = ArrayList<Pair<String, String?>>()
|
||||||
for (line in lines) {
|
for (line in lines) {
|
||||||
|
@ -99,8 +99,8 @@ class ZigStepDiscoveryService(private val project: Project) {
|
||||||
}
|
}
|
||||||
postReload(steps)
|
postReload(steps)
|
||||||
} else if (result.isTimeout) {
|
} else if (result.isTimeout) {
|
||||||
timeoutReload(CURRENT_TIMEOUT_SEC)
|
timeoutReload(currentTimeoutSec)
|
||||||
CURRENT_TIMEOUT_SEC *= 2
|
currentTimeoutSec *= 2
|
||||||
} else if (result.stderrLines.any { it.contains("error: no build.zig file found, in the current directory or any parent directories") }) {
|
} else if (result.stderrLines.any { it.contains("error: no build.zig file found, in the current directory or any parent directories") }) {
|
||||||
errorReload(ErrorType.MissingBuildZig, result.stderr)
|
errorReload(ErrorType.MissingBuildZig, result.stderr)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* This file is part of ZigBrains.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023-2024 FalsePattern
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included
|
||||||
|
* in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* ZigBrains is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, only version 3 of the License.
|
||||||
|
*
|
||||||
|
* ZigBrains is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with ZigBrains. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.falsepattern.zigbrains.zig.codeInsight
|
||||||
|
|
||||||
|
import com.falsepattern.zigbrains.ZigBrainsBundle
|
||||||
|
import com.falsepattern.zigbrains.zig.psi.ZigFile
|
||||||
|
import com.falsepattern.zigbrains.zig.psi.ZigTypes
|
||||||
|
import com.intellij.codeInsight.template.TemplateActionContext
|
||||||
|
import com.intellij.codeInsight.template.TemplateContextType
|
||||||
|
import com.intellij.psi.util.elementType
|
||||||
|
|
||||||
|
class ZigContext: TemplateContextType(ZigBrainsBundle.message("zig")) {
|
||||||
|
override fun isInContext(templateActionContext: TemplateActionContext): Boolean {
|
||||||
|
val file = templateActionContext.file
|
||||||
|
val offset = templateActionContext.startOffset
|
||||||
|
|
||||||
|
if (file !is ZigFile)
|
||||||
|
return false
|
||||||
|
|
||||||
|
val element = file.findElementAt(offset) ?: return true
|
||||||
|
|
||||||
|
return when (element.elementType) {
|
||||||
|
ZigTypes.LINE_COMMENT, ZigTypes.CONTAINER_DOC_COMMENT, ZigTypes.DOC_COMMENT -> false
|
||||||
|
ZigTypes.STRING_LITERAL_SINGLE, ZigTypes.STRING_LITERAL_MULTI -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,7 +41,7 @@ class ZigStringElementManipulator: AbstractElementManipulator<ZigStringLiteral>(
|
||||||
val originalContext = element.text!!
|
val originalContext = element.text!!
|
||||||
val isMultiline = element.isMultiline
|
val isMultiline = element.isMultiline
|
||||||
@NonNls
|
@NonNls
|
||||||
val prefix = "const x = \n";
|
val prefix = "const x = \n"
|
||||||
val suffix = "\n;"
|
val suffix = "\n;"
|
||||||
val sbFactory: (Int) -> StringBuilder = {
|
val sbFactory: (Int) -> StringBuilder = {
|
||||||
val sb = StringBuilder(prefix.length + suffix.length + it)
|
val sb = StringBuilder(prefix.length + suffix.length + it)
|
||||||
|
|
|
@ -38,7 +38,7 @@ class MakeStringMultiline: PsiElementBaseIntentionAction() {
|
||||||
override fun getFamilyName() = ZigBrainsBundle.message("intention.family.name.make-string-multiline")
|
override fun getFamilyName() = ZigBrainsBundle.message("intention.family.name.make-string-multiline")
|
||||||
|
|
||||||
override fun isAvailable(project: Project, editor: Editor?, element: PsiElement) =
|
override fun isAvailable(project: Project, editor: Editor?, element: PsiElement) =
|
||||||
editor != null && element.parentOfType<ZigStringLiteral>()?.isMultiline?.not() ?: false
|
editor != null && element.parentOfType<ZigStringLiteral>()?.isMultiline?.not() == true
|
||||||
|
|
||||||
override fun invoke(project: Project, editor: Editor?, element: PsiElement) {
|
override fun invoke(project: Project, editor: Editor?, element: PsiElement) {
|
||||||
editor ?: return
|
editor ?: return
|
||||||
|
|
|
@ -41,7 +41,7 @@ class MakeStringQuoted: PsiElementBaseIntentionAction() {
|
||||||
override fun getFamilyName() = ZigBrainsBundle.message("intention.family.name.make-string-quoted")
|
override fun getFamilyName() = ZigBrainsBundle.message("intention.family.name.make-string-quoted")
|
||||||
|
|
||||||
override fun isAvailable(project: Project, editor: Editor?, element: PsiElement) =
|
override fun isAvailable(project: Project, editor: Editor?, element: PsiElement) =
|
||||||
editor != null && element.parentOfType<ZigStringLiteral>()?.isMultiline ?: false
|
editor != null && element.parentOfType<ZigStringLiteral>()?.isMultiline == true
|
||||||
|
|
||||||
override fun invoke(project: Project, editor: Editor?, element: PsiElement) {
|
override fun invoke(project: Project, editor: Editor?, element: PsiElement) {
|
||||||
editor ?: return
|
editor ?: return
|
||||||
|
|
|
@ -24,5 +24,4 @@ package com.falsepattern.zigbrains.zig.lexerstring
|
||||||
|
|
||||||
import com.intellij.lexer.FlexAdapter
|
import com.intellij.lexer.FlexAdapter
|
||||||
|
|
||||||
class ZigLexerStringAdapter: FlexAdapter(ZigLexerString(null)) {
|
class ZigLexerStringAdapter: FlexAdapter(ZigLexerString(null))
|
||||||
}
|
|
|
@ -67,7 +67,7 @@ abstract class ZigStringLiteralMixinImpl(node: ASTNode): ASTWrapperPsiElement(no
|
||||||
val text = myHost.text.also { _text = it }
|
val text = myHost.text.also { _text = it }
|
||||||
val isMultiline = myHost.isMultiline
|
val isMultiline = myHost.isMultiline
|
||||||
val contentRanges = myHost.contentRanges.also { _contentRanges = it }
|
val contentRanges = myHost.contentRanges.also { _contentRanges = it }
|
||||||
var decoded = false;
|
var decoded = false
|
||||||
for (range in contentRanges) {
|
for (range in contentRanges) {
|
||||||
val intersection = range.intersection(rangeInsideHost) ?: continue
|
val intersection = range.intersection(rangeInsideHost) ?: continue
|
||||||
decoded = true
|
decoded = true
|
||||||
|
|
|
@ -133,7 +133,7 @@ private fun doAddCompletions(
|
||||||
|
|
||||||
private val ZonProperty.isDependency: Boolean
|
private val ZonProperty.isDependency: Boolean
|
||||||
get() {
|
get() {
|
||||||
return parentOfType<ZonEntry>()?.isDependency ?: false
|
return parentOfType<ZonEntry>()?.isDependency == true
|
||||||
}
|
}
|
||||||
|
|
||||||
private val ZonEntry.isDependency: Boolean
|
private val ZonEntry.isDependency: Boolean
|
||||||
|
|
|
@ -170,6 +170,11 @@
|
||||||
icon="/icons/zig_build_tool.svg"
|
icon="/icons/zig_build_tool.svg"
|
||||||
id="zigbrains.build"
|
id="zigbrains.build"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<liveTemplateContext
|
||||||
|
contextId="ZIG"
|
||||||
|
implementation="com.falsepattern.zigbrains.zig.codeInsight.ZigContext"
|
||||||
|
/>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.falsepattern.zigbrains">
|
<extensions defaultExtensionNs="com.falsepattern.zigbrains">
|
||||||
|
|
|
@ -114,4 +114,5 @@ build.tool.window.status.loading=Running zig build -l
|
||||||
build.tool.window.status.error.missing-build-zig=No build.zig file found
|
build.tool.window.status.error.missing-build-zig=No build.zig file found
|
||||||
build.tool.window.status.error.missing-toolchain=No zig toolchain configured
|
build.tool.window.status.error.missing-toolchain=No zig toolchain configured
|
||||||
build.tool.window.status.error.general=Error while running zig build -l
|
build.tool.window.status.error.general=Error while running zig build -l
|
||||||
build.tool.window.status.timeout=zig build -l timed out after {0} seconds.
|
build.tool.window.status.timeout=zig build -l timed out after {0} seconds.
|
||||||
|
zig=Zig
|
|
@ -1,7 +1,7 @@
|
||||||
pluginName=ZigBrains
|
pluginName=ZigBrains
|
||||||
pluginRepositoryUrl=https://github.com/FalsePattern/ZigBrains
|
pluginRepositoryUrl=https://github.com/FalsePattern/ZigBrains
|
||||||
|
|
||||||
pluginVersion=20.1.3
|
pluginVersion=20.2.0
|
||||||
|
|
||||||
pluginSinceBuild=241
|
pluginSinceBuild=241
|
||||||
pluginUntilBuild=241.*
|
pluginUntilBuild=241.*
|
||||||
|
@ -14,7 +14,7 @@ javaVersion=17
|
||||||
runIdeTarget=clion
|
runIdeTarget=clion
|
||||||
|
|
||||||
lsp4jVersion=0.21.1
|
lsp4jVersion=0.21.1
|
||||||
lsp4ijVersion=0.7.0
|
lsp4ijVersion=0.9.0
|
||||||
lsp4ijNightly=false
|
lsp4ijNightly=false
|
||||||
|
|
||||||
kotlin.stdlib.default.dependency=false
|
kotlin.stdlib.default.dependency=false
|
||||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
3
gradlew
vendored
3
gradlew
vendored
|
@ -86,8 +86,7 @@ done
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
Loading…
Add table
Reference in a new issue