class Spoom::LSP::DocumentSymbol
def self.from_json(json)
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
def accept_printer(printer)
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, Color::BLUE, Color::BOLD) printer.print_colored(' (', Color::LIGHT_BLACK) if range printer.print_object(range) elsif location printer.print_object(location) end printer.print_colored(')', Color::LIGHT_BLACK) printer.printn unless children.empty? printer.indent printer.print_objects(children) printer.dedent end # TODO: also display details? end
def kind_string
def kind_string return "<unknown:#{kind}>" unless SYMBOL_KINDS.key?(kind) SYMBOL_KINDS[kind] end
def to_s
def to_s "#{name} (#{range})" end