Error recovery from use nodes
use
use What
use Whatever\
use Whatever\{} // cursor inside the braces
use Whatever\{Hello, } // cursor after the comma
Currently all result in
Syntax error, unexpected EOF, expecting ',' or ';' on line 4
==> Node dump:
array(
)
- Could be a
Usenode with an emptyusesarray - Could be a
Usenode with aUseUseforWhat - Could be a
Usenode with aUseUsewith aNamewhere the last element ofpartsis an empty string, so thattoString()returnsWhatever\ - Could be a
GroupUsenode with an emptyusesarray - Could be a
GroupUsenode with aUseUseforHelloand anErrornode
I wanted to say thank you for adding all the other improvements so quickly! Being able to work with the parser nodes even in currently-edited documents is extremely powerful and I now have IDE-like completion for the common use cases (variables, keywords, methods, properties, classes, static class properties / methods / constants). That would have been so much harder with just tokenization.
The second case is handled as part of https://github.com/nikic/PHP-Parser/commit/62877b5d14e4d2e4b213a9cdb25413b72bb6505a. The fifth case is handled with https://github.com/nikic/PHP-Parser/commit/a8eb2fc67516a641f4699af2e92b1260af10ce10 (as well as any other uses of invalid trailing commas). I did not include an Error node, in part because this particular case is actually going to be valid syntax in PHP 7.2.