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

Function blankCppInlineAnnotationMacros

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

Source from the content-addressed store, hash-verified

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