Class: RubyLsp::Requests::ShowSyntaxTree
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/requests/show_syntax_tree.rb
Overview

Show syntax tree is a custom LSP request that displays the AST for the current document or for the current selection in a new tab.
Example
# Executing the Ruby LSP: Show syntax tree command will display the AST for the document
1 + 1
# (program (statements ((binary (int "1") + (int "1")))))
Instance Method Summary collapse
-
#initialize(document, range) ⇒ ShowSyntaxTree
constructor
A new instance of ShowSyntaxTree.
- #perform ⇒ Object
Constructor Details
#initialize(document, range) ⇒ ShowSyntaxTree
Returns a new instance of ShowSyntaxTree.
24 25 26 27 28 29 |
# File 'lib/ruby_lsp/requests/show_syntax_tree.rb', line 24 def initialize(document, range) super() @document = document @range = range @tree = T.let(document.parse_result.value, Prism::ProgramNode) end |
Instance Method Details
#perform ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/ruby_lsp/requests/show_syntax_tree.rb', line 32 def perform return ast_for_range if @range output_string = +"" PP.pp(@tree, output_string) output_string end |