Remove helpers.rs dependency on Binding (#3839)

This commit is contained in:
Charlie Marsh 2023-03-31 23:19:45 -04:00 committed by GitHub
parent b6276e2d95
commit 27e40e9b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 19 deletions

View file

@ -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>,