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.


276
277
278
279
280
281
282
283
# File 'lib/spoom/sorbet/lsp/structures.rb', line 276

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

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix.


266
267
268
# File 'lib/spoom/sorbet/lsp/structures.rb', line 266

def prefix
  @prefix
end

#seenObject

Returns the value of attribute seen.


266
267
268
# File 'lib/spoom/sorbet/lsp/structures.rb', line 266

def seen
  @seen
end

Instance Method Details

#clean_uri(uri) ⇒ Object


297
298
299
300
# File 'lib/spoom/sorbet/lsp/structures.rb', line 297

def clean_uri(uri)
  return uri unless prefix
  uri.delete_prefix(prefix)
end

303
304
305
306
307
308
309
310
# File 'lib/spoom/sorbet/lsp/structures.rb', line 303

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

286
287
288
289
# File 'lib/spoom/sorbet/lsp/structures.rb', line 286

def print_object(object)
  return unless object
  object.accept_printer(self)
end

292
293
294
# File 'lib/spoom/sorbet/lsp/structures.rb', line 292

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