Include decorators in Function and Class definition ranges (#4467)

This commit is contained in:
Micha Reiser 2023-05-22 17:50:42 +02:00 committed by GitHub
parent 9308e939f4
commit daadd24bde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 198 additions and 136 deletions

View file

@ -953,12 +953,7 @@ impl From<(ast::Stmt, &Locator<'_>)> for Stmt {
};
Stmt {
range: TextRange::new(
decorator_list
.first()
.map_or(range.start(), ast::Ranged::start),
body.end(),
),
range: TextRange::new(range.start(), body.end()),
node: StmtKind::FunctionDef {
name: name.into(),
args: Box::new((*args, locator).into()),
@ -999,12 +994,7 @@ impl From<(ast::Stmt, &Locator<'_>)> for Stmt {
};
Stmt {
range: TextRange::new(
decorator_list
.first()
.map_or(range.start(), |expr| expr.range().start()),
body.end(),
),
range: TextRange::new(range.start(), body.end()),
node: StmtKind::AsyncFunctionDef {
name: name.into(),
args: Box::new((*args, locator).into()),