diff options
author | Aleksey Kladov <[email protected]> | 2019-04-02 10:48:14 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-04-02 10:53:44 +0100 |
commit | 0e1e40676a82af782da2593c258c9af52ab78757 (patch) | |
tree | 335e06b2099a405ee11303e60e4922135762a357 | |
parent | cb5001c0a5ddadccd18fe787d89de3d6c3c8147f (diff) |
rename flavor to kind
-rw-r--r-- | crates/ra_hir/src/adt.rs | 28 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 18 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 18 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 30 |
6 files changed, 53 insertions, 53 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index 78ea8976b..e027eedd9 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs | |||
@@ -6,7 +6,7 @@ use std::sync::Arc; | |||
6 | use ra_arena::{RawId, Arena, impl_arena_id}; | 6 | use ra_arena::{RawId, Arena, impl_arena_id}; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | TreeArc, | 8 | TreeArc, |
9 | ast::{self, NameOwner, StructFlavor, TypeAscriptionOwner} | 9 | ast::{self, NameOwner, StructKind, TypeAscriptionOwner} |
10 | }; | 10 | }; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
@@ -47,7 +47,7 @@ pub struct StructData { | |||
47 | impl StructData { | 47 | impl StructData { |
48 | fn new(struct_def: &ast::StructDef) -> StructData { | 48 | fn new(struct_def: &ast::StructDef) -> StructData { |
49 | let name = struct_def.name().map(|n| n.as_name()); | 49 | let name = struct_def.name().map(|n| n.as_name()); |
50 | let variant_data = VariantData::new(struct_def.flavor()); | 50 | let variant_data = VariantData::new(struct_def.kind()); |
51 | let variant_data = Arc::new(variant_data); | 51 | let variant_data = Arc::new(variant_data); |
52 | StructData { name, variant_data } | 52 | StructData { name, variant_data } |
53 | } | 53 | } |
@@ -94,7 +94,7 @@ impl EnumData { | |||
94 | let variants = variants(&*enum_def) | 94 | let variants = variants(&*enum_def) |
95 | .map(|var| EnumVariantData { | 95 | .map(|var| EnumVariantData { |
96 | name: var.name().map(|it| it.as_name()), | 96 | name: var.name().map(|it| it.as_name()), |
97 | variant_data: Arc::new(VariantData::new(var.flavor())), | 97 | variant_data: Arc::new(VariantData::new(var.kind())), |
98 | }) | 98 | }) |
99 | .collect(); | 99 | .collect(); |
100 | Arc::new(EnumData { name, variants }) | 100 | Arc::new(EnumData { name, variants }) |
@@ -143,9 +143,9 @@ impl VariantData { | |||
143 | } | 143 | } |
144 | 144 | ||
145 | impl VariantData { | 145 | impl VariantData { |
146 | fn new(flavor: StructFlavor) -> Self { | 146 | fn new(flavor: StructKind) -> Self { |
147 | let inner = match flavor { | 147 | let inner = match flavor { |
148 | ast::StructFlavor::Tuple(fl) => { | 148 | ast::StructKind::Tuple(fl) => { |
149 | let fields = fl | 149 | let fields = fl |
150 | .fields() | 150 | .fields() |
151 | .enumerate() | 151 | .enumerate() |
@@ -156,7 +156,7 @@ impl VariantData { | |||
156 | .collect(); | 156 | .collect(); |
157 | VariantDataInner::Tuple(fields) | 157 | VariantDataInner::Tuple(fields) |
158 | } | 158 | } |
159 | ast::StructFlavor::Named(fl) => { | 159 | ast::StructKind::Named(fl) => { |
160 | let fields = fl | 160 | let fields = fl |
161 | .fields() | 161 | .fields() |
162 | .map(|fd| StructFieldData { | 162 | .map(|fd| StructFieldData { |
@@ -166,7 +166,7 @@ impl VariantData { | |||
166 | .collect(); | 166 | .collect(); |
167 | VariantDataInner::Struct(fields) | 167 | VariantDataInner::Struct(fields) |
168 | } | 168 | } |
169 | ast::StructFlavor::Unit => VariantDataInner::Unit, | 169 | ast::StructKind::Unit => VariantDataInner::Unit, |
170 | }; | 170 | }; |
171 | VariantData(inner) | 171 | VariantData(inner) |
172 | } | 172 | } |
@@ -200,27 +200,27 @@ impl StructField { | |||
200 | let fields = var_data.fields().unwrap(); | 200 | let fields = var_data.fields().unwrap(); |
201 | let ss; | 201 | let ss; |
202 | let es; | 202 | let es; |
203 | let (file_id, struct_flavor) = match self.parent { | 203 | let (file_id, struct_kind) = match self.parent { |
204 | VariantDef::Struct(s) => { | 204 | VariantDef::Struct(s) => { |
205 | let (file_id, source) = s.source(db); | 205 | let (file_id, source) = s.source(db); |
206 | ss = source; | 206 | ss = source; |
207 | (file_id, ss.flavor()) | 207 | (file_id, ss.kind()) |
208 | } | 208 | } |
209 | VariantDef::EnumVariant(e) => { | 209 | VariantDef::EnumVariant(e) => { |
210 | let (file_id, source) = e.source(db); | 210 | let (file_id, source) = e.source(db); |
211 | es = source; | 211 | es = source; |
212 | (file_id, es.flavor()) | 212 | (file_id, es.kind()) |
213 | } | 213 | } |
214 | }; | 214 | }; |
215 | 215 | ||
216 | let field_sources = match struct_flavor { | 216 | let field_sources = match struct_kind { |
217 | ast::StructFlavor::Tuple(fl) => { | 217 | ast::StructKind::Tuple(fl) => { |
218 | fl.fields().map(|it| FieldSource::Pos(it.to_owned())).collect() | 218 | fl.fields().map(|it| FieldSource::Pos(it.to_owned())).collect() |
219 | } | 219 | } |
220 | ast::StructFlavor::Named(fl) => { | 220 | ast::StructKind::Named(fl) => { |
221 | fl.fields().map(|it| FieldSource::Named(it.to_owned())).collect() | 221 | fl.fields().map(|it| FieldSource::Named(it.to_owned())).collect() |
222 | } | 222 | } |
223 | ast::StructFlavor::Unit => Vec::new(), | 223 | ast::StructKind::Unit => Vec::new(), |
224 | }; | 224 | }; |
225 | let field = field_sources | 225 | let field = field_sources |
226 | .into_iter() | 226 | .into_iter() |
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs index 334cb302b..f8bd0f784 100644 --- a/crates/ra_hir/src/code_model_impl/function.rs +++ b/crates/ra_hir/src/code_model_impl/function.rs | |||
@@ -20,12 +20,12 @@ impl FnSignature { | |||
20 | TypeRef::from_ast(type_ref) | 20 | TypeRef::from_ast(type_ref) |
21 | } else { | 21 | } else { |
22 | let self_type = TypeRef::Path(Name::self_type().into()); | 22 | let self_type = TypeRef::Path(Name::self_type().into()); |
23 | match self_param.flavor() { | 23 | match self_param.kind() { |
24 | ast::SelfParamFlavor::Owned => self_type, | 24 | ast::SelfParamKind::Owned => self_type, |
25 | ast::SelfParamFlavor::Ref => { | 25 | ast::SelfParamKind::Ref => { |
26 | TypeRef::Reference(Box::new(self_type), Mutability::Shared) | 26 | TypeRef::Reference(Box::new(self_type), Mutability::Shared) |
27 | } | 27 | } |
28 | ast::SelfParamFlavor::MutRef => { | 28 | ast::SelfParamKind::MutRef => { |
29 | TypeRef::Reference(Box::new(self_type), Mutability::Mut) | 29 | TypeRef::Reference(Box::new(self_type), Mutability::Mut) |
30 | } | 30 | } |
31 | } | 31 | } |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index ee2c4475c..45012827f 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -6,7 +6,7 @@ use rustc_hash::FxHashMap; | |||
6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; | 6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | SyntaxNodePtr, AstPtr, AstNode, | 8 | SyntaxNodePtr, AstPtr, AstNode, |
9 | ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor, TypeAscriptionOwner} | 9 | ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind, TypeAscriptionOwner} |
10 | }; | 10 | }; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
@@ -726,8 +726,8 @@ impl ExprCollector { | |||
726 | self.alloc_expr(Expr::Array { exprs }, syntax_ptr) | 726 | self.alloc_expr(Expr::Array { exprs }, syntax_ptr) |
727 | } | 727 | } |
728 | ast::ExprKind::Literal(e) => { | 728 | ast::ExprKind::Literal(e) => { |
729 | let lit = match e.flavor() { | 729 | let lit = match e.kind() { |
730 | LiteralFlavor::IntNumber { suffix } => { | 730 | LiteralKind::IntNumber { suffix } => { |
731 | let known_name = suffix | 731 | let known_name = suffix |
732 | .and_then(|it| IntTy::from_suffix(&it).map(UncertainIntTy::Known)); | 732 | .and_then(|it| IntTy::from_suffix(&it).map(UncertainIntTy::Known)); |
733 | 733 | ||
@@ -736,7 +736,7 @@ impl ExprCollector { | |||
736 | known_name.unwrap_or(UncertainIntTy::Unknown), | 736 | known_name.unwrap_or(UncertainIntTy::Unknown), |
737 | ) | 737 | ) |
738 | } | 738 | } |
739 | LiteralFlavor::FloatNumber { suffix } => { | 739 | LiteralKind::FloatNumber { suffix } => { |
740 | let known_name = suffix | 740 | let known_name = suffix |
741 | .and_then(|it| FloatTy::from_suffix(&it).map(UncertainFloatTy::Known)); | 741 | .and_then(|it| FloatTy::from_suffix(&it).map(UncertainFloatTy::Known)); |
742 | 742 | ||
@@ -745,13 +745,13 @@ impl ExprCollector { | |||
745 | known_name.unwrap_or(UncertainFloatTy::Unknown), | 745 | known_name.unwrap_or(UncertainFloatTy::Unknown), |
746 | ) | 746 | ) |
747 | } | 747 | } |
748 | LiteralFlavor::ByteString => Literal::ByteString(Default::default()), | 748 | LiteralKind::ByteString => Literal::ByteString(Default::default()), |
749 | LiteralFlavor::String => Literal::String(Default::default()), | 749 | LiteralKind::String => Literal::String(Default::default()), |
750 | LiteralFlavor::Byte => { | 750 | LiteralKind::Byte => { |
751 | Literal::Int(Default::default(), UncertainIntTy::Known(IntTy::u8())) | 751 | Literal::Int(Default::default(), UncertainIntTy::Known(IntTy::u8())) |
752 | } | 752 | } |
753 | LiteralFlavor::Bool => Literal::Bool(Default::default()), | 753 | LiteralKind::Bool => Literal::Bool(Default::default()), |
754 | LiteralFlavor::Char => Literal::Char(Default::default()), | 754 | LiteralKind::Char => Literal::Char(Default::default()), |
755 | }; | 755 | }; |
756 | self.alloc_expr(Expr::Literal(lit), syntax_ptr) | 756 | self.alloc_expr(Expr::Literal(lit), syntax_ptr) |
757 | } | 757 | } |
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::{ | |||
16 | generated::*, | 16 | generated::*, |
17 | traits::*, | 17 | traits::*, |
18 | tokens::*, | 18 | tokens::*, |
19 | extensions::{PathSegmentKind, StructFlavor, SelfParamFlavor}, | 19 | extensions::{PathSegmentKind, StructKind, SelfParamKind}, |
20 | expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralFlavor}, | 20 | expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralKind}, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | /// The main trait to go from untyped `SyntaxNode` to a typed ast. The | 23 | /// 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 { | |||
192 | } | 192 | } |
193 | 193 | ||
194 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] | 194 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] |
195 | pub enum LiteralFlavor { | 195 | pub enum LiteralKind { |
196 | String, | 196 | String, |
197 | ByteString, | 197 | ByteString, |
198 | Char, | 198 | Char, |
@@ -210,7 +210,7 @@ impl ast::Literal { | |||
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | pub fn flavor(&self) -> LiteralFlavor { | 213 | pub fn kind(&self) -> LiteralKind { |
214 | match self.token().kind() { | 214 | match self.token().kind() { |
215 | INT_NUMBER => { | 215 | INT_NUMBER => { |
216 | let allowed_suffix_list = [ | 216 | let allowed_suffix_list = [ |
@@ -222,7 +222,7 @@ impl ast::Literal { | |||
222 | .iter() | 222 | .iter() |
223 | .find(|&s| text.ends_with(s)) | 223 | .find(|&s| text.ends_with(s)) |
224 | .map(|&suf| SmolStr::new(suf)); | 224 | .map(|&suf| SmolStr::new(suf)); |
225 | LiteralFlavor::IntNumber { suffix } | 225 | LiteralKind::IntNumber { suffix } |
226 | } | 226 | } |
227 | FLOAT_NUMBER => { | 227 | FLOAT_NUMBER => { |
228 | let allowed_suffix_list = ["f64", "f32"]; | 228 | let allowed_suffix_list = ["f64", "f32"]; |
@@ -231,13 +231,13 @@ impl ast::Literal { | |||
231 | .iter() | 231 | .iter() |
232 | .find(|&s| text.ends_with(s)) | 232 | .find(|&s| text.ends_with(s)) |
233 | .map(|&suf| SmolStr::new(suf)); | 233 | .map(|&suf| SmolStr::new(suf)); |
234 | LiteralFlavor::FloatNumber { suffix: suffix } | 234 | LiteralKind::FloatNumber { suffix: suffix } |
235 | } | 235 | } |
236 | STRING | RAW_STRING => LiteralFlavor::String, | 236 | STRING | RAW_STRING => LiteralKind::String, |
237 | TRUE_KW | FALSE_KW => LiteralFlavor::Bool, | 237 | TRUE_KW | FALSE_KW => LiteralKind::Bool, |
238 | BYTE_STRING | RAW_BYTE_STRING => LiteralFlavor::ByteString, | 238 | BYTE_STRING | RAW_BYTE_STRING => LiteralKind::ByteString, |
239 | CHAR => LiteralFlavor::Char, | 239 | CHAR => LiteralKind::Char, |
240 | BYTE => LiteralFlavor::Byte, | 240 | BYTE => LiteralKind::Byte, |
241 | _ => unreachable!(), | 241 | _ => unreachable!(), |
242 | } | 242 | } |
243 | } | 243 | } |
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 { | |||
159 | } | 159 | } |
160 | 160 | ||
161 | #[derive(Debug, Clone, PartialEq, Eq)] | 161 | #[derive(Debug, Clone, PartialEq, Eq)] |
162 | pub enum StructFlavor<'a> { | 162 | pub enum StructKind<'a> { |
163 | Tuple(&'a ast::PosFieldDefList), | 163 | Tuple(&'a ast::PosFieldDefList), |
164 | Named(&'a ast::NamedFieldDefList), | 164 | Named(&'a ast::NamedFieldDefList), |
165 | Unit, | 165 | Unit, |
166 | } | 166 | } |
167 | 167 | ||
168 | impl StructFlavor<'_> { | 168 | impl StructKind<'_> { |
169 | fn from_node<N: AstNode>(node: &N) -> StructFlavor { | 169 | fn from_node<N: AstNode>(node: &N) -> StructKind { |
170 | if let Some(nfdl) = child_opt::<_, ast::NamedFieldDefList>(node) { | 170 | if let Some(nfdl) = child_opt::<_, ast::NamedFieldDefList>(node) { |
171 | StructFlavor::Named(nfdl) | 171 | StructKind::Named(nfdl) |
172 | } else if let Some(pfl) = child_opt::<_, ast::PosFieldDefList>(node) { | 172 | } else if let Some(pfl) = child_opt::<_, ast::PosFieldDefList>(node) { |
173 | StructFlavor::Tuple(pfl) | 173 | StructKind::Tuple(pfl) |
174 | } else { | 174 | } else { |
175 | StructFlavor::Unit | 175 | StructKind::Unit |
176 | } | 176 | } |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | impl ast::StructDef { | 180 | impl ast::StructDef { |
181 | pub fn flavor(&self) -> StructFlavor { | 181 | pub fn kind(&self) -> StructKind { |
182 | StructFlavor::from_node(self) | 182 | StructKind::from_node(self) |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
@@ -191,8 +191,8 @@ impl ast::EnumVariant { | |||
191 | .and_then(ast::EnumDef::cast) | 191 | .and_then(ast::EnumDef::cast) |
192 | .expect("EnumVariants are always nested in Enums") | 192 | .expect("EnumVariants are always nested in Enums") |
193 | } | 193 | } |
194 | pub fn flavor(&self) -> StructFlavor { | 194 | pub fn kind(&self) -> StructKind { |
195 | StructFlavor::from_node(self) | 195 | StructKind::from_node(self) |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
@@ -243,7 +243,7 @@ impl ast::ReferenceType { | |||
243 | } | 243 | } |
244 | 244 | ||
245 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | 245 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] |
246 | pub enum SelfParamFlavor { | 246 | pub enum SelfParamKind { |
247 | /// self | 247 | /// self |
248 | Owned, | 248 | Owned, |
249 | /// &self | 249 | /// &self |
@@ -261,7 +261,7 @@ impl ast::SelfParam { | |||
261 | .expect("invalid tree: self param must have self") | 261 | .expect("invalid tree: self param must have self") |
262 | } | 262 | } |
263 | 263 | ||
264 | pub fn flavor(&self) -> SelfParamFlavor { | 264 | pub fn kind(&self) -> SelfParamKind { |
265 | let borrowed = self.syntax().children_with_tokens().any(|n| n.kind() == AMP); | 265 | let borrowed = self.syntax().children_with_tokens().any(|n| n.kind() == AMP); |
266 | if borrowed { | 266 | if borrowed { |
267 | // check for a `mut` coming after the & -- `mut &self` != `&mut self` | 267 | // check for a `mut` coming after the & -- `mut &self` != `&mut self` |
@@ -271,12 +271,12 @@ impl ast::SelfParam { | |||
271 | .skip_while(|n| n.kind() != AMP) | 271 | .skip_while(|n| n.kind() != AMP) |
272 | .any(|n| n.kind() == MUT_KW) | 272 | .any(|n| n.kind() == MUT_KW) |
273 | { | 273 | { |
274 | SelfParamFlavor::MutRef | 274 | SelfParamKind::MutRef |
275 | } else { | 275 | } else { |
276 | SelfParamFlavor::Ref | 276 | SelfParamKind::Ref |
277 | } | 277 | } |
278 | } else { | 278 | } else { |
279 | SelfParamFlavor::Owned | 279 | SelfParamKind::Owned |
280 | } | 280 | } |
281 | } | 281 | } |
282 | } | 282 | } |