aravagarwal/CodeCloakPII
0
1# tree-sitter-java2 3This crate provides a Java grammar for the [tree-sitter][] parsing library. To4use this crate, add it to the `[dependencies]` section of your `Cargo.toml`5file. (Note that you will probably also need to depend on the6[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful7way.)8 9``` toml10[dependencies]11tree-sitter = "0.17"12tree-sitter-java = "0.16"13```14 15Typically, you will use the [language][language func] function to add this16grammar to a tree-sitter [Parser][], and then use the parser to parse some code:17 18``` rust19let code = r#"20 class Test {21 int double(int x) {22 return x * 2;23 }24 }25"#;26let mut parser = Parser::new();27parser.set_language(tree_sitter_java::language()).expect("Error loading Java grammar");28let parsed = parser.parse(code, None);29```30 31If you have any questions, please reach out to us in the [tree-sitter32discussions] page.33 34[Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html35[language func]: https://docs.rs/tree-sitter-java/*/tree_sitter_java/fn.language.html36[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html37[tree-sitter]: https://tree-sitter.github.io/38[tree-sitter crate]: https://crates.io/crates/tree-sitter39[tree-sitter discussions]: https://github.com/tree-sitter/tree-sitter/discussions40 