From 23c6d786744358a2e39970acc635fe2a3cdd98c9 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 15 May 2019 16:25:53 -0700 Subject: [PATCH] Fix presentation of missing nodes in parse command --- cli/src/parse.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cli/src/parse.rs b/cli/src/parse.rs index 95ecebc1..a8d411e1 100644 --- a/cli/src/parse.rs +++ b/cli/src/parse.rs @@ -163,14 +163,24 @@ pub fn parse_file_at_path( if let Some(node) = first_error { let start = node.start_position(); let end = node.end_position(); + write!(&mut stdout, "\t(")?; + if node.is_missing() { + if node.is_named() { + write!(&mut stdout, "MISSING {}", node.kind())?; + } else { + write!( + &mut stdout, + "MISSING \"{}\"", + node.kind().replace("\n", "\\n") + )?; + } + } else { + write!(&mut stdout, "{}", node.kind())?; + } write!( &mut stdout, - "\t({} [{}, {}] - [{}, {}])", - node.kind(), - start.row, - start.column, - end.row, - end.column + " [{}, {}] - [{}, {}])", + start.row, start.column, end.row, end.column )?; } write!(&mut stdout, "\n")?;