MCPcopy Create free account
hub / github.com/CodeBendKit/codeseek / refresh_file

Method refresh_file

rust-core/src/codegraph/parser.rs:84–128  ·  view source on GitHub ↗

增量更新单个文件

(
        &mut self,
        file_path: &PathBuf,
        entity_graph: &mut EntityGraph,
        call_graph: &mut PetCodeGraph,
    )

Source from the content-addressed store, hash-verified

82
83 /// 增量更新单个文件
84 pub fn refresh_file(
85 &mut self,
86 file_path: &PathBuf,
87 entity_graph: &mut EntityGraph,
88 call_graph: &mut PetCodeGraph,
89 ) -> Result<(), String> {
90 info!("Refreshing file: {}", file_path.display());
91
92 // 检查文件是否存在
93 if !file_path.exists() {
94 // 文件被删除,清理相关索引
95 self._remove_file_entities(file_path, entity_graph, call_graph);
96 return Ok(());
97 }
98
99 // 解析文件,提取新的实体和函数
100 let (classes, functions) = self._extract_entities_from_file(file_path)?;
101
102 // 移除旧的实体和函数
103 self._remove_file_entities(file_path, entity_graph, call_graph);
104
105 // 添加到图中
106 let class_ids: Vec<Uuid> = classes.iter().map(|c| c.id).collect();
107 let function_ids: Vec<Uuid> = functions.iter().map(|f| f.id).collect();
108
109 for class in classes {
110 entity_graph.add_class(class);
111 }
112
113 for function in functions {
114 call_graph.add_function(function);
115 }
116
117 // 分析调用关系
118 self._analyze_file_calls(file_path, &function_ids, call_graph)?;
119
120 // 更新索引
121 self.file_index.rebuild_for_file(file_path, class_ids.clone(), function_ids.clone());
122
123 // 更新代码片段索引
124 self._update_snippet_index(file_path, &class_ids, &function_ids, entity_graph)?;
125
126 info!("Successfully refreshed file: {}", file_path.display());
127 Ok(())
128 }
129
130 /// 从文件提取实体
131 fn _extract_entities_from_file(&self, file_path: &PathBuf) -> Result<(Vec<ClassInfo>, Vec<FunctionInfo>), String> {

Callers

nothing calls this directly

Calls 7

add_classMethod · 0.80
rebuild_for_fileMethod · 0.80
_remove_file_entitiesMethod · 0.45
add_functionMethod · 0.45
_analyze_file_callsMethod · 0.45
_update_snippet_indexMethod · 0.45

Tested by

no test coverage detected