mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Some cleanup and additional tests
This commit is contained in:
parent
d571d26955
commit
c5852f422f
7 changed files with 138 additions and 31 deletions
|
@ -65,6 +65,17 @@ mod tests {
|
|||
check_completion(code, expected_completions, CompletionKind::Reference);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore] // should not complete foo, which currently doesn't work
|
||||
fn dont_complete_current_use() {
|
||||
check_reference_completion(
|
||||
"dont_complete_current_use",
|
||||
r"
|
||||
use self::foo<|>;
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_mod_with_docs() {
|
||||
check_reference_completion(
|
||||
|
|
|
@ -6,29 +6,15 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
}
|
||||
let names = ctx.resolver.all_names();
|
||||
|
||||
// let module_scope = module.scope(ctx.db);
|
||||
names
|
||||
.into_iter()
|
||||
// FIXME check tests
|
||||
// .filter(|(_name, res)| {
|
||||
// // For cases like `use self::foo<|>` don't suggest foo itself.
|
||||
// match res.import {
|
||||
// None => true,
|
||||
// Some(import) => {
|
||||
// let source = module.import_source(ctx.db, import);
|
||||
// !source.syntax().range().is_subrange(&ctx.leaf.range())
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
.for_each(|(name, res)| {
|
||||
CompletionItem::new(
|
||||
CompletionKind::Reference,
|
||||
ctx.source_range(),
|
||||
name.to_string(),
|
||||
)
|
||||
.from_resolution(ctx, &res)
|
||||
.add_to(acc)
|
||||
});
|
||||
names.into_iter().for_each(|(name, res)| {
|
||||
CompletionItem::new(
|
||||
CompletionKind::Reference,
|
||||
ctx.source_range(),
|
||||
name.to_string(),
|
||||
)
|
||||
.from_resolution(ctx, &res)
|
||||
.add_to(acc)
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -86,6 +72,30 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_generic_params() {
|
||||
check_reference_completion(
|
||||
"generic_params",
|
||||
r"
|
||||
fn quux<T>() {
|
||||
<|>
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_generic_params_in_struct() {
|
||||
check_reference_completion(
|
||||
"generic_params_in_struct",
|
||||
r"
|
||||
struct X<T> {
|
||||
x: <|>
|
||||
}
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_module_items() {
|
||||
check_reference_completion(
|
||||
|
@ -145,5 +155,4 @@ mod tests {
|
|||
fn completes_self_in_methods() {
|
||||
check_reference_completion("self_in_methods", r"impl S { fn foo(&self) { <|> } }")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
created: "2019-02-01T22:20:40.580128393+00:00"
|
||||
creator: insta@0.5.3
|
||||
expression: kind_completions
|
||||
source: crates/ra_ide_api/src/completion/completion_item.rs
|
||||
---
|
||||
[
|
||||
CompletionItem {
|
||||
completion_kind: Reference,
|
||||
label: "T",
|
||||
kind: Some(
|
||||
TypeParam
|
||||
),
|
||||
detail: None,
|
||||
documentation: None,
|
||||
lookup: None,
|
||||
insert_text: None,
|
||||
insert_text_format: PlainText,
|
||||
source_range: [44; 44),
|
||||
text_edit: None
|
||||
},
|
||||
CompletionItem {
|
||||
completion_kind: Reference,
|
||||
label: "quux",
|
||||
kind: Some(
|
||||
Function
|
||||
),
|
||||
detail: Some(
|
||||
"fn quux<T>()"
|
||||
),
|
||||
documentation: None,
|
||||
lookup: None,
|
||||
insert_text: Some(
|
||||
"quux()$0"
|
||||
),
|
||||
insert_text_format: Snippet,
|
||||
source_range: [44; 44),
|
||||
text_edit: None
|
||||
}
|
||||
]
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
created: "2019-02-01T22:23:21.508620224+00:00"
|
||||
creator: insta@0.5.3
|
||||
expression: kind_completions
|
||||
source: crates/ra_ide_api/src/completion/completion_item.rs
|
||||
---
|
||||
[
|
||||
CompletionItem {
|
||||
completion_kind: Reference,
|
||||
label: "T",
|
||||
kind: Some(
|
||||
TypeParam
|
||||
),
|
||||
detail: None,
|
||||
documentation: None,
|
||||
lookup: None,
|
||||
insert_text: None,
|
||||
insert_text_format: PlainText,
|
||||
source_range: [46; 46),
|
||||
text_edit: None
|
||||
},
|
||||
CompletionItem {
|
||||
completion_kind: Reference,
|
||||
label: "X",
|
||||
kind: Some(
|
||||
Struct
|
||||
),
|
||||
detail: None,
|
||||
documentation: None,
|
||||
lookup: None,
|
||||
insert_text: None,
|
||||
insert_text_format: PlainText,
|
||||
source_range: [46; 46),
|
||||
text_edit: None
|
||||
}
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue