MCPcopy Create free account
hub / github.com/dexwritescode/rust-mcp / extract_function_impl

Function extract_function_impl

src/tools/refactoring.rs:45–97  ·  view source on GitHub ↗
(
    args: Value,
    analyzer: &mut RustAnalyzerClient,
)

Source from the content-addressed store, hash-verified

43}
44
45pub async fn extract_function_impl(
46 args: Value,
47 analyzer: &mut RustAnalyzerClient,
48) -> Result<ToolResult> {
49 let file_path = args
50 .get("file_path")
51 .and_then(|v| v.as_str())
52 .ok_or_else(|| anyhow::anyhow!("Missing file_path parameter"))?;
53 let start_line = args
54 .get("start_line")
55 .and_then(|v| v.as_u64())
56 .ok_or_else(|| anyhow::anyhow!("Missing start_line parameter"))?;
57 let start_character = args
58 .get("start_character")
59 .and_then(|v| v.as_u64())
60 .ok_or_else(|| anyhow::anyhow!("Missing start_character parameter"))?;
61 let end_line = args
62 .get("end_line")
63 .and_then(|v| v.as_u64())
64 .ok_or_else(|| anyhow::anyhow!("Missing end_line parameter"))?;
65 let end_character = args
66 .get("end_character")
67 .and_then(|v| v.as_u64())
68 .ok_or_else(|| anyhow::anyhow!("Missing end_character parameter"))?;
69 let function_name = args
70 .get("function_name")
71 .and_then(|v| v.as_str())
72 .ok_or_else(|| anyhow::anyhow!("Missing function_name parameter"))?;
73
74 // Implementation will use rust-analyzer LSP to extract function
75 let result = analyzer
76 .extract_function(
77 file_path,
78 start_line as u32,
79 start_character as u32,
80 end_line as u32,
81 end_character as u32,
82 function_name,
83 )
84 .await?;
85
86 Ok(ToolResult {
87 content: vec![
88 json!({
89 "type": "text",
90 "text": result
91 })
92 .as_object()
93 .unwrap()
94 .clone(),
95 ],
96 })
97}
98
99pub async fn inline_function_impl(
100 args: Value,

Callers 1

execute_toolFunction · 0.85

Calls 1

extract_functionMethod · 0.45

Tested by

no test coverage detected