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

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

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.

Parameters:

  • title: (String)
  • command: (String)
  • arguments: (Array[untyped]) (defaults to: nil)


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

#attributesHash[Symbol, untyped] (readonly)

Returns the value of attribute attributes.

Returns:

  • (Hash[Symbol, untyped])


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

def attributes
  @attributes
end

Instance Method Details

#argumentsLSPAny[]

Arguments that the command handler should be invoked with.

Returns:

  • (LSPAny[])


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_hashHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


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

def to_hash
  attributes
end

#to_json(*args) ⇒ String

Parameters:

  • (Object)

Returns:

  • (String)


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

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