mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Replace ID based TokenMap with proper relative text-ranges / spans
This commit is contained in:
parent
f79439caed
commit
890eb17b4e
80 changed files with 1816 additions and 2046 deletions
|
@ -31,5 +31,6 @@ paths.workspace = true
|
|||
tt.workspace = true
|
||||
stdx.workspace = true
|
||||
profile.workspace = true
|
||||
text-size.workspace = true
|
||||
# Intentionally *not* depend on anything salsa-related
|
||||
# base-db.workspace = true
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
use std::collections::{HashMap, VecDeque};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use text_size::TextRange;
|
||||
use tt::Span;
|
||||
|
||||
use crate::msg::{ENCODE_CLOSE_SPAN_VERSION, VARIABLE_SIZED_SPANS};
|
||||
|
@ -55,6 +56,19 @@ impl SerializableSpan<1> for tt::TokenId {
|
|||
}
|
||||
}
|
||||
|
||||
impl<FileId> SerializableSpan<3> for tt::SpanData<FileId>
|
||||
where
|
||||
FileId: From<u32> + Into<u32>,
|
||||
Self: Span,
|
||||
{
|
||||
fn into_u32(self) -> [u32; 3] {
|
||||
[self.anchor.into(), self.range.start().into(), self.range.end().into()]
|
||||
}
|
||||
fn from_u32([file_id, start, end]: [u32; 3]) -> Self {
|
||||
tt::SpanData { anchor: file_id.into(), range: TextRange::new(start.into(), end.into()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct FlatTree {
|
||||
subtree: Vec<u32>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue