diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt index a803e316f8..7c63be3d4a 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt @@ -226,8 +226,6 @@ internal open class ExtensionsCodeGeneratorImpl( private fun String.removeQuotes() = this.removeSurrounding("`") - private fun generateExtensionProperties(markers: List) = markers.map { generateExtensionProperties(it) } - private fun generatePropertyCode( marker: IsolatedMarker, shortMarkerName: String, @@ -430,11 +428,6 @@ internal class CodeGeneratorImpl(typeRendering: TypeRenderingStrategy = FullyQua return CodeGenResult(code, context.generatedMarkers) } - private fun generateInterfaces( - schemas: List, - fields: Boolean, - ) = schemas.map { generateInterface(it, fields) } - private fun generateInterface( marker: Marker, fields: Boolean, @@ -483,7 +476,7 @@ internal class CodeGeneratorImpl(typeRendering: TypeRenderingStrategy = FullyQua append("\n}") } } else { - "" + " { }" } resultDeclarations.add(header + baseInterfacesDeclaration + body) return resultDeclarations.join() diff --git a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt index 70c09b5d80..ed33a20f74 100644 --- a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt +++ b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt @@ -60,7 +60,7 @@ class CodeGenerationTests : BaseTest() { val typeName = ReplCodeGeneratorImpl.markerInterfacePrefix val expectedDeclaration = """ @DataSchema - interface $typeName + interface $typeName { } """.trimIndent() + "\n" + expectedProperties(typeName, typeName) @@ -85,7 +85,7 @@ class CodeGenerationTests : BaseTest() { val typeName = ReplCodeGeneratorImpl.markerInterfacePrefix val expectedDeclaration = """ @DataSchema - interface $typeName + interface $typeName { } """.trimIndent() + "\n" + expectedProperties(typeName, typeName) @@ -104,7 +104,7 @@ class CodeGenerationTests : BaseTest() { val type2 = ReplCodeGeneratorImpl.markerInterfacePrefix val declaration1 = """ @DataSchema(isOpen = false) - interface $type1 + interface $type1 { } val $dfName<$type1>.city: $dataCol<$stringName?> @JvmName("${type1}_city") get() = this["city"] as $dataCol<$stringName?> val $dfRowName<$type1>.city: $stringName? @JvmName("${type1}_city") get() = this["city"] as $stringName? @@ -119,7 +119,7 @@ class CodeGenerationTests : BaseTest() { val declaration2 = """ @DataSchema - interface $type2 + interface $type2 { } val $dfName<$type2>.age: $dataCol<$intName> @JvmName("${type2}_age") get() = this["age"] as $dataCol<$intName> val $dfRowName<$type2>.age: $intName @JvmName("${type2}_age") get() = this["age"] as $intName @@ -146,7 +146,7 @@ class CodeGenerationTests : BaseTest() { val personClass = (Person::class).qualifiedName!! val expected = """ @DataSchema - interface $personClass + interface $personClass { } """.trimIndent() + "\n" + expectedProperties(personClassName, personShortName) val code = CodeGenerator.create(useFqNames = false) @@ -203,7 +203,7 @@ class CodeGenerationTests : BaseTest() { val code = codeGen.generate(df.schema(), "Person", false, true, true).code.declarations val expected = """ @DataSchema - interface Person + interface Person { } """.trimIndent() + "\n" + expectedProperties("Person", "Person") code shouldBe expected diff --git a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt index 50a3fbbf2f..9c8983835b 100644 --- a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt +++ b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt @@ -75,7 +75,7 @@ class ReplCodeGenTests : BaseTest() { val expected = """ @DataSchema - interface $marker + interface $marker { } val $dfName<$marker>.age: $dataCol<$intName> @JvmName("${marker}_age") get() = this["age"] as $dataCol<$intName> val $dfRowName<$marker>.age: $intName @JvmName("${marker}_age") get() = this["age"] as $intName @@ -104,7 +104,7 @@ class ReplCodeGenTests : BaseTest() { val marker3 = marker + "1" val expected3 = """ @DataSchema - interface $marker3 : $markerFull + interface $marker3 : $markerFull { } val $dfName<$marker3>.city: $dataCol<$stringName> @JvmName("${marker3}_city") get() = this["city"] as $dataCol<$stringName> val $dfRowName<$marker3>.city: $stringName @JvmName("${marker3}_city") get() = this["city"] as $stringName @@ -122,7 +122,7 @@ class ReplCodeGenTests : BaseTest() { val marker5 = marker + "2" val expected5 = """ @DataSchema - interface $marker5 : $markerFull + interface $marker5 : $markerFull { } val $dfName<$marker5>.weight: $dataCol<$intName> @JvmName("${marker5}_weight") get() = this["weight"] as $dataCol<$intName> val $dfRowName<$marker5>.weight: $intName @JvmName("${marker5}_weight") get() = this["weight"] as $intName @@ -145,7 +145,7 @@ class ReplCodeGenTests : BaseTest() { val expected = """ @DataSchema - interface ${Test2._DataFrameType2::class.simpleName!!} : ${Test2._DataFrameType::class.qualifiedName}, ${Test2._DataFrameType1::class.qualifiedName} + interface ${Test2._DataFrameType2::class.simpleName!!} : ${Test2._DataFrameType::class.qualifiedName}, ${Test2._DataFrameType1::class.qualifiedName} { } """.trimIndent() @@ -164,7 +164,7 @@ class ReplCodeGenTests : BaseTest() { val marker = Test2._DataFrameType2::class.simpleName!! val expected = """ @DataSchema - interface $marker : ${Test2._DataFrameType::class.qualifiedName} + interface $marker : ${Test2._DataFrameType::class.qualifiedName} { } val $dfName<$marker>.city: $dataCol<$stringName?> @JvmName("${marker}_city") get() = this["city"] as $dataCol<$stringName?> val $dfRowName<$marker>.city: $stringName? @JvmName("${marker}_city") get() = this["city"] as $stringName? diff --git a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CodeGenerationTests.kt b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CodeGenerationTests.kt index 999f5cb6eb..e0620cb553 100644 --- a/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CodeGenerationTests.kt +++ b/core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CodeGenerationTests.kt @@ -51,4 +51,14 @@ class CodeGenerationTests : DataFrameJupyterTest() { row.a """.checkCompilation() } + + @Test + fun `interface without body compiled correctly`() { + """ + val a = dataFrameOf("a")(1, 2, 3) + val b = dataFrameOf("b")(1, 2, 3) + val ab = dataFrameOf("a", "b")(1, 2) + ab.a + """.checkCompilation() + } } 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 a803e316f8..7c63be3d4a 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 @@ -226,8 +226,6 @@ internal open class ExtensionsCodeGeneratorImpl( private fun String.removeQuotes() = this.removeSurrounding("`") - private fun generateExtensionProperties(markers: List) = markers.map { generateExtensionProperties(it) } - private fun generatePropertyCode( marker: IsolatedMarker, shortMarkerName: String, @@ -430,11 +428,6 @@ internal class CodeGeneratorImpl(typeRendering: TypeRenderingStrategy = FullyQua return CodeGenResult(code, context.generatedMarkers) } - private fun generateInterfaces( - schemas: List, - fields: Boolean, - ) = schemas.map { generateInterface(it, fields) } - private fun generateInterface( marker: Marker, fields: Boolean, @@ -483,7 +476,7 @@ internal class CodeGeneratorImpl(typeRendering: TypeRenderingStrategy = FullyQua append("\n}") } } else { - "" + " { }" } resultDeclarations.add(header + baseInterfacesDeclaration + body) return resultDeclarations.join() 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 70c09b5d80..ed33a20f74 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 @@ -60,7 +60,7 @@ class CodeGenerationTests : BaseTest() { val typeName = ReplCodeGeneratorImpl.markerInterfacePrefix val expectedDeclaration = """ @DataSchema - interface $typeName + interface $typeName { } """.trimIndent() + "\n" + expectedProperties(typeName, typeName) @@ -85,7 +85,7 @@ class CodeGenerationTests : BaseTest() { val typeName = ReplCodeGeneratorImpl.markerInterfacePrefix val expectedDeclaration = """ @DataSchema - interface $typeName + interface $typeName { } """.trimIndent() + "\n" + expectedProperties(typeName, typeName) @@ -104,7 +104,7 @@ class CodeGenerationTests : BaseTest() { val type2 = ReplCodeGeneratorImpl.markerInterfacePrefix val declaration1 = """ @DataSchema(isOpen = false) - interface $type1 + interface $type1 { } val $dfName<$type1>.city: $dataCol<$stringName?> @JvmName("${type1}_city") get() = this["city"] as $dataCol<$stringName?> val $dfRowName<$type1>.city: $stringName? @JvmName("${type1}_city") get() = this["city"] as $stringName? @@ -119,7 +119,7 @@ class CodeGenerationTests : BaseTest() { val declaration2 = """ @DataSchema - interface $type2 + interface $type2 { } val $dfName<$type2>.age: $dataCol<$intName> @JvmName("${type2}_age") get() = this["age"] as $dataCol<$intName> val $dfRowName<$type2>.age: $intName @JvmName("${type2}_age") get() = this["age"] as $intName @@ -146,7 +146,7 @@ class CodeGenerationTests : BaseTest() { val personClass = (Person::class).qualifiedName!! val expected = """ @DataSchema - interface $personClass + interface $personClass { } """.trimIndent() + "\n" + expectedProperties(personClassName, personShortName) val code = CodeGenerator.create(useFqNames = false) @@ -203,7 +203,7 @@ class CodeGenerationTests : BaseTest() { val code = codeGen.generate(df.schema(), "Person", false, true, true).code.declarations val expected = """ @DataSchema - interface Person + interface Person { } """.trimIndent() + "\n" + expectedProperties("Person", "Person") code shouldBe expected 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 50a3fbbf2f..9c8983835b 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 @@ -75,7 +75,7 @@ class ReplCodeGenTests : BaseTest() { val expected = """ @DataSchema - interface $marker + interface $marker { } val $dfName<$marker>.age: $dataCol<$intName> @JvmName("${marker}_age") get() = this["age"] as $dataCol<$intName> val $dfRowName<$marker>.age: $intName @JvmName("${marker}_age") get() = this["age"] as $intName @@ -104,7 +104,7 @@ class ReplCodeGenTests : BaseTest() { val marker3 = marker + "1" val expected3 = """ @DataSchema - interface $marker3 : $markerFull + interface $marker3 : $markerFull { } val $dfName<$marker3>.city: $dataCol<$stringName> @JvmName("${marker3}_city") get() = this["city"] as $dataCol<$stringName> val $dfRowName<$marker3>.city: $stringName @JvmName("${marker3}_city") get() = this["city"] as $stringName @@ -122,7 +122,7 @@ class ReplCodeGenTests : BaseTest() { val marker5 = marker + "2" val expected5 = """ @DataSchema - interface $marker5 : $markerFull + interface $marker5 : $markerFull { } val $dfName<$marker5>.weight: $dataCol<$intName> @JvmName("${marker5}_weight") get() = this["weight"] as $dataCol<$intName> val $dfRowName<$marker5>.weight: $intName @JvmName("${marker5}_weight") get() = this["weight"] as $intName @@ -145,7 +145,7 @@ class ReplCodeGenTests : BaseTest() { val expected = """ @DataSchema - interface ${Test2._DataFrameType2::class.simpleName!!} : ${Test2._DataFrameType::class.qualifiedName}, ${Test2._DataFrameType1::class.qualifiedName} + interface ${Test2._DataFrameType2::class.simpleName!!} : ${Test2._DataFrameType::class.qualifiedName}, ${Test2._DataFrameType1::class.qualifiedName} { } """.trimIndent() @@ -164,7 +164,7 @@ class ReplCodeGenTests : BaseTest() { val marker = Test2._DataFrameType2::class.simpleName!! val expected = """ @DataSchema - interface $marker : ${Test2._DataFrameType::class.qualifiedName} + interface $marker : ${Test2._DataFrameType::class.qualifiedName} { } val $dfName<$marker>.city: $dataCol<$stringName?> @JvmName("${marker}_city") get() = this["city"] as $dataCol<$stringName?> val $dfRowName<$marker>.city: $stringName? @JvmName("${marker}_city") get() = this["city"] as $stringName? diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CodeGenerationTests.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CodeGenerationTests.kt index 999f5cb6eb..e0620cb553 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CodeGenerationTests.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/CodeGenerationTests.kt @@ -51,4 +51,14 @@ class CodeGenerationTests : DataFrameJupyterTest() { row.a """.checkCompilation() } + + @Test + fun `interface without body compiled correctly`() { + """ + val a = dataFrameOf("a")(1, 2, 3) + val b = dataFrameOf("b")(1, 2, 3) + val ab = dataFrameOf("a", "b")(1, 2) + ab.a + """.checkCompilation() + } }