From 6453b29cb571d5c54bac427842ba8a9dd6874861 Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Mon, 22 Oct 2018 13:49:27 -0400 Subject: Add LspError to explicity return errors from LSP handlers Fixes #145 --- crates/ra_lsp_server/src/main_loop/handlers.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs') 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::{ InsertTextFormat, Location, Position, SymbolInformation, TextDocumentIdentifier, TextEdit, RenameParams, WorkspaceEdit, PrepareRenameResponse }; +use gen_lsp_server::ErrorCode; use ra_analysis::{FileId, FoldKind, Query, RunnableKind}; use ra_syntax::text_utils::contains_offset_nonstrict; use serde_json::to_value; @@ -16,7 +17,7 @@ use crate::{ project_model::TargetKind, req::{self, Decoration}, server_world::ServerWorld, - Result, + Result, LspError }; pub fn handle_syntax_tree( @@ -476,7 +477,7 @@ pub fn handle_rename( let offset = params.position.conv_with(&line_index); if params.new_name.is_empty() { - return Ok(None); + return Err(LspError::new(ErrorCode::InvalidParams as i32, "New Name cannot be empty".into()).into()); } let refs = world.analysis().find_all_refs(file_id, offset)?; -- cgit v1.2.3