ruby-lsp 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +9 -1
  3. data/.github/workflows/publish_docs.yml +32 -0
  4. data/.rubocop.yml +25 -0
  5. data/CHANGELOG.md +23 -0
  6. data/Gemfile +8 -4
  7. data/Gemfile.lock +64 -13
  8. data/README.md +58 -1
  9. data/Rakefile +5 -0
  10. data/VERSION +1 -1
  11. data/bin/tapioca +29 -0
  12. data/dev.yml +3 -0
  13. data/exe/ruby-lsp +19 -3
  14. data/lib/ruby-lsp.rb +2 -0
  15. data/lib/ruby_lsp/cli.rb +23 -7
  16. data/lib/ruby_lsp/document.rb +98 -6
  17. data/lib/ruby_lsp/handler.rb +119 -18
  18. data/lib/ruby_lsp/internal.rb +7 -0
  19. data/lib/ruby_lsp/requests/base_request.rb +19 -5
  20. data/lib/ruby_lsp/requests/code_actions.rb +30 -9
  21. data/lib/ruby_lsp/requests/diagnostics.rb +29 -77
  22. data/lib/ruby_lsp/requests/document_highlight.rb +111 -0
  23. data/lib/ruby_lsp/requests/document_symbol.rb +75 -16
  24. data/lib/ruby_lsp/requests/folding_ranges.rb +63 -19
  25. data/lib/ruby_lsp/requests/formatting.rb +19 -2
  26. data/lib/ruby_lsp/requests/rubocop_request.rb +21 -8
  27. data/lib/ruby_lsp/requests/selection_ranges.rb +114 -0
  28. data/lib/ruby_lsp/requests/semantic_highlighting.rb +132 -61
  29. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +100 -0
  30. data/lib/ruby_lsp/requests/support/selection_range.rb +20 -0
  31. data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +70 -0
  32. data/lib/ruby_lsp/requests/support/syntax_error_diagnostic.rb +32 -0
  33. data/lib/ruby_lsp/requests.rb +10 -0
  34. data/lib/ruby_lsp/store.rb +23 -2
  35. data/rakelib/check_docs.rake +57 -0
  36. data/ruby-lsp.gemspec +2 -1
  37. data/sorbet/config +4 -0
  38. data/sorbet/rbi/.rubocop.yml +8 -0
  39. data/sorbet/rbi/gems/ansi@1.5.0.rbi +338 -0
  40. data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
  41. data/sorbet/rbi/gems/builder@3.2.4.rbi +418 -0
  42. data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
  43. data/sorbet/rbi/gems/debug@1.5.0.rbi +1273 -0
  44. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +867 -0
  45. data/sorbet/rbi/gems/io-console@0.5.11.rbi +8 -0
  46. data/sorbet/rbi/gems/irb@1.4.1.rbi +376 -0
  47. data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +7325 -0
  48. data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
  49. data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +612 -0
  50. data/sorbet/rbi/gems/minitest@5.15.0.rbi +994 -0
  51. data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
  52. data/sorbet/rbi/gems/parser@3.1.2.0.rbi +3968 -0
  53. data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +734 -0
  54. data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
  55. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
  56. data/sorbet/rbi/gems/rake@13.0.6.rbi +1853 -0
  57. data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
  58. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1854 -0
  59. data/sorbet/rbi/gems/reline@0.3.1.rbi +1274 -0
  60. data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
  61. data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +4180 -0
  62. data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +1369 -0
  63. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +246 -0
  64. data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +8 -0
  65. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +652 -0
  66. data/sorbet/rbi/gems/rubocop@1.30.0.rbi +36729 -0
  67. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
  68. data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
  69. data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +6777 -0
  70. data/sorbet/rbi/gems/tapioca@0.8.1.rbi +1972 -0
  71. data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
  72. data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +27 -0
  73. data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
  74. data/sorbet/rbi/gems/webrick@1.7.0.rbi +1779 -0
  75. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +289 -0
  76. data/sorbet/rbi/gems/yard@0.9.27.rbi +13048 -0
  77. data/sorbet/rbi/shims/fiddle.rbi +4 -0
  78. data/sorbet/rbi/shims/hash.rbi +6 -0
  79. data/sorbet/rbi/shims/rdoc.rbi +4 -0
  80. data/sorbet/tapioca/config.yml +13 -0
  81. data/sorbet/tapioca/require.rb +7 -0
  82. metadata +74 -6
  83. data/shipit.production.yml +0 -1
