diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-19 12:15:55 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-19 12:15:55 +0100 |
commit | f209843e31af7f0e0212aa28ffec2efad2a70c6f (patch) | |
tree | 548227da78a3bea644f57714d075410c0bdf7469 /crates/ra_ide_api/src/name_ref_kind.rs | |
parent | 58d4983ba5745975446d60f2886d96f8d2adf0f2 (diff) | |
parent | d4a66166c002f0a49e41d856a49cb5685ac93202 (diff) |
Merge #1545
1545: migrate ra_syntax to the new rowan API r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/name_ref_kind.rs')
-rw-r--r-- | crates/ra_ide_api/src/name_ref_kind.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_ide_api/src/name_ref_kind.rs b/crates/ra_ide_api/src/name_ref_kind.rs index 67381c9c8..6832acf5d 100644 --- a/crates/ra_ide_api/src/name_ref_kind.rs +++ b/crates/ra_ide_api/src/name_ref_kind.rs | |||
@@ -26,7 +26,7 @@ pub(crate) fn classify_name_ref( | |||
26 | // Check if it is a method | 26 | // Check if it is a method |
27 | if let Some(method_call) = name_ref.syntax().parent().and_then(ast::MethodCallExpr::cast) { | 27 | if let Some(method_call) = name_ref.syntax().parent().and_then(ast::MethodCallExpr::cast) { |
28 | tested_by!(goto_definition_works_for_methods); | 28 | tested_by!(goto_definition_works_for_methods); |
29 | if let Some(func) = analyzer.resolve_method_call(method_call) { | 29 | if let Some(func) = analyzer.resolve_method_call(&method_call) { |
30 | return Some(Method(func)); | 30 | return Some(Method(func)); |
31 | } | 31 | } |
32 | } | 32 | } |
@@ -40,7 +40,7 @@ pub(crate) fn classify_name_ref( | |||
40 | .and_then(ast::MacroCall::cast) | 40 | .and_then(ast::MacroCall::cast) |
41 | { | 41 | { |
42 | tested_by!(goto_definition_works_for_macros); | 42 | tested_by!(goto_definition_works_for_macros); |
43 | if let Some(mac) = analyzer.resolve_macro_call(db, macro_call) { | 43 | if let Some(mac) = analyzer.resolve_macro_call(db, ¯o_call) { |
44 | return Some(Macro(mac)); | 44 | return Some(Macro(mac)); |
45 | } | 45 | } |
46 | } | 46 | } |
@@ -48,7 +48,7 @@ pub(crate) fn classify_name_ref( | |||
48 | // It could also be a field access | 48 | // It could also be a field access |
49 | if let Some(field_expr) = name_ref.syntax().parent().and_then(ast::FieldExpr::cast) { | 49 | if let Some(field_expr) = name_ref.syntax().parent().and_then(ast::FieldExpr::cast) { |
50 | tested_by!(goto_definition_works_for_fields); | 50 | tested_by!(goto_definition_works_for_fields); |
51 | if let Some(field) = analyzer.resolve_field(field_expr) { | 51 | if let Some(field) = analyzer.resolve_field(&field_expr) { |
52 | return Some(FieldAccess(field)); | 52 | return Some(FieldAccess(field)); |
53 | }; | 53 | }; |
54 | } | 54 | } |
@@ -59,7 +59,7 @@ pub(crate) fn classify_name_ref( | |||
59 | 59 | ||
60 | let struct_lit = field_expr.syntax().ancestors().find_map(ast::StructLit::cast); | 60 | let struct_lit = field_expr.syntax().ancestors().find_map(ast::StructLit::cast); |
61 | 61 | ||
62 | if let Some(ty) = struct_lit.and_then(|lit| analyzer.type_of(db, lit.into())) { | 62 | if let Some(ty) = struct_lit.and_then(|lit| analyzer.type_of(db, &lit.into())) { |
63 | if let Some((hir::AdtDef::Struct(s), _)) = ty.as_adt() { | 63 | if let Some((hir::AdtDef::Struct(s), _)) = ty.as_adt() { |
64 | let hir_path = hir::Path::from_name_ref(name_ref); | 64 | let hir_path = hir::Path::from_name_ref(name_ref); |
65 | let hir_name = hir_path.as_ident().unwrap(); | 65 | let hir_name = hir_path.as_ident().unwrap(); |
@@ -73,7 +73,7 @@ pub(crate) fn classify_name_ref( | |||
73 | 73 | ||
74 | // General case, a path or a local: | 74 | // General case, a path or a local: |
75 | if let Some(path) = name_ref.syntax().ancestors().find_map(ast::Path::cast) { | 75 | if let Some(path) = name_ref.syntax().ancestors().find_map(ast::Path::cast) { |
76 | if let Some(resolved) = analyzer.resolve_path(db, path) { | 76 | if let Some(resolved) = analyzer.resolve_path(db, &path) { |
77 | return match resolved { | 77 | return match resolved { |
78 | hir::PathResolution::Def(def) => Some(Def(def)), | 78 | hir::PathResolution::Def(def) => Some(Def(def)), |
79 | hir::PathResolution::LocalBinding(Either::A(pat)) => Some(Pat(pat)), | 79 | hir::PathResolution::LocalBinding(Either::A(pat)) => Some(Pat(pat)), |