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

Function iterateNearestIterableAncestor

src/languages/getNodeMatcher.ts:91–107  ·  view source on GitHub ↗
(
  node: SyntaxNode,
  selection: SelectionWithEditor,
  nodeMatcher: NodeMatcher
)

Source from the content-addressed store, hash-verified

89}
90
91function iterateNearestIterableAncestor(
92 node: SyntaxNode,
93 selection: SelectionWithEditor,
94 nodeMatcher: NodeMatcher
95) {
96 let parent: SyntaxNode | null = node.parent;
97 while (parent != null) {
98 const matches = parent!.namedChildren
99 .flatMap((sibling) => nodeMatcher(selection, sibling))
100 .filter((match) => match != null) as NodeMatcherValue[];
101 if (matches.length > 0) {
102 return matches;
103 }
104 parent = parent.parent;
105 }
106 return [];
107}

Callers 1

matcherIncludeSiblingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected