创建未解析的调用关系
(
&self,
caller: &FunctionInfo,
call_name: &str,
file_path: &PathBuf,
call_line: usize,
code_graph: &mut PetCodeGraph,
)
| 1336 | |
| 1337 | /// 创建未解析的调用关系 |
| 1338 | fn _create_unresolved_call_relation( |
| 1339 | &self, |
| 1340 | caller: &FunctionInfo, |
| 1341 | call_name: &str, |
| 1342 | file_path: &PathBuf, |
| 1343 | call_line: usize, |
| 1344 | code_graph: &mut PetCodeGraph, |
| 1345 | ) { |
| 1346 | // 为未解析的调用创建一个临时函数节点 |
| 1347 | let temp_callee_id = Uuid::new_v4(); |
| 1348 | let temp_callee = FunctionInfo { |
| 1349 | id: temp_callee_id, |
| 1350 | name: call_name.to_string(), |
| 1351 | file_path: file_path.clone(), |
| 1352 | line_start: call_line, |
| 1353 | line_end: call_line, |
| 1354 | namespace: "unresolved".to_string(), |
| 1355 | language: caller.language.clone(), |
| 1356 | signature: Some(format!("unresolved_call_{}", call_name)), |
| 1357 | }; |
| 1358 | |
| 1359 | // 添加到代码图 |
| 1360 | let _node_index = code_graph.add_function(temp_callee); |
| 1361 | |
| 1362 | // 创建未解析的调用关系 |
| 1363 | let relation = CallRelation { |
| 1364 | caller_id: caller.id, |
| 1365 | callee_id: temp_callee_id, |
| 1366 | caller_name: caller.name.clone(), |
| 1367 | callee_name: call_name.to_string(), |
| 1368 | caller_file: caller.file_path.clone(), |
| 1369 | callee_file: file_path.clone(), |
| 1370 | line_number: call_line, |
| 1371 | is_resolved: false, |
| 1372 | }; |
| 1373 | |
| 1374 | if let Err(e) = code_graph.add_call_relation(relation) { |
| 1375 | warn!("Failed to add unresolved call relation: {}", e); |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | /// 回退调用分析(当TreeSitter解析失败时使用) |
| 1380 | fn _fallback_call_analysis( |
no test coverage detected