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