mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-01 02:14:20 +00:00
Merge #1130
1130: Use inline snapshots in complete_fn_param r=matklad a=vipentti Relates to #1127 Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
This commit is contained in:
commit
b28e403c6c
@ -54,48 +54,79 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::completion::{check_completion, CompletionKind};
|
||||
use crate::completion::{do_completion, CompletionItem, CompletionKind};
|
||||
use insta::assert_debug_snapshot_matches;
|
||||
|
||||
fn check_magic_completion(name: &str, code: &str) {
|
||||
check_completion(name, code, CompletionKind::Magic);
|
||||
fn do_magic_completion(code: &str) -> Vec<CompletionItem> {
|
||||
do_completion(code, CompletionKind::Magic)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_param_completion_last_param() {
|
||||
check_magic_completion(
|
||||
"param_completion_last_param",
|
||||
r"
|
||||
fn foo(file_id: FileId) {}
|
||||
fn bar(file_id: FileId) {}
|
||||
fn baz(file<|>) {}
|
||||
",
|
||||
assert_debug_snapshot_matches!(
|
||||
do_magic_completion(
|
||||
r"
|
||||
fn foo(file_id: FileId) {}
|
||||
fn bar(file_id: FileId) {}
|
||||
fn baz(file<|>) {}
|
||||
",
|
||||
),
|
||||
@r###"[
|
||||
CompletionItem {
|
||||
label: "file_id: FileId",
|
||||
source_range: [110; 114),
|
||||
delete: [110; 114),
|
||||
insert: "file_id: FileId",
|
||||
lookup: "file_id"
|
||||
}
|
||||
]"###
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_param_completion_nth_param() {
|
||||
check_magic_completion(
|
||||
"param_completion_nth_param",
|
||||
r"
|
||||
fn foo(file_id: FileId) {}
|
||||
fn bar(file_id: FileId) {}
|
||||
fn baz(file<|>, x: i32) {}
|
||||
",
|
||||
assert_debug_snapshot_matches!(
|
||||
do_magic_completion(
|
||||
r"
|
||||
fn foo(file_id: FileId) {}
|
||||
fn bar(file_id: FileId) {}
|
||||
fn baz(file<|>, x: i32) {}
|
||||
",
|
||||
),
|
||||
@r###"[
|
||||
CompletionItem {
|
||||
label: "file_id: FileId",
|
||||
source_range: [110; 114),
|
||||
delete: [110; 114),
|
||||
insert: "file_id: FileId",
|
||||
lookup: "file_id"
|
||||
}
|
||||
]"###
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_param_completion_trait_param() {
|
||||
check_magic_completion(
|
||||
"param_completion_trait_param",
|
||||
r"
|
||||
pub(crate) trait SourceRoot {
|
||||
pub fn contains(&self, file_id: FileId) -> bool;
|
||||
pub fn module_map(&self) -> &ModuleMap;
|
||||
pub fn lines(&self, file_id: FileId) -> &LineIndex;
|
||||
pub fn syntax(&self, file<|>)
|
||||
}
|
||||
",
|
||||
assert_debug_snapshot_matches!(
|
||||
do_magic_completion(
|
||||
r"
|
||||
pub(crate) trait SourceRoot {
|
||||
pub fn contains(&self, file_id: FileId) -> bool;
|
||||
pub fn module_map(&self) -> &ModuleMap;
|
||||
pub fn lines(&self, file_id: FileId) -> &LineIndex;
|
||||
pub fn syntax(&self, file<|>)
|
||||
}
|
||||
",
|
||||
),
|
||||
@r###"[
|
||||
CompletionItem {
|
||||
label: "file_id: FileId",
|
||||
source_range: [289; 293),
|
||||
delete: [289; 293),
|
||||
insert: "file_id: FileId",
|
||||
lookup: "file_id"
|
||||
}
|
||||
]"###
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
---
|
||||
created: "2019-02-18T09:22:23.949634602Z"
|
||||
creator: insta@0.6.2
|
||||
source: crates/ra_ide_api/src/completion/completion_item.rs
|
||||
expression: kind_completions
|
||||
---
|
||||
[
|
||||
CompletionItem {
|
||||
label: "file_id: FileId",
|
||||
source_range: [98; 102),
|
||||
delete: [98; 102),
|
||||
insert: "file_id: FileId",
|
||||
lookup: "file_id"
|
||||
}
|
||||
]
|
@ -1,15 +0,0 @@
|
||||
---
|
||||
created: "2019-02-18T09:22:23.949634355Z"
|
||||
creator: insta@0.6.2
|
||||
source: crates/ra_ide_api/src/completion/completion_item.rs
|
||||
expression: kind_completions
|
||||
---
|
||||
[
|
||||
CompletionItem {
|
||||
label: "file_id: FileId",
|
||||
source_range: [98; 102),
|
||||
delete: [98; 102),
|
||||
insert: "file_id: FileId",
|
||||
lookup: "file_id"
|
||||
}
|
||||
]
|
@ -1,15 +0,0 @@
|
||||
---
|
||||
created: "2019-02-18T09:22:23.974417169Z"
|
||||
creator: insta@0.6.2
|
||||
source: crates/ra_ide_api/src/completion/completion_item.rs
|
||||
expression: kind_completions
|
||||
---
|
||||
[
|
||||
CompletionItem {
|
||||
label: "file_id: FileId",
|
||||
source_range: [269; 273),
|
||||
delete: [269; 273),
|
||||
insert: "file_id: FileId",
|
||||
lookup: "file_id"
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user