diff options
author | Aleksey Kladov <[email protected]> | 2020-01-14 16:39:28 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-01-15 15:52:28 +0000 |
commit | 11d6b9daddfa9275c507a5e246541c28a78023ab (patch) | |
tree | 1284a6dd8fe99e549c2bdba4198665b6e350910a /crates/ra_ide/src/references.rs | |
parent | 35bfeaf4af4bcccf355f1e0e1a38547a2982a251 (diff) |
Only new-style classification
Diffstat (limited to 'crates/ra_ide/src/references.rs')
-rw-r--r-- | crates/ra_ide/src/references.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 2b74d7653..b0e5fddcc 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs | |||
@@ -14,7 +14,7 @@ mod name_definition; | |||
14 | mod rename; | 14 | mod rename; |
15 | mod search_scope; | 15 | mod search_scope; |
16 | 16 | ||
17 | use hir::InFile; | 17 | use hir::{InFile, SourceBinder}; |
18 | use once_cell::unsync::Lazy; | 18 | use once_cell::unsync::Lazy; |
19 | use ra_db::{SourceDatabase, SourceDatabaseExt}; | 19 | use ra_db::{SourceDatabase, SourceDatabaseExt}; |
20 | use ra_prof::profile; | 20 | use ra_prof::profile; |
@@ -29,7 +29,7 @@ use crate::{ | |||
29 | }; | 29 | }; |
30 | 30 | ||
31 | pub(crate) use self::{ | 31 | pub(crate) use self::{ |
32 | classify::{classify_name, classify_name2, classify_name_ref, classify_name_ref2}, | 32 | classify::{classify_name, classify_name_ref}, |
33 | name_definition::{NameDefinition, NameKind}, | 33 | name_definition::{NameDefinition, NameKind}, |
34 | rename::rename, | 34 | rename::rename, |
35 | }; | 35 | }; |
@@ -171,13 +171,14 @@ fn find_name( | |||
171 | syntax: &SyntaxNode, | 171 | syntax: &SyntaxNode, |
172 | position: FilePosition, | 172 | position: FilePosition, |
173 | ) -> Option<RangeInfo<(String, NameDefinition)>> { | 173 | ) -> Option<RangeInfo<(String, NameDefinition)>> { |
174 | let mut sb = SourceBinder::new(db); | ||
174 | if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) { | 175 | if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) { |
175 | let def = classify_name(db, InFile::new(position.file_id.into(), &name))?; | 176 | let def = classify_name(&mut sb, InFile::new(position.file_id.into(), &name))?; |
176 | let range = name.syntax().text_range(); | 177 | let range = name.syntax().text_range(); |
177 | return Some(RangeInfo::new(range, (name.text().to_string(), def))); | 178 | return Some(RangeInfo::new(range, (name.text().to_string(), def))); |
178 | } | 179 | } |
179 | let name_ref = find_node_at_offset::<ast::NameRef>(&syntax, position.offset)?; | 180 | let name_ref = find_node_at_offset::<ast::NameRef>(&syntax, position.offset)?; |
180 | let def = classify_name_ref(db, InFile::new(position.file_id.into(), &name_ref))?; | 181 | let def = classify_name_ref(&mut sb, InFile::new(position.file_id.into(), &name_ref))?; |
181 | let range = name_ref.syntax().text_range(); | 182 | let range = name_ref.syntax().text_range(); |
182 | Some(RangeInfo::new(range, (name_ref.text().to_string(), def))) | 183 | Some(RangeInfo::new(range, (name_ref.text().to_string(), def))) |
183 | } | 184 | } |
@@ -209,7 +210,10 @@ fn process_definition( | |||
209 | continue; | 210 | continue; |
210 | } | 211 | } |
211 | } | 212 | } |
212 | if let Some(d) = classify_name_ref(db, InFile::new(file_id.into(), &name_ref)) { | 213 | // FIXME: reuse sb |
214 | let mut sb = SourceBinder::new(db); | ||
215 | if let Some(d) = classify_name_ref(&mut sb, InFile::new(file_id.into(), &name_ref)) | ||
216 | { | ||
213 | if d == def { | 217 | if d == def { |
214 | let kind = if name_ref | 218 | let kind = if name_ref |
215 | .syntax() | 219 | .syntax() |