Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7d44043

Browse files
eileencodeskddnewton
authored andcommitted
remove genspace
1 parent ba93f7a commit 7d44043

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

lib/syntax_tree/prism/prettier_print.rb

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,6 @@ def self.for(output)
276276
# default is \n.
277277
DEFAULT_NEWLINE = "\n"
278278

279-
# When generating spaces after a newline for indentation, by default we
280-
# generate one space per character needed for indentation. You can change this
281-
# behavior (for instance to use tabs) by passing a different genspace
282-
# procedure.
283-
DEFAULT_GENSPACE = ->(n) { " " * n }
284-
Ractor.make_shareable(DEFAULT_GENSPACE) if defined?(Ractor)
285-
286279
# There are two modes in printing, break and flat. When we're in break mode,
287280
# any lines will use their newline, any if-breaks will use their break
288281
# contents, etc.
@@ -301,7 +294,7 @@ def self.for(output)
301294
# This is a convenience method which is same as follows:
302295
#
303296
# begin
304-
# q = PrettierPrint.new(output, maxwidth, newline, &genspace)
297+
# q = PrettierPrint.new(output, maxwidth, newline)
305298
# ...
306299
# q.flush
307300
# output
@@ -311,10 +304,9 @@ def self.format(
311304
output = "".dup,
312305
maxwidth = 80,
313306
newline = DEFAULT_NEWLINE,
314-
genspace = DEFAULT_GENSPACE,
315307
indentation = DEFAULT_INDENTATION
316308
)
317-
q = new(output, maxwidth, newline, &genspace)
309+
q = new(output, maxwidth, newline)
318310
yield q
319311
q.flush(indentation)
320312
output
@@ -342,12 +334,6 @@ def self.format(
342334
# This defaults to "\n", and should be String
343335
attr_reader :newline
344336

345-
# An object that responds to call that takes one argument, of an Integer, and
346-
# returns the corresponding number of spaces.
347-
#
348-
# By default this is: ->(n) { ' ' * n }
349-
attr_reader :genspace
350-
351337
# The stack of groups that are being printed.
352338
attr_reader :groups
353339

@@ -374,14 +360,12 @@ def self.format(
374360
def initialize(
375361
output = "".dup,
376362
maxwidth = 80,
377-
newline = DEFAULT_NEWLINE,
378-
&genspace
363+
newline = DEFAULT_NEWLINE
379364
)
380365
@output = output
381366
@buffer = Buffer.for(output)
382367
@maxwidth = maxwidth
383368
@newline = newline
384-
@genspace = genspace || DEFAULT_GENSPACE
385369
reset
386370
end
387371

@@ -429,7 +413,7 @@ def flush(base_indentation = DEFAULT_INDENTATION)
429413
position = base_indentation
430414

431415
# Start the buffer with the base indentation level.
432-
buffer << genspace.call(base_indentation) if base_indentation > 0
416+
buffer << " " * base_indentation if base_indentation > 0
433417

434418
# This is our command stack. A command consists of a triplet of an
435419
# indentation level, the mode (break or flat), and a doc node.
@@ -513,7 +497,7 @@ def flush(base_indentation = DEFAULT_INDENTATION)
513497
else
514498
position -= buffer.trim!
515499
buffer << newline
516-
buffer << genspace.call(indent)
500+
buffer << " " * indent
517501
position = indent
518502
end
519503
when Indent

0 commit comments

Comments
 (0)