diff options
Diffstat (limited to 'crates/ra_analysis/src/input.rs')
-rw-r--r-- | crates/ra_analysis/src/input.rs | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/crates/ra_analysis/src/input.rs b/crates/ra_analysis/src/input.rs deleted file mode 100644 index a78b6e397..000000000 --- a/crates/ra_analysis/src/input.rs +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | use std::{fmt, sync::Arc}; | ||
2 | |||
3 | use relative_path::RelativePath; | ||
4 | use rustc_hash::FxHashMap; | ||
5 | use rustc_hash::FxHashSet; | ||
6 | use salsa; | ||
7 | |||
8 | use crate::{symbol_index::SymbolIndex, FileResolverImp}; | ||
9 | |||
10 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
11 | pub struct FileId(pub u32); | ||
12 | |||
13 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
14 | pub struct CrateId(pub u32); | ||
15 | |||
16 | #[derive(Debug, Clone, Default, PartialEq, Eq)] | ||
17 | pub struct CrateGraph { | ||
18 | pub(crate) crate_roots: FxHashMap<CrateId, FileId>, | ||
19 | } | ||
20 | |||
21 | impl CrateGraph { | ||
22 | pub fn new() -> CrateGraph { | ||
23 | CrateGraph::default() | ||
24 | } | ||
25 | pub fn add_crate_root(&mut self, file_id: FileId) -> CrateId { | ||
26 | let crate_id = CrateId(self.crate_roots.len() as u32); | ||
27 | let prev = self.crate_roots.insert(crate_id, file_id); | ||
28 | assert!(prev.is_none()); | ||
29 | crate_id | ||
30 | } | ||
31 | } | ||
32 | |||
33 | pub trait FileResolver: fmt::Debug + Send + Sync + 'static { | ||
34 | fn file_stem(&self, file_id: FileId) -> String; | ||
35 | fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId>; | ||
36 | fn debug_path(&self, _file_id: FileId) -> Option<std::path::PathBuf> { | ||
37 | None | ||
38 | } | ||
39 | } | ||
40 | |||
41 | salsa::query_group! { | ||
42 | pub(crate) trait FilesDatabase: salsa::Database { | ||
43 | fn file_text(file_id: FileId) -> Arc<String> { | ||
44 | type FileTextQuery; | ||
45 | storage input; | ||
46 | } | ||
47 | fn file_source_root(file_id: FileId) -> SourceRootId { | ||
48 | type FileSourceRootQuery; | ||
49 | storage input; | ||
50 | } | ||
51 | fn source_root(id: SourceRootId) -> Arc<SourceRoot> { | ||
52 | type SourceRootQuery; | ||
53 | storage input; | ||
54 | } | ||
55 | fn libraries() -> Arc<Vec<SourceRootId>> { | ||
56 | type LibrariesQuery; | ||
57 | storage input; | ||
58 | } | ||
59 | fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> { | ||
60 | type LibrarySymbolsQuery; | ||
61 | storage input; | ||
62 | } | ||
63 | fn crate_graph() -> Arc<CrateGraph> { | ||
64 | type CrateGraphQuery; | ||
65 | storage input; | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | |||
70 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] | ||
71 | pub(crate) struct SourceRootId(pub(crate) u32); | ||
72 | |||
73 | #[derive(Default, Clone, Debug, PartialEq, Eq)] | ||
74 | pub(crate) struct SourceRoot { | ||
75 | pub(crate) file_resolver: FileResolverImp, | ||
76 | pub(crate) files: FxHashSet<FileId>, | ||
77 | } | ||
78 | |||
79 | pub(crate) const WORKSPACE: SourceRootId = SourceRootId(0); | ||