aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
authorWilco Kusee <[email protected]>2019-11-29 14:14:42 +0000
committerWilco Kusee <[email protected]>2019-11-29 14:14:53 +0000
commit9c764cb966cd62d8eaa83fbb7d91646a850dc256 (patch)
tree46f572272a2567f90c5b8e004bb75998df155bd2 /crates/ra_lsp_server/src
parent8b278b1ab660df0728508e45e88ac769a2e03a58 (diff)
Only allow renames to valid identifiers
Diffstat (limited to 'crates/ra_lsp_server/src')
-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),