From 0e1e40676a82af782da2593c258c9af52ab78757 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 2 Apr 2019 12:48:14 +0300 Subject: rename flavor to kind --- crates/ra_syntax/src/ast.rs | 4 ++-- crates/ra_syntax/src/ast/expr_extensions.rs | 18 ++++++++--------- crates/ra_syntax/src/ast/extensions.rs | 30 ++++++++++++++--------------- 3 files changed, 26 insertions(+), 26 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 74a415bdd..dcc71eabe 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -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 diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index ddc26206f..b24f86cec 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs @@ -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!(), } } diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 87592bfd8..342581faf 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -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(node: &N) -> StructFlavor { +impl StructKind<'_> { + fn from_node(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 } } } -- cgit v1.2.3