mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-21 04:03:11 +00:00
add is_union to structs AST
This commit is contained in:
parent
4ca8331933
commit
765f93b8d8
@ -3,7 +3,12 @@
|
|||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::{SmolStr, SyntaxToken, ast::{self, AstNode, children, child_opt}, SyntaxKind::*, SyntaxElement, T};
|
use crate::{
|
||||||
|
SmolStr, SyntaxToken,
|
||||||
|
ast::{self, AstNode, children, child_opt},
|
||||||
|
SyntaxKind::*,
|
||||||
|
SyntaxElement, T,
|
||||||
|
};
|
||||||
use ra_parser::SyntaxKind;
|
use ra_parser::SyntaxKind;
|
||||||
|
|
||||||
impl ast::Name {
|
impl ast::Name {
|
||||||
@ -196,6 +201,17 @@ impl StructKind<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ast::StructDef {
|
impl ast::StructDef {
|
||||||
|
pub fn is_union(&self) -> bool {
|
||||||
|
for child in self.syntax().children_with_tokens() {
|
||||||
|
match child.kind() {
|
||||||
|
T![struct] => return false,
|
||||||
|
T![union] => return true,
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
pub fn kind(&self) -> StructKind {
|
pub fn kind(&self) -> StructKind {
|
||||||
StructKind::from_node(self)
|
StructKind::from_node(self)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user