From f1abc7bdc63fedd5a699b4c495bb23f1b6d254f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 19 Jul 2019 12:56:47 +0300 Subject: migrate ra_ide_api to the new rowan --- crates/ra_ide_api/src/completion/complete_keyword.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'crates/ra_ide_api/src/completion/complete_keyword.rs') diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs index 034ed934d..4cf34eff8 100644 --- a/crates/ra_ide_api/src/completion/complete_keyword.rs +++ b/crates/ra_ide_api/src/completion/complete_keyword.rs @@ -52,7 +52,7 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte return; } - let fn_def = match ctx.function_syntax { + let fn_def = match &ctx.function_syntax { Some(it) => it, None => return, }; @@ -65,7 +65,7 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte acc.add(keyword(ctx, "else", "else {$0}")); acc.add(keyword(ctx, "else if", "else if $0 {}")); } - if is_in_loop_body(ctx.token) { + if is_in_loop_body(&ctx.token) { if ctx.can_be_stmt { acc.add(keyword(ctx, "continue", "continue;")); acc.add(keyword(ctx, "break", "break;")); @@ -74,19 +74,19 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte acc.add(keyword(ctx, "break", "break")); } } - acc.add_all(complete_return(ctx, fn_def, ctx.can_be_stmt)); + acc.add_all(complete_return(ctx, &fn_def, ctx.can_be_stmt)); } -fn is_in_loop_body(leaf: SyntaxToken) -> bool { +fn is_in_loop_body(leaf: &SyntaxToken) -> bool { for node in leaf.parent().ancestors() { if node.kind() == FN_DEF || node.kind() == LAMBDA_EXPR { break; } let loop_body = visitor() - .visit::(LoopBodyOwner::loop_body) - .visit::(LoopBodyOwner::loop_body) - .visit::(LoopBodyOwner::loop_body) - .accept(node); + .visit::(|it| it.loop_body()) + .visit::(|it| it.loop_body()) + .visit::(|it| it.loop_body()) + .accept(&node); if let Some(Some(body)) = loop_body { if leaf.range().is_subrange(&body.syntax().range()) { return true; -- cgit v1.2.3