mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-15 23:05:40 +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
|
@ -8,7 +8,6 @@ use ruff_python_ast::AstNode;
|
|||
use ruff_python_ast::Mod;
|
||||
use ruff_python_parser::{parse, AsMode, ParseError, Parsed};
|
||||
use ruff_python_trivia::CommentRanges;
|
||||
use ruff_source_file::Locator;
|
||||
|
||||
use crate::comments::{
|
||||
has_skip_comment, leading_comments, trailing_comments, Comments, SourceComment,
|
||||
|
@ -127,10 +126,9 @@ pub fn format_module_ast<'a>(
|
|||
) -> FormatResult<Formatted<PyFormatContext<'a>>> {
|
||||
let source_code = SourceCode::new(source);
|
||||
let comments = Comments::from_ast(parsed.syntax(), source_code, comment_ranges);
|
||||
let locator = Locator::new(source);
|
||||
|
||||
let formatted = format!(
|
||||
PyFormatContext::new(options, locator.contents(), comments, parsed.tokens()),
|
||||
PyFormatContext::new(options, source, comments, parsed.tokens()),
|
||||
[parsed.syntax().format()]
|
||||
)?;
|
||||
formatted
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue