Skip to content

Commit 2900f43

Browse files
authored
refactor(native): extract emit_pts_alias_edges params into struct (#1485)
* chore: gitignore napi-generated artifacts in crates/codegraph-core * chore(tests): remove unused biome suppression in visitor.test.ts * fix(titan-run): sync --start-from enum and phase-timestamp list with actual phases * fix(hooks): track Bash file modifications via before/after git status diff Adds snapshot-pre-bash.sh (PreToolUse Bash) + track-bash-writes.sh (PostToolUse Bash): the pre-hook captures git status --porcelain to a per-worktree temp file before each Bash call; the post-hook diffs the before/after state and appends newly modified or created files to .claude/session-edits.log. This closes the gap where files written by sed -i, printf redirects, tee, heredocs, or build tools (Cargo.lock, lockfiles) were never recorded, causing guard-git.sh to emit false-positive BLOCKED errors. Closes #1457 * chore(native): remove dead code (unused var, method, variant, fields) - clojure.rs: annotate lifetime-anchor assignment to silence false-positive - cfg.rs: remove never-called start_line_of method - complexity.rs: remove never-constructed NotHandled variant; convert irrefutable if-let patterns to plain let destructures - dataflow.rs: remove never-read callee fields from CallReturn/Destructured - incremental.rs: remove never-read lang field from CacheEntry cargo check and cargo clippy both clean after these changes. * refactor(native): extract emit_pts_alias_edges params into PtsAliasCtx struct
1 parent dc22b03 commit 2900f43

1 file changed

Lines changed: 55 additions & 24 deletions

File tree

crates/codegraph-core/src/domain/graph/builder/stages/build_edges.rs

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -360,50 +360,55 @@ fn resolve_via_points_to<'a>(
360360
}
361361
}
362362

363+
/// Per-call-site inputs for `emit_pts_alias_edges`.
364+
/// Groups the lookup parameters so the function stays within the argument-count limit.
365+
struct PtsAliasCtx<'a> {
366+
pts: &'a HashMap<String, HashSet<String>>,
367+
lookup_name: &'a str,
368+
call_line: u32,
369+
caller_id: u32,
370+
caller_name: &'a str,
371+
is_dynamic: u32,
372+
rel_path: &'a str,
373+
imported_names: &'a HashMap<&'a str, &'a str>,
374+
type_map: &'a HashMap<&'a str, (&'a str, f64)>,
375+
}
376+
363377
/// Resolve each pts alias of `lookup_name` and emit hop-penalised call edges.
364378
/// Shared by the no-receiver gate and the receiver-key (`rest.prop()`) fallback;
365379
/// mirrors the alias-emission loops in buildFileCallEdges (build-edges.ts).
366-
#[allow(clippy::too_many_arguments)]
367380
fn emit_pts_alias_edges<'a>(
368381
ctx: &EdgeContext<'a>,
369-
pts: &HashMap<String, HashSet<String>>,
370-
lookup_name: &str,
371-
call_line: u32,
372-
caller_id: u32,
373-
caller_name: &str,
374-
is_dynamic: u32,
375-
rel_path: &str,
376-
imported_names: &HashMap<&str, &str>,
377-
type_map: &HashMap<&str, (&str, f64)>,
382+
alias_ctx: &PtsAliasCtx<'_>,
378383
seen_edges: &HashSet<u64>,
379384
pts_edge_map: &mut HashMap<u64, usize>,
380385
edges: &mut Vec<ComputedEdge>,
381386
) {
382-
for alias in resolve_via_points_to(lookup_name, pts) {
383-
let alias_imported_from = imported_names.get(alias).copied();
387+
for alias in resolve_via_points_to(alias_ctx.lookup_name, alias_ctx.pts) {
388+
let alias_imported_from = alias_ctx.imported_names.get(alias).copied();
384389
let alias_call = CallInfo {
385390
name: alias.to_string(),
386-
line: call_line,
391+
line: alias_ctx.call_line,
387392
dynamic: Some(true),
388393
receiver: None,
389394
};
390395
let mut alias_targets = resolve_call_targets(
391-
ctx, &alias_call, rel_path, alias_imported_from, type_map, caller_name,
396+
ctx, &alias_call, alias_ctx.rel_path, alias_imported_from, alias_ctx.type_map, alias_ctx.caller_name,
392397
);
393-
sort_targets_by_confidence(&mut alias_targets, rel_path, alias_imported_from);
398+
sort_targets_by_confidence(&mut alias_targets, alias_ctx.rel_path, alias_imported_from);
394399
for t in &alias_targets {
395-
let edge_key = ((caller_id as u64) << 32) | (t.id as u64);
396-
if t.id != caller_id && !seen_edges.contains(&edge_key) && !pts_edge_map.contains_key(&edge_key) {
397-
let conf = resolve::compute_confidence(rel_path, &t.file, alias_imported_from)
400+
let edge_key = ((alias_ctx.caller_id as u64) << 32) | (t.id as u64);
401+
if t.id != alias_ctx.caller_id && !seen_edges.contains(&edge_key) && !pts_edge_map.contains_key(&edge_key) {
402+
let conf = resolve::compute_confidence(alias_ctx.rel_path, &t.file, alias_imported_from)
398403
- PROPAGATION_HOP_PENALTY;
399404
if conf > 0.0 {
400405
pts_edge_map.insert(edge_key, edges.len());
401406
edges.push(ComputedEdge {
402-
source_id: caller_id,
407+
source_id: alias_ctx.caller_id,
403408
target_id: t.id,
404409
kind: "calls".to_string(),
405410
confidence: conf,
406-
dynamic: is_dynamic,
411+
dynamic: alias_ctx.is_dynamic,
407412
});
408413
}
409414
}
@@ -593,8 +598,21 @@ fn process_file<'a>(
593598
};
594599
if let Some(lookup_name) = lookup_name {
595600
emit_pts_alias_edges(
596-
ctx, pts, &lookup_name, call.line, caller_id, caller_name, is_dynamic,
597-
rel_path, &imported_names, &type_map, &seen_edges, &mut pts_edge_map, edges,
601+
ctx,
602+
&PtsAliasCtx {
603+
pts,
604+
lookup_name: &lookup_name,
605+
call_line: call.line,
606+
caller_id,
607+
caller_name,
608+
is_dynamic,
609+
rel_path,
610+
imported_names: &imported_names,
611+
type_map: &type_map,
612+
},
613+
&seen_edges,
614+
&mut pts_edge_map,
615+
edges,
598616
);
599617
}
600618
}
@@ -609,8 +627,21 @@ fn process_file<'a>(
609627
let receiver_key = format!("{}.{}", receiver, call.name);
610628
if pts.contains_key(receiver_key.as_str()) {
611629
emit_pts_alias_edges(
612-
ctx, pts, &receiver_key, call.line, caller_id, caller_name, is_dynamic,
613-
rel_path, &imported_names, &type_map, &seen_edges, &mut pts_edge_map, edges,
630+
ctx,
631+
&PtsAliasCtx {
632+
pts,
633+
lookup_name: &receiver_key,
634+
call_line: call.line,
635+
caller_id,
636+
caller_name,
637+
is_dynamic,
638+
rel_path,
639+
imported_names: &imported_names,
640+
type_map: &type_map,
641+
},
642+
&seen_edges,
643+
&mut pts_edge_map,
644+
edges,
614645
);
615646
}
616647
}

0 commit comments

Comments
 (0)