* 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)
| 653 | * callers/impact and skews kind statistics. |
| 654 | */ |
| 655 | function 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 …` |
no test coverage detected