Enhance keep_tokens option for RubyVM::AbstractSyntaxTree parsing methods
Implementation for Language Server Protocol (LSP) sometimes needs token information.
For example both m(1) and m(1, ) has same AST structure other than node locations
then it's impossible to check the existence of , from AST. However in later case,
it might be better to suggest variables list for the second argument.
Token information is important for such case.
This commit adds these methods.
Add keep_tokens option for RubyVM::AbstractSyntaxTree.parse, .parse_file and .of
Add RubyVM::AbstractSyntaxTree::Node#tokens which returns tokens for the node including tokens for descendants nodes.
Add RubyVM::AbstractSyntaxTree::Node#all_tokens which returns all tokens for the input script regardless the receiver node.
Enhance keep_tokens option for RubyVM::AbstractSyntaxTree parsing methods
Implementation for Language Server Protocol (LSP) sometimes needs token information.
For example both
m(1)
andm(1, )
has same AST structure other than node locationsthen it's impossible to check the existence of
,
from AST. However in later case,it might be better to suggest variables list for the second argument.
Token information is important for such case.
This commit adds these methods.
keep_tokens
option forRubyVM::AbstractSyntaxTree.parse
,.parse_file
and.of
RubyVM::AbstractSyntaxTree::Node#tokens
which returns tokens for the node including tokens for descendants nodes.RubyVM::AbstractSyntaxTree::Node#all_tokens
which returns all tokens for the input script regardless the receiver node.[Feature #19070]
Impacts on memory usage and performance are below:
Memory usage:
Performance: