aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-04-02 10:48:14 +0100
committerAleksey Kladov <[email protected]>2019-04-02 10:53:44 +0100
commit0e1e40676a82af782da2593c258c9af52ab78757 (patch)
tree335e06b2099a405ee11303e60e4922135762a357 /crates/ra_syntax/src
parentcb5001c0a5ddadccd18fe787d89de3d6c3c8147f (diff)
rename flavor to kind
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs4
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs18
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs30
3 files changed, 26 insertions, 26 deletions
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)]
195pub enum LiteralFlavor { 195pub 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)]
162pub enum StructFlavor<'a> { 162pub 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
168impl StructFlavor<'_> { 168impl 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
180impl ast::StructDef { 180impl 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)]
246pub enum SelfParamFlavor { 246pub 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}