@@ -52,6 +52,10 @@ Each node will have:
52
52
/// ${line}
53
53
% end
54
54
public struct ${ node. name} : ${ base_type} Protocol {
55
+ % # ======
56
+ % # Cursor
57
+ % # ======
58
+ %
55
59
% if node. children:
56
60
enum Cursor: Int {
57
61
% for child in node. children:
@@ -60,6 +64,10 @@ public struct ${node.name}: ${base_type}Protocol {
60
64
}
61
65
% end
62
66
67
+ % # ==============
68
+ % # Initialization
69
+ % # ==============
70
+ %
63
71
public let _syntaxNode : Syntax
64
72
65
73
/// Converts the given `Syntax` node to a `${node.name}` if possible. Returns
@@ -79,10 +87,16 @@ public struct ${node.name}: ${base_type}Protocol {
79
87
80
88
% for child in node. children:
81
89
% child_node = NODE_MAP . get ( child. syntax_kind)
90
+ %
91
+ % # ===================
92
+ % # Children properties
93
+ % # ===================
94
+ %
82
95
% ret_type = child. type_name
83
96
% if child. is_optional:
84
97
% ret_type += '? '
85
98
% end
99
+
86
100
% for line in dedented_lines( child. description) :
87
101
/// ${line}
88
102
% end
@@ -99,6 +113,10 @@ public struct ${node.name}: ${base_type}Protocol {
99
113
self = with ${ child. name} ( value)
100
114
}
101
115
}
116
+ %
117
+ % # ===============
118
+ % # Adding children
119
+ % # ===============
102
120
% if child_node and child_node. is_syntax_collection ( ) :
103
121
% child_elt = child. collection_element_name
104
122
% child_elt_type = child_node. collection_element_type
@@ -126,6 +144,9 @@ public struct ${node.name}: ${base_type}Protocol {
126
144
}
127
145
% end
128
146
147
+ % # ===================
148
+ % # Replacing children
149
+ % # ===================
129
150
/// Returns a copy of the receiver with its `${child.swift_name}` replaced.
130
151
/// - param newChild: The new `${child.swift_name}` to replace the node's
131
152
/// current `${child.swift_name}`, if present.
0 commit comments