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

Function blankCppInlineAnnotationMacros

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

Source from the content-addressed store, hash-verified

630 */
631const CPP_INLINE_ANNOTATION_RE = /\b(?:UMETA|UPARAM|UE_DEPRECATED\w*)\s*\(/g;
632export function blankCppInlineAnnotationMacros(source: string): string {
633 if (!/\b(?:UMETA|UPARAM|UE_DEPRECATED)/.test(source)) return source;
634 const chars = source.split('');
635 const re = new RegExp(CPP_INLINE_ANNOTATION_RE.source, 'g');
636 let m: RegExpExecArray | null;
637 while ((m = re.exec(source)) !== null) {
638 let i = m.index + m[0].length - 1; // index of the opening '('
639 let depth = 0;
640 let end = -1;
641 for (; i < source.length; i++) {
642 const c = source[i];
643 if (c === '"' || c === "'") {
644 const quote = c;
645 i++;
646 while (i < source.length && source[i] !== quote) {
647 if (source[i] === '\\') i++;
648 i++;
649 }
650 continue;
651 }
652 if (c === '(') depth++;
653 else if (c === ')') {
654 depth--;
655 if (depth === 0) { end = i + 1; break; }
656 }
657 }
658 if (end < 0) continue;
659 for (let k = m.index; k < end; k++) {
660 if (chars[k] !== '\n' && chars[k] !== '\r') chars[k] = ' ';
661 }
662 re.lastIndex = end;
663 }
664 return chars.join('');
665}
666
667/**
668 * 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