diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-21 14:48:46 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-21 14:48:46 +0100 |
commit | 443061e75260e55bbaa741c5c85377b8d5c57e47 (patch) | |
tree | c28241dc1639480ba5154040e9f31384eabfed06 /crates/ra_syntax/src/ast | |
parent | 1137fc47bbbc8d648db3bc669e41fd059a09dd1d (diff) | |
parent | 773ad2edb3b84bf20378a577bc4cd808384de078 (diff) |
Merge #1570
1570: switch to upstream rowan's API r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 13 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 5 |
2 files changed, 6 insertions, 12 deletions
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 139bd3ec0..f9190d877 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use crate::{ | 3 | use crate::{ |
4 | ast::{self, child_opt, children, AstChildren, AstNode}, | 4 | ast::{self, child_opt, children, AstChildren, AstNode}, |
5 | SmolStr, SyntaxElement, | 5 | SmolStr, |
6 | SyntaxKind::*, | 6 | SyntaxKind::*, |
7 | SyntaxToken, T, | 7 | SyntaxToken, T, |
8 | }; | 8 | }; |
@@ -229,14 +229,11 @@ pub enum LiteralKind { | |||
229 | 229 | ||
230 | impl ast::Literal { | 230 | impl ast::Literal { |
231 | pub fn token(&self) -> SyntaxToken { | 231 | pub fn token(&self) -> SyntaxToken { |
232 | let elem = self | 232 | self.syntax() |
233 | .syntax() | ||
234 | .children_with_tokens() | 233 | .children_with_tokens() |
235 | .find(|e| e.kind() != ATTR && !e.kind().is_trivia()); | 234 | .find(|e| e.kind() != ATTR && !e.kind().is_trivia()) |
236 | match elem { | 235 | .and_then(|e| e.into_token()) |
237 | Some(SyntaxElement::Token(token)) => token, | 236 | .unwrap() |
238 | _ => unreachable!(), | ||
239 | } | ||
240 | } | 237 | } |
241 | 238 | ||
242 | pub fn kind(&self) -> LiteralKind { | 239 | pub fn kind(&self) -> LiteralKind { |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 753fc42c6..d4873b39a 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -24,10 +24,7 @@ impl ast::NameRef { | |||
24 | } | 24 | } |
25 | 25 | ||
26 | fn text_of_first_token(node: &SyntaxNode) -> &SmolStr { | 26 | fn text_of_first_token(node: &SyntaxNode) -> &SmolStr { |
27 | match node.0.green().children().first() { | 27 | node.green().children().first().and_then(|it| it.as_token()).unwrap().text() |
28 | Some(rowan::GreenElement::Token(it)) => it.text(), | ||
29 | _ => panic!(), | ||
30 | } | ||
31 | } | 28 | } |
32 | 29 | ||
33 | impl ast::Attr { | 30 | impl ast::Attr { |