mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-04 10:50:15 +00:00
Use stable AST IDs
Instead of simple numbering, we hash important bits, like the name of the item. This will allow for much better incrementality, e.g. when you add an item. Currently, this invalidates the IDs of all following items, which invalidates pretty much everything.
This commit is contained in:
parent
5b2c8bc9ae
commit
4bcf03e28b
22 changed files with 1220 additions and 546 deletions
|
@ -30,6 +30,16 @@ impl ast::Name {
|
|||
pub fn text(&self) -> TokenText<'_> {
|
||||
text_of_first_token(self.syntax())
|
||||
}
|
||||
pub fn text_non_mutable(&self) -> &str {
|
||||
fn first_token(green_ref: &GreenNodeData) -> &GreenTokenData {
|
||||
green_ref.children().next().and_then(NodeOrToken::into_token).unwrap()
|
||||
}
|
||||
|
||||
match self.syntax().green() {
|
||||
Cow::Borrowed(green_ref) => first_token(green_ref).text(),
|
||||
Cow::Owned(_) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::NameRef {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue