Skip to content

Commit f370393

Browse files
bors[bot]hdhoang
andcommitted
Merge #728
728: add postfix completion for `dbg!()` with `.dbg` r=matklad a=hdhoang closes #716 Co-authored-by: Hoàng Đức Hiếu <[email protected]>
2 parents 02bacf7 + 9dd7ccf commit f370393

4 files changed

+28
-230
lines changed

crates/ra_ide_api/src/completion/complete_postfix.rs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
4242
)
4343
.add_to(acc);
4444
postfix_snippet(ctx, "while", &format!("while {} {{\n$0\n}}", receiver_text)).add_to(acc);
45+
postfix_snippet(ctx, "dbg", &format!("dbg!({})", receiver_text)).add_to(acc);
4546
}
4647
}
4748

@@ -55,9 +56,9 @@ mod tests {
5556
}
5657

5758
#[test]
58-
fn test_filter_postfix_completion1() {
59+
fn postfix_completion_works_for_trivial_path_expression() {
5960
check_snippet_completion(
60-
"filter_postfix_completion1",
61+
"postfix_completion_works_for_trivial_path_expression",
6162
r#"
6263
fn main() {
6364
let bar = "a";
@@ -66,30 +67,4 @@ mod tests {
6667
"#,
6768
);
6869
}
69-
70-
#[test]
71-
fn test_filter_postfix_completion2() {
72-
check_snippet_completion(
73-
"filter_postfix_completion2",
74-
r#"
75-
fn main() {
76-
let bar = "a";
77-
bar.i<|>
78-
}
79-
"#,
80-
);
81-
}
82-
83-
#[test]
84-
fn test_filter_postfix_completion3() {
85-
check_snippet_completion(
86-
"filter_postfix_completion3",
87-
r#"
88-
fn main() {
89-
let bar = "a";
90-
bar.if<|>
91-
}
92-
"#,
93-
);
94-
}
9570
}

crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion2.snap

Lines changed: 0 additions & 100 deletions
This file was deleted.

crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion3.snap

Lines changed: 0 additions & 100 deletions
This file was deleted.

crates/ra_ide_api/src/completion/snapshots/completion_item__filter_postfix_completion1.snap renamed to crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
---
2-
created: "2019-01-27T19:56:59.944118550+00:00"
3-
creator: insta@0.5.2
2+
created: "2019-02-03T11:38:42.897384636+00:00"
3+
creator: insta@0.5.3
44
expression: kind_completions
55
source: crates/ra_ide_api/src/completion/completion_item.rs
66
---
77
[
8+
CompletionItem {
9+
completion_kind: Postfix,
10+
label: "dbg",
11+
kind: None,
12+
detail: None,
13+
documentation: None,
14+
lookup: None,
15+
insert_text: Some(
16+
"dbg!(bar)"
17+
),
18+
insert_text_format: Snippet,
19+
source_range: [76; 76),
20+
text_edit: Some(
21+
TextEdit {
22+
atoms: [
23+
AtomTextEdit {
24+
delete: [72; 76),
25+
insert: ""
26+
}
27+
]
28+
}
29+
)
30+
},
831
CompletionItem {
932
completion_kind: Postfix,
1033
label: "if",

0 commit comments

Comments
 (0)