MCPcopy Create free account
hub / github.com/douglance/devsql / run

Method run

crates/devsql/src/tools/impact.rs:42–143  ·  view source on GitHub ↗
(&self, ctx: CommandContext)

Source from the content-addressed store, hash-verified

40#[async_trait::async_trait]
41impl CommandHandler for ImpactHandler {
42 async fn run(&self, ctx: CommandContext) -> CommandResult {
43 let file = match ctx.args.get("file").and_then(|v| v.as_str()) {
44 Some(f) => f.to_string(),
45 None => {
46 return CommandResult::Error {
47 code: "MISSING_ARG".into(),
48 message: "Missing required argument: file".into(),
49 retryable: false,
50 exit_code: Some(1),
51 cta: None,
52 };
53 }
54 };
55
56 let (mut engine, _repo_path) = match engine_from_options(&ctx.options) {
57 Ok(v) => v,
58 Err(e) => return e,
59 };
60
61 // Load symbols and imports tables
62 if let Err(e) = engine.load_code_tables(&["symbols", "imports"]) {
63 return CommandResult::Error {
64 code: "LOAD_ERROR".into(),
65 message: format!("Failed to load code tables: {e}"),
66 retryable: false,
67 exit_code: Some(1),
68 cta: None,
69 };
70 }
71
72 // Find exported symbols from the target file
73 let exports_sql = format!(
74 "SELECT name, kind, line_start, signature, visibility \
75 FROM symbols \
76 WHERE file_path LIKE '%{file}%' \
77 AND (visibility = 'pub' OR visibility = 'public' OR visibility IS NULL) \
78 ORDER BY line_start"
79 );
80
81 let exported_symbols = match engine.query(&exports_sql) {
82 Ok(rows) => rows,
83 Err(e) => {
84 return CommandResult::Error {
85 code: "QUERY_ERROR".into(),
86 message: format!("Exports query failed: {e}"),
87 retryable: false,
88 exit_code: Some(1),
89 cta: None,
90 };
91 }
92 };
93
94 // Collect exported symbol names for dependency search
95 let symbol_names: Vec<String> = exported_symbols
96 .iter()
97 .filter_map(|s| s.get("name").and_then(|v| v.as_str()).map(String::from))
98 .collect();
99

Callers

nothing calls this directly

Calls 4

engine_from_optionsFunction · 0.85
load_code_tablesMethod · 0.80
queryMethod · 0.80
is_emptyMethod · 0.80

Tested by

no test coverage detected