diff options
author | Aleksey Kladov <[email protected]> | 2018-12-21 09:18:14 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-21 09:18:14 +0000 |
commit | b5b44659a42cf982590519317ede9ead354f9c4e (patch) | |
tree | 460d82184faa07256e77cf8b353e135f2b935d1e /crates/ra_lsp_server/src/server_world.rs | |
parent | 0063f03e86f4222a5027720142eb20db4adc485d (diff) |
edits use source-root API
Diffstat (limited to 'crates/ra_lsp_server/src/server_world.rs')
-rw-r--r-- | crates/ra_lsp_server/src/server_world.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index 785877c4b..73cccc9dd 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs | |||
@@ -8,7 +8,7 @@ use ra_analysis::{ | |||
8 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, | 8 | Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, |
9 | SourceRootId | 9 | SourceRootId |
10 | }; | 10 | }; |
11 | use ra_vfs::{Vfs, VfsChange, VfsFile}; | 11 | use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot}; |
12 | use rustc_hash::FxHashMap; | 12 | use rustc_hash::FxHashMap; |
13 | use relative_path::RelativePathBuf; | 13 | use relative_path::RelativePathBuf; |
14 | use parking_lot::RwLock; | 14 | use parking_lot::RwLock; |
@@ -183,4 +183,12 @@ impl ServerWorld { | |||
183 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; | 183 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; |
184 | Ok(url) | 184 | Ok(url) |
185 | } | 185 | } |
186 | |||
187 | pub fn path_to_uri(&self, root: SourceRootId, path: &RelativePathBuf) -> Result<Url> { | ||
188 | let base = self.vfs.read().root2path(VfsRoot(root.0)); | ||
189 | let path = path.to_path(base); | ||
190 | let url = Url::from_file_path(&path) | ||
191 | .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; | ||
192 | Ok(url) | ||
193 | } | ||
186 | } | 194 | } |