Create a new registry with all supported language parsers.
()
| 249 | impl ParserRegistry { |
| 250 | /// Create a new registry with all supported language parsers. |
| 251 | pub fn new() -> Self { |
| 252 | let mut parsers: HashMap<Language, Box<dyn LanguageParser>> = HashMap::new(); |
| 253 | |
| 254 | parsers.insert( |
| 255 | Language::TypeScript, |
| 256 | Box::new(typescript::TypeScriptParser::new()), |
| 257 | ); |
| 258 | parsers.insert( |
| 259 | Language::Tsx, |
| 260 | Box::new(typescript::TypeScriptParser::new_tsx()), |
| 261 | ); |
| 262 | parsers.insert(Language::Python, Box::new(python::PythonParser::new())); |
| 263 | parsers.insert(Language::Rust, Box::new(rust::RustParser::new())); |
| 264 | parsers.insert(Language::Go, Box::new(go::GoParser::new())); |
| 265 | parsers.insert(Language::Java, Box::new(java::JavaParser::new())); |
| 266 | parsers.insert(Language::Cpp, Box::new(cpp::CppParser::new())); |
| 267 | parsers.insert(Language::C, Box::new(cpp::CppParser::new_c())); |
| 268 | parsers.insert(Language::Swift, Box::new(swift::SwiftParser::new())); |
| 269 | |
| 270 | Self { parsers } |
| 271 | } |
| 272 | |
| 273 | /// Check if a file path is supported. |
| 274 | pub fn is_supported(&self, path: &str) -> bool { |