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

Method _update_snippet_index

rust-core/src/storage/incremental.rs:338–377  ·  view source on GitHub ↗

更新代码片段索引

(
        &mut self,
        file_path: &PathBuf,
        class_ids: &[Uuid],
        function_ids: &[Uuid],
    )

Source from the content-addressed store, hash-verified

336
337 /// 更新代码片段索引
338 fn _update_snippet_index(
339 &mut self,
340 file_path: &PathBuf,
341 class_ids: &[Uuid],
342 function_ids: &[Uuid],
343 ) -> Result<(), String> {
344 // 读取文件内容
345 let content = fs::read_to_string(file_path)
346 .map_err(|e| format!("Failed to read file for snippet indexing: {}", e))?;
347
348 let _lines: Vec<&str> = content.lines().collect();
349
350 // 为类添加代码片段
351 for &class_id in class_ids {
352 if let Some(entity) = self.snippet_index.get_snippet_info(&class_id) {
353 let snippet_info = crate::codegraph::types::SnippetInfo {
354 file_path: file_path.clone(),
355 line_start: entity.line_start,
356 line_end: entity.line_end,
357 cached_content: None,
358 };
359 self.snippet_index.add_snippet(class_id, snippet_info);
360 }
361 }
362
363 // 为函数添加代码片段
364 for &function_id in function_ids {
365 if let Some(entity) = self.snippet_index.get_snippet_info(&function_id) {
366 let snippet_info = crate::codegraph::types::SnippetInfo {
367 file_path: file_path.clone(),
368 line_start: entity.line_start,
369 line_end: entity.line_end,
370 cached_content: None,
371 };
372 self.snippet_index.add_snippet(function_id, snippet_info);
373 }
374 }
375
376 Ok(())
377 }
378
379 /// 检测文件语言
380 fn _detect_language(&self, file_path: &Path) -> String {

Callers 1

_update_fileMethod · 0.45

Calls 2

get_snippet_infoMethod · 0.80
add_snippetMethod · 0.80

Tested by

no test coverage detected