Complete names from prelude

This commit is contained in:
Florian Diebold 2019-02-13 20:53:42 +01:00
parent 92c595a6a6
commit 911e32bca9
4 changed files with 84 additions and 5 deletions

View file

@ -4,7 +4,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) {
if !ctx.is_trivial_path {
return;
}
let names = ctx.resolver.all_names();
let names = ctx.resolver.all_names(ctx.db);
names.into_iter().for_each(|(name, res)| {
CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.to_string())
@ -165,4 +165,23 @@ mod tests {
fn completes_self_in_methods() {
check_reference_completion("self_in_methods", r"impl S { fn foo(&self) { <|> } }")
}
#[test]
fn completes_prelude() {
check_reference_completion(
"completes_prelude",
"
//- /main.rs
fn foo() { let x: <|> }
//- /std/lib.rs
#[prelude_import]
use prelude::*;
mod prelude {
struct Option;
}
",
);
}
}

View file

@ -0,0 +1,54 @@
---
created: "2019-02-13T19:52:43.734834624Z"
creator: insta@0.6.2
source: crates/ra_ide_api/src/completion/completion_item.rs
expression: kind_completions
---
[
CompletionItem {
completion_kind: Reference,
label: "Option",
kind: Some(
Struct
),
detail: None,
documentation: None,
lookup: None,
insert_text: None,
insert_text_format: PlainText,
source_range: [18; 18),
text_edit: None
},
CompletionItem {
completion_kind: Reference,
label: "foo",
kind: Some(
Function
),
detail: Some(
"fn foo()"
),
documentation: None,
lookup: None,
insert_text: Some(
"foo()$0"
),
insert_text_format: Snippet,
source_range: [18; 18),
text_edit: None
},
CompletionItem {
completion_kind: Reference,
label: "std",
kind: Some(
Module
),
detail: None,
documentation: None,
lookup: None,
insert_text: None,
insert_text_format: PlainText,
source_range: [18; 18),
text_edit: None
}
]