Sha256: ba97b190fd9b430aa5aa7e7198e1842be161ca1829eba4ba3934d6896ca4576d
Contents?: true
Size: 1.32 KB
Versions: 15
Compression:
Stored size: 1.32 KB
Contents
# typed: strict # frozen_string_literal: true module RubyLsp module ResponseBuilders class DocumentSymbol < ResponseBuilder extend T::Sig ResponseType = type_member { { fixed: T::Array[Interface::DocumentSymbol] } } class SymbolHierarchyRoot extend T::Sig sig { returns(T::Array[Interface::DocumentSymbol]) } attr_reader :children sig { void } def initialize @children = T.let([], T::Array[Interface::DocumentSymbol]) end end sig { void } def initialize super @stack = T.let( [SymbolHierarchyRoot.new], T::Array[T.any(SymbolHierarchyRoot, Interface::DocumentSymbol)], ) end sig { params(symbol: Interface::DocumentSymbol).void } def push(symbol) @stack << symbol end alias_method(:<<, :push) sig { returns(T.nilable(Interface::DocumentSymbol)) } def pop if @stack.size > 1 T.cast(@stack.pop, Interface::DocumentSymbol) end end sig { returns(T.any(SymbolHierarchyRoot, Interface::DocumentSymbol)) } def last T.must(@stack.last) end sig { override.returns(T::Array[Interface::DocumentSymbol]) } def response T.must(@stack.first).children end end end end
Version data entries
15 entries across 15 versions & 1 rubygems