mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Encode edition within FileId in the hir layer
This commit is contained in:
parent
92268627a8
commit
5264f86242
160 changed files with 1117 additions and 824 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue