aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/references/rename.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/references/rename.rs')
-rw-r--r--crates/ra_ide/src/references/rename.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index 626efb603..9a84c1c88 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -2,7 +2,9 @@
2 2
3use hir::ModuleSource; 3use hir::ModuleSource;
4use ra_db::{RelativePath, RelativePathBuf, SourceDatabase, SourceDatabaseExt}; 4use ra_db::{RelativePath, RelativePathBuf, SourceDatabase, SourceDatabaseExt};
5use ra_syntax::{algo::find_node_at_offset, ast, tokenize, AstNode, SyntaxKind, SyntaxNode}; 5use ra_syntax::{
6 algo::find_node_at_offset, ast, lex_single_valid_syntax_kind, AstNode, SyntaxKind, SyntaxNode,
7};
6use ra_text_edit::TextEdit; 8use ra_text_edit::TextEdit;
7 9
8use crate::{ 10use crate::{
@@ -17,11 +19,9 @@ pub(crate) fn rename(
17 position: FilePosition, 19 position: FilePosition,
18 new_name: &str, 20 new_name: &str,
19) -> Option<RangeInfo<SourceChange>> { 21) -> Option<RangeInfo<SourceChange>> {
20 let tokens = tokenize(new_name); 22 match lex_single_valid_syntax_kind(new_name)? {
21 if tokens.len() != 1 23 SyntaxKind::IDENT | SyntaxKind::UNDERSCORE => (),
22 || (tokens[0].kind != SyntaxKind::IDENT && tokens[0].kind != SyntaxKind::UNDERSCORE) 24 _ => return None,
23 {
24 return None;
25 } 25 }
26 26
27 let parse = db.parse(position.file_id); 27 let parse = db.parse(position.file_id);