[SIR] Add SirTransformerVoid class
This is convenient for cases when the transformer has no context to pass to each method
This commit is contained in:
committed by
Space Team
parent
1bc2ac2c87
commit
1bed6a063f
+3
-9
@@ -20,16 +20,10 @@ import org.jetbrains.kotlin.utils.withIndent
|
|||||||
internal class TransformerVoidPrinter(
|
internal class TransformerVoidPrinter(
|
||||||
printer: SmartPrinter,
|
printer: SmartPrinter,
|
||||||
override val visitorType: ClassRef<*>,
|
override val visitorType: ClassRef<*>,
|
||||||
) : AbstractTransformerPrinter<Element, Field>(printer) {
|
) : AbstractTransformerVoidPrinter<Element, Field>(printer) {
|
||||||
|
|
||||||
override val visitorTypeParameters: List<TypeVariable>
|
override val transformerSuperClass: ClassRef<PositionTypeParameterRef>
|
||||||
get() = emptyList()
|
get() = elementTransformerType
|
||||||
|
|
||||||
override val visitorSuperType: ClassRef<PositionTypeParameterRef>
|
|
||||||
get() = elementTransformerType.withArgs(visitorDataType)
|
|
||||||
|
|
||||||
override val visitorDataType: TypeRef
|
|
||||||
get() = StandardTypes.nothing.copy(nullable = true)
|
|
||||||
|
|
||||||
// IrPackageFragment is treated as transformByChildren in IrElementTransformerVoid for historical reasons.
|
// IrPackageFragment is treated as transformByChildren in IrElementTransformerVoid for historical reasons.
|
||||||
private val Element.isPackageFragment: Boolean
|
private val Element.isPackageFragment: Boolean
|
||||||
|
|||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.generators.tree
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
|
import org.jetbrains.kotlin.generators.tree.printer.FunctionParameter
|
||||||
|
import org.jetbrains.kotlin.generators.tree.printer.printFunctionDeclaration
|
||||||
|
import org.jetbrains.kotlin.utils.SmartPrinter
|
||||||
|
import org.jetbrains.kotlin.utils.withIndent
|
||||||
|
|
||||||
|
abstract class AbstractTransformerVoidPrinter<Element : AbstractElement<Element, Field, *>, Field : AbstractField<Field>>(
|
||||||
|
printer: SmartPrinter
|
||||||
|
) : AbstractTransformerPrinter<Element, Field>(printer) {
|
||||||
|
|
||||||
|
final override val visitorTypeParameters: List<TypeVariable>
|
||||||
|
get() = emptyList()
|
||||||
|
|
||||||
|
final override val visitorDataType: TypeRef
|
||||||
|
get() = StandardTypes.nothing.copy(nullable = true)
|
||||||
|
|
||||||
|
abstract val transformerSuperClass: ClassRef<PositionTypeParameterRef>
|
||||||
|
|
||||||
|
override val visitorSuperType: ClassRef<PositionTypeParameterRef>?
|
||||||
|
get() = transformerSuperClass.withArgs(visitorDataType)
|
||||||
|
|
||||||
|
context(ImportCollector)
|
||||||
|
override fun printMethodsForElement(element: Element) {
|
||||||
|
printer.run {
|
||||||
|
val elementParameterName = element.visitorParameterName
|
||||||
|
val dataParameter = FunctionParameter("data", visitorDataType)
|
||||||
|
val methodName = "transform" + element.name
|
||||||
|
if (element.isRootElement) {
|
||||||
|
println()
|
||||||
|
val elementTP = TypeVariable("E", listOf(element))
|
||||||
|
printFunctionDeclaration(
|
||||||
|
name = methodName,
|
||||||
|
parameters = listOf(FunctionParameter(elementParameterName, elementTP)),
|
||||||
|
returnType = elementTP,
|
||||||
|
typeParameters = listOf(elementTP),
|
||||||
|
modality = Modality.ABSTRACT,
|
||||||
|
)
|
||||||
|
println()
|
||||||
|
println()
|
||||||
|
printFunctionDeclaration(
|
||||||
|
name = methodName,
|
||||||
|
parameters = listOf(FunctionParameter(elementParameterName, elementTP), dataParameter),
|
||||||
|
returnType = elementTP,
|
||||||
|
typeParameters = listOf(elementTP),
|
||||||
|
modality = Modality.FINAL,
|
||||||
|
override = true,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
val parentInVisitor = parentInVisitor(element) ?: return
|
||||||
|
val returnType = visitMethodReturnType(element)
|
||||||
|
println()
|
||||||
|
printFunctionDeclaration(
|
||||||
|
name = methodName,
|
||||||
|
parameters = listOf(FunctionParameter(elementParameterName, element)),
|
||||||
|
returnType = returnType,
|
||||||
|
modality = Modality.OPEN,
|
||||||
|
)
|
||||||
|
println(" =")
|
||||||
|
withIndent {
|
||||||
|
println("transform", parentInVisitor.name, "(", elementParameterName, ")")
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
printFunctionDeclaration(
|
||||||
|
name = methodName,
|
||||||
|
parameters = listOf(FunctionParameter(elementParameterName, element), dataParameter),
|
||||||
|
returnType = returnType,
|
||||||
|
modality = Modality.FINAL,
|
||||||
|
override = true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
println(" =")
|
||||||
|
withIndent {
|
||||||
|
println(methodName, "(", elementParameterName, ")")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+83
-21
@@ -237,6 +237,27 @@ fun SmartPrinter.printAcceptMethod(
|
|||||||
println()
|
println()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun transformMethodKDoc(
|
||||||
|
transformerParameter: FunctionParameter,
|
||||||
|
dataParameter: FunctionParameter?,
|
||||||
|
treeName: String,
|
||||||
|
) = buildString {
|
||||||
|
append("Runs the provided [")
|
||||||
|
append(transformerParameter.name)
|
||||||
|
append("] on the $treeName subtree with the root at this node.\n\n")
|
||||||
|
append("@param ")
|
||||||
|
append(transformerParameter.name)
|
||||||
|
append(" The transformer to use.")
|
||||||
|
if (dataParameter != null) {
|
||||||
|
append("\n@param ")
|
||||||
|
append(dataParameter.name)
|
||||||
|
append(" An arbitrary context to pass to each invocation of [")
|
||||||
|
append(transformerParameter.name)
|
||||||
|
append("]'s methods.")
|
||||||
|
}
|
||||||
|
append("\n@return The transformed node.")
|
||||||
|
}
|
||||||
|
|
||||||
context(ImportCollector)
|
context(ImportCollector)
|
||||||
fun SmartPrinter.printTransformMethod(
|
fun SmartPrinter.printTransformMethod(
|
||||||
element: AbstractElement<*, *, *>,
|
element: AbstractElement<*, *, *>,
|
||||||
@@ -249,15 +270,7 @@ fun SmartPrinter.printTransformMethod(
|
|||||||
println()
|
println()
|
||||||
val transformerParameter = FunctionParameter("transformer", transformerClass.withArgs(dataTP))
|
val transformerParameter = FunctionParameter("transformer", transformerClass.withArgs(dataTP))
|
||||||
if (element.isRootElement) {
|
if (element.isRootElement) {
|
||||||
printKDoc(
|
printKDoc(transformMethodKDoc(transformerParameter, dataParameter, treeName))
|
||||||
"""
|
|
||||||
Runs the provided [${transformerParameter.name}] on the $treeName subtree with the root at this node.
|
|
||||||
|
|
||||||
@param ${transformerParameter.name} The transformer to use.
|
|
||||||
@param ${dataParameter.name} An arbitrary context to pass to each invocation of [${transformerParameter.name}]'s methods.
|
|
||||||
@return The transformed node.
|
|
||||||
""".trimIndent()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (returnType is TypeParameterRef && implementation != null) {
|
if (returnType is TypeParameterRef && implementation != null) {
|
||||||
println("@Suppress(\"UNCHECKED_CAST\")")
|
println("@Suppress(\"UNCHECKED_CAST\")")
|
||||||
@@ -313,6 +326,36 @@ fun SmartPrinter.printAcceptChildrenMethod(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun transformChildrenMethodKDoc(transformerParameter: FunctionParameter, dataParameter: FunctionParameter?, returnType: TypeRef) =
|
||||||
|
buildString {
|
||||||
|
append("Recursively transforms this node's children *in place* using [")
|
||||||
|
append(transformerParameter.name)
|
||||||
|
append("].\n\n")
|
||||||
|
append("Basically, executes `this.child = this.child.transform(")
|
||||||
|
append(transformerParameter.name)
|
||||||
|
if (dataParameter != null) {
|
||||||
|
append(", ")
|
||||||
|
append(dataParameter.name)
|
||||||
|
}
|
||||||
|
append(")` for each child of this node.\n\n")
|
||||||
|
append("Does **not** run [")
|
||||||
|
append(transformerParameter.name)
|
||||||
|
append("] on this node itself.\n\n")
|
||||||
|
append("@param ")
|
||||||
|
append(transformerParameter.name)
|
||||||
|
append(" The transformer to use for transforming the children.")
|
||||||
|
if (dataParameter != null) {
|
||||||
|
append("\n@param ")
|
||||||
|
append(dataParameter.name)
|
||||||
|
append(" An arbitrary context to pass to each invocation of [")
|
||||||
|
append(transformerParameter.name)
|
||||||
|
append("]'s methods.")
|
||||||
|
}
|
||||||
|
if (returnType != StandardTypes.unit) {
|
||||||
|
append("\n@return `this`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
context(ImportCollector)
|
context(ImportCollector)
|
||||||
fun SmartPrinter.printTransformChildrenMethod(
|
fun SmartPrinter.printTransformChildrenMethod(
|
||||||
element: FieldContainer<*>,
|
element: FieldContainer<*>,
|
||||||
@@ -325,18 +368,7 @@ fun SmartPrinter.printTransformChildrenMethod(
|
|||||||
println()
|
println()
|
||||||
val transformerParameter = FunctionParameter("transformer", transformerClass.withArgs(dataTP))
|
val transformerParameter = FunctionParameter("transformer", transformerClass.withArgs(dataTP))
|
||||||
if (!override) {
|
if (!override) {
|
||||||
printKDoc(
|
printKDoc(transformChildrenMethodKDoc(transformerParameter, dataParameter, returnType))
|
||||||
"""
|
|
||||||
Recursively transforms this node's children *in place* using [${transformerParameter.name}].
|
|
||||||
|
|
||||||
Basically, executes `this.child = this.child.transform(${transformerParameter.name}, ${dataParameter.name})` for each child of this node.
|
|
||||||
|
|
||||||
Does **not** run [${transformerParameter.name}] on this node itself.
|
|
||||||
|
|
||||||
@param ${transformerParameter.name} The transformer to use for transforming the children.
|
|
||||||
@param ${dataParameter.name} An arbitrary context to pass to each invocation of [${transformerParameter.name}]'s methods.
|
|
||||||
""".trimIndent() + (if (returnType == StandardTypes.unit) "" else "\n@return `this`")
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
printFunctionDeclaration(
|
printFunctionDeclaration(
|
||||||
name = "transformChildren",
|
name = "transformChildren",
|
||||||
@@ -362,4 +394,34 @@ fun SmartPrinter.printAcceptChildrenVoidMethod(visitorType: ClassRef<*>) {
|
|||||||
println(" = acceptChildren(", visitorParameter.name, ", null)")
|
println(" = acceptChildren(", visitorParameter.name, ", null)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context(ImportCollector)
|
||||||
|
fun SmartPrinter.printTransformVoidMethod(element: AbstractElement<*, *, *>, transformerType: ClassRef<*>, treeName: String) {
|
||||||
|
assert(element.isRootElement) { "Expected root element" }
|
||||||
|
val transformerParameter = FunctionParameter("transformer", transformerType)
|
||||||
|
val elementTP = TypeVariable("E", listOf(element))
|
||||||
|
printKDoc(transformMethodKDoc(transformerParameter, null, treeName))
|
||||||
|
printFunctionDeclaration(
|
||||||
|
name = "transform",
|
||||||
|
parameters = listOf(transformerParameter),
|
||||||
|
returnType = elementTP,
|
||||||
|
typeParameters = listOf(elementTP)
|
||||||
|
)
|
||||||
|
println(" =")
|
||||||
|
withIndent {
|
||||||
|
println("transform(", transformerParameter.name, ", null)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context(ImportCollector)
|
||||||
|
fun SmartPrinter.printTransformChildrenVoidMethod(element: AbstractElement<*, *, *>, visitorType: ClassRef<*>, returnType: TypeRef) {
|
||||||
|
assert(element.isRootElement) { "Expected root element" }
|
||||||
|
val transformerParameter = FunctionParameter("transformer", visitorType)
|
||||||
|
printKDoc(transformChildrenMethodKDoc(transformerParameter, null, returnType))
|
||||||
|
printFunctionDeclaration("transformChildren", listOf(transformerParameter), returnType)
|
||||||
|
println(" =")
|
||||||
|
withIndent {
|
||||||
|
println("transformChildren(", transformerParameter.name, ", null)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun AbstractField<*>.call(): String = if (nullable) "?." else "."
|
fun AbstractField<*>.call(): String = if (nullable) "?." else "."
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.jetbrains.kotlin.sir
|
package org.jetbrains.kotlin.sir
|
||||||
|
|
||||||
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
import org.jetbrains.kotlin.sir.visitors.SirTransformer
|
||||||
|
import org.jetbrains.kotlin.sir.visitors.SirTransformerVoid
|
||||||
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
import org.jetbrains.kotlin.sir.visitors.SirVisitor
|
||||||
import org.jetbrains.kotlin.sir.visitors.SirVisitorVoid
|
import org.jetbrains.kotlin.sir.visitors.SirVisitorVoid
|
||||||
|
|
||||||
@@ -54,6 +55,15 @@ sealed interface SirElement {
|
|||||||
|
|
||||||
fun acceptChildren(visitor: SirVisitorVoid) = acceptChildren(visitor, null)
|
fun acceptChildren(visitor: SirVisitorVoid) = acceptChildren(visitor, null)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs the provided [transformer] on the Swift IR subtree with the root at this node.
|
||||||
|
*
|
||||||
|
* @param transformer The transformer to use.
|
||||||
|
* @return The transformed node.
|
||||||
|
*/
|
||||||
|
fun <E : SirElement> transform(transformer: SirTransformerVoid): E =
|
||||||
|
transform(transformer, null)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively transforms this node's children *in place* using [transformer].
|
* Recursively transforms this node's children *in place* using [transformer].
|
||||||
*
|
*
|
||||||
@@ -65,4 +75,16 @@ sealed interface SirElement {
|
|||||||
* @param data An arbitrary context to pass to each invocation of [transformer]'s methods.
|
* @param data An arbitrary context to pass to each invocation of [transformer]'s methods.
|
||||||
*/
|
*/
|
||||||
fun <D> transformChildren(transformer: SirTransformer<D>, data: D)
|
fun <D> transformChildren(transformer: SirTransformer<D>, data: D)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively transforms this node's children *in place* using [transformer].
|
||||||
|
*
|
||||||
|
* Basically, executes `this.child = this.child.transform(transformer)` for each child of this node.
|
||||||
|
*
|
||||||
|
* Does **not** run [transformer] on this node itself.
|
||||||
|
*
|
||||||
|
* @param transformer The transformer to use for transforming the children.
|
||||||
|
*/
|
||||||
|
fun transformChildren(transformer: SirTransformerVoid) =
|
||||||
|
transformChildren(transformer, null)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This file was generated automatically. See native/swift/sir/tree-generator/Readme.md.
|
||||||
|
// DO NOT MODIFY IT MANUALLY.
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.sir.visitors
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.sir.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated by [org.jetbrains.kotlin.sir.tree.generator.printer.TransformerVoidPrinter]
|
||||||
|
*/
|
||||||
|
abstract class SirTransformerVoid : SirTransformer<Nothing?>() {
|
||||||
|
|
||||||
|
abstract fun <E : SirElement> transformElement(element: E): E
|
||||||
|
|
||||||
|
final override fun <E : SirElement> transformElement(element: E, data: Nothing?): E =
|
||||||
|
transformElement(element)
|
||||||
|
|
||||||
|
open fun transformModule(module: SirModule): SirModule =
|
||||||
|
transformElement(module)
|
||||||
|
|
||||||
|
final override fun transformModule(module: SirModule, data: Nothing?): SirModule =
|
||||||
|
transformModule(module)
|
||||||
|
|
||||||
|
open fun transformDeclarationContainer(declarationContainer: SirDeclarationContainer): SirDeclarationContainer =
|
||||||
|
transformElement(declarationContainer)
|
||||||
|
|
||||||
|
final override fun transformDeclarationContainer(declarationContainer: SirDeclarationContainer, data: Nothing?): SirDeclarationContainer =
|
||||||
|
transformDeclarationContainer(declarationContainer)
|
||||||
|
|
||||||
|
open fun transformDeclaration(declaration: SirDeclaration): SirDeclaration =
|
||||||
|
transformElement(declaration)
|
||||||
|
|
||||||
|
final override fun transformDeclaration(declaration: SirDeclaration, data: Nothing?): SirDeclaration =
|
||||||
|
transformDeclaration(declaration)
|
||||||
|
|
||||||
|
open fun transformForeignDeclaration(foreignDeclaration: SirForeignDeclaration): SirDeclaration =
|
||||||
|
transformDeclaration(foreignDeclaration)
|
||||||
|
|
||||||
|
final override fun transformForeignDeclaration(foreignDeclaration: SirForeignDeclaration, data: Nothing?): SirDeclaration =
|
||||||
|
transformForeignDeclaration(foreignDeclaration)
|
||||||
|
|
||||||
|
open fun transformNamedDeclaration(namedDeclaration: SirNamedDeclaration): SirDeclaration =
|
||||||
|
transformDeclaration(namedDeclaration)
|
||||||
|
|
||||||
|
final override fun transformNamedDeclaration(namedDeclaration: SirNamedDeclaration, data: Nothing?): SirDeclaration =
|
||||||
|
transformNamedDeclaration(namedDeclaration)
|
||||||
|
|
||||||
|
open fun transformEnum(enum: SirEnum): SirDeclaration =
|
||||||
|
transformNamedDeclaration(enum)
|
||||||
|
|
||||||
|
final override fun transformEnum(enum: SirEnum, data: Nothing?): SirDeclaration =
|
||||||
|
transformEnum(enum)
|
||||||
|
|
||||||
|
open fun transformStruct(struct: SirStruct): SirDeclaration =
|
||||||
|
transformNamedDeclaration(struct)
|
||||||
|
|
||||||
|
final override fun transformStruct(struct: SirStruct, data: Nothing?): SirDeclaration =
|
||||||
|
transformStruct(struct)
|
||||||
|
|
||||||
|
open fun transformCallable(callable: SirCallable): SirDeclaration =
|
||||||
|
transformDeclaration(callable)
|
||||||
|
|
||||||
|
final override fun transformCallable(callable: SirCallable, data: Nothing?): SirDeclaration =
|
||||||
|
transformCallable(callable)
|
||||||
|
|
||||||
|
open fun transformFunction(function: SirFunction): SirDeclaration =
|
||||||
|
transformCallable(function)
|
||||||
|
|
||||||
|
final override fun transformFunction(function: SirFunction, data: Nothing?): SirDeclaration =
|
||||||
|
transformFunction(function)
|
||||||
|
|
||||||
|
open fun transformForeignFunction(foreignFunction: SirForeignFunction): SirDeclaration =
|
||||||
|
transformCallable(foreignFunction)
|
||||||
|
|
||||||
|
final override fun transformForeignFunction(foreignFunction: SirForeignFunction, data: Nothing?): SirDeclaration =
|
||||||
|
transformForeignFunction(foreignFunction)
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@ fun main(args: Array<String>) {
|
|||||||
elementVisitorType to ::VisitorPrinter,
|
elementVisitorType to ::VisitorPrinter,
|
||||||
elementVisitorVoidType to ::VisitorVoidPrinter,
|
elementVisitorVoidType to ::VisitorVoidPrinter,
|
||||||
elementTransformerType to ::TransformerPrinter.bind(model.rootElement),
|
elementTransformerType to ::TransformerPrinter.bind(model.rootElement),
|
||||||
|
elementTransformerVoidType to ::TransformerVoidPrinter,
|
||||||
),
|
),
|
||||||
ImplementationConfigurator,
|
ImplementationConfigurator,
|
||||||
BuilderConfigurator(model.elements),
|
BuilderConfigurator(model.elements),
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ private const val VISITORS_PACKAGE = "$BASE_PACKAGE.visitors"
|
|||||||
val elementVisitorType = type(VISITORS_PACKAGE, "SirVisitor", TypeKind.Class)
|
val elementVisitorType = type(VISITORS_PACKAGE, "SirVisitor", TypeKind.Class)
|
||||||
val elementVisitorVoidType = type(VISITORS_PACKAGE, "SirVisitorVoid", TypeKind.Class)
|
val elementVisitorVoidType = type(VISITORS_PACKAGE, "SirVisitorVoid", TypeKind.Class)
|
||||||
val elementTransformerType = type(VISITORS_PACKAGE, "SirTransformer", TypeKind.Class)
|
val elementTransformerType = type(VISITORS_PACKAGE, "SirTransformer", TypeKind.Class)
|
||||||
|
val elementTransformerVoidType = type(VISITORS_PACKAGE, "SirTransformerVoid", TypeKind.Class)
|
||||||
|
|
||||||
val swiftIrImplementationDetailAnnotation = type(BASE_PACKAGE, "SirImplementationDetail", TypeKind.Class)
|
val swiftIrImplementationDetailAnnotation = type(BASE_PACKAGE, "SirImplementationDetail", TypeKind.Class)
|
||||||
val swiftIrBuilderDslAnnotation = type(BASE_PACKAGE, "SirBuilderDsl", TypeKind.Class)
|
val swiftIrBuilderDslAnnotation = type(BASE_PACKAGE, "SirBuilderDsl", TypeKind.Class)
|
||||||
|
|||||||
+5
-4
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.sir.tree.generator.printer
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.generators.tree.*
|
import org.jetbrains.kotlin.generators.tree.*
|
||||||
import org.jetbrains.kotlin.generators.tree.printer.*
|
import org.jetbrains.kotlin.generators.tree.printer.*
|
||||||
import org.jetbrains.kotlin.sir.tree.generator.SwiftIrTree
|
import org.jetbrains.kotlin.sir.tree.generator.*
|
||||||
import org.jetbrains.kotlin.sir.tree.generator.elementTransformerType
|
|
||||||
import org.jetbrains.kotlin.sir.tree.generator.elementVisitorType
|
|
||||||
import org.jetbrains.kotlin.sir.tree.generator.elementVisitorVoidType
|
|
||||||
import org.jetbrains.kotlin.sir.tree.generator.model.Element
|
import org.jetbrains.kotlin.sir.tree.generator.model.Element
|
||||||
import org.jetbrains.kotlin.sir.tree.generator.model.Field
|
import org.jetbrains.kotlin.sir.tree.generator.model.Field
|
||||||
import org.jetbrains.kotlin.utils.SmartPrinter
|
import org.jetbrains.kotlin.utils.SmartPrinter
|
||||||
@@ -42,8 +39,12 @@ internal class ElementPrinter(printer: SmartPrinter) : AbstractElementPrinter<El
|
|||||||
println()
|
println()
|
||||||
println()
|
println()
|
||||||
printAcceptChildrenVoidMethod(elementVisitorVoidType)
|
printAcceptChildrenVoidMethod(elementVisitorVoidType)
|
||||||
|
println()
|
||||||
|
printTransformVoidMethod(element, elementTransformerVoidType, treeName)
|
||||||
printTransformChildrenMethod(element, elementTransformerType, StandardTypes.unit)
|
printTransformChildrenMethod(element, elementTransformerType, StandardTypes.unit)
|
||||||
println()
|
println()
|
||||||
|
println()
|
||||||
|
printTransformChildrenVoidMethod(element, elementTransformerVoidType, StandardTypes.unit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.sir.tree.generator.printer
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.generators.tree.AbstractTransformerVoidPrinter
|
||||||
|
import org.jetbrains.kotlin.generators.tree.ClassRef
|
||||||
|
import org.jetbrains.kotlin.generators.tree.PositionTypeParameterRef
|
||||||
|
import org.jetbrains.kotlin.sir.tree.generator.elementTransformerType
|
||||||
|
import org.jetbrains.kotlin.sir.tree.generator.model.Element
|
||||||
|
import org.jetbrains.kotlin.sir.tree.generator.model.Field
|
||||||
|
import org.jetbrains.kotlin.utils.SmartPrinter
|
||||||
|
|
||||||
|
internal class TransformerVoidPrinter(
|
||||||
|
printer: SmartPrinter,
|
||||||
|
override val visitorType: ClassRef<*>,
|
||||||
|
) : AbstractTransformerVoidPrinter<Element, Field>(printer) {
|
||||||
|
|
||||||
|
override val transformerSuperClass: ClassRef<PositionTypeParameterRef>
|
||||||
|
get() = elementTransformerType
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user