File: initialize_params.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 (128 lines) | stat: -rw-r--r-- 3,836 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
module LanguageServer
  module Protocol
    module Interface
      class InitializeParams
        def initialize(work_done_token: nil, process_id:, client_info: nil, locale: nil, root_path: nil, root_uri:, initialization_options: nil, capabilities:, trace: nil, workspace_folders: nil)
          @attributes = {}

          @attributes[:workDoneToken] = work_done_token if work_done_token
          @attributes[:processId] = process_id
          @attributes[:clientInfo] = client_info if client_info
          @attributes[:locale] = locale if locale
          @attributes[:rootPath] = root_path if root_path
          @attributes[:rootUri] = root_uri
          @attributes[:initializationOptions] = initialization_options if initialization_options
          @attributes[:capabilities] = capabilities
          @attributes[:trace] = trace if trace
          @attributes[:workspaceFolders] = workspace_folders if workspace_folders

          @attributes.freeze
        end

        #
        # An optional token that a server can use to report work done progress.
        #
        # @return [ProgressToken]
        def work_done_token
          attributes.fetch(:workDoneToken)
        end

        #
        # The process Id of the parent process that started the server. Is null if
        # the process has not been started by another process. If the parent
        # process is not alive then the server should exit (see exit notification)
        # its process.
        #
        # @return [number]
        def process_id
          attributes.fetch(:processId)
        end

        #
        # Information about the client
        #
        # @return [{ name: string; version?: string; }]
        def client_info
          attributes.fetch(:clientInfo)
        end

        #
        # The locale the client is currently showing the user interface
        # in. This must not necessarily be the locale of the operating
        # system.
        #
        # Uses IETF language tags as the value's syntax
        # (See https://en.wikipedia.org/wiki/IETF_language_tag)
        #
        # @return [string]
        def locale
          attributes.fetch(:locale)
        end

        #
        # The rootPath of the workspace. Is null
        # if no folder is open.
        #
        # @return [string]
        def root_path
          attributes.fetch(:rootPath)
        end

        #
        # The rootUri of the workspace. Is null if no
        # folder is open. If both `rootPath` and `rootUri` are set
        # `rootUri` wins.
        #
        # @return [string]
        def root_uri
          attributes.fetch(:rootUri)
        end

        #
        # User provided initialization options.
        #
        # @return [LSPAny]
        def initialization_options
          attributes.fetch(:initializationOptions)
        end

        #
        # The capabilities provided by the client (editor or tool)
        #
        # @return [ClientCapabilities]
        def capabilities
          attributes.fetch(:capabilities)
        end

        #
        # The initial trace setting. If omitted trace is disabled ('off').
        #
        # @return [TraceValue]
        def trace
          attributes.fetch(:trace)
        end

        #
        # The workspace folders configured in the client when the server starts.
        # This property is only available if the client supports workspace folders.
        # It can be `null` if the client supports workspace folders but none are
        # configured.
        #
        # @return [WorkspaceFolder[]]
        def workspace_folders
          attributes.fetch(:workspaceFolders)
        end

        attr_reader :attributes

        def to_hash
          attributes
        end

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