aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/completions
diff options
context:
space:
mode:
Diffstat (limited to 'crates/completion/src/completions')
-rw-r--r--crates/completion/src/completions/attribute.rs40
-rw-r--r--crates/completion/src/completions/dot.rs2
-rw-r--r--crates/completion/src/completions/mod_.rs9
-rw-r--r--crates/completion/src/completions/postfix.rs4
-rw-r--r--crates/completion/src/completions/postfix/format_like.rs2
5 files changed, 25 insertions, 32 deletions
diff --git a/crates/completion/src/completions/attribute.rs b/crates/completion/src/completions/attribute.rs
index 3d517c886..f3d669458 100644
--- a/crates/completion/src/completions/attribute.rs
+++ b/crates/completion/src/completions/attribute.rs
@@ -9,7 +9,8 @@ use syntax::{ast, AstNode, SyntaxKind};
9use crate::{ 9use crate::{
10 context::CompletionContext, 10 context::CompletionContext,
11 generated_lint_completions::{CLIPPY_LINTS, FEATURES}, 11 generated_lint_completions::{CLIPPY_LINTS, FEATURES},
12 item::{CompletionItem, CompletionItemKind, CompletionKind, Completions}, 12 item::{CompletionItem, CompletionItemKind, CompletionKind},
13 Completions,
13}; 14};
14 15
15pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 16pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
@@ -60,7 +61,7 @@ fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attr
60 } 61 }
61 62
62 if attribute.kind() == ast::AttrKind::Inner || !attr_completion.prefer_inner { 63 if attribute.kind() == ast::AttrKind::Inner || !attr_completion.prefer_inner {
63 acc.add(item); 64 acc.add(item.build());
64 } 65 }
65 } 66 }
66} 67}
@@ -152,21 +153,15 @@ fn complete_derive(acc: &mut Completions, ctx: &CompletionContext, derive_input:
152 label.push_str(", "); 153 label.push_str(", ");
153 label.push_str(dependency); 154 label.push_str(dependency);
154 } 155 }
155 acc.add( 156 CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), label)
156 CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), label) 157 .kind(CompletionItemKind::Attribute)
157 .kind(CompletionItemKind::Attribute), 158 .add_to(acc)
158 );
159 } 159 }
160 160
161 for custom_derive_name in get_derive_names_in_scope(ctx).difference(&existing_derives) { 161 for custom_derive_name in get_derive_names_in_scope(ctx).difference(&existing_derives) {
162 acc.add( 162 CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), custom_derive_name)
163 CompletionItem::new( 163 .kind(CompletionItemKind::Attribute)
164 CompletionKind::Attribute, 164 .add_to(acc)
165 ctx.source_range(),
166 custom_derive_name,
167 )
168 .kind(CompletionItemKind::Attribute),
169 );
170 } 165 }
171 } 166 }
172} 167}
@@ -182,15 +177,14 @@ fn complete_lint(
182 .into_iter() 177 .into_iter()
183 .filter(|completion| !existing_lints.contains(completion.label)) 178 .filter(|completion| !existing_lints.contains(completion.label))
184 { 179 {
185 acc.add( 180 CompletionItem::new(
186 CompletionItem::new( 181 CompletionKind::Attribute,
187 CompletionKind::Attribute, 182 ctx.source_range(),
188 ctx.source_range(), 183 lint_completion.label,
189 lint_completion.label, 184 )
190 ) 185 .kind(CompletionItemKind::Attribute)
191 .kind(CompletionItemKind::Attribute) 186 .detail(lint_completion.description)
192 .detail(lint_completion.description), 187 .add_to(acc)
193 );
194 } 188 }
195 } 189 }
196} 190}
diff --git a/crates/completion/src/completions/dot.rs b/crates/completion/src/completions/dot.rs
index 92b1f489d..c9875045a 100644
--- a/crates/completion/src/completions/dot.rs
+++ b/crates/completion/src/completions/dot.rs
@@ -4,7 +4,7 @@ use hir::{HasVisibility, Type};
4use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
5use test_utils::mark; 5use test_utils::mark;
6 6
7use crate::{context::CompletionContext, item::Completions}; 7use crate::{context::CompletionContext, Completions};
8 8
9/// Complete dot accesses, i.e. fields or methods. 9/// Complete dot accesses, i.e. fields or methods.
10pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { 10pub(crate) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
diff --git a/crates/completion/src/completions/mod_.rs b/crates/completion/src/completions/mod_.rs
index 9612ca36a..c96f84171 100644
--- a/crates/completion/src/completions/mod_.rs
+++ b/crates/completion/src/completions/mod_.rs
@@ -7,7 +7,7 @@ use rustc_hash::FxHashSet;
7 7
8use crate::{CompletionItem, CompletionItemKind}; 8use crate::{CompletionItem, CompletionItemKind};
9 9
10use crate::{context::CompletionContext, item::CompletionKind, item::Completions}; 10use crate::{context::CompletionContext, item::CompletionKind, Completions};
11 11
12/// Complete mod declaration, i.e. `mod <|> ;` 12/// Complete mod declaration, i.e. `mod <|> ;`
13pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 13pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
@@ -75,10 +75,9 @@ pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Op
75 if mod_under_caret.semicolon_token().is_none() { 75 if mod_under_caret.semicolon_token().is_none() {
76 label.push(';') 76 label.push(';')
77 } 77 }
78 acc.add( 78 CompletionItem::new(CompletionKind::Magic, ctx.source_range(), &label)
79 CompletionItem::new(CompletionKind::Magic, ctx.source_range(), &label) 79 .kind(CompletionItemKind::Module)
80 .kind(CompletionItemKind::Module), 80 .add_to(acc)
81 )
82 }); 81 });
83 82
84 Some(()) 83 Some(())
diff --git a/crates/completion/src/completions/postfix.rs b/crates/completion/src/completions/postfix.rs
index f83ab8d2d..348f017bd 100644
--- a/crates/completion/src/completions/postfix.rs
+++ b/crates/completion/src/completions/postfix.rs
@@ -13,8 +13,8 @@ use self::format_like::add_format_like_completions;
13use crate::{ 13use crate::{
14 config::SnippetCap, 14 config::SnippetCap,
15 context::CompletionContext, 15 context::CompletionContext,
16 item::{Builder, CompletionKind, Completions}, 16 item::{Builder, CompletionKind},
17 CompletionItem, CompletionItemKind, 17 CompletionItem, CompletionItemKind, Completions,
18}; 18};
19 19
20pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { 20pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
diff --git a/crates/completion/src/completions/postfix/format_like.rs b/crates/completion/src/completions/postfix/format_like.rs
index 8a91665b6..3595e0fce 100644
--- a/crates/completion/src/completions/postfix/format_like.rs
+++ b/crates/completion/src/completions/postfix/format_like.rs
@@ -16,7 +16,7 @@
16 16
17use crate::{ 17use crate::{
18 completions::postfix::postfix_snippet, config::SnippetCap, context::CompletionContext, 18 completions::postfix::postfix_snippet, config::SnippetCap, context::CompletionContext,
19 item::Completions, 19 Completions,
20}; 20};
21use syntax::ast::{self, AstToken}; 21use syntax::ast::{self, AstToken};
22 22