mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
Eel API: rename methods in EelPath: foobarE -> foobar
IJ-CR-147046 (cherry picked from commit 38d4ed91bb138a96c999f140c9671b96dac081a0) GitOrigin-RevId: 26a58200d6f669137019495176576661bf1c01d2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
650e3a7632
commit
994d8c338c
@@ -7,12 +7,11 @@ import com.intellij.platform.eel.EelUserPosixInfo
|
|||||||
import com.intellij.platform.eel.EelUserWindowsInfo
|
import com.intellij.platform.eel.EelUserWindowsInfo
|
||||||
import com.intellij.platform.eel.fs.EelFileSystemApi.StatError
|
import com.intellij.platform.eel.fs.EelFileSystemApi.StatError
|
||||||
import com.intellij.platform.eel.path.EelPath
|
import com.intellij.platform.eel.path.EelPath
|
||||||
import com.intellij.platform.eel.path.EelPathError
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import kotlin.Throws
|
import kotlin.Throws
|
||||||
|
|
||||||
fun EelFileSystemApi.getPathE(string: String, vararg other: String): EelPath.Absolute {
|
fun EelFileSystemApi.getPath(string: String, vararg other: String): EelPath.Absolute {
|
||||||
return EelPath.Absolute.buildE(listOf(string, *other), when (this) {
|
return EelPath.Absolute.build(listOf(string, *other), when (this) {
|
||||||
is EelFileSystemPosixApi -> EelPath.Absolute.OS.UNIX
|
is EelFileSystemPosixApi -> EelPath.Absolute.OS.UNIX
|
||||||
is EelFileSystemWindowsApi -> EelPath.Absolute.OS.WINDOWS
|
is EelFileSystemWindowsApi -> EelPath.Absolute.OS.WINDOWS
|
||||||
else -> throw UnsupportedOperationException("Unsupported OS: ${this::class.java}")
|
else -> throw UnsupportedOperationException("Unsupported OS: ${this::class.java}")
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package com.intellij.platform.eel.path
|
package com.intellij.platform.eel.path
|
||||||
|
|
||||||
import com.intellij.platform.eel.EelResult
|
import kotlin.Throws
|
||||||
|
|
||||||
|
|
||||||
internal class ArrayListEelAbsolutePath private constructor(
|
internal class ArrayListEelAbsolutePath private constructor(
|
||||||
private val _root: Root,
|
private val _root: Root,
|
||||||
@@ -33,7 +34,7 @@ internal class ArrayListEelAbsolutePath private constructor(
|
|||||||
root.fileName == other.root.fileName &&
|
root.fileName == other.root.fileName &&
|
||||||
(0..<other.nameCount).all { getName(it) == other.getName(it) }
|
(0..<other.nameCount).all { getName(it) == other.getName(it) }
|
||||||
|
|
||||||
override fun normalizeE(): EelPath.Absolute {
|
override fun normalize(): EelPath.Absolute {
|
||||||
val result = mutableListOf<String>()
|
val result = mutableListOf<String>()
|
||||||
for (part in parts) {
|
for (part in parts) {
|
||||||
when (part) {
|
when (part) {
|
||||||
@@ -56,7 +57,7 @@ internal class ArrayListEelAbsolutePath private constructor(
|
|||||||
return ArrayListEelAbsolutePath(_root, result)
|
return ArrayListEelAbsolutePath(_root, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resolveE(other: EelPath.Relative): EelPath.Absolute {
|
override fun resolve(other: EelPath.Relative): EelPath.Absolute {
|
||||||
val result = parts.toMutableList()
|
val result = parts.toMutableList()
|
||||||
for (index in 0..<other.nameCount) {
|
for (index in 0..<other.nameCount) {
|
||||||
val name = other.getName(index).fileName
|
val name = other.getName(index).fileName
|
||||||
@@ -69,7 +70,7 @@ internal class ArrayListEelAbsolutePath private constructor(
|
|||||||
return ArrayListEelAbsolutePath(_root, result)
|
return ArrayListEelAbsolutePath(_root, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getChildE(name: String): EelPath.Absolute {
|
override fun getChild(name: String): EelPath.Absolute {
|
||||||
val error = checkFileName(name)
|
val error = checkFileName(name)
|
||||||
return if (error == null)
|
return if (error == null)
|
||||||
ArrayListEelAbsolutePath(_root, parts + name)
|
ArrayListEelAbsolutePath(_root, parts + name)
|
||||||
@@ -108,7 +109,7 @@ internal class ArrayListEelAbsolutePath private constructor(
|
|||||||
if (parts.isEmpty()) return EelPath.Relative.EMPTY
|
if (parts.isEmpty()) return EelPath.Relative.EMPTY
|
||||||
|
|
||||||
require(index in parts.indices) { "$index !in ${parts.indices}" }
|
require(index in parts.indices) { "$index !in ${parts.indices}" }
|
||||||
return EelPath.Relative.buildE(parts[index])
|
return EelPath.Relative.build(parts[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun endsWith(other: EelPath.Relative): Boolean {
|
override fun endsWith(other: EelPath.Relative): Boolean {
|
||||||
@@ -134,7 +135,7 @@ internal class ArrayListEelAbsolutePath private constructor(
|
|||||||
return nameCount - other.nameCount
|
return nameCount - other.nameCount
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun relativizeE(other: EelPath.Absolute): EelPath.Relative {
|
override fun relativize(other: EelPath.Absolute): EelPath.Relative {
|
||||||
if (root != other.root) {
|
if (root != other.root) {
|
||||||
throw EelPathException(other.root.toString(), "The other path has a different root")
|
throw EelPathException(other.root.toString(), "The other path has a different root")
|
||||||
}
|
}
|
||||||
@@ -155,7 +156,7 @@ internal class ArrayListEelAbsolutePath private constructor(
|
|||||||
result += other.getName(index).fileName
|
result += other.getName(index).fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
return EelPath.Relative.buildE(result)
|
return EelPath.Relative.build(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean =
|
override fun equals(other: Any?): Boolean =
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package com.intellij.platform.eel.path
|
package com.intellij.platform.eel.path
|
||||||
|
|
||||||
|
import kotlin.Throws
|
||||||
|
|
||||||
|
|
||||||
internal class ArrayListEelRelativePath private constructor(
|
internal class ArrayListEelRelativePath private constructor(
|
||||||
private val parts: List<String>,
|
private val parts: List<String>,
|
||||||
) : EelPath.Relative {
|
) : EelPath.Relative {
|
||||||
@@ -24,7 +27,7 @@ internal class ArrayListEelRelativePath private constructor(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resolveE(other: EelPath.Relative): ArrayListEelRelativePath {
|
override fun resolve(other: EelPath.Relative): ArrayListEelRelativePath {
|
||||||
val result = mutableListOf<String>()
|
val result = mutableListOf<String>()
|
||||||
result += parts
|
result += parts
|
||||||
if (other != EMPTY) {
|
if (other != EMPTY) {
|
||||||
@@ -36,7 +39,7 @@ internal class ArrayListEelRelativePath private constructor(
|
|||||||
return ArrayListEelRelativePath(result)
|
return ArrayListEelRelativePath(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getChildE(name: String): ArrayListEelRelativePath =
|
override fun getChild(name: String): ArrayListEelRelativePath =
|
||||||
when {
|
when {
|
||||||
name.isEmpty() -> throw EelPathException(name, "Empty child name is not allowed")
|
name.isEmpty() -> throw EelPathException(name, "Empty child name is not allowed")
|
||||||
"/" in name -> throw EelPathException(name, "Invalid symbol in child name: /")
|
"/" in name -> throw EelPathException(name, "Invalid symbol in child name: /")
|
||||||
@@ -121,7 +124,7 @@ internal class ArrayListEelRelativePath private constructor(
|
|||||||
// Not optimal, but DRY.
|
// Not optimal, but DRY.
|
||||||
var result = ArrayListEelRelativePath(listOf())
|
var result = ArrayListEelRelativePath(listOf())
|
||||||
for (part in parts) {
|
for (part in parts) {
|
||||||
result = result.getChildE(part)
|
result = result.getChild(part)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.intellij.platform.eel.EelResult
|
|||||||
import com.intellij.platform.eel.getOrThrow
|
import com.intellij.platform.eel.getOrThrow
|
||||||
import com.intellij.platform.eel.path.EelPath.Absolute.OS
|
import com.intellij.platform.eel.path.EelPath.Absolute.OS
|
||||||
import java.nio.file.InvalidPathException
|
import java.nio.file.InvalidPathException
|
||||||
|
import kotlin.Throws
|
||||||
|
|
||||||
interface EelPathError {
|
interface EelPathError {
|
||||||
val raw: String
|
val raw: String
|
||||||
@@ -26,9 +27,9 @@ sealed interface EelPath {
|
|||||||
companion object {
|
companion object {
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun parseE(raw: String, os: OS?): EelPath =
|
fun parse(raw: String, os: OS?): EelPath =
|
||||||
ArrayListEelAbsolutePath.parseOrNull(raw, os)
|
ArrayListEelAbsolutePath.parseOrNull(raw, os)
|
||||||
?: Relative.parseE(raw)
|
?: Relative.parse(raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
val fileName: String
|
val fileName: String
|
||||||
@@ -101,7 +102,7 @@ sealed interface EelPath {
|
|||||||
* It should fail in cases like Absolute("/").resolve(Relative("..")).
|
* It should fail in cases like Absolute("/").resolve(Relative("..")).
|
||||||
*/
|
*/
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun resolveE(other: Relative): EelPath
|
fun resolve(other: Relative): EelPath
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ```kotlin
|
* ```kotlin
|
||||||
@@ -114,7 +115,7 @@ sealed interface EelPath {
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun getChildE(name: String): EelPath
|
fun getChild(name: String): EelPath
|
||||||
|
|
||||||
override fun toString(): String
|
override fun toString(): String
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ sealed interface EelPath {
|
|||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun parseE(raw: String): Relative =
|
fun parse(raw: String): Relative =
|
||||||
ArrayListEelRelativePath.parse(raw)
|
ArrayListEelRelativePath.parse(raw)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,15 +131,15 @@ sealed interface EelPath {
|
|||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun buildE(vararg parts: String): Relative =
|
fun build(vararg parts: String): Relative =
|
||||||
buildE(listOf(*parts))
|
build(listOf(*parts))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parts of the path must not contain / or \.
|
* The parts of the path must not contain / or \.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun buildE(parts: List<String>): Relative =
|
fun build(parts: List<String>): Relative =
|
||||||
ArrayListEelRelativePath.build(parts)
|
ArrayListEelRelativePath.build(parts)
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
@@ -151,10 +152,10 @@ sealed interface EelPath {
|
|||||||
fun startsWith(other: Relative): Boolean
|
fun startsWith(other: Relative): Boolean
|
||||||
|
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
override fun resolveE(other: Relative): Relative
|
override fun resolve(other: Relative): Relative
|
||||||
|
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
override fun getChildE(name: String): Relative
|
override fun getChild(name: String): Relative
|
||||||
|
|
||||||
override fun compareTo(other: Relative): Int
|
override fun compareTo(other: Relative): Int
|
||||||
|
|
||||||
@@ -182,18 +183,18 @@ sealed interface EelPath {
|
|||||||
interface Absolute : EelPath, Comparable<Absolute> {
|
interface Absolute : EelPath, Comparable<Absolute> {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun parseE(raw: String, os: OS?): Absolute =
|
fun parse(raw: String, os: OS?): Absolute =
|
||||||
ArrayListEelAbsolutePath.parseOrNull(raw, os)
|
ArrayListEelAbsolutePath.parseOrNull(raw, os)
|
||||||
?: throw EelPathException(raw, "Not an absolute path")
|
?: throw EelPathException(raw, "Not an absolute path")
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun buildE(vararg parts: String): Absolute =
|
fun build(vararg parts: String): Absolute =
|
||||||
buildE(listOf(*parts), null)
|
build(listOf(*parts), null)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun buildE(parts: List<String>, os: OS?): Absolute =
|
fun build(parts: List<String>, os: OS?): Absolute =
|
||||||
ArrayListEelAbsolutePath.build(parts, os)
|
ArrayListEelAbsolutePath.build(parts, os)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,11 +214,11 @@ sealed interface EelPath {
|
|||||||
|
|
||||||
/** See [java.nio.file.Path.normalize] */
|
/** See [java.nio.file.Path.normalize] */
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun normalizeE(): Absolute
|
fun normalize(): Absolute
|
||||||
|
|
||||||
/** See [java.nio.file.Path.resolve] */
|
/** See [java.nio.file.Path.resolve] */
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
override fun resolveE(other: Relative): Absolute
|
override fun resolve(other: Relative): Absolute
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See [java.nio.file.Path.relativize].
|
* See [java.nio.file.Path.relativize].
|
||||||
@@ -228,10 +229,10 @@ sealed interface EelPath {
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun relativizeE(other: Absolute): Relative
|
fun relativize(other: Absolute): Relative
|
||||||
|
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
override fun getChildE(name: String): Absolute
|
override fun getChild(name: String): Absolute
|
||||||
|
|
||||||
fun scan(): Sequence<Absolute>
|
fun scan(): Sequence<Absolute>
|
||||||
|
|
||||||
@@ -243,7 +244,7 @@ sealed interface EelPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun EelPath.div(part: String): EelPath = resolveE(EelPath.Relative.parseE(part))
|
operator fun EelPath.div(part: String): EelPath = resolve(EelPath.Relative.parse(part))
|
||||||
|
|
||||||
@Throws(InvalidPathException::class)
|
@Throws(InvalidPathException::class)
|
||||||
fun <P : EelPath, E : EelPathError> EelResult<P, E>.getOrThrow(): P = getOrThrow { throw InvalidPathException(it.raw, it.reason) }
|
fun <P : EelPath, E : EelPathError> EelResult<P, E>.getOrThrow(): P = getOrThrow { throw InvalidPathException(it.raw, it.reason) }
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class EelAbsolutePathTest {
|
|||||||
|
|
||||||
for (rawPath in (unixPaths + windowsPaths)) {
|
for (rawPath in (unixPaths + windowsPaths)) {
|
||||||
add(dynamicTest(rawPath) {
|
add(dynamicTest(rawPath) {
|
||||||
val eelPath = EelPath.Absolute.parseE(rawPath, null)
|
val eelPath = EelPath.Absolute.parse(rawPath, null)
|
||||||
eelPath.toString() shouldBe rawPath
|
eelPath.toString() shouldBe rawPath
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class EelRelativePathTest {
|
|||||||
abc/./def/../ghi, abc/ghi
|
abc/./def/../ghi, abc/ghi
|
||||||
./abc/def/../ghi, abc/ghi """)
|
./abc/def/../ghi, abc/ghi """)
|
||||||
fun normalize(source: String?, expected: String?) {
|
fun normalize(source: String?, expected: String?) {
|
||||||
val sourcePath = EelPath.Relative.parseE(source ?: "")
|
val sourcePath = EelPath.Relative.parse(source ?: "")
|
||||||
val expectedPath = EelPath.Relative.parseE(expected ?: "")
|
val expectedPath = EelPath.Relative.parse(expected ?: "")
|
||||||
sourcePath.normalize() should be(expectedPath)
|
sourcePath.normalize() should be(expectedPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,9 +39,9 @@ class EelRelativePathTest {
|
|||||||
inner class getChild {
|
inner class getChild {
|
||||||
@Test
|
@Test
|
||||||
fun positive() {
|
fun positive() {
|
||||||
val empty = EelPath.Relative.buildE()
|
val empty = EelPath.Relative.build()
|
||||||
empty.getChildE("a") should be(EelPath.Relative.buildE("a"))
|
empty.getChild("a") should be(EelPath.Relative.build("a"))
|
||||||
empty.getChildE("a").getChildE("bc") should be(EelPath.Relative.buildE("a", "bc"))
|
empty.getChild("a").getChild("bc") should be(EelPath.Relative.build("a", "bc"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,11 +49,11 @@ class EelRelativePathTest {
|
|||||||
inner class resolve {
|
inner class resolve {
|
||||||
@Test
|
@Test
|
||||||
fun `parent directory should persist`() {
|
fun `parent directory should persist`() {
|
||||||
val path = EelPath.Relative.parseE("abc/..")
|
val path = EelPath.Relative.parse("abc/..")
|
||||||
val targetPath = EelPath.Relative.parseE("def")
|
val targetPath = EelPath.Relative.parse("def")
|
||||||
|
|
||||||
withClue("IjentPath.Relative.resolve must not normalize paths") {
|
withClue("IjentPath.Relative.resolve must not normalize paths") {
|
||||||
EelPath.Relative.parseE("abc/../def") should be(path.resolveE(targetPath))
|
EelPath.Relative.parse("abc/../def") should be(path.resolve(targetPath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,15 +63,15 @@ class EelRelativePathTest {
|
|||||||
@Test
|
@Test
|
||||||
fun positive() {
|
fun positive() {
|
||||||
val raw = "a/b/c"
|
val raw = "a/b/c"
|
||||||
val path = EelPath.Relative.parseE(raw)
|
val path = EelPath.Relative.parse(raw)
|
||||||
val expected = EelPath.Relative.parseE("b")
|
val expected = EelPath.Relative.parse("b")
|
||||||
expected should be(path.getName(1))
|
expected should be(path.getName(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `out of bound`() {
|
fun `out of bound`() {
|
||||||
val raw = "a/b/c"
|
val raw = "a/b/c"
|
||||||
val path = EelPath.Relative.parseE(raw)
|
val path = EelPath.Relative.parse(raw)
|
||||||
|
|
||||||
shouldThrowAny {
|
shouldThrowAny {
|
||||||
path.getName(10)
|
path.getName(10)
|
||||||
@@ -84,14 +84,14 @@ class EelRelativePathTest {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(strings = ["a/b", "a/b/c"])
|
@ValueSource(strings = ["a/b", "a/b/c"])
|
||||||
fun `is not null`(raw: String) {
|
fun `is not null`(raw: String) {
|
||||||
val path = EelPath.Relative.parseE(raw)
|
val path = EelPath.Relative.parse(raw)
|
||||||
path.parent shouldNot be(null)
|
path.parent shouldNot be(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(strings = ["", "a"])
|
@ValueSource(strings = ["", "a"])
|
||||||
fun `is null`(raw: String) {
|
fun `is null`(raw: String) {
|
||||||
val path = EelPath.Relative.parseE(raw)
|
val path = EelPath.Relative.parse(raw)
|
||||||
path.parent should be(null)
|
path.parent should be(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.intellij.openapi.util.SystemInfo
|
|||||||
import com.intellij.platform.eel.*
|
import com.intellij.platform.eel.*
|
||||||
import com.intellij.platform.eel.fs.EelFileSystemPosixApi
|
import com.intellij.platform.eel.fs.EelFileSystemPosixApi
|
||||||
import com.intellij.platform.eel.fs.EelFileSystemWindowsApi
|
import com.intellij.platform.eel.fs.EelFileSystemWindowsApi
|
||||||
import com.intellij.platform.eel.fs.getPathE
|
import com.intellij.platform.eel.fs.getPath
|
||||||
import com.intellij.platform.eel.path.EelPath
|
import com.intellij.platform.eel.path.EelPath
|
||||||
import com.intellij.platform.eel.provider.EelUserPosixInfoImpl
|
import com.intellij.platform.eel.provider.EelUserPosixInfoImpl
|
||||||
import com.intellij.platform.eel.provider.EelUserWindowsInfoImpl
|
import com.intellij.platform.eel.provider.EelUserWindowsInfoImpl
|
||||||
@@ -13,7 +13,7 @@ import java.nio.file.Path
|
|||||||
|
|
||||||
internal class LocalEelPathMapper(private val eelApi: EelApi) : EelPathMapper {
|
internal class LocalEelPathMapper(private val eelApi: EelApi) : EelPathMapper {
|
||||||
override fun getOriginalPath(path: Path): EelPath.Absolute {
|
override fun getOriginalPath(path: Path): EelPath.Absolute {
|
||||||
return eelApi.fs.getPathE(path.toString())
|
return eelApi.fs.getPath(path.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toNioPath(path: EelPath.Absolute): Path {
|
override fun toNioPath(path: EelPath.Absolute): Path {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.intellij.platform.eel.provider.utils
|
|||||||
|
|
||||||
import com.intellij.execution.process.ProcessOutput
|
import com.intellij.execution.process.ProcessOutput
|
||||||
import com.intellij.platform.eel.*
|
import com.intellij.platform.eel.*
|
||||||
import com.intellij.platform.eel.fs.getPathE
|
import com.intellij.platform.eel.fs.getPath
|
||||||
import com.intellij.platform.eel.path.EelPath
|
import com.intellij.platform.eel.path.EelPath
|
||||||
import com.intellij.util.io.computeDetached
|
import com.intellij.util.io.computeDetached
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
@@ -84,6 +84,6 @@ suspend fun EelApi.where(exe: String): EelPath.Absolute? {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return fs.getPathE(result.stdout)
|
return fs.getPath(result.stdout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,8 +70,8 @@ class IjentNioFileSystem internal constructor(
|
|||||||
is IjentFileSystemPosixApi -> EelPath.Absolute.OS.UNIX
|
is IjentFileSystemPosixApi -> EelPath.Absolute.OS.UNIX
|
||||||
is IjentFileSystemWindowsApi -> EelPath.Absolute.OS.WINDOWS
|
is IjentFileSystemWindowsApi -> EelPath.Absolute.OS.WINDOWS
|
||||||
}
|
}
|
||||||
return EelPath.parseE(first, os)
|
return EelPath.parse(first, os)
|
||||||
.resolveE(EelPath.Relative.buildE(*more))
|
.resolve(EelPath.Relative.build(*more))
|
||||||
.toNioPath()
|
.toNioPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ class IjentNioFileSystemProvider : FileSystemProvider() {
|
|||||||
.getOrThrowFileSystemException()
|
.getOrThrowFileSystemException()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map { (childName, childStat) ->
|
.map { (childName, childStat) ->
|
||||||
val childIjentPath = dir.eelPath.getChildE(childName)
|
val childIjentPath = dir.eelPath.getChild(childName)
|
||||||
val childAttrs = when (childStat) {
|
val childAttrs = when (childStat) {
|
||||||
is EelPosixFileInfo -> IjentNioPosixFileAttributes(childStat)
|
is EelPosixFileInfo -> IjentNioPosixFileAttributes(childStat)
|
||||||
is EelWindowsFileInfo -> TODO()
|
is EelWindowsFileInfo -> TODO()
|
||||||
@@ -219,7 +219,7 @@ class IjentNioFileSystemProvider : FileSystemProvider() {
|
|||||||
.getOrThrowFileSystemException()
|
.getOrThrowFileSystemException()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.map { childName ->
|
.map { childName ->
|
||||||
val childIjentPath = dir.eelPath.getChildE(childName)
|
val childIjentPath = dir.eelPath.getChild(childName)
|
||||||
IjentNioPath(childIjentPath, nioFs, null)
|
IjentNioPath(childIjentPath, nioFs, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.intellij.util.text.nullize
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.file.*
|
import java.nio.file.*
|
||||||
|
import kotlin.Throws
|
||||||
import kotlin.coroutines.Continuation
|
import kotlin.coroutines.Continuation
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlin.coroutines.startCoroutine
|
import kotlin.coroutines.startCoroutine
|
||||||
@@ -54,7 +55,7 @@ internal fun Path.toEelPath(): EelPath =
|
|||||||
|
|
||||||
isAbsolute -> throw InvalidPathException(toString(), "This path can't be converted to IjentPath")
|
isAbsolute -> throw InvalidPathException(toString(), "This path can't be converted to IjentPath")
|
||||||
|
|
||||||
else -> EelPath.Relative.parseE(toString())
|
else -> EelPath.Relative.parse(toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun <T> fsBlocking(body: suspend () -> T): T = invokeSuspending(body)
|
internal fun <T> fsBlocking(body: suspend () -> T): T = invokeSuspending(body)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class IjentNioPath internal constructor(
|
|||||||
|
|
||||||
override fun getFileName(): IjentNioPath? =
|
override fun getFileName(): IjentNioPath? =
|
||||||
EelPath.Relative
|
EelPath.Relative
|
||||||
.parseE(eelPath.fileName)
|
.parse(eelPath.fileName)
|
||||||
.toNioPath()
|
.toNioPath()
|
||||||
.takeIf { it.nameCount > 0 }
|
.takeIf { it.nameCount > 0 }
|
||||||
|
|
||||||
@@ -83,20 +83,20 @@ class IjentNioPath internal constructor(
|
|||||||
|
|
||||||
override fun normalize(): IjentNioPath =
|
override fun normalize(): IjentNioPath =
|
||||||
when (eelPath) {
|
when (eelPath) {
|
||||||
is EelPath.Absolute -> eelPath.normalizeE().toNioPath()
|
is EelPath.Absolute -> eelPath.normalize().toNioPath()
|
||||||
is EelPath.Relative -> eelPath.normalize().toNioPath()
|
is EelPath.Relative -> eelPath.normalize().toNioPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resolve(other: Path): IjentNioPath =
|
override fun resolve(other: Path): IjentNioPath =
|
||||||
when (val otherIjentPath = other.toEelPath()) {
|
when (val otherIjentPath = other.toEelPath()) {
|
||||||
is EelPath.Absolute -> otherIjentPath.toNioPath() // TODO is it the desired behaviour?
|
is EelPath.Absolute -> otherIjentPath.toNioPath() // TODO is it the desired behaviour?
|
||||||
is EelPath.Relative -> eelPath.resolveE(otherIjentPath).toNioPath()
|
is EelPath.Relative -> eelPath.resolve(otherIjentPath).toNioPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun relativize(other: Path): IjentNioPath =
|
override fun relativize(other: Path): IjentNioPath =
|
||||||
when (val otherIjentPath = other.toEelPath()) {
|
when (val otherIjentPath = other.toEelPath()) {
|
||||||
is EelPath.Absolute -> when (eelPath) {
|
is EelPath.Absolute -> when (eelPath) {
|
||||||
is EelPath.Absolute -> eelPath.relativizeE(otherIjentPath).toNioPath()
|
is EelPath.Absolute -> eelPath.relativize(otherIjentPath).toNioPath()
|
||||||
is EelPath.Relative -> throw InvalidPathException("$this.relativize($other)",
|
is EelPath.Relative -> throw InvalidPathException("$this.relativize($other)",
|
||||||
"Can't relativize these paths")
|
"Can't relativize these paths")
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ class IjentNioPath internal constructor(
|
|||||||
override fun toRealPath(vararg options: LinkOption): IjentNioPath =
|
override fun toRealPath(vararg options: LinkOption): IjentNioPath =
|
||||||
when (eelPath) {
|
when (eelPath) {
|
||||||
is EelPath.Absolute ->
|
is EelPath.Absolute ->
|
||||||
eelPath.normalizeE()
|
eelPath.normalize()
|
||||||
.let { normalizedPath ->
|
.let { normalizedPath ->
|
||||||
if (LinkOption.NOFOLLOW_LINKS in options)
|
if (LinkOption.NOFOLLOW_LINKS in options)
|
||||||
normalizedPath
|
normalizedPath
|
||||||
|
|||||||
@@ -7,12 +7,7 @@ import com.intellij.platform.core.nio.fs.MultiRoutingFsPath
|
|||||||
import com.intellij.platform.eel.*
|
import com.intellij.platform.eel.*
|
||||||
import com.intellij.platform.eel.EelExecApi.ExecuteProcessError
|
import com.intellij.platform.eel.EelExecApi.ExecuteProcessError
|
||||||
import com.intellij.platform.eel.fs.getPath
|
import com.intellij.platform.eel.fs.getPath
|
||||||
import com.intellij.platform.eel.fs.EelFileSystemApi
|
|
||||||
import com.intellij.platform.eel.fs.getPathE
|
|
||||||
import com.intellij.platform.eel.path.EelPath
|
import com.intellij.platform.eel.path.EelPath
|
||||||
import com.intellij.platform.eel.path.getOrThrow
|
|
||||||
import com.intellij.util.awaitCancellationAndInvoke
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import org.jetbrains.annotations.ApiStatus.Internal
|
import org.jetbrains.annotations.ApiStatus.Internal
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.io.path.pathString
|
import kotlin.io.path.pathString
|
||||||
@@ -55,7 +50,7 @@ private class EelEphemeralRootAwareMapper(
|
|||||||
private val eelApi: EelApiBase,
|
private val eelApi: EelApiBase,
|
||||||
) : EelPathMapper {
|
) : EelPathMapper {
|
||||||
override fun getOriginalPath(path: Path): EelPath.Absolute? {
|
override fun getOriginalPath(path: Path): EelPath.Absolute? {
|
||||||
return path.toEphemeralRootAwarePath()?.originalPath?.let { eelApi.fs.getPathE(it.toString()) }
|
return path.toEphemeralRootAwarePath()?.originalPath?.let { eelApi.fs.getPath(it.toString()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toNioPath(path: EelPath.Absolute): Path {
|
override fun toNioPath(path: EelPath.Absolute): Path {
|
||||||
|
|||||||
Reference in New Issue
Block a user