mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-10-31 12:04:43 +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
				
			
		|  | @ -277,8 +277,8 @@ mod tests { | |||
|         assert_eq!(quoted.to_string(), "hello"); | ||||
|         let t = format!("{quoted:#?}"); | ||||
|         expect![[r#" | ||||
|             SUBTREE $$ 937550:0@0..0#ROOT2024 937550:0@0..0#ROOT2024 | ||||
|               IDENT   hello 937550:0@0..0#ROOT2024"#]]
 | ||||
|             SUBTREE $$ 937550:Root[0000, 0]@0..0#ROOT2024 937550:Root[0000, 0]@0..0#ROOT2024 | ||||
|               IDENT   hello 937550:Root[0000, 0]@0..0#ROOT2024"#]]
 | ||||
|         .assert_eq(&t); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| use std::borrow::Borrow; | ||||
| 
 | ||||
| use either::Either; | ||||
| use span::{AstIdNode, ErasedFileAstId, FileAstId, FileId, SyntaxContext}; | ||||
| use span::{ErasedFileAstId, FileAstId, FileId, SyntaxContext}; | ||||
| use syntax::{AstNode, AstPtr, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextRange, TextSize}; | ||||
| 
 | ||||
| use crate::{ | ||||
|  | @ -106,7 +106,7 @@ impl FileRange { | |||
| /// It is stable across reparses, and can be used as salsa key/value.
 | ||||
| pub type AstId<N> = crate::InFile<FileAstId<N>>; | ||||
| 
 | ||||
| impl<N: AstIdNode> AstId<N> { | ||||
| impl<N: AstNode> AstId<N> { | ||||
|     pub fn to_node(&self, db: &dyn ExpandDatabase) -> N { | ||||
|         self.to_ptr(db).to_node(&db.parse_or_expand(self.file_id)) | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Chayim Refael Friedman
						Chayim Refael Friedman