搜索实体
(&self, query: &str)
| 133 | |
| 134 | /// 搜索实体 |
| 135 | pub fn search_entities(&self, query: &str) -> Vec<SearchResult> { |
| 136 | let mut results = Vec::new(); |
| 137 | |
| 138 | // 搜索函数 |
| 139 | let call_graph = self.call_graph.read(); |
| 140 | let functions = call_graph.find_functions_by_name(query); |
| 141 | for function in functions { |
| 142 | results.push(SearchResult { |
| 143 | id: function.id, |
| 144 | name: function.name.clone(), |
| 145 | entity_type: "function".to_string(), |
| 146 | file_path: function.file_path.clone(), |
| 147 | line_start: function.line_start, |
| 148 | line_end: function.line_end, |
| 149 | language: function.language.clone(), |
| 150 | }); |
| 151 | } |
| 152 | |
| 153 | // 搜索类 |
| 154 | let entity_graph = self.entity_graph.read(); |
| 155 | let classes = entity_graph.find_classes_by_name(query); |
| 156 | for class in classes { |
| 157 | results.push(SearchResult { |
| 158 | id: class.id, |
| 159 | name: class.name.clone(), |
| 160 | entity_type: "class".to_string(), |
| 161 | file_path: class.file_path.clone(), |
| 162 | line_start: class.line_start, |
| 163 | line_end: class.line_end, |
| 164 | language: class.language.clone(), |
| 165 | }); |
| 166 | } |
| 167 | |
| 168 | results |
| 169 | } |
| 170 | |
| 171 | /// 获取函数的调用者 |
| 172 | pub fn get_function_callers(&self, function_id: &uuid::Uuid) -> Vec<FunctionInfo> { |
no test coverage detected