[SIR generator] Add SirVisitorVoid class
This is convenient for cases when the visitor has no context to pass to each method
This commit is contained in:
committed by
Space Team
parent
80c9eae409
commit
80847b9ee2
+2
-2
@@ -60,8 +60,8 @@ abstract class AbstractVisitorVoidPrinter<Element, Field>(
|
||||
element,
|
||||
hasDataParameter = false,
|
||||
modality = when {
|
||||
element.isRootElement && visitorType.kind == TypeKind.Class -> Modality.ABSTRACT
|
||||
!element.isRootElement && visitorType.kind == TypeKind.Class -> Modality.OPEN
|
||||
isAbstractVisitRootElementMethod && visitorType.kind == TypeKind.Class -> Modality.ABSTRACT
|
||||
!isAbstractVisitRootElementMethod && visitorType.kind == TypeKind.Class -> Modality.OPEN
|
||||
else -> null
|
||||
}
|
||||
)
|
||||
|
||||
+14
@@ -348,4 +348,18 @@ fun SmartPrinter.printTransformChildrenMethod(
|
||||
)
|
||||
}
|
||||
|
||||
context(ImportCollector)
|
||||
fun SmartPrinter.printAcceptVoidMethod(visitorType: ClassRef<*>) {
|
||||
val visitorParameter = FunctionParameter("visitor", visitorType)
|
||||
printFunctionDeclaration("accept", listOf(visitorParameter), StandardTypes.unit)
|
||||
println(" = accept(", visitorParameter.name, ", null)")
|
||||
}
|
||||
|
||||
context(ImportCollector)
|
||||
fun SmartPrinter.printAcceptChildrenVoidMethod(visitorType: ClassRef<*>) {
|
||||
val visitorParameter = FunctionParameter("visitor", visitorType)
|
||||
printFunctionDeclaration("acceptChildren", listOf(visitorParameter), StandardTypes.unit)
|
||||
println(" = acceptChildren(", visitorParameter.name, ", null)")
|
||||
}
|
||||
|
||||
fun AbstractField<*>.call(): String = if (nullable) "?." else "."
|
||||
|
||||
Reference in New Issue
Block a user