diff options
Diffstat (limited to 'crates/ra_ide_db/src')
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 35 | ||||
-rw-r--r-- | crates/ra_ide_db/src/search.rs | 4 |
2 files changed, 24 insertions, 15 deletions
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index e06b189a0..f391a8e43 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs | |||
@@ -290,20 +290,25 @@ pub fn classify_name_ref( | |||
290 | 290 | ||
291 | let path = name_ref.syntax().ancestors().find_map(ast::Path::cast)?; | 291 | let path = name_ref.syntax().ancestors().find_map(ast::Path::cast)?; |
292 | let resolved = sema.resolve_path(&path)?; | 292 | let resolved = sema.resolve_path(&path)?; |
293 | let res = match resolved { | 293 | Some(NameRefClass::Definition(resolved.into())) |
294 | PathResolution::Def(def) => Definition::ModuleDef(def), | 294 | } |
295 | PathResolution::AssocItem(item) => { | 295 | |
296 | let def = match item { | 296 | impl From<PathResolution> for Definition { |
297 | hir::AssocItem::Function(it) => it.into(), | 297 | fn from(path_resolution: PathResolution) -> Self { |
298 | hir::AssocItem::Const(it) => it.into(), | 298 | match path_resolution { |
299 | hir::AssocItem::TypeAlias(it) => it.into(), | 299 | PathResolution::Def(def) => Definition::ModuleDef(def), |
300 | }; | 300 | PathResolution::AssocItem(item) => { |
301 | Definition::ModuleDef(def) | 301 | let def = match item { |
302 | hir::AssocItem::Function(it) => it.into(), | ||
303 | hir::AssocItem::Const(it) => it.into(), | ||
304 | hir::AssocItem::TypeAlias(it) => it.into(), | ||
305 | }; | ||
306 | Definition::ModuleDef(def) | ||
307 | } | ||
308 | PathResolution::Local(local) => Definition::Local(local), | ||
309 | PathResolution::TypeParam(par) => Definition::TypeParam(par), | ||
310 | PathResolution::Macro(def) => Definition::Macro(def), | ||
311 | PathResolution::SelfType(impl_def) => Definition::SelfType(impl_def), | ||
302 | } | 312 | } |
303 | PathResolution::Local(local) => Definition::Local(local), | 313 | } |
304 | PathResolution::TypeParam(par) => Definition::TypeParam(par), | ||
305 | PathResolution::Macro(def) => Definition::Macro(def), | ||
306 | PathResolution::SelfType(impl_def) => Definition::SelfType(impl_def), | ||
307 | }; | ||
308 | Some(NameRefClass::Definition(res)) | ||
309 | } | 314 | } |
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index 81553150b..a7cae37b0 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs | |||
@@ -60,6 +60,10 @@ impl SearchScope { | |||
60 | SearchScope::new(std::iter::once((file, None)).collect()) | 60 | SearchScope::new(std::iter::once((file, None)).collect()) |
61 | } | 61 | } |
62 | 62 | ||
63 | pub fn files(files: &[FileId]) -> SearchScope { | ||
64 | SearchScope::new(files.iter().map(|f| (*f, None)).collect()) | ||
65 | } | ||
66 | |||
63 | pub fn intersection(&self, other: &SearchScope) -> SearchScope { | 67 | pub fn intersection(&self, other: &SearchScope) -> SearchScope { |
64 | let (mut small, mut large) = (&self.entries, &other.entries); | 68 | let (mut small, mut large) = (&self.entries, &other.entries); |
65 | if small.len() > large.len() { | 69 | if small.len() > large.len() { |