检测文件语言
(&self, file_path: &Path)
| 375 | |
| 376 | /// 检测文件语言 |
| 377 | fn _detect_language(&self, file_path: &Path) -> String { |
| 378 | if let Some(ext) = file_path.extension().and_then(|e| e.to_str()) { |
| 379 | match ext.to_lowercase().as_str() { |
| 380 | "rs" => "rust".to_string(), |
| 381 | "py" | "py3" | "pyx" => "python".to_string(), |
| 382 | "ts" | "tsx" => "typescript".to_string(), |
| 383 | "java" => "java".to_string(), |
| 384 | "cpp" | "cc" | "cxx" | "c++" | "c" | "h" | "hpp" | "hxx" | "hh" => "cpp".to_string(), |
| 385 | "go" => "go".to_string(), |
| 386 | _ => "unknown".to_string(), |
| 387 | } |
| 388 | } else { |
| 389 | "unknown".to_string() |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | /// 提取命名空间 |
| 394 | fn _extract_namespace(&self, file_path: &Path) -> String { |
no test coverage detected