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

Method flush_fn_ref_candidates

codegraph-kernel/src/go.rs:1320–1357  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

1318 }
1319
1320 fn flush_fn_ref_candidates(&mut self) {
1321 let cands = std::mem::take(&mut self.fn_ref_cands);
1322 if cands.is_empty() || util::is_generated_file(self.file_path) {
1323 return;
1324 }
1325 let survivors: Vec<Cand<'t>> = cands
1326 .into_iter()
1327 .filter(|c| {
1328 c.name.starts_with("this.")
1329 || c.name.contains('.')
1330 || c.name.contains("::")
1331 || self.defined_fn_names.contains(&c.name)
1332 || self.imported_names.contains(&c.name)
1333 })
1334 .collect();
1335 // One reference per function and name, at its first use; one per
1336 // scope where the function binds the name itself (#2596). Mirrors
1337 // flushFnRefCandidates / goScopedFnRefKeys.
1338 let scopes = go_scoped_fn_ref_scopes(&survivors, &self.node_ids, self.src);
1339 let mut seen: HashSet<(String, String, Option<usize>)> = HashSet::new();
1340 for (i, c) in survivors.into_iter().enumerate() {
1341 let scope = scopes.get(&i).copied();
1342 if !seen.insert((self.node_ids[c.from as usize].clone(), c.name.clone(), scope)) {
1343 continue;
1344 }
1345 let column = util::col16(self.src, &self.line_starts, c.row, c.column_byte);
1346 let name_ref = self.arena.put(&c.name);
1347 self.tables.push_ref(&RefRow {
1348 from_idx: c.from,
1349 kind: FUNCTION_REF_CODE,
1350 line: c.line,
1351 column,
1352 reference_name: name_ref,
1353 candidates: NONE_STR,
1354 from_id_str: NONE_STR,
1355 });
1356 }
1357 }
1358
1359 // --- value refs -------------------------------------------------------------------
1360

Callers 1

extractFunction · 0.45

Calls 8

is_generated_fileFunction · 0.85
go_scoped_fn_ref_scopesFunction · 0.85
col16Function · 0.85
getMethod · 0.65
putMethod · 0.65
takeFunction · 0.50
collectMethod · 0.45
push_refMethod · 0.45

Tested by

no test coverage detected