ruby-lsp 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +6 -0
  3. data/.rubocop.yml +16 -0
  4. data/CHANGELOG.md +13 -0
  5. data/Gemfile +8 -5
  6. data/Gemfile.lock +55 -10
  7. data/README.md +40 -0
  8. data/VERSION +1 -1
  9. data/bin/tapioca +29 -0
  10. data/dev.yml +3 -0
  11. data/exe/ruby-lsp +19 -4
  12. data/lib/internal.rb +7 -0
  13. data/lib/ruby-lsp.rb +1 -0
  14. data/lib/ruby_lsp/cli.rb +12 -5
  15. data/lib/ruby_lsp/document.rb +37 -14
  16. data/lib/ruby_lsp/handler.rb +78 -23
  17. data/lib/ruby_lsp/requests/base_request.rb +11 -0
  18. data/lib/ruby_lsp/requests/code_actions.rb +1 -0
  19. data/lib/ruby_lsp/requests/diagnostics.rb +1 -0
  20. data/lib/ruby_lsp/requests/document_highlight.rb +96 -0
  21. data/lib/ruby_lsp/requests/document_symbol.rb +1 -10
  22. data/lib/ruby_lsp/requests/folding_ranges.rb +3 -2
  23. data/lib/ruby_lsp/requests/formatting.rb +2 -1
  24. data/lib/ruby_lsp/requests/rubocop_request.rb +1 -0
  25. data/lib/ruby_lsp/requests/selection_ranges.rb +1 -0
  26. data/lib/ruby_lsp/requests/semantic_highlighting.rb +17 -3
  27. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +1 -0
  28. data/lib/ruby_lsp/requests/support/selection_range.rb +1 -0
  29. data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +12 -1
  30. data/lib/ruby_lsp/requests/support/syntax_error_diagnostic.rb +1 -0
  31. data/lib/ruby_lsp/requests.rb +2 -0
  32. data/lib/ruby_lsp/store.rb +19 -3
  33. data/rakelib/check_docs.rake +4 -1
  34. data/ruby-lsp.gemspec +1 -0
  35. data/sorbet/config +4 -0
  36. data/sorbet/rbi/.rubocop.yml +8 -0
  37. data/sorbet/rbi/gems/ansi@1.5.0.rbi +338 -0
  38. data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
  39. data/sorbet/rbi/gems/builder@3.2.4.rbi +418 -0
  40. data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
  41. data/sorbet/rbi/gems/debug@1.5.0.rbi +1273 -0
  42. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +867 -0
  43. data/sorbet/rbi/gems/io-console@0.5.11.rbi +8 -0
  44. data/sorbet/rbi/gems/irb@1.4.1.rbi +376 -0
  45. data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +7325 -0
  46. data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
  47. data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +612 -0
  48. data/sorbet/rbi/gems/minitest@5.15.0.rbi +994 -0
  49. data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
  50. data/sorbet/rbi/gems/parser@3.1.2.0.rbi +3968 -0
  51. data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +734 -0
  52. data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
  53. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
  54. data/sorbet/rbi/gems/rake@13.0.6.rbi +1853 -0
  55. data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
  56. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1854 -0
  57. data/sorbet/rbi/gems/reline@0.3.1.rbi +1274 -0
  58. data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
  59. data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +4180 -0
  60. data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +1369 -0
  61. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +246 -0
  62. data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +8 -0
  63. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +652 -0
  64. data/sorbet/rbi/gems/rubocop@1.30.0.rbi +36729 -0
  65. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
  66. data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
  67. data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +6777 -0
  68. data/sorbet/rbi/gems/tapioca@0.8.1.rbi +1972 -0
  69. data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
  70. data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +27 -0
  71. data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
  72. data/sorbet/rbi/gems/webrick@1.7.0.rbi +1779 -0
  73. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +289 -0
  74. data/sorbet/rbi/gems/yard@0.9.27.rbi +13048 -0
  75. data/sorbet/rbi/shims/fiddle.rbi +4 -0
  76. data/sorbet/rbi/shims/hash.rbi +6 -0
  77. data/sorbet/rbi/shims/rdoc.rbi +4 -0
  78. data/sorbet/tapioca/config.yml +13 -0
  79. data/sorbet/tapioca/require.rb +7 -0
  80. metadata +64 -2
