Class: RubyLsp::Requests::ShowSyntaxTree
- Defined in:
- lib/ruby_lsp/requests/show_syntax_tree.rb
Overview
Show syntax tree is a custom [LSP request](microsoft.github.io/language-server-protocol/specification#requestMessage) that displays the AST for the current document or for the current selection in a new tab.
Instance Method Summary collapse
-
#initialize(document, range) ⇒ ShowSyntaxTree
constructor
: (RubyDocument document, Hash[Symbol, untyped]? range) -> void.
-
#perform ⇒ Object
: -> String.
Constructor Details
#initialize(document, range) ⇒ ShowSyntaxTree
: (RubyDocument document, Hash[Symbol, untyped]? range) -> void
11 12 13 14 15 16 |
# File 'lib/ruby_lsp/requests/show_syntax_tree.rb', line 11 def initialize(document, range) super() @document = document @range = range @tree = document.ast #: Prism::ProgramNode end |
Instance Method Details
#perform ⇒ Object
: -> String
20 21 22 23 24 25 26 |
# File 'lib/ruby_lsp/requests/show_syntax_tree.rb', line 20 def perform return ast_for_range if @range output_string = +"" PP.pp(@tree, output_string) output_string end |