feat: Add C++ macro misparse handling and structural node extraction in function bodies

Addresses C++ macros like NLOHMANN_JSON_NAMESPACE_BEGIN that cause tree-sitter to misparse namespace blocks as function_definitions. Adds isMisparsedFunction hook to filter macro artifacts while still visiting their bodies to extract legitimate class/struct/enum definitions hidden inside the misparsed "function" scope.
This commit is contained in:
Colby McHenry
2026-04-06 23:24:26 -05:00
parent 6f34be38aa
commit 237fb3b206
4 changed files with 79 additions and 7 deletions
+9
View File
@@ -183,4 +183,13 @@ export interface LanguageExtractor {
* or undefined to keep it as a type alias.
*/
resolveTypeAliasKind?: (node: SyntaxNode, source: string) => NodeKind | undefined;
/**
* Check if a function/method name is a misparse artifact that should be skipped.
* Used by C/C++ where macros (e.g. NLOHMANN_JSON_NAMESPACE_BEGIN) cause tree-sitter
* to misparse namespace blocks as function_definitions. When this returns true,
* the function node is NOT created, but the body is still visited for calls and
* structural nodes (classes, structs, enums).
*/
isMisparsedFunction?: (name: string, node: SyntaxNode) => boolean;
}