mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-26 13:24:42 +00:00
Add stub type_params
handling for class and function definitions
This commit is contained in:
parent
df2b5dfed0
commit
7b0aeeec4b
13 changed files with 29 additions and 1 deletions
|
@ -149,6 +149,7 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
|
||||||
keywords,
|
keywords,
|
||||||
body,
|
body,
|
||||||
decorator_list,
|
decorator_list,
|
||||||
|
type_params,
|
||||||
range,
|
range,
|
||||||
} = node;
|
} = node;
|
||||||
let decorator_list = self.fold(decorator_list)?;
|
let decorator_list = self.fold(decorator_list)?;
|
||||||
|
@ -159,12 +160,15 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
|
||||||
let keywords = self.fold(keywords)?;
|
let keywords = self.fold(keywords)?;
|
||||||
let body = self.fold(body)?;
|
let body = self.fold(body)?;
|
||||||
let range = self.map_user(range, context)?;
|
let range = self.map_user(range, context)?;
|
||||||
|
let type_params = self.fold(type_params)?;
|
||||||
|
|
||||||
Ok(crate::StmtClassDef {
|
Ok(crate::StmtClassDef {
|
||||||
name,
|
name,
|
||||||
bases,
|
bases,
|
||||||
keywords,
|
keywords,
|
||||||
body,
|
body,
|
||||||
decorator_list,
|
decorator_list,
|
||||||
|
type_params,
|
||||||
range,
|
range,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -180,6 +184,7 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
|
||||||
returns,
|
returns,
|
||||||
type_comment,
|
type_comment,
|
||||||
range,
|
range,
|
||||||
|
type_params,
|
||||||
} = node;
|
} = node;
|
||||||
let decorator_list = self.fold(decorator_list)?;
|
let decorator_list = self.fold(decorator_list)?;
|
||||||
let context = self.will_map_user(&range);
|
let context = self.will_map_user(&range);
|
||||||
|
@ -189,6 +194,7 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
|
||||||
let returns = self.fold(returns)?;
|
let returns = self.fold(returns)?;
|
||||||
let body = self.fold(body)?;
|
let body = self.fold(body)?;
|
||||||
let type_comment = self.fold(type_comment)?;
|
let type_comment = self.fold(type_comment)?;
|
||||||
|
let type_params = self.fold(type_params)?;
|
||||||
let range = self.map_user(range, context)?;
|
let range = self.map_user(range, context)?;
|
||||||
Ok(crate::StmtFunctionDef {
|
Ok(crate::StmtFunctionDef {
|
||||||
name,
|
name,
|
||||||
|
@ -196,6 +202,7 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
|
||||||
body,
|
body,
|
||||||
decorator_list,
|
decorator_list,
|
||||||
returns,
|
returns,
|
||||||
|
type_params,
|
||||||
type_comment,
|
type_comment,
|
||||||
range,
|
range,
|
||||||
})
|
})
|
||||||
|
@ -211,6 +218,7 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
|
||||||
decorator_list,
|
decorator_list,
|
||||||
returns,
|
returns,
|
||||||
type_comment,
|
type_comment,
|
||||||
|
type_params,
|
||||||
range,
|
range,
|
||||||
} = node;
|
} = node;
|
||||||
let decorator_list = self.fold(decorator_list)?;
|
let decorator_list = self.fold(decorator_list)?;
|
||||||
|
@ -221,6 +229,7 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
|
||||||
let returns = self.fold(returns)?;
|
let returns = self.fold(returns)?;
|
||||||
let body = self.fold(body)?;
|
let body = self.fold(body)?;
|
||||||
let type_comment = self.fold(type_comment)?;
|
let type_comment = self.fold(type_comment)?;
|
||||||
|
let type_params = self.fold(type_params)?;
|
||||||
let range = self.map_user(range, context)?;
|
let range = self.map_user(range, context)?;
|
||||||
Ok(crate::StmtAsyncFunctionDef {
|
Ok(crate::StmtAsyncFunctionDef {
|
||||||
name,
|
name,
|
||||||
|
@ -229,6 +238,7 @@ impl crate::fold::Fold<TextRange> for LinearLocator<'_> {
|
||||||
decorator_list,
|
decorator_list,
|
||||||
returns,
|
returns,
|
||||||
type_comment,
|
type_comment,
|
||||||
|
type_params,
|
||||||
range,
|
range,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
5
parser/src/python.rs
generated
5
parser/src/python.rs
generated
|
@ -30685,6 +30685,7 @@ fn __action157(
|
||||||
let returns = r.map(|x| Box::new(x));
|
let returns = r.map(|x| Box::new(x));
|
||||||
let end_location = body.last().unwrap().end();
|
let end_location = body.last().unwrap().end();
|
||||||
let type_comment = None;
|
let type_comment = None;
|
||||||
|
let type_params = Vec::new();
|
||||||
if is_async.is_some() {
|
if is_async.is_some() {
|
||||||
ast::StmtAsyncFunctionDef {
|
ast::StmtAsyncFunctionDef {
|
||||||
name,
|
name,
|
||||||
|
@ -30693,6 +30694,7 @@ fn __action157(
|
||||||
decorator_list,
|
decorator_list,
|
||||||
returns,
|
returns,
|
||||||
type_comment,
|
type_comment,
|
||||||
|
type_params,
|
||||||
range: (location..end_location).into(),
|
range: (location..end_location).into(),
|
||||||
}
|
}
|
||||||
.into()
|
.into()
|
||||||
|
@ -30704,6 +30706,7 @@ fn __action157(
|
||||||
decorator_list,
|
decorator_list,
|
||||||
returns,
|
returns,
|
||||||
type_comment,
|
type_comment,
|
||||||
|
type_params,
|
||||||
range: (location..end_location).into(),
|
range: (location..end_location).into(),
|
||||||
}
|
}
|
||||||
.into()
|
.into()
|
||||||
|
@ -30842,12 +30845,14 @@ fn __action164(
|
||||||
None => (vec![], vec![]),
|
None => (vec![], vec![]),
|
||||||
};
|
};
|
||||||
let end_location = body.last().unwrap().end();
|
let end_location = body.last().unwrap().end();
|
||||||
|
let type_params = Vec::new();
|
||||||
ast::Stmt::ClassDef(ast::StmtClassDef {
|
ast::Stmt::ClassDef(ast::StmtClassDef {
|
||||||
name,
|
name,
|
||||||
bases,
|
bases,
|
||||||
keywords,
|
keywords,
|
||||||
body,
|
body,
|
||||||
decorator_list,
|
decorator_list,
|
||||||
|
type_params,
|
||||||
range: (location..end_location).into(),
|
range: (location..end_location).into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -85,6 +85,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -28,6 +28,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -102,6 +102,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -122,6 +122,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -131,6 +131,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -140,6 +140,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -65,6 +65,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -85,6 +85,7 @@ Ok(
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: parser/src/parser.rs
|
source: parser/src/parser.rs
|
||||||
expression: "parse_program(source, \"<test>\").unwrap()"
|
expression: "ast::Suite::parse(source, \"<test>\").unwrap()"
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
ClassDef(
|
ClassDef(
|
||||||
|
@ -68,6 +68,7 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
FunctionDef(
|
FunctionDef(
|
||||||
|
@ -129,10 +130,12 @@ expression: "parse_program(source, \"<test>\").unwrap()"
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
returns: None,
|
returns: None,
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
decorator_list: [],
|
decorator_list: [],
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -90,6 +90,7 @@ expression: parse_ast
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
type_comment: None,
|
type_comment: None,
|
||||||
|
type_params: [],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue