Class: Spoom::LSP::SignatureHelp

Inherits:
Object
  • Object
show all
Includes:
PrintableSymbol
Defined in:
lib/spoom/sorbet/lsp/structures.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc:, params:, label: nil) ⇒ SignatureHelp

: (doc: Object, params: Array, ?label: String?) -> void



183
184
185
186
187
# File 'lib/spoom/sorbet/lsp/structures.rb', line 183

def initialize(doc:, params:, label: nil)
  @label = label
  @doc = doc
  @params = params
end

Instance Attribute Details

#doc ⇒ Object (readonly)

TODO : Object



176
177
178
# File 'lib/spoom/sorbet/lsp/structures.rb', line 176

def doc
  @doc
end

#label ⇒ Object (readonly)

: String?



172
173
174
# File 'lib/spoom/sorbet/lsp/structures.rb', line 172

def label
  @label
end

#params ⇒ Object (readonly)

TODO : Array



180
181
182
# File 'lib/spoom/sorbet/lsp/structures.rb', line 180

def params
  @params
end

Class Method Details

.from_json(json) ⇒ Object

: (Hash[untyped, untyped] json) -> SignatureHelp



191
192
193
194
195
196
197
# File 'lib/spoom/sorbet/lsp/structures.rb', line 191

def from_json(json)
  SignatureHelp.new(
    label: json["label"],
    doc: json["documentation"],
    params: json["parameters"],
  )
end

Instance Method Details

#accept_printer(printer) ⇒ Object

: (SymbolPrinter printer) -> void



202
203
204
205
206
207
# File 'lib/spoom/sorbet/lsp/structures.rb', line 202

def accept_printer(printer)
  printer.print(label)
  printer.print("(")
  printer.print(params.map { |l| "#{l["label"]}: #{l["documentation"]}" }.join(", "))
  printer.print(")")
end

#to_s ⇒ Object

: -> String



210
211
212
# File 'lib/spoom/sorbet/lsp/structures.rb', line 210

def to_s
  "#{label}(#{params})."
end