Refactor range from Attributed to Nodes (#4422)

This commit is contained in:
Micha Reiser 2023-05-16 08:36:32 +02:00 committed by GitHub
parent 140e0acf54
commit fa26860296
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
330 changed files with 4816 additions and 3946 deletions

View file

@ -1,10 +1,13 @@
use ruff_text_size::TextRange;
use rustpython_parser::ast::Attributed;
use rustpython_parser::ast::Ranged;
use crate::source_code::Locator;
/// Extract the leading indentation from a line.
pub fn indentation<'a, T>(locator: &'a Locator, located: &Attributed<T>) -> Option<&'a str> {
pub fn indentation<'a, T>(locator: &'a Locator, located: &T) -> Option<&'a str>
where
T: Ranged,
{
let line_start = locator.line_start(located.start());
let indentation = &locator.contents()[TextRange::new(line_start, located.start())];