From 1e1d07600e1199ad55544871da06ba883eb035c1 Mon Sep 17 00:00:00 2001 From: Nikita Klimenko Date: Tue, 19 Nov 2024 14:08:54 +0200 Subject: [PATCH] Add `df.properties()` function to improve visibility of generated API for typed column access --- core/api/core.api | 7 +- .../kotlinx/dataframe/ColumnsContainer.kt | 6 +- .../kotlinx/dataframe/ColumnsScope.kt | 12 +++ .../kotlinx/dataframe/api/DataFrameGet.kt | 23 +++++ .../impl/codeGen/CodeGeneratorImpl.kt | 5 +- .../dataframe/codeGen/CodeGenerationTests.kt | 4 +- .../dataframe/codeGen/ReplCodeGenTests.kt | 8 +- .../plugin/extensions/IrBodyFiller.kt | 4 +- .../plugin/extensions/TokenGenerator.kt | 2 +- .../kotlinx/dataframe/plugin/utils/Names.kt | 6 ++ .../testData/box/propertiesOrder.fir.txt | 10 +-- .../diagnostics/selectDuringTyping.fir.txt | 2 +- .../diagnostics/toDataFrame_java.fir.txt | 8 +- .../dataframe/ksp/ExtensionsGenerator.kt | 2 +- .../ksp/DataFrameSymbolProcessorTest.kt | 90 +++++++++---------- 15 files changed, 119 insertions(+), 70 deletions(-) create mode 100644 core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsScope.kt diff --git a/core/api/core.api b/core/api/core.api index 0d9aa53c8e..9eaa3b3e89 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -192,7 +192,7 @@ public final class org/jetbrains/dataframe/keywords/SoftKeywords$Companion { public final fun getVALUES ()Ljava/util/List; } -public abstract interface class org/jetbrains/kotlinx/dataframe/ColumnsContainer { +public abstract interface class org/jetbrains/kotlinx/dataframe/ColumnsContainer : org/jetbrains/kotlinx/dataframe/ColumnsScope { public abstract fun columns ()Ljava/util/List; public abstract fun columnsCount ()I public abstract fun containsColumn (Ljava/lang/String;)Z @@ -234,6 +234,10 @@ public final class org/jetbrains/kotlinx/dataframe/ColumnsContainer$DefaultImpls public static fun get (Lorg/jetbrains/kotlinx/dataframe/ColumnsContainer;Lorg/jetbrains/kotlinx/dataframe/columns/ColumnReference;)Lorg/jetbrains/kotlinx/dataframe/columns/FrameColumn; } +public abstract interface class org/jetbrains/kotlinx/dataframe/ColumnsScope { + public abstract fun get (Ljava/lang/String;)Lorg/jetbrains/kotlinx/dataframe/DataColumn; +} + public abstract interface class org/jetbrains/kotlinx/dataframe/DataColumn : org/jetbrains/kotlinx/dataframe/columns/BaseColumn { public static final field Companion Lorg/jetbrains/kotlinx/dataframe/DataColumn$Companion; public abstract fun distinct ()Lorg/jetbrains/kotlinx/dataframe/DataColumn; @@ -4206,6 +4210,7 @@ public final class org/jetbrains/kotlinx/dataframe/api/DataFrameGetKt { public static final fun getOrNull (Lorg/jetbrains/kotlinx/dataframe/DataFrame;I)Lorg/jetbrains/kotlinx/dataframe/DataRow; public static final fun getRows (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Ljava/lang/Iterable;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; public static final fun getRows (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Lkotlin/ranges/IntRange;)Lorg/jetbrains/kotlinx/dataframe/DataFrame; + public static final fun properties (Lorg/jetbrains/kotlinx/dataframe/DataFrame;)Lorg/jetbrains/kotlinx/dataframe/ColumnsScope; public static final fun rows (Lorg/jetbrains/kotlinx/dataframe/DataFrame;)Ljava/lang/Iterable; public static final fun rowsReversed (Lorg/jetbrains/kotlinx/dataframe/DataFrame;)Ljava/lang/Iterable; } diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt index 85af9ee021..0203cf7e69 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsContainer.kt @@ -18,9 +18,9 @@ import kotlin.reflect.KProperty * * Base interface for [DataFrame] and [ColumnSelectionDsl] * - * @param T Schema marker. Used to generate extension properties for typed column access. + * @param T Schema marker. Used to resolve generated extension properties for typed column access. */ -public interface ColumnsContainer { +public interface ColumnsContainer : ColumnsScope { // region columns @@ -54,7 +54,7 @@ public interface ColumnsContainer { // region get - public operator fun get(columnName: String): AnyCol = getColumn(columnName) + public override operator fun get(columnName: String): AnyCol = getColumn(columnName) public operator fun get(columnPath: ColumnPath): AnyCol = getColumn(columnPath) diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsScope.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsScope.kt new file mode 100644 index 0000000000..3ef0bdafe3 --- /dev/null +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/ColumnsScope.kt @@ -0,0 +1,12 @@ +package org.jetbrains.kotlinx.dataframe + +/** + * Provides minimal API required for generated column properties: + * + * `val ColumnsScope.column: DataColumn get() = this["column"] as DataColumn` + * + * @param T Schema marker. Used to resolve generated extension properties for typed column access. + */ +public interface ColumnsScope { + public operator fun get(columnName: String): AnyCol +} diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataFrameGet.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataFrameGet.kt index c5322aa2ef..e6ce2fbf85 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataFrameGet.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/DataFrameGet.kt @@ -4,6 +4,7 @@ import org.jetbrains.kotlinx.dataframe.AnyCol import org.jetbrains.kotlinx.dataframe.AnyColumnReference import org.jetbrains.kotlinx.dataframe.ColumnSelector import org.jetbrains.kotlinx.dataframe.ColumnsContainer +import org.jetbrains.kotlinx.dataframe.ColumnsScope import org.jetbrains.kotlinx.dataframe.ColumnsSelector import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame @@ -58,6 +59,28 @@ public fun ColumnsContainer.getFrameColumn(columnName: String): FrameColu public fun ColumnsContainer.getColumnGroup(columnPath: ColumnPath): ColumnGroup<*> = get(columnPath).asColumnGroup() +/** + * Utility property to access scope with only dataframe column properties for code completion, + * filtering out DataFrame API. + * + * It's a quick way to check that code generation in notebooks or compiler plugin + * worked as expected or find columns you're interested in. + * + * In notebooks: + * ``` + * val df = DataFrame.read("file.csv") + * ==== next code cell + * df. // column properties are mixed together with methods, not easy to find unless you already know names + * df.properties(). // easy to overview available columns + * ``` + * In compiler plugin: + * ``` + * val df = @Import DataFrame.read("file.csv") + * df.properties(). + * ``` + */ +public fun DataFrame.properties(): ColumnsScope = this + // region getColumn public fun ColumnsContainer.getColumn(name: String): AnyCol = diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt index c4f0d5eb4d..689fab953a 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt @@ -12,6 +12,7 @@ import org.jetbrains.dataframe.impl.codeGen.InterfaceGenerationMode.WithFields import org.jetbrains.dataframe.keywords.HardKeywords import org.jetbrains.dataframe.keywords.ModifierKeywords import org.jetbrains.kotlinx.dataframe.ColumnsContainer +import org.jetbrains.kotlinx.dataframe.ColumnsScope import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataFrame import org.jetbrains.kotlinx.dataframe.DataRow @@ -166,7 +167,7 @@ internal object FullyQualifiedNames : TypeRenderingStrategy { internal object ShortNames : TypeRenderingStrategy { private val dataRow = DataRow::class.simpleName!! - private val columnsContainer = ColumnsContainer::class.simpleName!! + private val columnsContainer = ColumnsScope::class.simpleName!! private val dataFrame = DataFrame::class.simpleName!! private val dataColumn = DataColumn::class.simpleName!! private val columnGroup = ColumnGroup::class.simpleName!! @@ -565,7 +566,7 @@ public fun Code.toStandaloneSnippet(packageName: String, additionalImports: List appendLine("package $packageName") appendLine() } - appendLine("import org.jetbrains.kotlinx.dataframe.ColumnsContainer") + appendLine("import org.jetbrains.kotlinx.dataframe.ColumnsScope") appendLine("import org.jetbrains.kotlinx.dataframe.DataColumn") appendLine("import org.jetbrains.kotlinx.dataframe.DataFrame") appendLine("import org.jetbrains.kotlinx.dataframe.DataRow") diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt index af5090311c..c3bdbbbce9 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt @@ -6,7 +6,7 @@ import org.jetbrains.dataframe.impl.codeGen.InterfaceGenerationMode import org.jetbrains.dataframe.impl.codeGen.ReplCodeGenerator import org.jetbrains.dataframe.impl.codeGen.generate import org.jetbrains.kotlinx.dataframe.AnyRow -import org.jetbrains.kotlinx.dataframe.ColumnsContainer +import org.jetbrains.kotlinx.dataframe.ColumnsScope import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.api.dataFrameOf @@ -30,7 +30,7 @@ class CodeGenerationTests : BaseTest() { val personShortName = Person::class.simpleName!! - val dfName = (ColumnsContainer::class).simpleName!! + val dfName = (ColumnsScope::class).simpleName!! val dfRowName = (DataRow::class).simpleName!! val dataCol = (DataColumn::class).simpleName!! val dataRow = (DataRow::class).simpleName!! diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt index 30eb99e55c..81a704861c 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt @@ -4,7 +4,7 @@ import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldNotBeEmpty import org.jetbrains.dataframe.impl.codeGen.ReplCodeGenerator import org.jetbrains.dataframe.impl.codeGen.process -import org.jetbrains.kotlinx.dataframe.ColumnsContainer +import org.jetbrains.kotlinx.dataframe.ColumnsScope import org.jetbrains.kotlinx.dataframe.DataColumn import org.jetbrains.kotlinx.dataframe.DataRow import org.jetbrains.kotlinx.dataframe.annotations.DataSchema @@ -20,7 +20,7 @@ import org.junit.Test @Suppress("ktlint:standard:class-naming") class ReplCodeGenTests : BaseTest() { - val dfName = (ColumnsContainer::class).simpleName!! + val dfName = (ColumnsScope::class).simpleName!! val dfRowName = (DataRow::class).simpleName!! val dataCol = (DataColumn::class).simpleName!! val intName = Int::class.simpleName!! @@ -192,7 +192,7 @@ class ReplCodeGenTests : BaseTest() { repl.process() repl.process() val c = repl.process(Test3.df, Test3::df) - """val .*ColumnsContainer<\w*>.x:""".toRegex().findAll(c.declarations).count() shouldBe 1 + """val .*ColumnsScope<\w*>.x:""".toRegex().findAll(c.declarations).count() shouldBe 1 } object Test4 { @@ -216,6 +216,6 @@ class ReplCodeGenTests : BaseTest() { repl.process() repl.process() val c = repl.process(Test4.df, Test4::df) - """val .*ColumnsContainer<\w*>.a:""".toRegex().findAll(c.declarations).count() shouldBe 1 + """val .*ColumnsScope<\w*>.a:""".toRegex().findAll(c.declarations).count() shouldBe 1 } } diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/IrBodyFiller.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/IrBodyFiller.kt index fa395d4c9b..86312f5d9f 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/IrBodyFiller.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/IrBodyFiller.kt @@ -129,6 +129,8 @@ private class DataFrameFileLowering(val context: IrPluginContext) : FileLowering companion object { val COLUMNS_CONTAINER_ID = CallableId(ClassId(FqName("org.jetbrains.kotlinx.dataframe"), Name.identifier("ColumnsContainer")), Name.identifier("get")) + val COLUMNS_SCOPE_ID = + CallableId(ClassId(FqName("org.jetbrains.kotlinx.dataframe"), Name.identifier("ColumnsScope")), Name.identifier("get")) val DATA_ROW_ID = CallableId(ClassId(FqName("org.jetbrains.kotlinx.dataframe"), Name.identifier("DataRow")), Name.identifier("get")) } @@ -196,7 +198,7 @@ private class DataFrameFileLowering(val context: IrPluginContext) : FileLowering val get = if (isDataColumn) { context - .referenceFunctions(COLUMNS_CONTAINER_ID) + .referenceFunctions(COLUMNS_SCOPE_ID) .single { it.owner.valueParameters.size == 1 && it.owner.valueParameters[0].type == context.irBuiltIns.stringType } diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/TokenGenerator.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/TokenGenerator.kt index 0fed46fcd6..03e8009690 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/TokenGenerator.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/TokenGenerator.kt @@ -73,7 +73,7 @@ class TokenGenerator(session: FirSession) : FirDeclarationGenerationExtension(se val columnContainerExtension = generateExtensionProperty( callableId = callableId, receiverType = ConeClassLikeTypeImpl( - ConeClassLikeLookupTagImpl(Names.COLUMNS_CONTAINER_CLASS_ID), + ConeClassLikeLookupTagImpl(Names.COLUMNS_SCOPE_CLASS_ID), typeArguments = arrayOf(schemaProperty.marker), isNullable = false ), diff --git a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/utils/Names.kt b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/utils/Names.kt index ff6919e19a..a4c8d3812e 100644 --- a/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/utils/Names.kt +++ b/plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/utils/Names.kt @@ -33,6 +33,12 @@ object Names { FqName.fromSegments(listOf("org", "jetbrains", "kotlinx", "dataframe")), Name.identifier("ColumnsContainer") ) + + val COLUMNS_SCOPE_CLASS_ID: ClassId + get() = ClassId( + FqName.fromSegments(listOf("org", "jetbrains", "kotlinx", "dataframe")), + Name.identifier("ColumnsScope") + ) val DATA_ROW_CLASS_ID: ClassId get() = ClassId(FqName.fromSegments(listOf("org", "jetbrains", "kotlinx", "dataframe")), Name.identifier("DataRow")) val DF_ANNOTATIONS_PACKAGE: Name diff --git a/plugins/kotlin-dataframe/testData/box/propertiesOrder.fir.txt b/plugins/kotlin-dataframe/testData/box/propertiesOrder.fir.txt index e314eec135..368fb894c4 100644 --- a/plugins/kotlin-dataframe/testData/box/propertiesOrder.fir.txt +++ b/plugins/kotlin-dataframe/testData/box/propertiesOrder.fir.txt @@ -25,31 +25,31 @@ FILE: propertiesOrder.kt public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Read_16I>|.full_name: R|kotlin/String| public get(): R|kotlin/String| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</Read_16I>|.full_name: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Read_16I>|.full_name: R|org/jetbrains/kotlinx/dataframe/DataColumn| public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Read_16I>|.topics: R|kotlin/String| public get(): R|kotlin/String| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</Read_16I>|.topics: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Read_16I>|.topics: R|org/jetbrains/kotlinx/dataframe/DataColumn| public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Read_16I>|.watchers: R|kotlin/Int| public get(): R|kotlin/Int| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</Read_16I>|.watchers: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Read_16I>|.watchers: R|org/jetbrains/kotlinx/dataframe/DataColumn| public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Read_16I>|.stargazers_count: R|kotlin/Int| public get(): R|kotlin/Int| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</Read_16I>|.stargazers_count: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Read_16I>|.stargazers_count: R|org/jetbrains/kotlinx/dataframe/DataColumn| public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| public final val R|org/jetbrains/kotlinx/dataframe/DataRow</Read_16I>|.html_url: R|java/net/URL| public get(): R|java/net/URL| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</Read_16I>|.html_url: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</Read_16I>|.html_url: R|org/jetbrains/kotlinx/dataframe/DataColumn| public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| public constructor(): R|/Scope0| diff --git a/plugins/kotlin-dataframe/testData/diagnostics/selectDuringTyping.fir.txt b/plugins/kotlin-dataframe/testData/diagnostics/selectDuringTyping.fir.txt index 4479d8415e..1e918b2474 100644 --- a/plugins/kotlin-dataframe/testData/diagnostics/selectDuringTyping.fir.txt +++ b/plugins/kotlin-dataframe/testData/diagnostics/selectDuringTyping.fir.txt @@ -20,7 +20,7 @@ FILE: selectDuringTyping.kt public final val R|org/jetbrains/kotlinx/dataframe/DataRow</ExplodeSchema_94I>|.timestamps: R|kotlin/collections/List| public get(): R|kotlin/collections/List| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</ExplodeSchema_94I>|.timestamps: R|org/jetbrains/kotlinx/dataframe/DataColumn>| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</ExplodeSchema_94I>|.timestamps: R|org/jetbrains/kotlinx/dataframe/DataColumn>| public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn>| public constructor(): R|/Scope0| diff --git a/plugins/kotlin-dataframe/testData/diagnostics/toDataFrame_java.fir.txt b/plugins/kotlin-dataframe/testData/diagnostics/toDataFrame_java.fir.txt index 2ae2968c13..b3cfe8095d 100644 --- a/plugins/kotlin-dataframe/testData/diagnostics/toDataFrame_java.fir.txt +++ b/plugins/kotlin-dataframe/testData/diagnostics/toDataFrame_java.fir.txt @@ -22,7 +22,7 @@ FILE: test.kt public final val R|org/jetbrains/kotlinx/dataframe/DataRow</S_43I>|.javaRecord: R|org/jetbrains/kotlinx/dataframe/DataRow</JavaRecord_771>| public get(): R|org/jetbrains/kotlinx/dataframe/DataRow</JavaRecord_771>| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</S_43I>|.javaRecord: R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</JavaRecord_771>| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</S_43I>|.javaRecord: R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</JavaRecord_771>| public get(): R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</JavaRecord_771>| public constructor(): R|/Scope0| @@ -47,19 +47,19 @@ FILE: test.kt public final val R|org/jetbrains/kotlinx/dataframe/DataRow</JavaRecord_771>|.aaa: R|org/jetbrains/kotlinx/dataframe/DataRow</Aaa_771>| public get(): R|org/jetbrains/kotlinx/dataframe/DataRow</Aaa_771>| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</JavaRecord_771>|.aaa: R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</Aaa_771>| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</JavaRecord_771>|.aaa: R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</Aaa_771>| public get(): R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</Aaa_771>| public final val R|org/jetbrains/kotlinx/dataframe/DataRow</JavaRecord_771>|.bean: R|org/jetbrains/kotlinx/dataframe/DataRow</Bean_771>| public get(): R|org/jetbrains/kotlinx/dataframe/DataRow</Bean_771>| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</JavaRecord_771>|.bean: R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</Bean_771>| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</JavaRecord_771>|.bean: R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</Bean_771>| public get(): R|org/jetbrains/kotlinx/dataframe/columns/ColumnGroup</Bean_771>| public final val R|org/jetbrains/kotlinx/dataframe/DataRow</JavaRecord_771>|.i: R|kotlin/Int| public get(): R|kotlin/Int| - public final val R|org/jetbrains/kotlinx/dataframe/ColumnsContainer</JavaRecord_771>|.i: R|org/jetbrains/kotlinx/dataframe/DataColumn| + public final val R|org/jetbrains/kotlinx/dataframe/ColumnsScope</JavaRecord_771>|.i: R|org/jetbrains/kotlinx/dataframe/DataColumn| public get(): R|org/jetbrains/kotlinx/dataframe/DataColumn| public constructor(): R|/Scope1| diff --git a/plugins/symbol-processor/src/main/kotlin/org/jetbrains/dataframe/ksp/ExtensionsGenerator.kt b/plugins/symbol-processor/src/main/kotlin/org/jetbrains/dataframe/ksp/ExtensionsGenerator.kt index 2f7368284b..bae2908b13 100644 --- a/plugins/symbol-processor/src/main/kotlin/org/jetbrains/dataframe/ksp/ExtensionsGenerator.kt +++ b/plugins/symbol-processor/src/main/kotlin/org/jetbrains/dataframe/ksp/ExtensionsGenerator.kt @@ -132,7 +132,7 @@ class ExtensionsGenerator( private fun OutputStreamWriter.writeImports() { appendLine("import org.jetbrains.kotlinx.dataframe.annotations.*") - appendLine("import org.jetbrains.kotlinx.dataframe.ColumnsContainer") + appendLine("import org.jetbrains.kotlinx.dataframe.ColumnsScope") appendLine("import org.jetbrains.kotlinx.dataframe.DataColumn") appendLine("import org.jetbrains.kotlinx.dataframe.DataFrame") appendLine("import org.jetbrains.kotlinx.dataframe.DataRow") diff --git a/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt b/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt index 39b25fe292..3d943c3378 100644 --- a/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt +++ b/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt @@ -57,11 +57,11 @@ class DataFrameSymbolProcessorTest { class NestedClass } - val ColumnsContainer<`Hello Something`>.col1: DataColumn get() = name - val ColumnsContainer<`Hello Something`>.col2: DataColumn<`Hello Something`.NestedClass> get() = `test name` - val ColumnsContainer<`Hello Something`>.col3: DataColumn get() = nullableProperty - val ColumnsContainer<`Hello Something`>.col4: DataColumn<() -> Unit> get() = a - val ColumnsContainer<`Hello Something`>.col5: DataColumn>> get() = d + val ColumnsScope<`Hello Something`>.col1: DataColumn get() = name + val ColumnsScope<`Hello Something`>.col2: DataColumn<`Hello Something`.NestedClass> get() = `test name` + val ColumnsScope<`Hello Something`>.col3: DataColumn get() = nullableProperty + val ColumnsScope<`Hello Something`>.col4: DataColumn<() -> Unit> get() = a + val ColumnsScope<`Hello Something`>.col5: DataColumn>> get() = d val DataRow<`Hello Something`>.row1: String get() = name val DataRow<`Hello Something`>.row2: `Hello Something`.NestedClass get() = `test name` @@ -99,11 +99,11 @@ class DataFrameSymbolProcessorTest { class NestedClass } - val ColumnsContainer.col1: DataColumn get() = name - val ColumnsContainer.col2: DataColumn get() = `test name` - val ColumnsContainer.col3: DataColumn get() = nullableProperty - val ColumnsContainer.col4: DataColumn<() -> Unit> get() = a - val ColumnsContainer.col5: DataColumn>> get() = d + val ColumnsScope.col1: DataColumn get() = name + val ColumnsScope.col2: DataColumn get() = `test name` + val ColumnsScope.col3: DataColumn get() = nullableProperty + val ColumnsScope.col4: DataColumn<() -> Unit> get() = a + val ColumnsScope.col5: DataColumn>> get() = d val DataRow.row1: String get() = name val DataRow.row2: Hello.NestedClass get() = `test name` @@ -143,12 +143,12 @@ class DataFrameSymbolProcessorTest { class Nested } - val ColumnsContainer.col1: DataColumn get() = name - val ColumnsContainer.col2: DataColumn get() = `test name` - val ColumnsContainer.col3: DataColumn get() = nullableProperty - val ColumnsContainer.col4: DataColumn<() -> Unit> get() = a - val ColumnsContainer.col5: DataColumn>> get() = d - val ColumnsContainer.col6: DataColumn get() = nestedClass + val ColumnsScope.col1: DataColumn get() = name + val ColumnsScope.col2: DataColumn get() = `test name` + val ColumnsScope.col3: DataColumn get() = nullableProperty + val ColumnsScope.col4: DataColumn<() -> Unit> get() = a + val ColumnsScope.col5: DataColumn>> get() = d + val ColumnsScope.col6: DataColumn get() = nestedClass val DataRow.row1: String get() = name val DataRow.row2: Hello.InnerClass get() = `test name` @@ -190,12 +190,12 @@ class DataFrameSymbolProcessorTest { class Nested } - val ColumnsContainer.col1: DataColumn get() = name - val ColumnsContainer.col2: DataColumn get() = `test name` - val ColumnsContainer.col3: DataColumn get() = nullableProperty - val ColumnsContainer.col4: DataColumn<() -> Unit> get() = a - val ColumnsContainer.col5: DataColumn>> get() = d - val ColumnsContainer.col6: DataColumn get() = nestedClass + val ColumnsScope.col1: DataColumn get() = name + val ColumnsScope.col2: DataColumn get() = `test name` + val ColumnsScope.col3: DataColumn get() = nullableProperty + val ColumnsScope.col4: DataColumn<() -> Unit> get() = a + val ColumnsScope.col5: DataColumn>> get() = d + val ColumnsScope.col6: DataColumn get() = nestedClass val DataRow.row1: String get() = name val DataRow.row2: Hello.InnerClass get() = `test name` @@ -262,7 +262,7 @@ class DataFrameSymbolProcessorTest { val a: () -> Unit? } - val ColumnsContainer.test1: DataColumn<() -> Unit?> get() = a + val ColumnsScope.test1: DataColumn<() -> Unit?> get() = a val DataRow.test2: () -> Unit? get() = a """.trimIndent(), ), @@ -272,7 +272,7 @@ class DataFrameSymbolProcessorTest { result.inspectLines { codeLines -> codeLines.forOne { it - .shouldContain("ColumnsContainer.a") + .shouldContain("ColumnsScope.a") .shouldContain("DataColumn>") } codeLines.forOne { @@ -299,7 +299,7 @@ class DataFrameSymbolProcessorTest { val a: suspend () -> Unit? } - val ColumnsContainer.test1: DataColumn Unit?> get() = a + val ColumnsScope.test1: DataColumn Unit?> get() = a val DataRow.test2: suspend () -> Unit? get() = a """.trimIndent(), ), @@ -310,7 +310,7 @@ class DataFrameSymbolProcessorTest { result.inspectLines { codeLines -> codeLines.forOne { it - .shouldContain("ColumnsContainer.a") + .shouldContain("ColumnsScope.a") .shouldContain("DataColumn>") } codeLines.forOne { @@ -337,7 +337,7 @@ class DataFrameSymbolProcessorTest { val a: (() -> String)? } - val ColumnsContainer.test1: DataColumn<(() -> String)?> get() = a + val ColumnsScope.test1: DataColumn<(() -> String)?> get() = a val DataRow.test2: (() -> String)? get() = a """.trimIndent(), ), @@ -347,7 +347,7 @@ class DataFrameSymbolProcessorTest { result.inspectLines { codeLines -> codeLines.forOne { it - .shouldContain("ColumnsContainer.a") + .shouldContain("ColumnsScope.a") .shouldContain("DataColumn?>") } codeLines.forOne { @@ -374,7 +374,7 @@ class DataFrameSymbolProcessorTest { val a: (Int.() -> String)? } - val ColumnsContainer.test1: DataColumn<(Int.() -> String)?> get() = a + val ColumnsScope.test1: DataColumn<(Int.() -> String)?> get() = a val DataRow.test2: (Int.() -> String)? get() = a """.trimIndent(), ), @@ -384,7 +384,7 @@ class DataFrameSymbolProcessorTest { result.inspectLines { codeLines -> codeLines.forOne { it - .shouldContain("ColumnsContainer.a") + .shouldContain("ColumnsScope.a") .shouldContain("DataColumn?>") } codeLines.forOne { @@ -411,7 +411,7 @@ class DataFrameSymbolProcessorTest { val a: (a: String) -> Unit } - val ColumnsContainer.test1: DataColumn<(a: String) -> Unit> get() = a + val ColumnsScope.test1: DataColumn<(a: String) -> Unit> get() = a val DataRow.test2: (a: String) -> Unit get() = a """.trimIndent(), ), @@ -421,7 +421,7 @@ class DataFrameSymbolProcessorTest { result.inspectLines { codeLines -> codeLines.forOne { it - .shouldContain("ColumnsContainer.a") + .shouldContain("ColumnsScope.a") .shouldContain("DataColumn>") } codeLines.forOne { @@ -449,7 +449,7 @@ class DataFrameSymbolProcessorTest { val b get() = a } - val ColumnsContainer.test1: DataColumn get() = b + val ColumnsScope.test1: DataColumn get() = b val DataRow.test2: Int get() = b """.trimIndent(), ), @@ -479,7 +479,7 @@ class DataFrameSymbolProcessorTest { val a: A } - val ColumnsContainer.col1: DataColumn get() = a + val ColumnsScope.col1: DataColumn get() = a val DataRow.row1: A get() = a """.trimIndent(), @@ -510,7 +510,7 @@ class DataFrameSymbolProcessorTest { val a: A } - val ColumnsContainer.col1: ColumnGroup get() = a + val ColumnsScope.col1: ColumnGroup get() = a val DataRow.row1: DataRow get() = a """.trimIndent(), @@ -541,7 +541,7 @@ class DataFrameSymbolProcessorTest { val a: List } - val ColumnsContainer.col1: DataColumn> get() = a + val ColumnsScope.col1: DataColumn> get() = a val DataRow.row1: DataFrame get() = a """.trimIndent(), @@ -570,7 +570,7 @@ class DataFrameSymbolProcessorTest { val `test name`: Int } - val ColumnsContainer.test2: DataColumn get() = `test name` + val ColumnsScope.test2: DataColumn get() = `test name` val DataRow.test4: Int get() = `test name` """.trimIndent(), ), @@ -601,7 +601,7 @@ class DataFrameSymbolProcessorTest { val a: Int } - val ColumnsContainer.col1: DataColumn get() = a + val ColumnsScope.col1: DataColumn get() = a val DataRow.row1: Int get() = a """.trimIndent(), @@ -634,7 +634,7 @@ class DataFrameSymbolProcessorTest { val a: DataRow } - val ColumnsContainer.col1: ColumnGroup get() = a + val ColumnsScope.col1: ColumnGroup get() = a val DataRow.row1: DataRow get() = a """.trimIndent(), @@ -664,7 +664,7 @@ class DataFrameSymbolProcessorTest { val a: DataFrame } - val ColumnsContainer.col1: DataColumn> get() = a + val ColumnsScope.col1: DataColumn> get() = a val DataRow.row1: DataFrame get() = a """.trimIndent(), @@ -692,7 +692,7 @@ class DataFrameSymbolProcessorTest { val name: String } - val ColumnsContainer.test1: DataColumn get() = name + val ColumnsScope.test1: DataColumn get() = name val DataRow.test2: String get() = name """.trimIndent(), ), @@ -719,7 +719,7 @@ class DataFrameSymbolProcessorTest { val field: T } - val ColumnsContainer>.test1: DataColumn get() = field + val ColumnsScope>.test1: DataColumn get() = field val DataRow>.test2: T get() = field """.trimIndent(), ), @@ -746,7 +746,7 @@ class DataFrameSymbolProcessorTest { val field: T } - val ColumnsContainer>.test1: DataColumn get() = field + val ColumnsScope>.test1: DataColumn get() = field val DataRow>.test2: T get() = field """.trimIndent(), ), @@ -775,7 +775,7 @@ class DataFrameSymbolProcessorTest { val field: T } - val ColumnsContainer>.test1: DataColumn get() = field + val ColumnsScope>.test1: DataColumn get() = field val DataRow>.test2: T get() = field """.trimIndent(), ), @@ -806,7 +806,7 @@ class DataFrameSymbolProcessorTest { interface MySchema : KeyValue - val ColumnsContainer.test1: DataColumn get() = key + val ColumnsScope.test1: DataColumn get() = key val DataRow.test2: Int get() = value """.trimIndent(), ),