From 6b0029f1f77c719c155f5e558ddf5098a561f24b Mon Sep 17 00:00:00 2001 From: Vladimir Lagunov Date: Thu, 13 Nov 2025 17:43:59 +0100 Subject: [PATCH] IJPL-218404 Eel: BuildersGeneratorTest can now generate builders for static Kotlin functions GitOrigin-RevId: 74c78c37340d87c14e343371a68532bb40bbb479 --- platform/eel/BUILD.bazel | 1 + platform/eel/codegen/BuildersGeneratorTest.kt | 178 ++++++++++++++---- .../platform/eel/EelExecApiHelpers.kt | 18 +- .../platform/eel/EelExecPosixApiHelpers.kt | 24 ++- .../platform/eel/EelExecWindowsApiHelpers.kt | 10 +- .../eel/ExecuteProcessOptionsBuilder.kt | 14 +- .../platform/eel/FoobarOptsBuilder.kt | 33 ++++ .../intellij/platform/eel/OurThingHelpers.kt | 48 +++++ ...PosixEnvironmentVariablesOptionsBuilder.kt | 15 +- .../platform/eel/TmpExampleKtHelpers.kt | 46 +++++ .../eel/fs/ChangeAttributesOptionsBuilder.kt | 20 +- .../eel/fs/EelFileSystemApiHelpers.kt | 96 +++++----- .../eel/fs/EelFileSystemPosixApiHelpers.kt | 21 +-- .../eel/fs/EelFileSystemWindowsApiHelpers.kt | 21 +-- .../fs/ListDirectoryWithAttrsArgsBuilder.kt | 13 +- .../platform/eel/fs/MoveArgsBuilder.kt | 13 +- .../platform/eel/fs/StatArgsBuilder.kt | 13 +- .../eel/fs/WalkDirectoryOptionsBuilder.kt | 22 +-- .../platform/eel/fs/WatchOptionsBuilder.kt | 14 +- .../platform/eel/fs/WriteOptionsBuilder.kt | 13 +- .../intellij/platform/eel/kotlinAnyHelpers.kt | 86 +++++++++ .../eel/kotlinCollectionsMapHelpers.kt | 48 +++++ .../eel/intellij.platform.eel.codegen.iml | 1 + .../com/intellij/platform/eel/TmpExample.kt | 56 ++++++ 24 files changed, 606 insertions(+), 218 deletions(-) create mode 100644 platform/eel/gen-builders/com/intellij/platform/eel/FoobarOptsBuilder.kt create mode 100644 platform/eel/gen-builders/com/intellij/platform/eel/OurThingHelpers.kt create mode 100644 platform/eel/gen-builders/com/intellij/platform/eel/TmpExampleKtHelpers.kt create mode 100644 platform/eel/gen-builders/com/intellij/platform/eel/kotlinAnyHelpers.kt create mode 100644 platform/eel/gen-builders/com/intellij/platform/eel/kotlinCollectionsMapHelpers.kt create mode 100644 platform/eel/src/com/intellij/platform/eel/TmpExample.kt diff --git a/platform/eel/BUILD.bazel b/platform/eel/BUILD.bazel index 7a7f5bdf16a1..38f11aae67d2 100644 --- a/platform/eel/BUILD.bazel +++ b/platform/eel/BUILD.bazel @@ -49,6 +49,7 @@ jvm_library( "//platform/util/jdom", "//plugins/kotlin/base/test", "//plugins/kotlin/base/test:test_test_lib", + "//plugins/kotlin/base/indices", ], runtime_deps = ["//plugins/kotlin:kotlin-plugin-community-main"] ) diff --git a/platform/eel/codegen/BuildersGeneratorTest.kt b/platform/eel/codegen/BuildersGeneratorTest.kt index fe84a1dbcbbf..8573a5dfb036 100644 --- a/platform/eel/codegen/BuildersGeneratorTest.kt +++ b/platform/eel/codegen/BuildersGeneratorTest.kt @@ -34,8 +34,10 @@ import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar import com.intellij.openapi.util.Disposer import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.newvfs.RefreshQueue import com.intellij.openapi.vfs.readText import com.intellij.openapi.vfs.writeText +import com.intellij.platform.eel.codegen.BuilderRequest.Ownership import com.intellij.profile.codeInspection.InspectionProjectProfileManager import com.intellij.project.IntelliJProjectConfiguration import com.intellij.project.stateStore @@ -43,7 +45,6 @@ import com.intellij.psi.* import com.intellij.psi.codeStyle.CodeStyleManager import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.stubs.StubUpdatingIndex -import com.intellij.psi.util.findParentOfType import com.intellij.testFramework.IndexingTestUtil import com.intellij.testFramework.TestApplicationManager import com.intellij.testFramework.UsefulTestCase @@ -67,6 +68,7 @@ import org.jetbrains.jps.model.module.JpsModuleDependency import org.jetbrains.kotlin.analysis.api.KaExperimentalApi import org.jetbrains.kotlin.analysis.api.analyze import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KaTypeRendererForSource +import org.jetbrains.kotlin.analysis.api.types.symbol import org.jetbrains.kotlin.asJava.classes.KtLightClass import org.jetbrains.kotlin.asJava.elements.KtLightField import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget.* @@ -107,6 +109,7 @@ import kotlin.sequences.filterIsInstance import kotlin.sequences.flatMap import kotlin.sequences.generateSequence import kotlin.sequences.joinToString +import kotlin.sequences.lastOrNull import kotlin.sequences.map import kotlin.sequences.takeWhile import kotlin.sequences.toList @@ -118,20 +121,18 @@ import kotlin.text.contains import kotlin.text.endsWith import kotlin.text.indexOf import kotlin.text.isBlank -import kotlin.text.isNotBlank 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 import kotlin.text.removeSuffix import kotlin.text.replace import kotlin.text.replaceFirstChar -import kotlin.text.split import kotlin.text.startsWith import kotlin.text.substring -import kotlin.text.substringBeforeLast import kotlin.text.trim import kotlin.text.trimEnd import kotlin.text.trimIndent @@ -256,7 +257,8 @@ class BuildersGeneratorTest { } for ((path, contentPair) in filesContent) { - val virtualFile = VfsUtil.findFile(path, true)!! + if (contentPair.second.isEmpty) continue + val virtualFile = VfsUtil.findFile(path, true) ?: error("Failed to find the VFS file for $path") val (_, newContent) = contentPair if (newContent.isPresent) { prettifyFile(tempProject, virtualFile) @@ -288,7 +290,7 @@ class BuildersGeneratorTest { else "${path.toUri()} : " + "The new version of the file has been written to the disk, don't forget to commit it." - assertEquals(oldPrettifiedContent, newContent, errorMsg) + assertEquals(oldPrettifiedContent.orEmpty(), newContent.orEmpty(), errorMsg) } } } @@ -437,6 +439,7 @@ private suspend fun fillRequests( val queue = ArrayDeque() queue.addAll(newEelModule.rootManager.contentRoots) + RefreshQueue.getInstance().refresh(false, true, null, *newEelModule.rootManager.contentRoots) while (true) { val virtualFile = queue.removeFirstOrNull() ?: break if (virtualFile.isDirectory) { @@ -463,12 +466,21 @@ private class BuilderRequest( val throwsAnnotation: String?, val annotations: Collection, val argsInterfaceFqn: String, - val clsFqn: String, + val packageFqn: String, + val declarationFileName: String, + val ownership: Ownership, val methodName: String, val methodKDoc: String, val returnTypeFqn: String, val imports: Set, -) +) { + sealed class Ownership { + // Autogenerated toString() are used for ordering. + data object None : Ownership() + data class Method(val simpleClsName: String, val clsFqn: String) : Ownership() + data class ExtensionFunction(val renderedReceiver: String, val outerTypeFqn: String) : Ownership() + } +} private fun findBuilders(psiFile: PsiFile, methods: MutableList) { val imports = mutableSetOf() @@ -507,7 +519,23 @@ private fun findBuilders(psiFile: PsiFile, methods: MutableList) val fn = valueParameter.parent.parent as? KtNamedFunction ?: return val methodName = fn.name ?: return - val methodCls = valueParameter.containingClass()?.fqName ?: return + val methodPackage = fn.containingKtFile.packageFqName.asString() + val ownership = + fn.receiverTypeReference + ?.let { type -> + Ownership.ExtensionFunction( + renderedReceiver = type.renderWithFqnTypes(), + outerTypeFqn = analyze(type) { + type.type.symbol?.classId?.asSingleFqName()?.asString() ?: return@let null + }, + ) + } + ?: valueParameter.containingClass() + ?.fqName + ?.let { fqName -> + Ownership.Method(simpleClsName = fqName.shortName().asString(), clsFqn = fqName.asString()) + } + ?: Ownership.None val annotationsToCopyRegex = Regex(""" ( @@ -533,10 +561,12 @@ private fun findBuilders(psiFile: PsiFile, methods: MutableList) .let(::preferInternalAnnotation), throwsAnnotation = fn.annotationEntries.filter { it.shortName?.asString() in listOf("Throws", "ThrowsChecked") }.joinToString(" ") { it.text.trim() }, argsInterfaceFqn = typeFqn, - clsFqn = methodCls.asString(), + packageFqn = methodPackage, + ownership = ownership, + declarationFileName = fn.containingKtFile.name, methodName = methodName, methodKDoc = fn.docComment?.extractText() ?: "", - returnTypeFqn = fn.typeReference!!.renderWithFqnTypes(), + returnTypeFqn = fn.typeReference?.renderWithFqnTypes() ?: "Unit", imports = imports, ) } @@ -559,27 +589,37 @@ private suspend fun writeBuilderFiles( Optional.of(path.readText()) to Optional.empty() } - methods.sortBy { listOf(it.argsInterfaceFqn, it.clsFqn, it.methodName).joinToString() } + methods.sortBy { listOfNotNull(it.argsInterfaceFqn, it.packageFqn, it.ownership.toString(), it.methodName).joinToString() } val imports = TreeSet() - methods.flatMapTo(imports) { listOf(it.argsInterfaceFqn, it.clsFqn) } + methods.mapTo(imports) { it.argsInterfaceFqn } + methods.mapNotNullTo(imports) { + when (val o = it.ownership) { + is Ownership.Method -> o.clsFqn + Ownership.None, is Ownership.ExtensionFunction -> null + } + } methods.flatMapTo(imports) { request -> request.imports.map { import -> import.removePrefix("import ") } } val filesToWrite = mutableMapOf() - for ((clsFqn, clsBuilderRequests) in methods.groupByTo(linkedMapOf()) { it.clsFqn }) { - lateinit var sourcePackage: String + for ((key, clsBuilderRequests) in methods.groupByTo(linkedMapOf()) { builderRequest -> + builderRequest.packageFqn to when (val o = builderRequest.ownership) { + is Ownership.ExtensionFunction -> o.outerTypeFqn + .removePrefix(builderRequest.packageFqn + ".") + .replace(Regex("[.]\\w")) { it.value.substring(1).uppercase() } + .plus("Helpers") + + is Ownership.Method -> o.simpleClsName + "Helpers" + + Ownership.None -> builderRequest.declarationFileName.removeSuffix(".kt") + "KtHelpers" + } + }) { + val (sourcePackage, helpersClassName) = key @Language("kotlin") var text = "" readAction { - val cls = getKtClassFromKtLightClass( - JavaPsiFacade.getInstance(tempProject).findClass(clsFqn, GlobalSearchScope.projectScope(tempProject))) - check(cls != null) { "PsiClass for ${clsFqn} not found" } - check(cls.findParentOfType() == null) { "Nested classes are not supported: ${clsFqn}" } - - sourcePackage = clsFqn.substringBeforeLast('.') - val argsInterfacesByFqn: Map = clsBuilderRequests.associate { builderRequest -> val javaPsiFacade = JavaPsiFacade.getInstance(tempProject) val projectScope = GlobalSearchScope.projectScope(tempProject) @@ -616,6 +656,7 @@ private suspend fun writeBuilderFiles( name = property.name!!, typeFqn = property.typeReference!!.renderWithFqnTypes(), kdoc = property.docComment?.extractText() ?: "", + imports = property.getImportableTypes(), ) } .sortedBy { it.name } @@ -630,6 +671,7 @@ private suspend fun writeBuilderFiles( typeFqn = property.typeReference!!.renderWithFqnTypes(), body = property.getter!!.bodyExpression!!.renderWithFqnTypes(), kdoc = property.docComment?.extractText() ?: "", + imports = property.getImportableTypes(), ) } .sortedBy { it.name } @@ -656,13 +698,8 @@ private suspend fun writeBuilderFiles( } .sortedBy { it.name } - for (fullTypeFqn in requiredArguments.map { it.typeFqn } + optionalArguments.map { it.typeFqn }) { - for (singleTypeFqn in fullTypeFqn.split(Regex("[<>,?()-]"))) { - if (singleTypeFqn.isNotBlank()) { - imports += singleTypeFqn.trim() - } - } - } + requiredArguments.flatMapTo(imports) { it.imports } + optionalArguments.flatMapTo(imports) { it.imports } builderRequest.argsInterfaceFqn to ArgInterfaceInfo( name = argsInterface.name!!, @@ -686,7 +723,7 @@ private suspend fun writeBuilderFiles( for (builderRequest in clsBuilderRequests) { val ownedBuilderFqn = listOf( sourcePackage, - builderRequest.clsFqn.removePrefix("$sourcePackage.") + "Helpers", + helpersClassName, builderRequest.methodName.replaceFirstChar(Char::uppercaseChar), ).joinToString(".") @@ -701,15 +738,20 @@ private suspend fun writeBuilderFiles( } } + val methodReceiver = when (val o = builderRequest.ownership) { + is Ownership.ExtensionFunction -> o.renderedReceiver + is Ownership.Method -> o.clsFqn + Ownership.None -> null + } text += """ ${kdoc.renderKdoc()}@GeneratedBuilder.Result${builderRequest.annotations.joinToString("\n")} - fun ${builderRequest.clsFqn}.${builderRequest.methodName}(${ + fun ${methodReceiver?.plus(".").orEmpty()}${builderRequest.methodName}(${ requiredArguments.joinToString("") { prop -> "\n${prop.name}: ${prop.typeFqn}," }.surroundWithNewlinesIfNotBlank() }): $ownedBuilderFqn = $ownedBuilderFqn( - owner = this,${requiredArguments.joinToString("") { prop -> "\n${prop.name} = ${prop.name}," }} + ${if (methodReceiver != null) "owner = this," else ""} ${requiredArguments.joinToString("") { prop -> "\n${prop.name} = ${prop.name}," }} ) """ } @@ -722,18 +764,29 @@ private suspend fun writeBuilderFiles( .sorted() .joinToString("\n") - text += "$annotationsForGroup object ${clsFqn.removePrefix("$sourcePackage.").split('.').first()}Helpers {" + text += "$annotationsForGroup object $helpersClassName {" for (builderRequest in clsBuilderRequests) { val argsInterfaceInfo = argsInterfacesByFqn[builderRequest.argsInterfaceFqn]!! + val ownerForKdoc = when (val o = builderRequest.ownership) { + is Ownership.ExtensionFunction -> o.outerTypeFqn + is Ownership.Method -> o.clsFqn + Ownership.None -> null + } + val ownerForPropertyType = when (val o = builderRequest.ownership) { + is Ownership.ExtensionFunction -> o.renderedReceiver + is Ownership.Method -> o.clsFqn + else -> null + } + text += """ /** - * Create it via [${builderRequest.clsFqn}.${builderRequest.methodName}]. + * Create it via [${ownerForKdoc?.plus(".").orEmpty()}${builderRequest.methodName}]. */ @GeneratedBuilder.Result${builderRequest.annotations.joinToString("\n")} class ${builderRequest.methodName.replaceFirstChar(Char::uppercaseChar)}( - private val owner: ${builderRequest.clsFqn}, ${ + ${if (ownerForPropertyType != null) "private val owner: $ownerForPropertyType," else ""} ${ argsInterfaceInfo.requiredArguments.joinToString("") { prop -> "\nprivate var ${prop.name}: ${prop.typeFqn}," } @@ -757,11 +810,11 @@ private suspend fun writeBuilderFiles( } /** - * Complete the builder and call [${builderRequest.clsFqn}.${builderRequest.methodName}] + * Complete the builder and call [${ownerForKdoc?.plus(".").orEmpty()}${builderRequest.methodName}] * with an instance of [${builderRequest.argsInterfaceFqn}]. */${if (builderRequest.shouldCheckReturnValue) "@org.jetbrains.annotations.CheckReturnValue" else ""}${builderRequest.throwsAnnotation ?: ""} override suspend fun eelIt(): ${builderRequest.returnTypeFqn} = - owner.${builderRequest.methodName}(${argsInterfaceInfo.name}Impl( + ${if (ownerForPropertyType != null) "owner." else ""}${builderRequest.methodName}(${argsInterfaceInfo.name}Impl( ${ argsInterfaceInfo.properties.map { it.name }.joinToString("\n") { name -> "$name = $name," } }) @@ -772,7 +825,7 @@ private suspend fun writeBuilderFiles( text += "}" - filesToWrite[Path.of(genSrcDirName.toString(), sourcePackage.replace('.', '/'), "${cls.name}Helpers.kt")] = fileHeader + text + filesToWrite[Path.of(genSrcDirName.toString(), sourcePackage.replace('.', '/'), "$helpersClassName.kt")] = fileHeader + text for ((argsInterfaceFqn, argsInterfaceInfo) in argsInterfacesByFqn) { text = """ @@ -928,6 +981,23 @@ private fun PsiElement.renderWithFqnTypes(): String { append(element.type.render(KaTypeRendererForSource.WITH_QUALIFIED_NAMES, Variance.INVARIANT)) } } + element is KtQualifiedExpression -> { + val fqName = + element.children + .takeIf { children -> + assert(children.size == 2) + children.first() is KtSimpleNameExpression + } + ?.last() + ?.let { it as KtSimpleNameExpression } + ?.fqName() + if (fqName != null) { + append(fqName) + } + else { + super.visitElement(element) + } + } element.firstChild == null -> { append(element.text) } @@ -936,10 +1006,38 @@ private fun PsiElement.renderWithFqnTypes(): String { } } } + + private fun KtSimpleNameExpression.fqName(): String? = + analyze(this) { + val declaration = this@fqName.references.firstOrNull()?.resolve() as? KtNamedDeclaration + declaration?.fqName?.asString() + } }) } } +private fun PsiElement.getImportableTypes(): Collection { + val result = hashSetOf() + accept(object : PsiRecursiveElementWalkingVisitor() { + override fun visitElement(element: PsiElement) { + if (element is KtTypeReference) { + val clsName = analyze(element) { + val maybeNestedClass = element.type.takeIf { !it.isPrimitive && !it.isAnyType && !it.isNothingType }?.expandedSymbol?.classId + val rootClass = generateSequence(maybeNestedClass) { it.parentClassId }.lastOrNull() + rootClass?.asFqNameString() + } + if (clsName != null) { + result += clsName + } + } + else { + super.visitElement(element) + } + } + }) + return result +} + private fun KDoc.extractText(): String = text .trimIndent() @@ -969,8 +1067,8 @@ private fun getKtClassFromKtLightClass(lightClass: PsiClass?): KtClass? { } } -private class RequiredArgument(val name: String, val typeFqn: String, val kdoc: String) -private class OptionalArgument(val name: String, val typeFqn: String, val kdoc: String, val body: String) +private class RequiredArgument(val name: String, val typeFqn: String, val kdoc: String, val imports: Collection) +private class OptionalArgument(val name: String, val typeFqn: String, val kdoc: String, val body: String, val imports: Collection) private class Property(val name: String, val annotations: Collection) { override fun toString(): String { diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/EelExecApiHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/EelExecApiHelpers.kt index 5108f7123e45..bde5b7757524 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/EelExecApiHelpers.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/EelExecApiHelpers.kt @@ -6,8 +6,6 @@ package com.intellij.platform.eel import com.intellij.platform.eel.* 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 kotlinx.coroutines.CoroutineScope import org.jetbrains.annotations.ApiStatus @@ -119,9 +117,9 @@ object EelExecApiHelpers { private var env: Map = mapOf() - private var interactionOptions: InteractionOptions? = null + private var interactionOptions: EelExecApi.InteractionOptions? = null - private var ptyOrStdErrSettings: PtyOrStdErrSettings? = interactionOptions + private var ptyOrStdErrSettings: EelExecApi.PtyOrStdErrSettings? = interactionOptions private var scope: CoroutineScope? = null @@ -166,13 +164,13 @@ object EelExecApiHelpers { * See `termcap(2)`, `terminfo(2)`, `ncurses(3X)` and ISBN `0937175226`. */ @ApiStatus.Experimental - fun interactionOptions(arg: InteractionOptions?): Execute = apply { + fun interactionOptions(arg: EelExecApi.InteractionOptions?): Execute = apply { this.interactionOptions = arg } @Deprecated("Switch to interactionOptions", replaceWith = ReplaceWith("interactionOptions")) @ApiStatus.Internal - fun ptyOrStdErrSettings(arg: PtyOrStdErrSettings?): Execute = apply { + fun ptyOrStdErrSettings(arg: EelExecApi.PtyOrStdErrSettings?): Execute = apply { this.ptyOrStdErrSettings = arg } @@ -224,9 +222,9 @@ object EelExecApiHelpers { private var env: Map = mapOf() - private var interactionOptions: InteractionOptions? = null + private var interactionOptions: EelExecApi.InteractionOptions? = null - private var ptyOrStdErrSettings: PtyOrStdErrSettings? = interactionOptions + private var ptyOrStdErrSettings: EelExecApi.PtyOrStdErrSettings? = interactionOptions private var scope: CoroutineScope? = null @@ -271,13 +269,13 @@ object EelExecApiHelpers { * See `termcap(2)`, `terminfo(2)`, `ncurses(3X)` and ISBN `0937175226`. */ @ApiStatus.Experimental - fun interactionOptions(arg: InteractionOptions?): SpawnProcess = apply { + fun interactionOptions(arg: EelExecApi.InteractionOptions?): SpawnProcess = apply { this.interactionOptions = arg } @Deprecated("Switch to interactionOptions", replaceWith = ReplaceWith("interactionOptions")) @ApiStatus.Internal - fun ptyOrStdErrSettings(arg: PtyOrStdErrSettings?): SpawnProcess = apply { + fun ptyOrStdErrSettings(arg: EelExecApi.PtyOrStdErrSettings?): SpawnProcess = apply { this.ptyOrStdErrSettings = arg } diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/EelExecPosixApiHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/EelExecPosixApiHelpers.kt index 92c802c46e5a..5723e1045190 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/EelExecPosixApiHelpers.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/EelExecPosixApiHelpers.kt @@ -6,9 +6,7 @@ package com.intellij.platform.eel import com.intellij.platform.eel.* 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.EelExecPosixApi.PosixEnvironmentVariablesOptions.Mode +import com.intellij.platform.eel.EelExecPosixApi.PosixEnvironmentVariablesOptions import com.intellij.platform.eel.channels.EelDelicateApi import com.intellij.platform.eel.path.EelPath import kotlinx.coroutines.CoroutineScope @@ -54,9 +52,9 @@ object EelExecPosixApiHelpers { private var env: Map = mapOf() - private var interactionOptions: InteractionOptions? = null + private var interactionOptions: EelExecApi.InteractionOptions? = null - private var ptyOrStdErrSettings: PtyOrStdErrSettings? = interactionOptions + private var ptyOrStdErrSettings: EelExecApi.PtyOrStdErrSettings? = interactionOptions private var scope: CoroutineScope? = null @@ -101,13 +99,13 @@ object EelExecPosixApiHelpers { * See `termcap(2)`, `terminfo(2)`, `ncurses(3X)` and ISBN `0937175226`. */ @ApiStatus.Experimental - fun interactionOptions(arg: InteractionOptions?): SpawnProcess = apply { + fun interactionOptions(arg: EelExecApi.InteractionOptions?): SpawnProcess = apply { this.interactionOptions = arg } @Deprecated("Switch to interactionOptions", replaceWith = ReplaceWith("interactionOptions")) @ApiStatus.Internal - fun ptyOrStdErrSettings(arg: PtyOrStdErrSettings?): SpawnProcess = apply { + fun ptyOrStdErrSettings(arg: EelExecApi.PtyOrStdErrSettings?): SpawnProcess = apply { this.ptyOrStdErrSettings = arg } @@ -154,11 +152,11 @@ object EelExecPosixApiHelpers { class EnvironmentVariables( private val owner: EelExecPosixApi, ) : OwnedBuilder { - private var mode: Mode = Mode.DEFAULT + private var mode: PosixEnvironmentVariablesOptions.Mode = PosixEnvironmentVariablesOptions.Mode.DEFAULT private var onlyActual: Boolean = false - fun mode(arg: Mode): EnvironmentVariables = apply { + fun mode(arg: PosixEnvironmentVariablesOptions.Mode): EnvironmentVariables = apply { this.mode = arg } @@ -172,7 +170,7 @@ object EelExecPosixApiHelpers { * In this mode [EelExecApi.EnvironmentVariablesException] is not thrown. */ fun default(): EnvironmentVariables = - mode(Mode.DEFAULT) + mode(PosixEnvironmentVariablesOptions.Mode.DEFAULT) /** * **Use with caution, avoid when possible.** @@ -196,7 +194,7 @@ object EelExecPosixApiHelpers { */ @EelDelicateApi fun loginInteractive(): EnvironmentVariables = - mode(Mode.LOGIN_INTERACTIVE) + mode(PosixEnvironmentVariablesOptions.Mode.LOGIN_INTERACTIVE) /** * This mode executes a shell process supposed to load various profile scripts: @@ -209,7 +207,7 @@ object EelExecPosixApiHelpers { * **Notice:** In this mode [EelExecApi.EnvironmentVariablesException] MAY be thrown. */ fun loginNonInteractive(): EnvironmentVariables = - mode(Mode.LOGIN_NON_INTERACTIVE) + mode(PosixEnvironmentVariablesOptions.Mode.LOGIN_NON_INTERACTIVE) /** * The fastest way to get environment variables. It doesn't call shell scripts written by users. @@ -219,7 +217,7 @@ object EelExecPosixApiHelpers { * In this mode [EelExecApi.EnvironmentVariablesException] is not thrown. */ fun minimal(): EnvironmentVariables = - mode(Mode.MINIMAL) + mode(PosixEnvironmentVariablesOptions.Mode.MINIMAL) /** * The implementation MAY cache the environment variables by default because they rarely change in real life. diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/EelExecWindowsApiHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/EelExecWindowsApiHelpers.kt index d47b80460b37..cb792424863b 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/EelExecWindowsApiHelpers.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/EelExecWindowsApiHelpers.kt @@ -6,8 +6,6 @@ package com.intellij.platform.eel import com.intellij.platform.eel.* 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 kotlinx.coroutines.CoroutineScope import org.jetbrains.annotations.ApiStatus @@ -45,9 +43,9 @@ object EelExecWindowsApiHelpers { private var env: Map = mapOf() - private var interactionOptions: InteractionOptions? = null + private var interactionOptions: EelExecApi.InteractionOptions? = null - private var ptyOrStdErrSettings: PtyOrStdErrSettings? = interactionOptions + private var ptyOrStdErrSettings: EelExecApi.PtyOrStdErrSettings? = interactionOptions private var scope: CoroutineScope? = null @@ -92,13 +90,13 @@ object EelExecWindowsApiHelpers { * See `termcap(2)`, `terminfo(2)`, `ncurses(3X)` and ISBN `0937175226`. */ @ApiStatus.Experimental - fun interactionOptions(arg: InteractionOptions?): SpawnProcess = apply { + fun interactionOptions(arg: EelExecApi.InteractionOptions?): SpawnProcess = apply { this.interactionOptions = arg } @Deprecated("Switch to interactionOptions", replaceWith = ReplaceWith("interactionOptions")) @ApiStatus.Internal - fun ptyOrStdErrSettings(arg: PtyOrStdErrSettings?): SpawnProcess = apply { + fun ptyOrStdErrSettings(arg: EelExecApi.PtyOrStdErrSettings?): SpawnProcess = apply { this.ptyOrStdErrSettings = arg } diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/ExecuteProcessOptionsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/ExecuteProcessOptionsBuilder.kt index 1405c5bb94f2..13daf199692b 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/ExecuteProcessOptionsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/ExecuteProcessOptionsBuilder.kt @@ -5,8 +5,6 @@ package com.intellij.platform.eel 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 kotlinx.coroutines.CoroutineScope import org.jetbrains.annotations.ApiStatus @@ -28,9 +26,9 @@ class ExecuteProcessOptionsBuilder( private var env: Map = mapOf() - private var interactionOptions: InteractionOptions? = null + private var interactionOptions: EelExecApi.InteractionOptions? = null - private var ptyOrStdErrSettings: PtyOrStdErrSettings? = interactionOptions + private var ptyOrStdErrSettings: EelExecApi.PtyOrStdErrSettings? = interactionOptions private var scope: CoroutineScope? = null @@ -75,13 +73,13 @@ class ExecuteProcessOptionsBuilder( * See `termcap(2)`, `terminfo(2)`, `ncurses(3X)` and ISBN `0937175226`. */ @ApiStatus.Experimental - fun interactionOptions(arg: InteractionOptions?): ExecuteProcessOptionsBuilder = apply { + fun interactionOptions(arg: EelExecApi.InteractionOptions?): ExecuteProcessOptionsBuilder = apply { this.interactionOptions = arg } @Deprecated("Switch to interactionOptions", replaceWith = ReplaceWith("interactionOptions")) @ApiStatus.Internal - fun ptyOrStdErrSettings(arg: PtyOrStdErrSettings?): ExecuteProcessOptionsBuilder = apply { + fun ptyOrStdErrSettings(arg: EelExecApi.PtyOrStdErrSettings?): ExecuteProcessOptionsBuilder = apply { this.ptyOrStdErrSettings = arg } @@ -118,8 +116,8 @@ internal class ExecuteProcessOptionsImpl( override val args: List, override val env: Map, override val exe: String, - override val interactionOptions: InteractionOptions?, - override val ptyOrStdErrSettings: PtyOrStdErrSettings?, + override val interactionOptions: EelExecApi.InteractionOptions?, + override val ptyOrStdErrSettings: EelExecApi.PtyOrStdErrSettings?, override val scope: CoroutineScope?, override val workingDirectory: EelPath?, ) : ExecuteProcessOptions \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/FoobarOptsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/FoobarOptsBuilder.kt new file mode 100644 index 000000000000..d5c05eb691b9 --- /dev/null +++ b/platform/eel/gen-builders/com/intellij/platform/eel/FoobarOptsBuilder.kt @@ -0,0 +1,33 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +/** + * This file is generated by [com.intellij.platform.eel.codegen.BuildersGeneratorTest]. + */ +package com.intellij.platform.eel + + +@GeneratedBuilder.Result +class FoobarOptsBuilder { + private var bar: Int? = null + + private var foo: String? = null + + fun bar(arg: Int?): FoobarOptsBuilder = apply { + this.bar = arg + } + + fun foo(arg: String?): FoobarOptsBuilder = apply { + this.foo = arg + } + + fun build(): FoobarOpts = + FoobarOptsImpl( + bar = bar, + foo = foo, + ) +} + +@GeneratedBuilder.Result +internal class FoobarOptsImpl( + override val bar: Int?, + override val foo: String?, +) : FoobarOpts \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/OurThingHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/OurThingHelpers.kt new file mode 100644 index 000000000000..9144befd1af7 --- /dev/null +++ b/platform/eel/gen-builders/com/intellij/platform/eel/OurThingHelpers.kt @@ -0,0 +1,48 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +/** + * This file is generated by [com.intellij.platform.eel.codegen.BuildersGeneratorTest]. + */ +package com.intellij.platform.eel + +import com.intellij.platform.eel.* + + +@GeneratedBuilder.Result +fun OurThing.foobar5(): OurThingHelpers.Foobar5 = + OurThingHelpers.Foobar5( + owner = this, + ) + +object OurThingHelpers { + /** + * Create it via [com.intellij.platform.eel.OurThing.foobar5]. + */ + @GeneratedBuilder.Result + class Foobar5( + private val owner: OurThing, + ) : OwnedBuilder { + private var bar: Int? = null + + private var foo: String? = null + + fun bar(arg: Int?): Foobar5 = apply { + this.bar = arg + } + + fun foo(arg: String?): Foobar5 = apply { + this.foo = arg + } + + /** + * Complete the builder and call [com.intellij.platform.eel.OurThing.foobar5] + * with an instance of [com.intellij.platform.eel.FoobarOpts]. + */ + override suspend fun eelIt(): Unit = + owner.foobar5( + FoobarOptsImpl( + bar = bar, + foo = foo, + ) + ) + } +} \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/PosixEnvironmentVariablesOptionsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/PosixEnvironmentVariablesOptionsBuilder.kt index 1a2231e18cbf..3daaae58e101 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/PosixEnvironmentVariablesOptionsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/PosixEnvironmentVariablesOptionsBuilder.kt @@ -5,7 +5,6 @@ package com.intellij.platform.eel import com.intellij.platform.eel.EelExecPosixApi.PosixEnvironmentVariablesOptions -import com.intellij.platform.eel.EelExecPosixApi.PosixEnvironmentVariablesOptions.Mode import com.intellij.platform.eel.channels.EelDelicateApi import org.jetbrains.annotations.ApiStatus @@ -13,11 +12,11 @@ import org.jetbrains.annotations.ApiStatus @GeneratedBuilder.Result @ApiStatus.Experimental class PosixEnvironmentVariablesOptionsBuilder { - private var mode: Mode = Mode.DEFAULT + private var mode: PosixEnvironmentVariablesOptions.Mode = PosixEnvironmentVariablesOptions.Mode.DEFAULT private var onlyActual: Boolean = false - fun mode(arg: Mode): PosixEnvironmentVariablesOptionsBuilder = apply { + fun mode(arg: PosixEnvironmentVariablesOptions.Mode): PosixEnvironmentVariablesOptionsBuilder = apply { this.mode = arg } @@ -31,7 +30,7 @@ class PosixEnvironmentVariablesOptionsBuilder { * In this mode [EelExecApi.EnvironmentVariablesException] is not thrown. */ fun default(): PosixEnvironmentVariablesOptionsBuilder = - mode(Mode.DEFAULT) + mode(PosixEnvironmentVariablesOptions.Mode.DEFAULT) /** * **Use with caution, avoid when possible.** @@ -55,7 +54,7 @@ class PosixEnvironmentVariablesOptionsBuilder { */ @EelDelicateApi fun loginInteractive(): PosixEnvironmentVariablesOptionsBuilder = - mode(Mode.LOGIN_INTERACTIVE) + mode(PosixEnvironmentVariablesOptions.Mode.LOGIN_INTERACTIVE) /** * This mode executes a shell process supposed to load various profile scripts: @@ -68,7 +67,7 @@ class PosixEnvironmentVariablesOptionsBuilder { * **Notice:** In this mode [EelExecApi.EnvironmentVariablesException] MAY be thrown. */ fun loginNonInteractive(): PosixEnvironmentVariablesOptionsBuilder = - mode(Mode.LOGIN_NON_INTERACTIVE) + mode(PosixEnvironmentVariablesOptions.Mode.LOGIN_NON_INTERACTIVE) /** * The fastest way to get environment variables. It doesn't call shell scripts written by users. @@ -78,7 +77,7 @@ class PosixEnvironmentVariablesOptionsBuilder { * In this mode [EelExecApi.EnvironmentVariablesException] is not thrown. */ fun minimal(): PosixEnvironmentVariablesOptionsBuilder = - mode(Mode.MINIMAL) + mode(PosixEnvironmentVariablesOptions.Mode.MINIMAL) /** * The implementation MAY cache the environment variables by default because they rarely change in real life. @@ -101,6 +100,6 @@ class PosixEnvironmentVariablesOptionsBuilder { @GeneratedBuilder.Result internal class PosixEnvironmentVariablesOptionsImpl( - override val mode: Mode, + override val mode: PosixEnvironmentVariablesOptions.Mode, override val onlyActual: Boolean, ) : PosixEnvironmentVariablesOptions \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/TmpExampleKtHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/TmpExampleKtHelpers.kt new file mode 100644 index 000000000000..c0dfb4c58845 --- /dev/null +++ b/platform/eel/gen-builders/com/intellij/platform/eel/TmpExampleKtHelpers.kt @@ -0,0 +1,46 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +/** + * This file is generated by [com.intellij.platform.eel.codegen.BuildersGeneratorTest]. + */ +package com.intellij.platform.eel + +import com.intellij.platform.eel.* + + +@GeneratedBuilder.Result +fun foobar1(): TmpExampleKtHelpers.Foobar1 = + TmpExampleKtHelpers.Foobar1( + + ) + +object TmpExampleKtHelpers { + /** + * Create it via [foobar1]. + */ + @GeneratedBuilder.Result + class Foobar1 : OwnedBuilder { + private var bar: Int? = null + + private var foo: String? = null + + fun bar(arg: Int?): Foobar1 = apply { + this.bar = arg + } + + fun foo(arg: String?): Foobar1 = apply { + this.foo = arg + } + + /** + * Complete the builder and call [foobar1] + * with an instance of [com.intellij.platform.eel.FoobarOpts]. + */ + override suspend fun eelIt(): Unit = + foobar1( + FoobarOptsImpl( + bar = bar, + foo = foo, + ) + ) + } +} \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/ChangeAttributesOptionsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/ChangeAttributesOptionsBuilder.kt index 739d661eb472..6b7a02495271 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/ChangeAttributesOptionsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/ChangeAttributesOptionsBuilder.kt @@ -5,9 +5,7 @@ package com.intellij.platform.eel.fs import com.intellij.platform.eel.GeneratedBuilder -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 @@ -17,17 +15,17 @@ import org.jetbrains.annotations.ApiStatus class ChangeAttributesOptionsBuilder( private var path: EelPath, ) { - private var accessTime: TimeSinceEpoch? = null + private var accessTime: EelFileSystemApi.TimeSinceEpoch? = null - private var modificationTime: TimeSinceEpoch? = null + private var modificationTime: EelFileSystemApi.TimeSinceEpoch? = null - private var permissions: Permissions? = null + private var permissions: EelFileInfo.Permissions? = null - fun accessTime(arg: TimeSinceEpoch?): ChangeAttributesOptionsBuilder = apply { + fun accessTime(arg: EelFileSystemApi.TimeSinceEpoch?): ChangeAttributesOptionsBuilder = apply { this.accessTime = arg } - fun modificationTime(arg: TimeSinceEpoch?): ChangeAttributesOptionsBuilder = apply { + fun modificationTime(arg: EelFileSystemApi.TimeSinceEpoch?): ChangeAttributesOptionsBuilder = apply { this.modificationTime = arg } @@ -35,7 +33,7 @@ class ChangeAttributesOptionsBuilder( this.path = arg } - fun permissions(arg: Permissions?): ChangeAttributesOptionsBuilder = apply { + fun permissions(arg: EelFileInfo.Permissions?): ChangeAttributesOptionsBuilder = apply { this.permissions = arg } @@ -50,8 +48,8 @@ class ChangeAttributesOptionsBuilder( @GeneratedBuilder.Result internal class ChangeAttributesOptionsImpl( - override val accessTime: TimeSinceEpoch?, - override val modificationTime: TimeSinceEpoch?, + override val accessTime: EelFileSystemApi.TimeSinceEpoch?, + override val modificationTime: EelFileSystemApi.TimeSinceEpoch?, override val path: EelPath, - override val permissions: Permissions?, + override val permissions: EelFileInfo.Permissions?, ) : ChangeAttributesOptions \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemApiHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemApiHelpers.kt index d815b461436b..d0ec5ab3cab7 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemApiHelpers.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemApiHelpers.kt @@ -8,18 +8,10 @@ import com.intellij.platform.eel.EelResult import com.intellij.platform.eel.GeneratedBuilder import com.intellij.platform.eel.OwnedBuilder import com.intellij.platform.eel.channels.EelDelicateApi -import com.intellij.platform.eel.fs.EelFileInfo.Permissions -import com.intellij.platform.eel.fs.EelFileSystemApi.FileChangeType -import com.intellij.platform.eel.fs.EelFileSystemApi.FileWriterCreationMode -import com.intellij.platform.eel.fs.EelFileSystemApi.ReplaceExistingDuringMove import com.intellij.platform.eel.fs.EelFileSystemApi.StatError -import com.intellij.platform.eel.fs.EelFileSystemApi.SymlinkPolicy -import com.intellij.platform.eel.fs.EelFileSystemApi.TimeSinceEpoch import com.intellij.platform.eel.fs.EelFileSystemApi.UnwatchOptions -import com.intellij.platform.eel.fs.EelFileSystemApi.WalkDirectoryOptions.WalkDirectoryEntryOrder -import com.intellij.platform.eel.fs.EelFileSystemApi.WalkDirectoryOptions.WalkDirectoryTraversalOrder +import com.intellij.platform.eel.fs.EelFileSystemApi.WalkDirectoryOptions 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 @@ -231,17 +223,17 @@ object EelFileSystemApiHelpers { private val owner: EelFileSystemApi, private var path: EelPath, ) : OwnedBuilder> { - private var accessTime: TimeSinceEpoch? = null + private var accessTime: EelFileSystemApi.TimeSinceEpoch? = null - private var modificationTime: TimeSinceEpoch? = null + private var modificationTime: EelFileSystemApi.TimeSinceEpoch? = null - private var permissions: Permissions? = null + private var permissions: EelFileInfo.Permissions? = null - fun accessTime(arg: TimeSinceEpoch?): ChangeAttributes = apply { + fun accessTime(arg: EelFileSystemApi.TimeSinceEpoch?): ChangeAttributes = apply { this.accessTime = arg } - fun modificationTime(arg: TimeSinceEpoch?): ChangeAttributes = apply { + fun modificationTime(arg: EelFileSystemApi.TimeSinceEpoch?): ChangeAttributes = apply { this.modificationTime = arg } @@ -249,7 +241,7 @@ object EelFileSystemApiHelpers { this.path = arg } - fun permissions(arg: Permissions?): ChangeAttributes = apply { + fun permissions(arg: EelFileInfo.Permissions?): ChangeAttributes = apply { this.permissions = arg } @@ -441,13 +433,13 @@ object EelFileSystemApiHelpers { private val owner: EelFileSystemApi, private var path: EelPath, ) : OwnedBuilder>, EelFileSystemApi.ListDirectoryError>> { - private var symlinkPolicy: SymlinkPolicy = SymlinkPolicy.DO_NOT_RESOLVE + private var symlinkPolicy: EelFileSystemApi.SymlinkPolicy = EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE fun path(arg: EelPath): ListDirectoryWithAttrs = apply { this.path = arg } - fun symlinkPolicy(arg: SymlinkPolicy): ListDirectoryWithAttrs = apply { + fun symlinkPolicy(arg: EelFileSystemApi.SymlinkPolicy): ListDirectoryWithAttrs = apply { this.symlinkPolicy = arg } @@ -456,20 +448,20 @@ object EelFileSystemApiHelpers { * This option makes the operation a bit more efficient if it is not interested in symlinks. */ fun doNotResolve(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.DO_NOT_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE) /** * Resolves a symlink and returns the information about the target of the symlink, * But does not perform anything on the target of the symlink itself. */ fun justResolve(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.JUST_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.JUST_RESOLVE) /** * Resolves a symlink, follows it, and performs the required operation on target. */ fun resolveAndFollow(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.RESOLVE_AND_FOLLOW) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.RESOLVE_AND_FOLLOW) /** * Complete the builder and call [com.intellij.platform.eel.fs.EelFileSystemApi.listDirectoryWithAttrs] @@ -497,25 +489,25 @@ object EelFileSystemApiHelpers { ) : OwnedBuilder> { private var followLinks: Boolean = false - private var replaceExisting: ReplaceExistingDuringMove = ReplaceExistingDuringMove.REPLACE_EVERYTHING + private var replaceExisting: EelFileSystemApi.ReplaceExistingDuringMove = EelFileSystemApi.ReplaceExistingDuringMove.REPLACE_EVERYTHING fun followLinks(arg: Boolean): Move = apply { this.followLinks = arg } - fun replaceExisting(arg: ReplaceExistingDuringMove): Move = apply { + fun replaceExisting(arg: EelFileSystemApi.ReplaceExistingDuringMove): Move = apply { this.replaceExisting = arg } fun doNotReplace(): Move = - replaceExisting(ReplaceExistingDuringMove.DO_NOT_REPLACE) + replaceExisting(EelFileSystemApi.ReplaceExistingDuringMove.DO_NOT_REPLACE) /** For compatibility with Java NIO. */ fun doNotReplaceDirectories(): Move = - replaceExisting(ReplaceExistingDuringMove.DO_NOT_REPLACE_DIRECTORIES) + replaceExisting(EelFileSystemApi.ReplaceExistingDuringMove.DO_NOT_REPLACE_DIRECTORIES) fun replaceEverything(): Move = - replaceExisting(ReplaceExistingDuringMove.REPLACE_EVERYTHING) + replaceExisting(EelFileSystemApi.ReplaceExistingDuringMove.REPLACE_EVERYTHING) fun source(arg: EelPath): Move = apply { this.source = arg @@ -700,13 +692,13 @@ object EelFileSystemApiHelpers { private val owner: EelFileSystemApi, private var path: EelPath, ) : OwnedBuilder> { - private var symlinkPolicy: SymlinkPolicy = SymlinkPolicy.DO_NOT_RESOLVE + private var symlinkPolicy: EelFileSystemApi.SymlinkPolicy = EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE fun path(arg: EelPath): Stat = apply { this.path = arg } - fun symlinkPolicy(arg: SymlinkPolicy): Stat = apply { + fun symlinkPolicy(arg: EelFileSystemApi.SymlinkPolicy): Stat = apply { this.symlinkPolicy = arg } @@ -715,20 +707,20 @@ object EelFileSystemApiHelpers { * This option makes the operation a bit more efficient if it is not interested in symlinks. */ fun doNotResolve(): Stat = - symlinkPolicy(SymlinkPolicy.DO_NOT_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE) /** * Resolves a symlink and returns the information about the target of the symlink, * But does not perform anything on the target of the symlink itself. */ fun justResolve(): Stat = - symlinkPolicy(SymlinkPolicy.JUST_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.JUST_RESOLVE) /** * Resolves a symlink, follows it, and performs the required operation on target. */ fun resolveAndFollow(): Stat = - symlinkPolicy(SymlinkPolicy.RESOLVE_AND_FOLLOW) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.RESOLVE_AND_FOLLOW) /** * Complete the builder and call [com.intellij.platform.eel.fs.EelFileSystemApi.stat] @@ -781,7 +773,7 @@ object EelFileSystemApiHelpers { private val owner: EelFileSystemApi, private var path: EelPath, ) : OwnedBuilder> { - private var entryOrder: WalkDirectoryEntryOrder = WalkDirectoryEntryOrder.RANDOM + private var entryOrder: WalkDirectoryOptions.WalkDirectoryEntryOrder = WalkDirectoryOptions.WalkDirectoryEntryOrder.RANDOM private var fileContentsHash: Boolean = false @@ -789,7 +781,7 @@ object EelFileSystemApiHelpers { private var readMetadata: Boolean = false - private var traversalOrder: WalkDirectoryTraversalOrder = WalkDirectoryTraversalOrder.DFS + private var traversalOrder: WalkDirectoryOptions.WalkDirectoryTraversalOrder = WalkDirectoryOptions.WalkDirectoryTraversalOrder.DFS private var yieldDirectories: Boolean = true @@ -802,7 +794,7 @@ object EelFileSystemApiHelpers { /** * The default is RANDOM. */ - fun entryOrder(arg: WalkDirectoryEntryOrder): WalkDirectory = apply { + fun entryOrder(arg: WalkDirectoryOptions.WalkDirectoryEntryOrder): WalkDirectory = apply { this.entryOrder = arg } @@ -810,14 +802,14 @@ object EelFileSystemApiHelpers { * Yield directory entries in alphabetical order. */ fun alphabetical(): WalkDirectory = - entryOrder(WalkDirectoryEntryOrder.ALPHABETICAL) + entryOrder(WalkDirectoryOptions.WalkDirectoryEntryOrder.ALPHABETICAL) /** * Yield directory entries in order in which they appear on the file system. * If you do not care for the order of the files, this is the preferable option. */ fun random(): WalkDirectory = - entryOrder(WalkDirectoryEntryOrder.RANDOM) + entryOrder(WalkDirectoryOptions.WalkDirectoryEntryOrder.RANDOM) /** * Yield hash of the regular file's contents. Contents are hashed using xxHash. Default is false. @@ -866,7 +858,7 @@ object EelFileSystemApiHelpers { /** * The default is DFS. */ - fun traversalOrder(arg: WalkDirectoryTraversalOrder): WalkDirectory = apply { + fun traversalOrder(arg: WalkDirectoryOptions.WalkDirectoryTraversalOrder): WalkDirectory = apply { this.traversalOrder = arg } @@ -889,7 +881,7 @@ object EelFileSystemApiHelpers { * ``` */ fun bfs(): WalkDirectory = - traversalOrder(WalkDirectoryTraversalOrder.BFS) + traversalOrder(WalkDirectoryOptions.WalkDirectoryTraversalOrder.BFS) /** * Depth-first traversal, where directory entries are yielded in order they are encountered. @@ -911,7 +903,7 @@ object EelFileSystemApiHelpers { * ``` */ fun dfs(): WalkDirectory = - traversalOrder(WalkDirectoryTraversalOrder.DFS) + traversalOrder(WalkDirectoryOptions.WalkDirectoryTraversalOrder.DFS) /** * Default is true. @@ -971,15 +963,15 @@ object EelFileSystemApiHelpers { class AddWatchRoots( private val owner: EelFileSystemApi, ) : OwnedBuilder { - private var changeTypes: Set = emptySet() + private var changeTypes: Set = emptySet() - private var paths: Set = emptySet() + private var paths: Set = emptySet() - fun changeTypes(arg: Set): AddWatchRoots = apply { + fun changeTypes(arg: Set): AddWatchRoots = apply { this.changeTypes = arg } - fun paths(arg: Set): AddWatchRoots = apply { + fun paths(arg: Set): AddWatchRoots = apply { this.paths = arg } @@ -1008,7 +1000,7 @@ object EelFileSystemApiHelpers { ) : OwnedBuilder> { private var append: Boolean = false - private var creationMode: FileWriterCreationMode = FileWriterCreationMode.ALLOW_CREATE + private var creationMode: EelFileSystemApi.FileWriterCreationMode = EelFileSystemApi.FileWriterCreationMode.ALLOW_CREATE private var truncateExisting: Boolean = true @@ -1016,18 +1008,18 @@ object EelFileSystemApiHelpers { this.append = arg } - fun creationMode(arg: FileWriterCreationMode): OpenForReadingAndWriting = apply { + fun creationMode(arg: EelFileSystemApi.FileWriterCreationMode): OpenForReadingAndWriting = apply { this.creationMode = arg } fun allowCreate(): OpenForReadingAndWriting = - creationMode(FileWriterCreationMode.ALLOW_CREATE) + creationMode(EelFileSystemApi.FileWriterCreationMode.ALLOW_CREATE) fun onlyCreate(): OpenForReadingAndWriting = - creationMode(FileWriterCreationMode.ONLY_CREATE) + creationMode(EelFileSystemApi.FileWriterCreationMode.ONLY_CREATE) fun onlyOpenExisting(): OpenForReadingAndWriting = - creationMode(FileWriterCreationMode.ONLY_OPEN_EXISTING) + creationMode(EelFileSystemApi.FileWriterCreationMode.ONLY_OPEN_EXISTING) fun path(arg: EelPath): OpenForReadingAndWriting = apply { this.path = arg @@ -1064,7 +1056,7 @@ object EelFileSystemApiHelpers { ) : OwnedBuilder> { private var append: Boolean = false - private var creationMode: FileWriterCreationMode = FileWriterCreationMode.ALLOW_CREATE + private var creationMode: EelFileSystemApi.FileWriterCreationMode = EelFileSystemApi.FileWriterCreationMode.ALLOW_CREATE private var truncateExisting: Boolean = true @@ -1072,18 +1064,18 @@ object EelFileSystemApiHelpers { this.append = arg } - fun creationMode(arg: FileWriterCreationMode): OpenForWriting = apply { + fun creationMode(arg: EelFileSystemApi.FileWriterCreationMode): OpenForWriting = apply { this.creationMode = arg } fun allowCreate(): OpenForWriting = - creationMode(FileWriterCreationMode.ALLOW_CREATE) + creationMode(EelFileSystemApi.FileWriterCreationMode.ALLOW_CREATE) fun onlyCreate(): OpenForWriting = - creationMode(FileWriterCreationMode.ONLY_CREATE) + creationMode(EelFileSystemApi.FileWriterCreationMode.ONLY_CREATE) fun onlyOpenExisting(): OpenForWriting = - creationMode(FileWriterCreationMode.ONLY_OPEN_EXISTING) + creationMode(EelFileSystemApi.FileWriterCreationMode.ONLY_OPEN_EXISTING) fun path(arg: EelPath): OpenForWriting = apply { this.path = arg diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemPosixApiHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemPosixApiHelpers.kt index 01e11e7f38fe..09b40f8ee89c 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemPosixApiHelpers.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemPosixApiHelpers.kt @@ -8,7 +8,6 @@ import com.intellij.platform.eel.EelResult import com.intellij.platform.eel.GeneratedBuilder 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 @@ -45,13 +44,13 @@ object EelFileSystemPosixApiHelpers { private val owner: EelFileSystemPosixApi, private var path: EelPath, ) : OwnedBuilder>, EelFileSystemApi.ListDirectoryError>> { - private var symlinkPolicy: SymlinkPolicy = SymlinkPolicy.DO_NOT_RESOLVE + private var symlinkPolicy: EelFileSystemApi.SymlinkPolicy = EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE fun path(arg: EelPath): ListDirectoryWithAttrs = apply { this.path = arg } - fun symlinkPolicy(arg: SymlinkPolicy): ListDirectoryWithAttrs = apply { + fun symlinkPolicy(arg: EelFileSystemApi.SymlinkPolicy): ListDirectoryWithAttrs = apply { this.symlinkPolicy = arg } @@ -60,20 +59,20 @@ object EelFileSystemPosixApiHelpers { * This option makes the operation a bit more efficient if it is not interested in symlinks. */ fun doNotResolve(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.DO_NOT_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE) /** * Resolves a symlink and returns the information about the target of the symlink, * But does not perform anything on the target of the symlink itself. */ fun justResolve(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.JUST_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.JUST_RESOLVE) /** * Resolves a symlink, follows it, and performs the required operation on target. */ fun resolveAndFollow(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.RESOLVE_AND_FOLLOW) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.RESOLVE_AND_FOLLOW) /** * Complete the builder and call [com.intellij.platform.eel.fs.EelFileSystemPosixApi.listDirectoryWithAttrs] @@ -98,13 +97,13 @@ object EelFileSystemPosixApiHelpers { private val owner: EelFileSystemPosixApi, private var path: EelPath, ) : OwnedBuilder> { - private var symlinkPolicy: SymlinkPolicy = SymlinkPolicy.DO_NOT_RESOLVE + private var symlinkPolicy: EelFileSystemApi.SymlinkPolicy = EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE fun path(arg: EelPath): Stat = apply { this.path = arg } - fun symlinkPolicy(arg: SymlinkPolicy): Stat = apply { + fun symlinkPolicy(arg: EelFileSystemApi.SymlinkPolicy): Stat = apply { this.symlinkPolicy = arg } @@ -113,20 +112,20 @@ object EelFileSystemPosixApiHelpers { * This option makes the operation a bit more efficient if it is not interested in symlinks. */ fun doNotResolve(): Stat = - symlinkPolicy(SymlinkPolicy.DO_NOT_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE) /** * Resolves a symlink and returns the information about the target of the symlink, * But does not perform anything on the target of the symlink itself. */ fun justResolve(): Stat = - symlinkPolicy(SymlinkPolicy.JUST_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.JUST_RESOLVE) /** * Resolves a symlink, follows it, and performs the required operation on target. */ fun resolveAndFollow(): Stat = - symlinkPolicy(SymlinkPolicy.RESOLVE_AND_FOLLOW) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.RESOLVE_AND_FOLLOW) /** * Complete the builder and call [com.intellij.platform.eel.fs.EelFileSystemPosixApi.stat] diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemWindowsApiHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemWindowsApiHelpers.kt index 54faaa7e53d4..af573407597e 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemWindowsApiHelpers.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/EelFileSystemWindowsApiHelpers.kt @@ -8,7 +8,6 @@ import com.intellij.platform.eel.EelResult import com.intellij.platform.eel.GeneratedBuilder 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 @@ -45,13 +44,13 @@ object EelFileSystemWindowsApiHelpers { private val owner: EelFileSystemWindowsApi, private var path: EelPath, ) : OwnedBuilder>, EelFileSystemApi.ListDirectoryError>> { - private var symlinkPolicy: SymlinkPolicy = SymlinkPolicy.DO_NOT_RESOLVE + private var symlinkPolicy: EelFileSystemApi.SymlinkPolicy = EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE fun path(arg: EelPath): ListDirectoryWithAttrs = apply { this.path = arg } - fun symlinkPolicy(arg: SymlinkPolicy): ListDirectoryWithAttrs = apply { + fun symlinkPolicy(arg: EelFileSystemApi.SymlinkPolicy): ListDirectoryWithAttrs = apply { this.symlinkPolicy = arg } @@ -60,20 +59,20 @@ object EelFileSystemWindowsApiHelpers { * This option makes the operation a bit more efficient if it is not interested in symlinks. */ fun doNotResolve(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.DO_NOT_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE) /** * Resolves a symlink and returns the information about the target of the symlink, * But does not perform anything on the target of the symlink itself. */ fun justResolve(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.JUST_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.JUST_RESOLVE) /** * Resolves a symlink, follows it, and performs the required operation on target. */ fun resolveAndFollow(): ListDirectoryWithAttrs = - symlinkPolicy(SymlinkPolicy.RESOLVE_AND_FOLLOW) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.RESOLVE_AND_FOLLOW) /** * Complete the builder and call [com.intellij.platform.eel.fs.EelFileSystemWindowsApi.listDirectoryWithAttrs] @@ -98,13 +97,13 @@ object EelFileSystemWindowsApiHelpers { private val owner: EelFileSystemWindowsApi, private var path: EelPath, ) : OwnedBuilder> { - private var symlinkPolicy: SymlinkPolicy = SymlinkPolicy.DO_NOT_RESOLVE + private var symlinkPolicy: EelFileSystemApi.SymlinkPolicy = EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE fun path(arg: EelPath): Stat = apply { this.path = arg } - fun symlinkPolicy(arg: SymlinkPolicy): Stat = apply { + fun symlinkPolicy(arg: EelFileSystemApi.SymlinkPolicy): Stat = apply { this.symlinkPolicy = arg } @@ -113,20 +112,20 @@ object EelFileSystemWindowsApiHelpers { * This option makes the operation a bit more efficient if it is not interested in symlinks. */ fun doNotResolve(): Stat = - symlinkPolicy(SymlinkPolicy.DO_NOT_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE) /** * Resolves a symlink and returns the information about the target of the symlink, * But does not perform anything on the target of the symlink itself. */ fun justResolve(): Stat = - symlinkPolicy(SymlinkPolicy.JUST_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.JUST_RESOLVE) /** * Resolves a symlink, follows it, and performs the required operation on target. */ fun resolveAndFollow(): Stat = - symlinkPolicy(SymlinkPolicy.RESOLVE_AND_FOLLOW) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.RESOLVE_AND_FOLLOW) /** * Complete the builder and call [com.intellij.platform.eel.fs.EelFileSystemWindowsApi.stat] diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/ListDirectoryWithAttrsArgsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/ListDirectoryWithAttrsArgsBuilder.kt index 19fc64871260..9322da6057da 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/ListDirectoryWithAttrsArgsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/ListDirectoryWithAttrsArgsBuilder.kt @@ -6,7 +6,6 @@ package com.intellij.platform.eel.fs 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 @@ -16,13 +15,13 @@ import org.jetbrains.annotations.ApiStatus class ListDirectoryWithAttrsArgsBuilder( private var path: EelPath, ) { - private var symlinkPolicy: SymlinkPolicy = SymlinkPolicy.DO_NOT_RESOLVE + private var symlinkPolicy: EelFileSystemApi.SymlinkPolicy = EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE fun path(arg: EelPath): ListDirectoryWithAttrsArgsBuilder = apply { this.path = arg } - fun symlinkPolicy(arg: SymlinkPolicy): ListDirectoryWithAttrsArgsBuilder = apply { + fun symlinkPolicy(arg: EelFileSystemApi.SymlinkPolicy): ListDirectoryWithAttrsArgsBuilder = apply { this.symlinkPolicy = arg } @@ -31,20 +30,20 @@ class ListDirectoryWithAttrsArgsBuilder( * This option makes the operation a bit more efficient if it is not interested in symlinks. */ fun doNotResolve(): ListDirectoryWithAttrsArgsBuilder = - symlinkPolicy(SymlinkPolicy.DO_NOT_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE) /** * Resolves a symlink and returns the information about the target of the symlink, * But does not perform anything on the target of the symlink itself. */ fun justResolve(): ListDirectoryWithAttrsArgsBuilder = - symlinkPolicy(SymlinkPolicy.JUST_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.JUST_RESOLVE) /** * Resolves a symlink, follows it, and performs the required operation on target. */ fun resolveAndFollow(): ListDirectoryWithAttrsArgsBuilder = - symlinkPolicy(SymlinkPolicy.RESOLVE_AND_FOLLOW) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.RESOLVE_AND_FOLLOW) fun build(): ListDirectoryWithAttrsArgs = ListDirectoryWithAttrsArgsImpl( @@ -56,5 +55,5 @@ class ListDirectoryWithAttrsArgsBuilder( @GeneratedBuilder.Result internal class ListDirectoryWithAttrsArgsImpl( override val path: EelPath, - override val symlinkPolicy: SymlinkPolicy, + override val symlinkPolicy: EelFileSystemApi.SymlinkPolicy, ) : ListDirectoryWithAttrsArgs \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/MoveArgsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/MoveArgsBuilder.kt index 0f15bd95e7e5..802d09853fc1 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/MoveArgsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/MoveArgsBuilder.kt @@ -6,7 +6,6 @@ package com.intellij.platform.eel.fs 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 @@ -19,25 +18,25 @@ class MoveArgsBuilder( ) { private var followLinks: Boolean = false - private var replaceExisting: ReplaceExistingDuringMove = ReplaceExistingDuringMove.REPLACE_EVERYTHING + private var replaceExisting: EelFileSystemApi.ReplaceExistingDuringMove = EelFileSystemApi.ReplaceExistingDuringMove.REPLACE_EVERYTHING fun followLinks(arg: Boolean): MoveArgsBuilder = apply { this.followLinks = arg } - fun replaceExisting(arg: ReplaceExistingDuringMove): MoveArgsBuilder = apply { + fun replaceExisting(arg: EelFileSystemApi.ReplaceExistingDuringMove): MoveArgsBuilder = apply { this.replaceExisting = arg } fun doNotReplace(): MoveArgsBuilder = - replaceExisting(ReplaceExistingDuringMove.DO_NOT_REPLACE) + replaceExisting(EelFileSystemApi.ReplaceExistingDuringMove.DO_NOT_REPLACE) /** For compatibility with Java NIO. */ fun doNotReplaceDirectories(): MoveArgsBuilder = - replaceExisting(ReplaceExistingDuringMove.DO_NOT_REPLACE_DIRECTORIES) + replaceExisting(EelFileSystemApi.ReplaceExistingDuringMove.DO_NOT_REPLACE_DIRECTORIES) fun replaceEverything(): MoveArgsBuilder = - replaceExisting(ReplaceExistingDuringMove.REPLACE_EVERYTHING) + replaceExisting(EelFileSystemApi.ReplaceExistingDuringMove.REPLACE_EVERYTHING) fun source(arg: EelPath): MoveArgsBuilder = apply { this.source = arg @@ -59,7 +58,7 @@ class MoveArgsBuilder( @GeneratedBuilder.Result internal class MoveArgsImpl( override val followLinks: Boolean, - override val replaceExisting: ReplaceExistingDuringMove, + override val replaceExisting: EelFileSystemApi.ReplaceExistingDuringMove, override val source: EelPath, override val target: EelPath, ) : MoveArgs \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/StatArgsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/StatArgsBuilder.kt index 2c0dbd942071..a22004c4ca6f 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/StatArgsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/StatArgsBuilder.kt @@ -6,7 +6,6 @@ package com.intellij.platform.eel.fs 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 @@ -16,13 +15,13 @@ import org.jetbrains.annotations.ApiStatus class StatArgsBuilder( private var path: EelPath, ) { - private var symlinkPolicy: SymlinkPolicy = SymlinkPolicy.DO_NOT_RESOLVE + private var symlinkPolicy: EelFileSystemApi.SymlinkPolicy = EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE fun path(arg: EelPath): StatArgsBuilder = apply { this.path = arg } - fun symlinkPolicy(arg: SymlinkPolicy): StatArgsBuilder = apply { + fun symlinkPolicy(arg: EelFileSystemApi.SymlinkPolicy): StatArgsBuilder = apply { this.symlinkPolicy = arg } @@ -31,20 +30,20 @@ class StatArgsBuilder( * This option makes the operation a bit more efficient if it is not interested in symlinks. */ fun doNotResolve(): StatArgsBuilder = - symlinkPolicy(SymlinkPolicy.DO_NOT_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.DO_NOT_RESOLVE) /** * Resolves a symlink and returns the information about the target of the symlink, * But does not perform anything on the target of the symlink itself. */ fun justResolve(): StatArgsBuilder = - symlinkPolicy(SymlinkPolicy.JUST_RESOLVE) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.JUST_RESOLVE) /** * Resolves a symlink, follows it, and performs the required operation on target. */ fun resolveAndFollow(): StatArgsBuilder = - symlinkPolicy(SymlinkPolicy.RESOLVE_AND_FOLLOW) + symlinkPolicy(EelFileSystemApi.SymlinkPolicy.RESOLVE_AND_FOLLOW) fun build(): StatArgs = StatArgsImpl( @@ -56,5 +55,5 @@ class StatArgsBuilder( @GeneratedBuilder.Result internal class StatArgsImpl( override val path: EelPath, - override val symlinkPolicy: SymlinkPolicy, + override val symlinkPolicy: EelFileSystemApi.SymlinkPolicy, ) : StatArgs \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/WalkDirectoryOptionsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/WalkDirectoryOptionsBuilder.kt index 013e4c4a485d..a9c711ba091b 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/WalkDirectoryOptionsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/WalkDirectoryOptionsBuilder.kt @@ -6,8 +6,6 @@ package com.intellij.platform.eel.fs import com.intellij.platform.eel.GeneratedBuilder import com.intellij.platform.eel.fs.EelFileSystemApi.WalkDirectoryOptions -import com.intellij.platform.eel.fs.EelFileSystemApi.WalkDirectoryOptions.WalkDirectoryEntryOrder -import com.intellij.platform.eel.fs.EelFileSystemApi.WalkDirectoryOptions.WalkDirectoryTraversalOrder import com.intellij.platform.eel.path.EelPath import org.jetbrains.annotations.ApiStatus @@ -20,7 +18,7 @@ class WalkDirectoryOptionsBuilder( */ private var path: EelPath, ) { - private var entryOrder: WalkDirectoryEntryOrder = WalkDirectoryEntryOrder.RANDOM + private var entryOrder: WalkDirectoryOptions.WalkDirectoryEntryOrder = WalkDirectoryOptions.WalkDirectoryEntryOrder.RANDOM private var fileContentsHash: Boolean = false @@ -28,7 +26,7 @@ class WalkDirectoryOptionsBuilder( private var readMetadata: Boolean = false - private var traversalOrder: WalkDirectoryTraversalOrder = WalkDirectoryTraversalOrder.DFS + private var traversalOrder: WalkDirectoryOptions.WalkDirectoryTraversalOrder = WalkDirectoryOptions.WalkDirectoryTraversalOrder.DFS private var yieldDirectories: Boolean = true @@ -41,7 +39,7 @@ class WalkDirectoryOptionsBuilder( /** * The default is RANDOM. */ - fun entryOrder(arg: WalkDirectoryEntryOrder): WalkDirectoryOptionsBuilder = apply { + fun entryOrder(arg: WalkDirectoryOptions.WalkDirectoryEntryOrder): WalkDirectoryOptionsBuilder = apply { this.entryOrder = arg } @@ -49,14 +47,14 @@ class WalkDirectoryOptionsBuilder( * Yield directory entries in alphabetical order. */ fun alphabetical(): WalkDirectoryOptionsBuilder = - entryOrder(WalkDirectoryEntryOrder.ALPHABETICAL) + entryOrder(WalkDirectoryOptions.WalkDirectoryEntryOrder.ALPHABETICAL) /** * Yield directory entries in order in which they appear on the file system. * If you do not care for the order of the files, this is the preferable option. */ fun random(): WalkDirectoryOptionsBuilder = - entryOrder(WalkDirectoryEntryOrder.RANDOM) + entryOrder(WalkDirectoryOptions.WalkDirectoryEntryOrder.RANDOM) /** * Yield hash of the regular file's contents. Contents are hashed using xxHash. Default is false. @@ -105,7 +103,7 @@ class WalkDirectoryOptionsBuilder( /** * The default is DFS. */ - fun traversalOrder(arg: WalkDirectoryTraversalOrder): WalkDirectoryOptionsBuilder = apply { + fun traversalOrder(arg: WalkDirectoryOptions.WalkDirectoryTraversalOrder): WalkDirectoryOptionsBuilder = apply { this.traversalOrder = arg } @@ -128,7 +126,7 @@ class WalkDirectoryOptionsBuilder( * ``` */ fun bfs(): WalkDirectoryOptionsBuilder = - traversalOrder(WalkDirectoryTraversalOrder.BFS) + traversalOrder(WalkDirectoryOptions.WalkDirectoryTraversalOrder.BFS) /** * Depth-first traversal, where directory entries are yielded in order they are encountered. @@ -150,7 +148,7 @@ class WalkDirectoryOptionsBuilder( * ``` */ fun dfs(): WalkDirectoryOptionsBuilder = - traversalOrder(WalkDirectoryTraversalOrder.DFS) + traversalOrder(WalkDirectoryOptions.WalkDirectoryTraversalOrder.DFS) /** * Default is true. @@ -197,12 +195,12 @@ class WalkDirectoryOptionsBuilder( @GeneratedBuilder.Result internal class WalkDirectoryOptionsImpl( - override val entryOrder: WalkDirectoryEntryOrder, + override val entryOrder: WalkDirectoryOptions.WalkDirectoryEntryOrder, override val fileContentsHash: Boolean, override val maxDepth: Int, override val path: EelPath, override val readMetadata: Boolean, - override val traversalOrder: WalkDirectoryTraversalOrder, + override val traversalOrder: WalkDirectoryOptions.WalkDirectoryTraversalOrder, override val yieldDirectories: Boolean, override val yieldOtherFileTypes: Boolean, override val yieldRegularFiles: Boolean, diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/WatchOptionsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/WatchOptionsBuilder.kt index 6c42e6a3ded2..ed7305b12bbf 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/WatchOptionsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/WatchOptionsBuilder.kt @@ -5,24 +5,22 @@ package com.intellij.platform.eel.fs 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 = emptySet() + private var changeTypes: Set = emptySet() - private var paths: Set = emptySet() + private var paths: Set = emptySet() - fun changeTypes(arg: Set): WatchOptionsBuilder = apply { + fun changeTypes(arg: Set): WatchOptionsBuilder = apply { this.changeTypes = arg } - fun paths(arg: Set): WatchOptionsBuilder = apply { + fun paths(arg: Set): WatchOptionsBuilder = apply { this.paths = arg } @@ -35,6 +33,6 @@ class WatchOptionsBuilder { @GeneratedBuilder.Result internal class WatchOptionsImpl( - override val changeTypes: Set, - override val paths: Set, + override val changeTypes: Set, + override val paths: Set, ) : WatchOptions \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/fs/WriteOptionsBuilder.kt b/platform/eel/gen-builders/com/intellij/platform/eel/fs/WriteOptionsBuilder.kt index c3c084c626e6..62e53efcc31d 100644 --- a/platform/eel/gen-builders/com/intellij/platform/eel/fs/WriteOptionsBuilder.kt +++ b/platform/eel/gen-builders/com/intellij/platform/eel/fs/WriteOptionsBuilder.kt @@ -5,7 +5,6 @@ package com.intellij.platform.eel.fs 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 @@ -18,7 +17,7 @@ class WriteOptionsBuilder( ) { private var append: Boolean = false - private var creationMode: FileWriterCreationMode = FileWriterCreationMode.ALLOW_CREATE + private var creationMode: EelFileSystemApi.FileWriterCreationMode = EelFileSystemApi.FileWriterCreationMode.ALLOW_CREATE private var truncateExisting: Boolean = true @@ -26,18 +25,18 @@ class WriteOptionsBuilder( this.append = arg } - fun creationMode(arg: FileWriterCreationMode): WriteOptionsBuilder = apply { + fun creationMode(arg: EelFileSystemApi.FileWriterCreationMode): WriteOptionsBuilder = apply { this.creationMode = arg } fun allowCreate(): WriteOptionsBuilder = - creationMode(FileWriterCreationMode.ALLOW_CREATE) + creationMode(EelFileSystemApi.FileWriterCreationMode.ALLOW_CREATE) fun onlyCreate(): WriteOptionsBuilder = - creationMode(FileWriterCreationMode.ONLY_CREATE) + creationMode(EelFileSystemApi.FileWriterCreationMode.ONLY_CREATE) fun onlyOpenExisting(): WriteOptionsBuilder = - creationMode(FileWriterCreationMode.ONLY_OPEN_EXISTING) + creationMode(EelFileSystemApi.FileWriterCreationMode.ONLY_OPEN_EXISTING) fun path(arg: EelPath): WriteOptionsBuilder = apply { this.path = arg @@ -59,7 +58,7 @@ class WriteOptionsBuilder( @GeneratedBuilder.Result internal class WriteOptionsImpl( override val append: Boolean, - override val creationMode: FileWriterCreationMode, + override val creationMode: EelFileSystemApi.FileWriterCreationMode, override val path: EelPath, override val truncateExisting: Boolean, ) : WriteOptions \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/kotlinAnyHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/kotlinAnyHelpers.kt new file mode 100644 index 000000000000..4b83fc57fa00 --- /dev/null +++ b/platform/eel/gen-builders/com/intellij/platform/eel/kotlinAnyHelpers.kt @@ -0,0 +1,86 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +/** + * This file is generated by [com.intellij.platform.eel.codegen.BuildersGeneratorTest]. + */ +package com.intellij.platform.eel + +import com.intellij.platform.eel.* + + +@GeneratedBuilder.Result +fun Any.foobar2(): kotlinAnyHelpers.Foobar2 = + kotlinAnyHelpers.Foobar2( + owner = this, + ) + +@GeneratedBuilder.Result +fun Any.foobar3(): kotlinAnyHelpers.Foobar3 = + kotlinAnyHelpers.Foobar3( + owner = this, + ) + +object kotlinAnyHelpers { + /** + * Create it via [kotlin.Any.foobar2]. + */ + @GeneratedBuilder.Result + class Foobar2( + private val owner: Any, + ) : OwnedBuilder { + private var bar: Int? = null + + private var foo: String? = null + + fun bar(arg: Int?): Foobar2 = apply { + this.bar = arg + } + + fun foo(arg: String?): Foobar2 = apply { + this.foo = arg + } + + /** + * Complete the builder and call [kotlin.Any.foobar2] + * with an instance of [com.intellij.platform.eel.FoobarOpts]. + */ + override suspend fun eelIt(): Unit = + owner.foobar2( + FoobarOptsImpl( + bar = bar, + foo = foo, + ) + ) + } + + /** + * Create it via [kotlin.Any.foobar3]. + */ + @GeneratedBuilder.Result + class Foobar3( + private val owner: Any, + ) : OwnedBuilder { + private var bar: Int? = null + + private var foo: String? = null + + fun bar(arg: Int?): Foobar3 = apply { + this.bar = arg + } + + fun foo(arg: String?): Foobar3 = apply { + this.foo = arg + } + + /** + * Complete the builder and call [kotlin.Any.foobar3] + * with an instance of [com.intellij.platform.eel.FoobarOpts]. + */ + override suspend fun eelIt(): Unit = + owner.foobar3( + FoobarOptsImpl( + bar = bar, + foo = foo, + ) + ) + } +} \ No newline at end of file diff --git a/platform/eel/gen-builders/com/intellij/platform/eel/kotlinCollectionsMapHelpers.kt b/platform/eel/gen-builders/com/intellij/platform/eel/kotlinCollectionsMapHelpers.kt new file mode 100644 index 000000000000..cb3015ae01be --- /dev/null +++ b/platform/eel/gen-builders/com/intellij/platform/eel/kotlinCollectionsMapHelpers.kt @@ -0,0 +1,48 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +/** + * This file is generated by [com.intellij.platform.eel.codegen.BuildersGeneratorTest]. + */ +package com.intellij.platform.eel + +import com.intellij.platform.eel.* + + +@GeneratedBuilder.Result +fun Map.foobar4(): kotlinCollectionsMapHelpers.Foobar4 = + kotlinCollectionsMapHelpers.Foobar4( + owner = this, + ) + +object kotlinCollectionsMapHelpers { + /** + * Create it via [kotlin.collections.Map.foobar4]. + */ + @GeneratedBuilder.Result + class Foobar4( + private val owner: Map, + ) : OwnedBuilder { + private var bar: Int? = null + + private var foo: String? = null + + fun bar(arg: Int?): Foobar4 = apply { + this.bar = arg + } + + fun foo(arg: String?): Foobar4 = apply { + this.foo = arg + } + + /** + * Complete the builder and call [kotlin.collections.Map.foobar4] + * with an instance of [com.intellij.platform.eel.FoobarOpts]. + */ + override suspend fun eelIt(): Unit = + owner.foobar4( + FoobarOptsImpl( + bar = bar, + foo = foo, + ) + ) + } +} \ No newline at end of file diff --git a/platform/eel/intellij.platform.eel.codegen.iml b/platform/eel/intellij.platform.eel.codegen.iml index caa54cdc839a..0cc0ab4c9675 100644 --- a/platform/eel/intellij.platform.eel.codegen.iml +++ b/platform/eel/intellij.platform.eel.codegen.iml @@ -25,5 +25,6 @@ + \ No newline at end of file diff --git a/platform/eel/src/com/intellij/platform/eel/TmpExample.kt b/platform/eel/src/com/intellij/platform/eel/TmpExample.kt new file mode 100644 index 000000000000..9cce66e66d22 --- /dev/null +++ b/platform/eel/src/com/intellij/platform/eel/TmpExample.kt @@ -0,0 +1,56 @@ +// 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 + +fun foobar1(@GeneratedBuilder opts: FoobarOpts) { + println("foobar1") + println(opts.foo) + println(opts.bar) +} + +fun Any.foobar2(@GeneratedBuilder opts: FoobarOpts) { + println("foobar2") + println(this) + println(opts.foo) + println(opts.bar) +} + +fun Any.foobar3(@GeneratedBuilder opts: FoobarOpts) { + println("foobar3") + println(this) + println(opts.foo) + println(opts.bar) +} + +fun Map.foobar4(@GeneratedBuilder opts: FoobarOpts) { + println("foobar4") + println(this) + println(opts.foo) + println(opts.bar) +} + +class OurThing + +fun OurThing.foobar5(@GeneratedBuilder opts: FoobarOpts) { + println("foobar5") + println(this) + println(opts.foo) + println(opts.bar) +} + +fun OurThingHelpers.Foobar5.hurrDurr() = apply { + foo("hurr durr") + bar(31337) +} + +interface FoobarOpts { + val foo: String? get() = null + val bar: Int? get() = null +} + +suspend fun main() { + foobar1().foo("123").bar(456).eelIt() + (3.14159).foobar2().foo("xxx").eelIt() + (3.14159).foobar3().foo("yyy").eelIt() + mapOf("a" to "b").foobar4().foo("zzz").eelIt() + OurThing().foobar5().hurrDurr().eelIt() +} \ No newline at end of file