fix: replaced Path.exists() calls with File.toFile().exists()
This commit is contained in:
parent
adb8797051
commit
a3143dbc0c
9 changed files with 19 additions and 21 deletions
|
@ -17,6 +17,10 @@ Changelog structure reference:
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Zig source file path highlighter made the terminal lag with some files
|
||||||
|
|
||||||
## [20.1.1]
|
## [20.1.1]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -43,7 +43,6 @@ import java.nio.file.Path
|
||||||
import java.util.stream.Stream
|
import java.util.stream.Stream
|
||||||
import kotlin.io.path.isExecutable
|
import kotlin.io.path.isExecutable
|
||||||
import kotlin.io.path.isRegularFile
|
import kotlin.io.path.isRegularFile
|
||||||
import kotlin.io.path.notExists
|
|
||||||
|
|
||||||
class ZigDebugParametersBuild(
|
class ZigDebugParametersBuild(
|
||||||
driverConfiguration: DebuggerDriverConfiguration,
|
driverConfiguration: DebuggerDriverConfiguration,
|
||||||
|
@ -73,7 +72,7 @@ class ZigDebugParametersBuild(
|
||||||
fail("debug.build.compile.failed.no-workdir")
|
fail("debug.build.compile.failed.no-workdir")
|
||||||
}
|
}
|
||||||
val expectedOutputDir = workingDir.resolve(Path.of("zig-out", "bin"))
|
val expectedOutputDir = workingDir.resolve(Path.of("zig-out", "bin"))
|
||||||
if (expectedOutputDir.notExists()) {
|
if (!expectedOutputDir.toFile().exists()) {
|
||||||
fail("debug.build.compile.failed.autodetect")
|
fail("debug.build.compile.failed.autodetect")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ class ZigDebugParametersBuild(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exe.notExists())
|
if (!exe.toFile().exists())
|
||||||
fail("debug.build.compile.failed.no-file", exe)
|
fail("debug.build.compile.failed.no-file", exe)
|
||||||
else if (!exe.isExecutable())
|
else if (!exe.isExecutable())
|
||||||
fail("debug.build.compile.failed.non-exec-file", exe)
|
fail("debug.build.compile.failed.non-exec-file", exe)
|
||||||
|
|
|
@ -55,7 +55,6 @@ import java.net.URL
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.io.path.name
|
import kotlin.io.path.name
|
||||||
import kotlin.io.path.notExists
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
class ZigDebuggerToolchainService {
|
class ZigDebuggerToolchainService {
|
||||||
|
@ -80,7 +79,7 @@ class ZigDebuggerToolchainService {
|
||||||
val lldbPath = lldbPath()
|
val lldbPath = lldbPath()
|
||||||
val frameworkFile = lldbPath.resolve(frameworkPath)
|
val frameworkFile = lldbPath.resolve(frameworkPath)
|
||||||
val frontendFile = lldbPath.resolve(frontendPath)
|
val frontendFile = lldbPath.resolve(frontendPath)
|
||||||
if (frameworkFile.notExists() || frontendFile.notExists()) return DebuggerAvailability.NeedToDownload
|
if (!frameworkFile.toFile().exists() || !frontendFile.toFile().exists()) return DebuggerAvailability.NeedToDownload
|
||||||
|
|
||||||
val versions = loadDebuggerVersions(DebuggerKind.LLDB)
|
val versions = loadDebuggerVersions(DebuggerKind.LLDB)
|
||||||
val (lldbFrameworkUrl, lldbFrontendUrl) = lldbUrls() ?: return DebuggerAvailability.Unavailable
|
val (lldbFrameworkUrl, lldbFrontendUrl) = lldbUrls() ?: return DebuggerAvailability.Unavailable
|
||||||
|
@ -105,7 +104,7 @@ class ZigDebuggerToolchainService {
|
||||||
}
|
}
|
||||||
|
|
||||||
val gdbFile = gdbPath().resolve(gdbBinaryPath)
|
val gdbFile = gdbPath().resolve(gdbBinaryPath)
|
||||||
if (gdbFile.notExists()) return DebuggerAvailability.NeedToDownload
|
if (!gdbFile.toFile().exists()) return DebuggerAvailability.NeedToDownload
|
||||||
|
|
||||||
val versions = loadDebuggerVersions(DebuggerKind.GDB)
|
val versions = loadDebuggerVersions(DebuggerKind.GDB)
|
||||||
val gdbUrl = gdbUrl() ?: return DebuggerAvailability.Unavailable
|
val gdbUrl = gdbUrl() ?: return DebuggerAvailability.Unavailable
|
||||||
|
@ -123,7 +122,7 @@ class ZigDebuggerToolchainService {
|
||||||
val msvcBinaryPath = "vsdbg.exe"
|
val msvcBinaryPath = "vsdbg.exe"
|
||||||
|
|
||||||
val msvcFile = msvcPath().resolve(msvcBinaryPath)
|
val msvcFile = msvcPath().resolve(msvcBinaryPath)
|
||||||
if (msvcFile.notExists()) return DebuggerAvailability.NeedToDownload
|
if (!msvcFile.toFile().exists()) return DebuggerAvailability.NeedToDownload
|
||||||
|
|
||||||
val msvcUrl = msvcUrl() ?: return DebuggerAvailability.Binaries(MSVCBinaries(msvcFile))
|
val msvcUrl = msvcUrl() ?: return DebuggerAvailability.Binaries(MSVCBinaries(msvcFile))
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ data class Env(val env: Map<String, String>) {
|
||||||
val paths = path ?: return null
|
val paths = path ?: return null
|
||||||
for (dir in paths) {
|
for (dir in paths) {
|
||||||
val path = dir.toNioPathOrNull()?.absolute() ?: continue
|
val path = dir.toNioPathOrNull()?.absolute() ?: continue
|
||||||
if (path.notExists() || !path.isDirectory())
|
if (!path.toFile().exists() || !path.isDirectory())
|
||||||
continue
|
continue
|
||||||
val exePath = path.resolve(exeName).absolute()
|
val exePath = path.resolve(exeName).absolute()
|
||||||
if (!exePath.isRegularFile() || !exePath.isExecutable())
|
if (!exePath.isRegularFile() || !exePath.isExecutable())
|
||||||
|
|
|
@ -48,7 +48,6 @@ import org.eclipse.lsp4j.services.LanguageServer
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.isExecutable
|
import kotlin.io.path.isExecutable
|
||||||
import kotlin.io.path.isRegularFile
|
import kotlin.io.path.isRegularFile
|
||||||
import kotlin.io.path.notExists
|
|
||||||
import kotlin.io.path.pathString
|
import kotlin.io.path.pathString
|
||||||
|
|
||||||
class ZLSStreamConnectionProvider private constructor(private val project: Project, commandLine: GeneralCommandLine?) : OSProcessStreamConnectionProvider(commandLine) {
|
class ZLSStreamConnectionProvider private constructor(private val project: Project, commandLine: GeneralCommandLine?) : OSProcessStreamConnectionProvider(commandLine) {
|
||||||
|
@ -106,7 +105,7 @@ class ZLSStreamConnectionProvider private constructor(private val project: Proje
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (zlsPath.notExists()) {
|
if (!zlsPath.toFile().exists()) {
|
||||||
Notification(
|
Notification(
|
||||||
"zigbrains-lsp",
|
"zigbrains-lsp",
|
||||||
ZLSBundle.message("notification.message.zls-exe-not-exists.content", zlsPath),
|
ZLSBundle.message("notification.message.zls-exe-not-exists.content", zlsPath),
|
||||||
|
@ -125,7 +124,7 @@ class ZLSStreamConnectionProvider private constructor(private val project: Proje
|
||||||
val configPath: Path? = state.zlsConfigPath.let { configPath ->
|
val configPath: Path? = state.zlsConfigPath.let { configPath ->
|
||||||
if (configPath.isNotBlank()) {
|
if (configPath.isNotBlank()) {
|
||||||
configPath.toNioPathOrNull()?.let { nioPath ->
|
configPath.toNioPathOrNull()?.let { nioPath ->
|
||||||
if (nioPath.notExists()) {
|
if (!nioPath.toFile().exists()) {
|
||||||
Notification(
|
Notification(
|
||||||
"zigbrains-lsp",
|
"zigbrains-lsp",
|
||||||
ZLSBundle.message("notification.message.zls-config-not-exists.content", nioPath),
|
ZLSBundle.message("notification.message.zls-config-not-exists.content", nioPath),
|
||||||
|
|
|
@ -37,7 +37,6 @@ import java.util.concurrent.locks.ReentrantLock
|
||||||
import kotlin.concurrent.withLock
|
import kotlin.concurrent.withLock
|
||||||
import kotlin.io.path.isExecutable
|
import kotlin.io.path.isExecutable
|
||||||
import kotlin.io.path.isRegularFile
|
import kotlin.io.path.isRegularFile
|
||||||
import kotlin.io.path.notExists
|
|
||||||
|
|
||||||
@Service(Service.Level.PROJECT)
|
@Service(Service.Level.PROJECT)
|
||||||
@State(
|
@State(
|
||||||
|
@ -108,7 +107,7 @@ private suspend fun doValidate(project: Project, state: ZLSSettings): Boolean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (zlsPath.notExists()) {
|
if (!zlsPath.toFile().exists()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (!zlsPath.isRegularFile() || !zlsPath.isExecutable()) {
|
if (!zlsPath.isRegularFile() || !zlsPath.isExecutable()) {
|
||||||
|
|
|
@ -33,7 +33,6 @@ import com.intellij.openapi.vfs.toNioPathOrNull
|
||||||
import java.nio.file.InvalidPathException
|
import java.nio.file.InvalidPathException
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.isRegularFile
|
import kotlin.io.path.isRegularFile
|
||||||
import kotlin.io.path.notExists
|
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,9 +61,11 @@ class ZigSourceFileFilter(private val project: Project): Filter {
|
||||||
try {
|
try {
|
||||||
val pathStr = line.substring(i, end)
|
val pathStr = line.substring(i, end)
|
||||||
var path: Path = pathStr.toNioPathOrNull() ?: continue
|
var path: Path = pathStr.toNioPathOrNull() ?: continue
|
||||||
if ((path.notExists() || !path.isRegularFile()) && projectPath != null) {
|
var file = path.toFile()
|
||||||
|
if ((!file.exists() || !path.isRegularFile()) && projectPath != null) {
|
||||||
path = projectPath.resolve(pathStr)
|
path = projectPath.resolve(pathStr)
|
||||||
if (path.notExists() || !path.isRegularFile())
|
file = path.toFile()
|
||||||
|
if (!file.exists() || !path.isRegularFile())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
longest = path
|
longest = path
|
||||||
|
|
|
@ -51,8 +51,6 @@ import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import javax.swing.event.DocumentEvent
|
import javax.swing.event.DocumentEvent
|
||||||
import kotlin.io.path.exists
|
|
||||||
import kotlin.io.path.notExists
|
|
||||||
import kotlin.io.path.pathString
|
import kotlin.io.path.pathString
|
||||||
|
|
||||||
class ZigProjectSettingsPanel(private val project: Project?) : Disposable {
|
class ZigProjectSettingsPanel(private val project: Project?) : Disposable {
|
||||||
|
@ -160,7 +158,7 @@ class ZigProjectSettingsPanel(private val project: Project?) : Disposable {
|
||||||
delay(200)
|
delay(200)
|
||||||
val toolchain = pathToToolchain?.let { LocalZigToolchain(it) }
|
val toolchain = pathToToolchain?.let { LocalZigToolchain(it) }
|
||||||
val zig = toolchain?.zig
|
val zig = toolchain?.zig
|
||||||
if (zig?.path()?.exists() != true) {
|
if (zig?.path()?.toFile()?.exists() != true) {
|
||||||
toolchainVersion.text = ""
|
toolchainVersion.text = ""
|
||||||
|
|
||||||
if (!stdFieldOverride.isSelected) {
|
if (!stdFieldOverride.isSelected) {
|
||||||
|
|
|
@ -30,7 +30,6 @@ import com.intellij.notification.NotificationType
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.util.UserDataHolderBase
|
import com.intellij.openapi.util.UserDataHolderBase
|
||||||
import com.intellij.openapi.util.io.toNioPathOrNull
|
import com.intellij.openapi.util.io.toNioPathOrNull
|
||||||
import kotlin.io.path.notExists
|
|
||||||
import kotlin.io.path.pathString
|
import kotlin.io.path.pathString
|
||||||
|
|
||||||
class ToolchainZLSConfigProvider: SuspendingZLSConfigProvider {
|
class ToolchainZLSConfigProvider: SuspendingZLSConfigProvider {
|
||||||
|
@ -49,7 +48,7 @@ class ToolchainZLSConfigProvider: SuspendingZLSConfigProvider {
|
||||||
).notify(project)
|
).notify(project)
|
||||||
return previous
|
return previous
|
||||||
}
|
}
|
||||||
if (exe.notExists()) {
|
if (!exe.toFile().exists()) {
|
||||||
Notification(
|
Notification(
|
||||||
"zigbrains-lsp",
|
"zigbrains-lsp",
|
||||||
"Zig executable does not exiust: $exe",
|
"Zig executable does not exiust: $exe",
|
||||||
|
|
Loading…
Add table
Reference in a new issue