From 56e67e3a392d7c7c7f30ca39d8e83446ea8bbec3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 15 Oct 2020 17:27:50 +0200 Subject: More idiomatic classification API --- crates/assists/src/handlers/add_turbo_fish.rs | 4 ++-- crates/assists/src/handlers/expand_glob_import.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/assists/src') 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 @@ -use ide_db::defs::{classify_name_ref, Definition, NameRefClass}; +use ide_db::defs::{Definition, NameRefClass}; use syntax::{ast, AstNode, SyntaxKind, T}; use test_utils::mark; @@ -39,7 +39,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( return None; } let name_ref = ast::NameRef::cast(ident.parent())?; - let def = match classify_name_ref(&ctx.sema, &name_ref)? { + let def = match NameRefClass::classify(&ctx.sema, &name_ref)? { NameRefClass::Definition(def) => def, NameRefClass::ExternCrate(_) | NameRefClass::FieldShorthand { .. } => return None, }; 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 @@ use either::Either; use hir::{AssocItem, MacroDef, Module, ModuleDef, Name, PathResolution, ScopeDef}; use ide_db::{ - defs::{classify_name_ref, Definition, NameRefClass}, + defs::{Definition, NameRefClass}, search::SearchScope, }; use syntax::{ @@ -217,7 +217,7 @@ fn find_imported_defs(ctx: &AssistContext, star: SyntaxToken) -> Option .flatten() .filter_map(|n| Some(n.descendants().filter_map(ast::NameRef::cast))) .flatten() - .filter_map(|r| match classify_name_ref(&ctx.sema, &r)? { + .filter_map(|r| match NameRefClass::classify(&ctx.sema, &r)? { NameRefClass::Definition(Definition::ModuleDef(def)) => Some(Def::ModuleDef(def)), NameRefClass::Definition(Definition::Macro(def)) => Some(Def::MacroDef(def)), _ => None, -- cgit v1.2.3