red-knot: source_text, line_index, and parsed_module queries (#11822)

This commit is contained in:
Micha Reiser 2024-06-13 08:37:02 +01:00 committed by GitHub
parent efbf7b14b5
commit d4dd96d1f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 194 additions and 16 deletions

View file

@ -14,11 +14,12 @@ use crate::SourceLocation;
/// Index for fast [byte offset](TextSize) to [`SourceLocation`] conversions.
///
/// Cloning a [`LineIndex`] is cheap because it only requires bumping a reference count.
#[derive(Clone)]
#[derive(Clone, Eq, PartialEq)]
pub struct LineIndex {
inner: Arc<LineIndexInner>,
}
#[derive(Eq, PartialEq)]
struct LineIndexInner {
line_starts: Vec<TextSize>,
kind: IndexKind,
@ -268,7 +269,7 @@ impl Debug for LineIndex {
}
}
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
enum IndexKind {
/// Optimized index for an ASCII only document
Ascii,