aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-30 14:36:21 +0100
committerAleksey Kladov <[email protected]>2020-07-30 14:36:21 +0100
commit28ef4c375a9f56d69daf885504aea3df7012bb81 (patch)
tree5118a120ce8ff2b58e170415a07d0a089034fd6d /crates/ra_assists
parenteb2f8063444b11257111f4f8ade990ec810e0361 (diff)
Rename TypeParamList -> GenericParamList
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/handlers/generate_function.rs4
-rw-r--r--crates/ra_assists/src/handlers/generate_impl.rs4
-rw-r--r--crates/ra_assists/src/handlers/generate_new.rs5
-rw-r--r--crates/ra_assists/src/handlers/introduce_named_lifetime.rs12
-rw-r--r--crates/ra_assists/src/handlers/move_bounds.rs2
5 files changed, 14 insertions, 13 deletions
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 {
104struct FunctionBuilder { 104struct FunctionBuilder {
105 target: GeneratedFunctionTarget, 105 target: GeneratedFunctionTarget,
106 fn_name: ast::Name, 106 fn_name: ast::Name,
107 type_params: Option<ast::TypeParamList>, 107 type_params: Option<ast::GenericParamList>,
108 params: ast::ParamList, 108 params: ast::ParamList,
109 file: FileId, 109 file: FileId,
110 needs_pub: bool, 110 needs_pub: bool,
@@ -200,7 +200,7 @@ fn fn_args(
200 ctx: &AssistContext, 200 ctx: &AssistContext,
201 target_module: hir::Module, 201 target_module: hir::Module,
202 call: &ast::CallExpr, 202 call: &ast::CallExpr,
203) -> Option<(Option<ast::TypeParamList>, ast::ParamList)> { 203) -> Option<(Option<ast::GenericParamList>, ast::ParamList)> {
204 let mut arg_names = Vec::new(); 204 let mut arg_names = Vec::new();
205 let mut arg_types = Vec::new(); 205 let mut arg_types = Vec::new();
206 for arg in call.arg_list()?.args() { 206 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 @@
1use ra_syntax::ast::{self, AstNode, NameOwner, TypeParamsOwner}; 1use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner};
2use stdx::{format_to, SepBy}; 2use stdx::{format_to, SepBy};
3 3
4use crate::{AssistContext, AssistId, AssistKind, Assists}; 4use crate::{AssistContext, AssistId, AssistKind, Assists};
@@ -31,7 +31,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()
31 format!("Generate impl for `{}`", name), 31 format!("Generate impl for `{}`", name),
32 target, 32 target,
33 |edit| { 33 |edit| {
34 let type_params = nominal.type_param_list(); 34 let type_params = nominal.generic_param_list();
35 let start_offset = nominal.syntax().text_range().end(); 35 let start_offset = nominal.syntax().text_range().end();
36 let mut buf = String::new(); 36 let mut buf = String::new();
37 buf.push_str("\n\nimpl"); 37 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 @@
1use hir::Adt; 1use hir::Adt;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{ 3 ast::{
4 self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, 4 self, AstNode, GenericParamsOwner, NameOwner, StructKind, TypeAscriptionOwner,
5 VisibilityOwner,
5 }, 6 },
6 T, 7 T,
7}; 8};
@@ -91,7 +92,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
91// Generates the surrounding `impl Type { <code> }` including type and lifetime 92// Generates the surrounding `impl Type { <code> }` including type and lifetime
92// parameters 93// parameters
93fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { 94fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
94 let type_params = strukt.type_param_list(); 95 let type_params = strukt.generic_param_list();
95 let mut buf = String::with_capacity(code.len()); 96 let mut buf = String::with_capacity(code.len());
96 buf.push_str("\n\nimpl"); 97 buf.push_str("\n\nimpl");
97 if let Some(type_params) = &type_params { 98 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 @@
1use ra_syntax::{ 1use ra_syntax::{
2 ast::{self, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, 2 ast::{self, GenericParamsOwner, NameOwner, TypeAscriptionOwner},
3 AstNode, SyntaxKind, TextRange, TextSize, 3 AstNode, SyntaxKind, TextRange, TextSize,
4}; 4};
5use rustc_hash::FxHashSet; 5use rustc_hash::FxHashSet;
@@ -54,7 +54,7 @@ fn generate_fn_def_assist(
54 lifetime_loc: TextRange, 54 lifetime_loc: TextRange,
55) -> Option<()> { 55) -> Option<()> {
56 let param_list: ast::ParamList = fn_def.param_list()?; 56 let param_list: ast::ParamList = fn_def.param_list()?;
57 let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.type_param_list())?; 57 let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.generic_param_list())?;
58 let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end(); 58 let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end();
59 let self_param = 59 let self_param =
60 // use the self if it's a reference and has no explicit lifetime 60 // use the self if it's a reference and has no explicit lifetime
@@ -96,7 +96,7 @@ fn generate_impl_def_assist(
96 impl_def: &ast::ImplDef, 96 impl_def: &ast::ImplDef,
97 lifetime_loc: TextRange, 97 lifetime_loc: TextRange,
98) -> Option<()> { 98) -> Option<()> {
99 let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.type_param_list())?; 99 let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?;
100 let end_of_impl_kw = impl_def.impl_token()?.text_range().end(); 100 let end_of_impl_kw = impl_def.impl_token()?.text_range().end();
101 acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| { 101 acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| {
102 add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param); 102 add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param);
@@ -107,7 +107,7 @@ fn generate_impl_def_assist(
107/// Given a type parameter list, generate a unique lifetime parameter name 107/// Given a type parameter list, generate a unique lifetime parameter name
108/// which is not in the list 108/// which is not in the list
109fn generate_unique_lifetime_param_name( 109fn generate_unique_lifetime_param_name(
110 existing_type_param_list: &Option<ast::TypeParamList>, 110 existing_type_param_list: &Option<ast::GenericParamList>,
111) -> Option<char> { 111) -> Option<char> {
112 match existing_type_param_list { 112 match existing_type_param_list {
113 Some(type_params) => { 113 Some(type_params) => {
@@ -123,13 +123,13 @@ fn generate_unique_lifetime_param_name(
123 123
124/// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise 124/// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise
125/// add new type params brackets with the lifetime parameter at `new_type_params_loc`. 125/// add new type params brackets with the lifetime parameter at `new_type_params_loc`.
126fn add_lifetime_param<TypeParamsOwner: ast::TypeParamsOwner>( 126fn add_lifetime_param<TypeParamsOwner: ast::GenericParamsOwner>(
127 type_params_owner: &TypeParamsOwner, 127 type_params_owner: &TypeParamsOwner,
128 builder: &mut AssistBuilder, 128 builder: &mut AssistBuilder,
129 new_type_params_loc: TextSize, 129 new_type_params_loc: TextSize,
130 new_lifetime_param: char, 130 new_lifetime_param: char,
131) { 131) {
132 match type_params_owner.type_param_list() { 132 match type_params_owner.generic_param_list() {
133 // add the new lifetime parameter to an existing type param list 133 // add the new lifetime parameter to an existing type param list
134 Some(type_params) => { 134 Some(type_params) => {
135 builder.insert( 135 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};
23// } 23// }
24// ``` 24// ```
25pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { 25pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
26 let type_param_list = ctx.find_node_at_offset::<ast::TypeParamList>()?; 26 let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?;
27 27
28 let mut type_params = type_param_list.type_params(); 28 let mut type_params = type_param_list.type_params();
29 if type_params.all(|p| p.type_bound_list().is_none()) { 29 if type_params.all(|p| p.type_bound_list().is_none()) {