tree-sitter-java
tree-sitter-java copied to clipboard
`local_variable_declaration` and `ERROR` is generated when it encounters descriptors.
Problem description
Consider the following method:
@CheckReturnValue @Nonnull static public <E>String arrayToString(@Nonnull E[] v){
StringBuilder retval=new StringBuilder();
boolean first=true;
for ( E e : v) {
if (!first) {
retval.append(',');
}
first=false;
retval.append('[');
retval.append(e.toString());
retval.append(']');
}
return new String(retval);
}
Expected parse tree output (optional)
Parse code with output method_definition
Actual parse tree output (optional)
local_variable_declaration:@CheckReturnValue @Nonnull static public <E>Stringexpression_statement:arrayToString(@Nonnull E[] v){\n StringBuilder retval=new StringBuilder();
I think this just needs to be inside of a class declaration.
Thx! Putting it inside of a class declaration works. But it is quite confusing that why parser could handle statement StringBuilder retval = new StringBuilder() and whole class declaration but fails to parse a single method declaration.
Top level items are statement, of which expression_statement is a part of, but method_declaration is inside a class/interface body