diff options
author | Benjamin Coenen <[email protected]> | 2020-11-21 14:06:22 +0000 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-11-21 14:06:22 +0000 |
commit | 775c69183cd6c7a2a5c9f27e23e4f4b7bc67f06f (patch) | |
tree | 394e35486f76d44aa5270774f8c0020fa5acb255 | |
parent | cadf0e9fb630d04367ef2611383865963d84ab54 (diff) |
add let and letm postfix to turn expressions into variables
Signed-off-by: Benjamin Coenen <[email protected]>
-rw-r--r-- | crates/completion/src/completions/postfix.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/completion/src/completions/postfix.rs b/crates/completion/src/completions/postfix.rs index 7fbda7a6b..b4fac74a0 100644 --- a/crates/completion/src/completions/postfix.rs +++ b/crates/completion/src/completions/postfix.rs | |||
@@ -220,6 +220,18 @@ pub(crate) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { | |||
220 | ) | 220 | ) |
221 | .add_to(acc); | 221 | .add_to(acc); |
222 | 222 | ||
223 | postfix_snippet(ctx, cap, &dot_receiver, "let", "let", &format!("let $0 = {};", receiver_text)) | ||
224 | .add_to(acc); | ||
225 | postfix_snippet( | ||
226 | ctx, | ||
227 | cap, | ||
228 | &dot_receiver, | ||
229 | "letm", | ||
230 | "let mut", | ||
231 | &format!("let mut $0 = {};", receiver_text), | ||
232 | ) | ||
233 | .add_to(acc); | ||
234 | |||
223 | if let ast::Expr::Literal(literal) = dot_receiver.clone() { | 235 | if let ast::Expr::Literal(literal) = dot_receiver.clone() { |
224 | if let Some(literal_text) = ast::String::cast(literal.token()) { | 236 | if let Some(literal_text) = ast::String::cast(literal.token()) { |
225 | add_format_like_completions(acc, ctx, &dot_receiver, cap, &literal_text); | 237 | add_format_like_completions(acc, ctx, &dot_receiver, cap, &literal_text); |
@@ -296,6 +308,8 @@ fn main() { | |||
296 | sn dbg dbg!(expr) | 308 | sn dbg dbg!(expr) |
297 | sn dbgr dbg!(&expr) | 309 | sn dbgr dbg!(&expr) |
298 | sn if if expr {} | 310 | sn if if expr {} |
311 | sn let let | ||
312 | sn letm let mut | ||
299 | sn match match expr {} | 313 | sn match match expr {} |
300 | sn not !expr | 314 | sn not !expr |
301 | sn ok Ok(expr) | 315 | sn ok Ok(expr) |
@@ -321,6 +335,8 @@ fn main() { | |||
321 | sn call function(expr) | 335 | sn call function(expr) |
322 | sn dbg dbg!(expr) | 336 | sn dbg dbg!(expr) |
323 | sn dbgr dbg!(&expr) | 337 | sn dbgr dbg!(&expr) |
338 | sn let let | ||
339 | sn letm let mut | ||
324 | sn match match expr {} | 340 | sn match match expr {} |
325 | sn ok Ok(expr) | 341 | sn ok Ok(expr) |
326 | sn ref &expr | 342 | sn ref &expr |