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

Function goScopedFnRefScopes

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

Source from the content-addressed store, hash-verified

1021 * just for those. Mirrored in the kernel (go.rs `go_scoped_fn_ref_scopes`).
1022 */
1023export function goScopedFnRefScopes<C extends { name: string; fromNodeId: string; goNode?: SyntaxNode }>(
1024 candidates: ReadonlyArray<C>,
1025 source: string
1026): Map<C, number> {
1027 const groups = new Map<string, C[]>();
1028 for (const c of candidates) {
1029 if (!c.goNode || c.name.includes('.')) continue;
1030 const key = `${c.fromNodeId}|${c.name}`;
1031 const group = groups.get(key);
1032 if (group) group.push(c);
1033 else groups.set(key, [c]);
1034 }
1035 const sites = new Map<C, GoFnRefSite>();
1036 const units = new Map<number, SyntaxNode>();
1037 const names = new Set<string>();
1038 for (const group of groups.values()) {
1039 if (group.length < 2) continue;
1040 for (const c of group) {
1041 const site = goFnRefSite(c.goNode!);
1042 if (!site.unit) continue;
1043 sites.set(c, site);
1044 units.set(site.unit.id, site.unit);
1045 names.add(c.name);
1046 }
1047 }
1048 const out = new Map<C, number>();
1049 if (units.size === 0) return out;
1050 const bound = goLocalBindings(units.values(), names, source);
1051 for (const [c, site] of sites) {
1052 if (bound.has(`${site.unit!.id}|${c.name}`)) out.set(c, site.scope);
1053 }
1054 return out;
1055}

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