microsoft / microsoft/tolerant-php-parser
API should support getting next or previous tokens
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 894
- Forks
- 85
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 3
Description
A basic implementation of this would be adding a method Node::getDescendantTokenAtPosition (similar to Node::getDescendantNodeAtPosition), and because the tree is fully representative, we could simply $rootNode->getTokenAtPosition($token->getEnd()) or $rootNode->getTokenAtPosition($token->getFullStart()-1). Eventually, the method could be optimized further.
Edge cases:
- Zero-length error tokens (of type MissingToken) should not be returned by this method. All other tokens are uniquely addressable, as per our defined invariants.
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
Start with Node::getDescendantNodeAtPosition and the existing getTokenAtPosition behavior. Implement descendant-token lookup for the next and previous token positions, ensuring zero-length MissingToken error tokens are excluded. Done means all other tokens remain uniquely addressable under the stated tree invariants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100