Error recovery from use nodes
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 17.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides PHP examples for incomplete use and group-use statements but does not name files, tests, or a preferred AST result. Start by locating the parser entry point for use statements and existing error-recovery tests, then establish the intended node representation for each example before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100