移除文件相关的所有实体
(
&mut self,
file_path: &PathBuf,
entity_graph: &mut EntityGraph,
call_graph: &mut PetCodeGraph,
)
| 300 | |
| 301 | /// 移除文件相关的所有实体 |
| 302 | fn _remove_file_entities( |
| 303 | &mut self, |
| 304 | file_path: &PathBuf, |
| 305 | entity_graph: &mut EntityGraph, |
| 306 | call_graph: &mut PetCodeGraph, |
| 307 | ) { |
| 308 | // 获取文件的所有实体ID |
| 309 | let entity_ids = self.file_index.get_all_entity_ids(file_path); |
| 310 | let function_ids = self.file_index.get_all_function_ids(file_path); |
| 311 | let _class_ids = self.file_index.get_all_class_ids(file_path); |
| 312 | |
| 313 | // 从图中移除 |
| 314 | for entity_id in entity_ids { |
| 315 | entity_graph.remove_entity(&entity_id); |
| 316 | } |
| 317 | |
| 318 | for function_id in function_ids { |
| 319 | if let Some(node_index) = call_graph.get_node_index(&function_id) { |
| 320 | call_graph.graph.remove_node(node_index); |
| 321 | call_graph.function_to_node.remove(&function_id); |
| 322 | call_graph.node_to_function.remove(&node_index); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // 清理索引 |
| 327 | self.file_index.remove_file(file_path); |
| 328 | self.snippet_index.clear_file_cache(file_path); |
| 329 | } |
| 330 | |
| 331 | /// 更新代码片段索引 |
| 332 | fn _update_snippet_index( |
no test coverage detected