aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_tt
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-12-12 17:41:44 +0000
committerEdwin Cheng <[email protected]>2019-12-18 03:20:22 +0000
commit59295854f892b0a8f42a6fbc80b04d1f1c695828 (patch)
tree73f624f906a9d22e3edf408972dddf5eb8b50291 /crates/ra_tt
parentaceb9d7fb0809ccf364514d9177342edea144c59 (diff)
Add token id to delims
Diffstat (limited to 'crates/ra_tt')
-rw-r--r--crates/ra_tt/src/lib.rs16
1 files changed, 11 insertions, 5 deletions
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 {
55} 55}
56 56
57#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 57#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
58pub enum Delimiter { 58pub struct Delimiter {
59 pub id: TokenId,
60 pub kind: DelimiterKind,
61}
62
63#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
64pub enum DelimiterKind {
59 Parenthesis, 65 Parenthesis,
60 Brace, 66 Brace,
61 Bracket, 67 Bracket,
@@ -97,10 +103,10 @@ impl fmt::Display for TokenTree {
97 103
98impl fmt::Display for Subtree { 104impl fmt::Display for Subtree {
99 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 105 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
100 let (l, r) = match self.delimiter { 106 let (l, r) = match self.delimiter.map(|it| it.kind) {
101 Some(Delimiter::Parenthesis) => ("(", ")"), 107 Some(DelimiterKind::Parenthesis) => ("(", ")"),
102 Some(Delimiter::Brace) => ("{", "}"), 108 Some(DelimiterKind::Brace) => ("{", "}"),
103 Some(Delimiter::Bracket) => ("[", "]"), 109 Some(DelimiterKind::Bracket) => ("[", "]"),
104 None => ("", ""), 110 None => ("", ""),
105 }; 111 };
106 f.write_str(l)?; 112 f.write_str(l)?;