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

Function addNamespaceAliases

src/resolution/cpp-namespaces.ts:28–34  ·  view source on GitHub ↗

Add what a file declares. The first declaration of a name stands.

(file: string, source: string, aliases: Map<string, string>)

Source from the content-addressed store, hash-verified

26
27/** Add what a file declares. The first declaration of a name stands. */
28function addNamespaceAliases(file: string, source: string, aliases: Map<string, string>): void {
29 // (Few files declare one, and this looks for it without looking at every line.)
30 if (!CPP_NS_ALIAS_FILE.test(file) || !/\bnamespace[ \t]+\w+[ \t]*=/.test(source)) return;
31 for (const m of source.matchAll(/^[ \t]*namespace[ \t]+([A-Za-z_]\w*)[ \t]*=[ \t]*(?:::)?([A-Za-z_][\w:]*)[ \t]*;/gm)) {
32 if (!aliases.has(m[1]!)) aliases.set(m[1]!, m[2]!);
33 }
34}
35
36/** The project's namespace aliases: `namespace py = pybind11;`. */
37export function cppNamespaceAliases(context: ResolutionContext): Map<string, string> {

Callers 2

cppNamespaceAliasesFunction · 0.85
cppNamespaceAliasWalkFunction · 0.85

Calls 2

hasMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected