diff options
author | Dawer <[email protected]> | 2021-05-06 06:07:06 +0100 |
---|---|---|
committer | Dawer <[email protected]> | 2021-05-06 06:07:06 +0100 |
commit | d9b4ac81285985f384d1a9f0708ba54434b7f231 (patch) | |
tree | a2064a2a1e9577b8c23cfb172dbbb9c13ae0afd9 /crates | |
parent | d7e169fe55a15dd684e7a93dd111c66ed49ed949 (diff) |
Clean up
Diffstat (limited to 'crates')
-rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 8e6d7b092..88f9a0e97 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs | |||
@@ -5,11 +5,11 @@ use std::{borrow::Cow, fmt, iter::successors}; | |||
5 | 5 | ||
6 | use itertools::Itertools; | 6 | use itertools::Itertools; |
7 | use parser::SyntaxKind; | 7 | use parser::SyntaxKind; |
8 | use rowan::{GreenNodeData, GreenTokenData, NodeOrToken}; | 8 | use rowan::{GreenNodeData, GreenTokenData}; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | ast::{self, support, AstNode, AstToken, AttrsOwner, NameOwner, SyntaxNode}, | 11 | ast::{self, support, AstNode, AstToken, AttrsOwner, NameOwner, SyntaxNode}, |
12 | SmolStr, SyntaxElement, SyntaxToken, TokenText, T, | 12 | NodeOrToken, SmolStr, SyntaxElement, SyntaxToken, TokenText, T, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | impl ast::Lifetime { | 15 | impl ast::Lifetime { |
@@ -34,19 +34,6 @@ impl ast::NameRef { | |||
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | fn _text_of_first_token(node: &SyntaxNode) -> Cow<'_, str> { | ||
38 | fn cow_map<F: FnOnce(&GreenNodeData) -> &str>(green: Cow<GreenNodeData>, f: F) -> Cow<str> { | ||
39 | match green { | ||
40 | Cow::Borrowed(green_ref) => Cow::Borrowed(f(green_ref)), | ||
41 | Cow::Owned(green) => Cow::Owned(f(&green).to_owned()), | ||
42 | } | ||
43 | } | ||
44 | |||
45 | cow_map(node.green(), |green_ref| { | ||
46 | green_ref.children().next().and_then(NodeOrToken::into_token).unwrap().text() | ||
47 | }) | ||
48 | } | ||
49 | |||
50 | fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> { | 37 | fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> { |
51 | fn first_token(green_ref: &GreenNodeData) -> &GreenTokenData { | 38 | fn first_token(green_ref: &GreenNodeData) -> &GreenTokenData { |
52 | green_ref.children().next().and_then(NodeOrToken::into_token).unwrap() | 39 | green_ref.children().next().and_then(NodeOrToken::into_token).unwrap() |