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

Function maskCppCode

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

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

Calls

no outgoing calls

Tested by

no test coverage detected