mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 07:37:38 +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
|
@ -133,6 +133,17 @@ impl<'a> Locator<'a> {
|
|||
&self.contents[start..end]
|
||||
}
|
||||
|
||||
/// Return the byte offset of the given [`Location`].
|
||||
pub fn offset(&self, location: Location) -> usize {
|
||||
let index = self.get_or_init_index();
|
||||
truncate(location, index, self.contents)
|
||||
}
|
||||
|
||||
/// Return the underlying source code.
|
||||
pub fn contents(&self) -> &'a str {
|
||||
self.contents
|
||||
}
|
||||
|
||||
pub const fn len(&self) -> usize {
|
||||
self.contents.len()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue