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

Function extractCppReceiverType

src/extraction/languages/c-cpp.ts:86–101  ·  view source on GitHub ↗
(node: SyntaxNode, source: string)

Source from the content-addressed store, hash-verified

84}
85
86function extractCppReceiverType(node: SyntaxNode, source: string): string | undefined {
87 const declarator = getChildByField(node, 'declarator');
88 if (!declarator) return undefined;
89 const qid = findDeclaratorQualifiedId(declarator);
90 if (!qid) return undefined;
91 const parts = getNodeText(qid, source).trim().split('::').filter(Boolean);
92 if (parts.length <= 1) return undefined;
93 // An out-of-line template method definition carries the class's template
94 // parameter list in the qualifier (`template<typename T> T Box<T>::get()`),
95 // but the class node is indexed as bare `Box` — strip `<…>` so the receiver
96 // matches it, the same normalization #1043 applies to base-class refs.
97 // Multi-line parameter lists otherwise leak whole `<…>` blocks (newlines
98 // included) into qualified_name, which can exceed NAME_MAX (#1286).
99 const receiver = stripCppTemplateArgs(parts.slice(0, -1).join('::'));
100 return receiver || undefined;
101}
102
103/**
104 * Built-in / non-class return types that can never be a method receiver. We

Callers

nothing calls this directly

Calls 5

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90
stripCppTemplateArgsFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected