From 650e3a76321ebb4f44e808bf4dbf564d631923d5 Mon Sep 17 00:00:00 2001 From: Vladimir Lagunov Date: Thu, 17 Oct 2024 17:18:44 +0200 Subject: [PATCH] Eel API: remove deprecated methods in EelPath No significant reason for a long support for old method was found, i.e., there were no feature branches that the change could break. IJ-CR-147046 (cherry picked from commit 27708f33e75969090970c7230e8f1b3ff63e5b63) GitOrigin-RevId: 2e33872c365fbd9807c5837d1f3c542ab86a58f1 --- .../platform/eel/fs/EelFileSystemApi.kt | 9 --- .../eel/path/ArrayListEelAbsolutePath.kt | 12 ---- .../eel/path/ArrayListEelRelativePath.kt | 9 --- .../com/intellij/platform/eel/path/EelPath.kt | 69 ------------------- 4 files changed, 99 deletions(-) diff --git a/platform/eel/src/com/intellij/platform/eel/fs/EelFileSystemApi.kt b/platform/eel/src/com/intellij/platform/eel/fs/EelFileSystemApi.kt index fa2d389b74bd..6f707dc85144 100644 --- a/platform/eel/src/com/intellij/platform/eel/fs/EelFileSystemApi.kt +++ b/platform/eel/src/com/intellij/platform/eel/fs/EelFileSystemApi.kt @@ -19,15 +19,6 @@ fun EelFileSystemApi.getPathE(string: String, vararg other: String): EelPath.Abs }) } -@Deprecated("Use `getPathE`") -fun EelFileSystemApi.getPath(string: String, vararg other: String): EelResult { - return EelPath.Absolute.build(listOf(string, *other), when (this) { - is EelFileSystemPosixApi -> EelPath.Absolute.OS.UNIX - is EelFileSystemWindowsApi -> EelPath.Absolute.OS.WINDOWS - else -> throw UnsupportedOperationException("Unsupported OS: ${this::class.java}") - }) -} - // TODO Integrate case-(in)sensitiveness into the interface. interface EelFileSystemApi { diff --git a/platform/eel/src/com/intellij/platform/eel/path/ArrayListEelAbsolutePath.kt b/platform/eel/src/com/intellij/platform/eel/path/ArrayListEelAbsolutePath.kt index f04c3e06fdb1..f863f796be12 100644 --- a/platform/eel/src/com/intellij/platform/eel/path/ArrayListEelAbsolutePath.kt +++ b/platform/eel/src/com/intellij/platform/eel/path/ArrayListEelAbsolutePath.kt @@ -56,9 +56,6 @@ internal class ArrayListEelAbsolutePath private constructor( return ArrayListEelAbsolutePath(_root, result) } - @Deprecated("Use the method with EelPathException") - override fun normalize(): EelResult = exceptionAdapter { normalizeE() } - override fun resolveE(other: EelPath.Relative): EelPath.Absolute { val result = parts.toMutableList() for (index in 0.. = exceptionAdapter { resolveE(other) } - override fun getChildE(name: String): EelPath.Absolute { val error = checkFileName(name) return if (error == null) @@ -83,9 +77,6 @@ internal class ArrayListEelAbsolutePath private constructor( throw EelPathException(name, error) } - @Deprecated("Use the method with EelPathException") - override fun getChild(name: String): EelResult = exceptionAdapter { getChildE(name) } - override fun scan(): Sequence = parts.asSequence().scan(ArrayListEelAbsolutePath(_root, listOf())) { parent, name -> ArrayListEelAbsolutePath(_root, parent.parts + name) @@ -167,9 +158,6 @@ internal class ArrayListEelAbsolutePath private constructor( return EelPath.Relative.buildE(result) } - @Deprecated("Use the method with EelPathException") - override fun relativize(other: EelPath.Absolute): EelResult = exceptionAdapter { relativizeE(other) } - override fun equals(other: Any?): Boolean = other is EelPath.Absolute && nameCount == other.nameCount && diff --git a/platform/eel/src/com/intellij/platform/eel/path/ArrayListEelRelativePath.kt b/platform/eel/src/com/intellij/platform/eel/path/ArrayListEelRelativePath.kt index 053dcde00b06..ed83a3f89c12 100644 --- a/platform/eel/src/com/intellij/platform/eel/path/ArrayListEelRelativePath.kt +++ b/platform/eel/src/com/intellij/platform/eel/path/ArrayListEelRelativePath.kt @@ -1,9 +1,6 @@ // 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 -import com.intellij.platform.eel.EelResult -import kotlin.Throws - internal class ArrayListEelRelativePath private constructor( private val parts: List, ) : EelPath.Relative { @@ -39,9 +36,6 @@ internal class ArrayListEelRelativePath private constructor( return ArrayListEelRelativePath(result) } - @Deprecated("Use the method with EelPathException") - override fun resolve(other: EelPath.Relative): EelResult = exceptionAdapter { resolveE(other) } - override fun getChildE(name: String): ArrayListEelRelativePath = when { name.isEmpty() -> throw EelPathException(name, "Empty child name is not allowed") @@ -49,9 +43,6 @@ internal class ArrayListEelRelativePath private constructor( else -> ArrayListEelRelativePath(parts + name) } - @Deprecated("Use the method with EelPathException") - override fun getChild(name: String): EelResult = exceptionAdapter { getChildE(name) } - override fun compareTo(other: EelPath.Relative): Int { for (i in 0.. = - exceptionAdapter { parseE(raw, os) } } val fileName: String @@ -109,9 +103,6 @@ sealed interface EelPath { @Throws(EelPathException::class) fun resolveE(other: Relative): EelPath - @Deprecated("Use the method with EelPathException") - fun resolve(other: Relative): EelResult - /** * ```kotlin * IjentRelativePath.parse("", false).getChild("abc") == Ok(IjentRelativePath.parse("abc", false)) @@ -125,9 +116,6 @@ sealed interface EelPath { @Throws(EelPathException::class) fun getChildE(name: String): EelPath - @Deprecated("Use the method with EelPathException") - fun getChild(name: String): EelResult - override fun toString(): String interface Relative : EelPath, Comparable { @@ -137,11 +125,6 @@ sealed interface EelPath { fun parseE(raw: String): Relative = ArrayListEelRelativePath.parse(raw) - @JvmStatic - @Deprecated("Use the method with EelPathException") - fun parse(raw: String): EelResult = - exceptionAdapter { parseE(raw) } - /** * The parts of the path must not contain / or \. */ @@ -150,11 +133,6 @@ sealed interface EelPath { fun buildE(vararg parts: String): Relative = buildE(listOf(*parts)) - @JvmStatic - @Deprecated("Use the method with EelPathException") - fun build(vararg parts: String): EelResult = - exceptionAdapter { buildE(*parts) } - /** * The parts of the path must not contain / or \. */ @@ -163,11 +141,6 @@ sealed interface EelPath { fun buildE(parts: List): Relative = ArrayListEelRelativePath.build(parts) - @JvmStatic - @Deprecated("Use the method with EelPathException") - fun build(parts: List): EelResult = - exceptionAdapter { buildE(parts) } - @JvmField val EMPTY: Relative = ArrayListEelRelativePath.EMPTY } @@ -180,15 +153,9 @@ sealed interface EelPath { @Throws(EelPathException::class) override fun resolveE(other: Relative): Relative - @Deprecated("Use the method with EelPathException") - override fun resolve(other: Relative): EelResult - @Throws(EelPathException::class) override fun getChildE(name: String): Relative - @Deprecated("Use the method with EelPathException") - override fun getChild(name: String): EelResult - override fun compareTo(other: Relative): Int /** @@ -219,30 +186,15 @@ sealed interface EelPath { ArrayListEelAbsolutePath.parseOrNull(raw, os) ?: throw EelPathException(raw, "Not an absolute path") - @JvmStatic - @Deprecated("Use the method with EelPathException") - fun parse(raw: String, os: OS?): EelResult = - exceptionAdapter { parseE(raw, os) } - @JvmStatic @Throws(EelPathException::class) fun buildE(vararg parts: String): Absolute = buildE(listOf(*parts), null) - @JvmStatic - @Deprecated("Use the method with EelPathException") - fun build(vararg parts: String): EelResult = - exceptionAdapter { buildE(*parts) } - @JvmStatic @Throws(EelPathException::class) fun buildE(parts: List, os: OS?): Absolute = ArrayListEelAbsolutePath.build(parts, os) - - @JvmStatic - @Deprecated("Use the method with EelPathException") - fun build(parts: List, os: OS?): EelResult = - exceptionAdapter { buildE(parts, os) } } enum class OS { @@ -263,16 +215,10 @@ sealed interface EelPath { @Throws(EelPathException::class) fun normalizeE(): Absolute - @Deprecated("Use the method with EelPathException") - fun normalize(): EelResult - /** See [java.nio.file.Path.resolve] */ @Throws(EelPathException::class) override fun resolveE(other: Relative): Absolute - @Deprecated("Use the method with EelPathException") - override fun resolve(other: Relative): EelResult - /** * See [java.nio.file.Path.relativize]. * @@ -284,15 +230,9 @@ sealed interface EelPath { @Throws(EelPathException::class) fun relativizeE(other: Absolute): Relative - @Deprecated("Use the method with EelPathException") - fun relativize(other: Absolute): EelResult - @Throws(EelPathException::class) override fun getChildE(name: String): Absolute - @Deprecated("Use the method with EelPathException") - override fun getChild(name: String): EelResult - fun scan(): Sequence /** See [java.nio.file.Path.toString] */ @@ -312,13 +252,4 @@ val EelPlatform.pathOs: OS get() = when (this) { is EelPlatform.Posix -> OS.UNIX is EelPlatform.Windows -> OS.WINDOWS - } - -internal inline fun exceptionAdapter(body: () -> T): EelResult = - try { - val result = body() - OkResult(result) - } - catch (e: EelPathException) { - ErrorResult(e) } \ No newline at end of file