diff options
author | Aleksey Kladov <[email protected]> | 2020-10-15 16:27:50 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-10-15 16:38:17 +0100 |
commit | 56e67e3a392d7c7c7f30ca39d8e83446ea8bbec3 (patch) | |
tree | 4fe5fa460ddaf0bc19347d42bb91215614b5e840 /crates/assists/src | |
parent | f9c1336873d65805ad34129939d800dbf59daf61 (diff) |
More idiomatic classification API
Diffstat (limited to 'crates/assists/src')
-rw-r--r-- | crates/assists/src/handlers/add_turbo_fish.rs | 4 | ||||
-rw-r--r-- | crates/assists/src/handlers/expand_glob_import.rs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/crates/assists/src/handlers/add_turbo_fish.rs b/crates/assists/src/handlers/add_turbo_fish.rs index f4f997d8e..e3d84d698 100644 --- a/crates/assists/src/handlers/add_turbo_fish.rs +++ b/crates/assists/src/handlers/add_turbo_fish.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ide_db::defs::{classify_name_ref, Definition, NameRefClass}; | 1 | use ide_db::defs::{Definition, NameRefClass}; |
2 | use syntax::{ast, AstNode, SyntaxKind, T}; | 2 | use syntax::{ast, AstNode, SyntaxKind, T}; |
3 | use test_utils::mark; | 3 | use test_utils::mark; |
4 | 4 | ||
@@ -39,7 +39,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( | |||
39 | return None; | 39 | return None; |
40 | } | 40 | } |
41 | let name_ref = ast::NameRef::cast(ident.parent())?; | 41 | let name_ref = ast::NameRef::cast(ident.parent())?; |
42 | let def = match classify_name_ref(&ctx.sema, &name_ref)? { | 42 | let def = match NameRefClass::classify(&ctx.sema, &name_ref)? { |
43 | NameRefClass::Definition(def) => def, | 43 | NameRefClass::Definition(def) => def, |
44 | NameRefClass::ExternCrate(_) | NameRefClass::FieldShorthand { .. } => return None, | 44 | NameRefClass::ExternCrate(_) | NameRefClass::FieldShorthand { .. } => return None, |
45 | }; | 45 | }; |
diff --git a/crates/assists/src/handlers/expand_glob_import.rs b/crates/assists/src/handlers/expand_glob_import.rs index d1adff972..316a58d88 100644 --- a/crates/assists/src/handlers/expand_glob_import.rs +++ b/crates/assists/src/handlers/expand_glob_import.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use either::Either; | 1 | use either::Either; |
2 | use hir::{AssocItem, MacroDef, Module, ModuleDef, Name, PathResolution, ScopeDef}; | 2 | use hir::{AssocItem, MacroDef, Module, ModuleDef, Name, PathResolution, ScopeDef}; |
3 | use ide_db::{ | 3 | use ide_db::{ |
4 | defs::{classify_name_ref, Definition, NameRefClass}, | 4 | defs::{Definition, NameRefClass}, |
5 | search::SearchScope, | 5 | search::SearchScope, |
6 | }; | 6 | }; |
7 | use syntax::{ | 7 | use syntax::{ |
@@ -217,7 +217,7 @@ fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option<Vec<Def> | |||
217 | .flatten() | 217 | .flatten() |
218 | .filter_map(|n| Some(n.descendants().filter_map(ast::NameRef::cast))) | 218 | .filter_map(|n| Some(n.descendants().filter_map(ast::NameRef::cast))) |
219 | .flatten() | 219 | .flatten() |
220 | .filter_map(|r| match classify_name_ref(&ctx.sema, &r)? { | 220 | .filter_map(|r| match NameRefClass::classify(&ctx.sema, &r)? { |
221 | NameRefClass::Definition(Definition::ModuleDef(def)) => Some(Def::ModuleDef(def)), | 221 | NameRefClass::Definition(Definition::ModuleDef(def)) => Some(Def::ModuleDef(def)), |
222 | NameRefClass::Definition(Definition::Macro(def)) => Some(Def::MacroDef(def)), | 222 | NameRefClass::Definition(Definition::Macro(def)) => Some(Def::MacroDef(def)), |
223 | _ => None, | 223 | _ => None, |