diff options
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/imports_locator.rs | 9 | ||||
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 16 | ||||
-rw-r--r-- | crates/ra_ide/src/references/rename.rs | 12 |
3 files changed, 17 insertions, 20 deletions
diff --git a/crates/ra_ide/src/imports_locator.rs b/crates/ra_ide/src/imports_locator.rs index 48b014c7d..9e1a1c1ec 100644 --- a/crates/ra_ide/src/imports_locator.rs +++ b/crates/ra_ide/src/imports_locator.rs | |||
@@ -64,12 +64,9 @@ impl ImportsLocator for ImportsLocatorIde<'_> { | |||
64 | .into_iter() | 64 | .into_iter() |
65 | .chain(lib_results.into_iter()) | 65 | .chain(lib_results.into_iter()) |
66 | .filter_map(|import_candidate| self.get_name_definition(db, &import_candidate)) | 66 | .filter_map(|import_candidate| self.get_name_definition(db, &import_candidate)) |
67 | .filter_map(|name_definition_to_import| { | 67 | .filter_map(|name_definition_to_import| match name_definition_to_import.kind { |
68 | if let NameKind::Def(module_def) = name_definition_to_import.kind { | 68 | NameKind::Def(module_def) => Some(module_def), |
69 | Some(module_def) | 69 | _ => None, |
70 | } else { | ||
71 | None | ||
72 | } | ||
73 | }) | 70 | }) |
74 | .collect() | 71 | .collect() |
75 | } | 72 | } |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 393ca9447..de447a5aa 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -376,7 +376,7 @@ fn main() { | |||
376 | let mut start = 0; | 376 | let mut start = 0; |
377 | (0..2).for_each(|increment| { | 377 | (0..2).for_each(|increment| { |
378 | start += increment; | 378 | start += increment; |
379 | }) | 379 | }); |
380 | 380 | ||
381 | let multiply = |a, b, c, d| a * b * c * d; | 381 | let multiply = |a, b, c, d| a * b * c * d; |
382 | let _: i32 = multiply(1, 2, 3, 4); | 382 | let _: i32 = multiply(1, 2, 3, 4); |
@@ -399,37 +399,37 @@ fn main() { | |||
399 | label: "i32", | 399 | label: "i32", |
400 | }, | 400 | }, |
401 | InlayHint { | 401 | InlayHint { |
402 | range: [114; 122), | 402 | range: [115; 123), |
403 | kind: TypeHint, | 403 | kind: TypeHint, |
404 | label: "|…| -> i32", | 404 | label: "|…| -> i32", |
405 | }, | 405 | }, |
406 | InlayHint { | 406 | InlayHint { |
407 | range: [126; 127), | 407 | range: [127; 128), |
408 | kind: TypeHint, | 408 | kind: TypeHint, |
409 | label: "i32", | 409 | label: "i32", |
410 | }, | 410 | }, |
411 | InlayHint { | 411 | InlayHint { |
412 | range: [129; 130), | 412 | range: [130; 131), |
413 | kind: TypeHint, | 413 | kind: TypeHint, |
414 | label: "i32", | 414 | label: "i32", |
415 | }, | 415 | }, |
416 | InlayHint { | 416 | InlayHint { |
417 | range: [132; 133), | 417 | range: [133; 134), |
418 | kind: TypeHint, | 418 | kind: TypeHint, |
419 | label: "i32", | 419 | label: "i32", |
420 | }, | 420 | }, |
421 | InlayHint { | 421 | InlayHint { |
422 | range: [135; 136), | 422 | range: [136; 137), |
423 | kind: TypeHint, | 423 | kind: TypeHint, |
424 | label: "i32", | 424 | label: "i32", |
425 | }, | 425 | }, |
426 | InlayHint { | 426 | InlayHint { |
427 | range: [200; 212), | 427 | range: [201; 213), |
428 | kind: TypeHint, | 428 | kind: TypeHint, |
429 | label: "&|…| -> i32", | 429 | label: "&|…| -> i32", |
430 | }, | 430 | }, |
431 | InlayHint { | 431 | InlayHint { |
432 | range: [235; 244), | 432 | range: [236; 245), |
433 | kind: TypeHint, | 433 | kind: TypeHint, |
434 | label: "|| -> i32", | 434 | label: "|| -> i32", |
435 | }, | 435 | }, |
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 | ||
3 | use hir::ModuleSource; | 3 | use hir::ModuleSource; |
4 | use ra_db::{RelativePath, RelativePathBuf, SourceDatabase, SourceDatabaseExt}; | 4 | use ra_db::{RelativePath, RelativePathBuf, SourceDatabase, SourceDatabaseExt}; |
5 | use ra_syntax::{algo::find_node_at_offset, ast, tokenize, AstNode, SyntaxKind, SyntaxNode}; | 5 | use ra_syntax::{ |
6 | algo::find_node_at_offset, ast, lex_single_valid_syntax_kind, AstNode, SyntaxKind, SyntaxNode, | ||
7 | }; | ||
6 | use ra_text_edit::TextEdit; | 8 | use ra_text_edit::TextEdit; |
7 | 9 | ||
8 | use crate::{ | 10 | use 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); |