Sha256: e3c45e10545543f33976ce9ab99d6622f1a10478a5b0b2dfecdfde5d6bf13983

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      #
      # Params to show a document.
      #
      class ShowDocumentParams
        def initialize(uri:, external: nil, take_focus: nil, selection: nil)
          @attributes = {}

          @attributes[:uri] = uri
          @attributes[:external] = external if external
          @attributes[:takeFocus] = take_focus if take_focus
          @attributes[:selection] = selection if selection

          @attributes.freeze
        end

        #
        # The document uri to show.
        #
        # @return [string]
        def uri
          attributes.fetch(:uri)
        end

        #
        # Indicates to show the resource in an external program.
        # To show for example `https://code.visualstudio.com/`
        # in the default WEB browser set `external` to `true`.
        #
        # @return [boolean]
        def external
          attributes.fetch(:external)
        end

        #
        # An optional property to indicate whether the editor
        # showing the document should take focus or not.
        # Clients might ignore this property if an external
        # program is started.
        #
        # @return [boolean]
        def take_focus
          attributes.fetch(:takeFocus)
        end

        #
        # An optional selection range if the document is a text
        # document. Clients might ignore the property if an
        # external program is started or the file is not a text
        # file.
        #
        # @return [Range]
        def selection
          attributes.fetch(:selection)
        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

6 entries across 6 versions & 1 rubygems

Version Path
language_server-protocol-3.17.0.2 lib/language_server/protocol/interface/show_document_params.rb
language_server-protocol-3.17.0.1 lib/language_server/protocol/interface/show_document_params.rb
language_server-protocol-3.16.0.3 lib/language_server/protocol/interface/show_document_params.rb
language_server-protocol-3.16.0.2 lib/language_server/protocol/interface/show_document_params.rb
language_server-protocol-3.16.0.1 lib/language_server/protocol/interface/show_document_params.rb
language_server-protocol-3.16.0.0 lib/language_server/protocol/interface/show_document_params.rb