diff options
Diffstat (limited to 'crates/ra_ide/src/completion')
-rw-r--r-- | crates/ra_ide/src/completion/complete_fn_param.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/complete_keyword.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/complete_trait_impl.rs | 17 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/completion_context.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/patterns.rs | 2 |
5 files changed, 21 insertions, 22 deletions
diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs index d4b6112a5..406334257 100644 --- a/crates/ra_ide/src/completion/complete_fn_param.rs +++ b/crates/ra_ide/src/completion/complete_fn_param.rs | |||
@@ -19,8 +19,8 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) | |||
19 | 19 | ||
20 | let mut params = FxHashMap::default(); | 20 | let mut params = FxHashMap::default(); |
21 | 21 | ||
22 | let me = ctx.token.ancestors().find_map(ast::FnDef::cast); | 22 | let me = ctx.token.ancestors().find_map(ast::Fn::cast); |
23 | let mut process_fn = |func: ast::FnDef| { | 23 | let mut process_fn = |func: ast::Fn| { |
24 | if Some(&func) == me.as_ref() { | 24 | if Some(&func) == me.as_ref() { |
25 | return; | 25 | return; |
26 | } | 26 | } |
@@ -34,15 +34,15 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) | |||
34 | match_ast! { | 34 | match_ast! { |
35 | match node { | 35 | match node { |
36 | ast::SourceFile(it) => it.items().filter_map(|item| match item { | 36 | ast::SourceFile(it) => it.items().filter_map(|item| match item { |
37 | ast::Item::FnDef(it) => Some(it), | 37 | ast::Item::Fn(it) => Some(it), |
38 | _ => None, | 38 | _ => None, |
39 | }).for_each(&mut process_fn), | 39 | }).for_each(&mut process_fn), |
40 | ast::ItemList(it) => it.items().filter_map(|item| match item { | 40 | ast::ItemList(it) => it.items().filter_map(|item| match item { |
41 | ast::Item::FnDef(it) => Some(it), | 41 | ast::Item::Fn(it) => Some(it), |
42 | _ => None, | 42 | _ => None, |
43 | }).for_each(&mut process_fn), | 43 | }).for_each(&mut process_fn), |
44 | ast::AssocItemList(it) => it.assoc_items().filter_map(|item| match item { | 44 | ast::AssocItemList(it) => it.assoc_items().filter_map(|item| match item { |
45 | ast::AssocItem::FnDef(it) => Some(it), | 45 | ast::AssocItem::Fn(it) => Some(it), |
46 | _ => None, | 46 | _ => None, |
47 | }).for_each(&mut process_fn), | 47 | }).for_each(&mut process_fn), |
48 | _ => continue, | 48 | _ => continue, |
diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs index 1581b2d5d..b62064797 100644 --- a/crates/ra_ide/src/completion/complete_keyword.rs +++ b/crates/ra_ide/src/completion/complete_keyword.rs | |||
@@ -169,7 +169,7 @@ fn add_keyword(ctx: &CompletionContext, acc: &mut Completions, kw: &str, snippet | |||
169 | 169 | ||
170 | fn complete_return( | 170 | fn complete_return( |
171 | ctx: &CompletionContext, | 171 | ctx: &CompletionContext, |
172 | fn_def: &ast::FnDef, | 172 | fn_def: &ast::Fn, |
173 | can_be_stmt: bool, | 173 | can_be_stmt: bool, |
174 | ) -> Option<CompletionItem> { | 174 | ) -> Option<CompletionItem> { |
175 | let snip = match (can_be_stmt, fn_def.ret_type().is_some()) { | 175 | let snip = match (can_be_stmt, fn_def.ret_type().is_some()) { |
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index cf716540f..87221d964 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | //! | 2 | //! |
3 | //! This module adds the completion items related to implementing associated | 3 | //! This module adds the completion items related to implementing associated |
4 | //! items within a `impl Trait for Struct` block. The current context node | 4 | //! items within a `impl Trait for Struct` block. The current context node |
5 | //! must be within either a `FN_DEF`, `TYPE_ALIAS_DEF`, or `CONST_DEF` node | 5 | //! must be within either a `FN`, `TYPE_ALIAS`, or `CONST` node |
6 | //! and an direct child of an `IMPL_DEF`. | 6 | //! and an direct child of an `IMPL_DEF`. |
7 | //! | 7 | //! |
8 | //! # Examples | 8 | //! # Examples |
@@ -63,7 +63,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext | |||
63 | } | 63 | } |
64 | }), | 64 | }), |
65 | 65 | ||
66 | SyntaxKind::FN_DEF => { | 66 | SyntaxKind::FN => { |
67 | for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) | 67 | for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) |
68 | .into_iter() | 68 | .into_iter() |
69 | .filter_map(|item| match item { | 69 | .filter_map(|item| match item { |
@@ -75,7 +75,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext | |||
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | SyntaxKind::TYPE_ALIAS_DEF => { | 78 | SyntaxKind::TYPE_ALIAS => { |
79 | for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) | 79 | for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) |
80 | .into_iter() | 80 | .into_iter() |
81 | .filter_map(|item| match item { | 81 | .filter_map(|item| match item { |
@@ -87,7 +87,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext | |||
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | SyntaxKind::CONST_DEF => { | 90 | SyntaxKind::CONST => { |
91 | for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) | 91 | for missing_fn in get_missing_assoc_items(&ctx.sema, &impl_def) |
92 | .into_iter() | 92 | .into_iter() |
93 | .filter_map(|item| match item { | 93 | .filter_map(|item| match item { |
@@ -106,10 +106,9 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext | |||
106 | 106 | ||
107 | fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> { | 107 | fn completion_match(ctx: &CompletionContext) -> Option<(SyntaxNode, ImplDef)> { |
108 | let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() { | 108 | let (trigger, impl_def_offset) = ctx.token.ancestors().find_map(|p| match p.kind() { |
109 | SyntaxKind::FN_DEF | 109 | SyntaxKind::FN | SyntaxKind::TYPE_ALIAS | SyntaxKind::CONST | SyntaxKind::BLOCK_EXPR => { |
110 | | SyntaxKind::TYPE_ALIAS_DEF | 110 | Some((p, 2)) |
111 | | SyntaxKind::CONST_DEF | 111 | } |
112 | | SyntaxKind::BLOCK_EXPR => Some((p, 2)), | ||
113 | SyntaxKind::NAME_REF => Some((p, 5)), | 112 | SyntaxKind::NAME_REF => Some((p, 5)), |
114 | _ => None, | 113 | _ => None, |
115 | })?; | 114 | })?; |
@@ -201,7 +200,7 @@ fn add_const_impl( | |||
201 | } | 200 | } |
202 | } | 201 | } |
203 | 202 | ||
204 | fn make_const_compl_syntax(const_: &ast::ConstDef) -> String { | 203 | fn make_const_compl_syntax(const_: &ast::Const) -> String { |
205 | let const_ = edit::remove_attrs_and_docs(const_); | 204 | let const_ = edit::remove_attrs_and_docs(const_); |
206 | 205 | ||
207 | let const_start = const_.syntax().text_range().start(); | 206 | let const_start = const_.syntax().text_range().start(); |
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index cc55f6dd6..c8704eb3e 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -35,11 +35,11 @@ pub(crate) struct CompletionContext<'a> { | |||
35 | pub(super) krate: Option<hir::Crate>, | 35 | pub(super) krate: Option<hir::Crate>, |
36 | pub(super) expected_type: Option<Type>, | 36 | pub(super) expected_type: Option<Type>, |
37 | pub(super) name_ref_syntax: Option<ast::NameRef>, | 37 | pub(super) name_ref_syntax: Option<ast::NameRef>, |
38 | pub(super) function_syntax: Option<ast::FnDef>, | 38 | pub(super) function_syntax: Option<ast::Fn>, |
39 | pub(super) use_item_syntax: Option<ast::Use>, | 39 | pub(super) use_item_syntax: Option<ast::Use>, |
40 | pub(super) record_lit_syntax: Option<ast::RecordLit>, | 40 | pub(super) record_lit_syntax: Option<ast::RecordExpr>, |
41 | pub(super) record_pat_syntax: Option<ast::RecordPat>, | 41 | pub(super) record_pat_syntax: Option<ast::RecordPat>, |
42 | pub(super) record_field_syntax: Option<ast::RecordField>, | 42 | pub(super) record_field_syntax: Option<ast::RecordExprField>, |
43 | pub(super) impl_def: Option<ast::ImplDef>, | 43 | pub(super) impl_def: Option<ast::ImplDef>, |
44 | /// FIXME: `ActiveParameter` is string-based, which is very very wrong | 44 | /// FIXME: `ActiveParameter` is string-based, which is very very wrong |
45 | pub(super) active_parameter: Option<ActiveParameter>, | 45 | pub(super) active_parameter: Option<ActiveParameter>, |
@@ -316,7 +316,7 @@ impl<'a> CompletionContext<'a> { | |||
316 | self.name_ref_syntax = | 316 | self.name_ref_syntax = |
317 | find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); | 317 | find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); |
318 | let name_range = name_ref.syntax().text_range(); | 318 | let name_range = name_ref.syntax().text_range(); |
319 | if ast::RecordField::for_field_name(&name_ref).is_some() { | 319 | if ast::RecordExprField::for_field_name(&name_ref).is_some() { |
320 | self.record_lit_syntax = | 320 | self.record_lit_syntax = |
321 | self.sema.find_node_at_offset_with_macros(&original_file, offset); | 321 | self.sema.find_node_at_offset_with_macros(&original_file, offset); |
322 | } | 322 | } |
@@ -349,7 +349,7 @@ impl<'a> CompletionContext<'a> { | |||
349 | .sema | 349 | .sema |
350 | .ancestors_with_macros(self.token.parent()) | 350 | .ancestors_with_macros(self.token.parent()) |
351 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) | 351 | .take_while(|it| it.kind() != SOURCE_FILE && it.kind() != MODULE) |
352 | .find_map(ast::FnDef::cast); | 352 | .find_map(ast::Fn::cast); |
353 | 353 | ||
354 | self.record_field_syntax = self | 354 | self.record_field_syntax = self |
355 | .sema | 355 | .sema |
@@ -357,7 +357,7 @@ impl<'a> CompletionContext<'a> { | |||
357 | .take_while(|it| { | 357 | .take_while(|it| { |
358 | it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR | 358 | it.kind() != SOURCE_FILE && it.kind() != MODULE && it.kind() != CALL_EXPR |
359 | }) | 359 | }) |
360 | .find_map(ast::RecordField::cast); | 360 | .find_map(ast::RecordExprField::cast); |
361 | 361 | ||
362 | let parent = match name_ref.syntax().parent() { | 362 | let parent = match name_ref.syntax().parent() { |
363 | Some(it) => it, | 363 | Some(it) => it, |
diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs index 175209d8a..b8408da4e 100644 --- a/crates/ra_ide/src/completion/patterns.rs +++ b/crates/ra_ide/src/completion/patterns.rs | |||
@@ -134,7 +134,7 @@ pub(crate) fn is_in_loop_body(element: SyntaxElement) -> bool { | |||
134 | NodeOrToken::Token(token) => token.parent(), | 134 | NodeOrToken::Token(token) => token.parent(), |
135 | }; | 135 | }; |
136 | for node in leaf.ancestors() { | 136 | for node in leaf.ancestors() { |
137 | if node.kind() == FN_DEF || node.kind() == LAMBDA_EXPR { | 137 | if node.kind() == FN || node.kind() == LAMBDA_EXPR { |
138 | break; | 138 | break; |
139 | } | 139 | } |
140 | let loop_body = match_ast! { | 140 | let loop_body = match_ast! { |