Class: LanguageServer::Protocol::Interface::CodeAction
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::CodeAction
- Defined in:
- lib/language_server/protocol/interface/code_action.rb
Overview
A code action represents a change that can be performed in code, e.g. to fix a problem or to refactor code.
A CodeAction must set either ‘edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#command ⇒ Command
A command this code action executes.
-
#diagnostics ⇒ Diagnostic[]
The diagnostics that this code action resolves.
-
#edit ⇒ WorkspaceEdit
The workspace edit this code action performs.
-
#initialize(title:, kind: nil, diagnostics: nil, edit: nil, command: nil) ⇒ CodeAction
constructor
A new instance of CodeAction.
-
#kind ⇒ string
The kind of the code action.
-
#title ⇒ string
A short, human-readable, title for this code action.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(title:, kind: nil, diagnostics: nil, edit: nil, command: nil) ⇒ CodeAction
Returns a new instance of CodeAction.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 11 def initialize(title:, kind: nil, diagnostics: nil, edit: nil, command: nil) @attributes = {} @attributes[:title] = title @attributes[:kind] = kind if kind @attributes[:diagnostics] = diagnostics if diagnostics @attributes[:edit] = edit if edit @attributes[:command] = command if command @attributes.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
67 68 69 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 67 def attributes @attributes end |
Instance Method Details
#command ⇒ Command
A command this code action executes. If a code action provides an edit and a command, first the edit is executed and then the command.
63 64 65 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 63 def command attributes.fetch(:command) end |
#diagnostics ⇒ Diagnostic[]
The diagnostics that this code action resolves.
45 46 47 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 45 def diagnostics attributes.fetch(:diagnostics) end |
#edit ⇒ WorkspaceEdit
The workspace edit this code action performs.
53 54 55 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 53 def edit attributes.fetch(:edit) end |
#kind ⇒ string
The kind of the code action.
Used to filter code actions.
37 38 39 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 37 def kind attributes.fetch(:kind) end |
#title ⇒ string
A short, human-readable, title for this code action.
27 28 29 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 27 def title attributes.fetch(:title) end |
#to_hash ⇒ Object
69 70 71 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 69 def to_hash attributes end |
#to_json(*args) ⇒ Object
73 74 75 |
# File 'lib/language_server/protocol/interface/code_action.rb', line 73 def to_json(*args) to_hash.to_json(*args) end |