Eel/IJent cleanup: formatting, comments, unused variables

GitOrigin-RevId: e971e57f9f80e696e8e81e4aef5adc59ea426047
This commit is contained in:
Vladimir Lagunov
2024-09-26 11:44:55 +02:00
committed by intellij-monorepo-bot
parent a05c82545b
commit ce8757e59b
7 changed files with 77 additions and 55 deletions

View File

@@ -194,14 +194,19 @@ interface EelFileSystemApi {
where: EelPath.Absolute,
additionalMessage: String,
) : EelFsIOException(where, additionalMessage) {
class DoesNotExist(where: EelPath.Absolute, additionalMessage: String) : DeleteException(where, additionalMessage), EelFsError.DoesNotExist
class DirNotEmpty(where: EelPath.Absolute, additionalMessage: String) : DeleteException(where, additionalMessage), EelFsError.DirNotEmpty
class PermissionDenied(where: EelPath.Absolute, additionalMessage: String) : DeleteException(where, additionalMessage), EelFsError.PermissionDenied
class DoesNotExist(where: EelPath.Absolute, additionalMessage: String) : DeleteException(where,
additionalMessage), EelFsError.DoesNotExist
class DirNotEmpty(where: EelPath.Absolute, additionalMessage: String) : DeleteException(where,
additionalMessage), EelFsError.DirNotEmpty
class PermissionDenied(where: EelPath.Absolute, additionalMessage: String) : DeleteException(where,
additionalMessage), EelFsError.PermissionDenied
/**
* Thrown only when `followLinks` is specified for [delete]
*/
class UnresolvedLink(where: EelPath.Absolute): DeleteException(where, "Attempted to delete a file referenced by an unresolvable link")
class UnresolvedLink(where: EelPath.Absolute) : DeleteException(where, "Attempted to delete a file referenced by an unresolvable link")
class Other(where: EelPath.Absolute, additionalMessage: String)
: DeleteException(where, additionalMessage), EelFsError.Other
}
@@ -326,18 +331,18 @@ sealed interface EelOpenedFile {
*
* This operation modifies the file's cursor, i.e. [tell] may show different results before and after this function is invoked.
*
* It reads not more than [com.intellij.platform.ijent.spi.RECOMMENDED_MAX_PACKET_SIZE].
* The implementation MAY read less data than the capacity of the buffer even if it's possible to read the whole requested buffer.
*/
suspend fun read(buf: ByteBuffer): EelFsResult<ReadResult, ReadError>
suspend fun read(buf: ByteBuffer): EelFsResult<ReadResult, ReadError>
/**
* Reads data from the position [offset] of the file.
*
* This operation does not modify the file's cursor, i.e. [tell] will show the same result before and after this function is invoked.
*
* It reads not more than [com.intellij.platform.ijent.spi.RECOMMENDED_MAX_PACKET_SIZE].
* The implementation MAY read less than [offset] bytes even if it's possible to read the whole requested buffer.
*/
suspend fun read(buf: ByteBuffer, offset: Long): EelFsResult<ReadResult, ReadError>
suspend fun read(buf: ByteBuffer, offset: Long): EelFsResult<ReadResult, ReadError>
sealed interface ReadResult {
interface EOF : ReadResult
@@ -357,18 +362,18 @@ sealed interface EelOpenedFile {
/**
* TODO Document
*
* It writes not more than [com.intellij.platform.ijent.spi.RECOMMENDED_MAX_PACKET_SIZE].
* The implementation MAY write the part of the [buf] even if it's possible to write the whole buffer.
*/
suspend fun write(buf: ByteBuffer): EelFsResult<
suspend fun write(buf: ByteBuffer): EelFsResult<
Int,
WriteError>
/**
* TODO Document
*
* It writes not more than [com.intellij.platform.ijent.spi.RECOMMENDED_MAX_PACKET_SIZE].
* The implementation MAY write the part of the [buf] even if it's possible to write the whole buffer.
*/
suspend fun write(buf: ByteBuffer, pos: Long): EelFsResult<
suspend fun write(buf: ByteBuffer, pos: Long): EelFsResult<
Int,
WriteError>
@@ -428,10 +433,18 @@ interface EelFileSystemPosixApi : EelFileSystemApi {
where: EelPath.Absolute,
additionalMessage: String,
) : EelFsIOException(where, additionalMessage) {
class DirAlreadyExists(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where, additionalMessage), EelFsError.AlreadyExists
class FileAlreadyExists(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where, additionalMessage), EelFsError.AlreadyExists
class ParentNotFound(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where, additionalMessage), EelFsError.DoesNotExist
class PermissionDenied(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where, additionalMessage), EelFsError.PermissionDenied
class DirAlreadyExists(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where,
additionalMessage), EelFsError.AlreadyExists
class FileAlreadyExists(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where,
additionalMessage), EelFsError.AlreadyExists
class ParentNotFound(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where,
additionalMessage), EelFsError.DoesNotExist
class PermissionDenied(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where,
additionalMessage), EelFsError.PermissionDenied
class Other(where: EelPath.Absolute, additionalMessage: String) : CreateDirectoryException(where, additionalMessage), EelFsError.Other
}
@@ -461,25 +474,29 @@ interface EelFileSystemPosixApi : EelFileSystemApi {
/**
* Example: `createSymbolicLink("anywhere", "/directory_that_does_not_exist")`
*/
class DoesNotExist(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where, additionalMessage), EelFsError.DoesNotExist
class DoesNotExist(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where,
additionalMessage), EelFsError.DoesNotExist
/**
* Examples:
* * `createSymbolicLink("anywhere", "/etc/passwd")`
* * `createSymbolicLink("anywhere", "/home")`
*/
class FileAlreadyExists(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where, additionalMessage), EelFsError.AlreadyExists
class FileAlreadyExists(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where,
additionalMessage), EelFsError.AlreadyExists
/**
* Example: `createSymbolicLink("anywhere", "/etc/passwd/oops")`
*/
class NotDirectory(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where, additionalMessage), EelFsError.NotDirectory
class NotDirectory(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where,
additionalMessage), EelFsError.NotDirectory
/**
* Example:
* * With non-root permissions: `createSymbolicLink("anywhere", "/root/oops")`
*/
class PermissionDenied(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where, additionalMessage), EelFsError.PermissionDenied
class PermissionDenied(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where,
additionalMessage), EelFsError.PermissionDenied
/**
* Everything else, including `ELOOP`.
@@ -490,7 +507,8 @@ interface EelFileSystemPosixApi : EelFileSystemApi {
* createSymbolicLink("anywhere", "/tmp/foobar/oops") // Other("something about ELOOP")
* ```
*/
class Other(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where, additionalMessage), EelFsError.Other
class Other(where: EelPath.Absolute, additionalMessage: String) : CreateSymbolicLinkException(where,
additionalMessage), EelFsError.Other
}
}

View File

@@ -35,11 +35,11 @@ sealed interface EelFsError {
sealed interface PermissionDenied : EelFsError
sealed interface NotDirectory : EelFsError
sealed interface NotFile : EelFsError
sealed interface UnknownFile: EelFsError
sealed interface ReadOnlyFileSystem: EelFsError
sealed interface NameTooLong: EelFsError
sealed interface NotEnoughSpace: EelFsError
sealed interface DirNotEmpty: EelFsError
sealed interface UnknownFile : EelFsError
sealed interface ReadOnlyFileSystem : EelFsError
sealed interface NameTooLong : EelFsError
sealed interface NotEnoughSpace : EelFsError
sealed interface DirNotEmpty : EelFsError
}
/**
@@ -49,24 +49,25 @@ sealed class EelFsIOException(
override val where: EelPath.Absolute,
val additionalMessage: String,
) : IOException(), EelFsError {
override val message: String get() {
// TODO i18n
val prefix: @Nls String = when (this) {
is EelFsError.DoesNotExist -> "Does not exist"
is EelFsError.NotDirectory -> "Not a directory"
is EelFsError.NotFile -> "Not a file"
is EelFsError.PermissionDenied -> "Permission denied"
is EelFsError.AlreadyExists -> "File with this name already exists"
is EelFsError.ReadOnlyFileSystem -> "File system is read-only"
is EelFsError.Other -> "Unexpected rare error"
is EelFsError.DirNotEmpty -> "Directory is not empty"
is EelFsError.NameTooLong -> "Name is too long"
is EelFsError.NotEnoughSpace -> "Not enough space"
is EelOpenedFile.Writer.TruncateException.NegativeOffset -> "Offset is negative"
is EelOpenedFile.Writer.TruncateException.OffsetTooBig -> "Offset is too big"
is EelOpenedFile.Writer.TruncateException.UnknownFile -> "File is not opened"
is EelFileSystemApi.DeleteException.UnresolvedLink -> "Unresolved link"
override val message: String
get() {
// TODO i18n
val prefix: @Nls String = when (this) {
is EelFsError.DoesNotExist -> "Does not exist"
is EelFsError.NotDirectory -> "Not a directory"
is EelFsError.NotFile -> "Not a file"
is EelFsError.PermissionDenied -> "Permission denied"
is EelFsError.AlreadyExists -> "File with this name already exists"
is EelFsError.ReadOnlyFileSystem -> "File system is read-only"
is EelFsError.Other -> "Unexpected rare error"
is EelFsError.DirNotEmpty -> "Directory is not empty"
is EelFsError.NameTooLong -> "Name is too long"
is EelFsError.NotEnoughSpace -> "Not enough space"
is EelOpenedFile.Writer.TruncateException.NegativeOffset -> "Offset is negative"
is EelOpenedFile.Writer.TruncateException.OffsetTooBig -> "Offset is too big"
is EelOpenedFile.Writer.TruncateException.UnknownFile -> "File is not opened"
is EelFileSystemApi.DeleteException.UnresolvedLink -> "Unresolved link"
}
return if (additionalMessage.isEmpty()) "$prefix: $where" else "$prefix: $where ($additionalMessage)"
}
return if (additionalMessage.isEmpty()) "$prefix: $where" else "$prefix: $where ($additionalMessage)"
}
}

View File

@@ -6,7 +6,7 @@ import com.intellij.platform.eel.EelUserWindowsInfo
data class EelUserPosixInfoImpl(
override val uid: Int,
override val gid: Int
override val gid: Int,
) : EelUserPosixInfo
data object EelUserWindowsInfoImpl : EelUserWindowsInfo

View File

@@ -1,5 +1,6 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
@file:Suppress("DialogTitleCapitalization", "HardCodedStringLiteral")
package com.intellij.execution.wsl.ijent
import com.intellij.openapi.actionSystem.ActionUpdateThread
@@ -31,7 +32,7 @@ import kotlin.io.path.isDirectory
/**
* Base class for internal smoke testing of IJent.
* It was deliberately put into the core part, near WSL utilities, in order to be sure that IJent can be integrated into WSL support.
* It was deliberately put into the core part, near WSL utilities, to be sure that IJent can be integrated into WSL support.
*/
@Internal
abstract class AbstractIjentVerificationAction : DumbAwareAction() {
@@ -41,7 +42,7 @@ abstract class AbstractIjentVerificationAction : DumbAwareAction() {
super.update(e)
e.presentation.run {
isEnabledAndVisible = ApplicationManager.getApplication().isInternal
description = "An internal action for verifiying correct module layout for IJent"
description = "An internal action for verifying correct module layout for IJent"
}
}

View File

@@ -11,16 +11,16 @@
<orderEntry type="library" scope="TEST" name="JUnit5" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit5Params" level="project" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="library" name="opentelemetry" level="project" />
<orderEntry type="library" scope="TEST" name="kotlin-test" level="project" />
<orderEntry type="library" scope="TEST" name="kotlin-test-assertions-core-jvm" level="project" />
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
<orderEntry type="library" scope="TEST" name="kotlinx-coroutines-test" level="project" />
<orderEntry type="library" name="opentelemetry" level="project" />
<orderEntry type="module" module-name="intellij.platform.core" />
<orderEntry type="module" module-name="intellij.platform.core.nio.fs" />
<orderEntry type="module" module-name="intellij.platform.diagnostic.telemetry" />
<orderEntry type="module" module-name="intellij.platform.ijent" />
<orderEntry type="module" module-name="intellij.platform.eel" />
<orderEntry type="module" module-name="intellij.platform.eel.provider" />
<orderEntry type="module" module-name="intellij.platform.ijent" />
</component>
</module>

View File

@@ -42,7 +42,8 @@ internal fun EelFsError.throwFileSystemException(): Nothing {
is EelOpenedFile.SeekError.InvalidValue -> IllegalArgumentException(message)
is EelOpenedFile.Reader.ReadError.InvalidValue -> IllegalArgumentException(message)
is EelOpenedFile.Writer.TruncateException.NegativeOffset,
is EelOpenedFile.Writer.TruncateException.OffsetTooBig -> throw IllegalArgumentException(message)
is EelOpenedFile.Writer.TruncateException.OffsetTooBig,
-> throw IllegalArgumentException(message)
is EelOpenedFile.Writer.WriteError.InvalidValue -> throw IllegalArgumentException(message)
is EelFileSystemApi.DeleteException.UnresolvedLink -> throw FileSystemException(where.toString(), null, message)
is EelFsError.Other -> FileSystemException(where.toString(), null, message.nullize())

View File

@@ -8,11 +8,12 @@ import com.intellij.platform.ijent.fs.IjentFileSystemPosixApi
import com.intellij.platform.ijent.fs.IjentFileSystemWindowsApi
/**
* Provides access to an IJent process running on some machine. An instance of this interface gives ability to run commands
* on a local or a remote machine. Every instance corresponds to a single machine, i.e. unlike Run Targets, if IJent is launched
* in a Docker container, every call to execute a process (see [com.intellij.platform.eel.EelExecApi]) runs a command in the same Docker container.
* Provides access to an IJent process running on some machine.
* An instance of this interface gives the ability to run commands on a local or a remote machine. Every instance corresponds to
* a single machine, i.e., unlike Run Targets, if IJent is launched in a Docker container, every call to execute a process
* (see [com.intellij.platform.eel.EelExecApi]) runs a command in the same Docker container.
*
* Usually, [com.intellij.platform.ijent.deploy] creates instances of [com.intellij.platform.eel.IjentApi].
* Usually, [com.intellij.platform.ijent.deploy] creates instances of [com.intellij.platform.ijent.IjentApi].
*/
sealed interface IjentApi : AutoCloseable {