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

Function goScopedFnRefScopes

src/extraction/function-ref.ts:1003–1035  ·  view source on GitHub ↗
(
  candidates: ReadonlyArray<C>,
  source: string
)

Source from the content-addressed store, hash-verified

1001 * just for those. Mirrored in the kernel (go.rs `go_scoped_fn_ref_scopes`).
1002 */
1003export function goScopedFnRefScopes<C extends { name: string; fromNodeId: string; goNode?: SyntaxNode }>(
1004 candidates: ReadonlyArray<C>,
1005 source: string
1006): Map<C, number> {
1007 const groups = new Map<string, C[]>();
1008 for (const c of candidates) {
1009 if (!c.goNode || c.name.includes('.')) continue;
1010 const key = `${c.fromNodeId}|${c.name}`;
1011 const group = groups.get(key);
1012 if (group) group.push(c);
1013 else groups.set(key, [c]);
1014 }
1015 const sites = new Map<C, GoFnRefSite>();
1016 const units = new Map<number, SyntaxNode>();
1017 const names = new Set<string>();
1018 for (const group of groups.values()) {
1019 if (group.length < 2) continue;
1020 for (const c of group) {
1021 const site = goFnRefSite(c.goNode!);
1022 if (!site.unit) continue;
1023 sites.set(c, site);
1024 units.set(site.unit.id, site.unit);
1025 names.add(c.name);
1026 }
1027 }
1028 const out = new Map<C, number>();
1029 if (units.size === 0) return out;
1030 const bound = goLocalBindings(units.values(), names, source);
1031 for (const [c, site] of sites) {
1032 if (bound.has(`${site.unit!.id}|${c.name}`)) out.set(c, site.scope);
1033 }
1034 return out;
1035}

Callers 1

flushFnRefCandidatesMethod · 0.90

Calls 7

goFnRefSiteFunction · 0.85
goLocalBindingsFunction · 0.85
pushMethod · 0.80
hasMethod · 0.80
getMethod · 0.65
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected