mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
Remove checking file exists
This commit is contained in:
parent
e92740c28b
commit
ce3d78335d
1 changed files with 6 additions and 13 deletions
|
@ -11,7 +11,7 @@ use ra_ide_api::{
|
||||||
use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot};
|
use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot};
|
||||||
use relative_path::RelativePathBuf;
|
use relative_path::RelativePathBuf;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use failure::format_err;
|
use failure::{Error, format_err};
|
||||||
use gen_lsp_server::ErrorCode;
|
use gen_lsp_server::ErrorCode;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -155,18 +155,11 @@ impl ServerWorld {
|
||||||
pub fn uri_to_file_id(&self, uri: &Url) -> Result<FileId> {
|
pub fn uri_to_file_id(&self, uri: &Url) -> Result<FileId> {
|
||||||
let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?;
|
let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?;
|
||||||
let file = self.vfs.read().path2file(&path).ok_or_else(|| {
|
let file = self.vfs.read().path2file(&path).ok_or_else(|| {
|
||||||
// Check whether give path is exists,
|
// Show warning as this file is outside current workspace
|
||||||
// if so, maybe this file is outside out current workspace
|
Error::from(LspError {
|
||||||
if path.exists() {
|
code: ErrorCode::InvalidRequest as i32,
|
||||||
LspError {
|
message: "Rust file outside current workspace is not supported yet.".to_string(),
|
||||||
code: ErrorCode::InvalidRequest as i32,
|
})
|
||||||
message: "Rust file outside current workspace is not supported yet."
|
|
||||||
.to_string(),
|
|
||||||
}
|
|
||||||
.into()
|
|
||||||
} else {
|
|
||||||
format_err!("unknown file: {}", path.display())
|
|
||||||
}
|
|
||||||
})?;
|
})?;
|
||||||
Ok(FileId(file.0.into()))
|
Ok(FileId(file.0.into()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue