diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-20 23:16:21 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-20 23:16:21 +0100 |
commit | 4369c1c4a1f098b8e59a462afb9292137498bb43 (patch) | |
tree | ca8a3a7d60bca8e807a6597e4ec734953b4851d2 /crates/ra_syntax/src | |
parent | 9383ae720bd294b3a89ae54cb1ecad749f30b0fa (diff) | |
parent | 765f93b8d851e5e853c844c8a279e73b4b7d965c (diff) |
Merge #1291
1291: add is_union to structs AST r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-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 | } |