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

Function blankCppTrailingAttributeMacros

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

Source from the content-addressed store, hash-verified

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