(matcher: NodeMatcher)
| 66 | }; |
| 67 | |
| 68 | function matcherIncludeSiblings(matcher: NodeMatcher): NodeMatcher { |
| 69 | return ( |
| 70 | selection: SelectionWithEditor, |
| 71 | node: SyntaxNode |
| 72 | ): NodeMatcherValue[] | null => { |
| 73 | let matches = matcher(selection, node); |
| 74 | if (matches == null) { |
| 75 | return null; |
| 76 | } |
| 77 | matches = matches.flatMap((match) => |
| 78 | iterateNearestIterableAncestor( |
| 79 | match.node, |
| 80 | selectionWithEditorFromRange(selection, match.selection.selection), |
| 81 | matcher |
| 82 | ) |
| 83 | ) as NodeMatcherValue[]; |
| 84 | if (matches.length > 0) { |
| 85 | return matches; |
| 86 | } |
| 87 | return null; |
| 88 | }; |
| 89 | } |
| 90 | |
| 91 | function iterateNearestIterableAncestor( |
| 92 | node: SyntaxNode, |
no test coverage detected