[tree generator] Minor: pass model inside ImplementationConfigurator
Needed for config across many elements in subsequent commits. ^KT-65773 In Progress
This commit is contained in:
committed by
Space Team
parent
e737320d01
commit
6fadc51856
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.generators.tree.ImplementationKind.OpenClass
|
||||
|
||||
object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() {
|
||||
|
||||
override fun configure() = with(FirTreeBuilder) {
|
||||
override fun configure(model: Model) = with(FirTreeBuilder) {
|
||||
impl(constructor) {
|
||||
defaultFalse("isPrimary", withGetter = true)
|
||||
}
|
||||
@@ -627,7 +627,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
}
|
||||
}
|
||||
|
||||
override fun configureAllImplementations() {
|
||||
override fun configureAllImplementations(model: Model) {
|
||||
configureFieldInAllImplementations(
|
||||
field = "controlFlowGraphReference",
|
||||
implementationPredicate = { it.typeName != "FirAnonymousFunctionImpl" }
|
||||
|
||||
+3
-1
@@ -6,8 +6,8 @@
|
||||
package org.jetbrains.kotlin.fir.tree.generator
|
||||
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder
|
||||
import org.jetbrains.kotlin.fir.tree.generator.model.Element
|
||||
import org.jetbrains.kotlin.fir.tree.generator.printer.*
|
||||
import org.jetbrains.kotlin.generators.tree.Model
|
||||
import org.jetbrains.kotlin.generators.tree.printer.generateTree
|
||||
import org.jetbrains.kotlin.utils.bind
|
||||
import java.io.File
|
||||
@@ -15,6 +15,8 @@ import java.io.File
|
||||
internal const val BASE_PACKAGE = "org.jetbrains.kotlin.fir"
|
||||
internal const val VISITOR_PACKAGE = "$BASE_PACKAGE.visitors"
|
||||
|
||||
typealias Model = org.jetbrains.kotlin.generators.tree.Model<Element>
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val generationPath = args.firstOrNull()?.let { File(it) }
|
||||
?: File("../../tree/gen").canonicalFile
|
||||
|
||||
+3
-2
@@ -6,14 +6,15 @@
|
||||
package org.jetbrains.kotlin.ir.generator
|
||||
|
||||
import org.jetbrains.kotlin.ir.generator.config.AbstractIrTreeImplementationConfigurator
|
||||
import org.jetbrains.kotlin.ir.generator.model.Element
|
||||
|
||||
object ImplementationConfigurator : AbstractIrTreeImplementationConfigurator() {
|
||||
override fun configure(): Unit = with(IrTree) {
|
||||
override fun configure(model: Model): Unit = with(IrTree) {
|
||||
impl(simpleFunction)
|
||||
impl(property)
|
||||
}
|
||||
|
||||
override fun configureAllImplementations() {
|
||||
override fun configureAllImplementations(model: Model) {
|
||||
// Use configureFieldInAllImplementations to customize certain fields in all implementation classes
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -23,9 +23,9 @@ abstract class AbstractImplementationConfigurator<Implementation, Element, Imple
|
||||
protected abstract fun createImplementation(element: Element, name: String?): Implementation
|
||||
|
||||
fun configureImplementations(model: Model<Element>) {
|
||||
configure()
|
||||
configure(model)
|
||||
generateDefaultImplementations(model.elements)
|
||||
configureAllImplementations()
|
||||
configureAllImplementations(model)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ abstract class AbstractImplementationConfigurator<Implementation, Element, Imple
|
||||
*
|
||||
* Override this method and use [noImpl] or [impl] in it to configure implementations of tree nodes.
|
||||
*/
|
||||
protected abstract fun configure()
|
||||
protected abstract fun configure(model: Model<Element>)
|
||||
|
||||
/**
|
||||
* A customization point for batch-applying rules to existing implementations.
|
||||
@@ -41,7 +41,7 @@ abstract class AbstractImplementationConfigurator<Implementation, Element, Imple
|
||||
* Override this method and use [configureFieldInAllImplementations] to configure fields that are common to multiple implementation
|
||||
* classes.
|
||||
*/
|
||||
protected abstract fun configureAllImplementations()
|
||||
protected abstract fun configureAllImplementations(model: Model<Element>)
|
||||
|
||||
/**
|
||||
* Disables generating any implementation classes for [element].
|
||||
|
||||
+2
-2
@@ -9,11 +9,11 @@ import org.jetbrains.kotlin.sir.tree.generator.config.AbstractSwiftIrTreeImpleme
|
||||
|
||||
object ImplementationConfigurator : AbstractSwiftIrTreeImplementationConfigurator() {
|
||||
|
||||
override fun configure() = with(SwiftIrTree) {
|
||||
override fun configure(model: Model) = with(SwiftIrTree) {
|
||||
// Declare custom implementation classes, see org.jetbrains.kotlin.fir.tree.generator.ImplementationConfigurator
|
||||
}
|
||||
|
||||
override fun configureAllImplementations() {
|
||||
override fun configureAllImplementations(model: Model) {
|
||||
// Use configureFieldInAllImplementations to customize certain fields in all implementation classes
|
||||
configureFieldInAllImplementations(
|
||||
field = "parent",
|
||||
|
||||
Reference in New Issue
Block a user