Sha256: 48632fe5b102768c9ac7764a60cb2c4adb80de7becf3d5c1341326a0123a2be7
Contents?: true
Size: 1.32 KB
Versions: 40
Compression:
Stored size: 1.32 KB
Contents
# typed: strict # frozen_string_literal: true module RubyLsp module ResponseBuilders class DocumentSymbol < ResponseBuilder 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 extend T::Sig 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
40 entries across 40 versions & 1 rubygems