Skip to content

Commit 7387a55

Browse files
committed
Add structure markers to SyntaxNodes.swift.gyb
1 parent 35d32ca commit 7387a55

File tree

2 files changed

+602
-0
lines changed

2 files changed

+602
-0
lines changed

Sources/SwiftSyntax/SyntaxNodes.swift.gyb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Each node will have:
5252
/// ${line}
5353
% end
5454
public struct ${node.name}: ${base_type}Protocol {
55+
% # ======
56+
% # Cursor
57+
% # ======
58+
%
5559
% if node.children:
5660
enum Cursor: Int {
5761
% for child in node.children:
@@ -60,6 +64,10 @@ public struct ${node.name}: ${base_type}Protocol {
6064
}
6165
% end
6266

67+
% # ==============
68+
% # Initialization
69+
% # ==============
70+
%
6371
public let _syntaxNode: Syntax
6472

6573
/// Converts the given `Syntax` node to a `${node.name}` if possible. Returns
@@ -79,10 +87,16 @@ public struct ${node.name}: ${base_type}Protocol {
7987

8088
% for child in node.children:
8189
% child_node = NODE_MAP.get(child.syntax_kind)
90+
%
91+
% # ===================
92+
% # Children properties
93+
% # ===================
94+
%
8295
% ret_type = child.type_name
8396
% if child.is_optional:
8497
% ret_type += '?'
8598
% end
99+
86100
% for line in dedented_lines(child.description):
87101
/// ${line}
88102
% end
@@ -99,6 +113,10 @@ public struct ${node.name}: ${base_type}Protocol {
99113
self = with${child.name}(value)
100114
}
101115
}
116+
%
117+
% # ===============
118+
% # Adding children
119+
% # ===============
102120
% if child_node and child_node.is_syntax_collection():
103121
% child_elt = child.collection_element_name
104122
% child_elt_type = child_node.collection_element_type
@@ -126,6 +144,9 @@ public struct ${node.name}: ${base_type}Protocol {
126144
}
127145
% end
128146

147+
% # ===================
148+
% # Replacing children
149+
% # ===================
129150
/// Returns a copy of the receiver with its `${child.swift_name}` replaced.
130151
/// - param newChild: The new `${child.swift_name}` to replace the node's
131152
/// current `${child.swift_name}`, if present.

0 commit comments

Comments
 (0)