Sha256: b87d080432ee84d6c21c753334c29a421f33a168da7a2ae52bdbaf5a48517781
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
# typed: strict # frozen_string_literal: true module RubyLsp module Requests #  # # The [code actions](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction) # request informs the editor of RuboCop quick fixes that can be applied. These are accessible by hovering over a # specific diagnostic. # # # Example # # ```ruby # def say_hello # puts "Hello" # --> code action: quick fix indentation # end # ``` class CodeActions < BaseRequest extend T::Sig sig do params( uri: String, document: Document, range: T::Range[Integer], ).void end def initialize(uri, document, range) super(document) @uri = uri @range = range end sig { override.returns(T.all(T::Array[LanguageServer::Protocol::Interface::CodeAction], Object)) } def run diagnostics = @document.cache_fetch(:diagnostics) { Diagnostics.new(@uri, @document).run } corrections = diagnostics.select do |diagnostic| diagnostic.correctable? && T.cast(diagnostic, Support::RuboCopDiagnostic).in_range?(@range) end return [] if corrections.empty? T.cast(corrections, T::Array[Support::RuboCopDiagnostic]).map!(&:to_lsp_code_action) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-lsp-0.3.8 | lib/ruby_lsp/requests/code_actions.rb |