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

Function goScopedFnRefScopes

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

Source from the content-addressed store, hash-verified

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

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