aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/handlers.rs
diff options
context:
space:
mode:
authorJeremy A. Kolb <[email protected]>2018-10-22 18:49:27 +0100
committerJeremy A. Kolb <[email protected]>2018-10-22 18:49:27 +0100
commit6453b29cb571d5c54bac427842ba8a9dd6874861 (patch)
treec74fa43dddae877964522452f923a5f46f7c8525 /crates/ra_lsp_server/src/main_loop/handlers.rs
parent5a64b9a811554473e65db7e7ae515079ca48c70b (diff)
Add LspError to explicity return errors from LSP handlers
Fixes #145
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index f5dff4c80..baf82f3fc 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -7,6 +7,7 @@ use languageserver_types::{
7 InsertTextFormat, Location, Position, SymbolInformation, TextDocumentIdentifier, TextEdit, 7 InsertTextFormat, Location, Position, SymbolInformation, TextDocumentIdentifier, TextEdit,
8 RenameParams, WorkspaceEdit, PrepareRenameResponse 8 RenameParams, WorkspaceEdit, PrepareRenameResponse
9}; 9};
10use gen_lsp_server::ErrorCode;
10use ra_analysis::{FileId, FoldKind, Query, RunnableKind}; 11use ra_analysis::{FileId, FoldKind, Query, RunnableKind};
11use ra_syntax::text_utils::contains_offset_nonstrict; 12use ra_syntax::text_utils::contains_offset_nonstrict;
12use serde_json::to_value; 13use serde_json::to_value;
@@ -16,7 +17,7 @@ use crate::{
16 project_model::TargetKind, 17 project_model::TargetKind,
17 req::{self, Decoration}, 18 req::{self, Decoration},
18 server_world::ServerWorld, 19 server_world::ServerWorld,
19 Result, 20 Result, LspError
20}; 21};
21 22
22pub fn handle_syntax_tree( 23pub fn handle_syntax_tree(
@@ -476,7 +477,7 @@ pub fn handle_rename(
476 let offset = params.position.conv_with(&line_index); 477 let offset = params.position.conv_with(&line_index);
477 478
478 if params.new_name.is_empty() { 479 if params.new_name.is_empty() {
479 return Ok(None); 480 return Err(LspError::new(ErrorCode::InvalidParams as i32, "New Name cannot be empty".into()).into());
480 } 481 }
481 482
482 let refs = world.analysis().find_all_refs(file_id, offset)?; 483 let refs = world.analysis().find_all_refs(file_id, offset)?;