Class: PlatformosCheck::LanguageServer::QuickfixCodeActionProvider
- Inherits:
-
CodeActionProvider
- Object
- CodeActionProvider
- PlatformosCheck::LanguageServer::QuickfixCodeActionProvider
- Defined in:
- lib/platformos_check/language_server/code_action_providers/quickfix_code_action_provider.rb
Instance Attribute Summary
Attributes inherited from CodeActionProvider
#diagnostics_manager, #storage
Instance Method Summary collapse
Methods inherited from CodeActionProvider
all, #base_kind, inherited, #initialize, kind, #kind
Constructor Details
This class inherits a constructor from PlatformosCheck::LanguageServer::CodeActionProvider
Instance Method Details
#code_actions(relative_path, range) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/platformos_check/language_server/code_action_providers/quickfix_code_action_provider.rb', line 8 def code_actions(relative_path, range) correctable_diagnostics = diagnostics_manager .diagnostics(relative_path) .filter(&:correctable?) .reject do |diagnostic| # We cannot quickfix if the buffer was modified. This means # our diagnostics and InMemoryStorage are out of sync. diagnostic.file_version != storage.version(diagnostic.relative_path) end diagnostics_under_cursor = correctable_diagnostics .filter { |diagnostic| diagnostic.offense.in_range?(range) } return [] if diagnostics_under_cursor.empty? ( quickfix_cursor_code_actions(diagnostics_under_cursor) + quickfix_all_of_type_code_actions(diagnostics_under_cursor, correctable_diagnostics) + quickfix_all_code_action(correctable_diagnostics) ) end |