File tree Expand file tree Collapse file tree 3 files changed +65
-8
lines changed
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen
plugins/symbol-processor/src
main/kotlin/org/jetbrains/dataframe/ksp
test/kotlin/org/jetbrains/dataframe/ksp Expand file tree Collapse file tree 3 files changed +65
-8
lines changed Original file line number Diff line number Diff line change @@ -53,17 +53,19 @@ private val letterCategories = setOf(
53
53
CharCategory .DECIMAL_DIGIT_NUMBER
54
54
)
55
55
56
- internal fun String.needsQuoting (): Boolean {
57
- return isBlank() ||
56
+ internal fun String.needsQuoting (): Boolean =
57
+ if (isQuoted()) false
58
+ else isBlank() ||
58
59
first().isDigit() ||
59
60
contains(charsToQuote) ||
60
61
HardKeywords .VALUES .contains(this ) ||
61
62
ModifierKeywords .VALUES .contains(this ) ||
62
63
all { it == ' _' } ||
63
64
any { it != ' _' && it.category !in letterCategories }
64
- }
65
65
66
- internal fun String.quoteIfNeeded () = if (needsQuoting()) " `$this `" else this
66
+ public fun String.isQuoted (): Boolean = startsWith(" `" ) && endsWith(" `" )
67
+
68
+ public fun String.quoteIfNeeded (): String = if (needsQuoting()) " `$this `" else this
67
69
68
70
internal fun List<Code>.join () = joinToString(" \n " )
69
71
@@ -250,7 +252,7 @@ internal open class ExtensionsCodeGeneratorImpl(
250
252
val markerName = marker.name
251
253
val markerType = " $markerName${marker.typeArguments} "
252
254
val visibility = renderTopLevelDeclarationVisibility(marker)
253
- val shortMarkerName = markerName.substring(markerName.lastIndexOf(' .' ) + 1 )
255
+ val shortMarkerName = markerName.substring(markerName.lastIndexOf(' .' ) + 1 ).removeQuotes()
254
256
val nullableShortMarkerName = " Nullable$shortMarkerName "
255
257
256
258
fun String.toNullable () = if (this .last() == ' ?' || this == " *" ) this else " $this ?"
Original file line number Diff line number Diff line change 1
1
package org.jetbrains.dataframe.ksp
2
2
3
3
import com.google.devtools.ksp.symbol.KSDeclaration
4
+ import org.jetbrains.kotlinx.dataframe.impl.codeGen.quoteIfNeeded
4
5
5
- fun KSDeclaration.getQualifiedNameOrThrow (): String {
6
- return (qualifiedName ? : error(" @DataSchema declaration ${simpleName.asString()} at $location must have qualified name" )).asString()
7
- }
6
+ fun KSDeclaration.getQualifiedNameOrThrow (): String =
7
+ qualifiedName
8
+ ?.let {
9
+ buildString {
10
+ val qualifier = it.getQualifier()
11
+ if (qualifier.isNotEmpty()) {
12
+ for (it in qualifier.split(' .' )) {
13
+ append(it.quoteIfNeeded() + ' .' )
14
+ }
15
+ }
16
+
17
+ append(it.getShortName().quoteIfNeeded())
18
+ }
19
+ }
20
+ ? : error(" @DataSchema declaration ${simpleName.asString()} at $location must have qualified name" )
Original file line number Diff line number Diff line change @@ -33,6 +33,48 @@ class DataFrameSymbolProcessorTest {
33
33
KspCompilationTestRunner .compilationDir.deleteRecursively()
34
34
}
35
35
36
+ @Test
37
+ fun `interface with backticked name` () {
38
+ val result = KspCompilationTestRunner .compile(
39
+ TestCompilationParameters (
40
+ sources = listOf (
41
+ SourceFile .kotlin(
42
+ " MySources.kt" ,
43
+ """
44
+ $imports
45
+
46
+ class OuterClass
47
+
48
+ @DataSchema(isOpen = false)
49
+ interface `Hello Something` {
50
+ val name: String
51
+ val `test name`: NestedClass
52
+ val nullableProperty: Int?
53
+ val a: () -> Unit
54
+ val d: List<List<*>>
55
+
56
+ class NestedClass
57
+ }
58
+
59
+ val ColumnsContainer<`Hello Something`>.col1: DataColumn<String> get() = name
60
+ val ColumnsContainer<`Hello Something`>.col2: DataColumn<`Hello Something`.NestedClass> get() = `test name`
61
+ val ColumnsContainer<`Hello Something`>.col3: DataColumn<Int?> get() = nullableProperty
62
+ val ColumnsContainer<`Hello Something`>.col4: DataColumn<() -> Unit> get() = a
63
+ val ColumnsContainer<`Hello Something`>.col5: DataColumn<List<List<*>>> get() = d
64
+
65
+ val DataRow<`Hello Something`>.row1: String get() = name
66
+ val DataRow<`Hello Something`>.row2: `Hello Something`.NestedClass get() = `test name`
67
+ val DataRow<`Hello Something`>.row3: Int? get() = nullableProperty
68
+ val DataRow<`Hello Something`>.row4: () -> Unit get() = a
69
+ val DataRow<`Hello Something`>.row5: List<List<*>> get() = d
70
+ """ .trimIndent()
71
+ )
72
+ )
73
+ )
74
+ )
75
+ result.successfulCompilation shouldBe true
76
+ }
77
+
36
78
@Test
37
79
fun `all interface` () {
38
80
val result = KspCompilationTestRunner .compile(
You can’t perform that action at this time.
0 commit comments