Skip to content
4 changes: 0 additions & 4 deletions crates/codegraph-core/src/ast_analysis/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,6 @@ impl<'a> CfgBuilder<'a> {
}
}

fn start_line_of(&self, block_idx: u32) -> Option<u32> {
self.blocks.iter().find(|b| b.index == block_idx).and_then(|b| b.start_line)
}

/// Get statement children from a block or statement list.
fn get_statements<'b>(&self, node: &Node<'b>) -> Vec<Node<'b>> {
let kind = node.kind();
Expand Down
36 changes: 15 additions & 21 deletions crates/codegraph-core/src/ast_analysis/complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,6 @@ fn walk_children(
enum BranchAction {
/// Node handled — walk children at the given nesting delta, then return.
Handled { cognitive_delta: u32, cyclomatic_delta: u32, nesting_delta: u32 },
/// Not a special branch pattern — fall through to normal processing.
NotHandled,
}

/// Classify a branch node (one where `rules.is_branch(kind)` is true).
Expand Down Expand Up @@ -675,14 +673,12 @@ fn walk(

// Branch/control flow nodes (skip keyword leaf tokens)
if rules.is_branch(kind) && node.child_count() > 0 {
if let BranchAction::Handled { cognitive_delta, cyclomatic_delta, nesting_delta } =
classify_branch(node, kind, rules, nesting_level)
{
*cognitive += cognitive_delta;
*cyclomatic += cyclomatic_delta;
walk_children(node, nesting_level + nesting_delta, false, rules, cognitive, cyclomatic, max_nesting, depth);
return;
}
let BranchAction::Handled { cognitive_delta, cyclomatic_delta, nesting_delta } =
classify_branch(node, kind, rules, nesting_level);
*cognitive += cognitive_delta;
*cyclomatic += cyclomatic_delta;
walk_children(node, nesting_level + nesting_delta, false, rules, cognitive, cyclomatic, max_nesting, depth);
return;
}

// Pattern C plain else (Go/Java)
Expand Down Expand Up @@ -1323,17 +1319,15 @@ fn walk_all(

// Branch/control flow nodes (skip keyword leaf tokens)
if c_rules.is_branch(kind) && node.child_count() > 0 {
if let BranchAction::Handled { cognitive_delta, cyclomatic_delta, nesting_delta } =
classify_branch(node, kind, c_rules, nesting_level)
{
*cognitive += cognitive_delta;
*cyclomatic += cyclomatic_delta;
walk_all_children(
node, source, nesting_level + nesting_delta, false, skip_h,
c_rules, h_rules, cognitive, cyclomatic, max_nesting, operators, operands,
);
return;
}
let BranchAction::Handled { cognitive_delta, cyclomatic_delta, nesting_delta } =
classify_branch(node, kind, c_rules, nesting_level);
*cognitive += cognitive_delta;
*cyclomatic += cyclomatic_delta;
walk_all_children(
node, source, nesting_level + nesting_delta, false, skip_h,
c_rules, h_rules, cognitive, cyclomatic, max_nesting, operators, operands,
);
return;
}

// Pattern C plain else (Go/Java)
Expand Down
14 changes: 7 additions & 7 deletions crates/codegraph-core/src/ast_analysis/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,8 @@ fn collect_identifiers(node: &Node, out: &mut Vec<String>, rules: &DataflowRules

#[derive(Debug, Clone)]
enum LocalSource {
CallReturn { callee: String },
Destructured { callee: String },
CallReturn,
Destructured,
}

struct ScopeFrame {
Expand All @@ -908,8 +908,8 @@ fn find_binding(scope_stack: &[ScopeFrame], name: &str) -> Option<BindingInfo> {
}
if let Some(local) = scope.locals.get(name) {
let confidence = match local {
LocalSource::CallReturn { .. } => 0.9,
LocalSource::Destructured { .. } => 0.8,
LocalSource::CallReturn => 0.9,
LocalSource::Destructured => 0.8,
};
return Some(BindingInfo {
binding_type: "local".to_string(),
Expand Down Expand Up @@ -1200,7 +1200,7 @@ fn handle_var_declarator(
});
scope
.locals
.insert(n.clone(), LocalSource::Destructured { callee: callee.clone() });
.insert(n.clone(), LocalSource::Destructured);
}
} else {
let var_name = node_text(&name_n, source).to_string();
Expand All @@ -1211,7 +1211,7 @@ fn handle_var_declarator(
expression: truncate(node_text(node, source), DATAFLOW_TRUNCATION_LIMIT),
line: node_line(node),
});
scope.locals.insert(var_name, LocalSource::CallReturn { callee });
scope.locals.insert(var_name, LocalSource::CallReturn);
}
}

Expand Down Expand Up @@ -1267,7 +1267,7 @@ fn handle_assignment(
line: node_line(node),
});
if let Some(scope) = scope_stack.last_mut() {
scope.locals.insert(var_name, LocalSource::CallReturn { callee });
scope.locals.insert(var_name, LocalSource::CallReturn);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::types::FileSymbols;

struct CacheEntry {
tree: Tree,
lang: LanguageKind,
}

/// Cache of parse trees for incremental parsing.
Expand Down Expand Up @@ -51,7 +50,7 @@ impl ParseTreeCache {

let symbols = extract_symbols(lang, &tree, source_bytes, &file_path);

self.entries.insert(file_path, CacheEntry { tree, lang });
self.entries.insert(file_path, CacheEntry { tree });

Some(symbols)
}
Expand Down
4 changes: 4 additions & 0 deletions crates/codegraph-core/src/extractors/clojure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ fn walk_clojure(
return;
}

// `next_ns_owned` holds the String so that `next_ns` can borrow it as
// `&str` for the duration of this stack frame. The assignment looks
// "never read" to the compiler but the borrow on the next line reads it.
#[allow(unused_assignments)]
let mut next_ns_owned: Option<String> = None;
let next_ns: Option<&str> = if node.kind() == "list_lit" {
match handle_list_form(node, source, symbols, current_ns) {
Expand Down
Loading