Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/span_map.rs')
| -rw-r--r-- | crates/hir-expand/src/span_map.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/hir-expand/src/span_map.rs b/crates/hir-expand/src/span_map.rs index 740c27b89c..ab99cb14f9 100644 --- a/crates/hir-expand/src/span_map.rs +++ b/crates/hir-expand/src/span_map.rs @@ -79,10 +79,16 @@ impl SpanMapRef<'_> { } } -pub(crate) fn real_span_map(db: &dyn ExpandDatabase, file_id: EditionedFileId) -> Arc<RealSpanMap> { +pub(crate) fn real_span_map( + db: &dyn ExpandDatabase, + editioned_file_id: EditionedFileId, +) -> Arc<RealSpanMap> { use syntax::ast::HasModuleItem; let mut pairs = vec![(syntax::TextSize::new(0), span::ROOT_ERASED_FILE_AST_ID)]; - let ast_id_map = db.ast_id_map(file_id.into()); + let ast_id_map = db.ast_id_map(editioned_file_id.into()); + + let file_id = base_db::EditionedFileId::new(db, editioned_file_id); + let tree = db.parse(file_id).tree(); // This is an incrementality layer. Basically we can't use absolute ranges for our spans as that // would mean we'd invalidate everything whenever we type. So instead we make the text ranges @@ -134,7 +140,7 @@ pub(crate) fn real_span_map(db: &dyn ExpandDatabase, file_id: EditionedFileId) - }); Arc::new(RealSpanMap::from_file( - file_id, + editioned_file_id, pairs.into_boxed_slice(), tree.syntax().text_range().end(), )) |