mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
Implement Ranged
on more structs (#6921)
Now that it's in `ruff_text_size`, we can use it in a few places that we couldn't before.
This commit is contained in:
parent
fc89976c24
commit
059757a8c8
23 changed files with 104 additions and 115 deletions
|
@ -3,7 +3,7 @@ use std::cmp::Ordering;
|
|||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use ruff_text_size::{TextRange, TextSize};
|
||||
use ruff_text_size::{Ranged, TextRange, TextSize};
|
||||
|
||||
/// A text edit to be applied to a source file. Inserts, deletes, or replaces
|
||||
/// content at a given location.
|
||||
|
@ -62,20 +62,6 @@ impl Edit {
|
|||
self.content.as_deref()
|
||||
}
|
||||
|
||||
/// Returns the start location of the edit in the source document.
|
||||
pub const fn start(&self) -> TextSize {
|
||||
self.range.start()
|
||||
}
|
||||
|
||||
pub const fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
|
||||
/// Returns the edit's end location in the source document.
|
||||
pub const fn end(&self) -> TextSize {
|
||||
self.range.end()
|
||||
}
|
||||
|
||||
fn kind(&self) -> EditOperationKind {
|
||||
if self.content.is_none() {
|
||||
EditOperationKind::Deletion
|
||||
|
@ -120,6 +106,12 @@ impl PartialOrd for Edit {
|
|||
}
|
||||
}
|
||||
|
||||
impl Ranged for Edit {
|
||||
fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
enum EditOperationKind {
|
||||
/// Edit that inserts new content into the source document.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue