aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index c81fa7f67..137f26302 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -13,7 +13,7 @@ use ra_ide::{
13 AssistId, FileId, FilePosition, FileRange, Query, Runnable, RunnableKind, SearchScope, 13 AssistId, FileId, FilePosition, FileRange, Query, Runnable, RunnableKind, SearchScope,
14}; 14};
15use ra_prof::profile; 15use ra_prof::profile;
16use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; 16use ra_syntax::{tokenize, AstNode, SyntaxKind, TextRange, TextUnit};
17use rustc_hash::FxHashMap; 17use rustc_hash::FxHashMap;
18use serde::{Deserialize, Serialize}; 18use serde::{Deserialize, Serialize};
19use serde_json::to_value; 19use serde_json::to_value;
@@ -506,6 +506,12 @@ pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result<Optio
506 .into()); 506 .into());
507 } 507 }
508 508
509 // Only rename to valid identifiers
510 let tokens = tokenize(&params.new_name);
511 if tokens.len() != 1 || tokens[0].kind != SyntaxKind::IDENT {
512 return Ok(None);
513 }
514
509 let optional_change = world.analysis().rename(position, &*params.new_name)?; 515 let optional_change = world.analysis().rename(position, &*params.new_name)?;
510 let change = match optional_change { 516 let change = match optional_change {
511 None => return Ok(None), 517 None => return Ok(None),