aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/assists/src/utils.rs')
-rw-r--r--crates/assists/src/utils.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs
index 643dade23..5dd32aef1 100644
--- a/crates/assists/src/utils.rs
+++ b/crates/assists/src/utils.rs
@@ -279,7 +279,7 @@ pub(crate) fn does_pat_match_variant(pat: &ast::Pat, var: &ast::Pat) -> bool {
279// 279//
280// FIXME: change the new fn checking to a more semantic approach when that's more 280// FIXME: change the new fn checking to a more semantic approach when that's more
281// viable (e.g. we process proc macros, etc) 281// viable (e.g. we process proc macros, etc)
282// FIXME: this partially overlaps with `find_impl_block` 282// FIXME: this partially overlaps with `find_impl_block_*`
283pub(crate) fn find_struct_impl( 283pub(crate) fn find_struct_impl(
284 ctx: &AssistContext, 284 ctx: &AssistContext,
285 strukt: &ast::Adt, 285 strukt: &ast::Adt,
@@ -343,17 +343,25 @@ fn has_fn(imp: &ast::Impl, rhs_name: &str) -> bool {
343 343
344/// Find the start of the `impl` block for the given `ast::Impl`. 344/// Find the start of the `impl` block for the given `ast::Impl`.
345// 345//
346// FIXME: add a way to find the end of the `impl` block.
347// FIXME: this partially overlaps with `find_struct_impl` 346// FIXME: this partially overlaps with `find_struct_impl`
348pub(crate) fn find_impl_block(impl_def: ast::Impl, buf: &mut String) -> Option<TextSize> { 347pub(crate) fn find_impl_block_start(impl_def: ast::Impl, buf: &mut String) -> Option<TextSize> {
349 buf.push('\n'); 348 buf.push('\n');
350 let start = impl_def 349 let start = impl_def.assoc_item_list().and_then(|it| it.l_curly_token())?.text_range().end();
351 .syntax() 350 Some(start)
352 .descendants_with_tokens() 351}
353 .find(|t| t.kind() == T!['{'])? 352
353/// Find the end of the `impl` block for the given `ast::Impl`.
354//
355// FIXME: this partially overlaps with `find_struct_impl`
356pub(crate) fn find_impl_block_end(impl_def: ast::Impl, buf: &mut String) -> Option<TextSize> {
357 buf.push('\n');
358 let end = impl_def
359 .assoc_item_list()
360 .and_then(|it| it.r_curly_token())?
361 .prev_sibling_or_token()?
354 .text_range() 362 .text_range()
355 .end(); 363 .end();
356 Some(start) 364 Some(end)
357} 365}
358 366
359// Generates the surrounding `impl Type { <code> }` including type and lifetime 367// Generates the surrounding `impl Type { <code> }` including type and lifetime