From 28ef4c375a9f56d69daf885504aea3df7012bb81 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 15:36:21 +0200 Subject: Rename TypeParamList -> GenericParamList --- crates/ra_assists/src/handlers/generate_function.rs | 4 ++-- crates/ra_assists/src/handlers/generate_impl.rs | 4 ++-- crates/ra_assists/src/handlers/generate_new.rs | 5 +++-- crates/ra_assists/src/handlers/introduce_named_lifetime.rs | 12 ++++++------ crates/ra_assists/src/handlers/move_bounds.rs | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs index 006d0ffb2..56510861d 100644 --- a/crates/ra_assists/src/handlers/generate_function.rs +++ b/crates/ra_assists/src/handlers/generate_function.rs @@ -104,7 +104,7 @@ impl FunctionTemplate { struct FunctionBuilder { target: GeneratedFunctionTarget, fn_name: ast::Name, - type_params: Option, + type_params: Option, params: ast::ParamList, file: FileId, needs_pub: bool, @@ -200,7 +200,7 @@ fn fn_args( ctx: &AssistContext, target_module: hir::Module, call: &ast::CallExpr, -) -> Option<(Option, ast::ParamList)> { +) -> Option<(Option, ast::ParamList)> { let mut arg_names = Vec::new(); let mut arg_types = Vec::new(); for arg in call.arg_list()?.args() { diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/ra_assists/src/handlers/generate_impl.rs index 42eb4defa..d9b87c9c0 100644 --- a/crates/ra_assists/src/handlers/generate_impl.rs +++ b/crates/ra_assists/src/handlers/generate_impl.rs @@ -1,4 +1,4 @@ -use ra_syntax::ast::{self, AstNode, NameOwner, TypeParamsOwner}; +use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner}; use stdx::{format_to, SepBy}; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -31,7 +31,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<() format!("Generate impl for `{}`", name), target, |edit| { - let type_params = nominal.type_param_list(); + let type_params = nominal.generic_param_list(); let start_offset = nominal.syntax().text_range().end(); let mut buf = String::new(); buf.push_str("\n\nimpl"); diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index 4dff0ae4d..340f9b103 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs @@ -1,7 +1,8 @@ use hir::Adt; use ra_syntax::{ ast::{ - self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, + self, AstNode, GenericParamsOwner, NameOwner, StructKind, TypeAscriptionOwner, + VisibilityOwner, }, T, }; @@ -91,7 +92,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> // Generates the surrounding `impl Type { }` including type and lifetime // parameters fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { - let type_params = strukt.type_param_list(); + let type_params = strukt.generic_param_list(); let mut buf = String::with_capacity(code.len()); buf.push_str("\n\nimpl"); if let Some(type_params) = &type_params { diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index f3774fab1..4ad173ef0 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs @@ -1,5 +1,5 @@ use ra_syntax::{ - ast::{self, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, + ast::{self, GenericParamsOwner, NameOwner, TypeAscriptionOwner}, AstNode, SyntaxKind, TextRange, TextSize, }; use rustc_hash::FxHashSet; @@ -54,7 +54,7 @@ fn generate_fn_def_assist( lifetime_loc: TextRange, ) -> Option<()> { let param_list: ast::ParamList = fn_def.param_list()?; - let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.type_param_list())?; + let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.generic_param_list())?; let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end(); let self_param = // use the self if it's a reference and has no explicit lifetime @@ -96,7 +96,7 @@ fn generate_impl_def_assist( impl_def: &ast::ImplDef, lifetime_loc: TextRange, ) -> Option<()> { - let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.type_param_list())?; + let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?; let end_of_impl_kw = impl_def.impl_token()?.text_range().end(); acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| { add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param); @@ -107,7 +107,7 @@ fn generate_impl_def_assist( /// Given a type parameter list, generate a unique lifetime parameter name /// which is not in the list fn generate_unique_lifetime_param_name( - existing_type_param_list: &Option, + existing_type_param_list: &Option, ) -> Option { match existing_type_param_list { Some(type_params) => { @@ -123,13 +123,13 @@ fn generate_unique_lifetime_param_name( /// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise /// add new type params brackets with the lifetime parameter at `new_type_params_loc`. -fn add_lifetime_param( +fn add_lifetime_param( type_params_owner: &TypeParamsOwner, builder: &mut AssistBuilder, new_type_params_loc: TextSize, new_lifetime_param: char, ) { - match type_params_owner.type_param_list() { + match type_params_owner.generic_param_list() { // add the new lifetime parameter to an existing type param list Some(type_params) => { builder.insert( diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index dae6198ed..69ce90fbc 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // } // ``` pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { - let type_param_list = ctx.find_node_at_offset::()?; + let type_param_list = ctx.find_node_at_offset::()?; let mut type_params = type_param_list.type_params(); if type_params.all(|p| p.type_bound_list().is_none()) { -- cgit v1.2.3