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

Method flush_fn_ref_candidates

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

Source from the content-addressed store, hash-verified

1297 }
1298
1299 fn flush_fn_ref_candidates(&mut self) {
1300 let cands = std::mem::take(&mut self.fn_ref_cands);
1301 if cands.is_empty() || util::is_generated_file(self.file_path) {
1302 return;
1303 }
1304 let survivors: Vec<Cand<'t>> = cands
1305 .into_iter()
1306 .filter(|c| {
1307 c.name.starts_with("this.")
1308 || c.name.contains('.')
1309 || c.name.contains("::")
1310 || self.defined_fn_names.contains(&c.name)
1311 || self.imported_names.contains(&c.name)
1312 })
1313 .collect();
1314 // One reference per function and name, at its first use; one per
1315 // scope where the function binds the name itself (#2596). Mirrors
1316 // flushFnRefCandidates / goScopedFnRefKeys.
1317 let scopes = go_scoped_fn_ref_scopes(&survivors, &self.node_ids, self.src);
1318 let mut seen: HashSet<(String, String, Option<usize>)> = HashSet::new();
1319 for (i, c) in survivors.into_iter().enumerate() {
1320 let scope = scopes.get(&i).copied();
1321 if !seen.insert((self.node_ids[c.from as usize].clone(), c.name.clone(), scope)) {
1322 continue;
1323 }
1324 let column = util::col16(self.src, &self.line_starts, c.row, c.column_byte);
1325 let name_ref = self.arena.put(&c.name);
1326 self.tables.push_ref(&RefRow {
1327 from_idx: c.from,
1328 kind: FUNCTION_REF_CODE,
1329 line: c.line,
1330 column,
1331 reference_name: name_ref,
1332 candidates: NONE_STR,
1333 from_id_str: NONE_STR,
1334 });
1335 }
1336 }
1337
1338 // --- value refs -------------------------------------------------------------------
1339

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