tolerant-php-parser icon indicating copy to clipboard operation
tolerant-php-parser copied to clipboard

API should support getting next or previous tokens

Open mousetraps opened this issue 8 years ago • 0 comments
trafficstars

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.

mousetraps avatar Feb 07 '17 01:02 mousetraps