[wadler] Prettier handling of trivia
Split the rules for pre- and post- trivia, understand when we want to do either, handle multi-line-break (in an unsatisfying way, I guess) but otherwise lay the groundwork for thinking about it better. Also now we don't generate lazy "Text" nodes because I thought I might want to actually look at the newlines in the source but I don't yet. I *can* now, though. (I can also detect EOF so there's that.)
This commit is contained in:
parent
c31d527077
commit
8a17cfd586
5 changed files with 159 additions and 108 deletions
|
|
@ -371,7 +371,7 @@ class Harness:
|
|||
|
||||
printer = self.load_printer()
|
||||
if self.tree is not None:
|
||||
self.document = printer.convert_tree_to_document(self.tree)
|
||||
self.document = printer.convert_tree_to_document(self.tree, self.source)
|
||||
else:
|
||||
self.document = None
|
||||
|
||||
|
|
@ -541,12 +541,6 @@ class Harness:
|
|||
append(f"indent {doc.amount}")
|
||||
self.format_document(lines, doc.doc, indent + 1)
|
||||
|
||||
case wadler.Text(start, end):
|
||||
if self.source is not None:
|
||||
append(f"< {repr(self.source[start:end])}")
|
||||
else:
|
||||
append(f"< ??? {start}:{end}")
|
||||
|
||||
case wadler.Literal(text):
|
||||
append(f"literal {repr(text)}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue