diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index 6dccb98dd21..c9416a46c0e 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -162,8 +162,8 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild } jump.configure { - withArg("E", targetElement) - +field("target", jumpTargetType.withArgs("E")) + val e = withArg("E", targetElement) + +field("target", jumpTargetType to listOf(e)) } loopJump.configure { @@ -227,9 +227,9 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild } constExpression.configure { - withArg("T") - +field("kind", constKindType.withArgs("T"), withReplace = true) - +field("value", "T", null) + val t = withArg("T") + +field("kind", constKindType to listOf(t), withReplace = true) + +field("value", t) } functionCall.configure { @@ -572,7 +572,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild smartCastExpression.configure { +field("originalExpression", expression, withReplace = true).withTransform() - +field("typesFromSmartCast", "Collection", null, customType = coneKotlinTypeType) + +field("typesFromSmartCast", StandardTypes.collection to listOf(coneKotlinTypeType)) +field("smartcastType", typeRef) +field("smartcastTypeWithoutNullableNothing", typeRef, nullable = true) +booleanField("isStable") @@ -748,7 +748,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild whenExpression.configure { +field("subject", expression, nullable = true).withTransform() - +field("subjectVariable", variable.withArgs("E" to TypeRef.Star), nullable = true) + +field("subjectVariable", variable, nullable = true) +fieldList("branches", whenBranch).withTransform() +field("exhaustivenessStatus", exhaustivenessStatusType, nullable = true, withReplace = true) +booleanField("usedAsExpression") diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFieldConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFieldConfigurator.kt index 5db6663fdb1..bb32ae92335 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFieldConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFieldConfigurator.kt @@ -49,10 +49,6 @@ abstract class AbstractFieldConfigurator(private val argMap[argument] = type } - fun TypeRef.withArgs(vararg args: String): Pair> { - return this to args.map { NamedTypeParameterRef(it) } - } - fun needTransformOtherChildren() { element._needTransformOtherChildren = true } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeBuilder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeBuilder.kt index 76d4fae7c11..455a001364c 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeBuilder.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/context/AbstractFirTreeBuilder.kt @@ -23,10 +23,6 @@ abstract class AbstractFirTreeBuilder { "Element", Element.Kind.Other ) - - const val string = "String" - const val boolean = "Boolean" - const val int = "Int" } val elements = mutableListOf(baseFirElement) diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/ElementUtils.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/ElementUtils.kt index a20a6b030a4..c9db3a74bf8 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/ElementUtils.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/model/ElementUtils.kt @@ -5,19 +5,13 @@ package org.jetbrains.kotlin.fir.tree.generator.model -import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder -import org.jetbrains.kotlin.fir.tree.generator.context.type -import org.jetbrains.kotlin.generators.tree.typeWithArguments -import org.jetbrains.kotlin.generators.tree.Importable import org.jetbrains.kotlin.generators.tree.NamedTypeParameterRef +import org.jetbrains.kotlin.generators.tree.StandardTypes import org.jetbrains.kotlin.generators.tree.TypeRef +import org.jetbrains.kotlin.generators.tree.typeWithArguments // ----------- Simple field ----------- -fun field(name: String, type: String, packageName: String?, customType: TypeRef? = null, nullable: Boolean = false, withReplace: Boolean = false): Field { - return SimpleField(name, type, packageName, customType, nullable, withReplace) -} - fun field(name: String, type: TypeRef, nullable: Boolean = false, withReplace: Boolean = false): Field { return SimpleField(name, type.typeWithArguments, type.packageName, null, nullable, withReplace) } @@ -34,15 +28,15 @@ fun field(type: TypeRef, nullable: Boolean = false, withReplace: Boolean = false } fun booleanField(name: String, withReplace: Boolean = false): Field { - return field(name, AbstractFirTreeBuilder.boolean, null, withReplace = withReplace) + return field(name, StandardTypes.boolean, withReplace = withReplace) } fun stringField(name: String, nullable: Boolean = false): Field { - return field(name, AbstractFirTreeBuilder.string, null, null, nullable) + return field(name, StandardTypes.string, nullable = nullable) } fun intField(name: String, withReplace: Boolean = false): Field { - return field(name, AbstractFirTreeBuilder.int, null, withReplace = withReplace) + return field(name, StandardTypes.int, withReplace = withReplace) } // ----------- Fir field ----------- diff --git a/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/StandardTypes.kt b/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/StandardTypes.kt index d76216dbb48..bef3ff6d7e2 100644 --- a/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/StandardTypes.kt +++ b/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/StandardTypes.kt @@ -6,5 +6,9 @@ package org.jetbrains.kotlin.generators.tree object StandardTypes { + val boolean = type() + val string = type() + val int = type() + val collection = type>() val map = type>() } \ No newline at end of file