Class: LanguageServer::Protocol::Interface::CodeActionContext

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

Overview

Contains additional diagnostic information about the context in which a code action is run.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diagnostics:, only: nil) ⇒ CodeActionContext

Returns a new instance of CodeActionContext.



9
10
11
12
13
14
15
16
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 9

def initialize(diagnostics:, only: nil)
  @attributes = {}

  @attributes[:diagnostics] = diagnostics
  @attributes[:only] = only if only

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



37
38
39
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 37

def attributes
  @attributes
end

Instance Method Details

#diagnosticsDiagnostic[]

An array of diagnostics.

Returns:



22
23
24
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 22

def diagnostics
  attributes.fetch(:diagnostics)
end

#onlystring[]

Requested kind of actions to return.

Actions not of this kind are filtered out by the client before being shown. So servers can omit computing them.

Returns:

  • (string[])


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

def only
  attributes.fetch(:only)
end

#to_hashObject



39
40
41
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 39

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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