aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/completion/completion_context.rs
diff options
context:
space:
mode:
authorIgor Aleksanov <[email protected]>2020-09-12 15:14:17 +0100
committerIgor Aleksanov <[email protected]>2020-10-02 10:42:39 +0100
commitea320141c6f87383880878b91182355c9ad7dc7b (patch)
tree50e1ee50690c1ecea60caa01d6c6f7fbee983bfc /crates/ide/src/completion/completion_context.rs
parentc01cd6e3ed0763f8e773c34dc76db0e39396133d (diff)
Add postfix completion for format-like string literals
Diffstat (limited to 'crates/ide/src/completion/completion_context.rs')
-rw-r--r--crates/ide/src/completion/completion_context.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs
index 671b13328..842d1987c 100644
--- a/crates/ide/src/completion/completion_context.rs
+++ b/crates/ide/src/completion/completion_context.rs
@@ -74,6 +74,8 @@ pub(crate) struct CompletionContext<'a> {
74 pub(super) is_pattern_call: bool, 74 pub(super) is_pattern_call: bool,
75 /// If this is a macro call, i.e. the () are already there. 75 /// If this is a macro call, i.e. the () are already there.
76 pub(super) is_macro_call: bool, 76 pub(super) is_macro_call: bool,
77 /// If this is a string literal, like "lorem ipsum".
78 pub(super) is_string_literal: bool,
77 pub(super) is_path_type: bool, 79 pub(super) is_path_type: bool,
78 pub(super) has_type_args: bool, 80 pub(super) has_type_args: bool,
79 pub(super) attribute_under_caret: Option<ast::Attr>, 81 pub(super) attribute_under_caret: Option<ast::Attr>,
@@ -156,6 +158,7 @@ impl<'a> CompletionContext<'a> {
156 is_call: false, 158 is_call: false,
157 is_pattern_call: false, 159 is_pattern_call: false,
158 is_macro_call: false, 160 is_macro_call: false,
161 is_string_literal: false,
159 is_path_type: false, 162 is_path_type: false,
160 has_type_args: false, 163 has_type_args: false,
161 dot_receiver_is_ambiguous_float_literal: false, 164 dot_receiver_is_ambiguous_float_literal: false,
@@ -469,7 +472,13 @@ impl<'a> CompletionContext<'a> {
469 } 472 }
470 } else { 473 } else {
471 false 474 false
472 } 475 };
476
477 self.is_string_literal = if let Some(ast::Expr::Literal(l)) = &self.dot_receiver {
478 matches!(l.kind(), ast::LiteralKind::String { .. })
479 } else {
480 false
481 };
473 } 482 }
474 if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) { 483 if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) {
475 // As above 484 // As above