@@ -117,69 +117,6 @@ pub(crate) enum Syntax<'a> {
117117 } ,
118118}
119119
120- pub struct SyntaxTreeDisplay < ' a > ( Vec < & ' a Syntax < ' a > > ) ;
121-
122- #[ allow( dead_code) ]
123- impl < ' a > SyntaxTreeDisplay < ' a > {
124- pub fn from ( tree : Vec < & ' a Syntax < ' a > > ) -> Self {
125- Self ( tree)
126- }
127-
128- fn print_node (
129- f : & mut fmt:: Formatter < ' _ > ,
130- node : & Syntax ,
131- prefix : & str ,
132- is_last : bool ,
133- ) -> fmt:: Result {
134- let connector = if is_last { "└── " } else { "├── " } ;
135-
136- match node {
137- Syntax :: List {
138- open_position,
139- close_position,
140- children,
141- ..
142- } => {
143- writeln ! (
144- f,
145- "{}{}List (open: {:?}, close: {:?})" ,
146- prefix, connector, open_position, close_position
147- ) ?;
148-
149- // Prepare prefix for children
150- // If this was the last node, children don't need the vertical bar │
151- let child_prefix = format ! ( "{}{}" , prefix, if is_last { " " } else { "│ " } ) ;
152-
153- for ( i, child) in children. iter ( ) . enumerate ( ) {
154- Self :: print_node ( f, child, & child_prefix, i == children. len ( ) - 1 ) ?;
155- }
156- }
157- Syntax :: Atom {
158- content,
159- position,
160- kind,
161- ..
162- } => {
163- writeln ! (
164- f,
165- "{}{}Atom: {:?} {:#?} ({:?})" ,
166- prefix, connector, content, kind, position
167- ) ?;
168- }
169- }
170- Ok ( ( ) )
171- }
172- }
173-
174- impl < ' a > fmt:: Display for SyntaxTreeDisplay < ' a > {
175- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
176- for ( i, node) in self . 0 . iter ( ) . enumerate ( ) {
177- SyntaxTreeDisplay :: print_node ( f, node, "" , i == self . 0 . len ( ) - 1 ) ?;
178- }
179- Ok ( ( ) )
180- }
181- }
182-
183120fn dbg_pos ( pos : & [ SingleLineSpan ] ) -> String {
184121 match pos {
185122 [ ] => "-" . into ( ) ,
0 commit comments