IJPL-190497 Eel: Rename EelDescriptor.{platform,osFamily}

GitOrigin-RevId: 8f50c3d0adf900298ec54b3e89c539da9c806909
This commit is contained in:
Vladimir Lagunov
2025-06-13 23:28:32 +02:00
committed by intellij-monorepo-bot
parent 0c5c2a29db
commit 230ec9b156
24 changed files with 28 additions and 28 deletions

View File

@@ -173,7 +173,7 @@ fun Path.asEelPath(): EelPath {
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 relative = root.relativize(this)
if (descriptor.platform.isPosix) {
if (descriptor.osFamily.isPosix) {
return relative.fold(EelPath.parse("/", descriptor), { path, part -> path.resolve(part.toString()) })
}
else {

View File

@@ -98,7 +98,7 @@ data object LocalEelDescriptor : EelDescriptor {
private val LOG = logger<LocalEelDescriptor>()
override val userReadableDescription: @NonNls String = "Local: ${System.getProperty("os.name")}"
override val platform: EelOsFamily by lazy {
override val osFamily: EelOsFamily by lazy {
when {
SystemInfo.isWindows -> EelOsFamily.Windows
SystemInfo.isMac || SystemInfo.isLinux || SystemInfo.isFreeBSD -> EelOsFamily.Posix

View File

@@ -131,7 +131,7 @@ object EelPathUtils {
}
val root = eelPath.root.toString().replace('\\', '/')
// 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)
}

View File

@@ -7,7 +7,7 @@
*:com.intellij.platform.eel.EelApi$Pid
- a:getValue():J
*: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:toEelApi(kotlin.coroutines.Continuation):java.lang.Object
*:com.intellij.platform.eel.EelError

View File

@@ -54,7 +54,7 @@ interface EelDescriptor {
@Deprecated("Use platform instead", ReplaceWith("platform"))
@get:ApiStatus.Internal
val operatingSystem: OS
get() = when (platform) {
get() = when (osFamily) {
EelOsFamily.Windows -> OS.WINDOWS
EelOsFamily.Posix -> OS.UNIX
}
@@ -70,7 +70,7 @@ interface EelDescriptor {
* The platform of an environment corresponding to this [EelDescriptor].
*/
@get:ApiStatus.Experimental
val platform: EelOsFamily
val osFamily: EelOsFamily
@ApiStatus.Experimental
suspend fun toEelApi(): EelApi

View File

@@ -271,7 +271,7 @@ fun EelExecWindowsApi.spawnProcess(exe: String, vararg args: String): EelExecWin
*/
@ApiStatus.Internal
suspend fun EelExecApi.getShell(): Pair<EelPath, String> {
val (shell, cmdArg) = when (this.descriptor.platform) {
val (shell, cmdArg) = when (this.descriptor.osFamily) {
EelOsFamily.Windows -> {
val envs = fetchLoginShellEnvVariables()
Pair(envs["ComSpec"] ?: run {

View File

@@ -136,7 +136,7 @@ internal class ArrayListEelAbsolutePath private constructor(
fun build(parts: List<String>, descriptor: EelDescriptor): EelPath {
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.Posix -> null
}
@@ -170,7 +170,7 @@ internal class ArrayListEelAbsolutePath private constructor(
@Throws(EelPathException::class)
fun parseOrNull(raw: String, descriptor: EelDescriptor): ArrayListEelAbsolutePath? =
when (descriptor.platform) {
when (descriptor.osFamily) {
EelOsFamily.Windows -> findAbsoluteUncPath(raw, descriptor) ?: findAbsoluteTraditionalDosPath(raw, descriptor)
EelOsFamily.Posix -> findAbsoluteUnixPath(raw, descriptor)
}

View File

@@ -6,7 +6,7 @@ import com.intellij.platform.eel.EelOsFamily
import org.jetbrains.annotations.ApiStatus
@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.

View File

@@ -69,7 +69,7 @@ class EelAbsolutePathTest {
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 suspend fun toEelApi(): EelApi {

View File

@@ -71,7 +71,7 @@ class IjentNioFileSystem internal constructor(
more.fold(EelPath.parse(first, ijentFs.descriptor)) { path, newPart -> path.resolve(newPart) }.toNioPath()
}
catch (_: EelPathException) {
RelativeIjentNioPath(first.split(*ijentFs.descriptor.platform.directorySeparators) + more, this)
RelativeIjentNioPath(first.split(*ijentFs.descriptor.osFamily.directorySeparators) + more, this)
}
}

View File

@@ -581,7 +581,7 @@ class IjentNioFileSystemProvider : FileSystemProvider() {
override fun readSymbolicLink(link: Path): Path {
val fs = ensureAbsoluteIjentNioPath(link).nioFs
val absolutePath = link.eelPath
val os = fs.ijentFs.descriptor.platform
val os = fs.ijentFs.descriptor.osFamily
return fsBlocking {
when (val ijentFs = fs.ijentFs) {
is IjentFileSystemPosixApi -> when (val type = ijentFs.stat(absolutePath).justResolve().getOrThrowFileSystemException().type) {

View File

@@ -205,7 +205,7 @@ public final class JdkUtil {
}
private static boolean isCompatibleWithOs(@NotNull EelDescriptor descriptor) {
EelOsFamily os = descriptor.getPlatform();
EelOsFamily os = descriptor.getOsFamily();
return switch (os) {
case Windows -> SystemInfo.isWindows;
case Posix -> SystemInfo.isUnix;

View File

@@ -40,7 +40,7 @@
if (contextPath != null) {
var eelPath = JEelUtils.toEelPath(contextPath);
if (eelPath != null) {
return eelPath.getDescriptor().getPlatform() == EelOsFamily.Windows;
return eelPath.getDescriptor().getOsFamily() == EelOsFamily.Windows;
}
}
return SystemInfo.isWindows;

View File

@@ -153,7 +153,7 @@ class WslEelProvider(private val coroutineScope: CoroutineScope) : EelProvider {
}
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}"

View File

@@ -523,7 +523,7 @@ private class MockIjentApi(private val adapter: GeneralCommandLine, val rootUser
override val descriptor: EelDescriptor
get() = object : EelDescriptor {
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 {
throw UnsupportedOperationException()

View File

@@ -6,7 +6,7 @@ import com.intellij.platform.eel.EelDescriptor
import com.intellij.platform.eel.EelOsFamily
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"

View File

@@ -407,7 +407,7 @@ class MavenShCommandLineState(val environment: ExecutionEnvironment, private val
}
private fun isWindows() =
when (myConfiguration.project.getEelDescriptor().platform) {
when (myConfiguration.project.getEelDescriptor().osFamily) {
EelOsFamily.Posix -> false
EelOsFamily.Windows -> true
}

View File

@@ -112,7 +112,7 @@ internal class MavenWrapperSupport {
throw IllegalStateException(SyncBundle.message("zip.is.not.correct", zipFile.toAbsolutePath()))
}
val mavenHome = dirs[0]
if (mavenHome.getEelDescriptor().platform.isPosix) {
if (mavenHome.getEelDescriptor().osFamily.isPosix) {
makeMavenBinRunnable(mavenHome)
}
return mavenHome

View File

@@ -100,7 +100,7 @@ internal class ShDocumentationProvider(private val scope: CoroutineScope) : Docu
val path = eel.exec.fetchLoginShellEnvVariables()["PATH"]
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 file = eelDir.resolve("info").asNioPath()

View File

@@ -216,7 +216,7 @@ final class ShRunConfigurationProfileState implements RunProfileState {
@NotNull EelDescriptor eelDescriptor) {
systemDependentPath = convertPathUsingEel(systemDependentPath, eelDescriptor);
return switch (eelDescriptor.getPlatform()) {
return switch (eelDescriptor.getOsFamily()) {
case Windows ->
ShStringUtil.quote(systemDependentPath);
case Posix -> {

View File

@@ -157,7 +157,7 @@ class TerminalProjectOptionsProvider(val project: Project) : PersistentStateComp
}
private suspend fun findDefaultShellPath(eelDescriptor: EelDescriptor): String {
if (eelDescriptor.platform.isWindows) {
if (eelDescriptor.osFamily.isWindows) {
return "powershell.exe"
}
val eelApi = eelDescriptor.toEelApi()

View File

@@ -119,7 +119,7 @@ public final class LocalOptionsConfigurer {
final var isWindows =
eelDescriptor == null
? SystemInfo.isWindows
: switch (eelDescriptor.getPlatform()) {
: switch (eelDescriptor.getOsFamily()) {
case Posix -> false;
case Windows -> true;
};

View File

@@ -33,7 +33,7 @@ suspend fun waitNoError(delay: Duration = 100.milliseconds, repeat: Int = 50, ch
}
@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.Posix-> resolve("bin/$name")
}
@@ -53,7 +53,7 @@ private class PathMatcher(private val parent: Path) : TypeSafeMatcher<Path>(Path
private fun Path.expandWinPath(): Path =
try {
when (getEelDescriptor().platform) {
when (getEelDescriptor().osFamily) {
// 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`
EelOsFamily.Windows -> toRealPath()

View File

@@ -11,7 +11,7 @@ import kotlin.io.path.name
@RequiresBackgroundThread
@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.Posix -> parent.takeIf { it.name != "bin" } ?: parent.parent
}
@@ -19,5 +19,5 @@ fun PythonBinary.resolvePythonHome(): PythonHomePath = when (getEelDescriptor().
@RequiresBackgroundThread
@ApiStatus.Internal
fun PythonHomePath.resolvePythonBinary(): PythonBinary? {
return VirtualEnvReader(isWindows = getEelDescriptor().platform.isWindows).findPythonInPythonRoot(this)
return VirtualEnvReader(isWindows = getEelDescriptor().osFamily.isWindows).findPythonInPythonRoot(this)
}