diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_keyword.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_keyword.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs index 841c0c554..718b83418 100644 --- a/crates/ra_ide_api/src/completion/complete_keyword.rs +++ b/crates/ra_ide_api/src/completion/complete_keyword.rs | |||
@@ -2,7 +2,7 @@ use ra_syntax::{ | |||
2 | algo::visit::{visitor, Visitor}, | 2 | algo::visit::{visitor, Visitor}, |
3 | AstNode, | 3 | AstNode, |
4 | ast::{self, LoopBodyOwner}, | 4 | ast::{self, LoopBodyOwner}, |
5 | SyntaxKind::*, SyntaxNode, | 5 | SyntaxKind::*, SyntaxToken, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind}; | 8 | use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind}; |
@@ -62,7 +62,7 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte | |||
62 | acc.add(keyword(ctx, "else", "else {$0}")); | 62 | acc.add(keyword(ctx, "else", "else {$0}")); |
63 | acc.add(keyword(ctx, "else if", "else if $0 {}")); | 63 | acc.add(keyword(ctx, "else if", "else if $0 {}")); |
64 | } | 64 | } |
65 | if is_in_loop_body(ctx.leaf) { | 65 | if is_in_loop_body(ctx.token) { |
66 | if ctx.can_be_stmt { | 66 | if ctx.can_be_stmt { |
67 | acc.add(keyword(ctx, "continue", "continue;")); | 67 | acc.add(keyword(ctx, "continue", "continue;")); |
68 | acc.add(keyword(ctx, "break", "break;")); | 68 | acc.add(keyword(ctx, "break", "break;")); |
@@ -74,8 +74,8 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte | |||
74 | acc.add_all(complete_return(ctx, fn_def, ctx.can_be_stmt)); | 74 | acc.add_all(complete_return(ctx, fn_def, ctx.can_be_stmt)); |
75 | } | 75 | } |
76 | 76 | ||
77 | fn is_in_loop_body(leaf: &SyntaxNode) -> bool { | 77 | fn is_in_loop_body(leaf: SyntaxToken) -> bool { |
78 | for node in leaf.ancestors() { | 78 | for node in leaf.parent().ancestors() { |
79 | if node.kind() == FN_DEF || node.kind() == LAMBDA_EXPR { | 79 | if node.kind() == FN_DEF || node.kind() == LAMBDA_EXPR { |
80 | break; | 80 | break; |
81 | } | 81 | } |