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

Function preParseCppSource

src/extraction/languages/c-cpp.ts:787–807  ·  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

785 * or by content, for CUDA living in `.h`/`.hpp` headers). Offset-preserving;
786 * directive lines are restored at the end (see restoreDirectiveLines). */
787function preParseCppSource(source: string, filePath?: string): string {
788 // blankCLeadingAttrMacros runs AFTER the api-prefix blank so a stacked
789 // `FMT_NORETURN FMT_API void f(…)` reduces to the `MACRO Ret name(` shape
790 // it matches (the _API token is already spaces by then).
791 let blanked = blankLoneMacroLines(
792 blankCLeadingAttrMacros(
793 blankCppAnnotationMacroCalls(
794 blankCppInlineAnnotationMacros(
795 blankCppApiPrefixMacros(blankCppInlineMacros(blankCppExportMacros(source)))
796 )
797 )
798 )
799 );
800 const lower = filePath ? filePath.toLowerCase() : '';
801 if (lower.endsWith('.metal')) {
802 blanked = blankMetalAttributes(blanked);
803 } else if (lower.endsWith('.cu') || lower.endsWith('.cuh') || looksLikeCudaSource(source)) {
804 blanked = blankCudaConstructs(blanked);
805 }
806 return restoreDirectiveLines(source, blanked);
807}
808
809/**
810 * 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