sadr 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +67 -1
- data/lib/sadr/client.rb +994 -175
- data/lib/sadr/future.rb +1 -1
- data/lib/sadr/protocol.rb +135 -11
- data/lib/sadr/testing/fake_client.rb +20 -0
- data/lib/sadr/testing/fake_server.rb +173 -0
- data/lib/sadr/testing/fake_transport.rb +108 -0
- data/lib/sadr/testing.rb +6 -0
- data/lib/sadr/transport.rb +67 -21
- data/lib/sadr/version.rb +1 -1
- data/lib/sadr.rb +27 -3
- data/sig/sadr.rbs +65 -9
- metadata +6 -2
data/lib/sadr/version.rb
CHANGED
data/lib/sadr.rb
CHANGED
|
@@ -27,11 +27,35 @@ module Sadr
|
|
|
27
27
|
def define(*members)
|
|
28
28
|
return Data.define(*members) if defined?(Data)
|
|
29
29
|
|
|
30
|
-
Struct.new(*members
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
Struct.new(*members) do
|
|
31
|
+
members.each { |member| undef_method("#{member}=") }
|
|
32
|
+
|
|
33
|
+
def initialize(*values, **keywords)
|
|
34
|
+
if keywords.empty?
|
|
35
|
+
raise ArgumentError, "wrong number of arguments" unless values.length == self.class.members.length
|
|
36
|
+
|
|
37
|
+
super(*values)
|
|
38
|
+
else
|
|
39
|
+
raise ArgumentError, "cannot mix positional and keyword arguments" unless values.empty?
|
|
40
|
+
|
|
41
|
+
missing = self.class.members - keywords.keys
|
|
42
|
+
unknown = keywords.keys - self.class.members
|
|
43
|
+
raise ArgumentError, "missing keyword: #{missing.first.inspect}" unless missing.empty?
|
|
44
|
+
raise ArgumentError, "unknown keyword: #{unknown.first.inspect}" unless unknown.empty?
|
|
45
|
+
|
|
46
|
+
super(*self.class.members.map { |member| keywords.fetch(member) })
|
|
47
|
+
end
|
|
33
48
|
freeze
|
|
34
49
|
end
|
|
50
|
+
|
|
51
|
+
def with(**changes)
|
|
52
|
+
return self if changes.empty?
|
|
53
|
+
|
|
54
|
+
unknown = changes.keys - self.class.members
|
|
55
|
+
raise ArgumentError, "unknown keyword: #{unknown.first.inspect}" unless unknown.empty?
|
|
56
|
+
|
|
57
|
+
self.class.new(**to_h.merge(changes))
|
|
58
|
+
end
|
|
35
59
|
end
|
|
36
60
|
end
|
|
37
61
|
end
|
data/sig/sadr.rbs
CHANGED
|
@@ -35,19 +35,25 @@ module Sadr
|
|
|
35
35
|
class Position
|
|
36
36
|
attr_reader line: Integer
|
|
37
37
|
attr_reader character: Integer
|
|
38
|
-
def self.new: (line
|
|
38
|
+
def self.new: (Integer line, Integer character) -> Position
|
|
39
|
+
| (line: Integer, character: Integer) -> Position
|
|
40
|
+
def with: (?line: Integer, ?character: Integer) -> Position
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
class Range_
|
|
42
44
|
attr_reader start: Position
|
|
43
45
|
attr_reader end: Position
|
|
44
|
-
def self.new: (start
|
|
46
|
+
def self.new: (Position start, Position end) -> Range_
|
|
47
|
+
| (start: Position, end: Position) -> Range_
|
|
48
|
+
def with: (?start: Position, ?end: Position) -> Range_
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
class ContentChange
|
|
48
52
|
attr_reader range: Range_?
|
|
49
53
|
attr_reader text: String
|
|
50
|
-
def self.new: (range
|
|
54
|
+
def self.new: (Range_? range, String text) -> ContentChange
|
|
55
|
+
| (range: Range_?, text: String) -> ContentChange
|
|
56
|
+
def with: (?range: Range_?, ?text: String) -> ContentChange
|
|
51
57
|
end
|
|
52
58
|
|
|
53
59
|
class Document
|
|
@@ -55,7 +61,9 @@ module Sadr
|
|
|
55
61
|
attr_reader language_id: String
|
|
56
62
|
attr_reader version: Integer
|
|
57
63
|
attr_reader text: String
|
|
58
|
-
def self.new: (uri
|
|
64
|
+
def self.new: (String uri, String language_id, Integer version, String text) -> Document
|
|
65
|
+
| (uri: String, language_id: String, version: Integer, text: String) -> Document
|
|
66
|
+
def with: (?uri: String, ?language_id: String, ?version: Integer, ?text: String) -> Document
|
|
59
67
|
end
|
|
60
68
|
|
|
61
69
|
class Token
|
|
@@ -64,7 +72,9 @@ module Sadr
|
|
|
64
72
|
attr_reader length: Integer
|
|
65
73
|
attr_reader type: Integer
|
|
66
74
|
attr_reader modifiers: Integer
|
|
67
|
-
def self.new: (line
|
|
75
|
+
def self.new: (Integer line, Integer character, Integer length, Integer type, Integer modifiers) -> Token
|
|
76
|
+
| (line: Integer, character: Integer, length: Integer, type: Integer, modifiers: Integer) -> Token
|
|
77
|
+
def with: (?line: Integer, ?character: Integer, ?length: Integer, ?type: Integer, ?modifiers: Integer) -> Token
|
|
68
78
|
end
|
|
69
79
|
|
|
70
80
|
module Protocol
|
|
@@ -77,6 +87,7 @@ module Sadr
|
|
|
77
87
|
def self.semantic_tokens: (Array[Integer] data, ?legend: Hash[String, Array[String]]?) -> Array[Token]
|
|
78
88
|
def self.semantic_delta: (Array[Integer] data, Array[Hash[String, json]] edits) -> Array[Integer]
|
|
79
89
|
def self.diagnostics: (Array[object] values) -> Array[object]
|
|
90
|
+
def self.workspace_edit: (object value) -> object
|
|
80
91
|
end
|
|
81
92
|
|
|
82
93
|
class Future
|
|
@@ -100,10 +111,11 @@ module Sadr
|
|
|
100
111
|
MAX_MESSAGE: Integer
|
|
101
112
|
attr_reader stderr_lines: Array[String]
|
|
102
113
|
attr_reader pid: Integer
|
|
103
|
-
def initialize: (Array[String] command, ?cwd: String?, ?env: Hash[String, String?]) { (Hash[String, json]?, Exception?) -> untyped } -> void
|
|
114
|
+
def initialize: (Array[String] command, ?cwd: String?, ?env: Hash[String, String?], ?on_spawn: ^(Transport) -> untyped) { (Hash[String, json]?, Exception?) -> untyped } -> void
|
|
104
115
|
def self.read_message: (IO | StringIO io) -> Hash[String, json]?
|
|
105
116
|
def self.validate_message: (untyped message) -> Hash[String, json]
|
|
106
117
|
def write: (object message) -> untyped
|
|
118
|
+
def try_write: (object message) -> bool
|
|
107
119
|
def alive?: () -> bool
|
|
108
120
|
def close: () -> untyped
|
|
109
121
|
end
|
|
@@ -112,12 +124,12 @@ module Sadr
|
|
|
112
124
|
attr_reader capabilities: Hash[String, json]
|
|
113
125
|
attr_reader transport: Transport?
|
|
114
126
|
attr_reader diagnostics: Hash[String, Array[object]]
|
|
115
|
-
attr_reader state: :stopped | :starting | :running | :failed
|
|
127
|
+
attr_reader state: :stopped | :starting | :restarting | :running | :failed
|
|
116
128
|
attr_reader errors: Array[Error]
|
|
117
129
|
attr_reader server_info: Hash[String, json]?
|
|
118
130
|
attr_reader position_encoding: String?
|
|
119
|
-
def initialize: (command: Array[String], ?root: String, ?dispatch: ^() { () -> untyped } -> untyped, ?restart: bool, ?env: Hash[String, String?], ?initialization_options: json, ?configuration:
|
|
120
|
-
def start: (?timeout: Numeric) ->
|
|
131
|
+
def initialize: (command: Array[String], ?root: String, ?dispatch: ^() { () -> untyped } -> untyped, ?restart: bool, ?env: Hash[String, String?], ?initialization_options: json, ?configuration: json) -> void
|
|
132
|
+
def start: (?timeout: Numeric) -> Hash[String, json]
|
|
121
133
|
def stop: () -> untyped
|
|
122
134
|
def running?: () -> bool
|
|
123
135
|
def supports?: (String | Symbol capability) -> bool
|
|
@@ -136,17 +148,61 @@ module Sadr
|
|
|
136
148
|
def references: (String uri, Position position, ?include_declaration: bool) -> Future
|
|
137
149
|
def signature_help: (String uri, Position position, **json params) -> Future
|
|
138
150
|
def rename: (String uri, Position position, String new_name) -> Future
|
|
151
|
+
def prepare_rename: (String uri, Position position, **json params) -> Future
|
|
152
|
+
def document_highlight: (String uri, Position position, **json params) -> Future
|
|
153
|
+
def prepare_call_hierarchy: (String uri, Position position, **json params) -> Future
|
|
154
|
+
def prepare_type_hierarchy: (String uri, Position position, **json params) -> Future
|
|
155
|
+
def linked_editing_range: (String uri, Position position, **json params) -> Future
|
|
139
156
|
def document_symbol: (String uri) -> Future
|
|
140
157
|
def formatting: (String uri, object options) -> Future
|
|
158
|
+
def range_formatting: (String uri, Range_ range, object options) -> Future
|
|
141
159
|
def code_action: (String uri, Range_ range, object context) -> Future
|
|
142
160
|
def code_lens: (String uri) -> Future
|
|
143
161
|
def inlay_hint: (String uri, Range_ range) -> Future
|
|
162
|
+
def folding_range: (String uri) -> Future
|
|
163
|
+
def selection_range: (String uri, Array[Position | Hash[String | Symbol, Integer]] positions) -> Future
|
|
164
|
+
def document_link: (String uri) -> Future
|
|
144
165
|
def diagnostic: (String uri, ?previous_result_id: String?) -> Future
|
|
145
166
|
def semantic_tokens: (String uri, version: Integer) -> Array[Token]
|
|
146
167
|
def workspace_symbols: (String query) -> Future
|
|
147
168
|
def resolve_completion: (object item) -> Future
|
|
148
169
|
def resolve_code_action: (object action) -> Future
|
|
149
170
|
def resolve_code_lens: (object lens) -> Future
|
|
171
|
+
def resolve_document_link: (object link) -> Future
|
|
172
|
+
def call_hierarchy_incoming_calls: (object item) -> Future
|
|
173
|
+
def call_hierarchy_outgoing_calls: (object item) -> Future
|
|
174
|
+
def type_hierarchy_supertypes: (object item) -> Future
|
|
175
|
+
def type_hierarchy_subtypes: (object item) -> Future
|
|
150
176
|
def execute_command: (String command, ?arguments: Array[json]) -> Future
|
|
177
|
+
def did_change_configuration: (json settings) -> untyped
|
|
178
|
+
def did_change_watched_files: (Array[object] events) -> untyped
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
module Testing
|
|
182
|
+
class FakeServer
|
|
183
|
+
SCRIPT: String
|
|
184
|
+
DEFAULT_CAPABILITIES: Hash[String, json]
|
|
185
|
+
attr_reader capabilities: Hash[String, json]
|
|
186
|
+
attr_reader messages: Array[object]
|
|
187
|
+
def self.command: () -> Array[String]
|
|
188
|
+
def initialize: (?responses: Hash[String | Symbol, untyped], ?capabilities: Hash[String, json]) -> void
|
|
189
|
+
def transport: () { (Hash[String, json]?, Exception?) -> untyped } -> FakeTransport
|
|
190
|
+
def dispatch: (object message) -> Array[object]
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
class FakeTransport < Transport
|
|
194
|
+
attr_reader stderr_lines: Array[String]
|
|
195
|
+
attr_reader pid: Integer
|
|
196
|
+
def initialize: (FakeServer server) { (Hash[String, json]?, Exception?) -> untyped } -> void
|
|
197
|
+
def write: (object message) -> nil
|
|
198
|
+
def try_write: (object message) -> bool
|
|
199
|
+
def alive?: () -> bool
|
|
200
|
+
def close: () -> nil
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
class FakeClient < Client
|
|
204
|
+
attr_reader server: FakeServer
|
|
205
|
+
def initialize: (?server: FakeServer, **untyped options) -> void
|
|
206
|
+
end
|
|
151
207
|
end
|
|
152
208
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sadr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yudai Takada
|
|
@@ -26,6 +26,10 @@ files:
|
|
|
26
26
|
- lib/sadr/document_sync.rb
|
|
27
27
|
- lib/sadr/future.rb
|
|
28
28
|
- lib/sadr/protocol.rb
|
|
29
|
+
- lib/sadr/testing.rb
|
|
30
|
+
- lib/sadr/testing/fake_client.rb
|
|
31
|
+
- lib/sadr/testing/fake_server.rb
|
|
32
|
+
- lib/sadr/testing/fake_transport.rb
|
|
29
33
|
- lib/sadr/transport.rb
|
|
30
34
|
- lib/sadr/version.rb
|
|
31
35
|
- sig/sadr.rbs
|
|
@@ -51,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
51
55
|
- !ruby/object:Gem::Version
|
|
52
56
|
version: '0'
|
|
53
57
|
requirements: []
|
|
54
|
-
rubygems_version:
|
|
58
|
+
rubygems_version: 3.6.9
|
|
55
59
|
specification_version: 4
|
|
56
60
|
summary: A pure Ruby Language Server Protocol client
|
|
57
61
|
test_files: []
|