aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/world.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src/world.rs')
-rw-r--r--crates/ra_lsp_server/src/world.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs
index f9ce570ca..7822e1c1c 100644
--- a/crates/ra_lsp_server/src/world.rs
+++ b/crates/ra_lsp_server/src/world.rs
@@ -11,7 +11,6 @@ use ra_ide_api::{
11use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot}; 11use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot};
12use relative_path::RelativePathBuf; 12use relative_path::RelativePathBuf;
13use parking_lot::RwLock; 13use parking_lot::RwLock;
14use failure::{Error, format_err};
15use gen_lsp_server::ErrorCode; 14use gen_lsp_server::ErrorCode;
16 15
17use crate::{ 16use crate::{
@@ -169,13 +168,13 @@ impl WorldSnapshot {
169 } 168 }
170 169
171 pub fn uri_to_file_id(&self, uri: &Url) -> Result<FileId> { 170 pub fn uri_to_file_id(&self, uri: &Url) -> Result<FileId> {
172 let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?; 171 let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?;
173 let file = self.vfs.read().path2file(&path).ok_or_else(|| { 172 let file = self.vfs.read().path2file(&path).ok_or_else(|| {
174 // Show warning as this file is outside current workspace 173 // Show warning as this file is outside current workspace
175 Error::from(LspError { 174 LspError {
176 code: ErrorCode::InvalidRequest as i32, 175 code: ErrorCode::InvalidRequest as i32,
177 message: "Rust file outside current workspace is not supported yet.".to_string(), 176 message: "Rust file outside current workspace is not supported yet.".to_string(),
178 }) 177 }
179 })?; 178 })?;
180 Ok(FileId(file.0)) 179 Ok(FileId(file.0))
181 } 180 }
@@ -183,7 +182,7 @@ impl WorldSnapshot {
183 pub fn file_id_to_uri(&self, id: FileId) -> Result<Url> { 182 pub fn file_id_to_uri(&self, id: FileId) -> Result<Url> {
184 let path = self.vfs.read().file2path(VfsFile(id.0)); 183 let path = self.vfs.read().file2path(VfsFile(id.0));
185 let url = Url::from_file_path(&path) 184 let url = Url::from_file_path(&path)
186 .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; 185 .map_err(|_| format!("can't convert path to url: {}", path.display()))?;
187 Ok(url) 186 Ok(url)
188 } 187 }
189 188
@@ -191,7 +190,7 @@ impl WorldSnapshot {
191 let base = self.vfs.read().root2path(VfsRoot(root.0)); 190 let base = self.vfs.read().root2path(VfsRoot(root.0));
192 let path = path.to_path(base); 191 let path = path.to_path(base);
193 let url = Url::from_file_path(&path) 192 let url = Url::from_file_path(&path)
194 .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; 193 .map_err(|_| format!("can't convert path to url: {}", path.display()))?;
195 Ok(url) 194 Ok(url)
196 } 195 }
197 196