Skip to content

Commit 9d1f150

Browse files
bors[bot]Veykril
andauthored
Merge #10649
10649: internal: Remove `CompletionKind` in favor of `CompletionItemKind` r=Veykril a=Veykril and move some more tests around bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 parents dd43f3f + 0468b11 commit 9d1f150

34 files changed

+1558
-1563
lines changed

crates/ide_completion/src/completions.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use hir::known;
2121
use ide_db::SymbolKind;
2222

2323
use crate::{
24-
item::{Builder, CompletionKind},
24+
item::Builder,
2525
render::{
2626
const_::render_const,
2727
enum_variant::render_variant,
@@ -76,8 +76,7 @@ impl Completions {
7676
}
7777

7878
pub(crate) fn add_keyword(&mut self, ctx: &CompletionContext, keyword: &'static str) {
79-
let mut item = CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), keyword);
80-
item.kind(CompletionItemKind::Keyword);
79+
let item = CompletionItem::new(CompletionItemKind::Keyword, ctx.source_range(), keyword);
8180
item.add_to(self);
8281
}
8382

@@ -191,9 +190,7 @@ impl Completions {
191190
}
192191

193192
pub(crate) fn add_static_lifetime(&mut self, ctx: &CompletionContext) {
194-
let mut item =
195-
CompletionItem::new(CompletionKind::Reference, ctx.source_range(), "'static");
196-
item.kind(CompletionItemKind::SymbolKind(SymbolKind::LifetimeParam));
193+
let item = CompletionItem::new(SymbolKind::LifetimeParam, ctx.source_range(), "'static");
197194
self.add(item.build());
198195
}
199196

crates/ide_completion/src/completions/attribute.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use syntax::{algo::non_trivia_sibling, ast, AstNode, Direction, SyntaxKind, T};
1212

1313
use crate::{
1414
context::CompletionContext,
15-
item::{CompletionItem, CompletionItemKind, CompletionKind},
15+
item::{CompletionItem, CompletionItemKind},
1616
Completions,
1717
};
1818

