@@ -23,6 +23,7 @@ pub enum Ast<R = TextRange> {
23
23
MatchCase ( MatchCase < R > ) ,
24
24
Pattern ( Pattern < R > ) ,
25
25
TypeIgnore ( TypeIgnore < R > ) ,
26
+ Decorator ( Decorator < R > ) ,
26
27
}
27
28
impl < R > Node for Ast < R > {
28
29
const NAME : & ' static str = "AST" ;
@@ -137,6 +138,12 @@ impl<R> From<TypeIgnore<R>> for Ast<R> {
137
138
}
138
139
}
139
140
141
+ impl < R > From < Decorator < R > > for Ast < R > {
142
+ fn from ( node : Decorator < R > ) -> Self {
143
+ Ast :: Decorator ( node)
144
+ }
145
+ }
146
+
140
147
#[ derive( Clone , Debug , PartialEq ) ]
141
148
pub struct ModModule < R = TextRange > {
142
149
pub range : OptionalRange < R > ,
@@ -242,7 +249,7 @@ pub struct StmtFunctionDef<R = TextRange> {
242
249
pub name : Identifier ,
243
250
pub args : Box < Arguments < R > > ,
244
251
pub body : Vec < Stmt < R > > ,
245
- pub decorator_list : Vec < Expr < R > > ,
252
+ pub decorator_list : Vec < Decorator < R > > ,
246
253
pub returns : Option < Box < Expr < R > > > ,
247
254
pub type_comment : Option < String > ,
248
255
}
@@ -275,7 +282,7 @@ pub struct StmtAsyncFunctionDef<R = TextRange> {
275
282
pub name : Identifier ,
276
283
pub args : Box < Arguments < R > > ,
277
284
pub body : Vec < Stmt < R > > ,
278
- pub decorator_list : Vec < Expr < R > > ,
285
+ pub decorator_list : Vec < Decorator < R > > ,
279
286
pub returns : Option < Box < Expr < R > > > ,
280
287
pub type_comment : Option < String > ,
281
288
}
@@ -309,7 +316,7 @@ pub struct StmtClassDef<R = TextRange> {
309
316
pub bases : Vec < Expr < R > > ,
310
317
pub keywords : Vec < Keyword < R > > ,
311
318
pub body : Vec < Stmt < R > > ,
312
- pub decorator_list : Vec < Expr < R > > ,
319
+ pub decorator_list : Vec < Decorator < R > > ,
313
320
}
314
321
315
322
impl < R > Node for StmtClassDef < R > {
@@ -2987,3 +2994,14 @@ impl<R> Node for TypeIgnore<R> {
2987
2994
const NAME : & ' static str = "type_ignore" ;
2988
2995
const FIELD_NAMES : & ' static [ & ' static str ] = & [ ] ;
2989
2996
}
2997
+
2998
+ #[ derive( Clone , Debug , PartialEq ) ]
2999
+ pub struct Decorator < R = TextRange > {
3000
+ pub range : OptionalRange < R > ,
3001
+ pub expression : Expr < R > ,
3002
+ }
3003
+
3004
+ impl < R > Node for Decorator < R > {
3005
+ const NAME : & ' static str = "decorator" ;
3006
+ const FIELD_NAMES : & ' static [ & ' static str ] = & [ "expression" ] ;
3007
+ }
0 commit comments