Sha256: 3386cf555b444b7754b7e30b2646e6246e81e0573250028fb689fc63c34f0a8e

Contents?: true

Size: 1.96 KB

Versions: 4

Compression:

Stored size: 1.96 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      class LocationLink
        def initialize(origin_selection_range: nil, target_uri:, target_range:, target_selection_range:)
          @attributes = {}

          @attributes[:originSelectionRange] = origin_selection_range if origin_selection_range
          @attributes[:targetUri] = target_uri
          @attributes[:targetRange] = target_range
          @attributes[:targetSelectionRange] = target_selection_range

          @attributes.freeze
        end

        #
        # Span of the origin of this link.
        #
        # Used as the underlined span for mouse interaction. Defaults to the word
        # range at the mouse position.
        #
        # @return [Range]
        def origin_selection_range
          attributes.fetch(:originSelectionRange)
        end

        #
        # The target resource identifier of this link.
        #
        # @return [string]
        def target_uri
          attributes.fetch(:targetUri)
        end

        #
        # The full target range of this link. If the target for example is a symbol
        # then target range is the range enclosing this symbol not including
        # leading/trailing whitespace but everything else like comments. This
        # information is typically used to highlight the range in the editor.
        #
        # @return [Range]
        def target_range
          attributes.fetch(:targetRange)
        end

        #
        # The range that should be selected and revealed when this link is being
        # followed, e.g the name of a function. Must be contained by the the
        # `targetRange`. See also `DocumentSymbol#range`
        #
        # @return [Range]
        def target_selection_range
          attributes.fetch(:targetSelectionRange)
        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/location_link.rb
language_server-protocol-3.16.0.2 lib/language_server/protocol/interface/location_link.rb
language_server-protocol-3.16.0.1 lib/language_server/protocol/interface/location_link.rb
language_server-protocol-3.16.0.0 lib/language_server/protocol/interface/location_link.rb