Expand description
This crate provides Java language support for the tree-sitter parsing library.
The parser is generated for ABI 16, so it loads only with the willbooster-tree-sitter runtime (depend on it as
tree-sitter = { package = "willbooster-tree-sitter", version = "1.4.3" }); upstream’s tree-sitter crate rejects
it with a LanguageError.
Typically, you will use the LANGUAGE constant to add this language to a
tree-sitter Parser, and then use the parser to parse some code:
let code = "class Main {\n int answer() {\n return 42;\n }\n}\n";
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_java::LANGUAGE;
parser
.set_language(&language.into())
.expect("Error loading Java parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());Constants§
- LANGUAGE
- The tree-sitter
LanguageFnfor this grammar. - NODE_
TYPES - The content of the
node-types.jsonfile for this grammar.