ruby-lsp 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/VERSION +1 -1
  4. data/lib/ruby_lsp/handler.rb +0 -19
  5. data/lib/ruby_lsp/requests/document_link.rb +59 -0
  6. data/lib/ruby_lsp/requests/semantic_highlighting.rb +11 -5
  7. data/lib/ruby_lsp/requests/support/highlight_target.rb +2 -1
  8. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +9 -2
  9. data/lib/ruby_lsp/requests.rb +2 -0
  10. data/lib/ruby_lsp/server.rb +51 -19
  11. metadata +3 -69
  12. data/.github/dependabot.yml +0 -11
  13. data/.github/probots.yml +0 -2
  14. data/.github/pull_request_template.md +0 -15
  15. data/.github/workflows/ci.yml +0 -31
  16. data/.github/workflows/publish_docs.yml +0 -32
  17. data/.gitignore +0 -9
  18. data/.rubocop.yml +0 -40
  19. data/.vscode/extensions.json +0 -5
  20. data/.vscode/settings.json +0 -5
  21. data/.vscode/tasks.json +0 -25
  22. data/CODE_OF_CONDUCT.md +0 -78
  23. data/Gemfile +0 -18
  24. data/Gemfile.lock +0 -126
  25. data/Rakefile +0 -28
  26. data/bin/console +0 -19
  27. data/bin/rubocop +0 -29
  28. data/bin/tapioca +0 -29
  29. data/bin/test +0 -9
  30. data/dev.yml +0 -20
  31. data/rakelib/check_docs.rake +0 -81
  32. data/ruby-lsp.gemspec +0 -27
  33. data/service.yml +0 -2
  34. data/sorbet/config +0 -4
  35. data/sorbet/rbi/.rubocop.yml +0 -8
  36. data/sorbet/rbi/gems/ansi@1.5.0.rbi +0 -338
  37. data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -522
  38. data/sorbet/rbi/gems/builder@3.2.4.rbi +0 -418
  39. data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -8
  40. data/sorbet/rbi/gems/debug@1.5.0.rbi +0 -1273
  41. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +0 -867
  42. data/sorbet/rbi/gems/io-console@0.5.11.rbi +0 -8
  43. data/sorbet/rbi/gems/irb@1.4.1.rbi +0 -376
  44. data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +0 -7325
  45. data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -8
  46. data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +0 -612
  47. data/sorbet/rbi/gems/minitest@5.15.0.rbi +0 -994
  48. data/sorbet/rbi/gems/parallel@1.22.1.rbi +0 -163
  49. data/sorbet/rbi/gems/parser@3.1.2.0.rbi +0 -3968
  50. data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +0 -734
  51. data/sorbet/rbi/gems/pry@0.14.1.rbi +0 -8
  52. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +0 -227
  53. data/sorbet/rbi/gems/rake@13.0.6.rbi +0 -1853
  54. data/sorbet/rbi/gems/rbi@0.0.14.rbi +0 -2337
  55. data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +0 -1854
  56. data/sorbet/rbi/gems/reline@0.3.1.rbi +0 -1274
  57. data/sorbet/rbi/gems/rexml@3.2.5.rbi +0 -3852
  58. data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +0 -4180
  59. data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +0 -1369
  60. data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +0 -246
  61. data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +0 -8
  62. data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +0 -652
  63. data/sorbet/rbi/gems/rubocop@1.30.0.rbi +0 -36729
  64. data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +0 -732
  65. data/sorbet/rbi/gems/spoom@1.1.11.rbi +0 -1600
  66. data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +0 -6777
  67. data/sorbet/rbi/gems/tapioca@0.8.1.rbi +0 -1972
  68. data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -2921
  69. data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +0 -27
  70. data/sorbet/rbi/gems/unparser@0.6.5.rbi +0 -2789
  71. data/sorbet/rbi/gems/webrick@1.7.0.rbi +0 -1779
  72. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +0 -289
  73. data/sorbet/rbi/gems/yard@0.9.27.rbi +0 -13048
  74. data/sorbet/rbi/shims/fiddle.rbi +0 -4
  75. data/sorbet/rbi/shims/hash.rbi +0 -6
  76. data/sorbet/rbi/shims/rdoc.rbi +0 -4
  77. data/sorbet/tapioca/config.yml +0 -13
  78. data/sorbet/tapioca/require.rb +0 -7
