File: optional_versioned_text_document_identifier.rb

package info (click to toggle)
ruby-language-server-protocol 3.17.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,636 kB
  • sloc: ruby: 10,741; makefile: 4
file content (50 lines) | stat: -rw-r--r-- 1,340 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module LanguageServer
  module Protocol
    module Interface
      class OptionalVersionedTextDocumentIdentifier
        def initialize(uri:, version:)
          @attributes = {}

          @attributes[:uri] = uri
          @attributes[:version] = version

          @attributes.freeze
        end

        #
        # The text document's URI.
        #
        # @return [string]
        def uri
          attributes.fetch(:uri)
        end

        #
        # The version number of this document. If an optional versioned text document
        # identifier is sent from the server to the client and the file is not
        # open in the editor (the server has not received an open notification
        # before) the server can send `null` to indicate that the version is
        # known and the content on disk is the master (as specified with document
        # content ownership).
        #
        # The version number of a document will increase after each change,
        # including undo/redo. The number doesn't need to be consecutive.
        #
        # @return [number]
        def version
          attributes.fetch(:version)
        end

        attr_reader :attributes

        def to_hash
          attributes
        end

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