-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #913 from Kotlin/bugfixes-1
[Compiler plugin] Generate ColumnName annotations on frontend for all names that contain illegal characters
- Loading branch information
Showing
14 changed files
with
137 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/CallShapeAttribute.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...tlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/impl/PropertyName.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.jetbrains.kotlinx.dataframe.plugin.extensions.impl | ||
|
||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation | ||
import org.jetbrains.kotlin.fir.expressions.builder.buildAnnotationArgumentMapping | ||
import org.jetbrains.kotlin.fir.expressions.builder.buildLiteralExpression | ||
import org.jetbrains.kotlin.fir.resolve.defaultType | ||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef | ||
import org.jetbrains.kotlin.name.Name | ||
import org.jetbrains.kotlin.types.ConstantValueKind | ||
import org.jetbrains.kotlinx.dataframe.codeGen.ValidFieldName | ||
import org.jetbrains.kotlinx.dataframe.plugin.utils.Names | ||
|
||
data class PropertyName(val identifier: Name, val columnNameAnnotation: FirAnnotation?) { | ||
companion object { | ||
fun of(name: String): PropertyName { | ||
val valid = ValidFieldName.of(name) | ||
var columnName = false | ||
val identifier = if (valid.unquoted != name) { | ||
columnName = true | ||
Name.identifier(valid.unquoted) | ||
} else { | ||
Name.identifier(name) | ||
} | ||
val columnNameAnnotation: FirAnnotation? = if (columnName) { | ||
buildAnnotation(name) | ||
} else { | ||
null | ||
} | ||
return PropertyName(identifier, columnNameAnnotation) | ||
} | ||
|
||
fun buildAnnotation(name: String): FirAnnotation { | ||
return org.jetbrains.kotlin.fir.expressions.builder.buildAnnotation { | ||
annotationTypeRef = buildResolvedTypeRef { | ||
type = Names.COLUMN_NAME_ANNOTATION.defaultType(emptyList()) | ||
} | ||
argumentMapping = buildAnnotationArgumentMapping { | ||
mapping[Names.COLUMN_NAME_ARGUMENT] = buildLiteralExpression( | ||
source = null, | ||
kind = ConstantValueKind.String, | ||
value = name, | ||
setType = true | ||
) | ||
} | ||
} | ||
} | ||
|
||
fun of(identifier: Name, columnNameAnnotation: FirAnnotation?): PropertyName { | ||
return PropertyName(identifier, columnNameAnnotation) | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...in-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/extensions/impl/SchemaProperty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.jetbrains.kotlinx.dataframe.plugin.extensions.impl | ||
|
||
import org.jetbrains.kotlin.fir.types.ConeKotlinType | ||
import org.jetbrains.kotlin.fir.types.ConeTypeProjection | ||
|
||
data class SchemaProperty( | ||
val marker: ConeTypeProjection, | ||
val propertyName: PropertyName, | ||
val dataRowReturnType: ConeKotlinType, | ||
val columnContainerReturnType: ConeKotlinType, | ||
val override: Boolean = false | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
plugins/kotlin-dataframe/testData/box/columnName_invalidSymbol.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
fun box(): String { | ||
val df = dataFrameOf("a.b")(1) | ||
df.`a b` | ||
return "OK" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
fun box(): String { | ||
|
||
return "OK" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters