Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ast/src/lang/graphs/array_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,4 +947,21 @@ impl ArrayGraph {
let edge_type = sanitize_string(&format!("{}", edge.edge));
format!("{}-{}-{}", source_key, target_key, edge_type,)
}

pub fn find_dependents(
&self,
target_name: &str,
target_file: &str,
edge_types: &[EdgeType],
) -> Vec<(NodeRef, EdgeType)> {
self.edges
.iter()
.filter(|e| {
edge_types.contains(&e.edge)
&& e.target.node_data.name == target_name
&& e.target.node_data.file == target_file
})
.map(|e| (e.source.clone(), e.edge.clone()))
.collect()
}
}
33 changes: 33 additions & 0 deletions cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub enum Commands {
Changes(ChangesArgs),
/// Show a dependency tree for a named node
Deps(DepsArgs),
/// Show what is affected if a node changes (reverse dependency tree)
Impact(ImpactArgs),
}

#[derive(Debug, Args)]
Expand Down Expand Up @@ -155,6 +157,33 @@ pub struct DepsArgs {
pub files: Vec<String>,
}

#[derive(Debug, Args)]
pub struct ImpactArgs {
/// Name of the node to check impact for
#[arg(long)]
pub name: Option<String>,

/// File containing the node (seeds all nodes in file when --name is omitted)
#[arg(long)]
pub file: Option<String>,

/// Maximum traversal depth (0 = unlimited, default: 3)
#[arg(long, default_value = "3")]
pub depth: usize,

/// Only match seed nodes of this type (e.g. Function, Class, Endpoint)
#[arg(long)]
pub r#type: Option<String>,

/// Include unverified (cross-file unresolved) calls (default: true)
#[arg(long, default_value_t = true, action = ArgAction::Set)]
pub allow: bool,

/// Files or directories to parse
#[arg(value_name = "FILE_OR_DIR", num_args = 1..)]
pub files: Vec<String>,
}

impl CliArgs {
pub fn parse_and_expand() -> Result<Self> {
let mut args = Self::parse();
Expand Down Expand Up @@ -188,6 +217,10 @@ impl CliArgs {
return Ok(args);
}

if let Some(Commands::Impact(_)) = &args.command {
return Ok(args);
}

Ok(args)
}
}
Loading
Loading