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:
Chayim Refael Friedman 2025-05-21 00:04:59 +03:00
parent 5b2c8bc9ae
commit 4bcf03e28b
22 changed files with 1220 additions and 546 deletions

View file

@ -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 {