aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/syntax/src/ast/node_ext.rs17
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
6use itertools::Itertools; 6use itertools::Itertools;
7use parser::SyntaxKind; 7use parser::SyntaxKind;
8use rowan::{GreenNodeData, GreenTokenData, NodeOrToken}; 8use rowan::{GreenNodeData, GreenTokenData};
9 9
10use crate::{ 10use 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
15impl ast::Lifetime { 15impl ast::Lifetime {
@@ -34,19 +34,6 @@ impl ast::NameRef {
34 } 34 }
35} 35}
36 36
37fn _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
50fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> { 37fn 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()