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

Method flush_fn_ref_candidates

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

Source from the content-addressed store, hash-verified

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

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