chore: Fix kotlin style issues
This commit is contained in:
parent
87d30dfaa2
commit
ecf01829cf
22 changed files with 49 additions and 57 deletions
|
@ -38,6 +38,7 @@ import org.eclipse.lsp4j.jsonrpc.MessageConsumer
|
|||
import org.eclipse.lsp4j.jsonrpc.debug.messages.DebugResponseMessage
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Message
|
||||
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest
|
||||
import java.io.InputStream
|
||||
import java.lang.RuntimeException
|
||||
import java.security.MessageDigest
|
||||
import java.util.Base64
|
||||
|
@ -73,7 +74,7 @@ class WinDAPDriver(handler: Handler) : DAPDriver<IDebugProtocolServer, WinDAPDri
|
|||
handshakeFinished.acquire()
|
||||
}
|
||||
|
||||
inner class WinDAPDebuggerClient: DAPDriver<IDebugProtocolServer, WinDAPDriver.WinDAPDebuggerClient>.DAPDebuggerClient() {
|
||||
inner class WinDAPDebuggerClient: DAPDriver<IDebugProtocolServer, WinDAPDebuggerClient>.DAPDebuggerClient() {
|
||||
override fun output(args: OutputEventArguments) {
|
||||
if ("telemetry" == args.category)
|
||||
return
|
||||
|
@ -92,7 +93,7 @@ class WinDAPDriver(handler: Handler) : DAPDriver<IDebugProtocolServer, WinDAPDri
|
|||
val hasher = MessageDigest.getInstance("SHA-256")
|
||||
hasher.update(handshake.value.encodeToByteArray())
|
||||
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.finished()
|
||||
val b = ByteArray(1)
|
||||
|
|
|
@ -65,10 +65,10 @@ object DirenvCmd {
|
|||
return emptyEnv
|
||||
}
|
||||
}
|
||||
if (runOutput.output.isBlank()) {
|
||||
return emptyEnv
|
||||
return if (runOutput.output.isBlank()) {
|
||||
emptyEnv
|
||||
} 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 {
|
||||
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) {
|
||||
|
|
|
@ -224,7 +224,7 @@ class FilePathConfigurable(
|
|||
}
|
||||
}
|
||||
|
||||
class CheckboxConfigurable(
|
||||
open class CheckboxConfigurable(
|
||||
@Transient private val serializedName: String,
|
||||
@Transient @Nls private val label: String,
|
||||
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) =
|
||||
CheckboxConfigurable(serializedName, ZigBrainsBundle.message("exec.option.label.direnv"), project.zigProjectSettings.state.direnv)
|
||||
class DirenvConfigurable(serializedName: String, project: Project): CheckboxConfigurable(serializedName, ZigBrainsBundle.message("exec.option.label.direnv"), project.zigProjectSettings.state.direnv) {
|
||||
override fun clone(): DirenvConfigurable {
|
||||
return super.clone() as DirenvConfigurable
|
||||
}
|
||||
}
|
||||
|
||||
class OptimizationConfigurable(
|
||||
@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.direnv.DirenvCmd
|
||||
import com.falsepattern.zigbrains.project.toolchain.AbstractZigToolchain
|
||||
import com.intellij.execution.ExecutionException
|
||||
import com.intellij.execution.Executor
|
||||
import com.intellij.execution.configurations.ConfigurationFactory
|
||||
|
|
|
@ -34,7 +34,7 @@ abstract class ZigTopLevelLineMarker: RunLineMarkerContributor() {
|
|||
private fun getParentIfTopLevel(element: PsiElement): PsiElement? {
|
||||
var parent = getDeclaration(element)
|
||||
|
||||
var nestingLevel = 0;
|
||||
var nestingLevel = 0
|
||||
while (parent != null && parent !is PsiFile) {
|
||||
if (parent.elementType == ZigTypes.CONTAINER_DECLARATION) {
|
||||
if (nestingLevel != 0)
|
||||
|
@ -54,7 +54,7 @@ abstract class ZigTopLevelLineMarker: RunLineMarkerContributor() {
|
|||
|
||||
override fun getInfo(element: PsiElement): Info? {
|
||||
if (!elementMatches(element))
|
||||
return null;
|
||||
return null
|
||||
val actions = ExecutorAction.getActions(0)
|
||||
return Info(getIcon(element), actions, null)
|
||||
}
|
||||
|
|
|
@ -82,10 +82,10 @@ class ZigExecConfigBuild(project: Project, factory: ConfigurationFactory): ZigEx
|
|||
|
||||
override fun getConfigurables(): List<ZigConfigurable<*>> {
|
||||
val baseCfg = super.getConfigurables() + listOf(buildSteps, extraArgs, colored)
|
||||
if (ZBFeatures.debug()) {
|
||||
return baseCfg + listOf(exePath, exeArgs)
|
||||
return if (ZBFeatures.debug()) {
|
||||
baseCfg + listOf(exePath, exeArgs)
|
||||
} 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.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.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.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.template.ZigInitTemplate
|
||||
import com.falsepattern.zigbrains.project.template.ZigProjectTemplate
|
||||
import com.falsepattern.zigbrains.shared.coroutine.withEDTContext
|
||||
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
||||
import com.intellij.notification.Notification
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.GitRepositoryInitializer
|
||||
import com.intellij.openapi.application.writeAction
|
||||
import com.intellij.openapi.progress.coroutineToIndicator
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
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.util.ResourceUtil
|
||||
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.withContext
|
||||
|
||||
@JvmRecord
|
||||
data class ZigProjectConfigurationData(
|
||||
|
@ -141,7 +135,7 @@ private suspend fun createGitIgnoreFile(project: Project, projectDir: VirtualFil
|
|||
writeAction {
|
||||
ZigProjectConfigurationData::class.java.getResourceAsStream("/fileTemplates/internal/gitignore")?.use {
|
||||
val file = projectDir.createChildData(requestor, ".gitignore")
|
||||
file.setCharset(Charsets.UTF_8)
|
||||
file.charset = Charsets.UTF_8
|
||||
file.setBinaryContent(it.readAllBytes())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,17 +48,17 @@ class ZigProcessHandler : KillableColoredProcessHandler, ColoredTextAcceptor {
|
|||
|
||||
private val VT100_CHARS = CharArray(256).apply {
|
||||
this.fill(' ')
|
||||
this[0x6A] = '┘';
|
||||
this[0x6B] = '┐';
|
||||
this[0x6C] = '┌';
|
||||
this[0x6D] = '└';
|
||||
this[0x6E] = '┼';
|
||||
this[0x71] = '─';
|
||||
this[0x74] = '├';
|
||||
this[0x75] = '┤';
|
||||
this[0x76] = '┴';
|
||||
this[0x77] = '┬';
|
||||
this[0x78] = '│';
|
||||
this[0x6A] = '┘'
|
||||
this[0x6B] = '┐'
|
||||
this[0x6C] = '┌'
|
||||
this[0x6D] = '└'
|
||||
this[0x6E] = '┼'
|
||||
this[0x71] = '─'
|
||||
this[0x74] = '├'
|
||||
this[0x75] = '┤'
|
||||
this[0x76] = '┴'
|
||||
this[0x77] = '┬'
|
||||
this[0x78] = '│'
|
||||
}
|
||||
|
||||
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.settings.zigProjectSettings
|
||||
import com.falsepattern.zigbrains.project.toolchain.AbstractZigToolchain
|
||||
import com.falsepattern.zigbrains.shared.coroutine.withEDTContext
|
||||
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
||||
import com.intellij.execution.ExecutionException
|
||||
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.ZigToolchainProvider
|
||||
import com.falsepattern.zigbrains.shared.coroutine.launchWithEDT
|
||||
import com.falsepattern.zigbrains.shared.coroutine.withEDTContext
|
||||
import com.falsepattern.zigbrains.shared.zigCoroutineScope
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
|
||||
|
|
|
@ -28,9 +28,6 @@ interface ZigStepDiscoveryListener {
|
|||
suspend fun errorReload(type: ErrorType, details: String?) {}
|
||||
suspend fun timeoutReload(seconds: Int) {}
|
||||
|
||||
companion object {
|
||||
}
|
||||
|
||||
enum class ErrorType {
|
||||
MissingToolchain,
|
||||
MissingBuildZig,
|
||||
|
|
|
@ -44,7 +44,7 @@ class ZigStepDiscoveryService(private val project: Project) {
|
|||
private val reloading = AtomicBoolean(false)
|
||||
private val reloadScheduled = AtomicBoolean(false)
|
||||
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 listenerMutex = Mutex()
|
||||
|
||||
|
@ -83,10 +83,10 @@ class ZigStepDiscoveryService(private val project: Project) {
|
|||
val result = zig.callWithArgs(
|
||||
project.guessProjectDir()?.toNioPathOrNull(),
|
||||
"build", "-l",
|
||||
timeoutMillis = CURRENT_TIMEOUT_SEC * 1000L
|
||||
timeoutMillis = currentTimeoutSec * 1000L
|
||||
)
|
||||
if (result.checkSuccess(LOG)) {
|
||||
CURRENT_TIMEOUT_SEC = DEFAULT_TIMEOUT_SEC
|
||||
currentTimeoutSec = DEFAULT_TIMEOUT_SEC
|
||||
val lines = result.stdoutLines
|
||||
val steps = ArrayList<Pair<String, String?>>()
|
||||
for (line in lines) {
|
||||
|
@ -99,8 +99,8 @@ class ZigStepDiscoveryService(private val project: Project) {
|
|||
}
|
||||
postReload(steps)
|
||||
} else if (result.isTimeout) {
|
||||
timeoutReload(CURRENT_TIMEOUT_SEC)
|
||||
CURRENT_TIMEOUT_SEC *= 2
|
||||
timeoutReload(currentTimeoutSec)
|
||||
currentTimeoutSec *= 2
|
||||
} 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)
|
||||
} else {
|
||||
|
|
|
@ -41,7 +41,7 @@ class ZigStringElementManipulator: AbstractElementManipulator<ZigStringLiteral>(
|
|||
val originalContext = element.text!!
|
||||
val isMultiline = element.isMultiline
|
||||
@NonNls
|
||||
val prefix = "const x = \n";
|
||||
val prefix = "const x = \n"
|
||||
val suffix = "\n;"
|
||||
val sbFactory: (Int) -> StringBuilder = {
|
||||
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 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) {
|
||||
editor ?: return
|
||||
|
|
|
@ -41,7 +41,7 @@ class MakeStringQuoted: PsiElementBaseIntentionAction() {
|
|||
override fun getFamilyName() = ZigBrainsBundle.message("intention.family.name.make-string-quoted")
|
||||
|
||||
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) {
|
||||
editor ?: return
|
||||
|
|
|
@ -24,5 +24,4 @@ package com.falsepattern.zigbrains.zig.lexerstring
|
|||
|
||||
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 isMultiline = myHost.isMultiline
|
||||
val contentRanges = myHost.contentRanges.also { _contentRanges = it }
|
||||
var decoded = false;
|
||||
var decoded = false
|
||||
for (range in contentRanges) {
|
||||
val intersection = range.intersection(rangeInsideHost) ?: continue
|
||||
decoded = true
|
||||
|
|
|
@ -133,7 +133,7 @@ private fun doAddCompletions(
|
|||
|
||||
private val ZonProperty.isDependency: Boolean
|
||||
get() {
|
||||
return parentOfType<ZonEntry>()?.isDependency ?: false
|
||||
return parentOfType<ZonEntry>()?.isDependency == true
|
||||
}
|
||||
|
||||
private val ZonEntry.isDependency: Boolean
|
||||
|
|
Loading…
Add table
Reference in a new issue