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.rs75
1 files changed, 0 insertions, 75 deletions
diff --git a/crates/ra_analysis/src/input.rs b/crates/ra_analysis/src/input.rs
deleted file mode 100644
index e601cd58a..000000000
--- a/crates/ra_analysis/src/input.rs
+++ /dev/null
@@ -1,75 +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::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 fn debug_path(&self, _1file_id: FileId) -> Option<std::path::PathBuf> {
37 None
38 }
39}
40
41salsa::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 crate_graph() -> Arc<CrateGraph> {
60 type CrateGraphQuery;
61 storage input;
62 }
63 }
64}
65
66#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub(crate) struct SourceRootId(pub(crate) u32);
68
69#[derive(Default, Clone, Debug, PartialEq, Eq)]
70pub(crate) struct SourceRoot {
71 pub(crate) file_resolver: FileResolverImp,
72 pub(crate) files: FxHashSet<FileId>,
73}
74
75pub(crate) const WORKSPACE: SourceRootId = SourceRootId(0);