Encode edition within FileId in the hir layer

This commit is contained in:
Lukas Wirth 2024-07-17 17:35:40 +02:00
parent 92268627a8
commit 5264f86242
160 changed files with 1117 additions and 824 deletions

View file

@ -4,11 +4,10 @@
use std::{fmt, hash::Hash};
use stdx::{always, itertools::Itertools};
use vfs::FileId;
use crate::{
ErasedFileAstId, Span, SpanAnchor, SpanData, SyntaxContextId, TextRange, TextSize,
ROOT_ERASED_FILE_AST_ID,
EditionedFileId, ErasedFileAstId, Span, SpanAnchor, SpanData, SyntaxContextId, TextRange,
TextSize, ROOT_ERASED_FILE_AST_ID,
};
/// Maps absolute text ranges for the corresponding file to the relevant span data.
@ -109,7 +108,7 @@ where
#[derive(PartialEq, Eq, Hash, Debug)]
pub struct RealSpanMap {
file_id: FileId,
file_id: EditionedFileId,
/// Invariant: Sorted vec over TextSize
// FIXME: SortedVec<(TextSize, ErasedFileAstId)>?
pairs: Box<[(TextSize, ErasedFileAstId)]>,
@ -128,7 +127,7 @@ impl fmt::Display for RealSpanMap {
impl RealSpanMap {
/// Creates a real file span map that returns absolute ranges (relative ranges to the root ast id).
pub fn absolute(file_id: FileId) -> Self {
pub fn absolute(file_id: EditionedFileId) -> Self {
RealSpanMap {
file_id,
pairs: Box::from([(TextSize::new(0), ROOT_ERASED_FILE_AST_ID)]),
@ -137,7 +136,7 @@ impl RealSpanMap {
}
pub fn from_file(
file_id: FileId,
file_id: EditionedFileId,
pairs: Box<[(TextSize, ErasedFileAstId)]>,
end: TextSize,
) -> Self {