diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 18 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/expr_ext.rs | 11 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 1359 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 10 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/node_ext.rs | 99 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 10 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/parsing/text_tree_sink.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ptr.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/validation.rs | 8 | ||||
-rw-r--r-- | crates/ra_syntax/src/validation/block.rs | 2 |
12 files changed, 766 insertions, 771 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index c65c485cb..fd426ece9 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -139,7 +139,7 @@ fn test_doc_comment_of_statics() { | |||
139 | ) | 139 | ) |
140 | .ok() | 140 | .ok() |
141 | .unwrap(); | 141 | .unwrap(); |
142 | let st = file.syntax().descendants().find_map(StaticDef::cast).unwrap(); | 142 | let st = file.syntax().descendants().find_map(Static::cast).unwrap(); |
143 | assert_eq!("Number of levels", st.doc_comment_text().unwrap()); | 143 | assert_eq!("Number of levels", st.doc_comment_text().unwrap()); |
144 | } | 144 | } |
145 | 145 | ||
@@ -235,7 +235,7 @@ fn test_comments_preserve_trailing_whitespace() { | |||
235 | ) | 235 | ) |
236 | .ok() | 236 | .ok() |
237 | .unwrap(); | 237 | .unwrap(); |
238 | let def = file.syntax().descendants().find_map(StructDef::cast).unwrap(); | 238 | let def = file.syntax().descendants().find_map(Struct::cast).unwrap(); |
239 | assert_eq!( | 239 | assert_eq!( |
240 | "Representation of a Realm. \nIn the specification these are called Realm Records.", | 240 | "Representation of a Realm. \nIn the specification these are called Realm Records.", |
241 | def.doc_comment_text().unwrap() | 241 | def.doc_comment_text().unwrap() |
@@ -286,7 +286,7 @@ where | |||
286 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 286 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
287 | 287 | ||
288 | assert!(pred.for_token().is_none()); | 288 | assert!(pred.for_token().is_none()); |
289 | assert!(pred.type_param_list().is_none()); | 289 | assert!(pred.generic_param_list().is_none()); |
290 | assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); | 290 | assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); |
291 | assert_bound("Clone", bounds.next()); | 291 | assert_bound("Clone", bounds.next()); |
292 | assert_bound("Copy", bounds.next()); | 292 | assert_bound("Copy", bounds.next()); |
@@ -325,7 +325,7 @@ where | |||
325 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 325 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
326 | 326 | ||
327 | assert!(pred.for_token().is_some()); | 327 | assert!(pred.for_token().is_some()); |
328 | assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string()); | 328 | assert_eq!("<'a>", pred.generic_param_list().unwrap().syntax().text().to_string()); |
329 | assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); | 329 | assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); |
330 | assert_bound("Fn(&'a str)", bounds.next()); | 330 | assert_bound("Fn(&'a str)", bounds.next()); |
331 | } | 331 | } |
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 6ebe10ff6..8d3e42f25 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -29,9 +29,9 @@ impl ast::BinExpr { | |||
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | impl ast::FnDef { | 32 | impl ast::Fn { |
33 | #[must_use] | 33 | #[must_use] |
34 | pub fn with_body(&self, body: ast::BlockExpr) -> ast::FnDef { | 34 | pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn { |
35 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); | 35 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); |
36 | let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { | 36 | let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { |
37 | old_body.syntax().clone().into() | 37 | old_body.syntax().clone().into() |
@@ -116,18 +116,18 @@ impl ast::AssocItemList { | |||
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | impl ast::RecordFieldList { | 119 | impl ast::RecordExprFieldList { |
120 | #[must_use] | 120 | #[must_use] |
121 | pub fn append_field(&self, field: &ast::RecordField) -> ast::RecordFieldList { | 121 | pub fn append_field(&self, field: &ast::RecordExprField) -> ast::RecordExprFieldList { |
122 | self.insert_field(InsertPosition::Last, field) | 122 | self.insert_field(InsertPosition::Last, field) |
123 | } | 123 | } |
124 | 124 | ||
125 | #[must_use] | 125 | #[must_use] |
126 | pub fn insert_field( | 126 | pub fn insert_field( |
127 | &self, | 127 | &self, |
128 | position: InsertPosition<&'_ ast::RecordField>, | 128 | position: InsertPosition<&'_ ast::RecordExprField>, |
129 | field: &ast::RecordField, | 129 | field: &ast::RecordExprField, |
130 | ) -> ast::RecordFieldList { | 130 | ) -> ast::RecordExprFieldList { |
131 | let is_multiline = self.syntax().text().contains_char('\n'); | 131 | let is_multiline = self.syntax().text().contains_char('\n'); |
132 | let ws; | 132 | let ws; |
133 | let space = if is_multiline { | 133 | let space = if is_multiline { |
@@ -192,9 +192,9 @@ impl ast::RecordFieldList { | |||
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | impl ast::TypeAliasDef { | 195 | impl ast::TypeAlias { |
196 | #[must_use] | 196 | #[must_use] |
197 | pub fn remove_bounds(&self) -> ast::TypeAliasDef { | 197 | pub fn remove_bounds(&self) -> ast::TypeAlias { |
198 | let colon = match self.colon_token() { | 198 | let colon = match self.colon_token() { |
199 | Some(it) => it, | 199 | Some(it) => it, |
200 | None => return self.clone(), | 200 | None => return self.clone(), |
diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/ra_syntax/src/ast/expr_ext.rs index 69c85c809..f5ba87223 100644 --- a/crates/ra_syntax/src/ast/expr_ext.rs +++ b/crates/ra_syntax/src/ast/expr_ext.rs | |||
@@ -333,13 +333,12 @@ impl ast::Literal { | |||
333 | 333 | ||
334 | match token.kind() { | 334 | match token.kind() { |
335 | INT_NUMBER => { | 335 | INT_NUMBER => { |
336 | // FYI: there was a bug here previously, thus an if statement bellow is necessary. | 336 | // FYI: there was a bug here previously, thus the if statement below is necessary. |
337 | // The lexer treats e.g. `1f64` as an integer literal. See | 337 | // The lexer treats e.g. `1f64` as an integer literal. See |
338 | // https://github.com/rust-analyzer/rust-analyzer/issues/1592 | 338 | // https://github.com/rust-analyzer/rust-analyzer/issues/1592 |
339 | // and the comments on the linked PR. | 339 | // and the comments on the linked PR. |
340 | 340 | ||
341 | let text = token.text(); | 341 | let text = token.text(); |
342 | |||
343 | if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) { | 342 | if let suffix @ Some(_) = Self::find_suffix(&text, &FLOAT_SUFFIXES) { |
344 | LiteralKind::FloatNumber { suffix } | 343 | LiteralKind::FloatNumber { suffix } |
345 | } else { | 344 | } else { |
@@ -401,7 +400,7 @@ impl ast::BlockExpr { | |||
401 | Some(it) => it, | 400 | Some(it) => it, |
402 | None => return true, | 401 | None => return true, |
403 | }; | 402 | }; |
404 | !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) | 403 | !matches!(parent.kind(), FN | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) |
405 | } | 404 | } |
406 | } | 405 | } |
407 | 406 | ||
@@ -412,8 +411,8 @@ fn test_literal_with_attr() { | |||
412 | assert_eq!(lit.token().text(), r#""Hello""#); | 411 | assert_eq!(lit.token().text(), r#""Hello""#); |
413 | } | 412 | } |
414 | 413 | ||
415 | impl ast::RecordField { | 414 | impl ast::RecordExprField { |
416 | pub fn parent_record_lit(&self) -> ast::RecordLit { | 415 | pub fn parent_record_lit(&self) -> ast::RecordExpr { |
417 | self.syntax().ancestors().find_map(ast::RecordLit::cast).unwrap() | 416 | self.syntax().ancestors().find_map(ast::RecordExpr::cast).unwrap() |
418 | } | 417 | } |
419 | } | 418 | } |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index be657699f..4306efe13 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -24,36 +24,38 @@ impl Attr { | |||
24 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } | 24 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } |
25 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 25 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
26 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 26 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
27 | pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) } | 27 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } |
28 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } | ||
28 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 29 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
29 | } | 30 | } |
30 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 31 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
31 | pub struct ConstDef { | 32 | pub struct Const { |
32 | pub(crate) syntax: SyntaxNode, | 33 | pub(crate) syntax: SyntaxNode, |
33 | } | 34 | } |
34 | impl ast::AttrsOwner for ConstDef {} | 35 | impl ast::AttrsOwner for Const {} |
35 | impl ast::NameOwner for ConstDef {} | 36 | impl ast::NameOwner for Const {} |
36 | impl ast::VisibilityOwner for ConstDef {} | 37 | impl ast::VisibilityOwner for Const {} |
37 | impl ast::TypeAscriptionOwner for ConstDef {} | 38 | impl Const { |
38 | impl ConstDef { | ||
39 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 39 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } |
40 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 40 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
41 | pub fn underscore_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![_]) } | ||
41 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 42 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
43 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
42 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 44 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
43 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 45 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
44 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 46 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
45 | } | 47 | } |
46 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 48 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
47 | pub struct EnumDef { | 49 | pub struct Enum { |
48 | pub(crate) syntax: SyntaxNode, | 50 | pub(crate) syntax: SyntaxNode, |
49 | } | 51 | } |
50 | impl ast::AttrsOwner for EnumDef {} | 52 | impl ast::AttrsOwner for Enum {} |
51 | impl ast::NameOwner for EnumDef {} | 53 | impl ast::NameOwner for Enum {} |
52 | impl ast::VisibilityOwner for EnumDef {} | 54 | impl ast::VisibilityOwner for Enum {} |
53 | impl ast::TypeParamsOwner for EnumDef {} | 55 | impl ast::GenericParamsOwner for Enum {} |
54 | impl EnumDef { | 56 | impl Enum { |
55 | pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } | 57 | pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } |
56 | pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } | 58 | pub fn variant_list(&self) -> Option<VariantList> { support::child(&self.syntax) } |
57 | } | 59 | } |
58 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 60 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
59 | pub struct ExternBlock { | 61 | pub struct ExternBlock { |
@@ -79,19 +81,19 @@ impl ExternCrate { | |||
79 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 81 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
80 | } | 82 | } |
81 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 83 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
82 | pub struct FnDef { | 84 | pub struct Fn { |
83 | pub(crate) syntax: SyntaxNode, | 85 | pub(crate) syntax: SyntaxNode, |
84 | } | 86 | } |
85 | impl ast::AttrsOwner for FnDef {} | 87 | impl ast::AttrsOwner for Fn {} |
86 | impl ast::NameOwner for FnDef {} | 88 | impl ast::NameOwner for Fn {} |
87 | impl ast::VisibilityOwner for FnDef {} | 89 | impl ast::VisibilityOwner for Fn {} |
88 | impl ast::TypeParamsOwner for FnDef {} | 90 | impl ast::GenericParamsOwner for Fn {} |
89 | impl FnDef { | 91 | impl Fn { |
90 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
91 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
92 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 92 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } |
93 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } | 93 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } |
94 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
94 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | 95 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } |
96 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
95 | pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } | 97 | pub fn fn_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![fn]) } |
96 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 98 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } |
97 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 99 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } |
@@ -99,17 +101,18 @@ impl FnDef { | |||
99 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 101 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
100 | } | 102 | } |
101 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 103 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
102 | pub struct ImplDef { | 104 | pub struct Impl { |
103 | pub(crate) syntax: SyntaxNode, | 105 | pub(crate) syntax: SyntaxNode, |
104 | } | 106 | } |
105 | impl ast::AttrsOwner for ImplDef {} | 107 | impl ast::AttrsOwner for Impl {} |
106 | impl ast::VisibilityOwner for ImplDef {} | 108 | impl ast::VisibilityOwner for Impl {} |
107 | impl ast::TypeParamsOwner for ImplDef {} | 109 | impl ast::GenericParamsOwner for Impl {} |
108 | impl ImplDef { | 110 | impl Impl { |
109 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
110 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 111 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } |
111 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | 112 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } |
112 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } | 113 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![impl]) } |
114 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
115 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
113 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } | 116 | pub fn excl_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![!]) } |
114 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | 117 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } |
115 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } | 118 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } |
@@ -139,78 +142,76 @@ impl Module { | |||
139 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 142 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
140 | } | 143 | } |
141 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 144 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
142 | pub struct StaticDef { | 145 | pub struct Static { |
143 | pub(crate) syntax: SyntaxNode, | 146 | pub(crate) syntax: SyntaxNode, |
144 | } | 147 | } |
145 | impl ast::AttrsOwner for StaticDef {} | 148 | impl ast::AttrsOwner for Static {} |
146 | impl ast::NameOwner for StaticDef {} | 149 | impl ast::NameOwner for Static {} |
147 | impl ast::VisibilityOwner for StaticDef {} | 150 | impl ast::VisibilityOwner for Static {} |
148 | impl ast::TypeAscriptionOwner for StaticDef {} | 151 | impl Static { |
149 | impl StaticDef { | ||
150 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | 152 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } |
151 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 153 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
152 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 154 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
155 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
153 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 156 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
154 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 157 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
155 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 158 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
156 | } | 159 | } |
157 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 160 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
158 | pub struct StructDef { | 161 | pub struct Struct { |
159 | pub(crate) syntax: SyntaxNode, | 162 | pub(crate) syntax: SyntaxNode, |
160 | } | 163 | } |
161 | impl ast::AttrsOwner for StructDef {} | 164 | impl ast::AttrsOwner for Struct {} |
162 | impl ast::NameOwner for StructDef {} | 165 | impl ast::NameOwner for Struct {} |
163 | impl ast::VisibilityOwner for StructDef {} | 166 | impl ast::VisibilityOwner for Struct {} |
164 | impl ast::TypeParamsOwner for StructDef {} | 167 | impl ast::GenericParamsOwner for Struct {} |
165 | impl StructDef { | 168 | impl Struct { |
166 | pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) } | 169 | pub fn struct_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![struct]) } |
167 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 170 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
168 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | 171 | pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) } |
169 | } | 172 | } |
170 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 173 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
171 | pub struct TraitDef { | 174 | pub struct Trait { |
172 | pub(crate) syntax: SyntaxNode, | 175 | pub(crate) syntax: SyntaxNode, |
173 | } | 176 | } |
174 | impl ast::AttrsOwner for TraitDef {} | 177 | impl ast::AttrsOwner for Trait {} |
175 | impl ast::NameOwner for TraitDef {} | 178 | impl ast::NameOwner for Trait {} |
176 | impl ast::VisibilityOwner for TraitDef {} | 179 | impl ast::VisibilityOwner for Trait {} |
177 | impl ast::TypeParamsOwner for TraitDef {} | 180 | impl ast::GenericParamsOwner for Trait {} |
178 | impl ast::TypeBoundsOwner for TraitDef {} | 181 | impl ast::TypeBoundsOwner for Trait {} |
179 | impl TraitDef { | 182 | impl Trait { |
180 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } | 183 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) } |
181 | pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) } | 184 | pub fn auto_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![auto]) } |
182 | pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } | 185 | pub fn trait_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![trait]) } |
183 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } | 186 | pub fn assoc_item_list(&self) -> Option<AssocItemList> { support::child(&self.syntax) } |
184 | } | 187 | } |
185 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 188 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
186 | pub struct TypeAliasDef { | 189 | pub struct TypeAlias { |
187 | pub(crate) syntax: SyntaxNode, | 190 | pub(crate) syntax: SyntaxNode, |
188 | } | 191 | } |
189 | impl ast::AttrsOwner for TypeAliasDef {} | 192 | impl ast::AttrsOwner for TypeAlias {} |
190 | impl ast::NameOwner for TypeAliasDef {} | 193 | impl ast::NameOwner for TypeAlias {} |
191 | impl ast::VisibilityOwner for TypeAliasDef {} | 194 | impl ast::VisibilityOwner for TypeAlias {} |
192 | impl ast::TypeParamsOwner for TypeAliasDef {} | 195 | impl ast::GenericParamsOwner for TypeAlias {} |
193 | impl ast::TypeBoundsOwner for TypeAliasDef {} | 196 | impl ast::TypeBoundsOwner for TypeAlias {} |
194 | impl TypeAliasDef { | 197 | impl TypeAlias { |
195 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } | 198 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![default]) } |
196 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } | 199 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) } |
197 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 200 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
198 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 201 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
199 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 202 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
200 | } | 203 | } |
201 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 204 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
202 | pub struct UnionDef { | 205 | pub struct Union { |
203 | pub(crate) syntax: SyntaxNode, | 206 | pub(crate) syntax: SyntaxNode, |
204 | } | 207 | } |
205 | impl ast::AttrsOwner for UnionDef {} | 208 | impl ast::AttrsOwner for Union {} |
206 | impl ast::NameOwner for UnionDef {} | 209 | impl ast::NameOwner for Union {} |
207 | impl ast::VisibilityOwner for UnionDef {} | 210 | impl ast::VisibilityOwner for Union {} |
208 | impl ast::TypeParamsOwner for UnionDef {} | 211 | impl ast::GenericParamsOwner for Union {} |
209 | impl UnionDef { | 212 | impl Union { |
210 | pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } | 213 | pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } |
211 | pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { | 214 | pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } |
212 | support::child(&self.syntax) | ||
213 | } | ||
214 | } | 215 | } |
215 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 216 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
216 | pub struct Use { | 217 | pub struct Use { |
@@ -303,16 +304,16 @@ impl UseTreeList { | |||
303 | pub struct Abi { | 304 | pub struct Abi { |
304 | pub(crate) syntax: SyntaxNode, | 305 | pub(crate) syntax: SyntaxNode, |
305 | } | 306 | } |
306 | impl Abi {} | 307 | impl Abi { |
308 | pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } | ||
309 | } | ||
307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 310 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
308 | pub struct TypeParamList { | 311 | pub struct GenericParamList { |
309 | pub(crate) syntax: SyntaxNode, | 312 | pub(crate) syntax: SyntaxNode, |
310 | } | 313 | } |
311 | impl TypeParamList { | 314 | impl GenericParamList { |
312 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | 315 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } |
313 | pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) } | 316 | pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) } |
314 | pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) } | ||
315 | pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) } | ||
316 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } | 317 | pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) } |
317 | } | 318 | } |
318 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 319 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -322,6 +323,7 @@ pub struct ParamList { | |||
322 | impl ParamList { | 323 | impl ParamList { |
323 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | 324 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } |
324 | pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } | 325 | pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } |
326 | pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) } | ||
325 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } | 327 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } |
326 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 328 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
327 | } | 329 | } |
@@ -331,7 +333,7 @@ pub struct RetType { | |||
331 | } | 333 | } |
332 | impl RetType { | 334 | impl RetType { |
333 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } | 335 | pub fn thin_arrow_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![->]) } |
334 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 336 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
335 | } | 337 | } |
336 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 338 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
337 | pub struct WhereClause { | 339 | pub struct WhereClause { |
@@ -355,80 +357,167 @@ impl BlockExpr { | |||
355 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 357 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
356 | } | 358 | } |
357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 359 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
358 | pub struct RecordFieldDefList { | 360 | pub struct SelfParam { |
361 | pub(crate) syntax: SyntaxNode, | ||
362 | } | ||
363 | impl ast::AttrsOwner for SelfParam {} | ||
364 | impl SelfParam { | ||
365 | pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } | ||
366 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
367 | support::token(&self.syntax, T![lifetime]) | ||
368 | } | ||
369 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | ||
370 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
371 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
372 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
373 | } | ||
374 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
375 | pub struct Param { | ||
376 | pub(crate) syntax: SyntaxNode, | ||
377 | } | ||
378 | impl ast::AttrsOwner for Param {} | ||
379 | impl Param { | ||
380 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
381 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
382 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
383 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | ||
384 | } | ||
385 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
386 | pub struct TypeBoundList { | ||
387 | pub(crate) syntax: SyntaxNode, | ||
388 | } | ||
389 | impl TypeBoundList { | ||
390 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
391 | } | ||
392 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
393 | pub struct RecordFieldList { | ||
359 | pub(crate) syntax: SyntaxNode, | 394 | pub(crate) syntax: SyntaxNode, |
360 | } | 395 | } |
361 | impl RecordFieldDefList { | 396 | impl RecordFieldList { |
362 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | 397 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } |
363 | pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } | 398 | pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } |
364 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 399 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
365 | } | 400 | } |
366 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 401 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
367 | pub struct TupleFieldDefList { | 402 | pub struct TupleFieldList { |
368 | pub(crate) syntax: SyntaxNode, | 403 | pub(crate) syntax: SyntaxNode, |
369 | } | 404 | } |
370 | impl TupleFieldDefList { | 405 | impl TupleFieldList { |
371 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | 406 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } |
372 | pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } | 407 | pub fn fields(&self) -> AstChildren<TupleField> { support::children(&self.syntax) } |
373 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 408 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
374 | } | 409 | } |
375 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 410 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
376 | pub struct RecordFieldDef { | 411 | pub struct RecordField { |
377 | pub(crate) syntax: SyntaxNode, | 412 | pub(crate) syntax: SyntaxNode, |
378 | } | 413 | } |
379 | impl ast::AttrsOwner for RecordFieldDef {} | 414 | impl ast::AttrsOwner for RecordField {} |
380 | impl ast::NameOwner for RecordFieldDef {} | 415 | impl ast::NameOwner for RecordField {} |
381 | impl ast::VisibilityOwner for RecordFieldDef {} | 416 | impl ast::VisibilityOwner for RecordField {} |
382 | impl ast::TypeAscriptionOwner for RecordFieldDef {} | 417 | impl RecordField { |
383 | impl RecordFieldDef { | ||
384 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 418 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
419 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
385 | } | 420 | } |
386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 421 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
387 | pub struct TupleFieldDef { | 422 | pub struct TupleField { |
388 | pub(crate) syntax: SyntaxNode, | 423 | pub(crate) syntax: SyntaxNode, |
389 | } | 424 | } |
390 | impl ast::AttrsOwner for TupleFieldDef {} | 425 | impl ast::AttrsOwner for TupleField {} |
391 | impl ast::NameOwner for TupleFieldDef {} | 426 | impl ast::VisibilityOwner for TupleField {} |
392 | impl ast::VisibilityOwner for TupleFieldDef {} | 427 | impl TupleField { |
393 | impl TupleFieldDef { | 428 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
394 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
395 | } | 429 | } |
396 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 430 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
397 | pub struct EnumVariantList { | 431 | pub struct VariantList { |
398 | pub(crate) syntax: SyntaxNode, | 432 | pub(crate) syntax: SyntaxNode, |
399 | } | 433 | } |
400 | impl EnumVariantList { | 434 | impl VariantList { |
401 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | 435 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } |
402 | pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } | 436 | pub fn variants(&self) -> AstChildren<Variant> { support::children(&self.syntax) } |
403 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 437 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
404 | } | 438 | } |
405 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 439 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
406 | pub struct EnumVariant { | 440 | pub struct Variant { |
407 | pub(crate) syntax: SyntaxNode, | 441 | pub(crate) syntax: SyntaxNode, |
408 | } | 442 | } |
409 | impl ast::AttrsOwner for EnumVariant {} | 443 | impl ast::AttrsOwner for Variant {} |
410 | impl ast::NameOwner for EnumVariant {} | 444 | impl ast::NameOwner for Variant {} |
411 | impl ast::VisibilityOwner for EnumVariant {} | 445 | impl ast::VisibilityOwner for Variant {} |
412 | impl EnumVariant { | 446 | impl Variant { |
413 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | 447 | pub fn field_list(&self) -> Option<FieldList> { support::child(&self.syntax) } |
414 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 448 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
415 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 449 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
416 | } | 450 | } |
417 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 451 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
418 | pub struct TypeBoundList { | 452 | pub struct AssocItemList { |
419 | pub(crate) syntax: SyntaxNode, | 453 | pub(crate) syntax: SyntaxNode, |
420 | } | 454 | } |
421 | impl TypeBoundList { | 455 | impl ast::AttrsOwner for AssocItemList {} |
422 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | 456 | impl AssocItemList { |
457 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
458 | pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } | ||
459 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
423 | } | 460 | } |
424 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 461 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
425 | pub struct AssocItemList { | 462 | pub struct ExternItemList { |
426 | pub(crate) syntax: SyntaxNode, | 463 | pub(crate) syntax: SyntaxNode, |
427 | } | 464 | } |
428 | impl AssocItemList { | 465 | impl ast::AttrsOwner for ExternItemList {} |
466 | impl ExternItemList { | ||
467 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
468 | pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } | ||
469 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
470 | } | ||
471 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
472 | pub struct LifetimeParam { | ||
473 | pub(crate) syntax: SyntaxNode, | ||
474 | } | ||
475 | impl ast::AttrsOwner for LifetimeParam {} | ||
476 | impl LifetimeParam { | ||
477 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
478 | support::token(&self.syntax, T![lifetime]) | ||
479 | } | ||
480 | } | ||
481 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
482 | pub struct TypeParam { | ||
483 | pub(crate) syntax: SyntaxNode, | ||
484 | } | ||
485 | impl ast::AttrsOwner for TypeParam {} | ||
486 | impl ast::NameOwner for TypeParam {} | ||
487 | impl ast::TypeBoundsOwner for TypeParam {} | ||
488 | impl TypeParam { | ||
489 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
490 | pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
491 | } | ||
492 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
493 | pub struct ConstParam { | ||
494 | pub(crate) syntax: SyntaxNode, | ||
495 | } | ||
496 | impl ast::AttrsOwner for ConstParam {} | ||
497 | impl ast::NameOwner for ConstParam {} | ||
498 | impl ConstParam { | ||
499 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
500 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
501 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
502 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
503 | pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
504 | } | ||
505 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
506 | pub struct Literal { | ||
507 | pub(crate) syntax: SyntaxNode, | ||
508 | } | ||
509 | impl Literal {} | ||
510 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
511 | pub struct TokenTree { | ||
512 | pub(crate) syntax: SyntaxNode, | ||
513 | } | ||
514 | impl TokenTree { | ||
515 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | ||
516 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | ||
429 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | 517 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } |
430 | pub fn assoc_items(&self) -> AstChildren<AssocItem> { support::children(&self.syntax) } | ||
431 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 518 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
519 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } | ||
520 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | ||
432 | } | 521 | } |
433 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 522 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
434 | pub struct ParenType { | 523 | pub struct ParenType { |
@@ -436,7 +525,7 @@ pub struct ParenType { | |||
436 | } | 525 | } |
437 | impl ParenType { | 526 | impl ParenType { |
438 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | 527 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } |
439 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 528 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
440 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 529 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
441 | } | 530 | } |
442 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 531 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -470,7 +559,7 @@ impl PointerType { | |||
470 | pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } | 559 | pub fn star_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![*]) } |
471 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | 560 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } |
472 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 561 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
473 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 562 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
474 | } | 563 | } |
475 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 564 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
476 | pub struct ArrayType { | 565 | pub struct ArrayType { |
@@ -478,7 +567,7 @@ pub struct ArrayType { | |||
478 | } | 567 | } |
479 | impl ArrayType { | 568 | impl ArrayType { |
480 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } | 569 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } |
481 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 570 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
482 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 571 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
483 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 572 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
484 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 573 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
@@ -489,7 +578,7 @@ pub struct SliceType { | |||
489 | } | 578 | } |
490 | impl SliceType { | 579 | impl SliceType { |
491 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } | 580 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } |
492 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 581 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
493 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 582 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
494 | } | 583 | } |
495 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 584 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -502,7 +591,7 @@ impl ReferenceType { | |||
502 | support::token(&self.syntax, T![lifetime]) | 591 | support::token(&self.syntax, T![lifetime]) |
503 | } | 592 | } |
504 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | 593 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } |
505 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 594 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
506 | } | 595 | } |
507 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 596 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
508 | pub struct PlaceholderType { | 597 | pub struct PlaceholderType { |
@@ -528,8 +617,8 @@ pub struct ForType { | |||
528 | } | 617 | } |
529 | impl ForType { | 618 | impl ForType { |
530 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | 619 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } |
531 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } | 620 | pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) } |
532 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 621 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
533 | } | 622 | } |
534 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 623 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
535 | pub struct ImplTraitType { | 624 | pub struct ImplTraitType { |
@@ -793,7 +882,7 @@ impl ast::AttrsOwner for CastExpr {} | |||
793 | impl CastExpr { | 882 | impl CastExpr { |
794 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 883 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
795 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } | 884 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) } |
796 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 885 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
797 | } | 886 | } |
798 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 887 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
799 | pub struct RefExpr { | 888 | pub struct RefExpr { |
@@ -837,11 +926,6 @@ pub struct BinExpr { | |||
837 | impl ast::AttrsOwner for BinExpr {} | 926 | impl ast::AttrsOwner for BinExpr {} |
838 | impl BinExpr {} | 927 | impl BinExpr {} |
839 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 928 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
840 | pub struct Literal { | ||
841 | pub(crate) syntax: SyntaxNode, | ||
842 | } | ||
843 | impl Literal {} | ||
844 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
845 | pub struct MatchExpr { | 929 | pub struct MatchExpr { |
846 | pub(crate) syntax: SyntaxNode, | 930 | pub(crate) syntax: SyntaxNode, |
847 | } | 931 | } |
@@ -880,30 +964,32 @@ impl MatchGuard { | |||
880 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 964 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
881 | } | 965 | } |
882 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 966 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
883 | pub struct RecordLit { | 967 | pub struct RecordExpr { |
884 | pub(crate) syntax: SyntaxNode, | 968 | pub(crate) syntax: SyntaxNode, |
885 | } | 969 | } |
886 | impl RecordLit { | 970 | impl RecordExpr { |
887 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | 971 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } |
888 | pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } | 972 | pub fn record_expr_field_list(&self) -> Option<RecordExprFieldList> { |
973 | support::child(&self.syntax) | ||
974 | } | ||
889 | } | 975 | } |
890 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 976 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
891 | pub struct RecordFieldList { | 977 | pub struct RecordExprFieldList { |
892 | pub(crate) syntax: SyntaxNode, | 978 | pub(crate) syntax: SyntaxNode, |
893 | } | 979 | } |
894 | impl RecordFieldList { | 980 | impl RecordExprFieldList { |
895 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | 981 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } |
896 | pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } | 982 | pub fn fields(&self) -> AstChildren<RecordExprField> { support::children(&self.syntax) } |
897 | pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } | 983 | pub fn dotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![..]) } |
898 | pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } | 984 | pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } |
899 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | 985 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } |
900 | } | 986 | } |
901 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 987 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
902 | pub struct RecordField { | 988 | pub struct RecordExprField { |
903 | pub(crate) syntax: SyntaxNode, | 989 | pub(crate) syntax: SyntaxNode, |
904 | } | 990 | } |
905 | impl ast::AttrsOwner for RecordField {} | 991 | impl ast::AttrsOwner for RecordExprField {} |
906 | impl RecordField { | 992 | impl RecordExprField { |
907 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 993 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
908 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 994 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
909 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 995 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
@@ -1058,18 +1144,6 @@ impl TuplePat { | |||
1058 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | 1144 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } |
1059 | } | 1145 | } |
1060 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1146 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1061 | pub struct TokenTree { | ||
1062 | pub(crate) syntax: SyntaxNode, | ||
1063 | } | ||
1064 | impl TokenTree { | ||
1065 | pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } | ||
1066 | pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } | ||
1067 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
1068 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
1069 | pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['[']) } | ||
1070 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | ||
1071 | } | ||
1072 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1073 | pub struct MacroDef { | 1147 | pub struct MacroDef { |
1074 | pub(crate) syntax: SyntaxNode, | 1148 | pub(crate) syntax: SyntaxNode, |
1075 | } | 1149 | } |
@@ -1092,40 +1166,6 @@ impl MacroStmts { | |||
1092 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1166 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1093 | } | 1167 | } |
1094 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1168 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1095 | pub struct TypeParam { | ||
1096 | pub(crate) syntax: SyntaxNode, | ||
1097 | } | ||
1098 | impl ast::AttrsOwner for TypeParam {} | ||
1099 | impl ast::NameOwner for TypeParam {} | ||
1100 | impl ast::TypeBoundsOwner for TypeParam {} | ||
1101 | impl TypeParam { | ||
1102 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
1103 | pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
1104 | } | ||
1105 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1106 | pub struct LifetimeParam { | ||
1107 | pub(crate) syntax: SyntaxNode, | ||
1108 | } | ||
1109 | impl ast::AttrsOwner for LifetimeParam {} | ||
1110 | impl LifetimeParam { | ||
1111 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
1112 | support::token(&self.syntax, T![lifetime]) | ||
1113 | } | ||
1114 | } | ||
1115 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1116 | pub struct ConstParam { | ||
1117 | pub(crate) syntax: SyntaxNode, | ||
1118 | } | ||
1119 | impl ast::AttrsOwner for ConstParam {} | ||
1120 | impl ast::NameOwner for ConstParam {} | ||
1121 | impl ast::TypeAscriptionOwner for ConstParam {} | ||
1122 | impl ConstParam { | ||
1123 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![const]) } | ||
1124 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
1125 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
1126 | pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1127 | } | ||
1128 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1129 | pub struct TypeBound { | 1169 | pub struct TypeBound { |
1130 | pub(crate) syntax: SyntaxNode, | 1170 | pub(crate) syntax: SyntaxNode, |
1131 | } | 1171 | } |
@@ -1143,7 +1183,7 @@ pub struct WherePred { | |||
1143 | impl ast::TypeBoundsOwner for WherePred {} | 1183 | impl ast::TypeBoundsOwner for WherePred {} |
1144 | impl WherePred { | 1184 | impl WherePred { |
1145 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | 1185 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } |
1146 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } | 1186 | pub fn generic_param_list(&self) -> Option<GenericParamList> { support::child(&self.syntax) } |
1147 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | 1187 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { |
1148 | support::token(&self.syntax, T![lifetime]) | 1188 | support::token(&self.syntax, T![lifetime]) |
1149 | } | 1189 | } |
@@ -1163,42 +1203,16 @@ pub struct LetStmt { | |||
1163 | pub(crate) syntax: SyntaxNode, | 1203 | pub(crate) syntax: SyntaxNode, |
1164 | } | 1204 | } |
1165 | impl ast::AttrsOwner for LetStmt {} | 1205 | impl ast::AttrsOwner for LetStmt {} |
1166 | impl ast::TypeAscriptionOwner for LetStmt {} | ||
1167 | impl LetStmt { | 1206 | impl LetStmt { |
1168 | pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } | 1207 | pub fn let_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![let]) } |
1169 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1208 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
1170 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | 1209 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } |
1210 | pub fn ty(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
1171 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | 1211 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } |
1172 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } | 1212 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } |
1173 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 1213 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
1174 | } | 1214 | } |
1175 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1215 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1176 | pub struct SelfParam { | ||
1177 | pub(crate) syntax: SyntaxNode, | ||
1178 | } | ||
1179 | impl ast::AttrsOwner for SelfParam {} | ||
1180 | impl ast::TypeAscriptionOwner for SelfParam {} | ||
1181 | impl SelfParam { | ||
1182 | pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } | ||
1183 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
1184 | support::token(&self.syntax, T![lifetime]) | ||
1185 | } | ||
1186 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } | ||
1187 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
1188 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
1189 | } | ||
1190 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1191 | pub struct Param { | ||
1192 | pub(crate) syntax: SyntaxNode, | ||
1193 | } | ||
1194 | impl ast::AttrsOwner for Param {} | ||
1195 | impl ast::TypeAscriptionOwner for Param {} | ||
1196 | impl Param { | ||
1197 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
1198 | pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } | ||
1199 | pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) } | ||
1200 | } | ||
1201 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1202 | pub struct PathSegment { | 1216 | pub struct PathSegment { |
1203 | pub(crate) syntax: SyntaxNode, | 1217 | pub(crate) syntax: SyntaxNode, |
1204 | } | 1218 | } |
@@ -1250,39 +1264,20 @@ impl ConstArg { | |||
1250 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 1264 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
1251 | } | 1265 | } |
1252 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1266 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1253 | pub struct ExternItemList { | ||
1254 | pub(crate) syntax: SyntaxNode, | ||
1255 | } | ||
1256 | impl ExternItemList { | ||
1257 | pub fn l_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['{']) } | ||
1258 | pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } | ||
1259 | pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) } | ||
1260 | } | ||
1261 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1262 | pub struct MetaItem { | ||
1263 | pub(crate) syntax: SyntaxNode, | ||
1264 | } | ||
1265 | impl MetaItem { | ||
1266 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
1267 | pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) } | ||
1268 | pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) } | ||
1269 | pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } | ||
1270 | } | ||
1271 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1272 | pub enum Item { | 1267 | pub enum Item { |
1273 | ConstDef(ConstDef), | 1268 | Const(Const), |
1274 | EnumDef(EnumDef), | 1269 | Enum(Enum), |
1275 | ExternBlock(ExternBlock), | 1270 | ExternBlock(ExternBlock), |
1276 | ExternCrate(ExternCrate), | 1271 | ExternCrate(ExternCrate), |
1277 | FnDef(FnDef), | 1272 | Fn(Fn), |
1278 | ImplDef(ImplDef), | 1273 | Impl(Impl), |
1279 | MacroCall(MacroCall), | 1274 | MacroCall(MacroCall), |
1280 | Module(Module), | 1275 | Module(Module), |
1281 | StaticDef(StaticDef), | 1276 | Static(Static), |
1282 | StructDef(StructDef), | 1277 | Struct(Struct), |
1283 | TraitDef(TraitDef), | 1278 | Trait(Trait), |
1284 | TypeAliasDef(TypeAliasDef), | 1279 | TypeAlias(TypeAlias), |
1285 | UnionDef(UnionDef), | 1280 | Union(Union), |
1286 | Use(Use), | 1281 | Use(Use), |
1287 | } | 1282 | } |
1288 | impl ast::AttrsOwner for Item {} | 1283 | impl ast::AttrsOwner for Item {} |
@@ -1303,9 +1298,27 @@ pub enum TypeRef { | |||
1303 | DynTraitType(DynTraitType), | 1298 | DynTraitType(DynTraitType), |
1304 | } | 1299 | } |
1305 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1300 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1306 | pub enum FieldDefList { | 1301 | pub enum Pat { |
1307 | RecordFieldDefList(RecordFieldDefList), | 1302 | OrPat(OrPat), |
1308 | TupleFieldDefList(TupleFieldDefList), | 1303 | ParenPat(ParenPat), |
1304 | RefPat(RefPat), | ||
1305 | BoxPat(BoxPat), | ||
1306 | BindPat(BindPat), | ||
1307 | PlaceholderPat(PlaceholderPat), | ||
1308 | DotDotPat(DotDotPat), | ||
1309 | PathPat(PathPat), | ||
1310 | RecordPat(RecordPat), | ||
1311 | TupleStructPat(TupleStructPat), | ||
1312 | TuplePat(TuplePat), | ||
1313 | SlicePat(SlicePat), | ||
1314 | RangePat(RangePat), | ||
1315 | LiteralPat(LiteralPat), | ||
1316 | MacroPat(MacroPat), | ||
1317 | } | ||
1318 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1319 | pub enum FieldList { | ||
1320 | RecordFieldList(RecordFieldList), | ||
1321 | TupleFieldList(TupleFieldList), | ||
1309 | } | 1322 | } |
1310 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1323 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1311 | pub enum Expr { | 1324 | pub enum Expr { |
@@ -1324,7 +1337,7 @@ pub enum Expr { | |||
1324 | BlockExpr(BlockExpr), | 1337 | BlockExpr(BlockExpr), |
1325 | ReturnExpr(ReturnExpr), | 1338 | ReturnExpr(ReturnExpr), |
1326 | MatchExpr(MatchExpr), | 1339 | MatchExpr(MatchExpr), |
1327 | RecordLit(RecordLit), | 1340 | RecordExpr(RecordExpr), |
1328 | CallExpr(CallExpr), | 1341 | CallExpr(CallExpr), |
1329 | IndexExpr(IndexExpr), | 1342 | IndexExpr(IndexExpr), |
1330 | MethodCallExpr(MethodCallExpr), | 1343 | MethodCallExpr(MethodCallExpr), |
@@ -1343,31 +1356,28 @@ pub enum Expr { | |||
1343 | } | 1356 | } |
1344 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1345 | pub enum AssocItem { | 1358 | pub enum AssocItem { |
1346 | FnDef(FnDef), | 1359 | Fn(Fn), |
1347 | TypeAliasDef(TypeAliasDef), | 1360 | TypeAlias(TypeAlias), |
1348 | ConstDef(ConstDef), | 1361 | Const(Const), |
1349 | MacroCall(MacroCall), | 1362 | MacroCall(MacroCall), |
1350 | } | 1363 | } |
1351 | impl ast::AttrsOwner for AssocItem {} | 1364 | impl ast::AttrsOwner for AssocItem {} |
1352 | impl ast::NameOwner for AssocItem {} | 1365 | impl ast::NameOwner for AssocItem {} |
1353 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1366 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1354 | pub enum Pat { | 1367 | pub enum ExternItem { |
1355 | OrPat(OrPat), | 1368 | Fn(Fn), |
1356 | ParenPat(ParenPat), | 1369 | Static(Static), |
1357 | RefPat(RefPat), | 1370 | MacroCall(MacroCall), |
1358 | BoxPat(BoxPat), | 1371 | } |
1359 | BindPat(BindPat), | 1372 | impl ast::AttrsOwner for ExternItem {} |
1360 | PlaceholderPat(PlaceholderPat), | 1373 | impl ast::NameOwner for ExternItem {} |
1361 | DotDotPat(DotDotPat), | 1374 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1362 | PathPat(PathPat), | 1375 | pub enum GenericParam { |
1363 | RecordPat(RecordPat), | 1376 | LifetimeParam(LifetimeParam), |
1364 | TupleStructPat(TupleStructPat), | 1377 | TypeParam(TypeParam), |
1365 | TuplePat(TuplePat), | 1378 | ConstParam(ConstParam), |
1366 | SlicePat(SlicePat), | ||
1367 | RangePat(RangePat), | ||
1368 | LiteralPat(LiteralPat), | ||
1369 | MacroPat(MacroPat), | ||
1370 | } | 1379 | } |
1380 | impl ast::AttrsOwner for GenericParam {} | ||
1371 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1381 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1372 | pub enum Stmt { | 1382 | pub enum Stmt { |
1373 | LetStmt(LetStmt), | 1383 | LetStmt(LetStmt), |
@@ -1375,27 +1385,14 @@ pub enum Stmt { | |||
1375 | } | 1385 | } |
1376 | impl ast::AttrsOwner for Stmt {} | 1386 | impl ast::AttrsOwner for Stmt {} |
1377 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1387 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1378 | pub enum AttrInput { | ||
1379 | Literal(Literal), | ||
1380 | TokenTree(TokenTree), | ||
1381 | } | ||
1382 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1383 | pub enum ExternItem { | ||
1384 | FnDef(FnDef), | ||
1385 | StaticDef(StaticDef), | ||
1386 | } | ||
1387 | impl ast::AttrsOwner for ExternItem {} | ||
1388 | impl ast::NameOwner for ExternItem {} | ||
1389 | impl ast::VisibilityOwner for ExternItem {} | ||
1390 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1391 | pub enum AdtDef { | 1388 | pub enum AdtDef { |
1392 | StructDef(StructDef), | 1389 | Struct(Struct), |
1393 | EnumDef(EnumDef), | 1390 | Enum(Enum), |
1394 | UnionDef(UnionDef), | 1391 | Union(Union), |
1395 | } | 1392 | } |
1396 | impl ast::AttrsOwner for AdtDef {} | 1393 | impl ast::AttrsOwner for AdtDef {} |
1394 | impl ast::GenericParamsOwner for AdtDef {} | ||
1397 | impl ast::NameOwner for AdtDef {} | 1395 | impl ast::NameOwner for AdtDef {} |
1398 | impl ast::TypeParamsOwner for AdtDef {} | ||
1399 | impl ast::VisibilityOwner for AdtDef {} | 1396 | impl ast::VisibilityOwner for AdtDef {} |
1400 | impl AstNode for SourceFile { | 1397 | impl AstNode for SourceFile { |
1401 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } | 1398 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } |
@@ -1419,8 +1416,8 @@ impl AstNode for Attr { | |||
1419 | } | 1416 | } |
1420 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1417 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1421 | } | 1418 | } |
1422 | impl AstNode for ConstDef { | 1419 | impl AstNode for Const { |
1423 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } | 1420 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST } |
1424 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1421 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1425 | if Self::can_cast(syntax.kind()) { | 1422 | if Self::can_cast(syntax.kind()) { |
1426 | Some(Self { syntax }) | 1423 | Some(Self { syntax }) |
@@ -1430,8 +1427,8 @@ impl AstNode for ConstDef { | |||
1430 | } | 1427 | } |
1431 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1428 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1432 | } | 1429 | } |
1433 | impl AstNode for EnumDef { | 1430 | impl AstNode for Enum { |
1434 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } | 1431 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM } |
1435 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1432 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1436 | if Self::can_cast(syntax.kind()) { | 1433 | if Self::can_cast(syntax.kind()) { |
1437 | Some(Self { syntax }) | 1434 | Some(Self { syntax }) |
@@ -1463,8 +1460,8 @@ impl AstNode for ExternCrate { | |||
1463 | } | 1460 | } |
1464 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1461 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1465 | } | 1462 | } |
1466 | impl AstNode for FnDef { | 1463 | impl AstNode for Fn { |
1467 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } | 1464 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN } |
1468 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1465 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1469 | if Self::can_cast(syntax.kind()) { | 1466 | if Self::can_cast(syntax.kind()) { |
1470 | Some(Self { syntax }) | 1467 | Some(Self { syntax }) |
@@ -1474,8 +1471,8 @@ impl AstNode for FnDef { | |||
1474 | } | 1471 | } |
1475 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1472 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1476 | } | 1473 | } |
1477 | impl AstNode for ImplDef { | 1474 | impl AstNode for Impl { |
1478 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } | 1475 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL } |
1479 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1476 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1480 | if Self::can_cast(syntax.kind()) { | 1477 | if Self::can_cast(syntax.kind()) { |
1481 | Some(Self { syntax }) | 1478 | Some(Self { syntax }) |
@@ -1507,8 +1504,8 @@ impl AstNode for Module { | |||
1507 | } | 1504 | } |
1508 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1505 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1509 | } | 1506 | } |
1510 | impl AstNode for StaticDef { | 1507 | impl AstNode for Static { |
1511 | fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } | 1508 | fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC } |
1512 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1509 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1513 | if Self::can_cast(syntax.kind()) { | 1510 | if Self::can_cast(syntax.kind()) { |
1514 | Some(Self { syntax }) | 1511 | Some(Self { syntax }) |
@@ -1518,8 +1515,8 @@ impl AstNode for StaticDef { | |||
1518 | } | 1515 | } |
1519 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1516 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1520 | } | 1517 | } |
1521 | impl AstNode for StructDef { | 1518 | impl AstNode for Struct { |
1522 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } | 1519 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT } |
1523 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1520 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1524 | if Self::can_cast(syntax.kind()) { | 1521 | if Self::can_cast(syntax.kind()) { |
1525 | Some(Self { syntax }) | 1522 | Some(Self { syntax }) |
@@ -1529,8 +1526,8 @@ impl AstNode for StructDef { | |||
1529 | } | 1526 | } |
1530 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1527 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1531 | } | 1528 | } |
1532 | impl AstNode for TraitDef { | 1529 | impl AstNode for Trait { |
1533 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } | 1530 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT } |
1534 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1531 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1535 | if Self::can_cast(syntax.kind()) { | 1532 | if Self::can_cast(syntax.kind()) { |
1536 | Some(Self { syntax }) | 1533 | Some(Self { syntax }) |
@@ -1540,8 +1537,8 @@ impl AstNode for TraitDef { | |||
1540 | } | 1537 | } |
1541 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1538 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1542 | } | 1539 | } |
1543 | impl AstNode for TypeAliasDef { | 1540 | impl AstNode for TypeAlias { |
1544 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } | 1541 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS } |
1545 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1542 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1546 | if Self::can_cast(syntax.kind()) { | 1543 | if Self::can_cast(syntax.kind()) { |
1547 | Some(Self { syntax }) | 1544 | Some(Self { syntax }) |
@@ -1551,8 +1548,8 @@ impl AstNode for TypeAliasDef { | |||
1551 | } | 1548 | } |
1552 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1549 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1553 | } | 1550 | } |
1554 | impl AstNode for UnionDef { | 1551 | impl AstNode for Union { |
1555 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } | 1552 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNION } |
1556 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1553 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1557 | if Self::can_cast(syntax.kind()) { | 1554 | if Self::can_cast(syntax.kind()) { |
1558 | Some(Self { syntax }) | 1555 | Some(Self { syntax }) |
@@ -1672,8 +1669,8 @@ impl AstNode for Abi { | |||
1672 | } | 1669 | } |
1673 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1670 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1674 | } | 1671 | } |
1675 | impl AstNode for TypeParamList { | 1672 | impl AstNode for GenericParamList { |
1676 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } | 1673 | fn can_cast(kind: SyntaxKind) -> bool { kind == GENERIC_PARAM_LIST } |
1677 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1674 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1678 | if Self::can_cast(syntax.kind()) { | 1675 | if Self::can_cast(syntax.kind()) { |
1679 | Some(Self { syntax }) | 1676 | Some(Self { syntax }) |
@@ -1727,8 +1724,19 @@ impl AstNode for BlockExpr { | |||
1727 | } | 1724 | } |
1728 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1725 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1729 | } | 1726 | } |
1730 | impl AstNode for RecordFieldDefList { | 1727 | impl AstNode for SelfParam { |
1731 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } | 1728 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } |
1729 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1730 | if Self::can_cast(syntax.kind()) { | ||
1731 | Some(Self { syntax }) | ||
1732 | } else { | ||
1733 | None | ||
1734 | } | ||
1735 | } | ||
1736 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1737 | } | ||
1738 | impl AstNode for Param { | ||
1739 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } | ||
1732 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1740 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1733 | if Self::can_cast(syntax.kind()) { | 1741 | if Self::can_cast(syntax.kind()) { |
1734 | Some(Self { syntax }) | 1742 | Some(Self { syntax }) |
@@ -1738,8 +1746,8 @@ impl AstNode for RecordFieldDefList { | |||
1738 | } | 1746 | } |
1739 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1747 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1740 | } | 1748 | } |
1741 | impl AstNode for TupleFieldDefList { | 1749 | impl AstNode for TypeBoundList { |
1742 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST } | 1750 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } |
1743 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1751 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1744 | if Self::can_cast(syntax.kind()) { | 1752 | if Self::can_cast(syntax.kind()) { |
1745 | Some(Self { syntax }) | 1753 | Some(Self { syntax }) |
@@ -1749,8 +1757,8 @@ impl AstNode for TupleFieldDefList { | |||
1749 | } | 1757 | } |
1750 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1758 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1751 | } | 1759 | } |
1752 | impl AstNode for RecordFieldDef { | 1760 | impl AstNode for RecordFieldList { |
1753 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } | 1761 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } |
1754 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1762 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1755 | if Self::can_cast(syntax.kind()) { | 1763 | if Self::can_cast(syntax.kind()) { |
1756 | Some(Self { syntax }) | 1764 | Some(Self { syntax }) |
@@ -1760,8 +1768,8 @@ impl AstNode for RecordFieldDef { | |||
1760 | } | 1768 | } |
1761 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1769 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1762 | } | 1770 | } |
1763 | impl AstNode for TupleFieldDef { | 1771 | impl AstNode for TupleFieldList { |
1764 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } | 1772 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_LIST } |
1765 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1773 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1766 | if Self::can_cast(syntax.kind()) { | 1774 | if Self::can_cast(syntax.kind()) { |
1767 | Some(Self { syntax }) | 1775 | Some(Self { syntax }) |
@@ -1771,8 +1779,8 @@ impl AstNode for TupleFieldDef { | |||
1771 | } | 1779 | } |
1772 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1780 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1773 | } | 1781 | } |
1774 | impl AstNode for EnumVariantList { | 1782 | impl AstNode for RecordField { |
1775 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } | 1783 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } |
1776 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1784 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1777 | if Self::can_cast(syntax.kind()) { | 1785 | if Self::can_cast(syntax.kind()) { |
1778 | Some(Self { syntax }) | 1786 | Some(Self { syntax }) |
@@ -1782,8 +1790,8 @@ impl AstNode for EnumVariantList { | |||
1782 | } | 1790 | } |
1783 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1791 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1784 | } | 1792 | } |
1785 | impl AstNode for EnumVariant { | 1793 | impl AstNode for TupleField { |
1786 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } | 1794 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD } |
1787 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1795 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1788 | if Self::can_cast(syntax.kind()) { | 1796 | if Self::can_cast(syntax.kind()) { |
1789 | Some(Self { syntax }) | 1797 | Some(Self { syntax }) |
@@ -1793,8 +1801,19 @@ impl AstNode for EnumVariant { | |||
1793 | } | 1801 | } |
1794 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1802 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1795 | } | 1803 | } |
1796 | impl AstNode for TypeBoundList { | 1804 | impl AstNode for VariantList { |
1797 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | 1805 | fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT_LIST } |
1806 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1807 | if Self::can_cast(syntax.kind()) { | ||
1808 | Some(Self { syntax }) | ||
1809 | } else { | ||
1810 | None | ||
1811 | } | ||
1812 | } | ||
1813 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1814 | } | ||
1815 | impl AstNode for Variant { | ||
1816 | fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT } | ||
1798 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1817 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1799 | if Self::can_cast(syntax.kind()) { | 1818 | if Self::can_cast(syntax.kind()) { |
1800 | Some(Self { syntax }) | 1819 | Some(Self { syntax }) |
@@ -1815,6 +1834,72 @@ impl AstNode for AssocItemList { | |||
1815 | } | 1834 | } |
1816 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1835 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1817 | } | 1836 | } |
1837 | impl AstNode for ExternItemList { | ||
1838 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } | ||
1839 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1840 | if Self::can_cast(syntax.kind()) { | ||
1841 | Some(Self { syntax }) | ||
1842 | } else { | ||
1843 | None | ||
1844 | } | ||
1845 | } | ||
1846 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1847 | } | ||
1848 | impl AstNode for LifetimeParam { | ||
1849 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM } | ||
1850 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1851 | if Self::can_cast(syntax.kind()) { | ||
1852 | Some(Self { syntax }) | ||
1853 | } else { | ||
1854 | None | ||
1855 | } | ||
1856 | } | ||
1857 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1858 | } | ||
1859 | impl AstNode for TypeParam { | ||
1860 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM } | ||
1861 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1862 | if Self::can_cast(syntax.kind()) { | ||
1863 | Some(Self { syntax }) | ||
1864 | } else { | ||
1865 | None | ||
1866 | } | ||
1867 | } | ||
1868 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1869 | } | ||
1870 | impl AstNode for ConstParam { | ||
1871 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM } | ||
1872 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1873 | if Self::can_cast(syntax.kind()) { | ||
1874 | Some(Self { syntax }) | ||
1875 | } else { | ||
1876 | None | ||
1877 | } | ||
1878 | } | ||
1879 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1880 | } | ||
1881 | impl AstNode for Literal { | ||
1882 | fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } | ||
1883 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1884 | if Self::can_cast(syntax.kind()) { | ||
1885 | Some(Self { syntax }) | ||
1886 | } else { | ||
1887 | None | ||
1888 | } | ||
1889 | } | ||
1890 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1891 | } | ||
1892 | impl AstNode for TokenTree { | ||
1893 | fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } | ||
1894 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1895 | if Self::can_cast(syntax.kind()) { | ||
1896 | Some(Self { syntax }) | ||
1897 | } else { | ||
1898 | None | ||
1899 | } | ||
1900 | } | ||
1901 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1902 | } | ||
1818 | impl AstNode for ParenType { | 1903 | impl AstNode for ParenType { |
1819 | fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } | 1904 | fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } |
1820 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1905 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2277,17 +2362,6 @@ impl AstNode for BinExpr { | |||
2277 | } | 2362 | } |
2278 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2363 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2279 | } | 2364 | } |
2280 | impl AstNode for Literal { | ||
2281 | fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } | ||
2282 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2283 | if Self::can_cast(syntax.kind()) { | ||
2284 | Some(Self { syntax }) | ||
2285 | } else { | ||
2286 | None | ||
2287 | } | ||
2288 | } | ||
2289 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2290 | } | ||
2291 | impl AstNode for MatchExpr { | 2365 | impl AstNode for MatchExpr { |
2292 | fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR } | 2366 | fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR } |
2293 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2367 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2332,8 +2406,8 @@ impl AstNode for MatchGuard { | |||
2332 | } | 2406 | } |
2333 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2407 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2334 | } | 2408 | } |
2335 | impl AstNode for RecordLit { | 2409 | impl AstNode for RecordExpr { |
2336 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } | 2410 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR } |
2337 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2411 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2338 | if Self::can_cast(syntax.kind()) { | 2412 | if Self::can_cast(syntax.kind()) { |
2339 | Some(Self { syntax }) | 2413 | Some(Self { syntax }) |
@@ -2343,8 +2417,8 @@ impl AstNode for RecordLit { | |||
2343 | } | 2417 | } |
2344 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2418 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2345 | } | 2419 | } |
2346 | impl AstNode for RecordFieldList { | 2420 | impl AstNode for RecordExprFieldList { |
2347 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } | 2421 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST } |
2348 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2422 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2349 | if Self::can_cast(syntax.kind()) { | 2423 | if Self::can_cast(syntax.kind()) { |
2350 | Some(Self { syntax }) | 2424 | Some(Self { syntax }) |
@@ -2354,8 +2428,8 @@ impl AstNode for RecordFieldList { | |||
2354 | } | 2428 | } |
2355 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2429 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2356 | } | 2430 | } |
2357 | impl AstNode for RecordField { | 2431 | impl AstNode for RecordExprField { |
2358 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } | 2432 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD } |
2359 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2433 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2360 | if Self::can_cast(syntax.kind()) { | 2434 | if Self::can_cast(syntax.kind()) { |
2361 | Some(Self { syntax }) | 2435 | Some(Self { syntax }) |
@@ -2552,17 +2626,6 @@ impl AstNode for TuplePat { | |||
2552 | } | 2626 | } |
2553 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2627 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2554 | } | 2628 | } |
2555 | impl AstNode for TokenTree { | ||
2556 | fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } | ||
2557 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2558 | if Self::can_cast(syntax.kind()) { | ||
2559 | Some(Self { syntax }) | ||
2560 | } else { | ||
2561 | None | ||
2562 | } | ||
2563 | } | ||
2564 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2565 | } | ||
2566 | impl AstNode for MacroDef { | 2629 | impl AstNode for MacroDef { |
2567 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } | 2630 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } |
2568 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2631 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2596,39 +2659,6 @@ impl AstNode for MacroStmts { | |||
2596 | } | 2659 | } |
2597 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2660 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2598 | } | 2661 | } |
2599 | impl AstNode for TypeParam { | ||
2600 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM } | ||
2601 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2602 | if Self::can_cast(syntax.kind()) { | ||
2603 | Some(Self { syntax }) | ||
2604 | } else { | ||
2605 | None | ||
2606 | } | ||
2607 | } | ||
2608 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2609 | } | ||
2610 | impl AstNode for LifetimeParam { | ||
2611 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM } | ||
2612 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2613 | if Self::can_cast(syntax.kind()) { | ||
2614 | Some(Self { syntax }) | ||
2615 | } else { | ||
2616 | None | ||
2617 | } | ||
2618 | } | ||
2619 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2620 | } | ||
2621 | impl AstNode for ConstParam { | ||
2622 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM } | ||
2623 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2624 | if Self::can_cast(syntax.kind()) { | ||
2625 | Some(Self { syntax }) | ||
2626 | } else { | ||
2627 | None | ||
2628 | } | ||
2629 | } | ||
2630 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2631 | } | ||
2632 | impl AstNode for TypeBound { | 2662 | impl AstNode for TypeBound { |
2633 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } | 2663 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } |
2634 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2664 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2673,28 +2703,6 @@ impl AstNode for LetStmt { | |||
2673 | } | 2703 | } |
2674 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2704 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2675 | } | 2705 | } |
2676 | impl AstNode for SelfParam { | ||
2677 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } | ||
2678 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2679 | if Self::can_cast(syntax.kind()) { | ||
2680 | Some(Self { syntax }) | ||
2681 | } else { | ||
2682 | None | ||
2683 | } | ||
2684 | } | ||
2685 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2686 | } | ||
2687 | impl AstNode for Param { | ||
2688 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } | ||
2689 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2690 | if Self::can_cast(syntax.kind()) { | ||
2691 | Some(Self { syntax }) | ||
2692 | } else { | ||
2693 | None | ||
2694 | } | ||
2695 | } | ||
2696 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2697 | } | ||
2698 | impl AstNode for PathSegment { | 2706 | impl AstNode for PathSegment { |
2699 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | 2707 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } |
2700 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2708 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2750,33 +2758,11 @@ impl AstNode for ConstArg { | |||
2750 | } | 2758 | } |
2751 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2759 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2752 | } | 2760 | } |
2753 | impl AstNode for ExternItemList { | 2761 | impl From<Const> for Item { |
2754 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } | 2762 | fn from(node: Const) -> Item { Item::Const(node) } |
2755 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2756 | if Self::can_cast(syntax.kind()) { | ||
2757 | Some(Self { syntax }) | ||
2758 | } else { | ||
2759 | None | ||
2760 | } | ||
2761 | } | ||
2762 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2763 | } | 2763 | } |
2764 | impl AstNode for MetaItem { | 2764 | impl From<Enum> for Item { |
2765 | fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } | 2765 | fn from(node: Enum) -> Item { Item::Enum(node) } |
2766 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2767 | if Self::can_cast(syntax.kind()) { | ||
2768 | Some(Self { syntax }) | ||
2769 | } else { | ||
2770 | None | ||
2771 | } | ||
2772 | } | ||
2773 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2774 | } | ||
2775 | impl From<ConstDef> for Item { | ||
2776 | fn from(node: ConstDef) -> Item { Item::ConstDef(node) } | ||
2777 | } | ||
2778 | impl From<EnumDef> for Item { | ||
2779 | fn from(node: EnumDef) -> Item { Item::EnumDef(node) } | ||
2780 | } | 2766 | } |
2781 | impl From<ExternBlock> for Item { | 2767 | impl From<ExternBlock> for Item { |
2782 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } | 2768 | fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } |
@@ -2784,11 +2770,11 @@ impl From<ExternBlock> for Item { | |||
2784 | impl From<ExternCrate> for Item { | 2770 | impl From<ExternCrate> for Item { |
2785 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } | 2771 | fn from(node: ExternCrate) -> Item { Item::ExternCrate(node) } |
2786 | } | 2772 | } |
2787 | impl From<FnDef> for Item { | 2773 | impl From<Fn> for Item { |
2788 | fn from(node: FnDef) -> Item { Item::FnDef(node) } | 2774 | fn from(node: Fn) -> Item { Item::Fn(node) } |
2789 | } | 2775 | } |
2790 | impl From<ImplDef> for Item { | 2776 | impl From<Impl> for Item { |
2791 | fn from(node: ImplDef) -> Item { Item::ImplDef(node) } | 2777 | fn from(node: Impl) -> Item { Item::Impl(node) } |
2792 | } | 2778 | } |
2793 | impl From<MacroCall> for Item { | 2779 | impl From<MacroCall> for Item { |
2794 | fn from(node: MacroCall) -> Item { Item::MacroCall(node) } | 2780 | fn from(node: MacroCall) -> Item { Item::MacroCall(node) } |
@@ -2796,20 +2782,20 @@ impl From<MacroCall> for Item { | |||
2796 | impl From<Module> for Item { | 2782 | impl From<Module> for Item { |
2797 | fn from(node: Module) -> Item { Item::Module(node) } | 2783 | fn from(node: Module) -> Item { Item::Module(node) } |
2798 | } | 2784 | } |
2799 | impl From<StaticDef> for Item { | 2785 | impl From<Static> for Item { |
2800 | fn from(node: StaticDef) -> Item { Item::StaticDef(node) } | 2786 | fn from(node: Static) -> Item { Item::Static(node) } |
2801 | } | 2787 | } |
2802 | impl From<StructDef> for Item { | 2788 | impl From<Struct> for Item { |
2803 | fn from(node: StructDef) -> Item { Item::StructDef(node) } | 2789 | fn from(node: Struct) -> Item { Item::Struct(node) } |
2804 | } | 2790 | } |
2805 | impl From<TraitDef> for Item { | 2791 | impl From<Trait> for Item { |
2806 | fn from(node: TraitDef) -> Item { Item::TraitDef(node) } | 2792 | fn from(node: Trait) -> Item { Item::Trait(node) } |
2807 | } | 2793 | } |
2808 | impl From<TypeAliasDef> for Item { | 2794 | impl From<TypeAlias> for Item { |
2809 | fn from(node: TypeAliasDef) -> Item { Item::TypeAliasDef(node) } | 2795 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } |
2810 | } | 2796 | } |
2811 | impl From<UnionDef> for Item { | 2797 | impl From<Union> for Item { |
2812 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } | 2798 | fn from(node: Union) -> Item { Item::Union(node) } |
2813 | } | 2799 | } |
2814 | impl From<Use> for Item { | 2800 | impl From<Use> for Item { |
2815 | fn from(node: Use) -> Item { Item::Use(node) } | 2801 | fn from(node: Use) -> Item { Item::Use(node) } |
@@ -2817,28 +2803,26 @@ impl From<Use> for Item { | |||
2817 | impl AstNode for Item { | 2803 | impl AstNode for Item { |
2818 | fn can_cast(kind: SyntaxKind) -> bool { | 2804 | fn can_cast(kind: SyntaxKind) -> bool { |
2819 | match kind { | 2805 | match kind { |
2820 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN_DEF | IMPL_DEF | MACRO_CALL | 2806 | CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL | MACRO_CALL | MODULE |
2821 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | UNION_DEF | USE => { | 2807 | | STATIC | STRUCT | TRAIT | TYPE_ALIAS | UNION | USE => true, |
2822 | true | ||
2823 | } | ||
2824 | _ => false, | 2808 | _ => false, |
2825 | } | 2809 | } |
2826 | } | 2810 | } |
2827 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2811 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2828 | let res = match syntax.kind() { | 2812 | let res = match syntax.kind() { |
2829 | CONST_DEF => Item::ConstDef(ConstDef { syntax }), | 2813 | CONST => Item::Const(Const { syntax }), |
2830 | ENUM_DEF => Item::EnumDef(EnumDef { syntax }), | 2814 | ENUM => Item::Enum(Enum { syntax }), |
2831 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), | 2815 | EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), |
2832 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), | 2816 | EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), |
2833 | FN_DEF => Item::FnDef(FnDef { syntax }), | 2817 | FN => Item::Fn(Fn { syntax }), |
2834 | IMPL_DEF => Item::ImplDef(ImplDef { syntax }), | 2818 | IMPL => Item::Impl(Impl { syntax }), |
2835 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), | 2819 | MACRO_CALL => Item::MacroCall(MacroCall { syntax }), |
2836 | MODULE => Item::Module(Module { syntax }), | 2820 | MODULE => Item::Module(Module { syntax }), |
2837 | STATIC_DEF => Item::StaticDef(StaticDef { syntax }), | 2821 | STATIC => Item::Static(Static { syntax }), |
2838 | STRUCT_DEF => Item::StructDef(StructDef { syntax }), | 2822 | STRUCT => Item::Struct(Struct { syntax }), |
2839 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), | 2823 | TRAIT => Item::Trait(Trait { syntax }), |
2840 | TYPE_ALIAS_DEF => Item::TypeAliasDef(TypeAliasDef { syntax }), | 2824 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), |
2841 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), | 2825 | UNION => Item::Union(Union { syntax }), |
2842 | USE => Item::Use(Use { syntax }), | 2826 | USE => Item::Use(Use { syntax }), |
2843 | _ => return None, | 2827 | _ => return None, |
2844 | }; | 2828 | }; |
@@ -2846,19 +2830,19 @@ impl AstNode for Item { | |||
2846 | } | 2830 | } |
2847 | fn syntax(&self) -> &SyntaxNode { | 2831 | fn syntax(&self) -> &SyntaxNode { |
2848 | match self { | 2832 | match self { |
2849 | Item::ConstDef(it) => &it.syntax, | 2833 | Item::Const(it) => &it.syntax, |
2850 | Item::EnumDef(it) => &it.syntax, | 2834 | Item::Enum(it) => &it.syntax, |
2851 | Item::ExternBlock(it) => &it.syntax, | 2835 | Item::ExternBlock(it) => &it.syntax, |
2852 | Item::ExternCrate(it) => &it.syntax, | 2836 | Item::ExternCrate(it) => &it.syntax, |
2853 | Item::FnDef(it) => &it.syntax, | 2837 | Item::Fn(it) => &it.syntax, |
2854 | Item::ImplDef(it) => &it.syntax, | 2838 | Item::Impl(it) => &it.syntax, |
2855 | Item::MacroCall(it) => &it.syntax, | 2839 | Item::MacroCall(it) => &it.syntax, |
2856 | Item::Module(it) => &it.syntax, | 2840 | Item::Module(it) => &it.syntax, |
2857 | Item::StaticDef(it) => &it.syntax, | 2841 | Item::Static(it) => &it.syntax, |
2858 | Item::StructDef(it) => &it.syntax, | 2842 | Item::Struct(it) => &it.syntax, |
2859 | Item::TraitDef(it) => &it.syntax, | 2843 | Item::Trait(it) => &it.syntax, |
2860 | Item::TypeAliasDef(it) => &it.syntax, | 2844 | Item::TypeAlias(it) => &it.syntax, |
2861 | Item::UnionDef(it) => &it.syntax, | 2845 | Item::Union(it) => &it.syntax, |
2862 | Item::Use(it) => &it.syntax, | 2846 | Item::Use(it) => &it.syntax, |
2863 | } | 2847 | } |
2864 | } | 2848 | } |
@@ -2948,33 +2932,126 @@ impl AstNode for TypeRef { | |||
2948 | } | 2932 | } |
2949 | } | 2933 | } |
2950 | } | 2934 | } |
2951 | impl From<RecordFieldDefList> for FieldDefList { | 2935 | impl From<OrPat> for Pat { |
2952 | fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } | 2936 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } |
2937 | } | ||
2938 | impl From<ParenPat> for Pat { | ||
2939 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
2940 | } | ||
2941 | impl From<RefPat> for Pat { | ||
2942 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
2943 | } | ||
2944 | impl From<BoxPat> for Pat { | ||
2945 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
2946 | } | ||
2947 | impl From<BindPat> for Pat { | ||
2948 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
2949 | } | ||
2950 | impl From<PlaceholderPat> for Pat { | ||
2951 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
2952 | } | ||
2953 | impl From<DotDotPat> for Pat { | ||
2954 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
2955 | } | ||
2956 | impl From<PathPat> for Pat { | ||
2957 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
2958 | } | ||
2959 | impl From<RecordPat> for Pat { | ||
2960 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
2961 | } | ||
2962 | impl From<TupleStructPat> for Pat { | ||
2963 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
2964 | } | ||
2965 | impl From<TuplePat> for Pat { | ||
2966 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
2967 | } | ||
2968 | impl From<SlicePat> for Pat { | ||
2969 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
2970 | } | ||
2971 | impl From<RangePat> for Pat { | ||
2972 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
2973 | } | ||
2974 | impl From<LiteralPat> for Pat { | ||
2975 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
2976 | } | ||
2977 | impl From<MacroPat> for Pat { | ||
2978 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
2979 | } | ||
2980 | impl AstNode for Pat { | ||
2981 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2982 | match kind { | ||
2983 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
2984 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
2985 | | LITERAL_PAT | MACRO_PAT => true, | ||
2986 | _ => false, | ||
2987 | } | ||
2988 | } | ||
2989 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2990 | let res = match syntax.kind() { | ||
2991 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
2992 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
2993 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
2994 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
2995 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
2996 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
2997 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
2998 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
2999 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3000 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3001 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3002 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3003 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3004 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3005 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
3006 | _ => return None, | ||
3007 | }; | ||
3008 | Some(res) | ||
3009 | } | ||
3010 | fn syntax(&self) -> &SyntaxNode { | ||
3011 | match self { | ||
3012 | Pat::OrPat(it) => &it.syntax, | ||
3013 | Pat::ParenPat(it) => &it.syntax, | ||
3014 | Pat::RefPat(it) => &it.syntax, | ||
3015 | Pat::BoxPat(it) => &it.syntax, | ||
3016 | Pat::BindPat(it) => &it.syntax, | ||
3017 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3018 | Pat::DotDotPat(it) => &it.syntax, | ||
3019 | Pat::PathPat(it) => &it.syntax, | ||
3020 | Pat::RecordPat(it) => &it.syntax, | ||
3021 | Pat::TupleStructPat(it) => &it.syntax, | ||
3022 | Pat::TuplePat(it) => &it.syntax, | ||
3023 | Pat::SlicePat(it) => &it.syntax, | ||
3024 | Pat::RangePat(it) => &it.syntax, | ||
3025 | Pat::LiteralPat(it) => &it.syntax, | ||
3026 | Pat::MacroPat(it) => &it.syntax, | ||
3027 | } | ||
3028 | } | ||
3029 | } | ||
3030 | impl From<RecordFieldList> for FieldList { | ||
3031 | fn from(node: RecordFieldList) -> FieldList { FieldList::RecordFieldList(node) } | ||
2953 | } | 3032 | } |
2954 | impl From<TupleFieldDefList> for FieldDefList { | 3033 | impl From<TupleFieldList> for FieldList { |
2955 | fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) } | 3034 | fn from(node: TupleFieldList) -> FieldList { FieldList::TupleFieldList(node) } |
2956 | } | 3035 | } |
2957 | impl AstNode for FieldDefList { | 3036 | impl AstNode for FieldList { |
2958 | fn can_cast(kind: SyntaxKind) -> bool { | 3037 | fn can_cast(kind: SyntaxKind) -> bool { |
2959 | match kind { | 3038 | match kind { |
2960 | RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true, | 3039 | RECORD_FIELD_LIST | TUPLE_FIELD_LIST => true, |
2961 | _ => false, | 3040 | _ => false, |
2962 | } | 3041 | } |
2963 | } | 3042 | } |
2964 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3043 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
2965 | let res = match syntax.kind() { | 3044 | let res = match syntax.kind() { |
2966 | RECORD_FIELD_DEF_LIST => { | 3045 | RECORD_FIELD_LIST => FieldList::RecordFieldList(RecordFieldList { syntax }), |
2967 | FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax }) | 3046 | TUPLE_FIELD_LIST => FieldList::TupleFieldList(TupleFieldList { syntax }), |
2968 | } | ||
2969 | TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }), | ||
2970 | _ => return None, | 3047 | _ => return None, |
2971 | }; | 3048 | }; |
2972 | Some(res) | 3049 | Some(res) |
2973 | } | 3050 | } |
2974 | fn syntax(&self) -> &SyntaxNode { | 3051 | fn syntax(&self) -> &SyntaxNode { |
2975 | match self { | 3052 | match self { |
2976 | FieldDefList::RecordFieldDefList(it) => &it.syntax, | 3053 | FieldList::RecordFieldList(it) => &it.syntax, |
2977 | FieldDefList::TupleFieldDefList(it) => &it.syntax, | 3054 | FieldList::TupleFieldList(it) => &it.syntax, |
2978 | } | 3055 | } |
2979 | } | 3056 | } |
2980 | } | 3057 | } |
@@ -3023,8 +3100,8 @@ impl From<ReturnExpr> for Expr { | |||
3023 | impl From<MatchExpr> for Expr { | 3100 | impl From<MatchExpr> for Expr { |
3024 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } | 3101 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } |
3025 | } | 3102 | } |
3026 | impl From<RecordLit> for Expr { | 3103 | impl From<RecordExpr> for Expr { |
3027 | fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) } | 3104 | fn from(node: RecordExpr) -> Expr { Expr::RecordExpr(node) } |
3028 | } | 3105 | } |
3029 | impl From<CallExpr> for Expr { | 3106 | impl From<CallExpr> for Expr { |
3030 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } | 3107 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } |
@@ -3076,7 +3153,7 @@ impl AstNode for Expr { | |||
3076 | match kind { | 3153 | match kind { |
3077 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR | 3154 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR |
3078 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | 3155 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL |
3079 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR | 3156 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_EXPR | CALL_EXPR | INDEX_EXPR |
3080 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR | 3157 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | EFFECT_EXPR | CAST_EXPR |
3081 | | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { | 3158 | | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | BOX_EXPR => { |
3082 | true | 3159 | true |
@@ -3101,7 +3178,7 @@ impl AstNode for Expr { | |||
3101 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), | 3178 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), |
3102 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), | 3179 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), |
3103 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), | 3180 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), |
3104 | RECORD_LIT => Expr::RecordLit(RecordLit { syntax }), | 3181 | RECORD_EXPR => Expr::RecordExpr(RecordExpr { syntax }), |
3105 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | 3182 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), |
3106 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | 3183 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), |
3107 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), | 3184 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), |
@@ -3138,7 +3215,7 @@ impl AstNode for Expr { | |||
3138 | Expr::BlockExpr(it) => &it.syntax, | 3215 | Expr::BlockExpr(it) => &it.syntax, |
3139 | Expr::ReturnExpr(it) => &it.syntax, | 3216 | Expr::ReturnExpr(it) => &it.syntax, |
3140 | Expr::MatchExpr(it) => &it.syntax, | 3217 | Expr::MatchExpr(it) => &it.syntax, |
3141 | Expr::RecordLit(it) => &it.syntax, | 3218 | Expr::RecordExpr(it) => &it.syntax, |
3142 | Expr::CallExpr(it) => &it.syntax, | 3219 | Expr::CallExpr(it) => &it.syntax, |
3143 | Expr::IndexExpr(it) => &it.syntax, | 3220 | Expr::IndexExpr(it) => &it.syntax, |
3144 | Expr::MethodCallExpr(it) => &it.syntax, | 3221 | Expr::MethodCallExpr(it) => &it.syntax, |
@@ -3157,14 +3234,14 @@ impl AstNode for Expr { | |||
3157 | } | 3234 | } |
3158 | } | 3235 | } |
3159 | } | 3236 | } |
3160 | impl From<FnDef> for AssocItem { | 3237 | impl From<Fn> for AssocItem { |
3161 | fn from(node: FnDef) -> AssocItem { AssocItem::FnDef(node) } | 3238 | fn from(node: Fn) -> AssocItem { AssocItem::Fn(node) } |
3162 | } | 3239 | } |
3163 | impl From<TypeAliasDef> for AssocItem { | 3240 | impl From<TypeAlias> for AssocItem { |
3164 | fn from(node: TypeAliasDef) -> AssocItem { AssocItem::TypeAliasDef(node) } | 3241 | fn from(node: TypeAlias) -> AssocItem { AssocItem::TypeAlias(node) } |
3165 | } | 3242 | } |
3166 | impl From<ConstDef> for AssocItem { | 3243 | impl From<Const> for AssocItem { |
3167 | fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } | 3244 | fn from(node: Const) -> AssocItem { AssocItem::Const(node) } |
3168 | } | 3245 | } |
3169 | impl From<MacroCall> for AssocItem { | 3246 | impl From<MacroCall> for AssocItem { |
3170 | fn from(node: MacroCall) -> AssocItem { AssocItem::MacroCall(node) } | 3247 | fn from(node: MacroCall) -> AssocItem { AssocItem::MacroCall(node) } |
@@ -3172,15 +3249,15 @@ impl From<MacroCall> for AssocItem { | |||
3172 | impl AstNode for AssocItem { | 3249 | impl AstNode for AssocItem { |
3173 | fn can_cast(kind: SyntaxKind) -> bool { | 3250 | fn can_cast(kind: SyntaxKind) -> bool { |
3174 | match kind { | 3251 | match kind { |
3175 | FN_DEF | TYPE_ALIAS_DEF | CONST_DEF | MACRO_CALL => true, | 3252 | FN | TYPE_ALIAS | CONST | MACRO_CALL => true, |
3176 | _ => false, | 3253 | _ => false, |
3177 | } | 3254 | } |
3178 | } | 3255 | } |
3179 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3256 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3180 | let res = match syntax.kind() { | 3257 | let res = match syntax.kind() { |
3181 | FN_DEF => AssocItem::FnDef(FnDef { syntax }), | 3258 | FN => AssocItem::Fn(Fn { syntax }), |
3182 | TYPE_ALIAS_DEF => AssocItem::TypeAliasDef(TypeAliasDef { syntax }), | 3259 | TYPE_ALIAS => AssocItem::TypeAlias(TypeAlias { syntax }), |
3183 | CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), | 3260 | CONST => AssocItem::Const(Const { syntax }), |
3184 | MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), | 3261 | MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), |
3185 | _ => return None, | 3262 | _ => return None, |
3186 | }; | 3263 | }; |
@@ -3188,222 +3265,137 @@ impl AstNode for AssocItem { | |||
3188 | } | 3265 | } |
3189 | fn syntax(&self) -> &SyntaxNode { | 3266 | fn syntax(&self) -> &SyntaxNode { |
3190 | match self { | 3267 | match self { |
3191 | AssocItem::FnDef(it) => &it.syntax, | 3268 | AssocItem::Fn(it) => &it.syntax, |
3192 | AssocItem::TypeAliasDef(it) => &it.syntax, | 3269 | AssocItem::TypeAlias(it) => &it.syntax, |
3193 | AssocItem::ConstDef(it) => &it.syntax, | 3270 | AssocItem::Const(it) => &it.syntax, |
3194 | AssocItem::MacroCall(it) => &it.syntax, | 3271 | AssocItem::MacroCall(it) => &it.syntax, |
3195 | } | 3272 | } |
3196 | } | 3273 | } |
3197 | } | 3274 | } |
3198 | impl From<OrPat> for Pat { | 3275 | impl From<Fn> for ExternItem { |
3199 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | 3276 | fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) } |
3200 | } | ||
3201 | impl From<ParenPat> for Pat { | ||
3202 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
3203 | } | ||
3204 | impl From<RefPat> for Pat { | ||
3205 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
3206 | } | ||
3207 | impl From<BoxPat> for Pat { | ||
3208 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
3209 | } | ||
3210 | impl From<BindPat> for Pat { | ||
3211 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
3212 | } | 3277 | } |
3213 | impl From<PlaceholderPat> for Pat { | 3278 | impl From<Static> for ExternItem { |
3214 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | 3279 | fn from(node: Static) -> ExternItem { ExternItem::Static(node) } |
3215 | } | 3280 | } |
3216 | impl From<DotDotPat> for Pat { | 3281 | impl From<MacroCall> for ExternItem { |
3217 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | 3282 | fn from(node: MacroCall) -> ExternItem { ExternItem::MacroCall(node) } |
3218 | } | 3283 | } |
3219 | impl From<PathPat> for Pat { | 3284 | impl AstNode for ExternItem { |
3220 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
3221 | } | ||
3222 | impl From<RecordPat> for Pat { | ||
3223 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
3224 | } | ||
3225 | impl From<TupleStructPat> for Pat { | ||
3226 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
3227 | } | ||
3228 | impl From<TuplePat> for Pat { | ||
3229 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
3230 | } | ||
3231 | impl From<SlicePat> for Pat { | ||
3232 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
3233 | } | ||
3234 | impl From<RangePat> for Pat { | ||
3235 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
3236 | } | ||
3237 | impl From<LiteralPat> for Pat { | ||
3238 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
3239 | } | ||
3240 | impl From<MacroPat> for Pat { | ||
3241 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
3242 | } | ||
3243 | impl AstNode for Pat { | ||
3244 | fn can_cast(kind: SyntaxKind) -> bool { | 3285 | fn can_cast(kind: SyntaxKind) -> bool { |
3245 | match kind { | 3286 | match kind { |
3246 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | 3287 | FN | STATIC | MACRO_CALL => true, |
3247 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
3248 | | LITERAL_PAT | MACRO_PAT => true, | ||
3249 | _ => false, | 3288 | _ => false, |
3250 | } | 3289 | } |
3251 | } | 3290 | } |
3252 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3291 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3253 | let res = match syntax.kind() { | 3292 | let res = match syntax.kind() { |
3254 | OR_PAT => Pat::OrPat(OrPat { syntax }), | 3293 | FN => ExternItem::Fn(Fn { syntax }), |
3255 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | 3294 | STATIC => ExternItem::Static(Static { syntax }), |
3256 | REF_PAT => Pat::RefPat(RefPat { syntax }), | 3295 | MACRO_CALL => ExternItem::MacroCall(MacroCall { syntax }), |
3257 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
3258 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
3259 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
3260 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
3261 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
3262 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3263 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3264 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3265 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3266 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3267 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3268 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
3269 | _ => return None, | 3296 | _ => return None, |
3270 | }; | 3297 | }; |
3271 | Some(res) | 3298 | Some(res) |
3272 | } | 3299 | } |
3273 | fn syntax(&self) -> &SyntaxNode { | 3300 | fn syntax(&self) -> &SyntaxNode { |
3274 | match self { | 3301 | match self { |
3275 | Pat::OrPat(it) => &it.syntax, | 3302 | ExternItem::Fn(it) => &it.syntax, |
3276 | Pat::ParenPat(it) => &it.syntax, | 3303 | ExternItem::Static(it) => &it.syntax, |
3277 | Pat::RefPat(it) => &it.syntax, | 3304 | ExternItem::MacroCall(it) => &it.syntax, |
3278 | Pat::BoxPat(it) => &it.syntax, | ||
3279 | Pat::BindPat(it) => &it.syntax, | ||
3280 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3281 | Pat::DotDotPat(it) => &it.syntax, | ||
3282 | Pat::PathPat(it) => &it.syntax, | ||
3283 | Pat::RecordPat(it) => &it.syntax, | ||
3284 | Pat::TupleStructPat(it) => &it.syntax, | ||
3285 | Pat::TuplePat(it) => &it.syntax, | ||
3286 | Pat::SlicePat(it) => &it.syntax, | ||
3287 | Pat::RangePat(it) => &it.syntax, | ||
3288 | Pat::LiteralPat(it) => &it.syntax, | ||
3289 | Pat::MacroPat(it) => &it.syntax, | ||
3290 | } | 3305 | } |
3291 | } | 3306 | } |
3292 | } | 3307 | } |
3293 | impl From<LetStmt> for Stmt { | 3308 | impl From<LifetimeParam> for GenericParam { |
3294 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } | 3309 | fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) } |
3295 | } | 3310 | } |
3296 | impl From<ExprStmt> for Stmt { | 3311 | impl From<TypeParam> for GenericParam { |
3297 | fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) } | 3312 | fn from(node: TypeParam) -> GenericParam { GenericParam::TypeParam(node) } |
3298 | } | 3313 | } |
3299 | impl AstNode for Stmt { | 3314 | impl From<ConstParam> for GenericParam { |
3300 | fn can_cast(kind: SyntaxKind) -> bool { | 3315 | fn from(node: ConstParam) -> GenericParam { GenericParam::ConstParam(node) } |
3301 | match kind { | ||
3302 | LET_STMT | EXPR_STMT => true, | ||
3303 | _ => false, | ||
3304 | } | ||
3305 | } | ||
3306 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3307 | let res = match syntax.kind() { | ||
3308 | LET_STMT => Stmt::LetStmt(LetStmt { syntax }), | ||
3309 | EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }), | ||
3310 | _ => return None, | ||
3311 | }; | ||
3312 | Some(res) | ||
3313 | } | ||
3314 | fn syntax(&self) -> &SyntaxNode { | ||
3315 | match self { | ||
3316 | Stmt::LetStmt(it) => &it.syntax, | ||
3317 | Stmt::ExprStmt(it) => &it.syntax, | ||
3318 | } | ||
3319 | } | ||
3320 | } | ||
3321 | impl From<Literal> for AttrInput { | ||
3322 | fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) } | ||
3323 | } | 3316 | } |
3324 | impl From<TokenTree> for AttrInput { | 3317 | impl AstNode for GenericParam { |
3325 | fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) } | ||
3326 | } | ||
3327 | impl AstNode for AttrInput { | ||
3328 | fn can_cast(kind: SyntaxKind) -> bool { | 3318 | fn can_cast(kind: SyntaxKind) -> bool { |
3329 | match kind { | 3319 | match kind { |
3330 | LITERAL | TOKEN_TREE => true, | 3320 | LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true, |
3331 | _ => false, | 3321 | _ => false, |
3332 | } | 3322 | } |
3333 | } | 3323 | } |
3334 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3324 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3335 | let res = match syntax.kind() { | 3325 | let res = match syntax.kind() { |
3336 | LITERAL => AttrInput::Literal(Literal { syntax }), | 3326 | LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }), |
3337 | TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }), | 3327 | TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }), |
3328 | CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }), | ||
3338 | _ => return None, | 3329 | _ => return None, |
3339 | }; | 3330 | }; |
3340 | Some(res) | 3331 | Some(res) |
3341 | } | 3332 | } |
3342 | fn syntax(&self) -> &SyntaxNode { | 3333 | fn syntax(&self) -> &SyntaxNode { |
3343 | match self { | 3334 | match self { |
3344 | AttrInput::Literal(it) => &it.syntax, | 3335 | GenericParam::LifetimeParam(it) => &it.syntax, |
3345 | AttrInput::TokenTree(it) => &it.syntax, | 3336 | GenericParam::TypeParam(it) => &it.syntax, |
3337 | GenericParam::ConstParam(it) => &it.syntax, | ||
3346 | } | 3338 | } |
3347 | } | 3339 | } |
3348 | } | 3340 | } |
3349 | impl From<FnDef> for ExternItem { | 3341 | impl From<LetStmt> for Stmt { |
3350 | fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) } | 3342 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } |
3351 | } | 3343 | } |
3352 | impl From<StaticDef> for ExternItem { | 3344 | impl From<ExprStmt> for Stmt { |
3353 | fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } | 3345 | fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) } |
3354 | } | 3346 | } |
3355 | impl AstNode for ExternItem { | 3347 | impl AstNode for Stmt { |
3356 | fn can_cast(kind: SyntaxKind) -> bool { | 3348 | fn can_cast(kind: SyntaxKind) -> bool { |
3357 | match kind { | 3349 | match kind { |
3358 | FN_DEF | STATIC_DEF => true, | 3350 | LET_STMT | EXPR_STMT => true, |
3359 | _ => false, | 3351 | _ => false, |
3360 | } | 3352 | } |
3361 | } | 3353 | } |
3362 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3354 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3363 | let res = match syntax.kind() { | 3355 | let res = match syntax.kind() { |
3364 | FN_DEF => ExternItem::FnDef(FnDef { syntax }), | 3356 | LET_STMT => Stmt::LetStmt(LetStmt { syntax }), |
3365 | STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), | 3357 | EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }), |
3366 | _ => return None, | 3358 | _ => return None, |
3367 | }; | 3359 | }; |
3368 | Some(res) | 3360 | Some(res) |
3369 | } | 3361 | } |
3370 | fn syntax(&self) -> &SyntaxNode { | 3362 | fn syntax(&self) -> &SyntaxNode { |
3371 | match self { | 3363 | match self { |
3372 | ExternItem::FnDef(it) => &it.syntax, | 3364 | Stmt::LetStmt(it) => &it.syntax, |
3373 | ExternItem::StaticDef(it) => &it.syntax, | 3365 | Stmt::ExprStmt(it) => &it.syntax, |
3374 | } | 3366 | } |
3375 | } | 3367 | } |
3376 | } | 3368 | } |
3377 | impl From<StructDef> for AdtDef { | 3369 | impl From<Struct> for AdtDef { |
3378 | fn from(node: StructDef) -> AdtDef { AdtDef::StructDef(node) } | 3370 | fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } |
3379 | } | 3371 | } |
3380 | impl From<EnumDef> for AdtDef { | 3372 | impl From<Enum> for AdtDef { |
3381 | fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) } | 3373 | fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } |
3382 | } | 3374 | } |
3383 | impl From<UnionDef> for AdtDef { | 3375 | impl From<Union> for AdtDef { |
3384 | fn from(node: UnionDef) -> AdtDef { AdtDef::UnionDef(node) } | 3376 | fn from(node: Union) -> AdtDef { AdtDef::Union(node) } |
3385 | } | 3377 | } |
3386 | impl AstNode for AdtDef { | 3378 | impl AstNode for AdtDef { |
3387 | fn can_cast(kind: SyntaxKind) -> bool { | 3379 | fn can_cast(kind: SyntaxKind) -> bool { |
3388 | match kind { | 3380 | match kind { |
3389 | STRUCT_DEF | ENUM_DEF | UNION_DEF => true, | 3381 | STRUCT | ENUM | UNION => true, |
3390 | _ => false, | 3382 | _ => false, |
3391 | } | 3383 | } |
3392 | } | 3384 | } |
3393 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 3385 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
3394 | let res = match syntax.kind() { | 3386 | let res = match syntax.kind() { |
3395 | STRUCT_DEF => AdtDef::StructDef(StructDef { syntax }), | 3387 | STRUCT => AdtDef::Struct(Struct { syntax }), |
3396 | ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }), | 3388 | ENUM => AdtDef::Enum(Enum { syntax }), |
3397 | UNION_DEF => AdtDef::UnionDef(UnionDef { syntax }), | 3389 | UNION => AdtDef::Union(Union { syntax }), |
3398 | _ => return None, | 3390 | _ => return None, |
3399 | }; | 3391 | }; |
3400 | Some(res) | 3392 | Some(res) |
3401 | } | 3393 | } |
3402 | fn syntax(&self) -> &SyntaxNode { | 3394 | fn syntax(&self) -> &SyntaxNode { |
3403 | match self { | 3395 | match self { |
3404 | AdtDef::StructDef(it) => &it.syntax, | 3396 | AdtDef::Struct(it) => &it.syntax, |
3405 | AdtDef::EnumDef(it) => &it.syntax, | 3397 | AdtDef::Enum(it) => &it.syntax, |
3406 | AdtDef::UnionDef(it) => &it.syntax, | 3398 | AdtDef::Union(it) => &it.syntax, |
3407 | } | 3399 | } |
3408 | } | 3400 | } |
3409 | } | 3401 | } |
@@ -3417,37 +3409,37 @@ impl std::fmt::Display for TypeRef { | |||
3417 | std::fmt::Display::fmt(self.syntax(), f) | 3409 | std::fmt::Display::fmt(self.syntax(), f) |
3418 | } | 3410 | } |
3419 | } | 3411 | } |
3420 | impl std::fmt::Display for FieldDefList { | 3412 | impl std::fmt::Display for Pat { |
3421 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3413 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3422 | std::fmt::Display::fmt(self.syntax(), f) | 3414 | std::fmt::Display::fmt(self.syntax(), f) |
3423 | } | 3415 | } |
3424 | } | 3416 | } |
3425 | impl std::fmt::Display for Expr { | 3417 | impl std::fmt::Display for FieldList { |
3426 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3418 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3427 | std::fmt::Display::fmt(self.syntax(), f) | 3419 | std::fmt::Display::fmt(self.syntax(), f) |
3428 | } | 3420 | } |
3429 | } | 3421 | } |
3430 | impl std::fmt::Display for AssocItem { | 3422 | impl std::fmt::Display for Expr { |
3431 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3423 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3432 | std::fmt::Display::fmt(self.syntax(), f) | 3424 | std::fmt::Display::fmt(self.syntax(), f) |
3433 | } | 3425 | } |
3434 | } | 3426 | } |
3435 | impl std::fmt::Display for Pat { | 3427 | impl std::fmt::Display for AssocItem { |
3436 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3428 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3437 | std::fmt::Display::fmt(self.syntax(), f) | 3429 | std::fmt::Display::fmt(self.syntax(), f) |
3438 | } | 3430 | } |
3439 | } | 3431 | } |
3440 | impl std::fmt::Display for Stmt { | 3432 | impl std::fmt::Display for ExternItem { |
3441 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3433 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3442 | std::fmt::Display::fmt(self.syntax(), f) | 3434 | std::fmt::Display::fmt(self.syntax(), f) |
3443 | } | 3435 | } |
3444 | } | 3436 | } |
3445 | impl std::fmt::Display for AttrInput { | 3437 | impl std::fmt::Display for GenericParam { |
3446 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3438 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3447 | std::fmt::Display::fmt(self.syntax(), f) | 3439 | std::fmt::Display::fmt(self.syntax(), f) |
3448 | } | 3440 | } |
3449 | } | 3441 | } |
3450 | impl std::fmt::Display for ExternItem { | 3442 | impl std::fmt::Display for Stmt { |
3451 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3443 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3452 | std::fmt::Display::fmt(self.syntax(), f) | 3444 | std::fmt::Display::fmt(self.syntax(), f) |
3453 | } | 3445 | } |
@@ -3467,12 +3459,12 @@ impl std::fmt::Display for Attr { | |||
3467 | std::fmt::Display::fmt(self.syntax(), f) | 3459 | std::fmt::Display::fmt(self.syntax(), f) |
3468 | } | 3460 | } |
3469 | } | 3461 | } |
3470 | impl std::fmt::Display for ConstDef { | 3462 | impl std::fmt::Display for Const { |
3471 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3463 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3472 | std::fmt::Display::fmt(self.syntax(), f) | 3464 | std::fmt::Display::fmt(self.syntax(), f) |
3473 | } | 3465 | } |
3474 | } | 3466 | } |
3475 | impl std::fmt::Display for EnumDef { | 3467 | impl std::fmt::Display for Enum { |
3476 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3468 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3477 | std::fmt::Display::fmt(self.syntax(), f) | 3469 | std::fmt::Display::fmt(self.syntax(), f) |
3478 | } | 3470 | } |
@@ -3487,12 +3479,12 @@ impl std::fmt::Display for ExternCrate { | |||
3487 | std::fmt::Display::fmt(self.syntax(), f) | 3479 | std::fmt::Display::fmt(self.syntax(), f) |
3488 | } | 3480 | } |
3489 | } | 3481 | } |
3490 | impl std::fmt::Display for FnDef { | 3482 | impl std::fmt::Display for Fn { |
3491 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3483 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3492 | std::fmt::Display::fmt(self.syntax(), f) | 3484 | std::fmt::Display::fmt(self.syntax(), f) |
3493 | } | 3485 | } |
3494 | } | 3486 | } |
3495 | impl std::fmt::Display for ImplDef { | 3487 | impl std::fmt::Display for Impl { |
3496 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3488 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3497 | std::fmt::Display::fmt(self.syntax(), f) | 3489 | std::fmt::Display::fmt(self.syntax(), f) |
3498 | } | 3490 | } |
@@ -3507,27 +3499,27 @@ impl std::fmt::Display for Module { | |||
3507 | std::fmt::Display::fmt(self.syntax(), f) | 3499 | std::fmt::Display::fmt(self.syntax(), f) |
3508 | } | 3500 | } |
3509 | } | 3501 | } |
3510 | impl std::fmt::Display for StaticDef { | 3502 | impl std::fmt::Display for Static { |
3511 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3503 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3512 | std::fmt::Display::fmt(self.syntax(), f) | 3504 | std::fmt::Display::fmt(self.syntax(), f) |
3513 | } | 3505 | } |
3514 | } | 3506 | } |
3515 | impl std::fmt::Display for StructDef { | 3507 | impl std::fmt::Display for Struct { |
3516 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3508 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3517 | std::fmt::Display::fmt(self.syntax(), f) | 3509 | std::fmt::Display::fmt(self.syntax(), f) |
3518 | } | 3510 | } |
3519 | } | 3511 | } |
3520 | impl std::fmt::Display for TraitDef { | 3512 | impl std::fmt::Display for Trait { |
3521 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3513 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3522 | std::fmt::Display::fmt(self.syntax(), f) | 3514 | std::fmt::Display::fmt(self.syntax(), f) |
3523 | } | 3515 | } |
3524 | } | 3516 | } |
3525 | impl std::fmt::Display for TypeAliasDef { | 3517 | impl std::fmt::Display for TypeAlias { |
3526 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3518 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3527 | std::fmt::Display::fmt(self.syntax(), f) | 3519 | std::fmt::Display::fmt(self.syntax(), f) |
3528 | } | 3520 | } |
3529 | } | 3521 | } |
3530 | impl std::fmt::Display for UnionDef { | 3522 | impl std::fmt::Display for Union { |
3531 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3523 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3532 | std::fmt::Display::fmt(self.syntax(), f) | 3524 | std::fmt::Display::fmt(self.syntax(), f) |
3533 | } | 3525 | } |
@@ -3582,7 +3574,7 @@ impl std::fmt::Display for Abi { | |||
3582 | std::fmt::Display::fmt(self.syntax(), f) | 3574 | std::fmt::Display::fmt(self.syntax(), f) |
3583 | } | 3575 | } |
3584 | } | 3576 | } |
3585 | impl std::fmt::Display for TypeParamList { | 3577 | impl std::fmt::Display for GenericParamList { |
3586 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3578 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3587 | std::fmt::Display::fmt(self.syntax(), f) | 3579 | std::fmt::Display::fmt(self.syntax(), f) |
3588 | } | 3580 | } |
@@ -3607,37 +3599,47 @@ impl std::fmt::Display for BlockExpr { | |||
3607 | std::fmt::Display::fmt(self.syntax(), f) | 3599 | std::fmt::Display::fmt(self.syntax(), f) |
3608 | } | 3600 | } |
3609 | } | 3601 | } |
3610 | impl std::fmt::Display for RecordFieldDefList { | 3602 | impl std::fmt::Display for SelfParam { |
3611 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3603 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3612 | std::fmt::Display::fmt(self.syntax(), f) | 3604 | std::fmt::Display::fmt(self.syntax(), f) |
3613 | } | 3605 | } |
3614 | } | 3606 | } |
3615 | impl std::fmt::Display for TupleFieldDefList { | 3607 | impl std::fmt::Display for Param { |
3616 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3608 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3617 | std::fmt::Display::fmt(self.syntax(), f) | 3609 | std::fmt::Display::fmt(self.syntax(), f) |
3618 | } | 3610 | } |
3619 | } | 3611 | } |
3620 | impl std::fmt::Display for RecordFieldDef { | 3612 | impl std::fmt::Display for TypeBoundList { |
3621 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3613 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3622 | std::fmt::Display::fmt(self.syntax(), f) | 3614 | std::fmt::Display::fmt(self.syntax(), f) |
3623 | } | 3615 | } |
3624 | } | 3616 | } |
3625 | impl std::fmt::Display for TupleFieldDef { | 3617 | impl std::fmt::Display for RecordFieldList { |
3626 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3618 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3627 | std::fmt::Display::fmt(self.syntax(), f) | 3619 | std::fmt::Display::fmt(self.syntax(), f) |
3628 | } | 3620 | } |
3629 | } | 3621 | } |
3630 | impl std::fmt::Display for EnumVariantList { | 3622 | impl std::fmt::Display for TupleFieldList { |
3631 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3623 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3632 | std::fmt::Display::fmt(self.syntax(), f) | 3624 | std::fmt::Display::fmt(self.syntax(), f) |
3633 | } | 3625 | } |
3634 | } | 3626 | } |
3635 | impl std::fmt::Display for EnumVariant { | 3627 | impl std::fmt::Display for RecordField { |
3636 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3628 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3637 | std::fmt::Display::fmt(self.syntax(), f) | 3629 | std::fmt::Display::fmt(self.syntax(), f) |
3638 | } | 3630 | } |
3639 | } | 3631 | } |
3640 | impl std::fmt::Display for TypeBoundList { | 3632 | impl std::fmt::Display for TupleField { |
3633 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3634 | std::fmt::Display::fmt(self.syntax(), f) | ||
3635 | } | ||
3636 | } | ||
3637 | impl std::fmt::Display for VariantList { | ||
3638 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3639 | std::fmt::Display::fmt(self.syntax(), f) | ||
3640 | } | ||
3641 | } | ||
3642 | impl std::fmt::Display for Variant { | ||
3641 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3643 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3642 | std::fmt::Display::fmt(self.syntax(), f) | 3644 | std::fmt::Display::fmt(self.syntax(), f) |
3643 | } | 3645 | } |
@@ -3647,6 +3649,36 @@ impl std::fmt::Display for AssocItemList { | |||
3647 | std::fmt::Display::fmt(self.syntax(), f) | 3649 | std::fmt::Display::fmt(self.syntax(), f) |
3648 | } | 3650 | } |
3649 | } | 3651 | } |
3652 | impl std::fmt::Display for ExternItemList { | ||
3653 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3654 | std::fmt::Display::fmt(self.syntax(), f) | ||
3655 | } | ||
3656 | } | ||
3657 | impl std::fmt::Display for LifetimeParam { | ||
3658 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3659 | std::fmt::Display::fmt(self.syntax(), f) | ||
3660 | } | ||
3661 | } | ||
3662 | impl std::fmt::Display for TypeParam { | ||
3663 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3664 | std::fmt::Display::fmt(self.syntax(), f) | ||
3665 | } | ||
3666 | } | ||
3667 | impl std::fmt::Display for ConstParam { | ||
3668 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3669 | std::fmt::Display::fmt(self.syntax(), f) | ||
3670 | } | ||
3671 | } | ||
3672 | impl std::fmt::Display for Literal { | ||
3673 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3674 | std::fmt::Display::fmt(self.syntax(), f) | ||
3675 | } | ||
3676 | } | ||
3677 | impl std::fmt::Display for TokenTree { | ||
3678 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3679 | std::fmt::Display::fmt(self.syntax(), f) | ||
3680 | } | ||
3681 | } | ||
3650 | impl std::fmt::Display for ParenType { | 3682 | impl std::fmt::Display for ParenType { |
3651 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3683 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3652 | std::fmt::Display::fmt(self.syntax(), f) | 3684 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3857,11 +3889,6 @@ impl std::fmt::Display for BinExpr { | |||
3857 | std::fmt::Display::fmt(self.syntax(), f) | 3889 | std::fmt::Display::fmt(self.syntax(), f) |
3858 | } | 3890 | } |
3859 | } | 3891 | } |
3860 | impl std::fmt::Display for Literal { | ||
3861 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3862 | std::fmt::Display::fmt(self.syntax(), f) | ||
3863 | } | ||
3864 | } | ||
3865 | impl std::fmt::Display for MatchExpr { | 3892 | impl std::fmt::Display for MatchExpr { |
3866 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3893 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3867 | std::fmt::Display::fmt(self.syntax(), f) | 3894 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3882,17 +3909,17 @@ impl std::fmt::Display for MatchGuard { | |||
3882 | std::fmt::Display::fmt(self.syntax(), f) | 3909 | std::fmt::Display::fmt(self.syntax(), f) |
3883 | } | 3910 | } |
3884 | } | 3911 | } |
3885 | impl std::fmt::Display for RecordLit { | 3912 | impl std::fmt::Display for RecordExpr { |
3886 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3913 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3887 | std::fmt::Display::fmt(self.syntax(), f) | 3914 | std::fmt::Display::fmt(self.syntax(), f) |
3888 | } | 3915 | } |
3889 | } | 3916 | } |
3890 | impl std::fmt::Display for RecordFieldList { | 3917 | impl std::fmt::Display for RecordExprFieldList { |
3891 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3918 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3892 | std::fmt::Display::fmt(self.syntax(), f) | 3919 | std::fmt::Display::fmt(self.syntax(), f) |
3893 | } | 3920 | } |
3894 | } | 3921 | } |
3895 | impl std::fmt::Display for RecordField { | 3922 | impl std::fmt::Display for RecordExprField { |
3896 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3923 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3897 | std::fmt::Display::fmt(self.syntax(), f) | 3924 | std::fmt::Display::fmt(self.syntax(), f) |
3898 | } | 3925 | } |
@@ -3982,11 +4009,6 @@ impl std::fmt::Display for TuplePat { | |||
3982 | std::fmt::Display::fmt(self.syntax(), f) | 4009 | std::fmt::Display::fmt(self.syntax(), f) |
3983 | } | 4010 | } |
3984 | } | 4011 | } |
3985 | impl std::fmt::Display for TokenTree { | ||
3986 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3987 | std::fmt::Display::fmt(self.syntax(), f) | ||
3988 | } | ||
3989 | } | ||
3990 | impl std::fmt::Display for MacroDef { | 4012 | impl std::fmt::Display for MacroDef { |
3991 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4013 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3992 | std::fmt::Display::fmt(self.syntax(), f) | 4014 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4002,21 +4024,6 @@ impl std::fmt::Display for MacroStmts { | |||
4002 | std::fmt::Display::fmt(self.syntax(), f) | 4024 | std::fmt::Display::fmt(self.syntax(), f) |
4003 | } | 4025 | } |
4004 | } | 4026 | } |
4005 | impl std::fmt::Display for TypeParam { | ||
4006 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4007 | std::fmt::Display::fmt(self.syntax(), f) | ||
4008 | } | ||
4009 | } | ||
4010 | impl std::fmt::Display for LifetimeParam { | ||
4011 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4012 | std::fmt::Display::fmt(self.syntax(), f) | ||
4013 | } | ||
4014 | } | ||
4015 | impl std::fmt::Display for ConstParam { | ||
4016 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4017 | std::fmt::Display::fmt(self.syntax(), f) | ||
4018 | } | ||
4019 | } | ||
4020 | impl std::fmt::Display for TypeBound { | 4027 | impl std::fmt::Display for TypeBound { |
4021 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4028 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4022 | std::fmt::Display::fmt(self.syntax(), f) | 4029 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4037,16 +4044,6 @@ impl std::fmt::Display for LetStmt { | |||
4037 | std::fmt::Display::fmt(self.syntax(), f) | 4044 | std::fmt::Display::fmt(self.syntax(), f) |
4038 | } | 4045 | } |
4039 | } | 4046 | } |
4040 | impl std::fmt::Display for SelfParam { | ||
4041 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4042 | std::fmt::Display::fmt(self.syntax(), f) | ||
4043 | } | ||
4044 | } | ||
4045 | impl std::fmt::Display for Param { | ||
4046 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4047 | std::fmt::Display::fmt(self.syntax(), f) | ||
4048 | } | ||
4049 | } | ||
4050 | impl std::fmt::Display for PathSegment { | 4047 | impl std::fmt::Display for PathSegment { |
4051 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 4048 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
4052 | std::fmt::Display::fmt(self.syntax(), f) | 4049 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -4072,13 +4069,3 @@ impl std::fmt::Display for ConstArg { | |||
4072 | std::fmt::Display::fmt(self.syntax(), f) | 4069 | std::fmt::Display::fmt(self.syntax(), f) |
4073 | } | 4070 | } |
4074 | } | 4071 | } |
4075 | impl std::fmt::Display for ExternItemList { | ||
4076 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4077 | std::fmt::Display::fmt(self.syntax(), f) | ||
4078 | } | ||
4079 | } | ||
4080 | impl std::fmt::Display for MetaItem { | ||
4081 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
4082 | std::fmt::Display::fmt(self.syntax(), f) | ||
4083 | } | ||
4084 | } | ||
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 0ff69bc2d..509e8ae7a 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -64,18 +64,18 @@ pub fn use_item(use_tree: ast::UseTree) -> ast::Use { | |||
64 | ast_from_text(&format!("use {};", use_tree)) | 64 | ast_from_text(&format!("use {};", use_tree)) |
65 | } | 65 | } |
66 | 66 | ||
67 | pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { | 67 | pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordExprField { |
68 | return match expr { | 68 | return match expr { |
69 | Some(expr) => from_text(&format!("{}: {}", name, expr)), | 69 | Some(expr) => from_text(&format!("{}: {}", name, expr)), |
70 | None => from_text(&name.to_string()), | 70 | None => from_text(&name.to_string()), |
71 | }; | 71 | }; |
72 | 72 | ||
73 | fn from_text(text: &str) -> ast::RecordField { | 73 | fn from_text(text: &str) -> ast::RecordExprField { |
74 | ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) | 74 | ast_from_text(&format!("fn f() {{ S {{ {}, }} }}", text)) |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordFieldDef { | 78 | pub fn record_field_def(name: ast::NameRef, ty: ast::TypeRef) -> ast::RecordField { |
79 | ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) | 79 | ast_from_text(&format!("struct S {{ {}: {}, }}", name, ty)) |
80 | } | 80 | } |
81 | 81 | ||
@@ -291,10 +291,10 @@ pub fn visibility_pub_crate() -> ast::Visibility { | |||
291 | pub fn fn_def( | 291 | pub fn fn_def( |
292 | visibility: Option<ast::Visibility>, | 292 | visibility: Option<ast::Visibility>, |
293 | fn_name: ast::Name, | 293 | fn_name: ast::Name, |
294 | type_params: Option<ast::TypeParamList>, | 294 | type_params: Option<ast::GenericParamList>, |
295 | params: ast::ParamList, | 295 | params: ast::ParamList, |
296 | body: ast::BlockExpr, | 296 | body: ast::BlockExpr, |
297 | ) -> ast::FnDef { | 297 | ) -> ast::Fn { |
298 | let type_params = | 298 | let type_params = |
299 | if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; | 299 | if let Some(type_params) = type_params { format!("<{}>", type_params) } else { "".into() }; |
300 | let visibility = match visibility { | 300 | let visibility = match visibility { |
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 242900643..bba7310ad 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -7,7 +7,7 @@ use itertools::Itertools; | |||
7 | use ra_parser::SyntaxKind; | 7 | use ra_parser::SyntaxKind; |
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
10 | ast::{self, support, AstNode, AttrInput, NameOwner, SyntaxNode}, | 10 | ast::{self, support, AstNode, NameOwner, SyntaxNode}, |
11 | SmolStr, SyntaxElement, SyntaxToken, T, | 11 | SmolStr, SyntaxElement, SyntaxToken, T, |
12 | }; | 12 | }; |
13 | 13 | ||
@@ -39,29 +39,23 @@ pub enum AttrKind { | |||
39 | 39 | ||
40 | impl ast::Attr { | 40 | impl ast::Attr { |
41 | pub fn as_simple_atom(&self) -> Option<SmolStr> { | 41 | pub fn as_simple_atom(&self) -> Option<SmolStr> { |
42 | match self.input() { | 42 | if self.eq_token().is_some() || self.token_tree().is_some() { |
43 | None => self.simple_name(), | 43 | return None; |
44 | Some(_) => None, | ||
45 | } | 44 | } |
45 | self.simple_name() | ||
46 | } | 46 | } |
47 | 47 | ||
48 | pub fn as_simple_call(&self) -> Option<(SmolStr, ast::TokenTree)> { | 48 | pub fn as_simple_call(&self) -> Option<(SmolStr, ast::TokenTree)> { |
49 | match self.input() { | 49 | let tt = self.token_tree()?; |
50 | Some(AttrInput::TokenTree(tt)) => Some((self.simple_name()?, tt)), | 50 | Some((self.simple_name()?, tt)) |
51 | _ => None, | ||
52 | } | ||
53 | } | 51 | } |
54 | 52 | ||
55 | pub fn as_simple_key_value(&self) -> Option<(SmolStr, SmolStr)> { | 53 | pub fn as_simple_key_value(&self) -> Option<(SmolStr, SmolStr)> { |
56 | match self.input() { | 54 | let lit = self.literal()?; |
57 | Some(AttrInput::Literal(lit)) => { | 55 | let key = self.simple_name()?; |
58 | let key = self.simple_name()?; | 56 | // FIXME: escape? raw string? |
59 | // FIXME: escape? raw string? | 57 | let value = lit.syntax().first_token()?.text().trim_matches('"').into(); |
60 | let value = lit.syntax().first_token()?.text().trim_matches('"').into(); | 58 | Some((key, value)) |
61 | Some((key, value)) | ||
62 | } | ||
63 | _ => None, | ||
64 | } | ||
65 | } | 59 | } |
66 | 60 | ||
67 | pub fn simple_name(&self) -> Option<SmolStr> { | 61 | pub fn simple_name(&self) -> Option<SmolStr> { |
@@ -141,7 +135,7 @@ impl ast::UseTreeList { | |||
141 | } | 135 | } |
142 | } | 136 | } |
143 | 137 | ||
144 | impl ast::ImplDef { | 138 | impl ast::Impl { |
145 | pub fn target_type(&self) -> Option<ast::TypeRef> { | 139 | pub fn target_type(&self) -> Option<ast::TypeRef> { |
146 | match self.target() { | 140 | match self.target() { |
147 | (Some(t), None) | (_, Some(t)) => Some(t), | 141 | (Some(t), None) | (_, Some(t)) => Some(t), |
@@ -166,16 +160,16 @@ impl ast::ImplDef { | |||
166 | 160 | ||
167 | #[derive(Debug, Clone, PartialEq, Eq)] | 161 | #[derive(Debug, Clone, PartialEq, Eq)] |
168 | pub enum StructKind { | 162 | pub enum StructKind { |
169 | Record(ast::RecordFieldDefList), | 163 | Record(ast::RecordFieldList), |
170 | Tuple(ast::TupleFieldDefList), | 164 | Tuple(ast::TupleFieldList), |
171 | Unit, | 165 | Unit, |
172 | } | 166 | } |
173 | 167 | ||
174 | impl StructKind { | 168 | impl StructKind { |
175 | fn from_node<N: AstNode>(node: &N) -> StructKind { | 169 | fn from_node<N: AstNode>(node: &N) -> StructKind { |
176 | if let Some(nfdl) = support::child::<ast::RecordFieldDefList>(node.syntax()) { | 170 | if let Some(nfdl) = support::child::<ast::RecordFieldList>(node.syntax()) { |
177 | StructKind::Record(nfdl) | 171 | StructKind::Record(nfdl) |
178 | } else if let Some(pfl) = support::child::<ast::TupleFieldDefList>(node.syntax()) { | 172 | } else if let Some(pfl) = support::child::<ast::TupleFieldList>(node.syntax()) { |
179 | StructKind::Tuple(pfl) | 173 | StructKind::Tuple(pfl) |
180 | } else { | 174 | } else { |
181 | StructKind::Unit | 175 | StructKind::Unit |
@@ -183,17 +177,17 @@ impl StructKind { | |||
183 | } | 177 | } |
184 | } | 178 | } |
185 | 179 | ||
186 | impl ast::StructDef { | 180 | impl ast::Struct { |
187 | pub fn kind(&self) -> StructKind { | 181 | pub fn kind(&self) -> StructKind { |
188 | StructKind::from_node(self) | 182 | StructKind::from_node(self) |
189 | } | 183 | } |
190 | } | 184 | } |
191 | 185 | ||
192 | impl ast::RecordField { | 186 | impl ast::RecordExprField { |
193 | pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordField> { | 187 | pub fn for_field_name(field_name: &ast::NameRef) -> Option<ast::RecordExprField> { |
194 | let candidate = | 188 | let candidate = |
195 | field_name.syntax().parent().and_then(ast::RecordField::cast).or_else(|| { | 189 | field_name.syntax().parent().and_then(ast::RecordExprField::cast).or_else(|| { |
196 | field_name.syntax().ancestors().nth(4).and_then(ast::RecordField::cast) | 190 | field_name.syntax().ancestors().nth(4).and_then(ast::RecordExprField::cast) |
197 | })?; | 191 | })?; |
198 | if candidate.field_name().as_ref() == Some(field_name) { | 192 | if candidate.field_name().as_ref() == Some(field_name) { |
199 | Some(candidate) | 193 | Some(candidate) |
@@ -247,12 +241,12 @@ impl ast::RecordFieldPat { | |||
247 | } | 241 | } |
248 | } | 242 | } |
249 | 243 | ||
250 | impl ast::EnumVariant { | 244 | impl ast::Variant { |
251 | pub fn parent_enum(&self) -> ast::EnumDef { | 245 | pub fn parent_enum(&self) -> ast::Enum { |
252 | self.syntax() | 246 | self.syntax() |
253 | .parent() | 247 | .parent() |
254 | .and_then(|it| it.parent()) | 248 | .and_then(|it| it.parent()) |
255 | .and_then(ast::EnumDef::cast) | 249 | .and_then(ast::Enum::cast) |
256 | .expect("EnumVariants are always nested in Enums") | 250 | .expect("EnumVariants are always nested in Enums") |
257 | } | 251 | } |
258 | pub fn kind(&self) -> StructKind { | 252 | pub fn kind(&self) -> StructKind { |
@@ -473,18 +467,39 @@ impl ast::TokenTree { | |||
473 | } | 467 | } |
474 | } | 468 | } |
475 | 469 | ||
470 | impl ast::GenericParamList { | ||
471 | pub fn lifetime_params(&self) -> impl Iterator<Item = ast::LifetimeParam> { | ||
472 | self.generic_params().filter_map(|param| match param { | ||
473 | ast::GenericParam::LifetimeParam(it) => Some(it), | ||
474 | ast::GenericParam::TypeParam(_) | ast::GenericParam::ConstParam(_) => None, | ||
475 | }) | ||
476 | } | ||
477 | pub fn type_params(&self) -> impl Iterator<Item = ast::TypeParam> { | ||
478 | self.generic_params().filter_map(|param| match param { | ||
479 | ast::GenericParam::TypeParam(it) => Some(it), | ||
480 | ast::GenericParam::LifetimeParam(_) | ast::GenericParam::ConstParam(_) => None, | ||
481 | }) | ||
482 | } | ||
483 | pub fn const_params(&self) -> impl Iterator<Item = ast::ConstParam> { | ||
484 | self.generic_params().filter_map(|param| match param { | ||
485 | ast::GenericParam::ConstParam(it) => Some(it), | ||
486 | ast::GenericParam::TypeParam(_) | ast::GenericParam::LifetimeParam(_) => None, | ||
487 | }) | ||
488 | } | ||
489 | } | ||
490 | |||
476 | impl ast::DocCommentsOwner for ast::SourceFile {} | 491 | impl ast::DocCommentsOwner for ast::SourceFile {} |
477 | impl ast::DocCommentsOwner for ast::FnDef {} | 492 | impl ast::DocCommentsOwner for ast::Fn {} |
478 | impl ast::DocCommentsOwner for ast::StructDef {} | 493 | impl ast::DocCommentsOwner for ast::Struct {} |
479 | impl ast::DocCommentsOwner for ast::UnionDef {} | 494 | impl ast::DocCommentsOwner for ast::Union {} |
480 | impl ast::DocCommentsOwner for ast::RecordFieldDef {} | 495 | impl ast::DocCommentsOwner for ast::RecordField {} |
481 | impl ast::DocCommentsOwner for ast::TupleFieldDef {} | 496 | impl ast::DocCommentsOwner for ast::TupleField {} |
482 | impl ast::DocCommentsOwner for ast::EnumDef {} | 497 | impl ast::DocCommentsOwner for ast::Enum {} |
483 | impl ast::DocCommentsOwner for ast::EnumVariant {} | 498 | impl ast::DocCommentsOwner for ast::Variant {} |
484 | impl ast::DocCommentsOwner for ast::TraitDef {} | 499 | impl ast::DocCommentsOwner for ast::Trait {} |
485 | impl ast::DocCommentsOwner for ast::Module {} | 500 | impl ast::DocCommentsOwner for ast::Module {} |
486 | impl ast::DocCommentsOwner for ast::StaticDef {} | 501 | impl ast::DocCommentsOwner for ast::Static {} |
487 | impl ast::DocCommentsOwner for ast::ConstDef {} | 502 | impl ast::DocCommentsOwner for ast::Const {} |
488 | impl ast::DocCommentsOwner for ast::TypeAliasDef {} | 503 | impl ast::DocCommentsOwner for ast::TypeAlias {} |
489 | impl ast::DocCommentsOwner for ast::ImplDef {} | 504 | impl ast::DocCommentsOwner for ast::Impl {} |
490 | impl ast::DocCommentsOwner for ast::MacroCall {} | 505 | impl ast::DocCommentsOwner for ast::MacroCall {} |
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index 9fe0b93c1..3a56b1674 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs | |||
@@ -9,12 +9,6 @@ use crate::{ | |||
9 | SyntaxToken, T, | 9 | SyntaxToken, T, |
10 | }; | 10 | }; |
11 | 11 | ||
12 | pub trait TypeAscriptionOwner: AstNode { | ||
13 | fn ascribed_type(&self) -> Option<ast::TypeRef> { | ||
14 | support::child(self.syntax()) | ||
15 | } | ||
16 | } | ||
17 | |||
18 | pub trait NameOwner: AstNode { | 12 | pub trait NameOwner: AstNode { |
19 | fn name(&self) -> Option<ast::Name> { | 13 | fn name(&self) -> Option<ast::Name> { |
20 | support::child(self.syntax()) | 14 | support::child(self.syntax()) |
@@ -49,8 +43,8 @@ pub trait ModuleItemOwner: AstNode { | |||
49 | } | 43 | } |
50 | } | 44 | } |
51 | 45 | ||
52 | pub trait TypeParamsOwner: AstNode { | 46 | pub trait GenericParamsOwner: AstNode { |
53 | fn type_param_list(&self) -> Option<ast::TypeParamList> { | 47 | fn generic_param_list(&self) -> Option<ast::GenericParamList> { |
54 | support::child(self.syntax()) | 48 | support::child(self.syntax()) |
55 | } | 49 | } |
56 | 50 | ||
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 219dd0b07..6203b6206 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -255,11 +255,11 @@ fn api_walkthrough() { | |||
255 | let mut func = None; | 255 | let mut func = None; |
256 | for item in file.items() { | 256 | for item in file.items() { |
257 | match item { | 257 | match item { |
258 | ast::Item::FnDef(f) => func = Some(f), | 258 | ast::Item::Fn(f) => func = Some(f), |
259 | _ => unreachable!(), | 259 | _ => unreachable!(), |
260 | } | 260 | } |
261 | } | 261 | } |
262 | let func: ast::FnDef = func.unwrap(); | 262 | let func: ast::Fn = func.unwrap(); |
263 | 263 | ||
264 | // Each AST node has a bunch of getters for children. All getters return | 264 | // Each AST node has a bunch of getters for children. All getters return |
265 | // `Option`s though, to account for incomplete code. Some getters are common | 265 | // `Option`s though, to account for incomplete code. Some getters are common |
@@ -316,7 +316,7 @@ fn api_walkthrough() { | |||
316 | ); | 316 | ); |
317 | 317 | ||
318 | // As well as some iterator helpers: | 318 | // As well as some iterator helpers: |
319 | let f = expr_syntax.ancestors().find_map(ast::FnDef::cast); | 319 | let f = expr_syntax.ancestors().find_map(ast::Fn::cast); |
320 | assert_eq!(f, Some(func)); | 320 | assert_eq!(f, Some(func)); |
321 | assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); | 321 | assert!(expr_syntax.siblings_with_tokens(Direction::Next).any(|it| it.kind() == T!['}'])); |
322 | assert_eq!( | 322 | assert_eq!( |
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index c6b30a02a..6d1828d20 100644 --- a/crates/ra_syntax/src/parsing/text_tree_sink.rs +++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs | |||
@@ -146,8 +146,8 @@ fn n_attached_trivias<'a>( | |||
146 | trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, | 146 | trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, |
147 | ) -> usize { | 147 | ) -> usize { |
148 | match kind { | 148 | match kind { |
149 | MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | 149 | MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT | MODULE |
150 | | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => { | 150 | | RECORD_FIELD | STATIC => { |
151 | let mut res = 0; | 151 | let mut res = 0; |
152 | let mut trivias = trivias.enumerate().peekable(); | 152 | let mut trivias = trivias.enumerate().peekable(); |
153 | 153 | ||
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs index 62f03e93d..ca7957747 100644 --- a/crates/ra_syntax/src/ptr.rs +++ b/crates/ra_syntax/src/ptr.rs | |||
@@ -98,7 +98,7 @@ fn test_local_syntax_ptr() { | |||
98 | use crate::{ast, AstNode, SourceFile}; | 98 | use crate::{ast, AstNode, SourceFile}; |
99 | 99 | ||
100 | let file = SourceFile::parse("struct Foo { f: u32, }").ok().unwrap(); | 100 | let file = SourceFile::parse("struct Foo { f: u32, }").ok().unwrap(); |
101 | let field = file.syntax().descendants().find_map(ast::RecordFieldDef::cast).unwrap(); | 101 | let field = file.syntax().descendants().find_map(ast::RecordField::cast).unwrap(); |
102 | let ptr = SyntaxNodePtr::new(field.syntax()); | 102 | let ptr = SyntaxNodePtr::new(field.syntax()); |
103 | let field_syntax = ptr.to_node(file.syntax()); | 103 | let field_syntax = ptr.to_node(file.syntax()); |
104 | assert_eq!(field.syntax(), &field_syntax); | 104 | assert_eq!(field.syntax(), &field_syntax); |
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index fdec48fb0..0325ab0b4 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs | |||
@@ -4,7 +4,7 @@ mod block; | |||
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{ |
6 | ast, match_ast, AstNode, SyntaxError, | 6 | ast, match_ast, AstNode, SyntaxError, |
7 | SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN_DEF, INT_NUMBER, STRING, TYPE_ALIAS_DEF}, | 7 | SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST, FN, INT_NUMBER, STRING, TYPE_ALIAS}, |
8 | SyntaxNode, SyntaxToken, TextSize, T, | 8 | SyntaxNode, SyntaxToken, TextSize, T, |
9 | }; | 9 | }; |
10 | use rustc_lexer::unescape::{ | 10 | use rustc_lexer::unescape::{ |
@@ -91,7 +91,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> { | |||
91 | ast::Literal(it) => validate_literal(it, &mut errors), | 91 | ast::Literal(it) => validate_literal(it, &mut errors), |
92 | ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), | 92 | ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors), |
93 | ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), | 93 | ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors), |
94 | ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), | 94 | ast::RecordExprField(it) => validate_numeric_name(it.name_ref(), &mut errors), |
95 | ast::Visibility(it) => validate_visibility(it, &mut errors), | 95 | ast::Visibility(it) => validate_visibility(it, &mut errors), |
96 | ast::RangeExpr(it) => validate_range_expr(it, &mut errors), | 96 | ast::RangeExpr(it) => validate_range_expr(it, &mut errors), |
97 | ast::PathSegment(it) => validate_path_keywords(it, &mut errors), | 97 | ast::PathSegment(it) => validate_path_keywords(it, &mut errors), |
@@ -200,11 +200,11 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec<SyntaxError>) { | |||
200 | None => return, | 200 | None => return, |
201 | }; | 201 | }; |
202 | match parent.kind() { | 202 | match parent.kind() { |
203 | FN_DEF | CONST_DEF | TYPE_ALIAS_DEF => (), | 203 | FN | CONST | TYPE_ALIAS => (), |
204 | _ => return, | 204 | _ => return, |
205 | } | 205 | } |
206 | 206 | ||
207 | let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::ImplDef::cast) { | 207 | let impl_def = match parent.parent().and_then(|it| it.parent()).and_then(ast::Impl::cast) { |
208 | Some(it) => it, | 208 | Some(it) => it, |
209 | None => return, | 209 | None => return, |
210 | }; | 210 | }; |
diff --git a/crates/ra_syntax/src/validation/block.rs b/crates/ra_syntax/src/validation/block.rs index 2c08f7e6e..ad9901468 100644 --- a/crates/ra_syntax/src/validation/block.rs +++ b/crates/ra_syntax/src/validation/block.rs | |||
@@ -9,7 +9,7 @@ use crate::{ | |||
9 | pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) { | 9 | pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) { |
10 | if let Some(parent) = block.syntax().parent() { | 10 | if let Some(parent) = block.syntax().parent() { |
11 | match parent.kind() { | 11 | match parent.kind() { |
12 | FN_DEF | EXPR_STMT | BLOCK_EXPR => return, | 12 | FN | EXPR_STMT | BLOCK_EXPR => return, |
13 | _ => {} | 13 | _ => {} |
14 | } | 14 | } |
15 | } | 15 | } |