2 unstable releases

0.19.0 Mar 9, 2021
0.16.0 Oct 27, 2020

#82 in Parser tooling

Download history 3/week @ 2020-12-31 75/week @ 2021-01-07 97/week @ 2021-01-14 4/week @ 2021-01-21 300/week @ 2021-02-04 119/week @ 2021-02-11 187/week @ 2021-02-18 268/week @ 2021-02-25 1043/week @ 2021-03-04 346/week @ 2021-03-11 303/week @ 2021-03-18 558/week @ 2021-03-25 10/week @ 2021-04-01 307/week @ 2021-04-08

554 downloads per month
Used in 3 crates (via rust-code-analysis)

MIT license

1.5MB
45K SLoC

C 44K SLoC JavaScript 1K SLoC // 0.0% comments Scheme 116 SLoC // 0.0% comments Rust 33 SLoC // 0.1% comments

tree-sitter-java

This crate provides a Java grammar for the tree-sitter parsing library. To use this crate, add it to the [dependencies] section of your Cargo.toml file. (Note that you will probably also need to depend on the tree-sitter crate to use the parsed result in any useful way.)

[dependencies]
tree-sitter = "0.17"
tree-sitter-java = "0.16"

Typically, you will use the language function to add this grammar to a tree-sitter Parser, and then use the parser to parse some code:

let code = r#"
    class Test {
        int double(int x) {
            return x * 2;
        }
    }
"#;
let mut parser = Parser::new();
parser.set_language(tree_sitter_java::language()).expect("Error loading Java grammar");
let parsed = parser.parse(code, None);

If you have any questions, please reach out to us in the tree-sitter discussions page.

Dependencies

~1.5–2MB
~53K SLoC