ruby-lsp 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -16
- data/.github/pull_request_template.md +15 -0
- data/.github/workflows/ci.yml +31 -0
- data/.github/workflows/publish_docs.yml +32 -0
- data/.gitignore +9 -12
- data/.rubocop.yml +20 -2
- data/.vscode/settings.json +5 -0
- data/CHANGELOG.md +29 -0
- data/Gemfile +8 -4
- data/Gemfile.lock +76 -14
- data/README.md +69 -2
- data/Rakefile +5 -0
- data/VERSION +1 -1
- data/bin/tapioca +29 -0
- data/bin/test +7 -1
- data/dev.yml +7 -7
- data/exe/ruby-lsp +19 -2
- data/lib/internal.rb +7 -0
- data/lib/ruby-lsp.rb +4 -1
- data/lib/ruby_lsp/cli.rb +88 -0
- data/lib/ruby_lsp/document.rb +113 -0
- data/lib/ruby_lsp/handler.rb +236 -0
- data/lib/ruby_lsp/requests/base_request.rb +33 -0
- data/lib/ruby_lsp/requests/code_actions.rb +37 -0
- data/lib/ruby_lsp/requests/diagnostics.rb +37 -0
- data/lib/ruby_lsp/requests/document_highlight.rb +96 -0
- data/lib/ruby_lsp/requests/document_symbol.rb +216 -0
- data/lib/ruby_lsp/requests/folding_ranges.rb +213 -0
- data/lib/ruby_lsp/requests/formatting.rb +52 -0
- data/lib/ruby_lsp/requests/rubocop_request.rb +50 -0
- data/lib/ruby_lsp/requests/selection_ranges.rb +103 -0
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +112 -0
- data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +88 -0
- data/lib/ruby_lsp/requests/support/selection_range.rb +17 -0
- data/lib/ruby_lsp/requests/support/semantic_token_encoder.rb +60 -0
- data/lib/ruby_lsp/requests/support/syntax_error_diagnostic.rb +27 -0
- data/lib/ruby_lsp/requests.rb +24 -0
- data/lib/ruby_lsp/store.rb +59 -0
- data/rakelib/check_docs.rake +56 -0
- data/ruby-lsp.gemspec +5 -1
- data/{shipit.yml → shipit.production.yml} +0 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/.rubocop.yml +8 -0
- data/sorbet/rbi/gems/ansi@1.5.0.rbi +338 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +522 -0
- data/sorbet/rbi/gems/builder@3.2.4.rbi +418 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
- data/sorbet/rbi/gems/debug@1.5.0.rbi +1273 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +867 -0
- data/sorbet/rbi/gems/io-console@0.5.11.rbi +8 -0
- data/sorbet/rbi/gems/irb@1.4.1.rbi +376 -0
- data/sorbet/rbi/gems/language_server-protocol@3.16.0.3.rbi +7325 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
- data/sorbet/rbi/gems/minitest-reporters@1.5.0.rbi +612 -0
- data/sorbet/rbi/gems/minitest@5.15.0.rbi +994 -0
- data/sorbet/rbi/gems/parallel@1.22.1.rbi +163 -0
- data/sorbet/rbi/gems/parser@3.1.2.0.rbi +3968 -0
- data/sorbet/rbi/gems/prettier_print@0.1.0.rbi +734 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +227 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +1853 -0
- data/sorbet/rbi/gems/rbi@0.0.14.rbi +2337 -0
- data/sorbet/rbi/gems/regexp_parser@2.5.0.rbi +1854 -0
- data/sorbet/rbi/gems/reline@0.3.1.rbi +1274 -0
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +3852 -0
- data/sorbet/rbi/gems/rubocop-ast@1.18.0.rbi +4180 -0
- data/sorbet/rbi/gems/rubocop-minitest@0.20.0.rbi +1369 -0
- data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +246 -0
- data/sorbet/rbi/gems/rubocop-shopify@2.6.0.rbi +8 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.6.8.rbi +652 -0
- data/sorbet/rbi/gems/rubocop@1.30.0.rbi +36729 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +732 -0
- data/sorbet/rbi/gems/spoom@1.1.11.rbi +1600 -0
- data/sorbet/rbi/gems/syntax_tree@2.7.1.rbi +6777 -0
- data/sorbet/rbi/gems/tapioca@0.8.1.rbi +1972 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +2921 -0
- data/sorbet/rbi/gems/unicode-display_width@2.1.0.rbi +27 -0
- data/sorbet/rbi/gems/unparser@0.6.5.rbi +2789 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +1779 -0
- data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +289 -0
- data/sorbet/rbi/gems/yard@0.9.27.rbi +13048 -0
- data/sorbet/rbi/shims/fiddle.rbi +4 -0
- data/sorbet/rbi/shims/hash.rbi +6 -0
- data/sorbet/rbi/shims/rdoc.rbi +4 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +7 -0
- metadata +119 -9
- data/.vscode/launch.json +0 -19
- data/bin/package_extension +0 -5
- data/bin/style +0 -10
- data/lib/ruby/lsp/cli.rb +0 -37
- data/lib/ruby/lsp.rb +0 -3
@@ -0,0 +1,734 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `prettier_print` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem prettier_print`.
|
6
|
+
|
7
|
+
# This class implements a pretty printing algorithm. It finds line breaks and
|
8
|
+
# nice indentations for grouped structure.
|
9
|
+
#
|
10
|
+
# By default, the class assumes that primitive elements are strings and each
|
11
|
+
# byte in the strings is a single column in width. But it can be used for other
|
12
|
+
# situations by giving suitable arguments for some methods:
|
13
|
+
#
|
14
|
+
# * newline object and space generation block for PrettierPrint.new
|
15
|
+
# * optional width argument for PrettierPrint#text
|
16
|
+
# * PrettierPrint#breakable
|
17
|
+
#
|
18
|
+
# There are several candidate uses:
|
19
|
+
# * text formatting using proportional fonts
|
20
|
+
# * multibyte characters which has columns different to number of bytes
|
21
|
+
# * non-string formatting
|
22
|
+
#
|
23
|
+
# == Usage
|
24
|
+
#
|
25
|
+
# To use this module, you will need to generate a tree of print nodes that
|
26
|
+
# represent indentation and newline behavior before it gets sent to the printer.
|
27
|
+
# Each node has different semantics, depending on the desired output.
|
28
|
+
#
|
29
|
+
# The most basic node is a Text node. This represents plain text content that
|
30
|
+
# cannot be broken up even if it doesn't fit on one line. You would create one
|
31
|
+
# of those with the text method, as in:
|
32
|
+
#
|
33
|
+
# PrettierPrint.format { |q| q.text('my content') }
|
34
|
+
#
|
35
|
+
# No matter what the desired output width is, the output for the snippet above
|
36
|
+
# will always be the same.
|
37
|
+
#
|
38
|
+
# If you want to allow the printer to break up the content on the space
|
39
|
+
# character when there isn't enough width for the full string on the same line,
|
40
|
+
# you can use the Breakable and Group nodes. For example:
|
41
|
+
#
|
42
|
+
# PrettierPrint.format do |q|
|
43
|
+
# q.group do
|
44
|
+
# q.text("my")
|
45
|
+
# q.breakable
|
46
|
+
# q.text("content")
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# Now, if everything fits on one line (depending on the maximum width specified)
|
51
|
+
# then it will be the same output as the first example. If, however, there is
|
52
|
+
# not enough room on the line, then you will get two lines of output, one for
|
53
|
+
# the first string and one for the second.
|
54
|
+
#
|
55
|
+
# There are other nodes for the print tree as well, described in the
|
56
|
+
# documentation below. They control alignment, indentation, conditional
|
57
|
+
# formatting, and more.
|
58
|
+
#
|
59
|
+
# == References
|
60
|
+
# Christian Lindig, Strictly Pretty, March 2000
|
61
|
+
# https://lindig.github.io/papers/strictly-pretty-2000.pdf
|
62
|
+
#
|
63
|
+
# Philip Wadler, A prettier printer, March 1998
|
64
|
+
# https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
|
65
|
+
class PrettierPrint
|
66
|
+
# Creates a buffer for pretty printing.
|
67
|
+
#
|
68
|
+
# +output+ is an output target. If it is not specified, '' is assumed. It
|
69
|
+
# should have a << method which accepts the first argument +obj+ of
|
70
|
+
# PrettierPrint#text, the first argument +separator+ of PrettierPrint#breakable,
|
71
|
+
# the first argument +newline+ of PrettierPrint.new, and the result of a given
|
72
|
+
# block for PrettierPrint.new.
|
73
|
+
#
|
74
|
+
# +maxwidth+ specifies maximum line length. If it is not specified, 80 is
|
75
|
+
# assumed. However actual outputs may overflow +maxwidth+ if long
|
76
|
+
# non-breakable texts are provided.
|
77
|
+
#
|
78
|
+
# +newline+ is used for line breaks. "\n" is used if it is not specified.
|
79
|
+
#
|
80
|
+
# The block is used to generate spaces. ->(n) { ' ' * n } is used if it is not
|
81
|
+
# given.
|
82
|
+
#
|
83
|
+
# @return [PrettierPrint] a new instance of PrettierPrint
|
84
|
+
def initialize(output = T.unsafe(nil), maxwidth = T.unsafe(nil), newline = T.unsafe(nil), &genspace); end
|
85
|
+
|
86
|
+
# This inserts a BreakParent node into the print tree which forces the
|
87
|
+
# surrounding and all parent group nodes to break.
|
88
|
+
def break_parent; end
|
89
|
+
|
90
|
+
# This says "you can break a line here if necessary", and a +width+\-column
|
91
|
+
# text +separator+ is inserted if a line is not broken at the point.
|
92
|
+
#
|
93
|
+
# If +separator+ is not specified, ' ' is used.
|
94
|
+
#
|
95
|
+
# If +width+ is not specified, +separator.length+ is used. You will have to
|
96
|
+
# specify this when +separator+ is a multibyte character, for example.
|
97
|
+
#
|
98
|
+
# By default, if the surrounding group is broken and a newline is inserted,
|
99
|
+
# the printer will indent the subsequent line up to the current level of
|
100
|
+
# indentation. You can disable this behavior with the +indent+ argument if
|
101
|
+
# that's not desired (rare).
|
102
|
+
#
|
103
|
+
# By default, when you insert a Breakable into the print tree, it only breaks
|
104
|
+
# the surrounding group when the group's contents cannot fit onto the
|
105
|
+
# remaining space of the current line. You can force it to break the
|
106
|
+
# surrounding group instead if you always want the newline with the +force+
|
107
|
+
# argument.
|
108
|
+
#
|
109
|
+
# There are a few circumstances where you'll want to force the newline into
|
110
|
+
# the output but no insert a break parent (because you don't want to
|
111
|
+
# necessarily force the groups to break unless they need to). In this case you
|
112
|
+
# can pass `force: :skip_break_parent` to this method and it will not insert
|
113
|
+
# a break parent.`
|
114
|
+
def breakable(separator = T.unsafe(nil), width = T.unsafe(nil), indent: T.unsafe(nil), force: T.unsafe(nil)); end
|
115
|
+
|
116
|
+
# This is an output buffer that wraps the output object and provides
|
117
|
+
# additional functionality depending on its type.
|
118
|
+
#
|
119
|
+
# This defaults to Buffer::StringBuffer.new("".dup)
|
120
|
+
def buffer; end
|
121
|
+
|
122
|
+
# A convenience method which is same as follows:
|
123
|
+
#
|
124
|
+
# text(",")
|
125
|
+
# breakable
|
126
|
+
def comma_breakable; end
|
127
|
+
|
128
|
+
# Returns the group most recently added to the stack.
|
129
|
+
#
|
130
|
+
# Contrived example:
|
131
|
+
# out = ""
|
132
|
+
# => ""
|
133
|
+
# q = PrettierPrint.new(out)
|
134
|
+
# => #<PrettierPrint:0x0>
|
135
|
+
# q.group {
|
136
|
+
# q.text q.current_group.inspect
|
137
|
+
# q.text q.newline
|
138
|
+
# q.group(q.current_group.depth + 1) {
|
139
|
+
# q.text q.current_group.inspect
|
140
|
+
# q.text q.newline
|
141
|
+
# q.group(q.current_group.depth + 1) {
|
142
|
+
# q.text q.current_group.inspect
|
143
|
+
# q.text q.newline
|
144
|
+
# q.group(q.current_group.depth + 1) {
|
145
|
+
# q.text q.current_group.inspect
|
146
|
+
# q.text q.newline
|
147
|
+
# }
|
148
|
+
# }
|
149
|
+
# }
|
150
|
+
# }
|
151
|
+
# => 284
|
152
|
+
# puts out
|
153
|
+
# #<PrettierPrint::Group:0x0 @depth=1>
|
154
|
+
# #<PrettierPrint::Group:0x0 @depth=2>
|
155
|
+
# #<PrettierPrint::Group:0x0 @depth=3>
|
156
|
+
# #<PrettierPrint::Group:0x0 @depth=4>
|
157
|
+
def current_group; end
|
158
|
+
|
159
|
+
# This is similar to #breakable except the decision to break or not is
|
160
|
+
# determined individually.
|
161
|
+
#
|
162
|
+
# Two #fill_breakable under a group may cause 4 results:
|
163
|
+
# (break,break), (break,non-break), (non-break,break), (non-break,non-break).
|
164
|
+
# This is different to #breakable because two #breakable under a group
|
165
|
+
# may cause 2 results: (break,break), (non-break,non-break).
|
166
|
+
#
|
167
|
+
# The text +separator+ is inserted if a line is not broken at this point.
|
168
|
+
#
|
169
|
+
# If +separator+ is not specified, ' ' is used.
|
170
|
+
#
|
171
|
+
# If +width+ is not specified, +separator.length+ is used. You will have to
|
172
|
+
# specify this when +separator+ is a multibyte character, for example.
|
173
|
+
def fill_breakable(separator = T.unsafe(nil), width = T.unsafe(nil)); end
|
174
|
+
|
175
|
+
# Flushes all of the generated print tree onto the output buffer, then clears
|
176
|
+
# the generated tree from memory.
|
177
|
+
def flush; end
|
178
|
+
|
179
|
+
# An object that responds to call that takes one argument, of an Integer, and
|
180
|
+
# returns the corresponding number of spaces.
|
181
|
+
#
|
182
|
+
# By default this is: ->(n) { ' ' * n }
|
183
|
+
def genspace; end
|
184
|
+
|
185
|
+
# Groups line break hints added in the block. The line break hints are all to
|
186
|
+
# be used or not.
|
187
|
+
#
|
188
|
+
# If +indent+ is specified, the method call is regarded as nested by
|
189
|
+
# nest(indent) { ... }.
|
190
|
+
#
|
191
|
+
# If +open_object+ is specified, <tt>text(open_object, open_width)</tt> is
|
192
|
+
# called before grouping. If +close_object+ is specified,
|
193
|
+
# <tt>text(close_object, close_width)</tt> is called after grouping.
|
194
|
+
def group(indent = T.unsafe(nil), open_object = T.unsafe(nil), close_object = T.unsafe(nil), open_width = T.unsafe(nil), close_width = T.unsafe(nil)); end
|
195
|
+
|
196
|
+
# The stack of groups that are being printed.
|
197
|
+
def groups; end
|
198
|
+
|
199
|
+
# Inserts an IfBreak node with the contents of the block being added to its
|
200
|
+
# list of nodes that should be printed if the surrounding node breaks. If it
|
201
|
+
# doesn't, then you can specify the contents to be printed with the #if_flat
|
202
|
+
# method used on the return object from this method. For example,
|
203
|
+
#
|
204
|
+
# q.if_break { q.text('do') }.if_flat { q.text('{') }
|
205
|
+
#
|
206
|
+
# In the example above, if the surrounding group is broken it will print 'do'
|
207
|
+
# and if it is not it will print '{'.
|
208
|
+
def if_break; end
|
209
|
+
|
210
|
+
# This is similar to if_break in that it also inserts an IfBreak node into the
|
211
|
+
# print tree, however it's starting from the flat contents, and cannot be used
|
212
|
+
# to build the break contents.
|
213
|
+
def if_flat; end
|
214
|
+
|
215
|
+
# Very similar to the #nest method, this indents the nested content by one
|
216
|
+
# level by inserting an Indent node into the print tree. The contents of the
|
217
|
+
# node are determined by the block.
|
218
|
+
def indent; end
|
219
|
+
|
220
|
+
# This method calculates the position of the text relative to the current
|
221
|
+
# indentation level when the doc has been printed. It's useful for
|
222
|
+
# determining how to align text to doc nodes that are already built into the
|
223
|
+
# tree.
|
224
|
+
def last_position(node); end
|
225
|
+
|
226
|
+
# Inserts a LineSuffix node into the print tree. The contents of the node are
|
227
|
+
# determined by the block.
|
228
|
+
def line_suffix(priority: T.unsafe(nil)); end
|
229
|
+
|
230
|
+
# The maximum width of a line, before it is separated in to a newline
|
231
|
+
#
|
232
|
+
# This defaults to 80, and should be an Integer
|
233
|
+
def maxwidth; end
|
234
|
+
|
235
|
+
# Increases left margin after newline with +indent+ for line breaks added in
|
236
|
+
# the block.
|
237
|
+
def nest(indent); end
|
238
|
+
|
239
|
+
# The value that is appended to +output+ to add a new line.
|
240
|
+
#
|
241
|
+
# This defaults to "\n", and should be String
|
242
|
+
def newline; end
|
243
|
+
|
244
|
+
# The output object. It represents the final destination of the contents of
|
245
|
+
# the print tree. It should respond to <<.
|
246
|
+
#
|
247
|
+
# This defaults to "".dup
|
248
|
+
def output; end
|
249
|
+
|
250
|
+
# This method will remove any breakables from the list of contents so that
|
251
|
+
# no newlines are present in the output. If a newline is being forced into
|
252
|
+
# the output, the replace value will be used.
|
253
|
+
def remove_breaks(node, replace = T.unsafe(nil)); end
|
254
|
+
|
255
|
+
# Adds a separated list.
|
256
|
+
# The list is separated by comma with breakable space, by default.
|
257
|
+
#
|
258
|
+
# #seplist iterates the +list+ using +iter_method+.
|
259
|
+
# It yields each object to the block given for #seplist.
|
260
|
+
# The procedure +separator_proc+ is called between each yields.
|
261
|
+
#
|
262
|
+
# If the iteration is zero times, +separator_proc+ is not called at all.
|
263
|
+
#
|
264
|
+
# If +separator_proc+ is nil or not given,
|
265
|
+
# +lambda { comma_breakable }+ is used.
|
266
|
+
# If +iter_method+ is not given, :each is used.
|
267
|
+
#
|
268
|
+
# For example, following 3 code fragments has similar effect.
|
269
|
+
#
|
270
|
+
# q.seplist([1,2,3]) {|v| xxx v }
|
271
|
+
#
|
272
|
+
# q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v }
|
273
|
+
#
|
274
|
+
# xxx 1
|
275
|
+
# q.comma_breakable
|
276
|
+
# xxx 2
|
277
|
+
# q.comma_breakable
|
278
|
+
# xxx 3
|
279
|
+
def seplist(list, sep = T.unsafe(nil), iter_method = T.unsafe(nil)); end
|
280
|
+
|
281
|
+
# The current array of contents that calls to methods that generate print tree
|
282
|
+
# nodes will append to.
|
283
|
+
def target; end
|
284
|
+
|
285
|
+
# This adds +object+ as a text of +width+ columns in width.
|
286
|
+
#
|
287
|
+
# If +width+ is not specified, object.length is used.
|
288
|
+
def text(object = T.unsafe(nil), width = T.unsafe(nil)); end
|
289
|
+
|
290
|
+
# This inserts a Trim node into the print tree which, when printed, will clear
|
291
|
+
# all whitespace at the end of the output buffer. This is useful for the rare
|
292
|
+
# case where you need to delete printed indentation and force the next node
|
293
|
+
# to start at the beginning of the line.
|
294
|
+
def trim; end
|
295
|
+
|
296
|
+
# A convenience method used by a lot of the print tree node builders that
|
297
|
+
# temporarily changes the target that the builders will append to.
|
298
|
+
def with_target(target); end
|
299
|
+
|
300
|
+
private
|
301
|
+
|
302
|
+
# This method returns a boolean as to whether or not the remaining commands
|
303
|
+
# fit onto the remaining space on the current line. If we finish printing
|
304
|
+
# all of the commands or if we hit a newline, then we return true. Otherwise
|
305
|
+
# if we continue printing past the remaining space, we return false.
|
306
|
+
#
|
307
|
+
# @return [Boolean]
|
308
|
+
def fits?(next_command, rest_commands, remaining); end
|
309
|
+
|
310
|
+
def remove_breaks_with(doc, replace); end
|
311
|
+
|
312
|
+
# Resets the group stack and target array so that this pretty printer object
|
313
|
+
# can continue to be used before calling flush again if desired.
|
314
|
+
def reset; end
|
315
|
+
|
316
|
+
class << self
|
317
|
+
# This is a convenience method which is same as follows:
|
318
|
+
#
|
319
|
+
# begin
|
320
|
+
# q = PrettierPrint.new(output, maxwidth, newline, &genspace)
|
321
|
+
# ...
|
322
|
+
# q.flush
|
323
|
+
# output
|
324
|
+
# end
|
325
|
+
#
|
326
|
+
# @yield [q]
|
327
|
+
def format(output = T.unsafe(nil), maxwidth = T.unsafe(nil), newline = T.unsafe(nil), genspace = T.unsafe(nil)); end
|
328
|
+
|
329
|
+
# This is similar to PrettierPrint::format but the result has no breaks.
|
330
|
+
#
|
331
|
+
# +maxwidth+, +newline+ and +genspace+ are ignored.
|
332
|
+
#
|
333
|
+
# The invocation of +breakable+ in the block doesn't break a line and is
|
334
|
+
# treated as just an invocation of +text+.
|
335
|
+
#
|
336
|
+
# @yield [q]
|
337
|
+
def singleline_format(output = T.unsafe(nil), _maxwidth = T.unsafe(nil), _newline = T.unsafe(nil), _genspace = T.unsafe(nil)); end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
# A node in the print tree that represents aligning nested nodes to a certain
|
342
|
+
# prefix width or string.
|
343
|
+
class PrettierPrint::Align
|
344
|
+
# @return [Align] a new instance of Align
|
345
|
+
def initialize(indent:, contents: T.unsafe(nil)); end
|
346
|
+
|
347
|
+
# Returns the value of attribute contents.
|
348
|
+
def contents; end
|
349
|
+
|
350
|
+
# Returns the value of attribute indent.
|
351
|
+
def indent; end
|
352
|
+
|
353
|
+
def pretty_print(q); end
|
354
|
+
end
|
355
|
+
|
356
|
+
# A node in the print tree that forces the surrounding group to print out in
|
357
|
+
# the "break" mode as opposed to the "flat" mode. Useful for when you need to
|
358
|
+
# force a newline into a group.
|
359
|
+
class PrettierPrint::BreakParent
|
360
|
+
def pretty_print(q); end
|
361
|
+
end
|
362
|
+
|
363
|
+
# A node in the print tree that represents a place in the buffer that the
|
364
|
+
# content can be broken onto multiple lines.
|
365
|
+
class PrettierPrint::Breakable
|
366
|
+
# @return [Breakable] a new instance of Breakable
|
367
|
+
def initialize(separator = T.unsafe(nil), width = T.unsafe(nil), force: T.unsafe(nil), indent: T.unsafe(nil)); end
|
368
|
+
|
369
|
+
# @return [Boolean]
|
370
|
+
def force?; end
|
371
|
+
|
372
|
+
# @return [Boolean]
|
373
|
+
def indent?; end
|
374
|
+
|
375
|
+
def pretty_print(q); end
|
376
|
+
|
377
|
+
# Returns the value of attribute separator.
|
378
|
+
def separator; end
|
379
|
+
|
380
|
+
# Returns the value of attribute width.
|
381
|
+
def width; end
|
382
|
+
end
|
383
|
+
|
384
|
+
# When building up the contents in the output buffer, it's convenient to be
|
385
|
+
# able to trim trailing whitespace before newlines. If the output object is a
|
386
|
+
# string or array or strings, then we can do this with some gsub calls. If
|
387
|
+
# not, then this effectively just wraps the output object and forwards on
|
388
|
+
# calls to <<.
|
389
|
+
module PrettierPrint::Buffer
|
390
|
+
class << self
|
391
|
+
# This is a switch for building the correct output buffer wrapper class for
|
392
|
+
# the given output object.
|
393
|
+
def for(output); end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
# This is an output buffer that wraps an array output object. It provides a
|
398
|
+
# trim! method that trims off trailing whitespace from the last element in
|
399
|
+
# the array if it's an unfrozen string using the same method as the
|
400
|
+
# StringBuffer.
|
401
|
+
class PrettierPrint::Buffer::ArrayBuffer < ::PrettierPrint::Buffer::DefaultBuffer
|
402
|
+
# @return [ArrayBuffer] a new instance of ArrayBuffer
|
403
|
+
def initialize(output = T.unsafe(nil)); end
|
404
|
+
|
405
|
+
def trim!; end
|
406
|
+
end
|
407
|
+
|
408
|
+
# This is the default output buffer that provides a base implementation of
|
409
|
+
# trim! that does nothing. It's effectively a wrapper around whatever output
|
410
|
+
# object was given to the format command.
|
411
|
+
class PrettierPrint::Buffer::DefaultBuffer
|
412
|
+
# @return [DefaultBuffer] a new instance of DefaultBuffer
|
413
|
+
def initialize(output = T.unsafe(nil)); end
|
414
|
+
|
415
|
+
def <<(object); end
|
416
|
+
|
417
|
+
# Returns the value of attribute output.
|
418
|
+
def output; end
|
419
|
+
|
420
|
+
def trim!; end
|
421
|
+
end
|
422
|
+
|
423
|
+
# This is an output buffer that wraps a string output object. It provides a
|
424
|
+
# trim! method that trims off trailing whitespace from the string using
|
425
|
+
# gsub!.
|
426
|
+
class PrettierPrint::Buffer::StringBuffer < ::PrettierPrint::Buffer::DefaultBuffer
|
427
|
+
# @return [StringBuffer] a new instance of StringBuffer
|
428
|
+
def initialize(output = T.unsafe(nil)); end
|
429
|
+
|
430
|
+
def trim!; end
|
431
|
+
end
|
432
|
+
|
433
|
+
# When generating spaces after a newline for indentation, by default we
|
434
|
+
# generate one space per character needed for indentation. You can change this
|
435
|
+
# behavior (for instance to use tabs) by passing a different genspace
|
436
|
+
# procedure.
|
437
|
+
PrettierPrint::DEFAULT_GENSPACE = T.let(T.unsafe(nil), Proc)
|
438
|
+
|
439
|
+
# When printing, you can optionally specify the value that should be used
|
440
|
+
# whenever a group needs to be broken onto multiple lines. In this case the
|
441
|
+
# default is \n.
|
442
|
+
PrettierPrint::DEFAULT_NEWLINE = T.let(T.unsafe(nil), String)
|
443
|
+
|
444
|
+
# A node in the print tree that represents a group of items which the printer
|
445
|
+
# should try to fit onto one line. This is the basic command to tell the
|
446
|
+
# printer when to break. Groups are usually nested, and the printer will try
|
447
|
+
# to fit everything on one line, but if it doesn't fit it will break the
|
448
|
+
# outermost group first and try again. It will continue breaking groups until
|
449
|
+
# everything fits (or there are no more groups to break).
|
450
|
+
class PrettierPrint::Group
|
451
|
+
# @return [Group] a new instance of Group
|
452
|
+
def initialize(depth, contents: T.unsafe(nil)); end
|
453
|
+
|
454
|
+
def break; end
|
455
|
+
|
456
|
+
# @return [Boolean]
|
457
|
+
def break?; end
|
458
|
+
|
459
|
+
# Returns the value of attribute contents.
|
460
|
+
def contents; end
|
461
|
+
|
462
|
+
# Returns the value of attribute depth.
|
463
|
+
def depth; end
|
464
|
+
|
465
|
+
def pretty_print(q); end
|
466
|
+
end
|
467
|
+
|
468
|
+
# A node in the print tree that represents printing one thing if the
|
469
|
+
# surrounding group node is broken and another thing if the surrounding group
|
470
|
+
# node is flat.
|
471
|
+
class PrettierPrint::IfBreak
|
472
|
+
# @return [IfBreak] a new instance of IfBreak
|
473
|
+
def initialize(break_contents: T.unsafe(nil), flat_contents: T.unsafe(nil)); end
|
474
|
+
|
475
|
+
# Returns the value of attribute break_contents.
|
476
|
+
def break_contents; end
|
477
|
+
|
478
|
+
# Returns the value of attribute flat_contents.
|
479
|
+
def flat_contents; end
|
480
|
+
|
481
|
+
def pretty_print(q); end
|
482
|
+
end
|
483
|
+
|
484
|
+
# A small DSL-like object used for specifying the alternative contents to be
|
485
|
+
# printed if the surrounding group doesn't break for an IfBreak node.
|
486
|
+
class PrettierPrint::IfBreakBuilder
|
487
|
+
# @return [IfBreakBuilder] a new instance of IfBreakBuilder
|
488
|
+
def initialize(builder, if_break); end
|
489
|
+
|
490
|
+
# Returns the value of attribute builder.
|
491
|
+
def builder; end
|
492
|
+
|
493
|
+
# Returns the value of attribute if_break.
|
494
|
+
def if_break; end
|
495
|
+
|
496
|
+
def if_flat(&block); end
|
497
|
+
end
|
498
|
+
|
499
|
+
# A node in the print tree that is a variant of the Align node that indents
|
500
|
+
# its contents by one level.
|
501
|
+
class PrettierPrint::Indent
|
502
|
+
# @return [Indent] a new instance of Indent
|
503
|
+
def initialize(contents: T.unsafe(nil)); end
|
504
|
+
|
505
|
+
# Returns the value of attribute contents.
|
506
|
+
def contents; end
|
507
|
+
|
508
|
+
def pretty_print(q); end
|
509
|
+
end
|
510
|
+
|
511
|
+
# This object represents the current level of indentation within the printer.
|
512
|
+
# It has the ability to generate new levels of indentation through the #align
|
513
|
+
# and #indent methods.
|
514
|
+
class PrettierPrint::IndentLevel
|
515
|
+
# @return [IndentLevel] a new instance of IndentLevel
|
516
|
+
def initialize(genspace:, value: T.unsafe(nil), length: T.unsafe(nil), queue: T.unsafe(nil), root: T.unsafe(nil)); end
|
517
|
+
|
518
|
+
# This can accept a whole lot of different kinds of objects, due to the
|
519
|
+
# nature of the flexibility of the Align node.
|
520
|
+
def align(n); end
|
521
|
+
|
522
|
+
# Returns the value of attribute genspace.
|
523
|
+
def genspace; end
|
524
|
+
|
525
|
+
def indent(part = T.unsafe(nil)); end
|
526
|
+
|
527
|
+
# Returns the value of attribute length.
|
528
|
+
def length; end
|
529
|
+
|
530
|
+
# Returns the value of attribute queue.
|
531
|
+
def queue; end
|
532
|
+
|
533
|
+
# Returns the value of attribute root.
|
534
|
+
def root; end
|
535
|
+
|
536
|
+
# Returns the value of attribute value.
|
537
|
+
def value; end
|
538
|
+
end
|
539
|
+
|
540
|
+
PrettierPrint::IndentLevel::DedentPart = T.let(T.unsafe(nil), Object)
|
541
|
+
PrettierPrint::IndentLevel::IndentPart = T.let(T.unsafe(nil), Object)
|
542
|
+
|
543
|
+
class PrettierPrint::IndentLevel::NumberAlignPart < ::Struct
|
544
|
+
# Returns the value of attribute n
|
545
|
+
#
|
546
|
+
# @return [Object] the current value of n
|
547
|
+
def n; end
|
548
|
+
|
549
|
+
# Sets the attribute n
|
550
|
+
#
|
551
|
+
# @param value [Object] the value to set the attribute n to.
|
552
|
+
# @return [Object] the newly set value
|
553
|
+
def n=(_); end
|
554
|
+
|
555
|
+
class << self
|
556
|
+
def [](*_arg0); end
|
557
|
+
def inspect; end
|
558
|
+
def keyword_init?; end
|
559
|
+
def members; end
|
560
|
+
def new(*_arg0); end
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
564
|
+
class PrettierPrint::IndentLevel::StringAlignPart < ::Struct
|
565
|
+
# Returns the value of attribute n
|
566
|
+
#
|
567
|
+
# @return [Object] the current value of n
|
568
|
+
def n; end
|
569
|
+
|
570
|
+
# Sets the attribute n
|
571
|
+
#
|
572
|
+
# @param value [Object] the value to set the attribute n to.
|
573
|
+
# @return [Object] the newly set value
|
574
|
+
def n=(_); end
|
575
|
+
|
576
|
+
class << self
|
577
|
+
def [](*_arg0); end
|
578
|
+
def inspect; end
|
579
|
+
def keyword_init?; end
|
580
|
+
def members; end
|
581
|
+
def new(*_arg0); end
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
# A node in the print tree that has its own special buffer for implementing
|
586
|
+
# content that should flush before any newline.
|
587
|
+
#
|
588
|
+
# Useful for implementating trailing content, as it's not always practical to
|
589
|
+
# constantly check where the line ends to avoid accidentally printing some
|
590
|
+
# content after a line suffix node.
|
591
|
+
class PrettierPrint::LineSuffix
|
592
|
+
# @return [LineSuffix] a new instance of LineSuffix
|
593
|
+
def initialize(priority: T.unsafe(nil), contents: T.unsafe(nil)); end
|
594
|
+
|
595
|
+
# Returns the value of attribute contents.
|
596
|
+
def contents; end
|
597
|
+
|
598
|
+
def pretty_print(q); end
|
599
|
+
|
600
|
+
# Returns the value of attribute priority.
|
601
|
+
def priority; end
|
602
|
+
end
|
603
|
+
|
604
|
+
PrettierPrint::LineSuffix::DEFAULT_PRIORITY = T.let(T.unsafe(nil), Integer)
|
605
|
+
|
606
|
+
# There are two modes in printing, break and flat. When we're in break mode,
|
607
|
+
# any lines will use their newline, any if-breaks will use their break
|
608
|
+
# contents, etc.
|
609
|
+
PrettierPrint::MODE_BREAK = T.let(T.unsafe(nil), Integer)
|
610
|
+
|
611
|
+
# This is another print mode much like MODE_BREAK. When we're in flat mode, we
|
612
|
+
# attempt to print everything on one line until we either hit a broken group,
|
613
|
+
# a forced line, or the maximum width.
|
614
|
+
PrettierPrint::MODE_FLAT = T.let(T.unsafe(nil), Integer)
|
615
|
+
|
616
|
+
# PrettierPrint::SingleLine is used by PrettierPrint.singleline_format
|
617
|
+
#
|
618
|
+
# It is passed to be similar to a PrettierPrint object itself, by responding to
|
619
|
+
# all of the same print tree node builder methods, as well as the #flush
|
620
|
+
# method.
|
621
|
+
#
|
622
|
+
# The significant difference here is that there are no line breaks in the
|
623
|
+
# output. If an IfBreak node is used, only the flat contents are printed.
|
624
|
+
# LineSuffix nodes are printed at the end of the buffer when #flush is called.
|
625
|
+
class PrettierPrint::SingleLine
|
626
|
+
# Create a PrettierPrint::SingleLine object
|
627
|
+
#
|
628
|
+
# Arguments:
|
629
|
+
# * +output+ - String (or similar) to store rendered text. Needs to respond
|
630
|
+
# to '<<'.
|
631
|
+
# * +maxwidth+ - Argument position expected to be here for compatibility.
|
632
|
+
# This argument is a noop.
|
633
|
+
# * +newline+ - Argument position expected to be here for compatibility.
|
634
|
+
# This argument is a noop.
|
635
|
+
#
|
636
|
+
# @return [SingleLine] a new instance of SingleLine
|
637
|
+
def initialize(output, _maxwidth = T.unsafe(nil), _newline = T.unsafe(nil)); end
|
638
|
+
|
639
|
+
# Here for compatibility, does nothing.
|
640
|
+
def break_parent; end
|
641
|
+
|
642
|
+
# Appends +separator+ to the text to be output. By default +separator+ is
|
643
|
+
# ' '
|
644
|
+
#
|
645
|
+
# The +width+, +indent+, and +force+ arguments are here for compatibility.
|
646
|
+
# They are all noop arguments.
|
647
|
+
def breakable(separator = T.unsafe(nil), _width = T.unsafe(nil), indent: T.unsafe(nil), force: T.unsafe(nil)); end
|
648
|
+
|
649
|
+
# Appends +separator+ to the output buffer. +width+ is a noop here for
|
650
|
+
# compatibility.
|
651
|
+
def fill_breakable(separator = T.unsafe(nil), _width = T.unsafe(nil)); end
|
652
|
+
|
653
|
+
# Flushes the line suffixes onto the output buffer.
|
654
|
+
def flush; end
|
655
|
+
|
656
|
+
# Opens a block for grouping objects to be pretty printed.
|
657
|
+
#
|
658
|
+
# Arguments:
|
659
|
+
# * +indent+ - noop argument. Present for compatibility.
|
660
|
+
# * +open_obj+ - text appended before the &block. Default is ''
|
661
|
+
# * +close_obj+ - text appended after the &block. Default is ''
|
662
|
+
# * +open_width+ - noop argument. Present for compatibility.
|
663
|
+
# * +close_width+ - noop argument. Present for compatibility.
|
664
|
+
def group(_indent = T.unsafe(nil), open_object = T.unsafe(nil), close_object = T.unsafe(nil), _open_width = T.unsafe(nil), _close_width = T.unsafe(nil)); end
|
665
|
+
|
666
|
+
# Effectively unnecessary, but here for compatibility.
|
667
|
+
def if_break; end
|
668
|
+
|
669
|
+
# Also effectively unnecessary, but here for compatibility.
|
670
|
+
def if_flat; end
|
671
|
+
|
672
|
+
# A noop that immediately yields.
|
673
|
+
def indent; end
|
674
|
+
|
675
|
+
# Changes the target output buffer to the line suffix output buffer which
|
676
|
+
# will get flushed at the end of printing.
|
677
|
+
def line_suffix; end
|
678
|
+
|
679
|
+
# A buffer output that wraps any calls to line_suffix that will be flushed
|
680
|
+
# at the end of printing.
|
681
|
+
def line_suffixes; end
|
682
|
+
|
683
|
+
# Takes +indent+ arg, but does nothing with it.
|
684
|
+
#
|
685
|
+
# Yields to a block.
|
686
|
+
def nest(_indent); end
|
687
|
+
|
688
|
+
# The output object. It stores rendered text and should respond to <<.
|
689
|
+
def output; end
|
690
|
+
|
691
|
+
# The current array of contents that the print tree builder methods should
|
692
|
+
# append to.
|
693
|
+
def target; end
|
694
|
+
|
695
|
+
# Add +object+ to the text to be output.
|
696
|
+
#
|
697
|
+
# +width+ argument is here for compatibility. It is a noop argument.
|
698
|
+
def text(object = T.unsafe(nil), _width = T.unsafe(nil)); end
|
699
|
+
|
700
|
+
# Immediately trims the output buffer.
|
701
|
+
def trim; end
|
702
|
+
end
|
703
|
+
|
704
|
+
# A class that wraps the ability to call #if_flat. The contents of the
|
705
|
+
# #if_flat block are executed immediately, so effectively this class and the
|
706
|
+
# #if_break method that triggers it are unnecessary, but they're here to
|
707
|
+
# maintain compatibility.
|
708
|
+
class PrettierPrint::SingleLine::IfBreakBuilder
|
709
|
+
def if_flat; end
|
710
|
+
end
|
711
|
+
|
712
|
+
# A node in the print tree that represents plain content that cannot be broken
|
713
|
+
# up (by default this assumes strings, but it can really be anything).
|
714
|
+
class PrettierPrint::Text
|
715
|
+
# @return [Text] a new instance of Text
|
716
|
+
def initialize; end
|
717
|
+
|
718
|
+
def add(object: T.unsafe(nil), width: T.unsafe(nil)); end
|
719
|
+
|
720
|
+
# Returns the value of attribute objects.
|
721
|
+
def objects; end
|
722
|
+
|
723
|
+
def pretty_print(q); end
|
724
|
+
|
725
|
+
# Returns the value of attribute width.
|
726
|
+
def width; end
|
727
|
+
end
|
728
|
+
|
729
|
+
# A node in the print tree that represents trimming all of the indentation of
|
730
|
+
# the current line, in the rare case that you need to ignore the indentation
|
731
|
+
# that you've already created. This node should be placed after a Breakable.
|
732
|
+
class PrettierPrint::Trim
|
733
|
+
def pretty_print(q); end
|
734
|
+
end
|