diff options
Diffstat (limited to 'crates/libsyntax2/src/yellow/green.rs')
-rw-r--r-- | crates/libsyntax2/src/yellow/green.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/crates/libsyntax2/src/yellow/green.rs b/crates/libsyntax2/src/yellow/green.rs index f505b26d7..700f2704f 100644 --- a/crates/libsyntax2/src/yellow/green.rs +++ b/crates/libsyntax2/src/yellow/green.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | use { | 2 | |
3 | SyntaxKind, TextUnit, | 3 | use smol_str::SmolStr; |
4 | smol_str::SmolStr, | 4 | |
5 | }; | 5 | use {SyntaxKind, TextUnit}; |
6 | 6 | ||
7 | #[derive(Clone, Debug)] | 7 | #[derive(Clone, Debug)] |
8 | pub(crate) enum GreenNode { | 8 | pub(crate) enum GreenNode { |
@@ -31,7 +31,7 @@ impl GreenNode { | |||
31 | 31 | ||
32 | pub fn text_len(&self) -> TextUnit { | 32 | pub fn text_len(&self) -> TextUnit { |
33 | match self { | 33 | match self { |
34 | GreenNode::Leaf { text, ..} => TextUnit::of_str(text.as_str()), | 34 | GreenNode::Leaf { text, .. } => TextUnit::of_str(text.as_str()), |
35 | GreenNode::Branch(b) => b.text_len(), | 35 | GreenNode::Branch(b) => b.text_len(), |
36 | } | 36 | } |
37 | } | 37 | } |
@@ -54,6 +54,13 @@ impl GreenNode { | |||
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
57 | |||
58 | pub fn leaf_text(&self) -> Option<SmolStr> { | ||
59 | match self { | ||
60 | GreenNode::Leaf { text, .. } => Some(text.clone()), | ||
61 | GreenNode::Branch(_) => None, | ||
62 | } | ||
63 | } | ||
57 | } | 64 | } |
58 | 65 | ||
59 | #[derive(Clone, Debug)] | 66 | #[derive(Clone, Debug)] |