mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-172897 Eel: Remove package-info.java files, put explicit ApiStatus annotations
Although all entities remained internal, it's now easier to review every entity separately. GitOrigin-RevId: 21db402317f446abe16f7b32b30ee8015db2c9da
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8329017b59
commit
832ceab2b4
@@ -11,6 +11,7 @@ import com.intellij.platform.eel.EelDescriptor
|
||||
import com.intellij.platform.eel.EelPlatform
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import com.intellij.util.concurrency.annotations.RequiresBlockingContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import java.nio.file.FileSystem
|
||||
import java.nio.file.FileSystems
|
||||
@@ -20,6 +21,7 @@ import java.nio.file.spi.FileSystemProvider
|
||||
/**
|
||||
* A service that is responsible for mapping between instances of [EelPath] and [Path]
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface EelNioBridgeService {
|
||||
|
||||
companion object {
|
||||
@@ -73,6 +75,7 @@ interface EelNioBridgeService {
|
||||
* @throws IllegalArgumentException if the Eel API for [this] does not have a corresponding [java.nio.file.FileSystem]
|
||||
*/
|
||||
@Throws(IllegalArgumentException::class)
|
||||
@ApiStatus.Internal
|
||||
fun EelPath.asNioPath(): Path =
|
||||
asNioPath(null)
|
||||
|
||||
@@ -82,6 +85,7 @@ fun EelPath.asNioPath(): Path =
|
||||
* This function helps to choose the proper root according to the base path of the project.
|
||||
*/
|
||||
@Throws(IllegalArgumentException::class)
|
||||
@ApiStatus.Internal
|
||||
fun EelPath.asNioPath(project: Project?): Path {
|
||||
return asNioPathOrNull(project)
|
||||
?: throw IllegalArgumentException("Could not convert $this to nio.Path: the corresponding provider for $descriptor is not registered in ${EelNioBridgeService::class.simpleName}")
|
||||
@@ -92,9 +96,11 @@ fun EelPath.asNioPath(project: Project?): Path {
|
||||
* but they have different string representation, and some functionality is confused when `wsl.localhost` and `wsl$` are confused.
|
||||
* This function helps to choose the proper root according to the base path of the project.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
fun EelPath.asNioPathOrNull(): Path? =
|
||||
asNioPathOrNull(null)
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelPath.asNioPathOrNull(project: Project?): Path? {
|
||||
if (descriptor === LocalEelDescriptor) {
|
||||
return Path.of(toString())
|
||||
@@ -158,6 +164,7 @@ private fun asNioPathOrNullImpl(basePath: Path?, eelRoots: Collection<Path>, sou
|
||||
* It can happen if [this] belongs to a [java.nio.file.FileSystem] that was not registered as a backend of `MultiRoutingFileSystemProvider`
|
||||
*/
|
||||
@Throws(IllegalArgumentException::class)
|
||||
@ApiStatus.Internal
|
||||
fun Path.asEelPath(): EelPath {
|
||||
if (fileSystem != FileSystems.getDefault()) {
|
||||
throw IllegalArgumentException("Could not convert $this to EelPath: the path does not belong to the default NIO FileSystem")
|
||||
@@ -174,6 +181,7 @@ fun Path.asEelPath(): EelPath {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelDescriptor.routingPrefixes(): Set<Path> {
|
||||
return EelNioBridgeService.getInstanceSync().tryGetNioRoots(this)
|
||||
?: throw IllegalArgumentException("Failure of obtaining prefix: could not convert $this to EelPath. The path does not belong to the default NIO FileSystem")
|
||||
|
||||
@@ -20,9 +20,12 @@ import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import java.nio.file.Path
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface LocalWindowsEelApi : LocalEelApi, EelWindowsApi
|
||||
@ApiStatus.Internal
|
||||
interface LocalPosixEelApi : LocalEelApi, EelPosixApi
|
||||
|
||||
@ApiStatus.Internal
|
||||
object EelInitialization {
|
||||
private val logger = logger<EelInitialization>()
|
||||
|
||||
@@ -53,6 +56,7 @@ object EelInitialization {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun Path.getEelDescriptor(): EelDescriptor {
|
||||
return EelNioBridgeService.getInstanceSync().tryGetEelDescriptor(this) ?: LocalEelDescriptor
|
||||
}
|
||||
@@ -61,6 +65,7 @@ fun Path.getEelDescriptor(): EelDescriptor {
|
||||
* Retrieves [EelDescriptor] for the environment where [this] is located.
|
||||
* If the project is not the real one (i.e., it is default or not backed by a real file), then [LocalEelDescriptor] will be returned.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
fun Project.getEelDescriptor(): EelDescriptor {
|
||||
val filePath = projectFilePath
|
||||
if (filePath == null) {
|
||||
@@ -75,18 +80,22 @@ fun Project.getEelDescriptor(): EelDescriptor {
|
||||
return Path.of(filePath).getEelDescriptor()
|
||||
}
|
||||
|
||||
@get:ApiStatus.Internal
|
||||
val localEel: LocalEelApi by lazy {
|
||||
if (SystemInfo.isWindows) ApplicationManager.getApplication().service<LocalWindowsEelApi>() else ApplicationManager.getApplication().service<LocalPosixEelApi>()
|
||||
}
|
||||
|
||||
@Deprecated("Use toEelApiBlocking() instead", ReplaceWith("toEelApiBlocking()"))
|
||||
@ApiStatus.Internal
|
||||
fun EelDescriptor.upgradeBlocking(): EelApi = toEelApiBlocking()
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelDescriptor.toEelApiBlocking(): EelApi {
|
||||
if (this === LocalEelDescriptor) return localEel
|
||||
return runBlockingMaybeCancellable { toEelApi() }
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
data object LocalEelDescriptor : EelDescriptor {
|
||||
private val LOG = logger<LocalEelDescriptor>()
|
||||
override val userReadableDescription: @NonNls String = "Local: ${System.getProperty("os.name")}"
|
||||
@@ -127,6 +136,7 @@ interface EelProvider {
|
||||
suspend fun tryInitialize(path: String)
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelApi.systemOs(): OS {
|
||||
return when (platform) {
|
||||
is EelPlatform.Linux -> OS.Linux
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
/**
|
||||
* EEL API provider
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
package com.intellij.platform.eel.provider;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -7,11 +7,13 @@ import com.intellij.platform.eel.provider.EelNioBridgeService
|
||||
import com.intellij.platform.eel.provider.asEelPath
|
||||
import com.intellij.platform.eel.provider.asNioPath
|
||||
import com.intellij.platform.eel.provider.upgradeBlocking
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
* A collection of utility methods for Java.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
object JEelUtils {
|
||||
|
||||
@JvmStatic
|
||||
|
||||
+4
-2
@@ -1,13 +1,13 @@
|
||||
// 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.provider.utils
|
||||
|
||||
import com.intellij.platform.eel.ReadResult.*
|
||||
import com.intellij.platform.eel.ReadResult.EOF
|
||||
import com.intellij.platform.eel.channels.EelReceiveChannel
|
||||
import com.intellij.platform.eel.channels.EelSendChannel
|
||||
import com.intellij.platform.eel.channels.sendWholeBuffer
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.CheckReturnValue
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.charset.Charset
|
||||
@@ -19,11 +19,13 @@ private val DEFAULT_CHARSET = Charsets.UTF_8
|
||||
/**
|
||||
* Send [text] till the end. Useful to send commands to process
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelSendChannel.sendWholeText(text: String, charset: Charset = DEFAULT_CHARSET): Unit = sendWholeBuffer(ByteBuffer.wrap(text.toByteArray(charset)))
|
||||
|
||||
/**
|
||||
* Reads text from the channel to the end.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelReceiveChannel.readWholeText(bufferSize: Int = DEFAULT_BUFFER_SIZE, charset: Charset = DEFAULT_CHARSET): String = withContext(Dispatchers.IO) {
|
||||
val buffer = ByteBuffer.allocate(bufferSize)
|
||||
val result = ByteArrayOutputStream()
|
||||
|
||||
@@ -13,6 +13,7 @@ import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
@@ -36,15 +37,21 @@ import kotlin.time.Duration.Companion.milliseconds
|
||||
// copy functions copy data from/to an eel channel
|
||||
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun ReadableByteChannel.consumeAsEelChannel(): EelReceiveChannel = NioReadToEelAdapter(this)
|
||||
@ApiStatus.Internal
|
||||
fun WritableByteChannel.asEelChannel(): EelSendChannel = NioWriteToEelAdapter(this)
|
||||
|
||||
// Flushes data after each writing.
|
||||
@ApiStatus.Internal
|
||||
fun OutputStream.asEelChannel(): EelSendChannel = NioWriteToEelAdapter(Channels.newChannel(this), this)
|
||||
@ApiStatus.Internal
|
||||
fun InputStream.consumeAsEelChannel(): EelReceiveChannel = NioReadToEelAdapter(Channels.newChannel(this))
|
||||
@ApiStatus.Internal
|
||||
fun EelReceiveChannel.consumeAsInputStream(blockingContext: CoroutineContext = Dispatchers.IO): InputStream =
|
||||
InputStreamAdapterImpl(this, blockingContext)
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelSendChannel.asOutputStream(blockingContext: CoroutineContext = Dispatchers.IO): OutputStream =
|
||||
OutputStreamAdapterImpl(this, blockingContext)
|
||||
|
||||
@@ -53,6 +60,7 @@ fun EelSendChannel.asOutputStream(blockingContext: CoroutineContext = Dispatcher
|
||||
* Each buffer is fresh (not reused) but not flipped.
|
||||
* Errors are thrown out of the channel (directly or wrapped with [IOException] if not throwable).
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
fun CoroutineScope.consumeReceiveChannelAsKotlin(receiveChannel: EelReceiveChannel, bufferSize: Int = DEFAULT_BUFFER_SIZE): ReceiveChannel<ByteBuffer> =
|
||||
consumeReceiveChannelAsKotlinImpl(receiveChannel, bufferSize)
|
||||
|
||||
@@ -76,10 +84,14 @@ fun CoroutineScope.consumeReceiveChannelAsKotlin(receiveChannel: EelReceiveChann
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
fun EelReceiveChannel.lines(charset: Charset): Flow<String> = linesImpl(charset)
|
||||
@ApiStatus.Internal
|
||||
fun EelReceiveChannel.lines(): Flow<String> = lines(Charset.defaultCharset())
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun Socket.consumeAsEelChannel(): EelReceiveChannel = consumeAsEelChannelImpl()
|
||||
@ApiStatus.Internal
|
||||
fun Socket.asEelChannel(): EelSendChannel = asEelChannelImpl()
|
||||
|
||||
/**
|
||||
@@ -88,12 +100,14 @@ fun Socket.asEelChannel(): EelSendChannel = asEelChannelImpl()
|
||||
* Closing [source] makes [sink] return and [IOException]
|
||||
* Calling [closePipe] closes both [sink] and [source], you might provide custom error that will be reported on a writing attempt.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface EelPipe {
|
||||
val sink: EelSendChannel
|
||||
val source: EelReceiveChannel
|
||||
fun closePipe(error: Throwable? = null)
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelPipe(): EelPipe = EelPipeImpl()
|
||||
|
||||
|
||||
@@ -101,6 +115,7 @@ fun EelPipe(): EelPipe = EelPipeImpl()
|
||||
* Reads all data till the end from a channel.
|
||||
* Semantics is the same as [InputStream.readAllBytes]
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelReceiveChannel.readAllBytes(): ByteArray = withContext(Dispatchers.IO) {
|
||||
// The current implementation is suboptimal and might be rewritten, but the API should be the same
|
||||
consumeAsInputStream().readAllBytes()
|
||||
@@ -109,12 +124,14 @@ suspend fun EelReceiveChannel.readAllBytes(): ByteArray = withContext(Dispatcher
|
||||
/**
|
||||
* Result of [copy]
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
sealed class CopyError(override val cause: Throwable) : IOException() {
|
||||
class InError(override val cause: Throwable) : CopyError(cause)
|
||||
class OutError(override val cause: Throwable) : CopyError(cause)
|
||||
}
|
||||
|
||||
|
||||
@ApiStatus.Internal
|
||||
enum class OnError {
|
||||
/**
|
||||
* Pretend to error happened, and try again after some time (simple backoff algorithm is used)
|
||||
@@ -134,6 +151,7 @@ enum class OnError {
|
||||
* [onWriteError] and [onReadError] might be used to configure read/write error processing
|
||||
*/
|
||||
@Throws(CopyError::class)
|
||||
@ApiStatus.Internal
|
||||
suspend fun copy(
|
||||
src: EelReceiveChannel,
|
||||
dst: EelSendChannel,
|
||||
|
||||
@@ -9,20 +9,25 @@ import com.intellij.util.io.computeDetached
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
/**
|
||||
* To simplify [EelProcessExecutionResult] delegation
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface EelProcessExecutionResultInfo {
|
||||
val exitCode: Int
|
||||
val stdout: ByteArray
|
||||
val stderr: ByteArray
|
||||
}
|
||||
|
||||
@get:ApiStatus.Internal
|
||||
val EelProcessExecutionResultInfo.stdoutString: String get() = String(stdout)
|
||||
@get:ApiStatus.Internal
|
||||
val EelProcessExecutionResultInfo.stderrString: String get() = String(stderr)
|
||||
|
||||
@ApiStatus.Internal
|
||||
class EelProcessExecutionResult(override val exitCode: Int, override val stdout: ByteArray, override val stderr: ByteArray) : EelProcessExecutionResultInfo
|
||||
|
||||
/**
|
||||
@@ -41,6 +46,7 @@ class EelProcessExecutionResult(override val exitCode: Int, override val stdout:
|
||||
* @see EelProcess
|
||||
*/
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelProcess.awaitProcessResult(): EelProcessExecutionResult {
|
||||
return computeDetached {
|
||||
ByteArrayOutputStream().use { out ->
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.platform.eel.channels.EelSendChannel
|
||||
import com.intellij.util.io.blockingDispatcher
|
||||
import com.intellij.util.io.toByteArray
|
||||
import kotlinx.coroutines.*
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.IOException
|
||||
import java.net.*
|
||||
import java.nio.ByteBuffer
|
||||
@@ -33,6 +34,7 @@ private val LOG: Logger = Logger.getInstance(EelTunnelsApi::class.java)
|
||||
* This function returns when the server starts accepting connections.
|
||||
*/
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@ApiStatus.Internal
|
||||
fun CoroutineScope.forwardLocalPort(tunnels: EelTunnelsApi, localPort: Int, address: EelTunnelsApi.HostAddress) {
|
||||
val serverSocket = ServerSocket()
|
||||
serverSocket.bind(InetSocketAddress("localhost", localPort), 1024)
|
||||
@@ -93,6 +95,7 @@ fun CoroutineScope.forwardLocalPort(tunnels: EelTunnelsApi, localPort: Int, addr
|
||||
* @return An address which remote server listens to. It is useful to get the actual port if the port of [address] was 0
|
||||
*/
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@ApiStatus.Internal
|
||||
fun CoroutineScope.forwardLocalServer(tunnels: EelTunnelsApi, localPort: Int, address: EelTunnelsApi.HostAddress): Deferred<EelTunnelsApi.ResolvedSocketAddress> {
|
||||
// todo: do not forward anything if it is local eel
|
||||
val remoteAddress = CompletableDeferred<EelTunnelsApi.ResolvedSocketAddress>()
|
||||
@@ -183,6 +186,7 @@ private fun CoroutineScope.redirectIJentDataToClientConnection(connectionId: Int
|
||||
backChannel.close()
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelTunnelsApi.ResolvedSocketAddress.asInetAddress(): InetSocketAddress {
|
||||
val inetAddress = when (this) {
|
||||
is EelTunnelsApi.ResolvedSocketAddress.V4 -> InetAddress.getByAddress(ByteBuffer.allocate(4).putInt(bits.toInt()).toByteArray())
|
||||
|
||||
@@ -11,13 +11,16 @@ import com.intellij.platform.eel.fs.EelFsError
|
||||
import com.intellij.platform.eel.fs.EelOpenedFile
|
||||
import com.intellij.util.system.CpuArch
|
||||
import com.intellij.util.text.nullize
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.IOException
|
||||
import java.nio.file.*
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelExecApi.fetchLoginShellEnvVariablesBlocking(): Map<String, String> {
|
||||
return runBlockingMaybeCancellable { fetchLoginShellEnvVariables() }
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun CpuArch.toEelArch(): EelPlatform.Arch = when (this) {
|
||||
CpuArch.X86 -> EelPlatform.Arch.X86
|
||||
CpuArch.X86_64 -> EelPlatform.Arch.X86_64
|
||||
@@ -27,6 +30,7 @@ fun CpuArch.toEelArch(): EelPlatform.Arch = when (this) {
|
||||
}
|
||||
|
||||
@Throws(FileSystemException::class)
|
||||
@ApiStatus.Internal
|
||||
fun <T, E : EelFsError> EelResult<T, E>.getOrThrowFileSystemException(): T =
|
||||
when (this) {
|
||||
is EelResult.Ok -> value
|
||||
@@ -34,6 +38,7 @@ fun <T, E : EelFsError> EelResult<T, E>.getOrThrowFileSystemException(): T =
|
||||
}
|
||||
|
||||
@Throws(FileSystemException::class)
|
||||
@ApiStatus.Internal
|
||||
suspend fun <T, E : EelFsError, O : OwnedBuilder<EelResult<T, E>>> O.getOrThrowFileSystemException(): T =
|
||||
when (val v = eelIt()) {
|
||||
is EelResult.Ok -> v.value
|
||||
@@ -42,6 +47,7 @@ suspend fun <T, E : EelFsError, O : OwnedBuilder<EelResult<T, E>>> O.getOrThrowF
|
||||
|
||||
// TODO There's java.nio.file.FileSystemLoopException, so ELOOP should be added to all error codes for a decent support of all exceptions.
|
||||
@Throws(FileSystemException::class)
|
||||
@ApiStatus.Internal
|
||||
fun EelFsError.throwFileSystemException(): Nothing {
|
||||
throw when (this) {
|
||||
is EelFsError.DoesNotExist -> NoSuchFileException(where.toString(), null, message.nullize())
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
/**
|
||||
* EEL API provider
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
package com.intellij.platform.eel.provider.utils;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -92,14 +92,24 @@ import kotlin.jvm.optionals.getOrNull
|
||||
import kotlin.let
|
||||
import kotlin.run
|
||||
import kotlin.sequences.associateWithTo
|
||||
import kotlin.sequences.filter
|
||||
import kotlin.sequences.filterIsInstance
|
||||
import kotlin.sequences.flatMap
|
||||
import kotlin.sequences.generateSequence
|
||||
import kotlin.sequences.joinToString
|
||||
import kotlin.sequences.map
|
||||
import kotlin.sequences.takeWhile
|
||||
import kotlin.sequences.toSet
|
||||
import kotlin.takeIf
|
||||
import kotlin.text.Regex
|
||||
import kotlin.text.RegexOption
|
||||
import kotlin.text.buildString
|
||||
import kotlin.text.endsWith
|
||||
import kotlin.text.isBlank
|
||||
import kotlin.text.isNotEmpty
|
||||
import kotlin.text.lines
|
||||
import kotlin.text.lowercase
|
||||
import kotlin.text.matches
|
||||
import kotlin.text.orEmpty
|
||||
import kotlin.text.prependIndent
|
||||
import kotlin.text.removePrefix
|
||||
@@ -433,7 +443,7 @@ private suspend fun fillRequests(
|
||||
private class BuilderRequest(
|
||||
val shouldCheckReturnValue: Boolean,
|
||||
val throwsAnnotation: String?,
|
||||
val deprecatedAnnotation: String?,
|
||||
val annotations: Collection<String>,
|
||||
val argsInterfaceFqn: String,
|
||||
val clsFqn: String,
|
||||
val methodName: String,
|
||||
@@ -459,9 +469,27 @@ private fun findBuilders(psiFile: PsiFile, methods: MutableList<BuilderRequest>)
|
||||
val methodName = fn.name ?: return
|
||||
val methodCls = valueParameter.containingClass()?.fqName ?: return
|
||||
|
||||
val annotationsToCopyRegex = Regex("""
|
||||
(
|
||||
org[.]jetbrains[.]annotations[.]ApiStatus[.](Internal|Experimental|Obsolete|ScheduledForRemoval)
|
||||
|
|
||||
kotlin[.]Deprecated
|
||||
)
|
||||
""".trimIndent(), RegexOption.COMMENTS)
|
||||
|
||||
methods += BuilderRequest(
|
||||
shouldCheckReturnValue = fn.annotationEntries.mapNotNull { it.shortName?.asString() }.contains("CheckReturnValue"),
|
||||
deprecatedAnnotation = fn.annotationEntries.find { it.shortName?.asString() == "Deprecated" }?.text?.trim(),
|
||||
annotations = generateSequence(fn, PsiElement::getParent)
|
||||
.takeWhile { it !is PsiFile }
|
||||
.filterIsInstance<KtAnnotated>()
|
||||
.flatMap { it.annotationEntries }
|
||||
.filter {
|
||||
analyze(it) {
|
||||
it.typeReference?.getFqn()?.matches(annotationsToCopyRegex) == true
|
||||
}
|
||||
}
|
||||
.map { it.text.trim() }
|
||||
.toSet(),
|
||||
throwsAnnotation = fn.annotationEntries.filter { it.shortName?.asString() in listOf("Throws", "ThrowsChecked") }.joinToString(" ") { it.text.trim() },
|
||||
argsInterfaceFqn = typeFqn,
|
||||
clsFqn = methodCls.asString(),
|
||||
@@ -581,6 +609,7 @@ private suspend fun writeBuilderFiles(
|
||||
requiredArguments = requiredArguments,
|
||||
optionalArguments = optionalArguments,
|
||||
propertyNames = propertyNames,
|
||||
annotations = builderRequest.annotations,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -613,7 +642,7 @@ private suspend fun writeBuilderFiles(
|
||||
}
|
||||
|
||||
text += """
|
||||
${kdoc.renderKdoc()}@GeneratedBuilder.Result${builderRequest.deprecatedAnnotation ?: ""}
|
||||
${kdoc.renderKdoc()}@GeneratedBuilder.Result${builderRequest.annotations.joinToString("\n")}
|
||||
fun ${builderRequest.clsFqn}.${builderRequest.methodName}(${
|
||||
requiredArguments.joinToString("") { prop ->
|
||||
"\n${prop.name}: ${prop.typeFqn},"
|
||||
@@ -625,7 +654,9 @@ private suspend fun writeBuilderFiles(
|
||||
"""
|
||||
}
|
||||
|
||||
text += "object ${clsFqn.removePrefix("$sourcePackage.").split('.').first()}Helpers {"
|
||||
val annotationsForGroup = annotationsForGroup(clsBuilderRequests.map { it.annotations })
|
||||
|
||||
text += "$annotationsForGroup object ${clsFqn.removePrefix("$sourcePackage.").split('.').first()}Helpers {"
|
||||
|
||||
for (builderRequest in clsBuilderRequests) {
|
||||
val argsInterfaceInfo = argsInterfacesByFqn[builderRequest.argsInterfaceFqn]!!
|
||||
@@ -634,7 +665,7 @@ private suspend fun writeBuilderFiles(
|
||||
/**
|
||||
* Create it via [${builderRequest.clsFqn}.${builderRequest.methodName}].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@GeneratedBuilder.Result${builderRequest.annotations.joinToString("\n")}
|
||||
class ${builderRequest.methodName.replaceFirstChar(Char::uppercaseChar)}(
|
||||
private val owner: ${builderRequest.clsFqn}, ${
|
||||
argsInterfaceInfo.requiredArguments.joinToString("") { prop ->
|
||||
@@ -680,7 +711,7 @@ private suspend fun writeBuilderFiles(
|
||||
for ((argsInterfaceFqn, argsInterfaceInfo) in argsInterfacesByFqn) {
|
||||
text = """
|
||||
@GeneratedBuilder.Result
|
||||
class ${argsInterfaceInfo.name}Builder${
|
||||
${argsInterfaceInfo.annotations.sorted().joinToString("\n")} class ${argsInterfaceInfo.name}Builder${
|
||||
argsInterfaceInfo.requiredArguments.joinToString("", "(", ")") { prop ->
|
||||
"\n${prop.kdoc.renderKdoc()}private var ${prop.name}: ${prop.typeFqn},"
|
||||
}
|
||||
@@ -733,6 +764,21 @@ private suspend fun writeBuilderFiles(
|
||||
return filesContent
|
||||
}
|
||||
|
||||
private fun annotationsForGroup(annotationGroups: List<Collection<String>>): String {
|
||||
val union = annotationGroups.flatten().toSet()
|
||||
val result = annotationGroups
|
||||
.reduce { a, b -> a intersect b }
|
||||
.toMutableSet()
|
||||
union.find { it.endsWith(".Experimental") }?.let { experimental ->
|
||||
result += experimental
|
||||
}
|
||||
union.find { it.endsWith(".Internal") }?.let { internal ->
|
||||
result.removeIf { experimental -> experimental.endsWith(".Experimental") }
|
||||
result += internal
|
||||
}
|
||||
return result.sorted().joinToString()
|
||||
}
|
||||
|
||||
private fun renderPropertyInBuilder(
|
||||
tempProject: Project,
|
||||
name: String,
|
||||
@@ -847,4 +893,5 @@ private class ArgInterfaceInfo(
|
||||
val requiredArguments: List<RequiredArgument>,
|
||||
val optionalArguments: List<OptionalArgument>,
|
||||
val propertyNames: List<String>,
|
||||
val annotations: Collection<String>,
|
||||
)
|
||||
@@ -9,6 +9,7 @@ import com.intellij.platform.eel.EelExecApi.ExecuteProcessOptions
|
||||
import com.intellij.platform.eel.EelExecApi.InteractionOptions
|
||||
import com.intellij.platform.eel.EelExecApi.PtyOrStdErrSettings
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.CheckReturnValue
|
||||
|
||||
|
||||
@@ -29,6 +30,7 @@ import org.jetbrains.annotations.CheckReturnValue
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@Deprecated("Use spawnProcess instead")
|
||||
@ApiStatus.Internal
|
||||
fun EelExecApi.execute(
|
||||
exe: String,
|
||||
): EelExecApiHelpers.Execute =
|
||||
@@ -45,6 +47,7 @@ fun EelExecApi.execute(
|
||||
* [ExecuteProcessOptions.workingDirectory] is the path on the Linux host. There's no automatic path mapping in this interface.
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelExecApi.spawnProcess(
|
||||
exe: String,
|
||||
): EelExecApiHelpers.SpawnProcess =
|
||||
@@ -53,11 +56,14 @@ fun EelExecApi.spawnProcess(
|
||||
exe = exe,
|
||||
)
|
||||
|
||||
@ApiStatus.Internal
|
||||
object EelExecApiHelpers {
|
||||
/**
|
||||
* Create it via [com.intellij.platform.eel.EelExecApi.execute].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@Deprecated("Use spawnProcess instead")
|
||||
@ApiStatus.Internal
|
||||
class Execute(
|
||||
private val owner: EelExecApi,
|
||||
private var exe: String,
|
||||
@@ -145,6 +151,7 @@ object EelExecApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.EelExecApi.spawnProcess].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class SpawnProcess(
|
||||
private val owner: EelExecApi,
|
||||
private var exe: String,
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.platform.eel.EelExecApi.ExecuteProcessOptions
|
||||
import com.intellij.platform.eel.EelExecApi.InteractionOptions
|
||||
import com.intellij.platform.eel.EelExecApi.PtyOrStdErrSettings
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,7 @@ import com.intellij.platform.eel.path.EelPath
|
||||
* [ExecuteProcessOptions.workingDirectory] is the path on the Linux host. There's no automatic path mapping in this interface.
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelExecPosixApi.spawnProcess(
|
||||
exe: String,
|
||||
): EelExecPosixApiHelpers.SpawnProcess =
|
||||
@@ -27,11 +29,13 @@ fun EelExecPosixApi.spawnProcess(
|
||||
exe = exe,
|
||||
)
|
||||
|
||||
@ApiStatus.Internal
|
||||
object EelExecPosixApiHelpers {
|
||||
/**
|
||||
* Create it via [com.intellij.platform.eel.EelExecPosixApi.spawnProcess].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class SpawnProcess(
|
||||
private val owner: EelExecPosixApi,
|
||||
private var exe: String,
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.platform.eel.EelExecApi.ExecuteProcessOptions
|
||||
import com.intellij.platform.eel.EelExecApi.InteractionOptions
|
||||
import com.intellij.platform.eel.EelExecApi.PtyOrStdErrSettings
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,7 @@ import com.intellij.platform.eel.path.EelPath
|
||||
* [ExecuteProcessOptions.workingDirectory] is the path on the Linux host. There's no automatic path mapping in this interface.
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelExecWindowsApi.spawnProcess(
|
||||
exe: String,
|
||||
): EelExecWindowsApiHelpers.SpawnProcess =
|
||||
@@ -27,11 +29,13 @@ fun EelExecWindowsApi.spawnProcess(
|
||||
exe = exe,
|
||||
)
|
||||
|
||||
@ApiStatus.Internal
|
||||
object EelExecWindowsApiHelpers {
|
||||
/**
|
||||
* Create it via [com.intellij.platform.eel.EelExecWindowsApi.spawnProcess].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class SpawnProcess(
|
||||
private val owner: EelExecWindowsApi,
|
||||
private var exe: String,
|
||||
|
||||
@@ -7,6 +7,7 @@ package com.intellij.platform.eel
|
||||
import com.intellij.platform.eel.*
|
||||
import com.intellij.platform.eel.EelTunnelsApi.Connection
|
||||
import kotlinx.coroutines.channels.SendChannel
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@@ -34,6 +35,7 @@ import kotlin.time.Duration.Companion.seconds
|
||||
* One should not forget to invoke [Connection.close] when the connection is not needed.
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelTunnelsApi.getAcceptorForRemotePort(): EelTunnelsApiHelpers.GetAcceptorForRemotePort =
|
||||
EelTunnelsApiHelpers.GetAcceptorForRemotePort(
|
||||
owner = this,
|
||||
@@ -65,16 +67,19 @@ fun EelTunnelsApi.getAcceptorForRemotePort(): EelTunnelsApiHelpers.GetAcceptorFo
|
||||
* To configure a socket before connection use [configureSocketBeforeConnection]. After that, use [Connection.configureSocket]
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelTunnelsApi.getConnectionToRemotePort(): EelTunnelsApiHelpers.GetConnectionToRemotePort =
|
||||
EelTunnelsApiHelpers.GetConnectionToRemotePort(
|
||||
owner = this,
|
||||
)
|
||||
|
||||
@ApiStatus.Internal
|
||||
object EelTunnelsApiHelpers {
|
||||
/**
|
||||
* Create it via [com.intellij.platform.eel.EelTunnelsApi.getAcceptorForRemotePort].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class GetAcceptorForRemotePort(
|
||||
private val owner: EelTunnelsApi,
|
||||
) : OwnedBuilder<EelTunnelsApi.ConnectionAcceptor> {
|
||||
@@ -145,6 +150,7 @@ object EelTunnelsApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.EelTunnelsApi.getConnectionToRemotePort].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class GetConnectionToRemotePort(
|
||||
private val owner: EelTunnelsApi,
|
||||
) : OwnedBuilder<Connection> {
|
||||
|
||||
@@ -8,9 +8,11 @@ import com.intellij.platform.eel.EelExecApi.ExecuteProcessOptions
|
||||
import com.intellij.platform.eel.EelExecApi.InteractionOptions
|
||||
import com.intellij.platform.eel.EelExecApi.PtyOrStdErrSettings
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class ExecuteProcessOptionsBuilder(
|
||||
/**
|
||||
* An **absolute** path to the executable.
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
package com.intellij.platform.eel
|
||||
|
||||
import com.intellij.platform.eel.EelTunnelsApi.GetAcceptorForRemotePort
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class GetAcceptorForRemotePortBuilder() {
|
||||
private var configureServerSocket: @ExtensionFunctionType Function1<ConfigurableSocket, Unit> = {}
|
||||
|
||||
|
||||
+2
@@ -5,11 +5,13 @@
|
||||
package com.intellij.platform.eel
|
||||
|
||||
import com.intellij.platform.eel.EelTunnelsApi.GetConnectionToRemotePortArgs
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class GetConnectionToRemotePortArgsBuilder() {
|
||||
private var configureSocketBeforeConnection: @ExtensionFunctionType Function1<ConfigurableClientSocket, Unit> = {}
|
||||
|
||||
|
||||
+2
@@ -9,9 +9,11 @@ import com.intellij.platform.eel.fs.EelFileInfo.Permissions
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.ChangeAttributesOptions
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.TimeSinceEpoch
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class ChangeAttributesOptionsBuilder(
|
||||
private var path: EelPath,
|
||||
) {
|
||||
|
||||
@@ -7,9 +7,11 @@ package com.intellij.platform.eel.fs
|
||||
import com.intellij.platform.eel.GeneratedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.CopyOptions
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class CopyOptionsBuilder(
|
||||
private var source: EelPath,
|
||||
private var target: EelPath,
|
||||
|
||||
+2
@@ -7,9 +7,11 @@ package com.intellij.platform.eel.fs
|
||||
import com.intellij.platform.eel.GeneratedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.CreateTemporaryEntryOptions
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class CreateTemporaryEntryOptionsBuilder() {
|
||||
private var deleteOnExit: Boolean = false
|
||||
|
||||
|
||||
@@ -19,10 +19,12 @@ import com.intellij.platform.eel.fs.EelFileSystemApi.WatchOptions
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.WatchedPath
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.CheckReturnValue
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.changeAttributes(
|
||||
path: EelPath,
|
||||
): EelFileSystemApiHelpers.ChangeAttributes =
|
||||
@@ -32,6 +34,7 @@ fun EelFileSystemApi.changeAttributes(
|
||||
)
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.copy(
|
||||
source: EelPath,
|
||||
target: EelPath,
|
||||
@@ -43,12 +46,14 @@ fun EelFileSystemApi.copy(
|
||||
)
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.createTemporaryDirectory(): EelFileSystemApiHelpers.CreateTemporaryDirectory =
|
||||
EelFileSystemApiHelpers.CreateTemporaryDirectory(
|
||||
owner = this,
|
||||
)
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.createTemporaryFile(): EelFileSystemApiHelpers.CreateTemporaryFile =
|
||||
EelFileSystemApiHelpers.CreateTemporaryFile(
|
||||
owner = this,
|
||||
@@ -63,6 +68,7 @@ fun EelFileSystemApi.createTemporaryFile(): EelFileSystemApiHelpers.CreateTempor
|
||||
* TODO The behaviour is different from resolveSymlinks in [stat]. To be fixed.
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.listDirectoryWithAttrs(
|
||||
path: EelPath,
|
||||
): EelFileSystemApiHelpers.ListDirectoryWithAttrs =
|
||||
@@ -72,6 +78,7 @@ fun EelFileSystemApi.listDirectoryWithAttrs(
|
||||
)
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.move(
|
||||
source: EelPath,
|
||||
target: EelPath,
|
||||
@@ -86,6 +93,7 @@ fun EelFileSystemApi.move(
|
||||
* Similar to stat(2) and lstat(2). [symlinkPolicy] has an impact only on [EelFileInfo.type] if [path] points on a symlink.
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.stat(
|
||||
path: EelPath,
|
||||
): EelFileSystemApiHelpers.Stat =
|
||||
@@ -103,6 +111,7 @@ fun EelFileSystemApi.stat(
|
||||
* @throws UnsupportedOperationException if the method isn't implemented for the file system.
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.unwatch(
|
||||
path: EelPath,
|
||||
): EelFileSystemApiHelpers.Unwatch =
|
||||
@@ -130,12 +139,14 @@ fun EelFileSystemApi.unwatch(
|
||||
* @throws UnsupportedOperationException if the method isn't implemented for the file system.
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.watchChanges(): EelFileSystemApiHelpers.WatchChanges =
|
||||
EelFileSystemApiHelpers.WatchChanges(
|
||||
owner = this,
|
||||
)
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.openForReadingAndWriting(
|
||||
path: EelPath,
|
||||
): EelFileSystemApiHelpers.OpenForReadingAndWriting =
|
||||
@@ -148,6 +159,7 @@ fun EelFileSystemApi.openForReadingAndWriting(
|
||||
* Opens the file only for writing
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.openForWriting(
|
||||
path: EelPath,
|
||||
): EelFileSystemApiHelpers.OpenForWriting =
|
||||
@@ -156,11 +168,13 @@ fun EelFileSystemApi.openForWriting(
|
||||
path = path,
|
||||
)
|
||||
|
||||
@ApiStatus.Internal
|
||||
object EelFileSystemApiHelpers {
|
||||
/**
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.changeAttributes].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class ChangeAttributes(
|
||||
private val owner: EelFileSystemApi,
|
||||
private var path: EelPath,
|
||||
@@ -207,6 +221,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.copy].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class Copy(
|
||||
private val owner: EelFileSystemApi,
|
||||
private var source: EelPath,
|
||||
@@ -273,6 +288,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.createTemporaryDirectory].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class CreateTemporaryDirectory(
|
||||
private val owner: EelFileSystemApi,
|
||||
) : OwnedBuilder<EelResult<EelPath, EelFileSystemApi.CreateTemporaryEntryError>> {
|
||||
@@ -320,6 +336,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.createTemporaryFile].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class CreateTemporaryFile(
|
||||
private val owner: EelFileSystemApi,
|
||||
) : OwnedBuilder<EelResult<EelPath, EelFileSystemApi.CreateTemporaryEntryError>> {
|
||||
@@ -367,6 +384,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.listDirectoryWithAttrs].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class ListDirectoryWithAttrs(
|
||||
private val owner: EelFileSystemApi,
|
||||
private var path: EelPath,
|
||||
@@ -408,6 +426,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.move].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class Move(
|
||||
private val owner: EelFileSystemApi,
|
||||
private var source: EelPath,
|
||||
@@ -462,6 +481,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.stat].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class Stat(
|
||||
private val owner: EelFileSystemApi,
|
||||
private var path: EelPath,
|
||||
@@ -503,6 +523,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.unwatch].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class Unwatch(
|
||||
private val owner: EelFileSystemApi,
|
||||
private var path: EelPath,
|
||||
@@ -530,6 +551,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.watchChanges].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class WatchChanges(
|
||||
private val owner: EelFileSystemApi,
|
||||
) : OwnedBuilder<Flow<EelFileSystemApi.PathChange>> {
|
||||
@@ -563,6 +585,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.openForReadingAndWriting].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class OpenForReadingAndWriting(
|
||||
private val owner: EelFileSystemApi,
|
||||
private var path: EelPath,
|
||||
@@ -618,6 +641,7 @@ object EelFileSystemApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemApi.openForWriting].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class OpenForWriting(
|
||||
private val owner: EelFileSystemApi,
|
||||
private var path: EelPath,
|
||||
|
||||
@@ -10,10 +10,12 @@ import com.intellij.platform.eel.OwnedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.StatError
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.SymlinkPolicy
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.CheckReturnValue
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemPosixApi.listDirectoryWithAttrs(
|
||||
path: EelPath,
|
||||
): EelFileSystemPosixApiHelpers.ListDirectoryWithAttrs =
|
||||
@@ -23,6 +25,7 @@ fun EelFileSystemPosixApi.listDirectoryWithAttrs(
|
||||
)
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemPosixApi.stat(
|
||||
path: EelPath,
|
||||
): EelFileSystemPosixApiHelpers.Stat =
|
||||
@@ -31,11 +34,13 @@ fun EelFileSystemPosixApi.stat(
|
||||
path = path,
|
||||
)
|
||||
|
||||
@ApiStatus.Internal
|
||||
object EelFileSystemPosixApiHelpers {
|
||||
/**
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemPosixApi.listDirectoryWithAttrs].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class ListDirectoryWithAttrs(
|
||||
private val owner: EelFileSystemPosixApi,
|
||||
private var path: EelPath,
|
||||
@@ -77,6 +82,7 @@ object EelFileSystemPosixApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemPosixApi.stat].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class Stat(
|
||||
private val owner: EelFileSystemPosixApi,
|
||||
private var path: EelPath,
|
||||
|
||||
+6
@@ -10,10 +10,12 @@ import com.intellij.platform.eel.OwnedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.StatError
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.SymlinkPolicy
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.CheckReturnValue
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemWindowsApi.listDirectoryWithAttrs(
|
||||
path: EelPath,
|
||||
): EelFileSystemWindowsApiHelpers.ListDirectoryWithAttrs =
|
||||
@@ -23,6 +25,7 @@ fun EelFileSystemWindowsApi.listDirectoryWithAttrs(
|
||||
)
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemWindowsApi.stat(
|
||||
path: EelPath,
|
||||
): EelFileSystemWindowsApiHelpers.Stat =
|
||||
@@ -31,11 +34,13 @@ fun EelFileSystemWindowsApi.stat(
|
||||
path = path,
|
||||
)
|
||||
|
||||
@ApiStatus.Internal
|
||||
object EelFileSystemWindowsApiHelpers {
|
||||
/**
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemWindowsApi.listDirectoryWithAttrs].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class ListDirectoryWithAttrs(
|
||||
private val owner: EelFileSystemWindowsApi,
|
||||
private var path: EelPath,
|
||||
@@ -77,6 +82,7 @@ object EelFileSystemWindowsApiHelpers {
|
||||
* Create it via [com.intellij.platform.eel.fs.EelFileSystemWindowsApi.stat].
|
||||
*/
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class Stat(
|
||||
private val owner: EelFileSystemWindowsApi,
|
||||
private var path: EelPath,
|
||||
|
||||
+2
@@ -8,9 +8,11 @@ import com.intellij.platform.eel.GeneratedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.ListDirectoryWithAttrsArgs
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.SymlinkPolicy
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class ListDirectoryWithAttrsArgsBuilder(
|
||||
private var path: EelPath,
|
||||
) {
|
||||
|
||||
@@ -8,9 +8,11 @@ import com.intellij.platform.eel.GeneratedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.MoveArgs
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.ReplaceExistingDuringMove
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class MoveArgsBuilder(
|
||||
private var source: EelPath,
|
||||
private var target: EelPath,
|
||||
|
||||
@@ -8,9 +8,11 @@ import com.intellij.platform.eel.GeneratedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.StatArgs
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.SymlinkPolicy
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class StatArgsBuilder(
|
||||
private var path: EelPath,
|
||||
) {
|
||||
|
||||
@@ -7,9 +7,11 @@ package com.intellij.platform.eel.fs
|
||||
import com.intellij.platform.eel.GeneratedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.UnwatchOptions
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class UnwatchOptionsBuilder(
|
||||
private var path: EelPath,
|
||||
) {
|
||||
|
||||
@@ -8,9 +8,11 @@ import com.intellij.platform.eel.GeneratedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.FileChangeType
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.WatchOptions
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.WatchedPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class WatchOptionsBuilder() {
|
||||
private var changeTypes: Set<FileChangeType> = emptySet()
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@ import com.intellij.platform.eel.GeneratedBuilder
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.FileWriterCreationMode
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.WriteOptions
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
@GeneratedBuilder.Result
|
||||
@ApiStatus.Internal
|
||||
class WriteOptionsBuilder(
|
||||
private var path: EelPath,
|
||||
) {
|
||||
|
||||
@@ -4,13 +4,16 @@ package com.intellij.platform.eel
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi
|
||||
import com.intellij.platform.eel.fs.EelFileSystemPosixApi
|
||||
import com.intellij.platform.eel.fs.EelFileSystemWindowsApi
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* Marker interface that indicates EelApi is running on a local machine.
|
||||
* The check for “is local” should be performed only in very specific cases
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface LocalEelApi : EelApi
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelApi {
|
||||
val descriptor: EelDescriptor
|
||||
|
||||
@@ -42,6 +45,7 @@ interface EelApi {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelPosixApi : EelApi {
|
||||
override val exec: EelExecPosixApi
|
||||
override val platform: EelPlatform.Posix get() = descriptor.platform as EelPlatform.Posix
|
||||
@@ -50,6 +54,7 @@ interface EelPosixApi : EelApi {
|
||||
override val fs: EelFileSystemPosixApi
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelWindowsApi : EelApi {
|
||||
override val exec: EelExecWindowsApi
|
||||
override val platform: EelPlatform.Windows get() = descriptor.platform as EelPlatform.Windows
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
package com.intellij.platform.eel
|
||||
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelArchiveApi {
|
||||
suspend fun extract(archive: EelPath, target: EelPath)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.annotations.NonNls
|
||||
* @see com.intellij.openapi.fileChooser.impl.LocalFileChooserFactory.canUseNativeDialog
|
||||
*/
|
||||
@ApiStatus.OverrideOnly
|
||||
@ApiStatus.Internal
|
||||
interface EelDescriptorWithoutNativeFileChooserSupport : EelDescriptor
|
||||
|
||||
/**
|
||||
@@ -48,6 +49,7 @@ interface EelDescriptorWithoutNativeFileChooserSupport : EelDescriptor
|
||||
* TODO: In the future, [EelDescriptor] may also be serializable.
|
||||
* If you need to access the remote environment, you can use the method [toEelApi], which can suspend for some time before returning a working instance of [EelApi]
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface EelDescriptor {
|
||||
@Deprecated("Use platform instead", ReplaceWith("platform"))
|
||||
val operatingSystem: OS
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.IOException
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
@ApiStatus.Internal
|
||||
abstract class EelException @JvmOverloads constructor(
|
||||
open val error: EelError,
|
||||
cause: Throwable? = null,
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.annotations.CheckReturnValue
|
||||
/**
|
||||
* Methods related to process execution: start a process, collect stdin/stdout/stderr of the process, etc.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelExecApi {
|
||||
|
||||
val descriptor: EelDescriptor
|
||||
@@ -199,26 +200,32 @@ sealed interface EelExecApi {
|
||||
data object RedirectStdErr : InteractionOptions
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelExecPosixApi : EelExecApi {
|
||||
@ThrowsChecked(ExecuteProcessException::class)
|
||||
override suspend fun spawnProcess(@GeneratedBuilder generatedBuilder: ExecuteProcessOptions): EelPosixProcess
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelExecWindowsApi : EelExecApi {
|
||||
@ThrowsChecked(ExecuteProcessException::class)
|
||||
override suspend fun spawnProcess(@GeneratedBuilder generatedBuilder: ExecuteProcessOptions): EelWindowsProcess
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelExecApi.where(exe: String): EelPath? {
|
||||
return this.findExeFilesInPath(exe).firstOrNull()
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelExecApi.spawnProcess(exe: String, vararg args: String): EelExecApiHelpers.SpawnProcess =
|
||||
spawnProcess(exe).args(*args)
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelExecPosixApi.spawnProcess(exe: String, vararg args: String): EelExecPosixApiHelpers.SpawnProcess =
|
||||
spawnProcess(exe).args(*args)
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelExecWindowsApi.spawnProcess(exe: String, vararg args: String): EelExecWindowsApiHelpers.SpawnProcess =
|
||||
spawnProcess(exe).args(*args)
|
||||
|
||||
@@ -226,6 +233,7 @@ fun EelExecWindowsApi.spawnProcess(exe: String, vararg args: String): EelExecWin
|
||||
* Path to a shell / command processor: `cmd.exe` on Windows and Bourne Shell (`sh`) on POSIX.
|
||||
* Second argument is the one you might provide to this shell to execute command and exit, i.e.: `cmd /C` or `sh -c`
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelExecApi.getShell(): Pair<EelPath, String> {
|
||||
val (shell, cmdArg) = when (this.descriptor.platform) {
|
||||
is EelPlatform.Windows -> {
|
||||
|
||||
@@ -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.
|
||||
package com.intellij.platform.eel
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
enum class EelIpPreference {
|
||||
PREFER_V4, PREFER_V6, USE_SYSTEM_DEFAULT
|
||||
}
|
||||
@@ -2,26 +2,37 @@
|
||||
package com.intellij.platform.eel
|
||||
|
||||
import com.intellij.platform.eel.EelPlatform.*
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.isMac: Boolean get() = this is Darwin
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.isLinux: Boolean get() = this is Linux
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.isWindows: Boolean get() = this is Windows
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.isFreeBSD: Boolean get() = this is FreeBSD
|
||||
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.isArm32: Boolean get() = arch is Arch.ARM_32
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.isArm64: Boolean get() = arch is Arch.ARM_64
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.isX86: Boolean get() = arch is Arch.X86
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.isX86_64: Boolean get() = arch is Arch.X86_64
|
||||
|
||||
private val UNIX_DIRECTORY_SEPARATORS = charArrayOf('/')
|
||||
private val WINDOWS_DIRECTORY_SEPARATORS = charArrayOf('/', '\\')
|
||||
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.directorySeparators: CharArray
|
||||
get() = when (this) {
|
||||
is Windows -> WINDOWS_DIRECTORY_SEPARATORS
|
||||
is Posix -> UNIX_DIRECTORY_SEPARATORS
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelPlatform {
|
||||
val arch: Arch
|
||||
|
||||
@@ -74,6 +85,7 @@ sealed interface EelPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
@get:ApiStatus.Internal
|
||||
val EelPlatform.pathSeparator: String
|
||||
get() = when (this) {
|
||||
is Windows -> ";"
|
||||
|
||||
@@ -4,12 +4,13 @@ package com.intellij.platform.eel
|
||||
import com.intellij.platform.eel.channels.EelReceiveChannel
|
||||
import com.intellij.platform.eel.channels.EelSendChannel
|
||||
import kotlinx.coroutines.Deferred
|
||||
import java.io.IOException
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* Represents some process that was launched via [EelExecApi.spawnProcess].
|
||||
*
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelProcess {
|
||||
val pid: EelApi.Pid
|
||||
|
||||
@@ -57,6 +58,7 @@ sealed interface EelProcess {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelPosixProcess : EelProcess {
|
||||
/**
|
||||
* Sends `SIGTERM` on Unix.
|
||||
@@ -64,6 +66,7 @@ interface EelPosixProcess : EelProcess {
|
||||
suspend fun terminate()
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelWindowsProcess : EelProcess {
|
||||
// Nothing yet.
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.ApiStatus
|
||||
* Refrain from making new extension functions for [EelResult] and for using it in state of objects, putting EelResults into collections, etc.
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelResult<out P, out E /*: EelError*//* TODO Uncomment and fix usages. */> {
|
||||
interface Ok<out P> : EelResult<P, Nothing> {
|
||||
val value: P
|
||||
@@ -20,6 +21,7 @@ sealed interface EelResult<out P, out E /*: EelError*//* TODO Uncomment and fix
|
||||
}
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
@ApiStatus.Internal
|
||||
interface EelError {
|
||||
object Unknown : EelError
|
||||
}
|
||||
@@ -29,17 +31,21 @@ interface EelError {
|
||||
* val data = someFun().getOr { return it }
|
||||
* ```
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
inline fun <T, E> EelResult<T, E>.getOr(action: (EelResult.Error<E>) -> Nothing): T = when (this) {
|
||||
is EelResult.Ok -> this.value
|
||||
is EelResult.Error -> action(this)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@ApiStatus.Internal
|
||||
inline fun <T, E> EelResult<T, E>.getOrThrow(exception: (E) -> Throwable = { if (it is Throwable) it else RuntimeException(it.toString()) }): T = getOr { throw exception(it.error) }
|
||||
|
||||
@ApiStatus.Internal
|
||||
suspend inline fun <T, E, R, O> O.getOrThrow(exception: (E) -> Throwable = { if (it is Throwable) it else RuntimeException(it.toString()) }): T where R : EelResult<T, E>, O : OwnedBuilder<R> =
|
||||
eelIt().getOrThrow(exception)
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun <T, E> EelResult<T, E>.getOrNull(): T? = when (this) {
|
||||
is EelResult.Ok -> this.value
|
||||
is EelResult.Error -> null
|
||||
|
||||
@@ -8,6 +8,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import kotlinx.coroutines.channels.SendChannel
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.IOException
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
@@ -15,6 +16,7 @@ import kotlin.time.Duration.Companion.seconds
|
||||
/**
|
||||
* API for sockets. Use [hostAddressBuilder] to create arguments.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelTunnelsApi {
|
||||
/**
|
||||
* Creates a remote UNIX socket forwarding. IJent listens for a connection on the remote machine, and when the connection
|
||||
@@ -272,6 +274,7 @@ sealed interface EelTunnelsApi {
|
||||
/**
|
||||
* Socket configuration valid both for server and client socket
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface ConfigurableSocket {
|
||||
/**
|
||||
* Sets the possibility to reuse address of the socket
|
||||
@@ -283,6 +286,7 @@ interface ConfigurableSocket {
|
||||
/**
|
||||
* Client only socket options
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface ConfigurableClientSocket : ConfigurableSocket {
|
||||
/**
|
||||
* Disables pending data until acknowledgement
|
||||
@@ -295,18 +299,22 @@ interface ConfigurableClientSocket : ConfigurableSocket {
|
||||
* Convenience operator to decompose connection to a pair of channels when needed.
|
||||
* @return channel to server
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
operator fun Connection.component1(): EelSendChannel = sendChannel
|
||||
|
||||
/**
|
||||
* Convenience operator to decompose connection to a pair of channels when needed.
|
||||
* @return channel from server
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
operator fun Connection.component2(): EelReceiveChannel = receiveChannel
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelTunnelsPosixApi : EelTunnelsApi {
|
||||
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelTunnelsWindowsApi : EelTunnelsApi
|
||||
|
||||
/**
|
||||
@@ -331,6 +339,7 @@ interface EelTunnelsWindowsApi : EelTunnelsApi
|
||||
*
|
||||
* @see EelTunnelsApi.getConnectionToRemotePort for more details on the behavior of [Connection]
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
suspend fun <T> EelTunnelsApiHelpers.GetConnectionToRemotePort.withConnectionToRemotePort(
|
||||
errorHandler: suspend (EelConnectionError) -> T,
|
||||
action: suspend CoroutineScope.(Connection) -> T,
|
||||
@@ -369,17 +378,20 @@ private suspend fun <T> closeWithExceptionHandling(action: suspend CoroutineScop
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelTunnelsApiHelpers.GetConnectionToRemotePort.hostAddress(
|
||||
addr: EelTunnelsApi.HostAddress,
|
||||
): EelTunnelsApiHelpers.GetConnectionToRemotePort =
|
||||
hostname(addr.hostname).port(addr.port).protocolPreference(addr.protocolPreference).timeout(addr.timeout)
|
||||
|
||||
@ApiStatus.Internal
|
||||
suspend fun <T> EelTunnelsApi.withConnectionToRemotePort(
|
||||
host: String, port: UShort,
|
||||
errorHandler: suspend (EelConnectionError) -> T,
|
||||
action: suspend CoroutineScope.(Connection) -> T,
|
||||
): T = getConnectionToRemotePort().hostname(host).port(port).withConnectionToRemotePort(errorHandler, action)
|
||||
|
||||
@ApiStatus.Internal
|
||||
suspend fun <T> EelTunnelsApi.withConnectionToRemotePort(
|
||||
remotePort: UShort,
|
||||
errorHandler: suspend (EelConnectionError) -> T,
|
||||
@@ -387,6 +399,7 @@ suspend fun <T> EelTunnelsApi.withConnectionToRemotePort(
|
||||
): T = withConnectionToRemotePort("localhost", remotePort, errorHandler, action)
|
||||
|
||||
|
||||
@ApiStatus.Internal
|
||||
suspend fun <T> EelTunnelsApiHelpers.GetAcceptorForRemotePort.withAcceptorForRemotePort(
|
||||
errorHandler: suspend (EelConnectionError) -> T,
|
||||
action: suspend CoroutineScope.(EelTunnelsApi.ConnectionAcceptor) -> T,
|
||||
@@ -399,6 +412,7 @@ suspend fun <T> EelTunnelsApiHelpers.GetAcceptorForRemotePort.withAcceptorForRem
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelTunnelsApiHelpers.GetAcceptorForRemotePort.hostAddress(
|
||||
addr: EelTunnelsApi.HostAddress,
|
||||
): EelTunnelsApiHelpers.GetAcceptorForRemotePort =
|
||||
@@ -407,11 +421,13 @@ fun EelTunnelsApiHelpers.GetAcceptorForRemotePort.hostAddress(
|
||||
/**
|
||||
* Represents a common class for all network-related errors appearing during the interaction with IJent or local process
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelNetworkError : EelError
|
||||
|
||||
/**
|
||||
* An error that can happen during the creation of a connection to a remote server
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
sealed class EelConnectionError(override val message: String) : EelNetworkError, IOException() {
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,16 +2,20 @@
|
||||
package com.intellij.platform.eel
|
||||
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelUserInfo {
|
||||
val home: EelPath
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelUserPosixInfo : EelUserInfo {
|
||||
val uid: Int
|
||||
val gid: Int
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelUserWindowsInfo : EelUserInfo {
|
||||
// TODO https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-identifiers
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.eel
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.io.IOException
|
||||
|
||||
@ApiStatus.Internal
|
||||
class ExecuteProcessException(val errno: Int, override val message: String) : EelError, IOException()
|
||||
@@ -1,12 +1,15 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.eel
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* `com.intellij.platform.eel.codegen.BuildersGenerator` generates builders for all methods
|
||||
* that have a single argument with this annotation.
|
||||
*/
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER)
|
||||
@ApiStatus.Internal
|
||||
annotation class GeneratedBuilder {
|
||||
/**
|
||||
* The only purpose of this annotation is to help to find generated builders via "Find Usages".
|
||||
@@ -29,6 +32,7 @@ annotation class GeneratedBuilder {
|
||||
* val result = someApi.someMethod(builder.build())
|
||||
* ```
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface OwnedBuilder<T> {
|
||||
suspend fun eelIt(): T
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.intellij.platform.eel
|
||||
|
||||
import com.intellij.platform.eel.ReadResult.EOF
|
||||
import com.intellij.platform.eel.ReadResult.NOT_EOF
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
|
||||
/**
|
||||
@@ -20,6 +21,7 @@ import com.intellij.platform.eel.ReadResult.NOT_EOF
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
enum class ReadResult {
|
||||
EOF,
|
||||
NOT_EOF;
|
||||
|
||||
@@ -31,7 +31,7 @@ import kotlin.reflect.KClass
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.Internal
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(
|
||||
AnnotationTarget.CONSTRUCTOR,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.eel.annotations
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* This annotation should be applied to strings that could be directly used to construct [java.nio.file.Path] instances.
|
||||
* These strings are either local to the IDE process or have prefix pointing to the specific environment.
|
||||
@@ -16,6 +18,7 @@ package com.intellij.platform.eel.annotations
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.TYPE,
|
||||
)
|
||||
@ApiStatus.Internal
|
||||
annotation class MultiRoutingFileSystemPath
|
||||
|
||||
/**
|
||||
@@ -37,6 +40,7 @@ annotation class MultiRoutingFileSystemPath
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.TYPE,
|
||||
)
|
||||
@ApiStatus.Internal
|
||||
annotation class NativePath
|
||||
|
||||
/**
|
||||
@@ -61,6 +65,7 @@ annotation class NativePath
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.TYPE,
|
||||
)
|
||||
@ApiStatus.Internal
|
||||
annotation class Filename
|
||||
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@@ -73,4 +78,5 @@ annotation class Filename
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.TYPE,
|
||||
)
|
||||
@ApiStatus.Internal
|
||||
annotation class LocalPath
|
||||
@@ -1,5 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@ApiStatus.Internal
|
||||
package com.intellij.platform.eel.annotations;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -1,10 +1,13 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.eel.channels
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@MustBeDocumented
|
||||
@Retention(value = AnnotationRetention.BINARY)
|
||||
@RequiresOptIn(
|
||||
level = RequiresOptIn.Level.WARNING,
|
||||
message = "This function might send only part of the buffer. Consider using `sendWholeBuffer` instead"
|
||||
)
|
||||
@ApiStatus.Internal
|
||||
annotation class EelSendApi
|
||||
@@ -2,12 +2,13 @@
|
||||
package com.intellij.platform.eel.channels
|
||||
|
||||
import com.intellij.platform.eel.ReadResult
|
||||
import org.jetbrains.annotations.CheckReturnValue
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
/**
|
||||
* Channel to receive data from
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface EelReceiveChannel {
|
||||
/**
|
||||
* Reads data to [dst] but might read less (see buffer position).
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.eel.channels
|
||||
|
||||
import org.jetbrains.annotations.CheckReturnValue
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
/**
|
||||
* Consumes bytes as buffers. Each [send] writes `0` or more bytes or throws an exception in case of IO error
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface EelSendChannel {
|
||||
/**
|
||||
* Writes [src], suspends until written.
|
||||
@@ -42,6 +43,7 @@ interface EelSendChannel {
|
||||
* This method is *not* thread-safe (i.e. you can't send two buffers and the same time).
|
||||
*/
|
||||
@OptIn(EelSendApi::class)
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelSendChannel.sendWholeBuffer(src: ByteBuffer) {
|
||||
if (this is EelSendChannelCustomSendWholeBuffer) {
|
||||
return sendWholeBufferCustom(src)
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
/**
|
||||
* Channels are used to send and receive bytes as {@link java.nio.ByteBuffer}.
|
||||
* This API is pretty much low-level, but other modules contain useful tools to copy channels, pipes, convert them into JVM API, and so on.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@ApiStatus.Experimental
|
||||
package com.intellij.platform.eel.channels;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -2,8 +2,10 @@
|
||||
package com.intellij.platform.eel.fs
|
||||
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelFileInfo {
|
||||
val type: Type
|
||||
val permissions: Permissions
|
||||
@@ -38,6 +40,7 @@ sealed interface EelFileInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelPosixFileInfo : EelFileInfo {
|
||||
override val type: Type
|
||||
override val permissions: Permissions
|
||||
@@ -106,6 +109,7 @@ interface EelPosixFileInfo : EelFileInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelWindowsFileInfo : EelFileInfo {
|
||||
override val permissions: Permissions
|
||||
|
||||
|
||||
@@ -5,9 +5,11 @@ import com.intellij.platform.eel.*
|
||||
import com.intellij.platform.eel.fs.EelFileSystemApi.StatError
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.CheckReturnValue
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
@get:ApiStatus.Internal
|
||||
val EelFileSystemApi.pathSeparator: String
|
||||
get() = when (this) {
|
||||
is EelFileSystemPosixApi -> ":"
|
||||
@@ -15,14 +17,17 @@ val EelFileSystemApi.pathSeparator: String
|
||||
else -> throw UnsupportedOperationException("Unsupported OS: ${this::class.java}")
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
fun EelFileSystemApi.getPath(string: String): EelPath {
|
||||
return EelPath.parse(string, descriptor)
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface LocalEelFileSystemApi : EelFileSystemApi
|
||||
|
||||
// TODO Integrate case-(in)sensitiveness into the interface.
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelFileSystemApi {
|
||||
|
||||
/**
|
||||
@@ -583,6 +588,7 @@ interface EelFileSystemApi {
|
||||
}
|
||||
|
||||
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelOpenedFile {
|
||||
val path: EelPath
|
||||
|
||||
@@ -716,8 +722,10 @@ sealed interface EelOpenedFile {
|
||||
interface ReaderWriter : Reader, Writer
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface LocalEelFileSystemPosixApi : EelFileSystemPosixApi, LocalEelFileSystemApi
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelFileSystemPosixApi : EelFileSystemApi {
|
||||
override val user: EelUserPosixInfo
|
||||
|
||||
@@ -853,8 +861,10 @@ interface EelFileSystemPosixApi : EelFileSystemApi {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface LocalEelFileSystemWindowsApi : EelFileSystemWindowsApi, LocalEelFileSystemApi
|
||||
|
||||
@ApiStatus.Internal
|
||||
interface EelFileSystemWindowsApi : EelFileSystemApi {
|
||||
override val user: EelUserWindowsInfo
|
||||
|
||||
@@ -888,6 +898,7 @@ interface EelFileSystemWindowsApi : EelFileSystemApi {
|
||||
|
||||
@CheckReturnValue
|
||||
@Deprecated("Use the method with the builder")
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelFileSystemApi.changeAttributes(
|
||||
path: EelPath,
|
||||
setup: (EelFileSystemApi.ChangeAttributesOptions.Builder).() -> Unit,
|
||||
@@ -898,6 +909,7 @@ suspend fun EelFileSystemApi.changeAttributes(
|
||||
|
||||
@CheckReturnValue
|
||||
@Deprecated("Use the method with the builder")
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelFileSystemApi.openForWriting(path: EelPath, setup: (EelFileSystemApi.WriteOptions.Builder).() -> Unit): EelResult<EelOpenedFile.Writer, EelFileSystemApi.FileWriterError> {
|
||||
val options = EelFileSystemApi.WriteOptions.Builder(path).apply(setup).build()
|
||||
return openForWriting(options)
|
||||
@@ -905,6 +917,7 @@ suspend fun EelFileSystemApi.openForWriting(path: EelPath, setup: (EelFileSystem
|
||||
|
||||
@CheckReturnValue
|
||||
@Deprecated("Use the method with the builder")
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelFileSystemApi.copy(
|
||||
source: EelPath,
|
||||
target: EelPath,
|
||||
@@ -916,6 +929,7 @@ suspend fun EelFileSystemApi.copy(
|
||||
|
||||
@CheckReturnValue
|
||||
@Deprecated("Use the method with the builder")
|
||||
@ApiStatus.Internal
|
||||
suspend fun EelFileSystemApi.createTemporaryDirectory(setup: (EelFileSystemApi.CreateTemporaryEntryOptions.Builder).() -> Unit): EelResult<EelPath, EelFileSystemApi.CreateTemporaryEntryError> {
|
||||
val options = EelFileSystemApi.CreateTemporaryEntryOptions.Builder().apply(setup).build()
|
||||
return createTemporaryDirectory(options)
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.intellij.platform.eel.fs
|
||||
|
||||
import com.intellij.platform.eel.EelError
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelFsError : EelError {
|
||||
val where: EelPath
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
package com.intellij.platform.eel.fs
|
||||
|
||||
import com.intellij.platform.eel.path.EelPath
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
@ApiStatus.Internal
|
||||
data class EelPosixFileInfoImpl(
|
||||
override val type: EelPosixFileInfo.Type,
|
||||
override val permissions: EelPosixFileInfo.Permissions,
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
/**
|
||||
* This package is only for EEL API implementers. Do not use it.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
package com.intellij.platform.eel.fs;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
/**
|
||||
* EEL API provides the same API for local and non-local (ssh/wsl/etc) system
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
package com.intellij.platform.eel;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -3,7 +3,9 @@ package com.intellij.platform.eel.path
|
||||
|
||||
import com.intellij.platform.eel.EelDescriptor
|
||||
import com.intellij.platform.eel.EelPlatform
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@get:ApiStatus.Internal
|
||||
val EelPath.platform: EelPlatform get() = descriptor.platform
|
||||
|
||||
/**
|
||||
@@ -16,6 +18,7 @@ val EelPath.platform: EelPlatform get() = descriptor.platform
|
||||
*
|
||||
* All operations listed here do not require I/O.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
sealed interface EelPath {
|
||||
companion object {
|
||||
@Throws(EelPathException::class)
|
||||
@@ -156,6 +159,8 @@ sealed interface EelPath {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
operator fun EelPath.div(part: String): EelPath = resolve(part)
|
||||
|
||||
@ApiStatus.Internal
|
||||
class EelPathException(val raw: String, val reason: String) : RuntimeException("`$raw`: $reason")
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@ApiStatus.Internal
|
||||
package com.intellij.platform.eel.path;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
Reference in New Issue
Block a user