diff options
author | Aleksey Kladov <[email protected]> | 2019-02-11 16:28:39 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-11 18:02:19 +0000 |
commit | 58897dd8ddfd08ef494b7bc05ac15f5b1e3a4e1a (patch) | |
tree | fdd3ffbdca1ee8a9711d4080931e71f13d72e154 /crates/ra_mbe | |
parent | b356ab46f2b7482bf1ae0c0f6cd5a87ece8742bf (diff) |
assign ids to tokens
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/src/mbe_expander.rs | 4 | ||||
-rw-r--r-- | crates/ra_mbe/src/mbe_parser.rs | 2 | ||||
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index eec713d9c..f6177f078 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs | |||
@@ -3,6 +3,7 @@ | |||
3 | /// `tt::TokenTree` for the result of the expansion. | 3 | /// `tt::TokenTree` for the result of the expansion. |
4 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
5 | use ra_syntax::SmolStr; | 5 | use ra_syntax::SmolStr; |
6 | use tt::TokenId; | ||
6 | 7 | ||
7 | use crate::tt_cursor::TtCursor; | 8 | use crate::tt_cursor::TtCursor; |
8 | 9 | ||
@@ -185,7 +186,8 @@ fn expand_tt( | |||
185 | } | 186 | } |
186 | crate::TokenTree::Leaf(leaf) => match leaf { | 187 | crate::TokenTree::Leaf(leaf) => match leaf { |
187 | crate::Leaf::Ident(ident) => { | 188 | crate::Leaf::Ident(ident) => { |
188 | tt::Leaf::from(tt::Ident { text: ident.text.clone() }).into() | 189 | tt::Leaf::from(tt::Ident { text: ident.text.clone(), id: TokenId::unspecified() }) |
190 | .into() | ||
189 | } | 191 | } |
190 | crate::Leaf::Punct(punct) => tt::Leaf::from(punct.clone()).into(), | 192 | crate::Leaf::Punct(punct) => tt::Leaf::from(punct.clone()).into(), |
191 | crate::Leaf::Var(v) => bindings.get(&v.text, nesting)?.clone(), | 193 | crate::Leaf::Var(v) => bindings.get(&v.text, nesting)?.clone(), |
diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs index 60e566ed2..58e2533f1 100644 --- a/crates/ra_mbe/src/mbe_parser.rs +++ b/crates/ra_mbe/src/mbe_parser.rs | |||
@@ -41,7 +41,7 @@ fn parse_subtree(tt: &tt::Subtree) -> Option<crate::Subtree> { | |||
41 | } | 41 | } |
42 | } | 42 | } |
43 | tt::Leaf::Punct(punct) => crate::Leaf::from(*punct).into(), | 43 | tt::Leaf::Punct(punct) => crate::Leaf::from(*punct).into(), |
44 | tt::Leaf::Ident(tt::Ident { text }) => { | 44 | tt::Leaf::Ident(tt::Ident { text, id: _ }) => { |
45 | crate::Leaf::from(crate::Ident { text: text.clone() }).into() | 45 | crate::Leaf::from(crate::Ident { text: text.clone() }).into() |
46 | } | 46 | } |
47 | tt::Leaf::Literal(tt::Literal { text }) => { | 47 | tt::Leaf::Literal(tt::Literal { text }) => { |
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 9a2eceaba..d734f5597 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -37,7 +37,7 @@ fn convert_tt(tt: &SyntaxNode) -> Option<tt::Subtree> { | |||
37 | convert_tt(child)?.into() | 37 | convert_tt(child)?.into() |
38 | } else if child.kind().is_keyword() || child.kind() == IDENT { | 38 | } else if child.kind().is_keyword() || child.kind() == IDENT { |
39 | let text = child.leaf_text().unwrap().clone(); | 39 | let text = child.leaf_text().unwrap().clone(); |
40 | tt::Leaf::from(tt::Ident { text }).into() | 40 | tt::Leaf::from(tt::Ident { text, id: tt::TokenId::unspecified() }).into() |
41 | } else if child.kind().is_literal() { | 41 | } else if child.kind().is_literal() { |
42 | tt::Leaf::from(tt::Literal { text: child.leaf_text().unwrap().clone() }).into() | 42 | tt::Leaf::from(tt::Literal { text: child.leaf_text().unwrap().clone() }).into() |
43 | } else { | 43 | } else { |