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

Function cppWrittenClassParts

src/extraction/languages/c-cpp.ts:370–379  ·  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

368 * (ccpp/mod.rs).
369 */
370function cppWrittenClassParts(node: SyntaxNode, source: string): string[] | undefined {
371 if (!CPP_CLASS_SPECIFIERS.has(node.type)) return undefined;
372 const written = getChildByField(node, 'name');
373 if (written?.type !== 'qualified_identifier') return undefined;
374 let innermost: SyntaxNode | null = written;
375 while (innermost?.type === 'qualified_identifier') innermost = getChildByField(innermost, 'name');
376 if (innermost?.type !== 'type_identifier') return undefined;
377 const parts = stripCppTemplateArgs(getNodeText(written, source)).split('::').map((p) => p.trim()).filter(Boolean);
378 return parts.length > 0 && parts.every((p) => /^[A-Za-z_]\w*$/.test(p)) ? parts : undefined;
379}
380
381/**
382 * 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