File tree Expand file tree Collapse file tree 3 files changed +13
-27
lines changed Expand file tree Collapse file tree 3 files changed +13
-27
lines changed Original file line number Diff line number Diff line change @@ -676,17 +676,3 @@ fileprivate extension TokenSyntax {
676
676
}
677
677
}
678
678
}
679
-
680
- fileprivate extension SyntaxProtocol {
681
- /// Returns this node or the first ancestor that satisfies `condition`.
682
- func ancestorOrSelf< T> ( mapping map: ( Syntax ) -> T ? ) -> T ? {
683
- var walk : Syntax ? = Syntax ( self )
684
- while let unwrappedParent = walk {
685
- if let mapped = map ( unwrappedParent) {
686
- return mapped
687
- }
688
- walk = unwrappedParent. parent
689
- }
690
- return nil
691
- }
692
- }
Original file line number Diff line number Diff line change @@ -119,18 +119,6 @@ extension SyntaxProtocol {
119
119
}
120
120
}
121
121
122
- /// Returns this node or the first ancestor that satisfies `condition`.
123
- func ancestorOrSelf< T> ( mapping map: ( Syntax ) -> T ? ) -> T ? {
124
- var walk : Syntax ? = Syntax ( self )
125
- while let unwrappedParent = walk {
126
- if let mapped = map ( unwrappedParent) {
127
- return mapped
128
- }
129
- walk = unwrappedParent. parent
130
- }
131
- return nil
132
- }
133
-
134
122
/// Returns `true` if the next token's leading trivia should be made leading trivia
135
123
/// of this mode, when it is switched from being missing to present.
136
124
var shouldBeInsertedAfterNextTokenTrivia : Bool {
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ extension SyntaxProtocol {
186
186
}
187
187
}
188
188
189
- // MARK: Children / parent
189
+ // MARK: Children / parent / ancestor
190
190
191
191
extension SyntaxProtocol {
192
192
/// A sequence over the children of this node.
@@ -238,6 +238,18 @@ extension SyntaxProtocol {
238
238
public var previousToken : TokenSyntax ? {
239
239
return self . previousToken ( viewMode: . sourceAccurate)
240
240
}
241
+
242
+ /// Returns this node or the first ancestor that satisfies `condition`.
243
+ public func ancestorOrSelf< T> ( mapping map: ( Syntax ) -> T ? ) -> T ? {
244
+ var walk : Syntax ? = Syntax ( self )
245
+ while let unwrappedParent = walk {
246
+ if let mapped = map ( unwrappedParent) {
247
+ return mapped
248
+ }
249
+ walk = unwrappedParent. parent
250
+ }
251
+ return nil
252
+ }
241
253
}
242
254
243
255
// MARK: Accessing tokens
You can’t perform that action at this time.
0 commit comments