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

Function isMacroMisparsedTypeDecl

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

* Detect tree-sitter's misparse of a macro-annotated class/struct, e.g. * `class MACRO Name { … }` or `class MACRO Name : public Base { … }` (#946). * Not knowing `MACRO` is a macro, tree-sitter reads `class MACRO` as an * *elaborated type specifier* (a bodyless `class_specifier`/`struct_specifie

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

653 * callers/impact and skews kind statistics.
654 */
655function isMacroMisparsedTypeDecl(node: SyntaxNode): boolean {
656 const typeNode = getChildByField(node, 'type');
657 if (!typeNode) return false;
658 if (typeNode.type !== 'class_specifier' && typeNode.type !== 'struct_specifier') return false;
659 if (typeNode.namedChildren.some((c: SyntaxNode) => c.type === 'field_declaration_list')) return false;
660 const declarator = getChildByField(node, 'declarator');
661 if (declarator && declarator.type === 'function_declarator') return false;
662 return true;
663}
664
665/**
666 * Blank an export/visibility macro in a `class/struct EXPORT_MACRO Name …`

Callers 1

c-cpp.tsFile · 0.85

Calls 1

getChildByFieldFunction · 0.90

Tested by

no test coverage detected