MCPcopy
hub / github.com/colbymchenry/codegraph / recoverMangledCppName

Function recoverMangledCppName

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

Source from the content-addressed store, hash-verified

347 * that is a bare primitive/keyword rather than a real identifier.
348 */
349export function recoverMangledCppName(name: string): string {
350 if (!/\s/.test(name) || name.startsWith('operator') || name.startsWith('~')) return name;
351 if (/^\S+\s+\([A-Za-z_]\w*\)/.test(name)) return name; // `Ret (name)` idiom — leave alone
352 const beforeParams = name.includes('(') ? name.slice(0, name.indexOf('(')) : name;
353 const tokens = beforeParams.trim().split(/\s+/);
354 const candidate = tokens[tokens.length - 1];
355 if (!candidate || !/^[A-Za-z_]\w*$/.test(candidate) || CPP_PRIMITIVE_NAMES.has(candidate)) return name;
356 return candidate;
357}
358
359/** C/C++ source pre-processing before tree-sitter: recover both macro-annotated
360 * class definitions and macro-prefixed function definitions. Offset-preserving. */

Callers 1

extraction.test.tsFile · 0.90

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected