[SIR, FIR generators] Add KDocs for visitor-related methods of elements
This commit is contained in:
committed by
Space Team
parent
1bed6a063f
commit
cab87eba21
@@ -40,6 +40,11 @@ interface FirElement {
|
||||
fun <E : FirElement, D> transform(transformer: FirTransformer<D>, data: D): E =
|
||||
transformer.transformElement(this, data) as E
|
||||
|
||||
/**
|
||||
* Runs the provided [visitor] on the FIR subtree with the root at this node.
|
||||
*
|
||||
* @param visitor The visitor to accept.
|
||||
*/
|
||||
fun accept(visitor: FirVisitorVoid) = accept(visitor, null)
|
||||
|
||||
/**
|
||||
@@ -54,6 +59,15 @@ interface FirElement {
|
||||
*/
|
||||
fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D)
|
||||
|
||||
/**
|
||||
* Runs the provided [visitor] on subtrees with roots in this node's children.
|
||||
*
|
||||
* Basically, calls `accept(visitor)` on each child of this node.
|
||||
*
|
||||
* Does **not** run [visitor] on this node itself.
|
||||
*
|
||||
* @param visitor The visitor for children to accept.
|
||||
*/
|
||||
fun acceptChildren(visitor: FirVisitorVoid) = acceptChildren(visitor, null)
|
||||
|
||||
/**
|
||||
|
||||
+4
-3
@@ -21,14 +21,15 @@ internal class ElementPrinter(printer: SmartPrinter) : AbstractElementPrinter<El
|
||||
override fun SmartPrinter.printAdditionalMethods(element: Element) {
|
||||
val kind = element.kind ?: error("Expected non-null element kind")
|
||||
with(element) {
|
||||
printAcceptMethod(element, firVisitorType, hasImplementation = true, treeName = "FIR")
|
||||
val treeName = "FIR"
|
||||
printAcceptMethod(element, firVisitorType, hasImplementation = true, treeName = treeName)
|
||||
|
||||
printTransformMethod(
|
||||
element = element,
|
||||
transformerClass = firTransformerType,
|
||||
implementation = "transformer.transform${element.name}(this, data)",
|
||||
returnType = TypeVariable("E", listOf(AbstractFirTreeBuilder.baseFirElement)),
|
||||
treeName = "FIR",
|
||||
treeName = treeName,
|
||||
)
|
||||
|
||||
fun Field.replaceDeclaration(override: Boolean, overridenType: TypeRefWithNullability? = null, forceNullable: Boolean = false) {
|
||||
@@ -66,7 +67,7 @@ internal class ElementPrinter(printer: SmartPrinter) : AbstractElementPrinter<El
|
||||
|
||||
if (element.isRootElement) {
|
||||
println()
|
||||
printAcceptVoidMethod(firVisitorVoidType)
|
||||
printAcceptVoidMethod(firVisitorVoidType, treeName)
|
||||
printAcceptChildrenMethod(
|
||||
element = element,
|
||||
visitorClass = firVisitorType,
|
||||
|
||||
Reference in New Issue
Block a user