aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/completions/attribute.rs
diff options
context:
space:
mode:
authorIgor Aleksanov <[email protected]>2020-10-25 08:26:38 +0000
committerIgor Aleksanov <[email protected]>2020-10-25 08:26:38 +0000
commitf731d910cbfe36bbdfa3a3f1415d5c48c4a79238 (patch)
treecc221d5bad05e1b6dc8e30f876b29d274b05e827 /crates/completion/src/completions/attribute.rs
parent19c10672023ead0c1d64486154b6c4145b649568 (diff)
Move Completions structure definition into completions module
Diffstat (limited to 'crates/completion/src/completions/attribute.rs')
-rw-r--r--crates/completion/src/completions/attribute.rs40
1 files changed, 17 insertions, 23 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}