MCPcopy Create free account
hub / github.com/JaredStewart/coderlm / get_implementation

Function get_implementation

server/src/ops/symbol_ops.rs:75–106  ·  view source on GitHub ↗
(
    root: &Path,
    symbol_table: &Arc<SymbolTable>,
    symbol_name: &str,
    file: &str,
)

Source from the content-addressed store, hash-verified

73}
74
75pub fn get_implementation(
76 root: &Path,
77 symbol_table: &Arc<SymbolTable>,
78 symbol_name: &str,
79 file: &str,
80) -> Result<String, String> {
81 // Try exact lookup first
82 let sym = symbol_table.get(file, symbol_name).or_else(|| {
83 // Fuzzy fallback: search by name and filter by file
84 let candidates = symbol_table.search(symbol_name, 50);
85 candidates
86 .into_iter()
87 .find(|s| s.file == file && s.name.to_lowercase() == symbol_name.to_lowercase())
88 .or_else(|| {
89 // Broader: any symbol in the file whose name contains the query
90 let file_symbols = symbol_table.list_by_file(file);
91 file_symbols
92 .into_iter()
93 .find(|s| s.name.to_lowercase() == symbol_name.to_lowercase())
94 })
95 });
96
97 let sym = sym.ok_or_else(|| format!("Symbol '{}' not found in '{}'", symbol_name, file))?;
98
99 let abs_path = root.join(&sym.file);
100 let source = std::fs::read_to_string(&abs_path)
101 .map_err(|e| format!("Failed to read '{}': {}", sym.file, e))?;
102
103 let start = sym.byte_range.0;
104 let end = sym.byte_range.1.min(source.len());
105 Ok(source[start..end].to_string())
106}
107
108pub fn define_symbol(
109 symbol_table: &Arc<SymbolTable>,

Callers

nothing calls this directly

Calls 4

searchMethod · 0.80
list_by_fileMethod · 0.80
getMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected