Finds and returns the [`Scope`] corresponding to a given [`ast::StmtFunctionDef`]. This method searches all scopes created by a function definition, comparing the [`TextRange`] of the provided `function_def` with the range of the function associated with the scope.
(&self, function_def: &ast::StmtFunctionDef)
| 2374 | /// [`TextRange`] of the provided `function_def` with the range of the function |
| 2375 | /// associated with the scope. |
| 2376 | pub fn function_scope(&self, function_def: &ast::StmtFunctionDef) -> Option<&Scope<'_>> { |
| 2377 | self.scopes.iter().find(|scope| { |
| 2378 | let Some(function) = scope.kind.as_function() else { |
| 2379 | return false; |
| 2380 | }; |
| 2381 | function.range() == function_def.range() |
| 2382 | }) |
| 2383 | } |
| 2384 | |
| 2385 | /// Return `true` if the model is in a `typing.Protocol` subclass or an abstract |
| 2386 | /// method. |
no test coverage detected