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

Function blankCppTrailingAttributeMacros

src/extraction/languages/c-cpp.ts:902–923  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

900 /(?:[A-Z][A-Z0-9_]{2,}\b(?:\s*\((?:[^()]|\((?:[^()]|\([^()]*\))*\))*\))?\s*)+/y;
901const CPP_TRAILING_ATTR_FOLLOW_RE = /(?:\{|;|=(?!=)|:(?!:)|->|(?:override|final|const|noexcept)\b)/y;
902export function blankCppTrailingAttributeMacros(source: string): string {
903 if (!/\)[\s\w&]*?\b[A-Z][A-Z0-9_]{2,}\b/.test(source)) return source;
904 const code = maskCppCode(source);
905 const spans: Array<[number, number]> = [];
906 const re = new RegExp(CPP_TRAILING_ATTR_CANDIDATE_RE.source, 'g');
907 const run = new RegExp(CPP_TRAILING_ATTR_RUN_RE.source, 'y');
908 const follow = new RegExp(CPP_TRAILING_ATTR_FOLLOW_RE.source, 'y');
909 let m: RegExpExecArray | null;
910 while ((m = re.exec(code)) !== null) {
911 const macroStart = m.index + m[0].length;
912 if (/\n[ \t]*\r?\n/.test(m[0])) continue;
913 run.lastIndex = macroStart;
914 const r = run.exec(code);
915 if (!r) continue;
916 follow.lastIndex = macroStart + r[0].length;
917 if (!follow.test(code)) continue;
918 if (!closesParameterList(code, m.index)) continue;
919 pushCppRunTokens(spans, r[0], macroStart);
920 re.lastIndex = macroStart + r[0].length;
921 }
922 return blankCppSpans(source, spans, code);
923}
924
925// Type keywords that may stand right before a declared name (`int count_ …`).
926const CPP_TYPE_KEYWORDS = new Set([

Callers 2

preParseCppSourceFunction · 0.85

Calls 5

maskCppCodeFunction · 0.85
closesParameterListFunction · 0.85
pushCppRunTokensFunction · 0.85
blankCppSpansFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected