Skip to content

Generate SYNTAX_NODES in SwiftSyntaxBuilderGeneration #482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2022

Conversation

fwcd
Copy link
Member

@fwcd fwcd commented Jul 2, 2022

A small patch that generates the Swift declarations for SYNTAX_NODES (thereby also moving this declaration into its own file for #479). These are required by many gyb templates in SwiftSyntaxBuilder and let us move forward with the migration to Swift templates.

The definition of SYNTAX_NODES is analogous to the corresponding declaration in gyb_syntax_support.

cc @ahoppen @kimdv

@fwcd fwcd requested a review from ahoppen as a code owner July 2, 2022 15:43
@fwcd
Copy link
Member Author

fwcd commented Jul 2, 2022

@swift-ci please test

@kimdv
Copy link
Contributor

kimdv commented Jul 2, 2022

A small note on the implementation: Instead of manually concatenating EXPR_NODES, DECL_NODES etc. we use gyb to generate all of these nodes again. While this causes us to generate new instances for all of these nodes, it eliminates the redundancy of having to manually enumerate all of the different node kinds (though feel free to comment on whether you would prefer the latter approach instead).

Personally I like merge of the arrays better, otherwise we have the same node twice.
So I would prefer the

let SYNTAX_NODES: [Node] = COMMON_NODES +
    EXPR_NODES +
    DECL_NODES +
    ATTRIBUTE_NODES +
    STMT_NODES +
    GENERIC_NODES +
    TYPE_NODES +
    PATTERN_NODES +
    AVAILABILITY_NODES

@fwcd
Copy link
Member Author

fwcd commented Jul 3, 2022

I don't have a strong opinion here, so if you prefer the concatenation, let's do that instead 👍

@fwcd fwcd force-pushed the syntax-nodes-gen branch from d9cc7c2 to 32fcc54 Compare July 3, 2022 12:44
@fwcd
Copy link
Member Author

fwcd commented Jul 3, 2022

@swift-ci please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fwcd fwcd merged commit 535b9be into swiftlang:main Jul 4, 2022
@fwcd fwcd deleted the syntax-nodes-gen branch July 4, 2022 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants