mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Move identifier check to analysis
This commit is contained in:
parent
f081c9d94d
commit
be9ba2b392
2 changed files with 9 additions and 12 deletions
|
@ -56,7 +56,7 @@ use ra_db::{
|
|||
salsa::{self, ParallelDatabase},
|
||||
CheckCanceled, Env, FileLoader, SourceDatabase,
|
||||
};
|
||||
use ra_syntax::{SourceFile, TextRange, TextUnit};
|
||||
use ra_syntax::{tokenize, SourceFile, SyntaxKind, TextRange, TextUnit};
|
||||
|
||||
use crate::{db::LineIndexDatabase, display::ToNav, symbol_index::FileSymbol};
|
||||
|
||||
|
@ -470,6 +470,13 @@ impl Analysis {
|
|||
position: FilePosition,
|
||||
new_name: &str,
|
||||
) -> Cancelable<Option<RangeInfo<SourceChange>>> {
|
||||
let tokens = tokenize(new_name);
|
||||
if tokens.len() != 1
|
||||
|| (tokens[0].kind != SyntaxKind::IDENT && tokens[0].kind != SyntaxKind::UNDERSCORE)
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
self.with_db(|db| references::rename(db, position, new_name))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue