diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index f030e0df8..e4c99784c 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -3,7 +3,12 @@ | |||
3 | 3 | ||
4 | use itertools::Itertools; | 4 | use itertools::Itertools; |
5 | 5 | ||
6 | use crate::{SmolStr, SyntaxToken, ast::{self, AstNode, children, child_opt}, SyntaxKind::*, SyntaxElement, T}; | 6 | use crate::{ |
7 | SmolStr, SyntaxToken, | ||
8 | ast::{self, AstNode, children, child_opt}, | ||
9 | SyntaxKind::*, | ||
10 | SyntaxElement, T, | ||
11 | }; | ||
7 | use ra_parser::SyntaxKind; | 12 | use ra_parser::SyntaxKind; |
8 | 13 | ||
9 | impl ast::Name { | 14 | impl ast::Name { |
@@ -196,6 +201,17 @@ impl StructKind<'_> { | |||
196 | } | 201 | } |
197 | 202 | ||
198 | impl ast::StructDef { | 203 | impl ast::StructDef { |
204 | pub fn is_union(&self) -> bool { | ||
205 | for child in self.syntax().children_with_tokens() { | ||
206 | match child.kind() { | ||
207 | T![struct] => return false, | ||
208 | T![union] => return true, | ||
209 | _ => (), | ||
210 | } | ||
211 | } | ||
212 | false | ||
213 | } | ||
214 | |||
199 | pub fn kind(&self) -> StructKind { | 215 | pub fn kind(&self) -> StructKind { |
200 | StructKind::from_node(self) | 216 | StructKind::from_node(self) |
201 | } | 217 | } |