Class: Spoom::LSP::SymbolPrinter

Inherits:
Printer
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/spoom/sorbet/lsp/structures.rb

Instance Attribute Summary collapse

Attributes inherited from Printer

#out

Instance Method Summary collapse

Methods inherited from Printer

#colorize, #dedent, #indent, #print, #print_colored, #printl, #printn, #printt

Methods included from Colorize

#set_color

Constructor Details

#initialize(out: $stdout, colors: true, indent_level: 0, prefix: nil) ⇒ SymbolPrinter

Returns a new instance of SymbolPrinter.



326
327
328
329
330
331
332
333
# File 'lib/spoom/sorbet/lsp/structures.rb', line 326

def initialize(out: $stdout, colors: true, indent_level: 0, prefix: nil)
  super(out: out, colors: colors, indent_level: indent_level)
  @seen = T.let(Set.new, T::Set[Integer])
  @out = out
  @colors = colors
  @indent_level = indent_level
  @prefix = prefix
end

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix.



316
317
318
# File 'lib/spoom/sorbet/lsp/structures.rb', line 316

def prefix
  @prefix
end

#seenObject (readonly)

Returns the value of attribute seen.



313
314
315
# File 'lib/spoom/sorbet/lsp/structures.rb', line 313

def seen
  @seen
end

Instance Method Details

#clean_uri(uri) ⇒ Object



348
349
350
351
352
353
# File 'lib/spoom/sorbet/lsp/structures.rb', line 348

def clean_uri(uri)
  prefix = self.prefix
  return uri unless prefix

  uri.delete_prefix(prefix)
end


356
357
358
359
360
361
362
363
# File 'lib/spoom/sorbet/lsp/structures.rb', line 356

def print_list(objects)
  objects.each do |object|
    printt
    print("* ")
    print_object(object)
    printn
  end
end


336
337
338
339
340
# File 'lib/spoom/sorbet/lsp/structures.rb', line 336

def print_object(object)
  return unless object

  object.accept_printer(self)
end


343
344
345
# File 'lib/spoom/sorbet/lsp/structures.rb', line 343

def print_objects(objects)
  objects.each { |object| print_object(object) }
end