Sha256: 3656b092a74e7ea1f4185f60604f4757ca97a6e862fde6bd0f851b909b4230e3

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      #
      # A code lens represents a command that should be shown along with
      # source text, like the number of references, a way to run tests, etc.
      #
      # A code lens is _unresolved_ when no command is associated to it. For performance
      # reasons the creation of a code lens and resolving should be done in two stages.
      #
      class CodeLens
        def initialize(range:, command: nil, data: nil)
          @attributes = {}

          @attributes[:range] = range
          @attributes[:command] = command if command
          @attributes[:data] = data if data

          @attributes.freeze
        end

        #
        # The range in which this code lens is valid. Should only span a single line.
        #
        # @return [Range]
        def range
          attributes.fetch(:range)
        end

        #
        # The command this code lens represents.
        #
        # @return [Command]
        def command
          attributes.fetch(:command)
        end

        #
        # A data entry field that is preserved on a code lens item between
        # a code lens and a code lens resolve request.
        #
        # @return [any]
        def data
          attributes.fetch(:data)
        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

9 entries across 9 versions & 1 rubygems

Version Path
language_server-protocol-3.15.0.2 lib/language_server/protocol/interface/code_lens.rb
language_server-protocol-3.15.0.1 lib/language_server/protocol/interface/code_lens.rb
language_server-protocol-3.15.0.0 lib/language_server/protocol/interface/code_lens.rb
language_server-protocol-3.14.0.2 lib/language_server/protocol/interface/code_lens.rb
language_server-protocol-3.14.0.1 lib/language_server/protocol/interface/code_lens.rb
language_server-protocol-3.14.0.0 lib/language_server/protocol/interface/code_lens.rb
language_server-protocol-3.12.0.0 lib/language_server/protocol/interface/code_lens.rb
language_server-protocol-3.7.0.0 lib/language_server/protocol/interface/code_lens.rb
language_server-protocol-0.5.0 lib/language_server/protocol/interface/code_lens.rb