From 59295854f892b0a8f42a6fbc80b04d1f1c695828 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 13 Dec 2019 01:41:44 +0800 Subject: Add token id to delims --- crates/ra_tt/src/lib.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'crates/ra_tt') diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 209ca4048..73d8395a8 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs @@ -55,7 +55,13 @@ pub struct Subtree { } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub enum Delimiter { +pub struct Delimiter { + pub id: TokenId, + pub kind: DelimiterKind, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub enum DelimiterKind { Parenthesis, Brace, Bracket, @@ -97,10 +103,10 @@ impl fmt::Display for TokenTree { impl fmt::Display for Subtree { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let (l, r) = match self.delimiter { - Some(Delimiter::Parenthesis) => ("(", ")"), - Some(Delimiter::Brace) => ("{", "}"), - Some(Delimiter::Bracket) => ("[", "]"), + let (l, r) = match self.delimiter.map(|it| it.kind) { + Some(DelimiterKind::Parenthesis) => ("(", ")"), + Some(DelimiterKind::Brace) => ("{", "}"), + Some(DelimiterKind::Bracket) => ("[", "]"), None => ("", ""), }; f.write_str(l)?; -- cgit v1.2.3