MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / maybeGetNameNode

Function maybeGetNameNode

src/utils/tree-sitter.ts:202–218  ·  view source on GitHub ↗
(node: Node)

Source from the content-addressed store, hash-verified

200}
201
202function maybeGetNameNode(node: Node): Node | null {
203 for (const fieldName of NAME_FIELD_CANDIDATES) {
204 const field = node.childForFieldName(fieldName);
205 if (field) {
206 return field;
207 }
208 }
209
210 for (const child of node.namedChildren) {
211 if (!child) continue;
212 if (NAME_NODE_TYPE_HINTS.some((hint) => child.type.includes(hint))) {
213 return child;
214 }
215 }
216
217 return null;
218}
219
220function extractNodeName(node: Node): string {
221 const nameNode = maybeGetNameNode(node);

Callers 1

extractNodeNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected