Class: LanguageServer::Protocol::Interface::Command

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

Overview

Represents a reference to a command. Provides a title which will be used to represent a command in the UI and, optionally, an array of arguments which will be passed to the command handler function when invoked.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, command:, arguments: nil) ⇒ Command

Returns a new instance of Command.



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

def initialize(title:, command:, arguments: nil)
  @attributes = {}

  @attributes[:title] = title
  @attributes[:command] = command
  @attributes[:arguments] = arguments if arguments

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



46
47
48
# File 'lib/language_server/protocol/interface/command.rb', line 46

def attributes
  @attributes
end

Instance Method Details

#argumentsLSPAny[] | nil

Arguments that the command handler should be invoked with.

Returns:

  • (LSPAny[] | nil)


42
43
44
# File 'lib/language_server/protocol/interface/command.rb', line 42

def arguments
  attributes.fetch(:arguments)
end

#commandstring

The identifier of the actual command handler.

Returns:

  • (string)


33
34
35
# File 'lib/language_server/protocol/interface/command.rb', line 33

def command
  attributes.fetch(:command)
end

#titlestring

Title of the command, like save.

Returns:

  • (string)


25
26
27
# File 'lib/language_server/protocol/interface/command.rb', line 25

def title
  attributes.fetch(:title)
end

#to_hashObject



48
49
50
# File 'lib/language_server/protocol/interface/command.rb', line 48

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



52
53
54
# File 'lib/language_server/protocol/interface/command.rb', line 52

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