Class: PlatformosCheck::LanguageServer::SourceFixAllCodeActionProvider

Inherits:
CodeActionProvider
  • Object
show all
Defined in:
lib/platformos_check/language_server/code_action_providers/source_fix_all_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, _) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/platformos_check/language_server/code_action_providers/source_fix_all_code_action_provider.rb', line 8

def code_actions(relative_path, _)
  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
                .map(&:to_h)
  diagnostics_to_code_action(diagnostics)
end