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

Function isCppConstructorDeclaration

src/extraction/languages/c-cpp.ts:2963–2970  ·  view source on GitHub ↗
(node: SyntaxNode)

Source from the content-addressed store, hash-verified

2961
2962/** A constructor prototype carries defaults even when its body is in another file. */
2963export function isCppConstructorDeclaration(node: SyntaxNode): boolean {
2964 if (node.type !== 'declaration' || getChildByField(node, 'type')) return false;
2965 const owner = node.parent?.parent;
2966 if (!owner || !['class_specifier', 'struct_specifier', 'union_specifier'].includes(owner.type)) return false;
2967 const declarator = getChildByField(node, 'declarator');
2968 return declarator?.type === 'function_declarator'
2969 && getChildByField(declarator, 'declarator')?.text === getChildByField(owner, 'name')?.text;
2970}
2971
2972export const cppExtractor: LanguageExtractor = {
2973 // Recover macro-annotated class/struct definitions (`class MYMODULE_API Foo : Base`,

Callers 2

dispatchNodeMethod · 0.90
c-cpp.tsFile · 0.85

Calls 1

getChildByFieldFunction · 0.90

Tested by

no test coverage detected