rename flavor to kind
This commit is contained in:
@@ -16,8 +16,8 @@ pub use self::{
|
||||
generated::*,
|
||||
traits::*,
|
||||
tokens::*,
|
||||
extensions::{PathSegmentKind, StructFlavor, SelfParamFlavor},
|
||||
expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralFlavor},
|
||||
extensions::{PathSegmentKind, StructKind, SelfParamKind},
|
||||
expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralKind},
|
||||
};
|
||||
|
||||
/// The main trait to go from untyped `SyntaxNode` to a typed ast. The
|
||||
|
||||
@@ -192,7 +192,7 @@ impl ast::BinExpr {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum LiteralFlavor {
|
||||
pub enum LiteralKind {
|
||||
String,
|
||||
ByteString,
|
||||
Char,
|
||||
@@ -210,7 +210,7 @@ impl ast::Literal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn flavor(&self) -> LiteralFlavor {
|
||||
pub fn kind(&self) -> LiteralKind {
|
||||
match self.token().kind() {
|
||||
INT_NUMBER => {
|
||||
let allowed_suffix_list = [
|
||||
@@ -222,7 +222,7 @@ impl ast::Literal {
|
||||
.iter()
|
||||
.find(|&s| text.ends_with(s))
|
||||
.map(|&suf| SmolStr::new(suf));
|
||||
LiteralFlavor::IntNumber { suffix }
|
||||
LiteralKind::IntNumber { suffix }
|
||||
}
|
||||
FLOAT_NUMBER => {
|
||||
let allowed_suffix_list = ["f64", "f32"];
|
||||
@@ -231,13 +231,13 @@ impl ast::Literal {
|
||||
.iter()
|
||||
.find(|&s| text.ends_with(s))
|
||||
.map(|&suf| SmolStr::new(suf));
|
||||
LiteralFlavor::FloatNumber { suffix: suffix }
|
||||
LiteralKind::FloatNumber { suffix: suffix }
|
||||
}
|
||||
STRING | RAW_STRING => LiteralFlavor::String,
|
||||
TRUE_KW | FALSE_KW => LiteralFlavor::Bool,
|
||||
BYTE_STRING | RAW_BYTE_STRING => LiteralFlavor::ByteString,
|
||||
CHAR => LiteralFlavor::Char,
|
||||
BYTE => LiteralFlavor::Byte,
|
||||
STRING | RAW_STRING => LiteralKind::String,
|
||||
TRUE_KW | FALSE_KW => LiteralKind::Bool,
|
||||
BYTE_STRING | RAW_BYTE_STRING => LiteralKind::ByteString,
|
||||
CHAR => LiteralKind::Char,
|
||||
BYTE => LiteralKind::Byte,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,27 +159,27 @@ impl ast::ImplBlock {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum StructFlavor<'a> {
|
||||
pub enum StructKind<'a> {
|
||||
Tuple(&'a ast::PosFieldDefList),
|
||||
Named(&'a ast::NamedFieldDefList),
|
||||
Unit,
|
||||
}
|
||||
|
||||
impl StructFlavor<'_> {
|
||||
fn from_node<N: AstNode>(node: &N) -> StructFlavor {
|
||||
impl StructKind<'_> {
|
||||
fn from_node<N: AstNode>(node: &N) -> StructKind {
|
||||
if let Some(nfdl) = child_opt::<_, ast::NamedFieldDefList>(node) {
|
||||
StructFlavor::Named(nfdl)
|
||||
StructKind::Named(nfdl)
|
||||
} else if let Some(pfl) = child_opt::<_, ast::PosFieldDefList>(node) {
|
||||
StructFlavor::Tuple(pfl)
|
||||
StructKind::Tuple(pfl)
|
||||
} else {
|
||||
StructFlavor::Unit
|
||||
StructKind::Unit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::StructDef {
|
||||
pub fn flavor(&self) -> StructFlavor {
|
||||
StructFlavor::from_node(self)
|
||||
pub fn kind(&self) -> StructKind {
|
||||
StructKind::from_node(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,8 +191,8 @@ impl ast::EnumVariant {
|
||||
.and_then(ast::EnumDef::cast)
|
||||
.expect("EnumVariants are always nested in Enums")
|
||||
}
|
||||
pub fn flavor(&self) -> StructFlavor {
|
||||
StructFlavor::from_node(self)
|
||||
pub fn kind(&self) -> StructKind {
|
||||
StructKind::from_node(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ impl ast::ReferenceType {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum SelfParamFlavor {
|
||||
pub enum SelfParamKind {
|
||||
/// self
|
||||
Owned,
|
||||
/// &self
|
||||
@@ -261,7 +261,7 @@ impl ast::SelfParam {
|
||||
.expect("invalid tree: self param must have self")
|
||||
}
|
||||
|
||||
pub fn flavor(&self) -> SelfParamFlavor {
|
||||
pub fn kind(&self) -> SelfParamKind {
|
||||
let borrowed = self.syntax().children_with_tokens().any(|n| n.kind() == AMP);
|
||||
if borrowed {
|
||||
// check for a `mut` coming after the & -- `mut &self` != `&mut self`
|
||||
@@ -271,12 +271,12 @@ impl ast::SelfParam {
|
||||
.skip_while(|n| n.kind() != AMP)
|
||||
.any(|n| n.kind() == MUT_KW)
|
||||
{
|
||||
SelfParamFlavor::MutRef
|
||||
SelfParamKind::MutRef
|
||||
} else {
|
||||
SelfParamFlavor::Ref
|
||||
SelfParamKind::Ref
|
||||
}
|
||||
} else {
|
||||
SelfParamFlavor::Owned
|
||||
SelfParamKind::Owned
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user