mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 01:51:30 +00:00
Remove helpers.rs
dependency on Binding
(#3839)
This commit is contained in:
parent
b6276e2d95
commit
27e40e9b31
2 changed files with 22 additions and 19 deletions
|
@ -13,7 +13,6 @@ use rustpython_parser::{lexer, Mode, Tok};
|
|||
use smallvec::{smallvec, SmallVec};
|
||||
|
||||
use crate::context::Context;
|
||||
use crate::scope::{Binding, BindingKind};
|
||||
use crate::source_code::{Generator, Indexer, Locator, Stylist};
|
||||
use crate::types::{CallPath, Range};
|
||||
use crate::visitor;
|
||||
|
@ -978,21 +977,6 @@ pub fn identifier_range(stmt: &Stmt, locator: &Locator) -> Range {
|
|||
Range::from(stmt)
|
||||
}
|
||||
|
||||
/// Like `identifier_range`, but accepts a `Binding`.
|
||||
pub fn binding_range(binding: &Binding, locator: &Locator) -> Range {
|
||||
if matches!(
|
||||
binding.kind,
|
||||
BindingKind::ClassDefinition | BindingKind::FunctionDefinition
|
||||
) {
|
||||
binding
|
||||
.source
|
||||
.as_ref()
|
||||
.map_or(binding.range, |source| identifier_range(source, locator))
|
||||
} else {
|
||||
binding.range
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the ranges of [`Tok::Name`] tokens within a specified node.
|
||||
pub fn find_names<'a, T>(
|
||||
located: &'a Located<T>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue