aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_analysis/src/db/mod.rs11
-rw-r--r--crates/ra_analysis/src/imp.rs19
-rw-r--r--crates/ra_analysis/src/roots.rs1
-rw-r--r--crates/ra_analysis/tests/tests.rs2
4 files changed, 21 insertions, 12 deletions
diff --git a/crates/ra_analysis/src/db/mod.rs b/crates/ra_analysis/src/db/mod.rs
index c84bfa7a8..081510daa 100644
--- a/crates/ra_analysis/src/db/mod.rs
+++ b/crates/ra_analysis/src/db/mod.rs
@@ -61,21 +61,12 @@ salsa::query_group! {
61 } 61 }
62} 62}
63 63
64#[derive(Default, Debug)] 64#[derive(Default, Debug, PartialEq, Eq)]
65pub(crate) struct FileSet { 65pub(crate) struct FileSet {
66 pub(crate) files: FxHashSet<FileId>, 66 pub(crate) files: FxHashSet<FileId>,
67 pub(crate) resolver: FileResolverImp, 67 pub(crate) resolver: FileResolverImp,
68} 68}
69 69
70impl PartialEq for FileSet {
71 fn eq(&self, other: &FileSet) -> bool {
72 self.files == other.files
73 }
74}
75
76impl Eq for FileSet {
77}
78
79impl Hash for FileSet { 70impl Hash for FileSet {
80 fn hash<H: Hasher>(&self, hasher: &mut H) { 71 fn hash<H: Hasher>(&self, hasher: &mut H) {
81 let mut files = self.files.iter().cloned().collect::<Vec<_>>(); 72 let mut files = self.files.iter().cloned().collect::<Vec<_>>();
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 26f5e175b..6e6c022d9 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -3,6 +3,7 @@ use std::{
3 Arc, 3 Arc,
4 atomic::{AtomicBool, Ordering::SeqCst}, 4 atomic::{AtomicBool, Ordering::SeqCst},
5 }, 5 },
6 hash::{Hash, Hasher},
6 fmt, 7 fmt,
7 collections::VecDeque, 8 collections::VecDeque,
8 iter, 9 iter,
@@ -29,6 +30,21 @@ pub(crate) struct FileResolverImp {
29 inner: Arc<FileResolver> 30 inner: Arc<FileResolver>
30} 31}
31 32
33impl PartialEq for FileResolverImp {
34 fn eq(&self, other: &FileResolverImp) -> bool {
35 self.inner() == other.inner()
36 }
37}
38
39impl Eq for FileResolverImp {
40}
41
42impl Hash for FileResolverImp {
43 fn hash<H: Hasher>(&self, hasher: &mut H) {
44 self.inner().hash(hasher);
45 }
46}
47
32impl FileResolverImp { 48impl FileResolverImp {
33 pub(crate) fn new(inner: Arc<FileResolver>) -> FileResolverImp { 49 pub(crate) fn new(inner: Arc<FileResolver>) -> FileResolverImp {
34 FileResolverImp { inner } 50 FileResolverImp { inner }
@@ -39,6 +55,9 @@ impl FileResolverImp {
39 pub(crate) fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId> { 55 pub(crate) fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId> {
40 self.inner.resolve(file_id, path) 56 self.inner.resolve(file_id, path)
41 } 57 }
58 fn inner(&self) -> *const FileResolver {
59 &*self.inner
60 }
42} 61}
43 62
44impl Default for FileResolverImp { 63impl Default for FileResolverImp {
diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs
index 692a07ccd..766548c70 100644
--- a/crates/ra_analysis/src/roots.rs
+++ b/crates/ra_analysis/src/roots.rs
@@ -78,7 +78,6 @@ impl SourceRoot for WritableSourceRoot {
78 fn contains(&self, file_id: FileId) -> bool { 78 fn contains(&self, file_id: FileId) -> bool {
79 let db = self.db.read(); 79 let db = self.db.read();
80 let files = &db.file_set(()).files; 80 let files = &db.file_set(()).files;
81 eprintln!("files = {:?}", files);
82 files.contains(&file_id) 81 files.contains(&file_id)
83 } 82 }
84 fn lines(&self, file_id: FileId) -> Arc<LineIndex> { 83 fn lines(&self, file_id: FileId) -> Arc<LineIndex> {
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs
index 755640fb4..2d3679fa9 100644
--- a/crates/ra_analysis/tests/tests.rs
+++ b/crates/ra_analysis/tests/tests.rs
@@ -238,4 +238,4 @@ fn bar() {
238 assert_eq!(desc.params, vec!["&self".to_string(), "x".to_string()]); 238 assert_eq!(desc.params, vec!["&self".to_string(), "x".to_string()]);
239 assert_eq!(desc.ret_type, None); 239 assert_eq!(desc.ret_type, None);
240 assert_eq!(param, Some(1)); 240 assert_eq!(param, Some(1));
241} \ No newline at end of file 241}