mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +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
|
@ -1,7 +1,7 @@
|
|||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_trivia::{indentation_at_offset, PythonWhitespace};
|
||||
use ruff_source_file::{Line, UniversalNewlineIterator};
|
||||
use ruff_source_file::{Line, LineRanges, UniversalNewlineIterator};
|
||||
use ruff_text_size::Ranged;
|
||||
use ruff_text_size::{TextLen, TextRange};
|
||||
|
||||
|
@ -240,7 +240,7 @@ pub(crate) fn blank_before_after_class(checker: &mut Checker, docstring: &Docstr
|
|||
if let Some(first_line) = &first_line {
|
||||
let trailing = first_line.as_str().trim_whitespace_start();
|
||||
if let Some(next_statement) = trailing.strip_prefix(';') {
|
||||
let indentation = indentation_at_offset(docstring.start(), checker.locator())
|
||||
let indentation = indentation_at_offset(docstring.start(), checker.source())
|
||||
.expect("Own line docstring must have indentation");
|
||||
let mut diagnostic = Diagnostic::new(OneBlankLineAfterClass, docstring.range());
|
||||
let line_ending = checker.stylist().line_ending().as_str();
|
||||
|
|
|
@ -2,7 +2,7 @@ use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
|||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::str::{is_triple_quote, leading_quote};
|
||||
use ruff_python_semantic::Definition;
|
||||
use ruff_source_file::{NewlineWithTrailingNewline, UniversalNewlineIterator};
|
||||
use ruff_source_file::{LineRanges, NewlineWithTrailingNewline, UniversalNewlineIterator};
|
||||
use ruff_text_size::{Ranged, TextRange, TextSize};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
|
|
|
@ -1464,7 +1464,7 @@ fn blanks_and_section_underline(
|
|||
// Otherwise, documentation generators will not recognize the directive.
|
||||
let is_sphinx = checker
|
||||
.locator()
|
||||
.line(blank_lines_after_dashes_end)
|
||||
.line_str(blank_lines_after_dashes_end)
|
||||
.trim_start()
|
||||
.starts_with(".. ");
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ fn blanks_and_section_underline(
|
|||
// Otherwise, documentation generators will not recognize the directive.
|
||||
let is_sphinx = checker
|
||||
.locator()
|
||||
.line(blank_lines_end)
|
||||
.line_str(blank_lines_end)
|
||||
.trim_start()
|
||||
.starts_with(".. ");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue