aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs18
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
4use itertools::Itertools; 4use itertools::Itertools;
5 5
6use crate::{SmolStr, SyntaxToken, ast::{self, AstNode, children, child_opt}, SyntaxKind::*, SyntaxElement, T}; 6use crate::{
7 SmolStr, SyntaxToken,
8 ast::{self, AstNode, children, child_opt},
9 SyntaxKind::*,
10 SyntaxElement, T,
11};
7use ra_parser::SyntaxKind; 12use ra_parser::SyntaxKind;
8 13
9impl ast::Name { 14impl ast::Name {
@@ -196,6 +201,17 @@ impl StructKind<'_> {
196} 201}
197 202
198impl ast::StructDef { 203impl 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 }