Sha256: e850d95e1b9a256f7cfe3892a3347430c9c702e82c052412ae8d12f435486be1

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 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.
        #
        # @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.14.0.2 lib/language_server/protocol/interface/code_action_context.rb
language_server-protocol-3.14.0.1 lib/language_server/protocol/interface/code_action_context.rb
language_server-protocol-3.14.0.0 lib/language_server/protocol/interface/code_action_context.rb
language_server-protocol-3.12.0.0 lib/language_server/protocol/interface/code_action_context.rb