aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_db')
-rw-r--r--crates/ra_db/src/input.rs22
-rw-r--r--crates/ra_db/src/lib.rs2
-rw-r--r--crates/ra_db/src/mock.rs7
3 files changed, 9 insertions, 22 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index 65b674da9..51daa8e86 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -1,10 +1,15 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use rustc_hash::{FxHashSet, FxHashMap}; 3use rustc_hash::{FxHashMap};
4use relative_path::RelativePathBuf; 4use relative_path::RelativePathBuf;
5use ra_syntax::SmolStr; 5use ra_syntax::SmolStr;
6use salsa; 6use salsa;
7 7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
9pub struct SourceRootId(pub u32);
10
11pub const WORKSPACE: SourceRootId = SourceRootId(0);
12
8#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 13#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
9pub struct FileId(pub u32); 14pub struct FileId(pub u32);
10 15
@@ -93,14 +98,6 @@ salsa::query_group! {
93 type FileSourceRootQuery; 98 type FileSourceRootQuery;
94 storage input; 99 storage input;
95 } 100 }
96 fn source_root_files(id: SourceRootId) -> Arc<FxHashSet<FileId>> {
97 type SourceRootFilesQuery;
98 storage input;
99 }
100 fn source_root_file_by_path(id: SourceRootId, path: RelativePathBuf) -> Option<FileId> {
101 type SourceRootFileByPathQuery;
102 storage input;
103 }
104 fn source_root(id: SourceRootId) -> Arc<SourceRoot> { 101 fn source_root(id: SourceRootId) -> Arc<SourceRoot> {
105 type SourceRootQuery; 102 type SourceRootQuery;
106 storage input; 103 storage input;
@@ -116,12 +113,7 @@ salsa::query_group! {
116 } 113 }
117} 114}
118 115
119#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
120pub struct SourceRootId(pub u32);
121
122#[derive(Default, Clone, Debug, PartialEq, Eq)] 116#[derive(Default, Clone, Debug, PartialEq, Eq)]
123pub struct SourceRoot { 117pub struct SourceRoot {
124 pub files: FxHashSet<FileId>, 118 pub files: FxHashMap<RelativePathBuf, FileId>,
125} 119}
126
127pub const WORKSPACE: SourceRootId = SourceRootId(0);
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index 783b7a799..d1db281e6 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -28,7 +28,7 @@ pub use crate::{
28 input::{ 28 input::{
29 FilesDatabase, FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, WORKSPACE, 29 FilesDatabase, FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, WORKSPACE,
30 FileTextQuery, FileSourceRootQuery, SourceRootQuery, LibrariesQuery, CrateGraphQuery, 30 FileTextQuery, FileSourceRootQuery, SourceRootQuery, LibrariesQuery, CrateGraphQuery,
31 FileRelativePathQuery, SourceRootFilesQuery, SourceRootFileByPathQuery, 31 FileRelativePathQuery
32 }, 32 },
33 loc2id::{LocationIntener, NumericId}, 33 loc2id::{LocationIntener, NumericId},
34}; 34};
diff --git a/crates/ra_db/src/mock.rs b/crates/ra_db/src/mock.rs
index 14d9e79b5..efe987bdd 100644
--- a/crates/ra_db/src/mock.rs
+++ b/crates/ra_db/src/mock.rs
@@ -1,7 +1,7 @@
1use rustc_hash::FxHashSet; 1use rustc_hash::FxHashSet;
2use relative_path::{RelativePath, RelativePathBuf}; 2use relative_path::{RelativePath, RelativePathBuf};
3 3
4use crate::{FileId, FileResolver, SourceRoot}; 4use crate::{FileId, FileResolver};
5 5
6#[derive(Default, Debug, Clone)] 6#[derive(Default, Debug, Clone)]
7pub struct FileMap(Vec<(FileId, RelativePathBuf)>); 7pub struct FileMap(Vec<(FileId, RelativePathBuf)>);
@@ -13,11 +13,6 @@ impl FileMap {
13 file_id 13 file_id
14 } 14 }
15 15
16 pub fn into_source_root(self) -> SourceRoot {
17 let files = self.files();
18 SourceRoot { files }
19 }
20
21 pub fn files(&self) -> FxHashSet<FileId> { 16 pub fn files(&self) -> FxHashSet<FileId> {
22 self.iter().map(|(id, _)| id).collect() 17 self.iter().map(|(id, _)| id).collect()
23 } 18 }