aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/lib.rs9
-rw-r--r--crates/ra_ide/src/references/rename.rs9
2 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 1f88791d7..d1bff4a76 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -56,7 +56,7 @@ use ra_db::{
56 salsa::{self, ParallelDatabase}, 56 salsa::{self, ParallelDatabase},
57 CheckCanceled, Env, FileLoader, SourceDatabase, 57 CheckCanceled, Env, FileLoader, SourceDatabase,
58}; 58};
59use ra_syntax::{tokenize, SourceFile, SyntaxKind, TextRange, TextUnit}; 59use ra_syntax::{SourceFile, TextRange, TextUnit};
60 60
61use crate::{db::LineIndexDatabase, display::ToNav, symbol_index::FileSymbol}; 61use crate::{db::LineIndexDatabase, display::ToNav, symbol_index::FileSymbol};
62 62
@@ -470,13 +470,6 @@ impl Analysis {
470 position: FilePosition, 470 position: FilePosition,
471 new_name: &str, 471 new_name: &str,
472 ) -> Cancelable<Option<RangeInfo<SourceChange>>> { 472 ) -> Cancelable<Option<RangeInfo<SourceChange>>> {
473 let tokens = tokenize(new_name);
474 if tokens.len() != 1
475 || (tokens[0].kind != SyntaxKind::IDENT && tokens[0].kind != SyntaxKind::UNDERSCORE)
476 {
477 return Ok(None);
478 }
479
480 self.with_db(|db| references::rename(db, position, new_name)) 473 self.with_db(|db| references::rename(db, position, new_name))
481 } 474 }
482 475
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index c1771edf8..b804d5f6d 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -2,7 +2,7 @@
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, AstNode, SyntaxNode}; 5use ra_syntax::{algo::find_node_at_offset, ast, tokenize, AstNode, SyntaxKind, SyntaxNode};
6use ra_text_edit::TextEdit; 6use ra_text_edit::TextEdit;
7 7
8use crate::{ 8use crate::{
@@ -17,6 +17,13 @@ pub(crate) fn rename(
17 position: FilePosition, 17 position: FilePosition,
18 new_name: &str, 18 new_name: &str,
19) -> Option<RangeInfo<SourceChange>> { 19) -> Option<RangeInfo<SourceChange>> {
20 let tokens = tokenize(new_name);
21 if tokens.len() != 1
22 || (tokens[0].kind != SyntaxKind::IDENT && tokens[0].kind != SyntaxKind::UNDERSCORE)
23 {
24 return None;
25 }
26
20 let parse = db.parse(position.file_id); 27 let parse = db.parse(position.file_id);
21 if let Some((ast_name, ast_module)) = 28 if let Some((ast_name, ast_module)) =
22 find_name_and_module_at_offset(parse.tree().syntax(), position) 29 find_name_and_module_at_offset(parse.tree().syntax(), position)