Class: LanguageServer::Protocol::Interface::CodeActionContext
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::CodeActionContext
- 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
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#diagnostics ⇒ Diagnostic[]
An array of diagnostics known on the client side overlapping the range provided to the ‘textDocument/codeAction` request.
-
#initialize(diagnostics:, only: nil) ⇒ CodeActionContext
constructor
A new instance of CodeActionContext.
-
#only ⇒ string[]
Requested kind of actions to return.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
42 43 44 |
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 42 def attributes @attributes end |
Instance Method Details
#diagnostics ⇒ Diagnostic[]
An array of diagnostics known on the client side overlapping the range provided to the ‘textDocument/codeAction` request. They are provided so that the server knows which errors are currently presented to the user for the given range. There is no guarantee that these accurately reflect the error state of the resource. The primary parameter to compute code actions is the provided range.
27 28 29 |
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 27 def diagnostics attributes.fetch(:diagnostics) end |
#only ⇒ string[]
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.
38 39 40 |
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 38 def only attributes.fetch(:only) end |
#to_hash ⇒ Object
44 45 46 |
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 44 def to_hash attributes end |
#to_json(*args) ⇒ Object
48 49 50 |
# File 'lib/language_server/protocol/interface/code_action_context.rb', line 48 def to_json(*args) to_hash.to_json(*args) end |