diff options
Diffstat (limited to 'crates/ide_db')
-rw-r--r-- | crates/ide_db/src/search.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index a24335240..a3e765d05 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs | |||
@@ -30,6 +30,7 @@ pub enum ReferenceKind { | |||
30 | FieldShorthandForField, | 30 | FieldShorthandForField, |
31 | FieldShorthandForLocal, | 31 | FieldShorthandForLocal, |
32 | StructLiteral, | 32 | StructLiteral, |
33 | RecordFieldExprOrPat, | ||
33 | Other, | 34 | Other, |
34 | } | 35 | } |
35 | 36 | ||
@@ -278,8 +279,9 @@ impl<'a> FindUsages<'a> { | |||
278 | ) -> bool { | 279 | ) -> bool { |
279 | match NameRefClass::classify(self.sema, &name_ref) { | 280 | match NameRefClass::classify(self.sema, &name_ref) { |
280 | Some(NameRefClass::Definition(def)) if &def == self.def => { | 281 | Some(NameRefClass::Definition(def)) if &def == self.def => { |
281 | let kind = if is_record_lit_name_ref(&name_ref) || is_call_expr_name_ref(&name_ref) | 282 | let kind = if is_record_field_expr_or_pat(&name_ref) { |
282 | { | 283 | ReferenceKind::RecordFieldExprOrPat |
284 | } else if is_record_lit_name_ref(&name_ref) || is_call_expr_name_ref(&name_ref) { | ||
283 | ReferenceKind::StructLiteral | 285 | ReferenceKind::StructLiteral |
284 | } else { | 286 | } else { |
285 | ReferenceKind::Other | 287 | ReferenceKind::Other |
@@ -385,3 +387,17 @@ fn is_record_lit_name_ref(name_ref: &ast::NameRef) -> bool { | |||
385 | .map(|p| p.name_ref().as_ref() == Some(name_ref)) | 387 | .map(|p| p.name_ref().as_ref() == Some(name_ref)) |
386 | .unwrap_or(false) | 388 | .unwrap_or(false) |
387 | } | 389 | } |
390 | |||
391 | fn is_record_field_expr_or_pat(name_ref: &ast::NameRef) -> bool { | ||
392 | if let Some(parent) = name_ref.syntax().parent() { | ||
393 | match_ast! { | ||
394 | match parent { | ||
395 | ast::RecordExprField(it) => true, | ||
396 | ast::RecordPatField(_it) => true, | ||
397 | _ => false, | ||
398 | } | ||
399 | } | ||
400 | } else { | ||
401 | false | ||
402 | } | ||
403 | } | ||