Class: LanguageServer::Protocol::Interface::SignatureInformation

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/signature_information.rb

Overview

Represents the signature of something callable. A signature can have a label, like a function-name, a doc-comment, and a set of parameters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, documentation: nil, parameters: nil, active_parameter: nil) ⇒ SignatureInformation

Returns a new instance of SignatureInformation.



10
11
12
13
14
15
16
17
18
19
# File 'lib/language_server/protocol/interface/signature_information.rb', line 10

def initialize(label:, documentation: nil, parameters: nil, active_parameter: nil)
  @attributes = {}

  @attributes[:label] = label
  @attributes[:documentation] = documentation if documentation
  @attributes[:parameters] = parameters if parameters
  @attributes[:activeParameter] = active_parameter if active_parameter

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



57
58
59
# File 'lib/language_server/protocol/interface/signature_information.rb', line 57

def attributes
  @attributes
end

Instance Method Details

#active_parameternumber

The index of the active parameter.

If provided, this is used in place of ‘SignatureHelp.activeParameter`.

Returns:

  • (number)


53
54
55
# File 'lib/language_server/protocol/interface/signature_information.rb', line 53

def active_parameter
  attributes.fetch(:activeParameter)
end

#documentationstring | MarkupContent

The human-readable doc-comment of this signature. Will be shown in the UI but can be omitted.

Returns:



35
36
37
# File 'lib/language_server/protocol/interface/signature_information.rb', line 35

def documentation
  attributes.fetch(:documentation)
end

#labelstring

The label of this signature. Will be shown in the UI.

Returns:

  • (string)


26
27
28
# File 'lib/language_server/protocol/interface/signature_information.rb', line 26

def label
  attributes.fetch(:label)
end

#parametersParameterInformation[]

The parameters of this signature.

Returns:



43
44
45
# File 'lib/language_server/protocol/interface/signature_information.rb', line 43

def parameters
  attributes.fetch(:parameters)
end

#to_hashObject



59
60
61
# File 'lib/language_server/protocol/interface/signature_information.rb', line 59

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



63
64
65
# File 'lib/language_server/protocol/interface/signature_information.rb', line 63

def to_json(*args)
  to_hash.to_json(*args)
end