aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/db.rs')
-rw-r--r--crates/ra_analysis/src/db.rs24
1 files changed, 19 insertions, 5 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs
index 1709be5cf..9d46609ec 100644
--- a/crates/ra_analysis/src/db.rs
+++ b/crates/ra_analysis/src/db.rs
@@ -1,10 +1,9 @@
1use std::{fmt, sync::Arc}; 1use std::{fmt, sync::Arc};
2
2use salsa::{self, Database}; 3use salsa::{self, Database};
3use ra_db::{LocationIntener, BaseDatabase}; 4use ra_db::{LocationIntener, BaseDatabase, FileId};
4 5
5use crate::{ 6use crate::{symbol_index, LineIndex};
6 symbol_index,
7};
8 7
9#[derive(Debug)] 8#[derive(Debug)]
10pub(crate) struct RootDatabase { 9pub(crate) struct RootDatabase {
@@ -71,6 +70,19 @@ impl AsRef<LocationIntener<hir::MacroCallLoc, hir::MacroCallId>> for RootDatabas
71 } 70 }
72} 71}
73 72
73salsa::query_group! {
74 pub(crate) trait LineIndexDatabase: ra_db::FilesDatabase + BaseDatabase {
75 fn line_index(file_id: FileId) -> Arc<LineIndex> {
76 type LineIndexQuery;
77 }
78 }
79}
80
81fn line_index(db: &impl ra_db::FilesDatabase, file_id: FileId) -> Arc<LineIndex> {
82 let text = db.file_text(file_id);
83 Arc::new(LineIndex::new(&*text))
84}
85
74salsa::database_storage! { 86salsa::database_storage! {
75 pub(crate) struct RootDatabaseStorage for RootDatabase { 87 pub(crate) struct RootDatabaseStorage for RootDatabase {
76 impl ra_db::FilesDatabase { 88 impl ra_db::FilesDatabase {
@@ -84,7 +96,9 @@ salsa::database_storage! {
84 } 96 }
85 impl ra_db::SyntaxDatabase { 97 impl ra_db::SyntaxDatabase {
86 fn source_file() for ra_db::SourceFileQuery; 98 fn source_file() for ra_db::SourceFileQuery;
87 fn file_lines() for ra_db::FileLinesQuery; 99 }
100 impl LineIndexDatabase {
101 fn line_index() for LineIndexQuery;
88 } 102 }
89 impl symbol_index::SymbolsDatabase { 103 impl symbol_index::SymbolsDatabase {
90 fn file_symbols() for symbol_index::FileSymbolsQuery; 104 fn file_symbols() for symbol_index::FileSymbolsQuery;