]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide_assists/src/handlers/extract_type_alias.rs
Merge #11481
[rust.git] / crates / ide_assists / src / handlers / extract_type_alias.rs
index 4913ac1e08ea8f413f78d1f4c5e26842efdf6922..d7ad62782f84ccfc44f8c1670ce7e5c67c7d6c63 100644 (file)
@@ -1,7 +1,8 @@
 use either::Either;
+use ide_db::helpers::node_ext::walk_ty;
 use itertools::Itertools;
 use syntax::{
-    ast::{self, edit::IndentLevel, AstNode, GenericParamsOwner, NameOwner},
+    ast::{self, edit::IndentLevel, AstNode, HasGenericParams, HasName},
     match_ast,
 };
 
@@ -25,7 +26,7 @@
 // }
 // ```
 pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
-    if ctx.frange.range.is_empty() {
+    if ctx.has_empty_selection() {
         return None;
     }
 
@@ -120,7 +121,7 @@ fn find_lifetime(text: &str) -> impl Fn(&&ast::GenericParam) -> bool + '_ {
     }
 
     let mut generics = Vec::new();
-    ty.walk(&mut |ty| match ty {
+    walk_ty(ty, &mut |ty| match ty {
         ast::Type::PathType(ty) => {
             if let Some(path) = ty.path() {
                 if let Some(name_ref) = path.as_single_name_ref() {