@@ -0,0 +1,418 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `builder` gem.
5
+ # Please instead update this file by running `bin/tapioca gem builder`.
6
+
7
+ # If the Builder::XChar module is not currently defined, fail on any
8
+ # name clashes in standard library classes.
9
+ module Builder
10
+ class << self
11
+ def check_for_name_collision(klass, method_name, defined_constant = T.unsafe(nil)); end
12
+ end
13
+ end
14
+
15
+ Builder::BlankSlate = BasicObject
16
+
17
+ # Generic error for builder
18
+ class Builder::IllegalBlockError < ::RuntimeError; end
19
+
20
+ module Builder::XChar
21
+ class << self
22
+ # encode a string per XML rules
23
+ def encode(string); end
24
+
25
+ # convert a string to valid UTF-8, compensating for a number of
26
+ # common errors.
27
+ def unicode(string); end
28
+ end
29
+ end
30
+
31
+ # See
32
+ # http://intertwingly.net/stories/2004/04/14/i18n.html#CleaningWindows
33
+ # for details.
34
+ Builder::XChar::CP1252 = T.let(T.unsafe(nil), Hash)
35
+
36
+ Builder::XChar::CP1252_DIFFERENCES = T.let(T.unsafe(nil), String)
37
+ Builder::XChar::ENCODING_BINARY = T.let(T.unsafe(nil), Encoding)
38
+ Builder::XChar::ENCODING_ISO1 = T.let(T.unsafe(nil), Encoding)
39
+ Builder::XChar::ENCODING_UTF8 = T.let(T.unsafe(nil), Encoding)
40
+ Builder::XChar::INVALID_XML_CHAR = T.let(T.unsafe(nil), Regexp)
41
+
42
+ # See http://www.w3.org/TR/REC-xml/#dt-chardata for details.
43
+ Builder::XChar::PREDEFINED = T.let(T.unsafe(nil), Hash)
44
+
45
+ # http://www.fileformat.info/info/unicode/char/fffd/index.htm
46
+ Builder::XChar::REPLACEMENT_CHAR = T.let(T.unsafe(nil), String)
47
+
48
+ Builder::XChar::UNICODE_EQUIVALENT = T.let(T.unsafe(nil), String)
49
+
50
+ # See http://www.w3.org/TR/REC-xml/#charsets for details.
51
+ Builder::XChar::VALID = T.let(T.unsafe(nil), Array)
52
+
53
+ Builder::XChar::XML_PREDEFINED = T.let(T.unsafe(nil), Regexp)
54
+
55
+ # XmlBase is a base class for building XML builders. See
56
+ # Builder::XmlMarkup and Builder::XmlEvents for examples.
57
+ class Builder::XmlBase < ::BasicObject
58
+ # Create an XML markup builder.
59
+ #
60
+ # out :: Object receiving the markup. +out+ must respond to
61
+ # <tt><<</tt>.
62
+ # indent :: Number of spaces used for indentation (0 implies no
63
+ # indentation and no line breaks).
64
+ # initial :: Level of initial indentation.
65
+ # encoding :: When <tt>encoding</tt> and $KCODE are set to 'utf-8'
66
+ # characters aren't converted to character entities in
67
+ # the output stream.
68
+ #
69
+ # @return [XmlBase] a new instance of XmlBase
70
+ def initialize(indent = T.unsafe(nil), initial = T.unsafe(nil), encoding = T.unsafe(nil)); end
71
+
72
+ # Append text to the output target without escaping any markup.
73
+ # May be used within the markup brackets as:
74
+ #
75
+ # builder.p { |x| x << "<br/>HI" } #=> <p><br/>HI</p>
76
+ #
77
+ # This is useful when using non-builder enabled software that
78
+ # generates strings. Just insert the string directly into the
79
+ # builder without changing the inserted markup.
80
+ #
81
+ # It is also useful for stacking builder objects. Builders only
82
+ # use <tt><<</tt> to append to the target, so by supporting this
83
+ # method/operation builders can use other builders as their
84
+ # targets.
85
+ def <<(text); end
86
+
87
+ # @return [Boolean]
88
+ def explicit_nil_handling?; end
89
+
90
+ # Create XML markup based on the name of the method. This method
91
+ # is never invoked directly, but is called for each markup method
92
+ # in the markup block that isn't cached.
93
+ def method_missing(sym, *args, &block); end
94
+
95
+ # For some reason, nil? is sent to the XmlMarkup object. If nil?
96
+ # is not defined and method_missing is invoked, some strange kind
97
+ # of recursion happens. Since nil? won't ever be an XML tag, it
98
+ # is pretty safe to define it here. (Note: this is an example of
99
+ # cargo cult programming,
100
+ # cf. http://fishbowl.pastiche.org/2004/10/13/cargo_cult_programming).
101
+ #
102
+ # @return [Boolean]
103
+ def nil?; end
104
+
105
+ # Create a tag named +sym+. Other than the first argument which
106
+ # is the tag name, the arguments are the same as the tags
107
+ # implemented via <tt>method_missing</tt>.
108
+ def tag!(sym, *args, &block); end
109
+
110
+ # Append text to the output target. Escape any markup. May be
111
+ # used within the markup brackets as:
112
+ #
113
+ # builder.p { |b| b.br; b.text! "HI" } #=> <p><br/>HI</p>
114
+ def text!(text); end
115
+
116
+ private
117
+
118
+ def _escape(text); end
119
+ def _escape_attribute(text); end
120
+ def _indent; end
121
+ def _nested_structures(block); end
122
+ def _newline; end
123
+
124
+ # If XmlBase.cache_method_calls = true, we dynamicly create the method
125
+ # missed as an instance method on the XMLBase object. Because XML
126
+ # documents are usually very repetative in nature, the next node will
127
+ # be handled by the new method instead of method_missing. As
128
+ # method_missing is very slow, this speeds up document generation
129
+ # significantly.
130
+ def cache_method_call(sym); end
131
+
132
+ class << self
133
+ # Returns the value of attribute cache_method_calls.
134
+ def cache_method_calls; end
135
+
136
+ # Sets the attribute cache_method_calls
137
+ #
138
+ # @param value the value to set the attribute cache_method_calls to.
139
+ def cache_method_calls=(_arg0); end
140
+ end
141
+ end
142
+
143
+ # Create a series of SAX-like XML events (e.g. start_tag, end_tag)
144
+ # from the markup code. XmlEvent objects are used in a way similar
145
+ # to XmlMarkup objects, except that a series of events are generated
146
+ # and passed to a handler rather than generating character-based
147
+ # markup.
148
+ #
149
+ # Usage:
150
+ # xe = Builder::XmlEvents.new(hander)
151
+ # xe.title("HI") # Sends start_tag/end_tag/text messages to the handler.
152
+ #
153
+ # Indentation may also be selected by providing value for the
154
+ # indentation size and initial indentation level.
155
+ #
156
+ # xe = Builder::XmlEvents.new(handler, indent_size, initial_indent_level)
157
+ #
158
+ # == XML Event Handler
159
+ #
160
+ # The handler object must expect the following events.
161
+ #
162
+ # [<tt>start_tag(tag, attrs)</tt>]
163
+ # Announces that a new tag has been found. +tag+ is the name of
164
+ # the tag and +attrs+ is a hash of attributes for the tag.
165
+ #
166
+ # [<tt>end_tag(tag)</tt>]
167
+ # Announces that an end tag for +tag+ has been found.
168
+ #
169
+ # [<tt>text(text)</tt>]
170
+ # Announces that a string of characters (+text+) has been found.
171
+ # A series of characters may be broken up into more than one
172
+ # +text+ call, so the client cannot assume that a single
173
+ # callback contains all the text data.
174
+ class Builder::XmlEvents < ::Builder::XmlMarkup
175
+ def _end_tag(sym); end
176
+ def _start_tag(sym, attrs, end_too = T.unsafe(nil)); end
177
+ def text!(text); end
178
+ end
179
+
180
+ # Create XML markup easily. All (well, almost all) methods sent to
181
+ # an XmlMarkup object will be translated to the equivalent XML
182
+ # markup. Any method with a block will be treated as an XML markup
183
+ # tag with nested markup in the block.
184
+ #
185
+ # Examples will demonstrate this easier than words. In the
186
+ # following, +xm+ is an +XmlMarkup+ object.
187
+ #
188
+ # xm.em("emphasized") # => <em>emphasized</em>
189
+ # xm.em { xm.b("emp & bold") } # => <em><b>emph &amp; bold</b></em>
190
+ # xm.a("A Link", "href"=>"http://onestepback.org")
191
+ # # => <a href="http://onestepback.org">A Link</a>
192
+ # xm.div { xm.br } # => <div><br/></div>
193
+ # xm.target("name"=>"compile", "option"=>"fast")
194
+ # # => <target option="fast" name="compile"\>
195
+ # # NOTE: order of attributes is not specified.
196
+ #
197
+ # xm.instruct! # <?xml version="1.0" encoding="UTF-8"?>
198
+ # xm.html { # <html>
199
+ # xm.head { # <head>
200
+ # xm.title("History") # <title>History</title>
201
+ # } # </head>
202
+ # xm.body { # <body>
203
+ # xm.comment! "HI" # <!-- HI -->
204
+ # xm.h1("Header") # <h1>Header</h1>
205
+ # xm.p("paragraph") # <p>paragraph</p>
206
+ # } # </body>
207
+ # } # </html>
208
+ #
209
+ # == Notes:
210
+ #
211
+ # * The order that attributes are inserted in markup tags is
212
+ # undefined.
213
+ #
214
+ # * Sometimes you wish to insert text without enclosing tags. Use
215
+ # the <tt>text!</tt> method to accomplish this.
216
+ #
217
+ # Example:
218
+ #
219
+ # xm.div { # <div>
220
+ # xm.text! "line"; xm.br # line<br/>
221
+ # xm.text! "another line"; xmbr # another line<br/>
222
+ # } # </div>
223
+ #
224
+ # * The special XML characters <, >, and & are converted to &lt;,
225
+ # &gt; and &amp; automatically. Use the <tt><<</tt> operation to
226
+ # insert text without modification.
227
+ #
228
+ # * Sometimes tags use special characters not allowed in ruby
229
+ # identifiers. Use the <tt>tag!</tt> method to handle these
230
+ # cases.
231
+ #
232
+ # Example:
233
+ #
234
+ # xml.tag!("SOAP:Envelope") { ... }
235
+ #
236
+ # will produce ...
237
+ #
238
+ # <SOAP:Envelope> ... </SOAP:Envelope>"
239
+ #
240
+ # <tt>tag!</tt> will also take text and attribute arguments (after
241
+ # the tag name) like normal markup methods. (But see the next
242
+ # bullet item for a better way to handle XML namespaces).
243
+ #
244
+ # * Direct support for XML namespaces is now available. If the
245
+ # first argument to a tag call is a symbol, it will be joined to
246
+ # the tag to produce a namespace:tag combination. It is easier to
247
+ # show this than describe it.
248
+ #
249
+ # xml.SOAP :Envelope do ... end
250
+ #
251
+ # Just put a space before the colon in a namespace to produce the
252
+ # right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
253
+ # "<tt>xml.SOAP :Envelope</tt>")
254
+ #
255
+ # * XmlMarkup builds the markup in any object (called a _target_)
256
+ # that accepts the <tt><<</tt> method. If no target is given,
257
+ # then XmlMarkup defaults to a string target.
258
+ #
259
+ # Examples:
260
+ #
261
+ # xm = Builder::XmlMarkup.new
262
+ # result = xm.title("yada")
263
+ # # result is a string containing the markup.
264
+ #
265
+ # buffer = ""
266
+ # xm = Builder::XmlMarkup.new(buffer)
267
+ # # The markup is appended to buffer (using <<)
268
+ #
269
+ # xm = Builder::XmlMarkup.new(STDOUT)
270
+ # # The markup is written to STDOUT (using <<)
271
+ #
272
+ # xm = Builder::XmlMarkup.new
273
+ # x2 = Builder::XmlMarkup.new(:target=>xm)
274
+ # # Markup written to +x2+ will be send to +xm+.
275
+ #
276
+ # * Indentation is enabled by providing the number of spaces to
277
+ # indent for each level as a second argument to XmlBuilder.new.
278
+ # Initial indentation may be specified using a third parameter.
279
+ #
280
+ # Example:
281
+ #
282
+ # xm = Builder.new(:indent=>2)
283
+ # # xm will produce nicely formatted and indented XML.
284
+ #
285
+ # xm = Builder.new(:indent=>2, :margin=>4)
286
+ # # xm will produce nicely formatted and indented XML with 2
287
+ # # spaces per indent and an over all indentation level of 4.
288
+ #
289
+ # builder = Builder::XmlMarkup.new(:target=>$stdout, :indent=>2)
290
+ # builder.name { |b| b.first("Jim"); b.last("Weirich) }
291
+ # # prints:
292
+ # # <name>
293
+ # # <first>Jim</first>
294
+ # # <last>Weirich</last>
295
+ # # </name>
296
+ #
297
+ # * The instance_eval implementation which forces self to refer to
298
+ # the message receiver as self is now obsolete. We now use normal
299
+ # block calls to execute the markup block. This means that all
300
+ # markup methods must now be explicitly send to the xml builder.
301
+ # For instance, instead of
302
+ #
303
+ # xml.div { strong("text") }
304
+ #
305
+ # you need to write:
306
+ #
307
+ # xml.div { xml.strong("text") }
308
+ #
309
+ # Although more verbose, the subtle change in semantics within the
310
+ # block was found to be prone to error. To make this change a
311
+ # little less cumbersome, the markup block now gets the markup
312
+ # object sent as an argument, allowing you to use a shorter alias
313
+ # within the block.
314
+ #
315
+ # For example:
316
+ #
317
+ # xml_builder = Builder::XmlMarkup.new
318
+ # xml_builder.div { |xml|
319
+ # xml.stong("text")
320
+ # }
321
+ class Builder::XmlMarkup < ::Builder::XmlBase
322
+ # Create an XML markup builder. Parameters are specified by an
323
+ # option hash.
324
+ #
325
+ # :target => <em>target_object</em>::
326
+ # Object receiving the markup. +target_object+ must respond to
327
+ # the <tt><<(<em>a_string</em>)</tt> operator and return
328
+ # itself. The default target is a plain string target.
329
+ #
330
+ # :indent => <em>indentation</em>::
331
+ # Number of spaces used for indentation. The default is no
332
+ # indentation and no line breaks.
333
+ #
334
+ # :margin => <em>initial_indentation_level</em>::
335
+ # Amount of initial indentation (specified in levels, not
336
+ # spaces).
337
+ #
338
+ # :quote => <em>:single</em>::
339
+ # Use single quotes for attributes rather than double quotes.
340
+ #
341
+ # :escape_attrs => <em>OBSOLETE</em>::
342
+ # The :escape_attrs option is no longer supported by builder
343
+ # (and will be quietly ignored). String attribute values are
344
+ # now automatically escaped. If you need unescaped attribute
345
+ # values (perhaps you are using entities in the attribute
346
+ # values), then give the value as a Symbol. This allows much
347
+ # finer control over escaping attribute values.
348
+ #
349
+ # @return [XmlMarkup] a new instance of XmlMarkup
350
+ def initialize(options = T.unsafe(nil)); end
351
+
352
+ # Insert a CDATA section into the XML markup.
353
+ #
354
+ # For example:
355
+ #
356
+ # xml.cdata!("text to be included in cdata")
357
+ # #=> <![CDATA[text to be included in cdata]]>
358
+ def cdata!(text); end
359
+
360
+ def cdata_value!(open, text); end
361
+ def comment!(comment_text); end
362
+
363
+ # Insert an XML declaration into the XML markup.
364
+ #
365
+ # For example:
366
+ #
367
+ # xml.declare! :ELEMENT, :blah, "yada"
368
+ # # => <!ELEMENT blah "yada">
369
+ def declare!(inst, *args, &block); end
370
+
371
+ # Insert a processing instruction into the XML markup. E.g.
372
+ #
373
+ # For example:
374
+ #
375
+ # xml.instruct!
376
+ # #=> <?xml version="1.0" encoding="UTF-8"?>
377
+ # xml.instruct! :aaa, :bbb=>"ccc"
378
+ # #=> <?aaa bbb="ccc"?>
379
+ #
380
+ # Note: If the encoding is setup to "UTF-8" and the value of
381
+ # $KCODE is "UTF8", then builder will emit UTF-8 encoded strings
382
+ # rather than the entity encoding normally used.
383
+ def instruct!(directive_tag = T.unsafe(nil), attrs = T.unsafe(nil)); end
384
+
385
+ # Return the target of the builder.
386
+ def target!; end
387
+
388
+ private
389
+
390
+ def _attr_value(value); end
391
+
392
+ # Insert an ending tag.
393
+ def _end_tag(sym); end
394
+
395
+ def _ensure_no_block(got_block); end
396
+
397
+ # Insert the attributes (given in the hash).
398
+ def _insert_attributes(attrs, order = T.unsafe(nil)); end
399
+
400
+ # Insert special instruction.
401
+ def _special(open, close, data = T.unsafe(nil), attrs = T.unsafe(nil), order = T.unsafe(nil)); end
402
+
403
+ # Start an XML tag. If <tt>end_too</tt> is true, then the start
404
+ # tag is also the end tag (e.g. <br/>
405
+ def _start_tag(sym, attrs, end_too = T.unsafe(nil)); end
406
+
407
+ # Insert text directly in to the builder's target.
408
+ def _text(text); end
409
+ end
410
+
411
+ # Enhance the Integer class with a XML escaped character conversion.
412
+ class Integer < ::Numeric
413
+ include ::JSON::Ext::Generator::GeneratorMethods::Integer
414
+ end
415
+
416
+ class Symbol
417
+ include ::Comparable
418
+ end
@@ -0,0 +1,8 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `coderay` gem.
5
+ # Please instead update this file by running `bin/tapioca gem coderay`.
6
+
7
+ # THIS IS AN EMPTY RBI FILE.
8
+ # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires