aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-07 11:48:49 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-07 11:48:49 +0100
commit36f5d997565b6390a4b524e7e1d0d805f0f26bdb (patch)
treefb7f6a34b39aee1cda26a0180f09b7fbe1dd5b33 /crates/ra_lsp_server
parent990e74ba7c77485f914434ac6f09a40d1364634d (diff)
parentce3d78335d5db2643e05caf91041f9e92577ecc3 (diff)
Merge #1119
1119: Add warning when open file outside workspace r=matklad a=edwin0cheng When file is not found in `ra_vfs` but exist, use `LspError` for warning instead of `error_fmt` to bail out error, Temporarily fix #967 . edit: typo Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server')
-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