Skip to content

Commit 1b61ff4

Browse files
authored
SwiftSyntax: add a new trait IdentifiedDeclSyntax. NFC (swiftlang#14691)
IdentifiedDeclSyntax allows clients to access and modify declared names. All nominal declarations should have this trait.
1 parent 649e0d9 commit 1b61ff4

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

utils/gyb_syntax_support/DeclNodes.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# typealias-name generic-parameter-clause?
1616
# type-assignment
1717
# typealias-name -> identifier
18-
Node('TypealiasDecl', kind='Decl',
18+
Node('TypealiasDecl', kind='Decl', traits=['IdentifiedDeclSyntax'],
1919
children=[
2020
Child('Attributes', kind='AttributeList',
2121
is_optional=True),
@@ -36,7 +36,7 @@
3636
# inheritance-clause? type-assignment?
3737
# generic-where-clause?
3838
# associatedtype-name -> identifier
39-
Node('AssociatedtypeDecl', kind='Decl',
39+
Node('AssociatedtypeDecl', kind='Decl', traits=['IdentifiedDeclSyntax'],
4040
children=[
4141
Child('Attributes', kind='AttributeList',
4242
is_optional=True),
@@ -157,7 +157,8 @@
157157
# generic-where-clause?
158158
# '{' class-members '}'
159159
# class-name -> identifier
160-
Node('ClassDecl', kind='Decl', traits=['DeclGroupSyntax'],
160+
Node('ClassDecl', kind='Decl',
161+
traits=['DeclGroupSyntax', 'IdentifiedDeclSyntax'],
161162
children=[
162163
Child('Attributes', kind='AttributeList',
163164
is_optional=True),
@@ -181,7 +182,8 @@
181182
# generic-where-clause?
182183
# '{' struct-members '}'
183184
# struct-name -> identifier
184-
Node('StructDecl', kind='Decl', traits=['DeclGroupSyntax'],
185+
Node('StructDecl', kind='Decl',
186+
traits=['DeclGroupSyntax', 'IdentifiedDeclSyntax'],
185187
children=[
186188
Child('Attributes', kind='AttributeList',
187189
is_optional=True),
@@ -198,7 +200,8 @@
198200
Child('Members', kind='MemberDeclBlock'),
199201
]),
200202

201-
Node('ProtocolDecl', kind='Decl', traits=['DeclGroupSyntax'],
203+
Node('ProtocolDecl', kind='Decl',
204+
traits=['DeclGroupSyntax', 'IdentifiedDeclSyntax'],
202205
children=[
203206
Child('Attributes', kind='AttributeList',
204207
is_optional=True),
@@ -312,7 +315,7 @@
312315
element='Syntax',
313316
element_name='Modifier'),
314317

315-
Node('FunctionDecl', kind='Decl',
318+
Node('FunctionDecl', kind='Decl', traits=['IdentifiedDeclSyntax'],
316319
children=[
317320
Child('Attributes', kind='AttributeList',
318321
is_optional=True),

utils/gyb_syntax_support/Traits.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ def __init__(self, trait_name, children):
2121
Child('LeftBrace', kind='LeftBraceToken'),
2222
Child('RightBrace', kind='RightBraceToken'),
2323
]),
24+
25+
Trait('IdentifiedDeclSyntax',
26+
children=[
27+
Child('Identifier', kind='IdentifierToken'),
28+
]),
2429
]

0 commit comments

Comments
 (0)