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

Function preParseCppSource

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

C/C++ source pre-processing before tree-sitter: recover macro-annotated class * definitions, macro-prefixed function definitions, macro-prefixed members, and * macro-decorated members (Unreal-Engine reflection markup) — plus the non-C++ * surface of the dialects parsed with the C++ grammar: `.met

(source: string, filePath?: string)

Source from the content-addressed store, hash-verified

795 * or by content, for CUDA living in `.h`/`.hpp` headers). Offset-preserving;
796 * directive lines are restored at the end (see restoreDirectiveLines). */
797function preParseCppSource(source: string, filePath?: string): string {
798 // blankCLeadingAttrMacros runs AFTER the api-prefix blank so a stacked
799 // `FMT_NORETURN FMT_API void f(…)` reduces to the `MACRO Ret name(` shape
800 // it matches (the _API token is already spaces by then).
801 let blanked = blankLoneMacroLines(
802 blankCLeadingAttrMacros(
803 blankCppAnnotationMacroCalls(
804 blankCppInlineAnnotationMacros(
805 blankCppApiPrefixMacros(blankCppInlineMacros(blankCppExportMacros(source)))
806 )
807 )
808 )
809 );
810 const lower = filePath ? filePath.toLowerCase() : '';
811 if (lower.endsWith('.metal')) {
812 blanked = blankMetalAttributes(blanked);
813 } else if (lower.endsWith('.cu') || lower.endsWith('.cuh') || looksLikeCudaSource(source)) {
814 blanked = blankCudaConstructs(blanked);
815 }
816 return restoreDirectiveLines(source, blanked);
817}
818
819/**
820 * Blank an unknown attribute macro sitting in front of a C function

Callers

nothing calls this directly

Calls 11

blankLoneMacroLinesFunction · 0.85
blankCLeadingAttrMacrosFunction · 0.85
blankCppApiPrefixMacrosFunction · 0.85
blankCppInlineMacrosFunction · 0.85
blankCppExportMacrosFunction · 0.85
blankMetalAttributesFunction · 0.85
looksLikeCudaSourceFunction · 0.85
blankCudaConstructsFunction · 0.85
restoreDirectiveLinesFunction · 0.85

Tested by

no test coverage detected