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

Function blankCppInlineAnnotationMacros

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

Source from the content-addressed store, hash-verified

1576 */
1577const CPP_INLINE_ANNOTATION_RE = /\b(?:UMETA|UPARAM|UE_DEPRECATED\w*)\s*\(/g;
1578export function blankCppInlineAnnotationMacros(source: string): string {
1579 if (!/\b(?:UMETA|UPARAM|UE_DEPRECATED)/.test(source)) return source;
1580 const rawStrings = maskCppRawStrings(source);
1581 source = rawStrings.source;
1582 let chars: string[] | null = null;
1583 const re = new RegExp(CPP_INLINE_ANNOTATION_RE.source, 'g');
1584 let m: RegExpExecArray | null;
1585 while ((m = re.exec(source)) !== null) {
1586 let i = m.index + m[0].length - 1; // index of the opening '('
1587 let depth = 0;
1588 let end = -1;
1589 for (; i < source.length; i++) {
1590 const c = source[i];
1591 if (c === '"' || c === "'") {
1592 const quote = c;
1593 i++;
1594 while (i < source.length && source[i] !== quote) {
1595 if (source[i] === '\\') i++;
1596 i++;
1597 }
1598 continue;
1599 }
1600 if (c === '(') depth++;
1601 else if (c === ')') {
1602 depth--;
1603 if (depth === 0) { end = i + 1; break; }
1604 }
1605 }
1606 if (end < 0) continue;
1607 chars ??= source.split('');
1608 for (let k = m.index; k < end; k++) {
1609 if (chars[k] !== '\n' && chars[k] !== '\r') chars[k] = ' ';
1610 }
1611 re.lastIndex = end;
1612 }
1613 return rawStrings.restore(chars ? chars.join('') : source);
1614}
1615
1616/**
1617 * Blank CUDA-specific constructs before parsing `.cu`/`.cuh` files (parsed with

Callers 2

extraction.test.tsFile · 0.90
preParseCppSourceFunction · 0.85

Calls 4

maskCppRawStringsFunction · 0.85
restoreMethod · 0.80
execMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected