aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/references/classify.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/references/classify.rs')
-rw-r--r--crates/ra_ide_api/src/references/classify.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/crates/ra_ide_api/src/references/classify.rs b/crates/ra_ide_api/src/references/classify.rs
index 153082d5b..217f9951e 100644
--- a/crates/ra_ide_api/src/references/classify.rs
+++ b/crates/ra_ide_api/src/references/classify.rs
@@ -1,13 +1,13 @@
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
3use hir::{Either, FromSource, Module, ModuleSource, Path, PathResolution, Source, SourceAnalyzer}; 3use hir::{FromSource, Module, ModuleSource, Path, PathResolution, Source, SourceAnalyzer};
4use ra_db::FileId; 4use ra_db::FileId;
5use ra_prof::profile; 5use ra_prof::profile;
6use ra_syntax::{ast, match_ast, AstNode, AstPtr}; 6use ra_syntax::{ast, match_ast, AstNode};
7use test_utils::tested_by; 7use test_utils::tested_by;
8 8
9use super::{ 9use super::{
10 name_definition::{from_assoc_item, from_module_def, from_pat, from_struct_field}, 10 name_definition::{from_assoc_item, from_module_def, from_struct_field},
11 NameDefinition, NameKind, 11 NameDefinition, NameKind,
12}; 12};
13use crate::db::RootDatabase; 13use crate::db::RootDatabase;
@@ -25,7 +25,13 @@ pub(crate) fn classify_name(
25 match_ast! { 25 match_ast! {
26 match parent { 26 match parent {
27 ast::BindPat(it) => { 27 ast::BindPat(it) => {
28 from_pat(db, file_id, AstPtr::new(&it)) 28 let src = hir::Source { file_id, ast: it };
29 let local = hir::Local::from_source(db, src)?;
30 Some(NameDefinition {
31 visibility: None,
32 container: local.module(db),
33 kind: NameKind::Local(local),
34 })
29 }, 35 },
30 ast::RecordFieldDef(it) => { 36 ast::RecordFieldDef(it) => {
31 let ast = hir::FieldSource::Named(it); 37 let ast = hir::FieldSource::Named(it);
@@ -159,10 +165,10 @@ pub(crate) fn classify_name_ref(
159 match resolved { 165 match resolved {
160 Def(def) => Some(from_module_def(db, def, Some(container))), 166 Def(def) => Some(from_module_def(db, def, Some(container))),
161 AssocItem(item) => Some(from_assoc_item(db, item)), 167 AssocItem(item) => Some(from_assoc_item(db, item)),
162 LocalBinding(Either::A(pat)) => from_pat(db, file_id, pat), 168 Local(local) => {
163 LocalBinding(Either::B(par)) => { 169 let container = local.module(db);
164 let kind = NameKind::SelfParam(par); 170 let kind = NameKind::Local(local);
165 Some(NameDefinition { kind, container, visibility }) 171 Some(NameDefinition { kind, container, visibility: None })
166 } 172 }
167 GenericParam(par) => { 173 GenericParam(par) => {
168 // FIXME: get generic param def 174 // FIXME: get generic param def