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 {
676676 }
677677 }
678678}
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 {
119119 }
120120 }
121121
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-
134122 /// Returns `true` if the next token's leading trivia should be made leading trivia
135123 /// of this mode, when it is switched from being missing to present.
136124 var shouldBeInsertedAfterNextTokenTrivia : Bool {
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ extension SyntaxProtocol {
186186 }
187187}
188188
189- // MARK: Children / parent
189+ // MARK: Children / parent / ancestor
190190
191191extension SyntaxProtocol {
192192 /// A sequence over the children of this node.
@@ -238,6 +238,18 @@ extension SyntaxProtocol {
238238 public var previousToken : TokenSyntax ? {
239239 return self . previousToken ( viewMode: . sourceAccurate)
240240 }
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+ }
241253}
242254
243255// MARK: Accessing tokens
You can’t perform that action at this time.
0 commit comments