1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! # Extracting syntax information of program
//!
//! Implementation of the query supports Rust
//!
//! # Declaration
//!
//! Implementation of the language query in this project is based on [BrianHicks/tree-grepper](https://github.com/BrianHicks/tree-grepper).
//! We add classify option for `Invocation` and append cargo docs for source files.
//!
//! # Example
//!
//! ```
//! # fn main() -> anyhow::Result<()> {
//! use rust_hero::query::{Language,Extractor};
//! use tree_sitter::Parser;
//!
//! let lang = Language::Rust;
//! let query = lang
//! .parse_query("(function_item (identifier) @id) @function")
//! .unwrap();
//! let extractor = Extractor::new(lang, query);
//! let extracted = extractor
//! .extract_from_text(None, b"fn main(){println!(\"hello rust_hero\");}", &mut Parser::new())
//! // From Result<Option<ExtractedFile>>
//! .unwrap()
//! // From Option<ExtractedFile>
//! .unwrap();
//!
//! println!("{:?},{:?},{:?}",extracted.matches.len(),extracted.matches[0].name,extracted.matches[0].text);
//! assert_eq!(extracted.matches.len(), 2);
//! assert_eq!(extracted.matches[0].name, "function");
//! assert_eq!(extracted.matches[0].text, "fn main(){println!(\"hello rust_hero\");}");
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ExtractorChooser;
pub use Files;
pub use Language;