从AST符号提取类信息
(
&self,
symbol: &dyn crate::codegraph::treesitter::ast_instance_structs::AstSymbolInstance,
file_path: &PathBuf,
language: &str,
namespace: &str,
)
| 498 | |
| 499 | /// 从AST符号提取类信息 |
| 500 | fn _extract_class_info( |
| 501 | &self, |
| 502 | symbol: &dyn crate::codegraph::treesitter::ast_instance_structs::AstSymbolInstance, |
| 503 | file_path: &PathBuf, |
| 504 | language: &str, |
| 505 | namespace: &str, |
| 506 | ) -> ClassInfo { |
| 507 | let name = symbol.name().to_string(); |
| 508 | let range = symbol.full_range(); |
| 509 | let line_start = range.start_point.row + 1; |
| 510 | let line_end = range.end_point.row + 1; |
| 511 | |
| 512 | // 根据语言确定类类型 |
| 513 | let class_type = match language { |
| 514 | "rust" => ClassType::Struct, |
| 515 | "cpp" | "java" | "typescript" | "javascript" => ClassType::Class, |
| 516 | _ => ClassType::Class, |
| 517 | }; |
| 518 | |
| 519 | ClassInfo { |
| 520 | id: Uuid::new_v4(), |
| 521 | name, |
| 522 | file_path: file_path.clone(), |
| 523 | line_start, |
| 524 | line_end, |
| 525 | namespace: namespace.to_string(), |
| 526 | language: language.to_string(), |
| 527 | class_type, |
| 528 | parent_class: None, // 需要进一步解析继承关系 |
| 529 | implemented_interfaces: vec![], |
| 530 | member_functions: vec![], |
| 531 | member_variables: vec![], |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | /// 从AST符号提取函数调用信息 |
| 536 | fn _extract_function_call_info( |
no test coverage detected