@@ -144,10 +144,14 @@ public struct Syntax: SyntaxProtocol, SyntaxHashable {
144144 /// - Parameters:
145145 /// - newRaw: The node that should replace `self`
146146 /// - rawNodeArena: The arena in which `newRaw` resides
147- /// - allocationArena : The arena in which new nodes should be allocated
147+ /// - rawAllocationArena : The arena in which new nodes should be allocated
148148 /// - Returns: A syntax tree with all parents where this node has been
149149 /// replaced by `newRaw`
150- func replacingSelf( _ newRaw: RawSyntax , rawNodeArena: RetainedRawSyntaxArena , allocationArena: RawSyntaxArena ) -> Syntax {
150+ func replacingSelf(
151+ _ newRaw: RawSyntax ,
152+ rawNodeArena: RetainedRawSyntaxArena ,
153+ rawAllocationArena: RawSyntaxArena
154+ ) -> Syntax {
151155 precondition ( newRaw. arenaReference == rawNodeArena)
152156 // If we have a parent already, then ask our current parent to copy itself
153157 // recursively up to the root.
@@ -156,7 +160,7 @@ public struct Syntax: SyntaxProtocol, SyntaxHashable {
156160 at: layoutIndexInParent,
157161 with: newRaw,
158162 rawNodeArena: rawNodeArena,
159- allocationArena : allocationArena
163+ rawAllocationArena : rawAllocationArena
160164 )
161165 return newParent. child ( at: layoutIndexInParent) !
162166 } else {
@@ -172,75 +176,91 @@ public struct Syntax: SyntaxProtocol, SyntaxHashable {
172176 /// - index: The index pointing to where in the raw layout to place this
173177 /// child.
174178 /// - newChild: The raw syntax for the new child to replace.
175- /// - newChildArena : The arena in which `newChild` resides.
176- /// - arena : The arena in which the new node will be allocated.
179+ /// - rawNodeArena : The arena in which `newChild` resides.
180+ /// - rawAllocationArena : The arena in which the new node will be allocated.
177181 /// - Returns: The new root node created by this operation, and the new child
178182 /// syntax data.
179183 /// - SeeAlso: replacingSelf(_:)
180184 func replacingChild(
181185 at index: Int ,
182186 with newChild: RawSyntax ? ,
183187 rawNodeArena: RetainedRawSyntaxArena ? ,
184- allocationArena : RawSyntaxArena
188+ rawAllocationArena : RawSyntaxArena
185189 ) -> Syntax {
186190 precondition ( newChild == nil || ( rawNodeArena != nil && newChild!. arenaReference == rawNodeArena!) )
187191 // After newRaw has been allocated in `allocationArena`, `rawNodeArena` will
188192 // be a child arena of `allocationArena` and thus, `allocationArena` will
189193 // keep `newChild` alive.
190194 let newRaw = withExtendedLifetime ( rawNodeArena) {
191- raw. layoutView!. replacingChild ( at: index, with: newChild, arena: allocationArena )
195+ raw. layoutView!. replacingChild ( at: index, with: newChild, arena: rawAllocationArena )
192196 }
193- return replacingSelf ( newRaw, rawNodeArena: RetainedRawSyntaxArena ( allocationArena) , allocationArena: allocationArena)
197+ return replacingSelf (
198+ newRaw,
199+ rawNodeArena: RetainedRawSyntaxArena ( rawAllocationArena) ,
200+ rawAllocationArena: rawAllocationArena
201+ )
194202 }
195203
196- /// Same as `replacingChild(at:with:rawNodeArena:allocationArena :)` but takes a `__RawSyntaxArena` instead of a `RetainedRawSyntaxArena`.
204+ /// Same as `replacingChild(at:with:rawNodeArena:rawAllocationArena :)` but takes a `__RawSyntaxArena` instead of a `RetainedRawSyntaxArena`.
197205 func replacingChild(
198206 at index: Int ,
199207 with newChild: RawSyntax ? ,
200208 rawNodeArena: RawSyntaxArena ? ,
201- allocationArena : RawSyntaxArena
209+ rawAllocationArena : RawSyntaxArena
202210 ) -> Syntax {
203211 return self . replacingChild (
204212 at: index,
205213 with: newChild,
206214 rawNodeArena: rawNodeArena. map ( RetainedRawSyntaxArena . init) ,
207- allocationArena : allocationArena
215+ rawAllocationArena : rawAllocationArena
208216 )
209217 }
210218
211- /// Identical to `replacingChild(at: Int, with: RawSyntax?, arena : RawSyntaxArena)`
219+ /// Identical to `replacingChild(at: Int, with: RawSyntax?, rawAllocationArena : RawSyntaxArena)`
212220 /// that ensures that the arena of`newChild` doesn’t get de-allocated before
213221 /// `newChild` has been addded to the result.
214- func replacingChild( at index: Int , with newChild: Syntax ? , arena : RawSyntaxArena ) -> Syntax {
222+ func replacingChild( at index: Int , with newChild: Syntax ? , rawAllocationArena : RawSyntaxArena ) -> Syntax {
215223 return withExtendedLifetime ( newChild) {
216224 return replacingChild (
217225 at: index,
218226 with: newChild? . raw,
219227 rawNodeArena: newChild? . raw. arenaReference. retained,
220- allocationArena : arena
228+ rawAllocationArena : rawAllocationArena
221229 )
222230 }
223231 }
224232
225- func withLeadingTrivia( _ leadingTrivia: Trivia , arena: RawSyntaxArena ) -> Syntax {
226- if let raw = raw. withLeadingTrivia ( leadingTrivia, arena: arena) {
227- return replacingSelf ( raw, rawNodeArena: RetainedRawSyntaxArena ( arena) , allocationArena: arena)
233+ func withLeadingTrivia( _ leadingTrivia: Trivia , rawAllocationArena: RawSyntaxArena ) -> Syntax {
234+ if let raw = raw. withLeadingTrivia ( leadingTrivia, arena: rawAllocationArena) {
235+ return replacingSelf (
236+ raw,
237+ rawNodeArena: RetainedRawSyntaxArena ( rawAllocationArena) ,
238+ rawAllocationArena: rawAllocationArena
239+ )
228240 } else {
229241 return self
230242 }
231243 }
232244
233- func withTrailingTrivia( _ trailingTrivia: Trivia , arena: RawSyntaxArena ) -> Syntax {
234- if let raw = raw. withTrailingTrivia ( trailingTrivia, arena: arena) {
235- return replacingSelf ( raw, rawNodeArena: RetainedRawSyntaxArena ( arena) , allocationArena: arena)
245+ func withTrailingTrivia( _ trailingTrivia: Trivia , rawAllocationArena: RawSyntaxArena ) -> Syntax {
246+ if let raw = raw. withTrailingTrivia ( trailingTrivia, arena: rawAllocationArena) {
247+ return replacingSelf (
248+ raw,
249+ rawNodeArena: RetainedRawSyntaxArena ( rawAllocationArena) ,
250+ rawAllocationArena: rawAllocationArena
251+ )
236252 } else {
237253 return self
238254 }
239255 }
240256
241- func withPresence( _ presence: SourcePresence , arena: RawSyntaxArena ) -> Syntax {
242- if let raw = raw. tokenView? . withPresence ( presence, arena: arena) {
243- return replacingSelf ( raw, rawNodeArena: RetainedRawSyntaxArena ( arena) , allocationArena: arena)
257+ func withPresence( _ presence: SourcePresence , rawAllocationArena: RawSyntaxArena ) -> Syntax {
258+ if let raw = raw. tokenView? . withPresence ( presence, arena: rawAllocationArena) {
259+ return replacingSelf (
260+ raw,
261+ rawNodeArena: RetainedRawSyntaxArena ( rawAllocationArena) ,
262+ rawAllocationArena: rawAllocationArena
263+ )
244264 } else {
245265 return self
246266 }
0 commit comments