@@ -69,11 +69,10 @@ fn complete_new_attribute(acc: &mut Completions, ctx: &CompletionContext, attrib
6969

7070
let add_completion = |attr_completion: &AttrCompletion| {
7171
let mut item = CompletionItem::new(
72-
CompletionKind::Attribute,
72+
CompletionItemKind::Attribute,
7373
ctx.source_range(),
7474
attr_completion.label,
7575
);
76-
item.kind(CompletionItemKind::Attribute);
7776

7877
if let Some(lookup) = attr_completion.lookup {
7978
item.lookup_by(lookup);
@@ -103,11 +102,10 @@ fn complete_new_attribute(acc: &mut Completions, ctx: &CompletionContext, attrib
103102
if let hir::ScopeDef::MacroDef(mac) = scope_def {
104103
if mac.kind() == hir::MacroKind::Attr {
105104
let mut item = CompletionItem::new(
106-
CompletionKind::Attribute,
105+
CompletionItemKind::Attribute,
107106
ctx.source_range(),
108107
name.to_string(),
109108
);
110-
item.kind(CompletionItemKind::Attribute);
111109
if let Some(docs) = mac.docs(ctx.sema.db) {
112110
item.documentation(docs);
113111
}

crates/ide_completion/src/completions/attribute/cfg.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ use std::iter;
55
use syntax::SyntaxKind;
66

77
use crate::{
8-
completions::Completions, context::CompletionContext, item::CompletionKind, CompletionItem,
9-
CompletionItemKind,
8+
completions::Completions, context::CompletionContext, CompletionItem, CompletionItemKind,
109
};
1110

1211
pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
1312
let add_completion = |item: &str| {
1413
let mut completion =
15-
CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), item);
14+
CompletionItem::new(CompletionItemKind::Attribute, ctx.source_range(), item);
1615
completion.insert_text(format!(r#""{}""#, item));
17-
completion.kind(CompletionItemKind::Attribute);
1816
acc.add(completion.build());
1917
};
2018

@@ -35,7 +33,7 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
3533
if let Some(krate) = ctx.krate {
3634
krate.potential_cfg(ctx.db).get_cfg_values(&name).iter().for_each(|s| {
3735
let mut item = CompletionItem::new(
38-
CompletionKind::Attribute,
36+
CompletionItemKind::Attribute,
3937
ctx.source_range(),
4038
s.as_str(),
4139
);
@@ -49,7 +47,7 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
4947
if let Some(krate) = ctx.krate {
5048
krate.potential_cfg(ctx.db).get_cfg_keys().iter().for_each(|s| {
5149
let item = CompletionItem::new(
52-
CompletionKind::Attribute,
50+
CompletionItemKind::Attribute,
5351
ctx.source_range(),
5452
s.as_str(),
5553
);

crates/ide_completion/src/completions/attribute/derive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use syntax::ast;
77

88
use crate::{
99
context::CompletionContext,
10-
item::{CompletionItem, CompletionItemKind, CompletionKind},
10+
item::{CompletionItem, CompletionItemKind},
1111
Completions,
1212
};
1313

@@ -56,8 +56,8 @@ pub(super) fn complete_derive(
5656
_ => (&*name, None),
5757
};
5858

59-
let mut item = CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), label);
60-
item.kind(CompletionItemKind::Attribute);
59+
let mut item =
60+
CompletionItem::new(CompletionItemKind::Attribute, ctx.source_range(), label);
6161
if let Some(docs) = mac.docs(ctx.db) {
6262
item.documentation(docs);
6363
}

crates/ide_completion/src/completions/attribute/lint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use syntax::{ast, T};
44

55
use crate::{
66
context::CompletionContext,
7-
item::{CompletionItem, CompletionItemKind, CompletionKind},
7+
item::{CompletionItem, CompletionItemKind},
88
Completions,
99
};
1010

@@ -58,9 +58,9 @@ pub(super) fn complete_lint(
5858
Some(qual) if !is_qualified => format!("{}::{}", qual, name),
5959
_ => name.to_owned(),
6060
};
61-
let mut item = CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), label);
62-
item.kind(CompletionItemKind::Attribute)
63-
.documentation(hir::Documentation::new(description.to_owned()));
61+
let mut item =
62+
CompletionItem::new(CompletionItemKind::Attribute, ctx.source_range(), label);
63+
item.documentation(hir::Documentation::new(description.to_owned()));
6464
item.add_to(acc)
6565
}
6666
}

crates/ide_completion/src/completions/attribute/repr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use syntax::ast;
44

55
use crate::{
66
context::CompletionContext,
7-
item::{CompletionItem, CompletionItemKind, CompletionKind},
7+
item::{CompletionItem, CompletionItemKind},
88
Completions,
99
};
1010

@@ -30,8 +30,7 @@ pub(super) fn complete_repr(acc: &mut Completions, ctx: &CompletionContext, inpu
3030
}
3131

3232
let mut item =
33-
CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), label);
34-
item.kind(CompletionItemKind::Attribute);
33+
CompletionItem::new(CompletionItemKind::Attribute, ctx.source_range(), label);
3534
if let Some(lookup) = lookup {
3635
item.lookup_by(lookup);
3736
}

crates/ide_completion/src/completions/dot.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,10 @@ fn complete_methods(
9999
mod tests {
100100
use expect_test::{expect, Expect};
101101

102-
use crate::{
103-
tests::{check_edit, filtered_completion_list},
104-
CompletionKind,
105-
};
102+
use crate::tests::{check_edit, completion_list_no_kw};
106103

107104
fn check(ra_fixture: &str, expect: Expect) {
108-
let actual = filtered_completion_list(ra_fixture, CompletionKind::Reference);
105+
let actual = completion_list_no_kw(ra_fixture);
109106
expect.assert_eq(&actual);
110107
}
111108

@@ -166,7 +163,7 @@ impl A {
166163
struct A { the_field: u32 }
167164
fn foo(a: A) { a.$0() }
168165
"#,
169-
expect![[""]],
166+
expect![[r#""#]],
170167
);
171168
}
172169

@@ -405,7 +402,7 @@ fn foo(a: A) {
405402
a.$0
406403
}
407404
"#,
408-
expect![[""]],
405+
expect![[r#""#]],
409406
);
410407
}
411408

@@ -654,6 +651,7 @@ impl Foo { fn foo(&self) { $0 } }"#,
654651
lc self &Foo
655652
sp Self
656653
st Foo
654+
bt u32
657655
fd self.field i32
658656
me self.foo() fn(&self)
659657
"#]],
@@ -667,6 +665,7 @@ impl Foo { fn foo(&mut self) { $0 } }"#,
667665
lc self &mut Foo
668666
sp Self
669667
st Foo
668+
bt u32
670669
fd self.0 i32
671670
me self.foo() fn(&mut self)
672671
"#]],

0 commit comments

Comments
 (0)