aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/input.rs')
-rw-r--r--crates/ra_analysis/src/input.rs76
1 files changed, 0 insertions, 76 deletions
diff --git a/crates/ra_analysis/src/input.rs b/crates/ra_analysis/src/input.rs
deleted file mode 100644
index ba8a17fd5..000000000
--- a/crates/ra_analysis/src/input.rs
+++ /dev/null
@@ -1,76 +0,0 @@
1use std::{fmt, sync::Arc};
2
3use relative_path::RelativePath;
4use rustc_hash::FxHashMap;
5use rustc_hash::FxHashSet;
6use salsa;
7
8use crate::{symbol_index::SymbolIndex, FileResolverImp};
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub struct FileId(pub u32);
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
14pub struct CrateId(pub u32);
15
16#[derive(Debug, Clone, Default, PartialEq, Eq)]
17pub struct CrateGraph {
18 pub(crate) crate_roots: FxHashMap<CrateId, FileId>,
19}
20
21impl 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
33pub 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}
37
38salsa::query_group! {
39 pub(crate) trait FilesDatabase: salsa::Database {
40 fn file_text(file_id: FileId) -> Arc<String> {
41 type FileTextQuery;
42 storage input;
43 }
44 fn file_source_root(file_id: FileId) -> SourceRootId {
45 type FileSourceRootQuery;
46 storage input;
47 }
48 fn source_root(id: SourceRootId) -> Arc<SourceRoot> {
49 type SourceRootQuery;
50 storage input;
51 }
52 fn libraries() -> Arc<Vec<SourceRootId>> {
53 type LibrariesQuery;
54 storage input;
55 }
56 fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> {
57 type LibrarySymbolsQuery;
58 storage input;
59 }
60 fn crate_graph() -> Arc<CrateGraph> {
61 type CrateGraphQuery;
62 storage input;
63 }
64 }
65}
66
67#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
68pub(crate) struct SourceRootId(pub(crate) u32);
69
70#[derive(Default, Clone, Debug, PartialEq, Eq)]
71pub(crate) struct SourceRoot {
72 pub(crate) file_resolver: FileResolverImp,
73 pub(crate) files: FxHashSet<FileId>,
74}
75
76pub(crate) const WORKSPACE: SourceRootId = SourceRootId(0);