Remove copied core modules from ruff_python_formatter (#3371)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user