Class: PlatformosCheck::LanguageServer::CorrectionExecuteCommandProvider
- Inherits:
-
ExecuteCommandProvider
- Object
- ExecuteCommandProvider
- PlatformosCheck::LanguageServer::CorrectionExecuteCommandProvider
- Includes:
- URIHelper
- Defined in:
- lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb
Instance Attribute Summary collapse
-
#bridge ⇒ Object
readonly
Returns the value of attribute bridge.
-
#diagnostics_manager ⇒ Object
readonly
Returns the value of attribute diagnostics_manager.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
-
#execute(diagnostic_hashes) ⇒ Object
The arguments passed to this method are the ones forwarded from the selected CodeAction by the client.
-
#initialize(storage, bridge, diagnostics_manager) ⇒ CorrectionExecuteCommandProvider
constructor
A new instance of CorrectionExecuteCommandProvider.
Methods included from URIHelper
Methods inherited from ExecuteCommandProvider
all, command, #command, inherited
Constructor Details
#initialize(storage, bridge, diagnostics_manager) ⇒ CorrectionExecuteCommandProvider
Returns a new instance of CorrectionExecuteCommandProvider.
12 13 14 15 16 |
# File 'lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb', line 12 def initialize(storage, bridge, diagnostics_manager) @storage = storage @bridge = bridge @diagnostics_manager = diagnostics_manager end |
Instance Attribute Details
#bridge ⇒ Object (readonly)
Returns the value of attribute bridge.
10 11 12 |
# File 'lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb', line 10 def bridge @bridge end |
#diagnostics_manager ⇒ Object (readonly)
Returns the value of attribute diagnostics_manager.
10 11 12 |
# File 'lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb', line 10 def diagnostics_manager @diagnostics_manager end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
10 11 12 |
# File 'lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb', line 10 def storage @storage end |
Instance Method Details
#execute(diagnostic_hashes) ⇒ Object
The arguments passed to this method are the ones forwarded from the selected CodeAction by the client.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb', line 22 def execute(diagnostic_hashes) # attempt to apply the document changes workspace_edit = diagnostics_manager.workspace_edit(diagnostic_hashes) result = bridge.send_request('workspace/applyEdit', { label: 'PlatformOS Check correction', edit: workspace_edit }) # Bail if unable to apply changes return unless result[:applied] # Clean up internal representation of fixed diagnostics diagnostics_update = diagnostics_manager.delete_applied(diagnostic_hashes) # Send updated diagnostics to client diagnostics_update .map do |relative_path, diagnostics| bridge.send_notification('textDocument/publishDiagnostics', { uri: file_uri(storage.path(relative_path)), diagnostics: diagnostics.map(&:to_h) }) storage.path(relative_path) end end |