Strongly-typed AST types for Java, auto-generated from
tree-sitter-java's node-types.json.
This crate is generated by treesitter-types and is
automatically kept up to date when a new version of the grammar crate is released.
These types have been tested by parsing the Spring Framework source code.
See the Tree-sitter project for more information about the underlying parser framework.
Example
use *;
// A minimal Java hello-world program.
let src = b"\
class Hello {
public static void main(String[] args) {
System.out.println(\"Hello, World!\");
}
}
";
// Parse the source with tree-sitter and convert into typed AST.
let mut parser = new;
parser.set_language.unwrap;
let tree = parser.parse.unwrap;
let program = from_node.unwrap;
// The program has one top-level child: the `Hello` class.
assert_eq!;
// Unwrap the class declaration.
let Statement = &program.children else ;
let Declaration = stmt.as_ref else ;
let ClassDeclaration = decl.as_ref else ;
assert_eq!;
assert!; // no `extends`
assert!; // no `implements`
// The class body contains one method.
assert_eq!;