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

Commit 09afd69

Browse files
eileencodeskddnewton
authored andcommitted
remove text
1 parent 4216ac2 commit 09afd69

File tree

1 file changed

+1
-31
lines changed

1 file changed

+1
-31
lines changed

lib/syntax_tree/prism/prettier_print.rb

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -203,26 +203,6 @@ def type
203203
end
204204
end
205205

206-
# A node in the print tree that represents plain content that cannot be broken
207-
# up (by default this assumes strings, but it can really be anything).
208-
class Text
209-
attr_reader :objects, :width
210-
211-
def initialize
212-
@objects = []
213-
@width = 0
214-
end
215-
216-
def add(object: "", width: object.length)
217-
@objects << object
218-
@width += width
219-
end
220-
221-
def type
222-
:text
223-
end
224-
end
225-
226206
# A node in the print tree that represents trimming all of the indentation of
227207
# the current line, in the rare case that you need to ignore the indentation
228208
# that you've already created. This node should be placed after a Breakable.
@@ -508,9 +488,6 @@ def flush(base_indentation = DEFAULT_INDENTATION)
508488
line_suffixes << [indent, mode, doc]
509489
when :break_parent
510490
# do nothing
511-
when :text
512-
doc.objects.each { |object| buffer << object }
513-
position += doc.width
514491
else
515492
# Special case where the user has defined some way to get an extra doc
516493
# node that we don't explicitly support into the list. In this case
@@ -614,8 +591,6 @@ def last_position(node)
614591
width = 0
615592
when :if_break
616593
queue = doc.break_contents + queue
617-
when :text
618-
width += doc.width
619594
end
620595
end
621596

@@ -955,9 +930,6 @@ def fits?(next_commands, rest_commands, remaining)
955930
elsif mode == MODE_FLAT && doc.flat_contents.any?
956931
commands += doc.flat_contents.reverse.map { |part| [indent, mode, part] }
957932
end
958-
when :text
959-
doc.objects.each { |object| fit_buffer << object }
960-
remaining -= doc.width
961933
end
962934
end
963935

@@ -975,9 +947,7 @@ def reset
975947
def remove_breaks_with(doc, replace)
976948
case doc.type
977949
when :breakable
978-
text = Text.new
979-
text.add(object: doc.force? ? replace : doc.separator, width: doc.width)
980-
text
950+
doc.force? ? replace : doc.separator
981951
when :if_break
982952
Align.new(0, doc.flat_contents)
983953
else

0 commit comments

Comments
 (0)