mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-21 02:50:52 +00:00
Remove copied core
modules from ruff_python_formatter
(#3371)
This commit is contained in:
parent
130e733023
commit
0a9d259f9c
15 changed files with 105 additions and 273 deletions
|
@ -1,15 +1,21 @@
|
|||
use ruff_formatter::{FormatContext, SimpleFormatOptions};
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::core::locator::Locator;
|
||||
use ruff_formatter::{FormatContext, SimpleFormatOptions};
|
||||
use ruff_python_ast::source_code::Locator;
|
||||
|
||||
pub struct ASTFormatContext<'a> {
|
||||
options: SimpleFormatOptions,
|
||||
contents: Rc<str>,
|
||||
locator: Locator<'a>,
|
||||
}
|
||||
|
||||
impl<'a> ASTFormatContext<'a> {
|
||||
pub fn new(options: SimpleFormatOptions, locator: Locator<'a>) -> Self {
|
||||
Self { options, locator }
|
||||
Self {
|
||||
options,
|
||||
contents: Rc::from(locator.contents()),
|
||||
locator,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +28,10 @@ impl FormatContext for ASTFormatContext<'_> {
|
|||
}
|
||||
|
||||
impl<'a> ASTFormatContext<'a> {
|
||||
pub fn contents(&'a self) -> Rc<str> {
|
||||
self.contents.clone()
|
||||
}
|
||||
|
||||
pub fn locator(&'a self) -> &'a Locator {
|
||||
&self.locator
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue