1pub mod rust_parser;
11pub mod python_parser;
12pub mod go_parser;
13pub mod typescript_parser;
14pub mod java_parser;
15
16#[cfg(feature = "pattern")]
17pub mod pattern;
18
19#[cfg(feature = "text-search")]
20pub mod text_search;
21
22use deagle_core::{Language, Node, Result};
23use std::path::Path;
24
25pub use rust_parser::ParseResult;
26
27pub fn parse_file(path: &Path, content: &str, language: Language) -> Result<Vec<Node>> {
29 match language {
30 Language::Rust => rust_parser::parse(path, content),
31 Language::Python => python_parser::parse(path, content),
32 Language::Go => go_parser::parse(path, content),
33 Language::TypeScript | Language::JavaScript => typescript_parser::parse(path, content),
34 Language::Java => java_parser::parse(path, content),
35 _ => Ok(Vec::new()),
36 }
37}
38
39pub fn parse_file_with_edges(path: &Path, content: &str, language: Language) -> Result<ParseResult> {
41 match language {
42 Language::Rust => rust_parser::parse_with_edges(path, content),
43 Language::Python => python_parser::parse_with_edges(path, content),
44 Language::Go => go_parser::parse_with_edges(path, content),
45 Language::TypeScript | Language::JavaScript => typescript_parser::parse_with_edges(path, content),
46 Language::Java => java_parser::parse_with_edges(path, content),
47 _ => Ok(ParseResult { nodes: Vec::new(), edges: Vec::new() }),
48 }
49}
50
51pub fn parse_auto(path: &Path, content: &str) -> Result<Vec<Node>> {
53 let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("");
54 let lang = Language::from_extension(ext);
55 parse_file(path, content, lang)
56}