class Spoom::LSP::DocumentSymbol

Constants

SYMBOL_KINDS

Public Class Methods

from_json(json) click to toggle source
# File lib/spoom/sorbet/lsp/structures.rb, line 186
def self.from_json(json)
  DocumentSymbol.new(
    name: json['name'],
    detail: json['detail'],
    kind: json['kind'],
    location: json['location'] ? Location.from_json(json['location']) : nil,
    range: json['range'] ? Range.from_json(json['range']) : nil,
    children: json['children'] ? json['children'].map { |symbol| DocumentSymbol.from_json(symbol) } : [],
  )
end

Public Instance Methods

accept_printer(printer) click to toggle source
# File lib/spoom/sorbet/lsp/structures.rb, line 198
def accept_printer(printer)
  h = serialize.hash
  return if printer.seen.include?(h)
  printer.seen.add(h)

  printer.printt
  printer.print(kind_string)
  printer.print(' ')
  printer.print_colored(name, :blue, :bold)
  printer.print_colored(' (', :light_black)
  if range
    printer.print_object(range)
  elsif location
    printer.print_object(location)
  end
  printer.print_colored(')', :light_black)
  printer.printn
  unless children.empty?
    printer.indent
    printer.print_objects(children)
    printer.dedent
  end
  # TODO: also display details?
end
kind_string() click to toggle source
# File lib/spoom/sorbet/lsp/structures.rb, line 227
def kind_string
  return "<unknown:#{kind}>" unless SYMBOL_KINDS.key?(kind)
  SYMBOL_KINDS[kind]
end
to_s() click to toggle source
# File lib/spoom/sorbet/lsp/structures.rb, line 223
def to_s
  "#{name} (#{range})"
end