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

Function isCppConstructorDeclaration

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

Source from the content-addressed store, hash-verified

2962
2963/** A constructor prototype carries defaults even when its body is in another file. */
2964export function isCppConstructorDeclaration(node: SyntaxNode): boolean {
2965 if (node.type !== 'declaration' || getChildByField(node, 'type')) return false;
2966 const owner = node.parent?.parent;
2967 if (!owner || !['class_specifier', 'struct_specifier', 'union_specifier'].includes(owner.type)) return false;
2968 const declarator = getChildByField(node, 'declarator');
2969 return declarator?.type === 'function_declarator'
2970 && getChildByField(declarator, 'declarator')?.text === getChildByField(owner, 'name')?.text;
2971}
2972
2973export const cppExtractor: LanguageExtractor = {
2974 // 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