diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-04 14:38:55 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-04 14:38:55 +0100 |
commit | a559459fb0c86ef1eb66dabe6e0c6208ff4a6e42 (patch) | |
tree | d064e7f9d185257fffcb769db2ffc8a28c2db2b5 | |
parent | ea098fdbd2ac9f93e5501235fa4fa8e0f68b3cc4 (diff) | |
parent | 8f4478390e29f34c5530a25bd0338b689218677f (diff) |
Merge #4300
4300: Cleanup attribute completion r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | crates/ra_ide/src/completion.rs | 31 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/complete_attribute.rs | 19 |
2 files changed, 24 insertions, 26 deletions
diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index a0e06faa2..8bdc43b1a 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs | |||
@@ -65,23 +65,20 @@ pub(crate) fn completions( | |||
65 | let ctx = CompletionContext::new(db, position, config)?; | 65 | let ctx = CompletionContext::new(db, position, config)?; |
66 | 66 | ||
67 | let mut acc = Completions::default(); | 67 | let mut acc = Completions::default(); |
68 | if ctx.attribute_under_caret.is_some() { | 68 | complete_attribute::complete_attribute(&mut acc, &ctx); |
69 | complete_attribute::complete_attribute(&mut acc, &ctx); | 69 | complete_fn_param::complete_fn_param(&mut acc, &ctx); |
70 | } else { | 70 | complete_keyword::complete_expr_keyword(&mut acc, &ctx); |
71 | complete_fn_param::complete_fn_param(&mut acc, &ctx); | 71 | complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); |
72 | complete_keyword::complete_expr_keyword(&mut acc, &ctx); | 72 | complete_snippet::complete_expr_snippet(&mut acc, &ctx); |
73 | complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); | 73 | complete_snippet::complete_item_snippet(&mut acc, &ctx); |
74 | complete_snippet::complete_expr_snippet(&mut acc, &ctx); | 74 | complete_qualified_path::complete_qualified_path(&mut acc, &ctx); |
75 | complete_snippet::complete_item_snippet(&mut acc, &ctx); | 75 | complete_unqualified_path::complete_unqualified_path(&mut acc, &ctx); |
76 | complete_qualified_path::complete_qualified_path(&mut acc, &ctx); | 76 | complete_dot::complete_dot(&mut acc, &ctx); |
77 | complete_unqualified_path::complete_unqualified_path(&mut acc, &ctx); | 77 | complete_record::complete_record(&mut acc, &ctx); |
78 | complete_dot::complete_dot(&mut acc, &ctx); | 78 | complete_pattern::complete_pattern(&mut acc, &ctx); |
79 | complete_record::complete_record(&mut acc, &ctx); | 79 | complete_postfix::complete_postfix(&mut acc, &ctx); |
80 | complete_pattern::complete_pattern(&mut acc, &ctx); | 80 | complete_macro_in_item_position::complete_macro_in_item_position(&mut acc, &ctx); |
81 | complete_postfix::complete_postfix(&mut acc, &ctx); | 81 | complete_trait_impl::complete_trait_impl(&mut acc, &ctx); |
82 | complete_macro_in_item_position::complete_macro_in_item_position(&mut acc, &ctx); | ||
83 | complete_trait_impl::complete_trait_impl(&mut acc, &ctx); | ||
84 | } | ||
85 | 82 | ||
86 | Some(acc) | 83 | Some(acc) |
87 | } | 84 | } |
diff --git a/crates/ra_ide/src/completion/complete_attribute.rs b/crates/ra_ide/src/completion/complete_attribute.rs index 20e6edc17..f17266221 100644 --- a/crates/ra_ide/src/completion/complete_attribute.rs +++ b/crates/ra_ide/src/completion/complete_attribute.rs | |||
@@ -3,20 +3,21 @@ | |||
3 | //! This module uses a bit of static metadata to provide completions | 3 | //! This module uses a bit of static metadata to provide completions |
4 | //! for built-in attributes. | 4 | //! for built-in attributes. |
5 | 5 | ||
6 | use super::completion_context::CompletionContext; | 6 | use ra_syntax::{ast, AstNode, SyntaxKind}; |
7 | use super::completion_item::{CompletionItem, CompletionItemKind, CompletionKind, Completions}; | ||
8 | use ast::AttrInput; | ||
9 | use ra_syntax::{ | ||
10 | ast::{self, AttrKind}, | ||
11 | AstNode, SyntaxKind, | ||
12 | }; | ||
13 | use rustc_hash::FxHashSet; | 7 | use rustc_hash::FxHashSet; |
14 | 8 | ||
9 | use crate::completion::{ | ||
10 | completion_context::CompletionContext, | ||
11 | completion_item::{CompletionItem, CompletionItemKind, CompletionKind, Completions}, | ||
12 | }; | ||
13 | |||
15 | pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { | 14 | pub(super) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { |
16 | let attribute = ctx.attribute_under_caret.as_ref()?; | 15 | let attribute = ctx.attribute_under_caret.as_ref()?; |
17 | 16 | ||
18 | match (attribute.path(), attribute.input()) { | 17 | match (attribute.path(), attribute.input()) { |
19 | (Some(path), Some(AttrInput::TokenTree(token_tree))) if path.to_string() == "derive" => { | 18 | (Some(path), Some(ast::AttrInput::TokenTree(token_tree))) |
19 | if path.to_string() == "derive" => | ||
20 | { | ||
20 | complete_derive(acc, ctx, token_tree) | 21 | complete_derive(acc, ctx, token_tree) |
21 | } | 22 | } |
22 | _ => complete_attribute_start(acc, ctx, attribute), | 23 | _ => complete_attribute_start(acc, ctx, attribute), |
@@ -40,7 +41,7 @@ fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attr | |||
40 | _ => {} | 41 | _ => {} |
41 | } | 42 | } |
42 | 43 | ||
43 | if attribute.kind() == AttrKind::Inner || !attr_completion.should_be_inner { | 44 | if attribute.kind() == ast::AttrKind::Inner || !attr_completion.should_be_inner { |
44 | acc.add(item); | 45 | acc.add(item); |
45 | } | 46 | } |
46 | } | 47 | } |