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

Function maskCppCode

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

* The code the macro scans below match on, at the source's offsets: comments * are spaces, a string or char literal keeps its place as `\x01`s (it is a * token, not space: in `"… using " GTEST_NAME_` the macro does not start a * line, and a run of macros never reaches across a literal), and * pr

(source: string)

Source from the content-addressed store, hash-verified

745 * `TEST(file_test, open_windows_file) {` under it is not a trailing macro.
746 */
747function maskCppCode(source: string): string {
748 if (cppMaskMemo !== null && cppMaskMemo.source === source) return cppMaskMemo.code;
749 const code = source
750 .replace(CPP_COMMENT_OR_LITERAL_RE, (m) => m.replace(/[^\r\n]/g, m.startsWith('/') ? ' ' : '\x01'))
751 .replace(/^[ \t]*#(?:\\\r?\n|[^\r\n])*/gm, (m) => m.replace(/[^\r\n]/g, ' '));
752 cppMaskMemo = { source, code };
753 return code;
754}
755
756// The last source maskCppCode masked. The passes run one after another on
757// the same text: one that blanks nothing hands the next the same string, and

Calls

no outgoing calls

Tested by

no test coverage detected