diff options
author | Zac Pullar-Strecker <[email protected]> | 2020-07-31 03:12:44 +0100 |
---|---|---|
committer | Zac Pullar-Strecker <[email protected]> | 2020-07-31 03:12:44 +0100 |
commit | f05d7b41a719d848844b054a16477b29d0f063c6 (patch) | |
tree | 0a8a0946e8aef2ce64d4c13d0035ba41cce2daf3 /crates/ra_db/src/lib.rs | |
parent | 73ff610e41959e3e7c78a2b4b25b086883132956 (diff) | |
parent | 6b7cb8b5ab539fc4333ce34bc29bf77c976f232a (diff) |
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Hasn't fixed tests yet.
Diffstat (limited to 'crates/ra_db/src/lib.rs')
-rw-r--r-- | crates/ra_db/src/lib.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 4a3ba57da..f25be24fe 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -16,9 +16,8 @@ pub use crate::{ | |||
16 | SourceRoot, SourceRootId, | 16 | SourceRoot, SourceRootId, |
17 | }, | 17 | }, |
18 | }; | 18 | }; |
19 | pub use relative_path::{RelativePath, RelativePathBuf}; | ||
20 | pub use salsa; | 19 | pub use salsa; |
21 | pub use vfs::{file_set::FileSet, AbsPathBuf, VfsPath}; | 20 | pub use vfs::{file_set::FileSet, VfsPath}; |
22 | 21 | ||
23 | #[macro_export] | 22 | #[macro_export] |
24 | macro_rules! impl_intern_key { | 23 | macro_rules! impl_intern_key { |
@@ -80,7 +79,7 @@ pub struct FilePosition { | |||
80 | pub offset: TextSize, | 79 | pub offset: TextSize, |
81 | } | 80 | } |
82 | 81 | ||
83 | #[derive(Clone, Copy, Debug)] | 82 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] |
84 | pub struct FileRange { | 83 | pub struct FileRange { |
85 | pub file_id: FileId, | 84 | pub file_id: FileId, |
86 | pub range: TextRange, | 85 | pub range: TextRange, |
@@ -93,9 +92,9 @@ pub trait FileLoader { | |||
93 | fn file_text(&self, file_id: FileId) -> Arc<String>; | 92 | fn file_text(&self, file_id: FileId) -> Arc<String>; |
94 | /// Note that we intentionally accept a `&str` and not a `&Path` here. This | 93 | /// Note that we intentionally accept a `&str` and not a `&Path` here. This |
95 | /// method exists to handle `#[path = "/some/path.rs"] mod foo;` and such, | 94 | /// method exists to handle `#[path = "/some/path.rs"] mod foo;` and such, |
96 | /// so the input is guaranteed to be utf-8 string. We might introduce | 95 | /// so the input is guaranteed to be utf-8 string. One might be tempted to |
97 | /// `struct StrPath(str)` for clarity some day, but it's a bit messy, so we | 96 | /// introduce some kind of "utf-8 path with / separators", but that's a bad idea. Behold |
98 | /// get by with a `&str` for the time being. | 97 | /// `#[path = "C://no/way"]` |
99 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId>; | 98 | fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId>; |
100 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>; | 99 | fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>>; |
101 | } | 100 | } |
@@ -113,7 +112,7 @@ pub trait SourceDatabase: CheckCanceled + FileLoader + std::fmt::Debug { | |||
113 | fn crate_graph(&self) -> Arc<CrateGraph>; | 112 | fn crate_graph(&self) -> Arc<CrateGraph>; |
114 | } | 113 | } |
115 | 114 | ||
116 | fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> { | 115 | fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> { |
117 | let _p = profile("parse_query").detail(|| format!("{:?}", file_id)); | 116 | let _p = profile("parse_query").detail(|| format!("{:?}", file_id)); |
118 | let text = db.file_text(file_id); | 117 | let text = db.file_text(file_id); |
119 | SourceFile::parse(&*text) | 118 | SourceFile::parse(&*text) |
@@ -136,10 +135,7 @@ pub trait SourceDatabaseExt: SourceDatabase { | |||
136 | fn source_root_crates(&self, id: SourceRootId) -> Arc<FxHashSet<CrateId>>; | 135 | fn source_root_crates(&self, id: SourceRootId) -> Arc<FxHashSet<CrateId>>; |
137 | } | 136 | } |
138 | 137 | ||
139 | fn source_root_crates( | 138 | fn source_root_crates(db: &dyn SourceDatabaseExt, id: SourceRootId) -> Arc<FxHashSet<CrateId>> { |
140 | db: &(impl SourceDatabaseExt + SourceDatabase), | ||
141 | id: SourceRootId, | ||
142 | ) -> Arc<FxHashSet<CrateId>> { | ||
143 | let graph = db.crate_graph(); | 139 | let graph = db.crate_graph(); |
144 | let res = graph | 140 | let res = graph |
145 | .iter() | 141 | .iter() |