@@ -227,7 +227,13 @@ public final class SourceLocationConverter {
227
227
}
228
228
}
229
229
230
- extension _SyntaxBase {
230
+ public extension Syntax {
231
+ /// The starting location, in the provided file, of this Syntax node.
232
+ /// - Parameters:
233
+ /// - converter: The `SourceLocationConverter` that was previously
234
+ /// initialized using the root tree of this node.
235
+ /// - afterLeadingTrivia: Whether to skip leading trivia when getting
236
+ /// the node's location. Defaults to `true`.
231
237
func startLocation(
232
238
converter: SourceLocationConverter ,
233
239
afterLeadingTrivia: Bool = true
@@ -238,6 +244,12 @@ extension _SyntaxBase {
238
244
return converter. location ( for: pos)
239
245
}
240
246
247
+ /// The ending location, in the provided file, of this Syntax node.
248
+ /// - Parameters:
249
+ /// - converter: The `SourceLocationConverter` that was previously
250
+ /// initialized using the root tree of this node.
251
+ /// - afterTrailingTrivia: Whether to skip trailing trivia when getting
252
+ /// the node's location. Defaults to `false`.
241
253
func endLocation(
242
254
converter: SourceLocationConverter ,
243
255
afterTrailingTrivia: Bool = false
@@ -251,30 +263,40 @@ extension _SyntaxBase {
251
263
return converter. location ( for: pos)
252
264
}
253
265
266
+ /// The source range, in the provided file, of this Syntax node.
267
+ /// - Parameters:
268
+ /// - converter: The `SourceLocationConverter` that was previously
269
+ /// initialized using the root tree of this node.
270
+ /// - afterLeadingTrivia: Whether to skip leading trivia when getting
271
+ /// the node's start location. Defaults to `true`.
272
+ /// - afterTrailingTrivia: Whether to skip trailing trivia when getting
273
+ /// the node's end location. Defaults to `false`.
254
274
func sourceRange(
255
275
converter: SourceLocationConverter ,
256
276
afterLeadingTrivia: Bool = true ,
257
277
afterTrailingTrivia: Bool = false
258
278
) -> SourceRange {
259
- let start = startLocation ( converter: converter, afterLeadingTrivia: afterLeadingTrivia)
260
- let end = endLocation ( converter: converter, afterTrailingTrivia: afterTrailingTrivia)
279
+ let start = startLocation ( converter: converter,
280
+ afterLeadingTrivia: afterLeadingTrivia)
281
+ let end = endLocation ( converter: converter,
282
+ afterTrailingTrivia: afterTrailingTrivia)
261
283
return SourceRange ( start: start, end: end)
262
284
}
263
285
}
264
286
265
- extension Syntax {
287
+ public extension SyntaxProtocol {
266
288
/// The starting location, in the provided file, of this Syntax node.
267
289
/// - Parameters:
268
290
/// - converter: The `SourceLocationConverter` that was previously
269
291
/// initialized using the root tree of this node.
270
292
/// - afterLeadingTrivia: Whether to skip leading trivia when getting
271
293
/// the node's location. Defaults to `true`.
272
- public func startLocation(
294
+ func startLocation(
273
295
converter: SourceLocationConverter ,
274
296
afterLeadingTrivia: Bool = true
275
297
) -> SourceLocation {
276
- return base . startLocation ( converter: converter,
277
- afterLeadingTrivia: afterLeadingTrivia)
298
+ return _syntaxNode . startLocation ( converter: converter,
299
+ afterLeadingTrivia: afterLeadingTrivia)
278
300
}
279
301
280
302
/// The ending location, in the provided file, of this Syntax node.
@@ -283,12 +305,12 @@ extension Syntax {
283
305
/// initialized using the root tree of this node.
284
306
/// - afterTrailingTrivia: Whether to skip trailing trivia when getting
285
307
/// the node's location. Defaults to `false`.
286
- public func endLocation(
308
+ func endLocation(
287
309
converter: SourceLocationConverter ,
288
310
afterTrailingTrivia: Bool = false
289
311
) -> SourceLocation {
290
- return base . endLocation ( converter: converter,
291
- afterTrailingTrivia: afterTrailingTrivia)
312
+ return _syntaxNode . endLocation ( converter: converter,
313
+ afterTrailingTrivia: afterTrailingTrivia)
292
314
}
293
315
294
316
/// The source range, in the provided file, of this Syntax node.
@@ -299,14 +321,14 @@ extension Syntax {
299
321
/// the node's start location. Defaults to `true`.
300
322
/// - afterTrailingTrivia: Whether to skip trailing trivia when getting
301
323
/// the node's end location. Defaults to `false`.
302
- public func sourceRange(
324
+ func sourceRange(
303
325
converter: SourceLocationConverter ,
304
326
afterLeadingTrivia: Bool = true ,
305
327
afterTrailingTrivia: Bool = false
306
328
) -> SourceRange {
307
- return base . sourceRange ( converter: converter,
308
- afterLeadingTrivia: afterLeadingTrivia,
309
- afterTrailingTrivia: afterTrailingTrivia)
329
+ return _syntaxNode . sourceRange ( converter: converter,
330
+ afterLeadingTrivia: afterLeadingTrivia,
331
+ afterTrailingTrivia: afterTrailingTrivia)
310
332
}
311
333
}
312
334
0 commit comments