diff options
author | Aleksey Kladov <[email protected]> | 2019-11-24 17:06:55 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-24 17:06:55 +0000 |
commit | 63e3ea38d3ff7ab69b968e8962f33e82a4f978fb (patch) | |
tree | 8f4d416bad74f75e43924981b1d2c2099ea50edc /crates/ra_ide_api/src/references/classify.rs | |
parent | ac9ba5eb32073c16608acaa04324e7dc46d303d6 (diff) |
Don't redo field resolution in the IDE
Diffstat (limited to 'crates/ra_ide_api/src/references/classify.rs')
-rw-r--r-- | crates/ra_ide_api/src/references/classify.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/references/classify.rs b/crates/ra_ide_api/src/references/classify.rs index 4a4b030f8..cab06dea9 100644 --- a/crates/ra_ide_api/src/references/classify.rs +++ b/crates/ra_ide_api/src/references/classify.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | //! Functions that are used to classify an element from its definition or reference. | 1 | //! Functions that are used to classify an element from its definition or reference. |
2 | 2 | ||
3 | use hir::{FromSource, Module, ModuleSource, Path, PathResolution, Source, SourceAnalyzer}; | 3 | use hir::{FromSource, Module, ModuleSource, PathResolution, Source, SourceAnalyzer}; |
4 | use ra_prof::profile; | 4 | use ra_prof::profile; |
5 | use ra_syntax::{ast, match_ast, AstNode}; | 5 | use ra_syntax::{ast, match_ast, AstNode}; |
6 | use test_utils::tested_by; | 6 | use test_utils::tested_by; |
@@ -140,12 +140,8 @@ pub(crate) fn classify_name_ref( | |||
140 | 140 | ||
141 | if let Some(record_field) = ast::RecordField::cast(parent.clone()) { | 141 | if let Some(record_field) = ast::RecordField::cast(parent.clone()) { |
142 | tested_by!(goto_definition_works_for_record_fields); | 142 | tested_by!(goto_definition_works_for_record_fields); |
143 | if let Some(record_lit) = record_field.syntax().ancestors().find_map(ast::RecordLit::cast) { | 143 | if let Some(field_def) = analyzer.resolve_record_field(&record_field) { |
144 | let variant_def = analyzer.resolve_record_literal(&record_lit)?; | 144 | return Some(from_struct_field(db, field_def)); |
145 | let hir_path = Path::from_name_ref(name_ref.value); | ||
146 | let hir_name = hir_path.as_ident()?; | ||
147 | let field = variant_def.field(db, hir_name)?; | ||
148 | return Some(from_struct_field(db, field)); | ||
149 | } | 145 | } |
150 | } | 146 | } |
151 | 147 | ||