Class: Spoom::LSP::DocumentSymbol
- Inherits:
-
T::Struct
- Object
- T::Struct
- Spoom::LSP::DocumentSymbol
- Extended by:
- T::Sig
- Includes:
- PrintableSymbol
- Defined in:
- lib/spoom/sorbet/lsp/structures.rb
Constant Summary collapse
- SYMBOL_KINDS =
{ 1 => "file", 2 => "module", 3 => "namespace", 4 => "package", 5 => "class", 6 => "def", 7 => "property", 8 => "field", 9 => "constructor", 10 => "enum", 11 => "interface", 12 => "function", 13 => "variable", 14 => "const", 15 => "string", 16 => "number", 17 => "boolean", 18 => "array", 19 => "object", 20 => "key", 21 => "null", 22 => "enum_member", 23 => "struct", 24 => "event", 25 => "operator", 26 => "type_parameter", }
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_json(json) ⇒ Object
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 187 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 |
Instance Method Details
#accept_printer(printer) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 199 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 |
#kind_string ⇒ Object
228 229 230 231 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 228 def kind_string return "<unknown:#{kind}>" unless SYMBOL_KINDS.key?(kind) SYMBOL_KINDS[kind] end |
#to_s ⇒ Object
224 225 226 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 224 def to_s "#{name} (#{range})" end |