Remove copied core modules from ruff_python_formatter (#3371)

This commit is contained in:
Charlie Marsh 2023-03-08 14:03:40 -05:00 committed by GitHub
parent 130e733023
commit 0a9d259f9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 105 additions and 273 deletions

View file

@ -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
}