Sha256: 73108977ccd135969c244c317ec91c424fc2f17d3046fa2365e81620f964fdbc

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      #
      # Contains additional diagnostic information about the context in which
      # a code action is run.
      #
      class CodeActionContext
        def initialize(diagnostics:, only: nil)
          @attributes = {}

          @attributes[:diagnostics] = diagnostics
          @attributes[:only] = only if only

          @attributes.freeze
        end

        #
        # An array of diagnostics known on the client side overlapping the range
        # provided to the `textDocument/codeAction` request. They are provided so
        # that the server knows which errors are currently presented to the user
        # for the given range. There is no guarantee that these accurately reflect
        # the error state of the resource. The primary parameter
        # to compute code actions is the provided range.
        #
        # @return [Diagnostic[]]
        def diagnostics
          attributes.fetch(:diagnostics)
        end

        #
        # Requested kind of actions to return.
        #
        # Actions not of this kind are filtered out by the client before being
        # shown. So servers can omit computing them.
        #
        # @return [string[]]
        def only
          attributes.fetch(:only)
        end

        attr_reader :attributes

        def to_hash
          attributes
        end

        def to_json(*args)
          to_hash.to_json(*args)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
language_server-protocol-3.16.0.3 lib/language_server/protocol/interface/code_action_context.rb
language_server-protocol-3.16.0.2 lib/language_server/protocol/interface/code_action_context.rb
language_server-protocol-3.16.0.1 lib/language_server/protocol/interface/code_action_context.rb
language_server-protocol-3.16.0.0 lib/language_server/protocol/interface/code_action_context.rb