aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/syntax_node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/syntax_node.rs')
-rw-r--r--crates/ra_syntax/src/syntax_node.rs30
1 files changed, 4 insertions, 26 deletions
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs
index ef7a51686..769125d11 100644
--- a/crates/ra_syntax/src/syntax_node.rs
+++ b/crates/ra_syntax/src/syntax_node.rs
@@ -256,37 +256,18 @@ impl SyntaxNode {
256 } 256 }
257 257
258 pub fn debug_dump(&self) -> String { 258 pub fn debug_dump(&self) -> String {
259 let mut errors: Vec<_> = match self.ancestors().find_map(SourceFile::cast) {
260 Some(file) => file.errors(),
261 None => self.root_data().to_vec(),
262 };
263 errors.sort_by_key(|e| e.offset());
264 let mut err_pos = 0;
265 let mut level = 0; 259 let mut level = 0;
266 let mut buf = String::new(); 260 let mut buf = String::new();
267 macro_rules! indent {
268 () => {
269 for _ in 0..level {
270 buf.push_str(" ");
271 }
272 };
273 }
274 261
275 for event in self.preorder_with_tokens() { 262 for event in self.preorder_with_tokens() {
276 match event { 263 match event {
277 WalkEvent::Enter(element) => { 264 WalkEvent::Enter(element) => {
278 indent!(); 265 for _ in 0..level {
266 buf.push_str(" ");
267 }
279 match element { 268 match element {
280 SyntaxElement::Node(node) => writeln!(buf, "{:?}", node).unwrap(), 269 SyntaxElement::Node(node) => writeln!(buf, "{:?}", node).unwrap(),
281 SyntaxElement::Token(token) => { 270 SyntaxElement::Token(token) => writeln!(buf, "{:?}", token).unwrap(),
282 writeln!(buf, "{:?}", token).unwrap();
283 let off = token.range().end();
284 while err_pos < errors.len() && errors[err_pos].offset() <= off {
285 indent!();
286 writeln!(buf, "err: `{}`", errors[err_pos]).unwrap();
287 err_pos += 1;
288 }
289 }
290 } 271 }
291 level += 1; 272 level += 1;
292 } 273 }
@@ -295,9 +276,6 @@ impl SyntaxNode {
295 } 276 }
296 277
297 assert_eq!(level, 0); 278 assert_eq!(level, 0);
298 for err in errors[err_pos..].iter() {
299 writeln!(buf, "err: `{}`", err).unwrap();
300 }
301 279
302 buf 280 buf
303 } 281 }