Skip to content

Commit d785cc5

Browse files
committed
Split the generated SyntaxNodes.swift file into multiple files
This way, the files go down to a manageable file size again that can be view using Xcode.
1 parent 07bf174 commit d785cc5

12 files changed

+21160
-21231
lines changed

Sources/SwiftSyntax/SyntaxNodes.swift.gyb renamed to Sources/SwiftSyntax/SyntaxNodes.swift.gyb.template

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,11 @@
2121

2222
%{
2323
"""
24-
Each Syntax node implements the protocol of a more generic node. For example,
25-
StructDeclSyntax implements DeclSyntax and can be used in contexts
26-
where DeclSyntax is expected.
27-
28-
Each node will have:
29-
- An accessor for each child that will lazily instantiate it.
30-
- A `withX(_ x: XSyntax)` method for each child that will return a new Syntax
31-
node with the existing X child replaced with the passed-in version. This is a
32-
way to incrementally transform nodes in the tree.
33-
- An `addX(_ x: XSyntax)` method for children that are collections. This will
34-
append the provided node to the collection and return a new node with that
35-
collection replaced.
24+
This gyb-file generates the syntax nodes for SwiftSyntax. To keep the generated
25+
files at a managable file size, it is to be invoked multiple times with the
26+
global variable EMIT_KIND set to a base kind listed in
27+
gyb_syntax_support/kinds.py:SYNTAX_BASE_KINDES. It then only emits those syntax
28+
nodes whose base kind are that specified kind.
3629
"""
3730
}%
3831

@@ -44,6 +37,8 @@ Each node will have:
4437
% elif node.collection_element:
4538
% # Handled in SyntaxCollections.swift.gyb
4639
% pass
40+
% elif node.base_kind != EMIT_KIND:
41+
% pass
4742
% else:
4843
% # We are actually handling this node now
4944
// MARK: - ${node.name}
@@ -84,7 +79,6 @@ public struct ${node.name}: ${base_type}Protocol {
8479
assert(data.raw.kind == .${node.swift_syntax_kind})
8580
self._syntaxNode = Syntax(data)
8681
}
87-
8882
% for child in node.children:
8983
% child_node = NODE_MAP.get(child.syntax_kind)
9084
%

0 commit comments

Comments
 (0)