aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor/src/code_actions.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-28 21:59:57 +0100
committerAleksey Kladov <[email protected]>2018-08-28 21:59:57 +0100
commit15f15d92eb4d6ab791047eefbd6dd9b2baba1140 (patch)
tree3f8fde6b53446c9ecfeac4f6bd2f34da5a91aa33 /crates/libeditor/src/code_actions.rs
parentba02a55330d2ec9a0ea2c5cd457b82782ae299e9 (diff)
add impl works with lifetimes
Diffstat (limited to 'crates/libeditor/src/code_actions.rs')
-rw-r--r--crates/libeditor/src/code_actions.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/libeditor/src/code_actions.rs b/crates/libeditor/src/code_actions.rs
index 684b8243a..08a85f6e2 100644
--- a/crates/libeditor/src/code_actions.rs
+++ b/crates/libeditor/src/code_actions.rs
@@ -80,7 +80,9 @@ pub fn add_impl<'a>(file: &'a File, offset: TextUnit) -> Option<impl FnOnce() ->
80 buf.push_str(" "); 80 buf.push_str(" ");
81 buf.push_str(name.text().as_str()); 81 buf.push_str(name.text().as_str());
82 if let Some(type_params) = type_params { 82 if let Some(type_params) = type_params {
83 join(type_params.type_params().filter_map(|it| it.name()).map(|it| it.text())) 83 let lifetime_params = type_params.lifetime_params().filter_map(|it| it.lifetime()).map(|it| it.text());
84 let type_params = type_params.type_params().filter_map(|it| it.name()).map(|it| it.text());
85 join(lifetime_params.chain(type_params))
84 .surround_with("<", ">") 86 .surround_with("<", ">")
85 .to_buf(&mut buf); 87 .to_buf(&mut buf);
86 } 88 }
@@ -146,6 +148,11 @@ mod tests {
146 "struct Foo<T: Clone> {}\n\nimpl<T: Clone> Foo<T> {\n<|>\n}", 148 "struct Foo<T: Clone> {}\n\nimpl<T: Clone> Foo<T> {\n<|>\n}",
147 |file, off| add_impl(file, off).map(|f| f()), 149 |file, off| add_impl(file, off).map(|f| f()),
148 ); 150 );
151 check_action(
152 "struct Foo<'a, T: Foo<'a>> {<|>}",
153 "struct Foo<'a, T: Foo<'a>> {}\n\nimpl<'a, T: Foo<'a>> Foo<'a, T> {\n<|>\n}",
154 |file, off| add_impl(file, off).map(|f| f()),
155 );
149 } 156 }
150 157
151} 158}