mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
IJPL-190497 Eel: Rename EelDescriptor.{platform,osFamily}
GitOrigin-RevId: 8f50c3d0adf900298ec54b3e89c539da9c806909
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0c5c2a29db
commit
230ec9b156
@@ -173,7 +173,7 @@ fun Path.asEelPath(): EelPath {
|
|||||||
val descriptor = service.tryGetEelDescriptor(this) ?: return EelPath.parse(toString(), LocalEelDescriptor)
|
val descriptor = service.tryGetEelDescriptor(this) ?: return EelPath.parse(toString(), LocalEelDescriptor)
|
||||||
val root = service.tryGetNioRoots(descriptor)?.firstOrNull { this.startsWith(it) } ?: error("unreachable") // since the descriptor is not null, the root should be as well
|
val root = service.tryGetNioRoots(descriptor)?.firstOrNull { this.startsWith(it) } ?: error("unreachable") // since the descriptor is not null, the root should be as well
|
||||||
val relative = root.relativize(this)
|
val relative = root.relativize(this)
|
||||||
if (descriptor.platform.isPosix) {
|
if (descriptor.osFamily.isPosix) {
|
||||||
return relative.fold(EelPath.parse("/", descriptor), { path, part -> path.resolve(part.toString()) })
|
return relative.fold(EelPath.parse("/", descriptor), { path, part -> path.resolve(part.toString()) })
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ data object LocalEelDescriptor : EelDescriptor {
|
|||||||
private val LOG = logger<LocalEelDescriptor>()
|
private val LOG = logger<LocalEelDescriptor>()
|
||||||
override val userReadableDescription: @NonNls String = "Local: ${System.getProperty("os.name")}"
|
override val userReadableDescription: @NonNls String = "Local: ${System.getProperty("os.name")}"
|
||||||
|
|
||||||
override val platform: EelOsFamily by lazy {
|
override val osFamily: EelOsFamily by lazy {
|
||||||
when {
|
when {
|
||||||
SystemInfo.isWindows -> EelOsFamily.Windows
|
SystemInfo.isWindows -> EelOsFamily.Windows
|
||||||
SystemInfo.isMac || SystemInfo.isLinux || SystemInfo.isFreeBSD -> EelOsFamily.Posix
|
SystemInfo.isMac || SystemInfo.isLinux || SystemInfo.isFreeBSD -> EelOsFamily.Posix
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ object EelPathUtils {
|
|||||||
}
|
}
|
||||||
val root = eelPath.root.toString().replace('\\', '/')
|
val root = eelPath.root.toString().replace('\\', '/')
|
||||||
// see sun.nio.fs.WindowsUriSupport#toUri(java.lang.String, boolean, boolean)
|
// see sun.nio.fs.WindowsUriSupport#toUri(java.lang.String, boolean, boolean)
|
||||||
val trailing = if (eelPath.descriptor.platform.isWindows) "/" else ""
|
val trailing = if (eelPath.descriptor.osFamily.isWindows) "/" else ""
|
||||||
return URI("file", null, trailing + root + eelPath.parts.joinToString("/"), null, null)
|
return URI("file", null, trailing + root + eelPath.parts.joinToString("/"), null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*:com.intellij.platform.eel.EelApi$Pid
|
*:com.intellij.platform.eel.EelApi$Pid
|
||||||
- a:getValue():J
|
- a:getValue():J
|
||||||
*:com.intellij.platform.eel.EelDescriptor
|
*:com.intellij.platform.eel.EelDescriptor
|
||||||
- *a:getPlatform():com.intellij.platform.eel.EelOsFamily
|
- *a:getOsFamily():com.intellij.platform.eel.EelOsFamily
|
||||||
- *a:getUserReadableDescription():java.lang.String
|
- *a:getUserReadableDescription():java.lang.String
|
||||||
- *a:toEelApi(kotlin.coroutines.Continuation):java.lang.Object
|
- *a:toEelApi(kotlin.coroutines.Continuation):java.lang.Object
|
||||||
*:com.intellij.platform.eel.EelError
|
*:com.intellij.platform.eel.EelError
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ interface EelDescriptor {
|
|||||||
@Deprecated("Use platform instead", ReplaceWith("platform"))
|
@Deprecated("Use platform instead", ReplaceWith("platform"))
|
||||||
@get:ApiStatus.Internal
|
@get:ApiStatus.Internal
|
||||||
val operatingSystem: OS
|
val operatingSystem: OS
|
||||||
get() = when (platform) {
|
get() = when (osFamily) {
|
||||||
EelOsFamily.Windows -> OS.WINDOWS
|
EelOsFamily.Windows -> OS.WINDOWS
|
||||||
EelOsFamily.Posix -> OS.UNIX
|
EelOsFamily.Posix -> OS.UNIX
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ interface EelDescriptor {
|
|||||||
* The platform of an environment corresponding to this [EelDescriptor].
|
* The platform of an environment corresponding to this [EelDescriptor].
|
||||||
*/
|
*/
|
||||||
@get:ApiStatus.Experimental
|
@get:ApiStatus.Experimental
|
||||||
val platform: EelOsFamily
|
val osFamily: EelOsFamily
|
||||||
|
|
||||||
@ApiStatus.Experimental
|
@ApiStatus.Experimental
|
||||||
suspend fun toEelApi(): EelApi
|
suspend fun toEelApi(): EelApi
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ fun EelExecWindowsApi.spawnProcess(exe: String, vararg args: String): EelExecWin
|
|||||||
*/
|
*/
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
suspend fun EelExecApi.getShell(): Pair<EelPath, String> {
|
suspend fun EelExecApi.getShell(): Pair<EelPath, String> {
|
||||||
val (shell, cmdArg) = when (this.descriptor.platform) {
|
val (shell, cmdArg) = when (this.descriptor.osFamily) {
|
||||||
EelOsFamily.Windows -> {
|
EelOsFamily.Windows -> {
|
||||||
val envs = fetchLoginShellEnvVariables()
|
val envs = fetchLoginShellEnvVariables()
|
||||||
Pair(envs["ComSpec"] ?: run {
|
Pair(envs["ComSpec"] ?: run {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ internal class ArrayListEelAbsolutePath private constructor(
|
|||||||
fun build(parts: List<String>, descriptor: EelDescriptor): EelPath {
|
fun build(parts: List<String>, descriptor: EelDescriptor): EelPath {
|
||||||
require(parts.isNotEmpty()) { "Can't build an absolute path from no path parts" }
|
require(parts.isNotEmpty()) { "Can't build an absolute path from no path parts" }
|
||||||
|
|
||||||
val windowsRoot = when (descriptor.platform) {
|
val windowsRoot = when (descriptor.osFamily) {
|
||||||
EelOsFamily.Windows -> findAbsoluteUncPath(parts.first(), descriptor) ?: findAbsoluteTraditionalDosPath(parts.first(), descriptor)
|
EelOsFamily.Windows -> findAbsoluteUncPath(parts.first(), descriptor) ?: findAbsoluteTraditionalDosPath(parts.first(), descriptor)
|
||||||
EelOsFamily.Posix -> null
|
EelOsFamily.Posix -> null
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ internal class ArrayListEelAbsolutePath private constructor(
|
|||||||
|
|
||||||
@Throws(EelPathException::class)
|
@Throws(EelPathException::class)
|
||||||
fun parseOrNull(raw: String, descriptor: EelDescriptor): ArrayListEelAbsolutePath? =
|
fun parseOrNull(raw: String, descriptor: EelDescriptor): ArrayListEelAbsolutePath? =
|
||||||
when (descriptor.platform) {
|
when (descriptor.osFamily) {
|
||||||
EelOsFamily.Windows -> findAbsoluteUncPath(raw, descriptor) ?: findAbsoluteTraditionalDosPath(raw, descriptor)
|
EelOsFamily.Windows -> findAbsoluteUncPath(raw, descriptor) ?: findAbsoluteTraditionalDosPath(raw, descriptor)
|
||||||
EelOsFamily.Posix -> findAbsoluteUnixPath(raw, descriptor)
|
EelOsFamily.Posix -> findAbsoluteUnixPath(raw, descriptor)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.intellij.platform.eel.EelOsFamily
|
|||||||
import org.jetbrains.annotations.ApiStatus
|
import org.jetbrains.annotations.ApiStatus
|
||||||
|
|
||||||
@get:ApiStatus.Internal
|
@get:ApiStatus.Internal
|
||||||
val EelPath.platform: EelOsFamily get() = descriptor.platform
|
val EelPath.platform: EelOsFamily get() = descriptor.osFamily
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for **absolute** paths on some environment.
|
* An interface for **absolute** paths on some environment.
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class EelAbsolutePathTest {
|
|||||||
path.endsWith(listOf("C:", "foo", "bar", "bax")) shouldBe false
|
path.endsWith(listOf("C:", "foo", "bar", "bax")) shouldBe false
|
||||||
}
|
}
|
||||||
|
|
||||||
class DummyEelDescriptor(override val platform: EelOsFamily) : EelDescriptor {
|
class DummyEelDescriptor(override val osFamily: EelOsFamily) : EelDescriptor {
|
||||||
override val userReadableDescription: String = "mock"
|
override val userReadableDescription: String = "mock"
|
||||||
|
|
||||||
override suspend fun toEelApi(): EelApi {
|
override suspend fun toEelApi(): EelApi {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class IjentNioFileSystem internal constructor(
|
|||||||
more.fold(EelPath.parse(first, ijentFs.descriptor)) { path, newPart -> path.resolve(newPart) }.toNioPath()
|
more.fold(EelPath.parse(first, ijentFs.descriptor)) { path, newPart -> path.resolve(newPart) }.toNioPath()
|
||||||
}
|
}
|
||||||
catch (_: EelPathException) {
|
catch (_: EelPathException) {
|
||||||
RelativeIjentNioPath(first.split(*ijentFs.descriptor.platform.directorySeparators) + more, this)
|
RelativeIjentNioPath(first.split(*ijentFs.descriptor.osFamily.directorySeparators) + more, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -581,7 +581,7 @@ class IjentNioFileSystemProvider : FileSystemProvider() {
|
|||||||
override fun readSymbolicLink(link: Path): Path {
|
override fun readSymbolicLink(link: Path): Path {
|
||||||
val fs = ensureAbsoluteIjentNioPath(link).nioFs
|
val fs = ensureAbsoluteIjentNioPath(link).nioFs
|
||||||
val absolutePath = link.eelPath
|
val absolutePath = link.eelPath
|
||||||
val os = fs.ijentFs.descriptor.platform
|
val os = fs.ijentFs.descriptor.osFamily
|
||||||
return fsBlocking {
|
return fsBlocking {
|
||||||
when (val ijentFs = fs.ijentFs) {
|
when (val ijentFs = fs.ijentFs) {
|
||||||
is IjentFileSystemPosixApi -> when (val type = ijentFs.stat(absolutePath).justResolve().getOrThrowFileSystemException().type) {
|
is IjentFileSystemPosixApi -> when (val type = ijentFs.stat(absolutePath).justResolve().getOrThrowFileSystemException().type) {
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ public final class JdkUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isCompatibleWithOs(@NotNull EelDescriptor descriptor) {
|
private static boolean isCompatibleWithOs(@NotNull EelDescriptor descriptor) {
|
||||||
EelOsFamily os = descriptor.getPlatform();
|
EelOsFamily os = descriptor.getOsFamily();
|
||||||
return switch (os) {
|
return switch (os) {
|
||||||
case Windows -> SystemInfo.isWindows;
|
case Windows -> SystemInfo.isWindows;
|
||||||
case Posix -> SystemInfo.isUnix;
|
case Posix -> SystemInfo.isUnix;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
if (contextPath != null) {
|
if (contextPath != null) {
|
||||||
var eelPath = JEelUtils.toEelPath(contextPath);
|
var eelPath = JEelUtils.toEelPath(contextPath);
|
||||||
if (eelPath != null) {
|
if (eelPath != null) {
|
||||||
return eelPath.getDescriptor().getPlatform() == EelOsFamily.Windows;
|
return eelPath.getDescriptor().getOsFamily() == EelOsFamily.Windows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SystemInfo.isWindows;
|
return SystemInfo.isWindows;
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class WslEelProvider(private val coroutineScope: CoroutineScope) : EelProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class WslEelDescriptor(val distribution: WSLDistribution) : EelDescriptor {
|
data class WslEelDescriptor(val distribution: WSLDistribution) : EelDescriptor {
|
||||||
override val platform: EelOsFamily = EelOsFamily.Posix
|
override val osFamily: EelOsFamily = EelOsFamily.Posix
|
||||||
|
|
||||||
override val userReadableDescription: @NonNls String = "WSL: ${distribution.presentableName}"
|
override val userReadableDescription: @NonNls String = "WSL: ${distribution.presentableName}"
|
||||||
|
|
||||||
|
|||||||
@@ -523,7 +523,7 @@ private class MockIjentApi(private val adapter: GeneralCommandLine, val rootUser
|
|||||||
override val descriptor: EelDescriptor
|
override val descriptor: EelDescriptor
|
||||||
get() = object : EelDescriptor {
|
get() = object : EelDescriptor {
|
||||||
override val userReadableDescription: @NonNls String = "mock"
|
override val userReadableDescription: @NonNls String = "mock"
|
||||||
override val platform: EelOsFamily = this@MockIjentApi.platform.osFamily
|
override val osFamily: EelOsFamily = this@MockIjentApi.platform.osFamily
|
||||||
|
|
||||||
override suspend fun toEelApi(): EelApi {
|
override suspend fun toEelApi(): EelApi {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.intellij.platform.eel.EelDescriptor
|
|||||||
import com.intellij.platform.eel.EelOsFamily
|
import com.intellij.platform.eel.EelOsFamily
|
||||||
import org.jetbrains.annotations.NonNls
|
import org.jetbrains.annotations.NonNls
|
||||||
|
|
||||||
internal class EelTestDescriptor(val id: String, override val platform: EelOsFamily, val apiProvider: () -> EelApi) : EelDescriptor {
|
internal class EelTestDescriptor(val id: String, override val osFamily: EelOsFamily, val apiProvider: () -> EelApi) : EelDescriptor {
|
||||||
|
|
||||||
override val userReadableDescription: @NonNls String = "mock $id"
|
override val userReadableDescription: @NonNls String = "mock $id"
|
||||||
|
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ class MavenShCommandLineState(val environment: ExecutionEnvironment, private val
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isWindows() =
|
private fun isWindows() =
|
||||||
when (myConfiguration.project.getEelDescriptor().platform) {
|
when (myConfiguration.project.getEelDescriptor().osFamily) {
|
||||||
EelOsFamily.Posix -> false
|
EelOsFamily.Posix -> false
|
||||||
EelOsFamily.Windows -> true
|
EelOsFamily.Windows -> true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ internal class MavenWrapperSupport {
|
|||||||
throw IllegalStateException(SyncBundle.message("zip.is.not.correct", zipFile.toAbsolutePath()))
|
throw IllegalStateException(SyncBundle.message("zip.is.not.correct", zipFile.toAbsolutePath()))
|
||||||
}
|
}
|
||||||
val mavenHome = dirs[0]
|
val mavenHome = dirs[0]
|
||||||
if (mavenHome.getEelDescriptor().platform.isPosix) {
|
if (mavenHome.getEelDescriptor().osFamily.isPosix) {
|
||||||
makeMavenBinRunnable(mavenHome)
|
makeMavenBinRunnable(mavenHome)
|
||||||
}
|
}
|
||||||
return mavenHome
|
return mavenHome
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ internal class ShDocumentationProvider(private val scope: CoroutineScope) : Docu
|
|||||||
val path = eel.exec.fetchLoginShellEnvVariables()["PATH"]
|
val path = eel.exec.fetchLoginShellEnvVariables()["PATH"]
|
||||||
|
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
for (dir in StringUtil.tokenize(path, eelDescriptor.platform.pathSeparator)) {
|
for (dir in StringUtil.tokenize(path, eelDescriptor.osFamily.pathSeparator)) {
|
||||||
val eelDir = runCatching { parse(dir, eelDescriptor) }.getOrNull() ?: continue
|
val eelDir = runCatching { parse(dir, eelDescriptor) }.getOrNull() ?: continue
|
||||||
val file = eelDir.resolve("info").asNioPath()
|
val file = eelDir.resolve("info").asNioPath()
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ final class ShRunConfigurationProfileState implements RunProfileState {
|
|||||||
@NotNull EelDescriptor eelDescriptor) {
|
@NotNull EelDescriptor eelDescriptor) {
|
||||||
systemDependentPath = convertPathUsingEel(systemDependentPath, eelDescriptor);
|
systemDependentPath = convertPathUsingEel(systemDependentPath, eelDescriptor);
|
||||||
|
|
||||||
return switch (eelDescriptor.getPlatform()) {
|
return switch (eelDescriptor.getOsFamily()) {
|
||||||
case Windows ->
|
case Windows ->
|
||||||
ShStringUtil.quote(systemDependentPath);
|
ShStringUtil.quote(systemDependentPath);
|
||||||
case Posix -> {
|
case Posix -> {
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class TerminalProjectOptionsProvider(val project: Project) : PersistentStateComp
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun findDefaultShellPath(eelDescriptor: EelDescriptor): String {
|
private suspend fun findDefaultShellPath(eelDescriptor: EelDescriptor): String {
|
||||||
if (eelDescriptor.platform.isWindows) {
|
if (eelDescriptor.osFamily.isWindows) {
|
||||||
return "powershell.exe"
|
return "powershell.exe"
|
||||||
}
|
}
|
||||||
val eelApi = eelDescriptor.toEelApi()
|
val eelApi = eelDescriptor.toEelApi()
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public final class LocalOptionsConfigurer {
|
|||||||
final var isWindows =
|
final var isWindows =
|
||||||
eelDescriptor == null
|
eelDescriptor == null
|
||||||
? SystemInfo.isWindows
|
? SystemInfo.isWindows
|
||||||
: switch (eelDescriptor.getPlatform()) {
|
: switch (eelDescriptor.getOsFamily()) {
|
||||||
case Posix -> false;
|
case Posix -> false;
|
||||||
case Windows -> true;
|
case Windows -> true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ suspend fun waitNoError(delay: Duration = 100.milliseconds, repeat: Int = 50, ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequiresBackgroundThread
|
@RequiresBackgroundThread
|
||||||
fun PythonHomePath.resolvePythonTool(name: String): Path = when (getEelDescriptor().platform) {
|
fun PythonHomePath.resolvePythonTool(name: String): Path = when (getEelDescriptor().osFamily) {
|
||||||
EelOsFamily.Windows -> resolve("Scripts/$name.exe")
|
EelOsFamily.Windows -> resolve("Scripts/$name.exe")
|
||||||
EelOsFamily.Posix-> resolve("bin/$name")
|
EelOsFamily.Posix-> resolve("bin/$name")
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ private class PathMatcher(private val parent: Path) : TypeSafeMatcher<Path>(Path
|
|||||||
|
|
||||||
private fun Path.expandWinPath(): Path =
|
private fun Path.expandWinPath(): Path =
|
||||||
try {
|
try {
|
||||||
when (getEelDescriptor().platform) {
|
when (getEelDescriptor().osFamily) {
|
||||||
// On Windows we change 8.3 problem (c:\users\William.~1 -> c:\users\William.Gates)
|
// On Windows we change 8.3 problem (c:\users\William.~1 -> c:\users\William.Gates)
|
||||||
// But you are encountered to disable 8.3 with `fsutil 8dot3name set 1`
|
// But you are encountered to disable 8.3 with `fsutil 8dot3name set 1`
|
||||||
EelOsFamily.Windows -> toRealPath()
|
EelOsFamily.Windows -> toRealPath()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import kotlin.io.path.name
|
|||||||
|
|
||||||
@RequiresBackgroundThread
|
@RequiresBackgroundThread
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
fun PythonBinary.resolvePythonHome(): PythonHomePath = when (getEelDescriptor().platform) {
|
fun PythonBinary.resolvePythonHome(): PythonHomePath = when (getEelDescriptor().osFamily) {
|
||||||
EelOsFamily.Windows -> parent.takeIf { it.name.lowercase() != "scripts" } ?: parent.parent
|
EelOsFamily.Windows -> parent.takeIf { it.name.lowercase() != "scripts" } ?: parent.parent
|
||||||
EelOsFamily.Posix -> parent.takeIf { it.name != "bin" } ?: parent.parent
|
EelOsFamily.Posix -> parent.takeIf { it.name != "bin" } ?: parent.parent
|
||||||
}
|
}
|
||||||
@@ -19,5 +19,5 @@ fun PythonBinary.resolvePythonHome(): PythonHomePath = when (getEelDescriptor().
|
|||||||
@RequiresBackgroundThread
|
@RequiresBackgroundThread
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
fun PythonHomePath.resolvePythonBinary(): PythonBinary? {
|
fun PythonHomePath.resolvePythonBinary(): PythonBinary? {
|
||||||
return VirtualEnvReader(isWindows = getEelDescriptor().platform.isWindows).findPythonInPythonRoot(this)
|
return VirtualEnvReader(isWindows = getEelDescriptor().osFamily.isWindows).findPythonInPythonRoot(this)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user