Skip to content

Move result builder as last parameters #294

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ import SwiftSyntax
extension ${node.syntax_kind} {
public init(
% init_parameters = []
% init_result_builder_parameters = []
% for child in node.children:
% child_node = NODE_MAP.get(child.syntax_kind)
% child_token = SYNTAX_TOKEN_MAP.get(child.syntax_kind)
% if child_node and child_node.is_syntax_collection():
% # Allow initializing syntax collections with result builders
% default_value = "? = { nil }" if child.is_optional else " = { .empty }"
% init_parameters.append("@%sBuilder %sBuilder: () -> %s%s" % (child.syntax_kind, child.swift_name, child.syntax_kind, default_value))
% init_result_builder_parameters.append("@%sBuilder %sBuilder: () -> %s%s" % (child.syntax_kind, child.swift_name, child.syntax_kind, default_value))
% elif child_token and not child_token.text:
% # Allow initializing identifier or a token without a text with String value
% param_type = "String?" if child.is_optional else "String"
Expand All @@ -55,7 +56,7 @@ extension ${node.syntax_kind} {
% init_parameters.append("%s: %s%s" % (child.swift_name, param_type, default_value))
% end
% end
${',\n '.join(init_parameters)}
${',\n '.join(init_parameters + init_result_builder_parameters)}
) {
self.init(
% init_parameters = []
Expand Down
Loading