Class: RubyLsp::ResponseBuilders::DocumentSymbol

Inherits:
ResponseBuilder show all
Extended by:
T::Sig
Defined in:
lib/ruby_lsp/response_builders/document_symbol.rb

Defined Under Namespace

Classes: SymbolHierarchyRoot

Constant Summary collapse

ResponseType =
type_member { { fixed: T::Array[Interface::DocumentSymbol] } }

Instance Method Summary collapse

Constructor Details

#initializeDocumentSymbol

Returns a new instance of DocumentSymbol.



24
25
26
27
28
29
30
# File 'lib/ruby_lsp/response_builders/document_symbol.rb', line 24

def initialize
  super
  @stack = T.let(
    [SymbolHierarchyRoot.new],
    T::Array[T.any(SymbolHierarchyRoot, Interface::DocumentSymbol)],
  )
end

Instance Method Details

#lastObject



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

def last
  T.must(@stack.last)
end

#popObject



40
41
42
43
44
# File 'lib/ruby_lsp/response_builders/document_symbol.rb', line 40

def pop
  if @stack.size > 1
    T.cast(@stack.pop, Interface::DocumentSymbol)
  end
end

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



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

def push(symbol)
  @stack << symbol
end

#responseObject



52
53
54
# File 'lib/ruby_lsp/response_builders/document_symbol.rb', line 52

def response
  T.must(@stack.first).children
end