mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Map attribute input tokens correctly
This commit is contained in:
parent
cee02673d1
commit
177c70128c
8 changed files with 158 additions and 61 deletions
|
@ -1,5 +1,7 @@
|
|||
//! Mapping between `TokenId`s and the token's position in macro definitions or inputs.
|
||||
|
||||
use std::hash::Hash;
|
||||
|
||||
use parser::{SyntaxKind, T};
|
||||
use syntax::{TextRange, TextSize};
|
||||
|
||||
|
@ -24,6 +26,25 @@ impl TokenTextRange {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct MappedSubTree {
|
||||
pub tree: tt::Subtree,
|
||||
pub map: TokenMap,
|
||||
}
|
||||
|
||||
impl Eq for MappedSubTree {}
|
||||
impl PartialEq for MappedSubTree {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.tree == other.tree && self.map == other.map
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for MappedSubTree {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.tree.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps `tt::TokenId` to the relative range of the original token.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Default)]
|
||||
pub struct TokenMap {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue