add postfix completion for dbg!() with .dbg

This commit is contained in:
Hoàng Đức Hiếu 2019-02-02 22:10:18 +07:00
parent da3802b2ce
commit 1c5a63e3db
5 changed files with 212 additions and 6 deletions

View file

@ -42,6 +42,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
)
.add_to(acc);
postfix_snippet(ctx, "while", &format!("while {} {{\n$0\n}}", receiver_text)).add_to(acc);
postfix_snippet(ctx, "dbg", &format!("dbg!({})", receiver_text)).add_to(acc);
}
}
@ -92,4 +93,17 @@ mod tests {
"#,
);
}
#[test]
fn test_filter_postfix_completion4() {
check_snippet_completion(
"filter_postfix_completion4",
r#"
fn main() {
let bar = "a";
bar.dbg<|>
}
"#,
);
}
}

View file

@ -1,10 +1,33 @@
---
created: "2019-01-27T19:56:59.944118550+00:00"
creator: insta@0.5.2
created: "2019-02-02T15:08:34.016389802+00:00"
creator: insta@0.5.3
expression: kind_completions
source: crates/ra_ide_api/src/completion/completion_item.rs
---
[
CompletionItem {
completion_kind: Postfix,
label: "dbg",
kind: None,
detail: None,
documentation: None,
lookup: None,
insert_text: Some(
"dbg!(bar)"
),
insert_text_format: Snippet,
source_range: [76; 76),
text_edit: Some(
TextEdit {
atoms: [
AtomTextEdit {
delete: [72; 76),
insert: ""
}
]
}
)
},
CompletionItem {
completion_kind: Postfix,
label: "if",

View file

@ -1,10 +1,33 @@
---
created: "2019-01-27T19:56:59.942831213+00:00"
creator: insta@0.5.2
created: "2019-02-02T15:08:34.016388824+00:00"
creator: insta@0.5.3
expression: kind_completions
source: crates/ra_ide_api/src/completion/completion_item.rs
---
[
CompletionItem {
completion_kind: Postfix,
label: "dbg",
kind: None,
detail: None,
documentation: None,
lookup: None,
insert_text: Some(
"dbg!(bar)"
),
insert_text_format: Snippet,
source_range: [76; 77),
text_edit: Some(
TextEdit {
atoms: [
AtomTextEdit {
delete: [72; 76),
insert: ""
}
]
}
)
},
CompletionItem {
completion_kind: Postfix,
label: "if",

View file

@ -1,10 +1,33 @@
---
created: "2019-01-27T19:56:59.944615925+00:00"
creator: insta@0.5.2
created: "2019-02-02T15:08:34.060136941+00:00"
creator: insta@0.5.3
expression: kind_completions
source: crates/ra_ide_api/src/completion/completion_item.rs
---
[
CompletionItem {
completion_kind: Postfix,
label: "dbg",
kind: None,
detail: None,
documentation: None,
lookup: None,
insert_text: Some(
"dbg!(bar)"
),
insert_text_format: Snippet,
source_range: [78; 78),
text_edit: Some(
TextEdit {
atoms: [
AtomTextEdit {
delete: [72; 78),
insert: ""
}
]
}
)
},
CompletionItem {
completion_kind: Postfix,
label: "if",

View file

@ -0,0 +1,123 @@
---
created: "2019-02-02T15:08:34.069147268+00:00"
creator: insta@0.5.3
expression: kind_completions
source: crates/ra_ide_api/src/completion/completion_item.rs
---
[
CompletionItem {
completion_kind: Postfix,
label: "dbg",
kind: None,
detail: None,
documentation: None,
lookup: None,
insert_text: Some(
"dbg!(bar)"
),
insert_text_format: Snippet,
source_range: [78; 78),
text_edit: Some(
TextEdit {
atoms: [
AtomTextEdit {
delete: [72; 78),
insert: ""
}
]
}
)
},
CompletionItem {
completion_kind: Postfix,
label: "if",
kind: None,
detail: None,
documentation: None,
lookup: None,
insert_text: Some(
"if bar {$0}"
),
insert_text_format: Snippet,
source_range: [78; 78),
text_edit: Some(
TextEdit {
atoms: [
AtomTextEdit {
delete: [72; 78),
insert: ""
}
]
}
)
},
CompletionItem {
completion_kind: Postfix,
label: "match",
kind: None,
detail: None,
documentation: None,
lookup: None,
insert_text: Some(
"match bar {\n${1:_} => {$0\\},\n}"
),
insert_text_format: Snippet,
source_range: [78; 78),
text_edit: Some(
TextEdit {
atoms: [
AtomTextEdit {
delete: [72; 78),
insert: ""
}
]
}
)
},
CompletionItem {
completion_kind: Postfix,
label: "not",
kind: None,
detail: None,
documentation: None,
lookup: None,
insert_text: Some(
"!bar"
),
insert_text_format: Snippet,
source_range: [78; 78),
text_edit: Some(
TextEdit {
atoms: [
AtomTextEdit {
delete: [72; 78),
insert: ""
}
]
}
)
},
CompletionItem {
completion_kind: Postfix,
label: "while",
kind: None,
detail: None,
documentation: None,
lookup: None,
insert_text: Some(
"while bar {\n$0\n}"
),
insert_text_format: Snippet,
source_range: [78; 78),
text_edit: Some(
TextEdit {
atoms: [
AtomTextEdit {
delete: [72; 78),
insert: ""
}
]
}
)
}
]