syntax_tree 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -375,7 +375,7 @@ class PrettyPrint
375
375
  # This argument is a noop.
376
376
  # * +newline+ - Argument position expected to be here for compatibility.
377
377
  # This argument is a noop.
378
- def initialize(output, maxwidth = nil, newline = nil)
378
+ def initialize(output, _maxwidth = nil, _newline = nil)
379
379
  @output = Buffer.for(output)
380
380
  @target = @output
381
381
  @line_suffixes = Buffer::ArrayBuffer.new
@@ -397,7 +397,7 @@ class PrettyPrint
397
397
  # They are all noop arguments.
398
398
  def breakable(
399
399
  separator = " ",
400
- width = separator.length,
400
+ _width = separator.length,
401
401
  indent: nil,
402
402
  force: nil
403
403
  )
@@ -410,7 +410,7 @@ class PrettyPrint
410
410
 
411
411
  # Appends +separator+ to the output buffer. +width+ is a noop here for
412
412
  # compatibility.
413
- def fill_breakable(separator = " ", width = separator.length)
413
+ def fill_breakable(separator = " ", _width = separator.length)
414
414
  target << separator
415
415
  end
416
416
 
@@ -419,9 +419,9 @@ class PrettyPrint
419
419
  target.trim!
420
420
  end
421
421
 
422
- # ----------------------------------------------------------------------------
422
+ # --------------------------------------------------------------------------
423
423
  # Container node builders
424
- # ----------------------------------------------------------------------------
424
+ # --------------------------------------------------------------------------
425
425
 
426
426
  # Opens a block for grouping objects to be pretty printed.
427
427
  #
@@ -432,11 +432,11 @@ class PrettyPrint
432
432
  # * +open_width+ - noop argument. Present for compatibility.
433
433
  # * +close_width+ - noop argument. Present for compatibility.
434
434
  def group(
435
- indent = nil,
435
+ _indent = nil,
436
436
  open_object = "",
437
437
  close_object = "",
438
- open_width = nil,
439
- close_width = nil
438
+ _open_width = nil,
439
+ _close_width = nil
440
440
  )
441
441
  target << open_object
442
442
  yield
@@ -478,14 +478,14 @@ class PrettyPrint
478
478
  # Takes +indent+ arg, but does nothing with it.
479
479
  #
480
480
  # Yields to a block.
481
- def nest(indent)
481
+ def nest(_indent)
482
482
  yield
483
483
  end
484
484
 
485
485
  # Add +object+ to the text to be output.
486
486
  #
487
487
  # +width+ argument is here for compatibility. It is a noop argument.
488
- def text(object = "", width = nil)
488
+ def text(object = "", _width = nil)
489
489
  target << object
490
490
  end
491
491
  end
@@ -546,17 +546,17 @@ class PrettyPrint
546
546
  last_spaces = 0
547
547
  end
548
548
 
549
- next_queue.each do |part|
550
- case part
549
+ next_queue.each do |next_part|
550
+ case next_part
551
551
  when IndentPart
552
552
  flush_spaces.call
553
553
  add_spaces.call(2)
554
554
  when StringAlignPart
555
555
  flush_spaces.call
556
- next_value += part.n
557
- next_length += part.n.length
556
+ next_value += next_part.n
557
+ next_length += next_part.n.length
558
558
  when NumberAlignPart
559
- last_spaces += part.n
559
+ last_spaces += next_part.n
560
560
  end
561
561
  end
562
562
 
@@ -623,9 +623,9 @@ class PrettyPrint
623
623
  #
624
624
  def self.singleline_format(
625
625
  output = "".dup,
626
- maxwidth = nil,
627
- newline = nil,
628
- genspace = nil
626
+ _maxwidth = nil,
627
+ _newline = nil,
628
+ _genspace = nil
629
629
  )
630
630
  q = SingleLine.new(output)
631
631
  yield q
@@ -778,16 +778,19 @@ class PrettyPrint
778
778
  position -= buffer.trim!
779
779
  when Group
780
780
  if mode == MODE_FLAT && !should_remeasure
781
- commands <<
782
- [indent, doc.break? ? MODE_BREAK : MODE_FLAT, doc.contents]
781
+ commands << [
782
+ indent,
783
+ doc.break? ? MODE_BREAK : MODE_FLAT,
784
+ doc.contents
785
+ ]
783
786
  else
784
787
  should_remeasure = false
785
788
  next_cmd = [indent, MODE_FLAT, doc.contents]
786
-
787
- if !doc.break? && fits?(next_cmd, commands, maxwidth - position)
788
- commands << next_cmd
789
+ commands << if !doc.break? &&
790
+ fits?(next_cmd, commands, maxwidth - position)
791
+ next_cmd
789
792
  else
790
- commands << [indent, MODE_BREAK, doc.contents]
793
+ [indent, MODE_BREAK, doc.contents]
791
794
  end
792
795
  end
793
796
  when IfBreak
@@ -1060,7 +1063,7 @@ class PrettyPrint
1060
1063
  def text(object = "", width = object.length)
1061
1064
  doc = target.last
1062
1065
 
1063
- unless Text === doc
1066
+ unless doc.is_a?(Text)
1064
1067
  doc = Text.new
1065
1068
  target << doc
1066
1069
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SyntaxTree
4
- VERSION = "2.3.1"
4
+ VERSION = "2.4.0"
5
5
  end