@@ -0,0 +1,8 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `io-console` gem.
5
+ # Please instead update this file by running `bin/tapioca gem io-console`.
6
+
7
+ # THIS IS AN EMPTY RBI FILE.
8
+ # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires
@@ -0,0 +1,376 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `irb` gem.
5
+ # Please instead update this file by running `bin/tapioca gem irb`.
6
+
7
+ module IRB::Color
8
+ class << self
9
+ def clear(colorable: T.unsafe(nil)); end
10
+
11
+ # @return [Boolean]
12
+ def colorable?; end
13
+
14
+ def colorize(text, seq, colorable: T.unsafe(nil)); end
15
+
16
+ # If `complete` is false (code is incomplete), this does not warn compile_error.
17
+ # This option is needed to avoid warning a user when the compile_error is happening
18
+ # because the input is not wrong but just incomplete.
19
+ def colorize_code(code, complete: T.unsafe(nil), ignore_error: T.unsafe(nil), colorable: T.unsafe(nil)); end
20
+
21
+ # @return [Boolean]
22
+ def inspect_colorable?(obj, seen: T.unsafe(nil)); end
23
+
24
+ private
25
+
26
+ def dispatch_seq(token, expr, str, in_symbol:); end
27
+ def scan(code, allow_last_error:); end
28
+ def without_circular_ref(obj, seen:, &block); end
29
+ end
30
+ end
31
+
32
+ # A constant of all-bit 1 to match any Ripper's state in #dispatch_seq
33
+ IRB::Color::ALL = T.let(T.unsafe(nil), Integer)
34
+
35
+ IRB::Color::BLUE = T.let(T.unsafe(nil), Integer)
36
+ IRB::Color::BOLD = T.let(T.unsafe(nil), Integer)
37
+ IRB::Color::CLEAR = T.let(T.unsafe(nil), Integer)
38
+ IRB::Color::CYAN = T.let(T.unsafe(nil), Integer)
39
+ IRB::Color::DIM = T.let(T.unsafe(nil), Integer)
40
+ IRB::Color::ERROR_TOKENS = T.let(T.unsafe(nil), Array)
41
+ IRB::Color::GREEN = T.let(T.unsafe(nil), Integer)
42
+ IRB::Color::MAGENTA = T.let(T.unsafe(nil), Integer)
43
+ IRB::Color::RED = T.let(T.unsafe(nil), Integer)
44
+ IRB::Color::REVERSE = T.let(T.unsafe(nil), Integer)
45
+
46
+ # A class to manage a state to know whether the current token is for Symbol or not.
47
+ class IRB::Color::SymbolState
48
+ # @return [SymbolState] a new instance of SymbolState
49
+ def initialize; end
50
+
51
+ # Return true if the token is a part of Symbol.
52
+ def scan_token(token); end
53
+ end
54
+
55
+ IRB::Color::TOKEN_KEYWORDS = T.let(T.unsafe(nil), Hash)
56
+ IRB::Color::TOKEN_SEQ_EXPRS = T.let(T.unsafe(nil), Hash)
57
+ IRB::Color::UNDERLINE = T.let(T.unsafe(nil), Integer)
58
+ IRB::Color::YELLOW = T.let(T.unsafe(nil), Integer)
59
+
60
+ class IRB::ColorPrinter < ::PP
61
+ def pp(obj); end
62
+ def text(str, width = T.unsafe(nil)); end
63
+
64
+ class << self
65
+ def pp(obj, out = T.unsafe(nil), width = T.unsafe(nil)); end
66
+
67
+ private
68
+
69
+ def screen_width; end
70
+ end
71
+ end
72
+
73
+ # An output formatter used internally by the lexer.
74
+ module IRB::Notifier
75
+ private
76
+
77
+ # Define a new Notifier output source, returning a new CompositeNotifier
78
+ # with the given +prefix+ and +output_method+.
79
+ #
80
+ # The optional +prefix+ will be appended to all objects being inspected
81
+ # during output, using the given +output_method+ as the output source. If
82
+ # no +output_method+ is given, StdioOutputMethod will be used, and all
83
+ # expressions will be sent directly to STDOUT without any additional
84
+ # formatting.
85
+ def def_notifier(prefix = T.unsafe(nil), output_method = T.unsafe(nil)); end
86
+
87
+ class << self
88
+ # Define a new Notifier output source, returning a new CompositeNotifier
89
+ # with the given +prefix+ and +output_method+.
90
+ #
91
+ # The optional +prefix+ will be appended to all objects being inspected
92
+ # during output, using the given +output_method+ as the output source. If
93
+ # no +output_method+ is given, StdioOutputMethod will be used, and all
94
+ # expressions will be sent directly to STDOUT without any additional
95
+ # formatting.
96
+ def def_notifier(prefix = T.unsafe(nil), output_method = T.unsafe(nil)); end
97
+ end
98
+ end
99
+
100
+ # An abstract class, or superclass, for CompositeNotifier and
101
+ # LeveledNotifier to inherit. It provides several wrapper methods for the
102
+ # OutputMethod object used by the Notifier.
103
+ class IRB::Notifier::AbstractNotifier
104
+ # Creates a new Notifier object
105
+ #
106
+ # @return [AbstractNotifier] a new instance of AbstractNotifier
107
+ def initialize(prefix, base_notifier); end
108
+
109
+ # Execute the given block if notifications are enabled.
110
+ #
111
+ # @yield [@base_notifier]
112
+ def exec_if; end
113
+
114
+ # A wrapper method used to determine whether notifications are enabled.
115
+ #
116
+ # Defaults to +true+.
117
+ #
118
+ # @return [Boolean]
119
+ def notify?; end
120
+
121
+ # Same as #ppx, except it uses the #prefix given during object
122
+ # initialization.
123
+ # See OutputMethod#ppx for more detail.
124
+ def pp(*objs); end
125
+
126
+ # Same as #pp, except it concatenates the given +prefix+ with the #prefix
127
+ # given during object initialization.
128
+ #
129
+ # See OutputMethod#ppx for more detail.
130
+ def ppx(prefix, *objs); end
131
+
132
+ # The +prefix+ for this Notifier, which is appended to all objects being
133
+ # inspected during output.
134
+ def prefix; end
135
+
136
+ # See OutputMethod#print for more detail.
137
+ def print(*opts); end
138
+
139
+ # See OutputMethod#printf for more detail.
140
+ def printf(format, *opts); end
141
+
142
+ # See OutputMethod#printn for more detail.
143
+ def printn(*opts); end
144
+
145
+ # See OutputMethod#puts for more detail.
146
+ def puts(*objs); end
147
+ end
148
+
149
+ # A class that can be used to create a group of notifier objects with the
150
+ # intent of representing a leveled notification system for irb.
151
+ #
152
+ # This class will allow you to generate other notifiers, and assign them
153
+ # the appropriate level for output.
154
+ #
155
+ # The Notifier class provides a class-method Notifier.def_notifier to
156
+ # create a new composite notifier. Using the first composite notifier
157
+ # object you create, sibling notifiers can be initialized with
158
+ # #def_notifier.
159
+ class IRB::Notifier::CompositeNotifier < ::IRB::Notifier::AbstractNotifier
160
+ # Create a new composite notifier object with the given +prefix+, and
161
+ # +base_notifier+ to use for output.
162
+ #
163
+ # @return [CompositeNotifier] a new instance of CompositeNotifier
164
+ def initialize(prefix, base_notifier); end
165
+
166
+ # Creates a new LeveledNotifier in the composite #notifiers group.
167
+ #
168
+ # The given +prefix+ will be assigned to the notifier, and +level+ will
169
+ # be used as the index of the #notifiers Array.
170
+ #
171
+ # This method returns the newly created instance.
172
+ def def_notifier(level, prefix = T.unsafe(nil)); end
173
+
174
+ # Returns the leveled notifier for this object
175
+ def level; end
176
+
177
+ # Sets the leveled notifier for this object.
178
+ #
179
+ # When the given +value+ is an instance of AbstractNotifier,
180
+ # #level_notifier is set to the given object.
181
+ #
182
+ # When an Integer is given, #level_notifier is set to the notifier at the
183
+ # index +value+ in the #notifiers Array.
184
+ #
185
+ # If no notifier exists at the index +value+ in the #notifiers Array, an
186
+ # ErrUndefinedNotifier exception is raised.
187
+ #
188
+ # An ErrUnrecognizedLevel exception is raised if the given +value+ is not
189
+ # found in the existing #notifiers Array, or an instance of
190
+ # AbstractNotifier
191
+ def level=(value); end
192
+
193
+ # Returns the leveled notifier for this object
194
+ def level_notifier; end
195
+
196
+ # Sets the leveled notifier for this object.
197
+ #
198
+ # When the given +value+ is an instance of AbstractNotifier,
199
+ # #level_notifier is set to the given object.
200
+ #
201
+ # When an Integer is given, #level_notifier is set to the notifier at the
202
+ # index +value+ in the #notifiers Array.
203
+ #
204
+ # If no notifier exists at the index +value+ in the #notifiers Array, an
205
+ # ErrUndefinedNotifier exception is raised.
206
+ #
207
+ # An ErrUnrecognizedLevel exception is raised if the given +value+ is not
208
+ # found in the existing #notifiers Array, or an instance of
209
+ # AbstractNotifier
210
+ def level_notifier=(value); end
211
+
212
+ # List of notifiers in the group
213
+ def notifiers; end
214
+ end
215
+
216
+ class IRB::Notifier::ErrUndefinedNotifier < ::StandardError
217
+ # @return [ErrUndefinedNotifier] a new instance of ErrUndefinedNotifier
218
+ def initialize(val); end
219
+ end
220
+
221
+ class IRB::Notifier::ErrUnrecognizedLevel < ::StandardError
222
+ # @return [ErrUnrecognizedLevel] a new instance of ErrUnrecognizedLevel
223
+ def initialize(val); end
224
+ end
225
+
226
+ # A leveled notifier is comparable to the composite group from
227
+ # CompositeNotifier#notifiers.
228
+ class IRB::Notifier::LeveledNotifier < ::IRB::Notifier::AbstractNotifier
229
+ include ::Comparable
230
+
231
+ # Create a new leveled notifier with the given +base+, and +prefix+ to
232
+ # send to AbstractNotifier.new
233
+ #
234
+ # The given +level+ is used to compare other leveled notifiers in the
235
+ # CompositeNotifier group to determine whether or not to output
236
+ # notifications.
237
+ #
238
+ # @return [LeveledNotifier] a new instance of LeveledNotifier
239
+ def initialize(base, level, prefix); end
240
+
241
+ # Compares the level of this notifier object with the given +other+
242
+ # notifier.
243
+ #
244
+ # See the Comparable module for more information.
245
+ def <=>(other); end
246
+
247
+ # The current level of this notifier object
248
+ def level; end
249
+
250
+ # Whether to output messages to the output method, depending on the level
251
+ # of this notifier object.
252
+ #
253
+ # @return [Boolean]
254
+ def notify?; end
255
+ end
256
+
257
+ # NoMsgNotifier is a LeveledNotifier that's used as the default notifier
258
+ # when creating a new CompositeNotifier.
259
+ #
260
+ # This notifier is used as the +zero+ index, or level +0+, for
261
+ # CompositeNotifier#notifiers, and will not output messages of any sort.
262
+ class IRB::Notifier::NoMsgNotifier < ::IRB::Notifier::LeveledNotifier
263
+ # Creates a new notifier that should not be used to output messages.
264
+ #
265
+ # @return [NoMsgNotifier] a new instance of NoMsgNotifier
266
+ def initialize; end
267
+
268
+ # Ensures notifications are ignored, see AbstractNotifier#notify? for
269
+ # more information.
270
+ #
271
+ # @return [Boolean]
272
+ def notify?; end
273
+ end
274
+
275
+ # An abstract output class for IO in irb. This is mainly used internally by
276
+ # IRB::Notifier. You can define your own output method to use with Irb.new,
277
+ # or Context.new
278
+ class IRB::OutputMethod
279
+ # Returns an array of the given +format+ and +opts+ to be used by
280
+ # Kernel#sprintf, if there was a successful Regexp match in the given
281
+ # +format+ from #printf
282
+ #
283
+ # %
284
+ # <flag> [#0- +]
285
+ # <minimum field width> (\*|\*[1-9][0-9]*\$|[1-9][0-9]*)
286
+ # <precision>.(\*|\*[1-9][0-9]*\$|[1-9][0-9]*|)?
287
+ # #<length modifier>(hh|h|l|ll|L|q|j|z|t)
288
+ # <conversion specifier>[diouxXeEfgGcsb%]
289
+ def parse_printf_format(format, opts); end
290
+
291
+ # Prints the given +objs+ calling Object#inspect on each.
292
+ #
293
+ # See #puts for more detail.
294
+ def pp(*objs); end
295
+
296
+ # Prints the given +objs+ calling Object#inspect on each and appending the
297
+ # given +prefix+.
298
+ #
299
+ # See #puts for more detail.
300
+ def ppx(prefix, *objs); end
301
+
302
+ # Open this method to implement your own output method, raises a
303
+ # NotImplementedError if you don't define #print in your own class.
304
+ #
305
+ # @raise [NotImplementedError]
306
+ def print(*opts); end
307
+
308
+ # Extends IO#printf to format the given +opts+ for Kernel#sprintf using
309
+ # #parse_printf_format
310
+ def printf(format, *opts); end
311
+
312
+ # Prints the given +opts+, with a newline delimiter.
313
+ def printn(*opts); end
314
+
315
+ # Calls #print on each element in the given +objs+, followed by a newline
316
+ # character.
317
+ def puts(*objs); end
318
+ end
319
+
320
+ class IRB::OutputMethod::NotImplementedError < ::StandardError
321
+ # @return [NotImplementedError] a new instance of NotImplementedError
322
+ def initialize(val); end
323
+ end
324
+
325
+ # :stopdoc:
326
+ class RubyLex
327
+ # @return [RubyLex] a new instance of RubyLex
328
+ def initialize; end
329
+
330
+ def check_code_block(code, tokens = T.unsafe(nil)); end
331
+ def check_corresponding_token_depth(lines, line_index); end
332
+ def check_newline_depth_difference; end
333
+ def check_state(code, tokens = T.unsafe(nil), context: T.unsafe(nil)); end
334
+ def check_string_literal(tokens); end
335
+ def check_termination_in_prev_line(code, context: T.unsafe(nil)); end
336
+ def each_top_level_statement; end
337
+ def find_prev_spaces(line_index); end
338
+ def initialize_input; end
339
+
340
+ # @return [Boolean]
341
+ def is_method_calling?(tokens, index); end
342
+
343
+ def is_the_in_correspond_to_a_for(tokens, index); end
344
+ def lex; end
345
+ def process_continue(tokens = T.unsafe(nil)); end
346
+ def process_literal_type(tokens = T.unsafe(nil)); end
347
+ def process_nesting_level(tokens = T.unsafe(nil)); end
348
+ def prompt; end
349
+ def set_auto_indent(context); end
350
+
351
+ # io functions
352
+ def set_input(io, p = T.unsafe(nil), context: T.unsafe(nil), &block); end
353
+
354
+ def set_prompt(p = T.unsafe(nil), &block); end
355
+ def take_corresponding_syntax_to_kw_do(tokens, index); end
356
+
357
+ private
358
+
359
+ # @return [Boolean]
360
+ def heredoc_scope?; end
361
+
362
+ # @return [Boolean]
363
+ def in_keyword_case_scope?; end
364
+
365
+ class << self
366
+ def compile_with_errors_suppressed(code, line_no: T.unsafe(nil)); end
367
+ def ripper_lex_without_warning(code, context: T.unsafe(nil)); end
368
+ end
369
+ end
370
+
371
+ RubyLex::ERROR_TOKENS = T.let(T.unsafe(nil), Array)
372
+
373
+ class RubyLex::TerminateLineInput < ::StandardError
374
+ # @return [TerminateLineInput] a new instance of TerminateLineInput
375
+ def initialize; end
376
+ end