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

Function extractNodeName

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

Source from the content-addressed store, hash-verified

218}
219
220function extractNodeName(node: Node): string {
221 const nameNode = maybeGetNameNode(node);
222 if (nameNode?.text) {
223 const normalized = normalizeSymbolName(nameNode.text);
224 if (normalized) {
225 return normalized;
226 }
227 }
228
229 const compact = node.text.slice(0, 120).replace(/\s+/g, ' ').trim();
230 const match = compact.match(
231 /(?:class|interface|enum|struct|trait|function|def|fn)\s+([A-Za-z_][\w$]*)/
232 );
233 if (match?.[1]) {
234 return match[1];
235 }
236
237 return 'anonymous';
238}
239
240function isFunctionVariableDeclarator(node: Node): boolean {
241 if (node.type !== 'variable_declarator') {

Callers 1

buildSymbolFunction · 0.85

Calls 2

maybeGetNameNodeFunction · 0.85
normalizeSymbolNameFunction · 0.70

Tested by

no test coverage detected