MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / matcherIncludeSiblings

Function matcherIncludeSiblings

src/languages/getNodeMatcher.ts:68–89  ·  view source on GitHub ↗
(matcher: NodeMatcher)

Source from the content-addressed store, hash-verified

66};
67
68function 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
91function iterateNearestIterableAncestor(
92 node: SyntaxNode,

Callers 1

getNodeMatcherFunction · 0.85

Calls 3

matcherFunction · 0.85

Tested by

no test coverage detected