@@ -1,867 +0,0 @@
1
- # typed: true
2
-
3
- # DO NOT EDIT MANUALLY
4
- # This is an autogenerated file for types exported from the `diff-lcs` gem.
5
- # Please instead update this file by running `bin/tapioca gem diff-lcs`.
6
-
7
- module Diff; end
8
-
9
- module Diff::LCS
10
- # Returns the difference set between +self+ and +other+. See Diff::LCS#diff.
11
- def diff(other, callbacks = T.unsafe(nil), &block); end
12
-
13
- # Returns an Array containing the longest common subsequence(s) between
14
- # +self+ and +other+. See Diff::LCS#lcs.
15
- #
16
- # lcs = seq1.lcs(seq2)
17
- #
18
- # A note when using objects: Diff::LCS only works properly when each object
19
- # can be used as a key in a Hash, which typically means that the objects must
20
- # implement Object#eql? in a way that two identical values compare
21
- # identically for key purposes. That is:
22
- #
23
- # O.new('a').eql?(O.new('a')) == true
24
- def lcs(other, &block); end
25
-
26
- # Attempts to patch +self+ with the provided +patchset+. A new sequence based
27
- # on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Attempts
28
- # to autodiscover the direction of the patch.
29
- def patch(patchset); end
30
-
31
- # Attempts to patch +self+ with the provided +patchset+. A new sequence based
32
- # on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Does no
33
- # patch direction autodiscovery.
34
- def patch!(patchset); end
35
-
36
- # Attempts to patch +self+ with the provided +patchset+, using #patch!. If
37
- # the sequence this is used on supports #replace, the value of +self+ will be
38
- # replaced. See Diff::LCS#patch. Does no patch direction autodiscovery.
39
- def patch_me(patchset); end
40
-
41
- # Returns the balanced ("side-by-side") difference set between +self+ and
42
- # +other+. See Diff::LCS#sdiff.
43
- def sdiff(other, callbacks = T.unsafe(nil), &block); end
44
-
45
- # Traverses the discovered longest common subsequences between +self+ and
46
- # +other+ using the alternate, balanced algorithm. See
47
- # Diff::LCS#traverse_balanced.
48
- def traverse_balanced(other, callbacks = T.unsafe(nil), &block); end
49
-
50
- # Traverses the discovered longest common subsequences between +self+ and
51
- # +other+. See Diff::LCS#traverse_sequences.
52
- def traverse_sequences(other, callbacks = T.unsafe(nil), &block); end
53
-
54
- # Attempts to patch +self+ with the provided +patchset+. A new sequence based
55
- # on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Attempts
56
- # to autodiscover the direction of the patch.
57
- def unpatch(patchset); end
58
-
59
- # Attempts to unpatch +self+ with the provided +patchset+. A new sequence
60
- # based on +self+ and the +patchset+ will be created. See Diff::LCS#unpatch.
61
- # Does no patch direction autodiscovery.
62
- def unpatch!(patchset); end
63
-
64
- # Attempts to unpatch +self+ with the provided +patchset+, using #unpatch!.
65
- # If the sequence this is used on supports #replace, the value of +self+ will
66
- # be replaced. See Diff::LCS#unpatch. Does no patch direction autodiscovery.
67
- def unpatch_me(patchset); end
68
-
69
- class << self
70
- # :yields seq1[i] for each matched:
71
- def LCS(seq1, seq2, &block); end
72
-
73
- def callbacks_for(callbacks); end
74
-
75
- # #diff computes the smallest set of additions and deletions necessary to
76
- # turn the first sequence into the second, and returns a description of these
77
- # changes.
78
- #
79
- # See Diff::LCS::DiffCallbacks for the default behaviour. An alternate
80
- # behaviour may be implemented with Diff::LCS::ContextDiffCallbacks. If a
81
- # Class argument is provided for +callbacks+, #diff will attempt to
82
- # initialise it. If the +callbacks+ object (possibly initialised) responds to
83
- # #finish, it will be called.
84
- def diff(seq1, seq2, callbacks = T.unsafe(nil), &block); end
85
-
86
- # :yields seq1[i] for each matched:
87
- def lcs(seq1, seq2, &block); end
88
-
89
- # Applies a +patchset+ to the sequence +src+ according to the +direction+
90
- # (<tt>:patch</tt> or <tt>:unpatch</tt>), producing a new sequence.
91
- #
92
- # If the +direction+ is not specified, Diff::LCS::patch will attempt to
93
- # discover the direction of the +patchset+.
94
- #
95
- # A +patchset+ can be considered to apply forward (<tt>:patch</tt>) if the
96
- # following expression is true:
97
- #
98
- # patch(s1, diff(s1, s2)) -> s2
99
- #
100
- # A +patchset+ can be considered to apply backward (<tt>:unpatch</tt>) if the
101
- # following expression is true:
102
- #
103
- # patch(s2, diff(s1, s2)) -> s1
104
- #
105
- # If the +patchset+ contains no changes, the +src+ value will be returned as
106
- # either <tt>src.dup</tt> or +src+. A +patchset+ can be deemed as having no
107
- # changes if the following predicate returns true:
108
- #
109
- # patchset.empty? or
110
- # patchset.flatten(1).all? { |change| change.unchanged? }
111
- #
112
- # === Patchsets
113
- #
114
- # A +patchset+ is always an enumerable sequence of changes, hunks of changes,
115
- # or a mix of the two. A hunk of changes is an enumerable sequence of
116
- # changes:
117
- #
118
- # [ # patchset
119
- # # change
120
- # [ # hunk
121
- # # change
122
- # ]
123
- # ]
124
- #
125
- # The +patch+ method accepts <tt>patchset</tt>s that are enumerable sequences
126
- # containing either Diff::LCS::Change objects (or a subclass) or the array
127
- # representations of those objects. Prior to application, array
128
- # representations of Diff::LCS::Change objects will be reified.
129
- def patch(src, patchset, direction = T.unsafe(nil)); end
130
-
131
- # Given a set of patchset, convert the current version to the next version.
132
- # Does no auto-discovery.
133
- def patch!(src, patchset); end
134
-
135
- # #sdiff computes all necessary components to show two sequences and their
136
- # minimized differences side by side, just like the Unix utility
137
- # <em>sdiff</em> does:
138
- #
139
- # old < -
140
- # same same
141
- # before | after
142
- # - > new
143
- #
144
- # See Diff::LCS::SDiffCallbacks for the default behaviour. An alternate
145
- # behaviour may be implemented with Diff::LCS::ContextDiffCallbacks. If a
146
- # Class argument is provided for +callbacks+, #diff will attempt to
147
- # initialise it. If the +callbacks+ object (possibly initialised) responds to
148
- # #finish, it will be called.
149
- #
150
- # Each element of a returned array is a Diff::LCS::ContextChange object,
151
- # which can be implicitly converted to an array.
152
- #
153
- # Diff::LCS.sdiff(a, b).each do |action, (old_pos, old_element), (new_pos, new_element)|
154
- # case action
155
- # when '!'
156
- # # replace
157
- # when '-'
158
- # # delete
159
- # when '+'
160
- # # insert
161
- # end
162
- # end
163
- def sdiff(seq1, seq2, callbacks = T.unsafe(nil), &block); end
164
-
165
- # #traverse_balanced is an alternative to #traverse_sequences. It uses a
166
- # different algorithm to iterate through the entries in the computed longest
167
- # common subsequence. Instead of viewing the changes as insertions or
168
- # deletions from one of the sequences, #traverse_balanced will report
169
- # <em>changes</em> between the sequences.
170
- #
171
- # The arguments to #traverse_balanced are the two sequences to traverse and a
172
- # callback object, like this:
173
- #
174
- # traverse_balanced(seq1, seq2, Diff::LCS::ContextDiffCallbacks.new)
175
- #
176
- # #sdiff is implemented with #traverse_balanced.
177
- #
178
- # == Callback Methods
179
- #
180
- # Optional callback methods are <em>emphasized</em>.
181
- #
182
- # callbacks#match:: Called when +a+ and +b+ are pointing to
183
- # common elements in +A+ and +B+.
184
- # callbacks#discard_a:: Called when +a+ is pointing to an
185
- # element not in +B+.
186
- # callbacks#discard_b:: Called when +b+ is pointing to an
187
- # element not in +A+.
188
- # <em>callbacks#change</em>:: Called when +a+ and +b+ are pointing to
189
- # the same relative position, but
190
- # <tt>A[a]</tt> and <tt>B[b]</tt> are not
191
- # the same; a <em>change</em> has
192
- # occurred.
193
- #
194
- # #traverse_balanced might be a bit slower than #traverse_sequences,
195
- # noticable only while processing huge amounts of data.
196
- #
197
- # == Algorithm
198
- #
199
- # a---+
200
- # v
201
- # A = a b c e h j l m n p
202
- # B = b c d e f j k l m r s t
203
- # ^
204
- # b---+
205
- #
206
- # === Matches
207
- #
208
- # If there are two arrows (+a+ and +b+) pointing to elements of sequences +A+
209
- # and +B+, the arrows will initially point to the first elements of their
210
- # respective sequences. #traverse_sequences will advance the arrows through
211
- # the sequences one element at a time, calling a method on the user-specified
212
- # callback object before each advance. It will advance the arrows in such a
213
- # way that if there are elements <tt>A[i]</tt> and <tt>B[j]</tt> which are
214
- # both equal and part of the longest common subsequence, there will be some
215
- # moment during the execution of #traverse_sequences when arrow +a+ is
216
- # pointing to <tt>A[i]</tt> and arrow +b+ is pointing to <tt>B[j]</tt>. When
217
- # this happens, #traverse_sequences will call <tt>callbacks#match</tt> and
218
- # then it will advance both arrows.
219
- #
220
- # === Discards
221
- #
222
- # Otherwise, one of the arrows is pointing to an element of its sequence that
223
- # is not part of the longest common subsequence. #traverse_sequences will
224
- # advance that arrow and will call <tt>callbacks#discard_a</tt> or
225
- # <tt>callbacks#discard_b</tt>, depending on which arrow it advanced.
226
- #
227
- # === Changes
228
- #
229
- # If both +a+ and +b+ point to elements that are not part of the longest
230
- # common subsequence, then #traverse_sequences will try to call
231
- # <tt>callbacks#change</tt> and advance both arrows. If
232
- # <tt>callbacks#change</tt> is not implemented, then
233
- # <tt>callbacks#discard_a</tt> and <tt>callbacks#discard_b</tt> will be
234
- # called in turn.
235
- #
236
- # The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>,
237
- # <tt>callbacks#discard_b</tt>, and <tt>callbacks#change</tt> are invoked
238
- # with an event comprising the action ("=", "+", "-", or "!", respectively),
239
- # the indicies +i+ and +j+, and the elements <tt>A[i]</tt> and <tt>B[j]</tt>.
240
- # Return values are discarded by #traverse_balanced.
241
- #
242
- # === Context
243
- #
244
- # Note that +i+ and +j+ may not be the same index position, even if +a+ and
245
- # +b+ are considered to be pointing to matching or changed elements.
246
- def traverse_balanced(seq1, seq2, callbacks = T.unsafe(nil)); end
247
-
248
- # #traverse_sequences is the most general facility provided by this module;
249
- # #diff and #lcs are implemented as calls to it.
250
- #
251
- # The arguments to #traverse_sequences are the two sequences to traverse, and
252
- # a callback object, like this:
253
- #
254
- # traverse_sequences(seq1, seq2, Diff::LCS::ContextDiffCallbacks.new)
255
- #
256
- # == Callback Methods
257
- #
258
- # Optional callback methods are <em>emphasized</em>.
259
- #
260
- # callbacks#match:: Called when +a+ and +b+ are pointing to
261
- # common elements in +A+ and +B+.
262
- # callbacks#discard_a:: Called when +a+ is pointing to an
263
- # element not in +B+.
264
- # callbacks#discard_b:: Called when +b+ is pointing to an
265
- # element not in +A+.
266
- # <em>callbacks#finished_a</em>:: Called when +a+ has reached the end of
267
- # sequence +A+.
268
- # <em>callbacks#finished_b</em>:: Called when +b+ has reached the end of
269
- # sequence +B+.
270
- #
271
- # == Algorithm
272
- #
273
- # a---+
274
- # v
275
- # A = a b c e h j l m n p
276
- # B = b c d e f j k l m r s t
277
- # ^
278
- # b---+
279
- #
280
- # If there are two arrows (+a+ and +b+) pointing to elements of sequences +A+
281
- # and +B+, the arrows will initially point to the first elements of their
282
- # respective sequences. #traverse_sequences will advance the arrows through
283
- # the sequences one element at a time, calling a method on the user-specified
284
- # callback object before each advance. It will advance the arrows in such a
285
- # way that if there are elements <tt>A[i]</tt> and <tt>B[j]</tt> which are
286
- # both equal and part of the longest common subsequence, there will be some
287
- # moment during the execution of #traverse_sequences when arrow +a+ is
288
- # pointing to <tt>A[i]</tt> and arrow +b+ is pointing to <tt>B[j]</tt>. When
289
- # this happens, #traverse_sequences will call <tt>callbacks#match</tt> and
290
- # then it will advance both arrows.
291
- #
292
- # Otherwise, one of the arrows is pointing to an element of its sequence that
293
- # is not part of the longest common subsequence. #traverse_sequences will
294
- # advance that arrow and will call <tt>callbacks#discard_a</tt> or
295
- # <tt>callbacks#discard_b</tt>, depending on which arrow it advanced. If both
296
- # arrows point to elements that are not part of the longest common
297
- # subsequence, then #traverse_sequences will advance arrow +a+ and call the
298
- # appropriate callback, then it will advance arrow +b+ and call the appropriate
299
- # callback.
300
- #
301
- # The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>, and
302
- # <tt>callbacks#discard_b</tt> are invoked with an event comprising the
303
- # action ("=", "+", or "-", respectively), the indicies +i+ and +j+, and the
304
- # elements <tt>A[i]</tt> and <tt>B[j]</tt>. Return values are discarded by
305
- # #traverse_sequences.
306
- #
307
- # === End of Sequences
308
- #
309
- # If arrow +a+ reaches the end of its sequence before arrow +b+ does,
310
- # #traverse_sequence will try to call <tt>callbacks#finished_a</tt> with the
311
- # last index and element of +A+ (<tt>A[-1]</tt>) and the current index and
312
- # element of +B+ (<tt>B[j]</tt>). If <tt>callbacks#finished_a</tt> does not
313
- # exist, then <tt>callbacks#discard_b</tt> will be called on each element of
314
- # +B+ until the end of the sequence is reached (the call will be done with
315
- # <tt>A[-1]</tt> and <tt>B[j]</tt> for each element).
316
- #
317
- # If +b+ reaches the end of +B+ before +a+ reaches the end of +A+,
318
- # <tt>callbacks#finished_b</tt> will be called with the current index and
319
- # element of +A+ (<tt>A[i]</tt>) and the last index and element of +B+
320
- # (<tt>A[-1]</tt>). Again, if <tt>callbacks#finished_b</tt> does not exist on
321
- # the callback object, then <tt>callbacks#discard_a</tt> will be called on
322
- # each element of +A+ until the end of the sequence is reached (<tt>A[i]</tt>
323
- # and <tt>B[-1]</tt>).
324
- #
325
- # There is a chance that one additional <tt>callbacks#discard_a</tt> or
326
- # <tt>callbacks#discard_b</tt> will be called after the end of the sequence
327
- # is reached, if +a+ has not yet reached the end of +A+ or +b+ has not yet
328
- # reached the end of +B+.
329
- def traverse_sequences(seq1, seq2, callbacks = T.unsafe(nil)); end
330
-
331
- # Given a set of patchset, convert the current version to the prior version.
332
- # Does no auto-discovery.
333
- def unpatch!(src, patchset); end
334
-
335
- private
336
-
337
- def diff_traversal(method, seq1, seq2, callbacks, &block); end
338
- end
339
- end
340
-
341
- # An alias for DefaultCallbacks that is used in
342
- # Diff::LCS#traverse_balanced.
343
- #
344
- # Diff::LCS.LCS(seq1, seq2, Diff::LCS::BalancedCallbacks)
345
- Diff::LCS::BalancedCallbacks = Diff::LCS::DefaultCallbacks
346
-
347
- # A block is an operation removing, adding, or changing a group of items.
348
- # Basically, this is just a list of changes, where each change adds or
349
- # deletes a single item. Used by bin/ldiff.
350
- class Diff::LCS::Block
351
- # @return [Block] a new instance of Block
352
- def initialize(chunk); end
353
-
354
- # Returns the value of attribute changes.
355
- def changes; end
356
-
357
- def diff_size; end
358
-
359
- # Returns the value of attribute insert.
360
- def insert; end
361
-
362
- def op; end
363
-
364
- # Returns the value of attribute remove.
365
- def remove; end
366
- end
367
-
368
- # Represents a simplistic (non-contextual) change. Represents the removal or
369
- # addition of an element from either the old or the new sequenced
370
- # enumerable.
371
- class Diff::LCS::Change
372
- include ::Comparable
373
-
374
- # @return [Change] a new instance of Change
375
- def initialize(*args); end
376
-
377
- def <=>(other); end
378
- def ==(other); end
379
-
380
- # Returns the action this Change represents.
381
- def action; end
382
-
383
- # @return [Boolean]
384
- def adding?; end
385
-
386
- # @return [Boolean]
387
- def changed?; end
388
-
389
- # @return [Boolean]
390
- def deleting?; end
391
-
392
- # Returns the sequence element of the Change.
393
- def element; end
394
-
395
- # @return [Boolean]
396
- def finished_a?; end
397
-
398
- # @return [Boolean]
399
- def finished_b?; end
400
-
401
- def inspect(*_args); end
402
-
403
- # Returns the position of the Change.
404
- def position; end
405
-
406
- def to_a; end
407
- def to_ary; end
408
-
409
- # @return [Boolean]
410
- def unchanged?; end
411
-
412
- class << self
413
- def from_a(arr); end
414
-
415
- # @return [Boolean]
416
- def valid_action?(action); end
417
- end
418
- end
419
-
420
- Diff::LCS::Change::IntClass = Integer
421
-
422
- # The only actions valid for changes are '+' (add), '-' (delete), '='
423
- # (no change), '!' (changed), '<' (tail changes from first sequence), or
424
- # '>' (tail changes from second sequence). The last two ('<>') are only
425
- # found with Diff::LCS::diff and Diff::LCS::sdiff.
426
- Diff::LCS::Change::VALID_ACTIONS = T.let(T.unsafe(nil), Array)
427
-
428
- # Represents a contextual change. Contains the position and values of the
429
- # elements in the old and the new sequenced enumerables as well as the action
430
- # taken.
431
- class Diff::LCS::ContextChange < ::Diff::LCS::Change
432
- # @return [ContextChange] a new instance of ContextChange
433
- def initialize(*args); end
434
-
435
- def <=>(other); end
436
- def ==(other); end
437
-
438
- # Returns the new element being changed.
439
- def new_element; end
440
-
441
- # Returns the new position being changed.
442
- def new_position; end
443
-
444
- # Returns the old element being changed.
445
- def old_element; end
446
-
447
- # Returns the old position being changed.
448
- def old_position; end
449
-
450
- def to_a; end
451
- def to_ary; end
452
-
453
- class << self
454
- def from_a(arr); end
455
-
456
- # Simplifies a context change for use in some diff callbacks. '<' actions
457
- # are converted to '-' and '>' actions are converted to '+'.
458
- def simplify(event); end
459
- end
460
- end
461
-
462
- # This will produce a compound array of contextual diff change objects. Each
463
- # element in the #diffs array is a "hunk" array, where each element in each
464
- # "hunk" array is a single change. Each change is a Diff::LCS::ContextChange
465
- # that contains both the old index and new index values for the change. The
466
- # "hunk" provides the full context for the changes. Both old and new objects
467
- # will be presented for changed objects. +nil+ will be substituted for a
468
- # discarded object.
469
- #
470
- # seq1 = %w(a b c e h j l m n p)
471
- # seq2 = %w(b c d e f j k l m r s t)
472
- #
473
- # diffs = Diff::LCS.diff(seq1, seq2, Diff::LCS::ContextDiffCallbacks)
474
- # # This example shows a simplified array format.
475
- # # [ [ [ '-', [ 0, 'a' ], [ 0, nil ] ] ], # 1
476
- # # [ [ '+', [ 3, nil ], [ 2, 'd' ] ] ], # 2
477
- # # [ [ '-', [ 4, 'h' ], [ 4, nil ] ], # 3
478
- # # [ '+', [ 5, nil ], [ 4, 'f' ] ] ],
479
- # # [ [ '+', [ 6, nil ], [ 6, 'k' ] ] ], # 4
480
- # # [ [ '-', [ 8, 'n' ], [ 9, nil ] ], # 5
481
- # # [ '+', [ 9, nil ], [ 9, 'r' ] ],
482
- # # [ '-', [ 9, 'p' ], [ 10, nil ] ],
483
- # # [ '+', [ 10, nil ], [ 10, 's' ] ],
484
- # # [ '+', [ 10, nil ], [ 11, 't' ] ] ] ]
485
- #
486
- # The five hunks shown are comprised of individual changes; if there is a
487
- # related set of changes, they are still shown individually.
488
- #
489
- # This callback can also be used with Diff::LCS#sdiff, which will produce
490
- # results like:
491
- #
492
- # diffs = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextCallbacks)
493
- # # This example shows a simplified array format.
494
- # # [ [ [ "-", [ 0, "a" ], [ 0, nil ] ] ], # 1
495
- # # [ [ "+", [ 3, nil ], [ 2, "d" ] ] ], # 2
496
- # # [ [ "!", [ 4, "h" ], [ 4, "f" ] ] ], # 3
497
- # # [ [ "+", [ 6, nil ], [ 6, "k" ] ] ], # 4
498
- # # [ [ "!", [ 8, "n" ], [ 9, "r" ] ], # 5
499
- # # [ "!", [ 9, "p" ], [ 10, "s" ] ],
500
- # # [ "+", [ 10, nil ], [ 11, "t" ] ] ] ]
501
- #
502
- # The five hunks are still present, but are significantly shorter in total
503
- # presentation, because changed items are shown as changes ("!") instead of
504
- # potentially "mismatched" pairs of additions and deletions.
505
- #
506
- # The result of this operation is similar to that of
507
- # Diff::LCS::SDiffCallbacks. They may be compared as:
508
- #
509
- # s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
510
- # c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten(1)
511
- #
512
- # s == c # -> true
513
- #
514
- # === Use
515
- #
516
- # This callback object must be initialised and can be used by the
517
- # Diff::LCS#diff or Diff::LCS#sdiff methods.
518
- #
519
- # cbo = Diff::LCS::ContextDiffCallbacks.new
520
- # Diff::LCS.LCS(seq1, seq2, cbo)
521
- # cbo.finish
522
- #
523
- # Note that the call to #finish is absolutely necessary, or the last set of
524
- # changes will not be visible. Alternatively, can be used as:
525
- #
526
- # cbo = Diff::LCS::ContextDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
527
- #
528
- # The necessary #finish call will be made.
529
- #
530
- # === Simplified Array Format
531
- #
532
- # The simplified array format used in the example above can be obtained
533
- # with:
534
- #
535
- # require 'pp'
536
- # pp diffs.map { |e| e.map { |f| f.to_a } }
537
- class Diff::LCS::ContextDiffCallbacks < ::Diff::LCS::DiffCallbacks
538
- def change(event); end
539
- def discard_a(event); end
540
- def discard_b(event); end
541
- end
542
-
543
- # This callback object implements the default set of callback events,
544
- # which only returns the event itself. Note that #finished_a and
545
- # #finished_b are not implemented -- I haven't yet figured out where they
546
- # would be useful.
547
- #
548
- # Note that this is intended to be called as is, e.g.,
549
- #
550
- # Diff::LCS.LCS(seq1, seq2, Diff::LCS::DefaultCallbacks)
551
- class Diff::LCS::DefaultCallbacks
552
- class << self
553
- # Called when both the old and new values have changed.
554
- def change(event); end
555
-
556
- # Called when the old value is discarded in favour of the new value.
557
- def discard_a(event); end
558
-
559
- # Called when the new value is discarded in favour of the old value.
560
- def discard_b(event); end
561
-
562
- # Called when two items match.
563
- def match(event); end
564
- end
565
- end
566
-
567
- # This will produce a compound array of simple diff change objects. Each
568
- # element in the #diffs array is a +hunk+ or +hunk+ array, where each
569
- # element in each +hunk+ array is a single Change object representing the
570
- # addition or removal of a single element from one of the two tested
571
- # sequences. The +hunk+ provides the full context for the changes.
572
- #
573
- # diffs = Diff::LCS.diff(seq1, seq2)
574
- # # This example shows a simplified array format.
575
- # # [ [ [ '-', 0, 'a' ] ], # 1
576
- # # [ [ '+', 2, 'd' ] ], # 2
577
- # # [ [ '-', 4, 'h' ], # 3
578
- # # [ '+', 4, 'f' ] ],
579
- # # [ [ '+', 6, 'k' ] ], # 4
580
- # # [ [ '-', 8, 'n' ], # 5
581
- # # [ '-', 9, 'p' ],
582
- # # [ '+', 9, 'r' ],
583
- # # [ '+', 10, 's' ],
584
- # # [ '+', 11, 't' ] ] ]
585
- #
586
- # There are five hunks here. The first hunk says that the +a+ at position 0
587
- # of the first sequence should be deleted (<tt>'-'</tt>). The second hunk
588
- # says that the +d+ at position 2 of the second sequence should be inserted
589
- # (<tt>'+'</tt>). The third hunk says that the +h+ at position 4 of the
590
- # first sequence should be removed and replaced with the +f+ from position 4
591
- # of the second sequence. The other two hunks are described similarly.
592
- #
593
- # === Use
594
- #
595
- # This callback object must be initialised and is used by the Diff::LCS#diff
596
- # method.
597
- #
598
- # cbo = Diff::LCS::DiffCallbacks.new
599
- # Diff::LCS.LCS(seq1, seq2, cbo)
600
- # cbo.finish
601
- #
602
- # Note that the call to #finish is absolutely necessary, or the last set of
603
- # changes will not be visible. Alternatively, can be used as:
604
- #
605
- # cbo = Diff::LCS::DiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
606
- #
607
- # The necessary #finish call will be made.
608
- #
609
- # === Simplified Array Format
610
- #
611
- # The simplified array format used in the example above can be obtained
612
- # with:
613
- #
614
- # require 'pp'
615
- # pp diffs.map { |e| e.map { |f| f.to_a } }
616
- class Diff::LCS::DiffCallbacks
617
- # :yields self:
618
- #
619
- # @return [DiffCallbacks] a new instance of DiffCallbacks
620
- def initialize; end
621
-
622
- # Returns the difference set collected during the diff process.
623
- def diffs; end
624
-
625
- def discard_a(event); end
626
- def discard_b(event); end
627
-
628
- # Finalizes the diff process. If an unprocessed hunk still exists, then it
629
- # is appended to the diff list.
630
- def finish; end
631
-
632
- def match(_event); end
633
-
634
- private
635
-
636
- def finish_hunk; end
637
- end
638
-
639
- # A Hunk is a group of Blocks which overlap because of the context surrounding
640
- # each block. (So if we're not using context, every hunk will contain one
641
- # block.) Used in the diff program (bin/ldiff).
642
- class Diff::LCS::Hunk
643
- # Create a hunk using references to both the old and new data, as well as the
644
- # piece of data.
645
- #
646
- # @return [Hunk] a new instance of Hunk
647
- def initialize(data_old, data_new, piece, flag_context, file_length_difference); end
648
-
649
- # Returns the value of attribute blocks.
650
- def blocks; end
651
-
652
- # Returns a diff string based on a format.
653
- def diff(format, last = T.unsafe(nil)); end
654
-
655
- # Returns the value of attribute end_new.
656
- def end_new; end
657
-
658
- # Returns the value of attribute end_old.
659
- def end_old; end
660
-
661
- # Returns the value of attribute file_length_difference.
662
- def file_length_difference; end
663
-
664
- # Change the "start" and "end" fields to note that context should be added
665
- # to this hunk.
666
- def flag_context; end
667
-
668
- def flag_context=(context); end
669
-
670
- # Merges this hunk and the provided hunk together if they overlap. Returns
671
- # a truthy value so that if there is no overlap, you can know the merge
672
- # was skipped.
673
- def merge(hunk); end
674
-
675
- # @return [Boolean]
676
- def missing_last_newline?(data); end
677
-
678
- # Determines whether there is an overlap between this hunk and the
679
- # provided hunk. This will be true if the difference between the two hunks
680
- # start or end positions is within one position of each other.
681
- #
682
- # @return [Boolean]
683
- def overlaps?(hunk); end
684
-
685
- # Returns the value of attribute start_new.
686
- def start_new; end
687
-
688
- # Returns the value of attribute start_old.
689
- def start_old; end
690
-
691
- # Merges this hunk and the provided hunk together if they overlap. Returns
692
- # a truthy value so that if there is no overlap, you can know the merge
693
- # was skipped.
694
- def unshift(hunk); end
695
-
696
- private
697
-
698
- def context_diff(last = T.unsafe(nil)); end
699
-
700
- # Generate a range of item numbers to print. Only print 1 number if the
701
- # range has only one item in it. Otherwise, it's 'start,end'
702
- def context_range(mode, op, last = T.unsafe(nil)); end
703
-
704
- def ed_diff(format, _last = T.unsafe(nil)); end
705
- def encode(literal, target_encoding = T.unsafe(nil)); end
706
- def encode_as(string, *args); end
707
-
708
- # Note that an old diff can't have any context. Therefore, we know that
709
- # there's only one block in the hunk.
710
- def old_diff(_last = T.unsafe(nil)); end
711
-
712
- def unified_diff(last = T.unsafe(nil)); end
713
-
714
- # Generate a range of item numbers to print for unified diff. Print number
715
- # where block starts, followed by number of lines in the block
716
- # (don't print number of lines if it's 1)
717
- def unified_range(mode, last); end
718
- end
719
-
720
- Diff::LCS::Hunk::ED_DIFF_OP_ACTION = T.let(T.unsafe(nil), Hash)
721
- Diff::LCS::Hunk::OLD_DIFF_OP_ACTION = T.let(T.unsafe(nil), Hash)
722
-
723
- module Diff::LCS::Internals
724
- class << self
725
- # This method will analyze the provided patchset to provide a single-pass
726
- # normalization (conversion of the array form of Diff::LCS::Change objects to
727
- # the object form of same) and detection of whether the patchset represents
728
- # changes to be made.
729
- def analyze_patchset(patchset, depth = T.unsafe(nil)); end
730
-
731
- # Examine the patchset and the source to see in which direction the
732
- # patch should be applied.
733
- #
734
- # WARNING: By default, this examines the whole patch, so this could take
735
- # some time. This also works better with Diff::LCS::ContextChange or
736
- # Diff::LCS::Change as its source, as an array will cause the creation
737
- # of one of the above.
738
- def intuit_diff_direction(src, patchset, limit = T.unsafe(nil)); end
739
-
740
- # Compute the longest common subsequence between the sequenced
741
- # Enumerables +a+ and +b+. The result is an array whose contents is such
742
- # that
743
- #
744
- # result = Diff::LCS::Internals.lcs(a, b)
745
- # result.each_with_index do |e, i|
746
- # assert_equal(a[i], b[e]) unless e.nil?
747
- # end
748
- def lcs(a, b); end
749
-
750
- private
751
-
752
- # If +vector+ maps the matching elements of another collection onto this
753
- # Enumerable, compute the inverse of +vector+ that maps this Enumerable
754
- # onto the collection. (Currently unused.)
755
- def inverse_vector(a, vector); end
756
-
757
- # Returns a hash mapping each element of an Enumerable to the set of
758
- # positions it occupies in the Enumerable, optionally restricted to the
759
- # elements specified in the range of indexes specified by +interval+.
760
- def position_hash(enum, interval); end
761
-
762
- # Find the place at which +value+ would normally be inserted into the
763
- # Enumerable. If that place is already occupied by +value+, do nothing
764
- # and return +nil+. If the place does not exist (i.e., it is off the end
765
- # of the Enumerable), add it to the end. Otherwise, replace the element
766
- # at that point with +value+. It is assumed that the Enumerable's values
767
- # are numeric.
768
- #
769
- # This operation preserves the sort order.
770
- def replace_next_larger(enum, value, last_index = T.unsafe(nil)); end
771
- end
772
- end
773
-
774
- # This will produce a simple array of diff change objects. Each element in
775
- # the #diffs array is a single ContextChange. In the set of #diffs provided
776
- # by SDiffCallbacks, both old and new objects will be presented for both
777
- # changed <strong>and unchanged</strong> objects. +nil+ will be substituted
778
- # for a discarded object.
779
- #
780
- # The diffset produced by this callback, when provided to Diff::LCS#sdiff,
781
- # will compute and display the necessary components to show two sequences
782
- # and their minimized differences side by side, just like the Unix utility
783
- # +sdiff+.
784
- #
785
- # same same
786
- # before | after
787
- # old < -
788
- # - > new
789
- #
790
- # seq1 = %w(a b c e h j l m n p)
791
- # seq2 = %w(b c d e f j k l m r s t)
792
- #
793
- # diffs = Diff::LCS.sdiff(seq1, seq2)
794
- # # This example shows a simplified array format.
795
- # # [ [ "-", [ 0, "a"], [ 0, nil ] ],
796
- # # [ "=", [ 1, "b"], [ 0, "b" ] ],
797
- # # [ "=", [ 2, "c"], [ 1, "c" ] ],
798
- # # [ "+", [ 3, nil], [ 2, "d" ] ],
799
- # # [ "=", [ 3, "e"], [ 3, "e" ] ],
800
- # # [ "!", [ 4, "h"], [ 4, "f" ] ],
801
- # # [ "=", [ 5, "j"], [ 5, "j" ] ],
802
- # # [ "+", [ 6, nil], [ 6, "k" ] ],
803
- # # [ "=", [ 6, "l"], [ 7, "l" ] ],
804
- # # [ "=", [ 7, "m"], [ 8, "m" ] ],
805
- # # [ "!", [ 8, "n"], [ 9, "r" ] ],
806
- # # [ "!", [ 9, "p"], [ 10, "s" ] ],
807
- # # [ "+", [ 10, nil], [ 11, "t" ] ] ]
808
- #
809
- # The result of this operation is similar to that of
810
- # Diff::LCS::ContextDiffCallbacks. They may be compared as:
811
- #
812
- # s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
813
- # c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten(1)
814
- #
815
- # s == c # -> true
816
- #
817
- # === Use
818
- #
819
- # This callback object must be initialised and is used by the Diff::LCS#sdiff
820
- # method.
821
- #
822
- # cbo = Diff::LCS::SDiffCallbacks.new
823
- # Diff::LCS.LCS(seq1, seq2, cbo)
824
- #
825
- # As with the other initialisable callback objects,
826
- # Diff::LCS::SDiffCallbacks can be initialised with a block. As there is no
827
- # "fininishing" to be done, this has no effect on the state of the object.
828
- #
829
- # cbo = Diff::LCS::SDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
830
- #
831
- # === Simplified Array Format
832
- #
833
- # The simplified array format used in the example above can be obtained
834
- # with:
835
- #
836
- # require 'pp'
837
- # pp diffs.map { |e| e.to_a }
838
- class Diff::LCS::SDiffCallbacks
839
- # :yields self:
840
- #
841
- # @return [SDiffCallbacks] a new instance of SDiffCallbacks
842
- # @yield [_self]
843
- # @yieldparam _self [Diff::LCS::SDiffCallbacks] the object that the method was called on
844
- def initialize; end
845
-
846
- def change(event); end
847
-
848
- # Returns the difference set collected during the diff process.
849
- def diffs; end
850
-
851
- def discard_a(event); end
852
- def discard_b(event); end
853
- def match(event); end
854
- end
855
-
856
- # An alias for DefaultCallbacks that is used in
857
- # Diff::LCS#traverse_sequences.
858
- #
859
- # Diff::LCS.LCS(seq1, seq2, Diff::LCS::SequenceCallbacks)
860
- Diff::LCS::SequenceCallbacks = Diff::LCS::DefaultCallbacks
861
-
862
- Diff::LCS::VERSION = T.let(T.unsafe(nil), String)
863
-
864
- # Enhance the Integer class with a XML escaped character conversion.
865
- class Integer < ::Numeric
866
- include ::JSON::Ext::Generator::GeneratorMethods::Integer
867
- end