Skip to content

Commit 432f36e

Browse files
authored
Merge pull request #37426 from kimdv/kimdv/add-helper-method-for-swift-syntax
[SwiftSyntax] Added helper for swift buildables
2 parents 1050470 + 0b0e20b commit 432f36e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

utils/gyb_syntax_support/kinds.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,18 @@ def lowercase_first_word(name):
3838
if word_index == 0:
3939
return name
4040
return name[:word_index].lower() + name[word_index:]
41+
42+
43+
def syntax_buildable_child_type(type_name, syntax_kind, is_token,
44+
is_optional=False):
45+
if syntax_kind in SYNTAX_BASE_KINDS:
46+
buildable_type = syntax_kind + 'Buildable'
47+
elif not is_token:
48+
buildable_type = syntax_kind
49+
else:
50+
buildable_type = type_name
51+
52+
if is_optional:
53+
buildable_type += '?'
54+
55+
return buildable_type

0 commit comments

Comments
 (0)