aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-05-20 23:04:20 +0100
committerAleksey Kladov <[email protected]>2019-05-20 23:15:56 +0100
commit765f93b8d851e5e853c844c8a279e73b4b7d965c (patch)
treeca8a3a7d60bca8e807a6597e4ec734953b4851d2 /crates
parent4ca8331933033b4cb8252c3056020bc4bfa2d78f (diff)
add is_union to structs AST
Diffstat (limited to 'crates')
-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 }