Class: RubyLsp::ResponseBuilders::DocumentSymbol

Inherits:
ResponseBuilder show all
Defined in:
lib/ruby_lsp/response_builders/document_symbol.rb

Overview

: [ResponseType = Array]

Defined Under Namespace

Classes: SymbolHierarchyRoot

Instance Method Summary collapse

Constructor Details

#initializeDocumentSymbol

: -> void



19
20
21
22
# File 'lib/ruby_lsp/response_builders/document_symbol.rb', line 19

def initialize
  super
  @stack = [SymbolHierarchyRoot.new] #: Array[(SymbolHierarchyRoot | Interface::DocumentSymbol)]
end

Instance Method Details

#lastObject

: -> (SymbolHierarchyRoot | Interface::DocumentSymbol)



39
40
41
# File 'lib/ruby_lsp/response_builders/document_symbol.rb', line 39

def last
  @stack.last #: as !nil
end

#popObject

: -> Interface::DocumentSymbol?



32
33
34
35
36
# File 'lib/ruby_lsp/response_builders/document_symbol.rb', line 32

def pop
  if @stack.size > 1
    @stack.pop #: as Interface::DocumentSymbol
  end
end

#push(symbol) ⇒ Object Also known as: <<

: (Interface::DocumentSymbol symbol) -> void



25
26
27
# File 'lib/ruby_lsp/response_builders/document_symbol.rb', line 25

def push(symbol)
  @stack << symbol
end

#responseObject

: -> Array



45
46
47
48
# File 'lib/ruby_lsp/response_builders/document_symbol.rb', line 45

def response
  @stack.first #: as !nil
    .children
end