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

Function blankCppInlineAnnotationMacros

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

Source from the content-addressed store, hash-verified

640 */
641const CPP_INLINE_ANNOTATION_RE = /\b(?:UMETA|UPARAM|UE_DEPRECATED\w*)\s*\(/g;
642export function blankCppInlineAnnotationMacros(source: string): string {
643 if (!/\b(?:UMETA|UPARAM|UE_DEPRECATED)/.test(source)) return source;
644 const chars = source.split('');
645 const re = new RegExp(CPP_INLINE_ANNOTATION_RE.source, 'g');
646 let m: RegExpExecArray | null;
647 while ((m = re.exec(source)) !== null) {
648 let i = m.index + m[0].length - 1; // index of the opening '('
649 let depth = 0;
650 let end = -1;
651 for (; i < source.length; i++) {
652 const c = source[i];
653 if (c === '"' || c === "'") {
654 const quote = c;
655 i++;
656 while (i < source.length && source[i] !== quote) {
657 if (source[i] === '\\') i++;
658 i++;
659 }
660 continue;
661 }
662 if (c === '(') depth++;
663 else if (c === ')') {
664 depth--;
665 if (depth === 0) { end = i + 1; break; }
666 }
667 }
668 if (end < 0) continue;
669 for (let k = m.index; k < end; k++) {
670 if (chars[k] !== '\n' && chars[k] !== '\r') chars[k] = ' ';
671 }
672 re.lastIndex = end;
673 }
674 return chars.join('');
675}
676
677/**
678 * Blank CUDA-specific constructs before parsing `.cu`/`.cuh` files (parsed with

Callers 2

extraction.test.tsFile · 0.90
preParseCppSourceFunction · 0.85

Calls 2

execMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected