From 39c84bca06d32a09e7d508f0f6bcc356ec02373d Mon Sep 17 00:00:00 2001 From: Sergej Jaskiewicz Date: Wed, 6 Dec 2023 13:07:33 +0100 Subject: [PATCH] [tree generators] Add a method for configuring all leaf builders It will be used in the new Swift IR tree that will be added in the next commit. --- .../tree/config/AbstractBuilderConfigurator.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/config/AbstractBuilderConfigurator.kt b/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/config/AbstractBuilderConfigurator.kt index 2469637d6e9..02874dd3f68 100644 --- a/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/config/AbstractBuilderConfigurator.kt +++ b/generators/tree-generator-common/src/org/jetbrains/kotlin/generators/tree/config/AbstractBuilderConfigurator.kt @@ -127,6 +127,9 @@ abstract class AbstractBuilderConfigurator> + get() = elements.flatMap { it.allImplementations }.mapNotNull { it.builder } + /** * Allows to batch-apply [config] to certain fields in _all_ the builders that satisfy the given * [builderPredicate]. @@ -143,8 +146,7 @@ abstract class AbstractBuilderConfigurator Boolean)? = null, config: LeafBuilderConfigurationContext.(field: String) -> Unit ) { - val builders = elements.flatMap { it.allImplementations }.mapNotNull { it.builder } - for (builder in builders) { + for (builder in allLeafBuilders) { if (builderPredicate != null && !builderPredicate(builder)) continue if (!builder.allFields.any { it.name == field }) continue if (fieldPredicate != null && !fieldPredicate(builder[field])) continue @@ -152,6 +154,17 @@ abstract class AbstractBuilderConfigurator Unit) { + for (builder in allLeafBuilders) { + LeafBuilderConfigurationContext(builder).config() + } + } + /** * A DSL for configuring one or more intermediate or leaf builder classes. */