Skip to content

Commit 0b0e20b

Browse files
committed
[SwiftSyntax] Added helper for swift buildables
1 parent 7da537c commit 0b0e20b

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)