MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / cppWrittenClassParts

Function cppWrittenClassParts

src/extraction/languages/c-cpp.ts:368–377  ·  view source on GitHub ↗

* The `::` segments of a C++ class, struct or union name written with a * scope, the scope's template arguments dropped: `['SkipList', 'Node']` for * an out-of-line nested class `struct SkipList ::Node`. Such * a class was indexed ` `, so its members were no class's. *

(node: SyntaxNode, source: string)

Source from the content-addressed store, hash-verified

366 * (ccpp/mod.rs).
367 */
368function cppWrittenClassParts(node: SyntaxNode, source: string): string[] | undefined {
369 if (!CPP_CLASS_SPECIFIERS.has(node.type)) return undefined;
370 const written = getChildByField(node, 'name');
371 if (written?.type !== 'qualified_identifier') return undefined;
372 let innermost: SyntaxNode | null = written;
373 while (innermost?.type === 'qualified_identifier') innermost = getChildByField(innermost, 'name');
374 if (innermost?.type !== 'type_identifier') return undefined;
375 const parts = stripCppTemplateArgs(getNodeText(written, source)).split('::').map((p) => p.trim()).filter(Boolean);
376 return parts.length > 0 && parts.every((p) => /^[A-Za-z_]\w*$/.test(p)) ? parts : undefined;
377}
378
379/**
380 * The name a C++ `qualified_identifier` ends in, past its scopes: the

Callers 1

c-cpp.tsFile · 0.85

Calls 5

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90
stripCppTemplateArgsFunction · 0.85
hasMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected