mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 11:59:10 +00:00
Extract LineIndex
independent methods from Locator
(#13938)
This commit is contained in:
parent
f8eb547fb4
commit
9f3a38d408
171 changed files with 1348 additions and 1284 deletions
|
@ -17,7 +17,6 @@ ruff_macros = { workspace = true }
|
|||
ruff_python_ast = { workspace = true }
|
||||
ruff_python_parser = { workspace = true }
|
||||
ruff_python_stdlib = { workspace = true }
|
||||
ruff_source_file = { workspace = true }
|
||||
ruff_text_size = { workspace = true }
|
||||
|
||||
bitflags = { workspace = true }
|
||||
|
|
|
@ -8,7 +8,6 @@ use ruff_index::{newtype_index, IndexSlice, IndexVec};
|
|||
use ruff_python_ast::helpers::extract_handled_exceptions;
|
||||
use ruff_python_ast::name::QualifiedName;
|
||||
use ruff_python_ast::{self as ast, Stmt};
|
||||
use ruff_source_file::Locator;
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::context::ExecutionContext;
|
||||
|
@ -228,8 +227,8 @@ impl<'a> Binding<'a> {
|
|||
}
|
||||
|
||||
/// Returns the name of the binding (e.g., `x` in `x = 1`).
|
||||
pub fn name<'b>(&self, locator: &Locator<'b>) -> &'b str {
|
||||
locator.slice(self.range)
|
||||
pub fn name<'b>(&self, source: &'b str) -> &'b str {
|
||||
&source[self.range]
|
||||
}
|
||||
|
||||
/// Returns the statement in which the binding was defined.
|
||||
|
|
|
@ -4,7 +4,6 @@ use bitflags::bitflags;
|
|||
|
||||
use ruff_index::{newtype_index, IndexSlice, IndexVec};
|
||||
use ruff_python_ast::ExprContext;
|
||||
use ruff_source_file::Locator;
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::scope::ScopeId;
|
||||
|
@ -157,8 +156,8 @@ pub struct UnresolvedReference {
|
|||
|
||||
impl UnresolvedReference {
|
||||
/// Returns the name of the reference.
|
||||
pub fn name<'a>(&self, locator: &Locator<'a>) -> &'a str {
|
||||
locator.slice(self.range)
|
||||
pub fn name<'a>(&self, source: &'a str) -> &'a str {
|
||||
&source[self.range]
|
||||
}
|
||||
|
||||
/// The range of the reference in the source code.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue