aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/server_world.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs
index af4798494..4b1d592bb 100644
--- a/crates/ra_lsp_server/src/server_world.rs
+++ b/crates/ra_lsp_server/src/server_world.rs
@@ -11,12 +11,14 @@ 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::format_err; 14use failure::{Error, format_err};
15use gen_lsp_server::ErrorCode;
15 16
16use crate::{ 17use crate::{
17 project_model::ProjectWorkspace, 18 project_model::ProjectWorkspace,
18 vfs_filter::IncludeRustFiles, 19 vfs_filter::IncludeRustFiles,
19 Result, 20 Result,
21 LspError,
20}; 22};
21 23
22#[derive(Debug)] 24#[derive(Debug)]
@@ -152,11 +154,13 @@ impl ServerWorld {
152 154
153 pub fn uri_to_file_id(&self, uri: &Url) -> Result<FileId> { 155 pub fn uri_to_file_id(&self, uri: &Url) -> Result<FileId> {
154 let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?; 156 let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?;
155 let file = self 157 let file = self.vfs.read().path2file(&path).ok_or_else(|| {
156 .vfs 158 // Show warning as this file is outside current workspace
157 .read() 159 Error::from(LspError {
158 .path2file(&path) 160 code: ErrorCode::InvalidRequest as i32,
159 .ok_or_else(|| format_err!("unknown file: {}", path.display()))?; 161 message: "Rust file outside current workspace is not supported yet.".to_string(),
162 })
163 })?;
160 Ok(FileId(file.0.into())) 164 Ok(FileId(file.0.into()))
161 } 165 }
162 166