diff options
author | Aleksey Kladov <[email protected]> | 2019-01-10 18:38:04 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-10 18:38:04 +0000 |
commit | faa1d35cbc29be23667319628e4034348ea50fe9 (patch) | |
tree | 195ec048e65baba519213a0a9c9b0143de555376 /crates/ra_ide_api/src/completion/completion_context.rs | |
parent | f96312b8360040086a236279515d178bf26ffb14 (diff) |
dont complete () if they are already there
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_context.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_context.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 01786bb69..113f6c070 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs | |||
@@ -32,8 +32,8 @@ pub(super) struct CompletionContext<'a> { | |||
32 | pub(super) is_new_item: bool, | 32 | pub(super) is_new_item: bool, |
33 | /// The receiver if this is a field or method access, i.e. writing something.<|> | 33 | /// The receiver if this is a field or method access, i.e. writing something.<|> |
34 | pub(super) dot_receiver: Option<&'a ast::Expr>, | 34 | pub(super) dot_receiver: Option<&'a ast::Expr>, |
35 | /// If this is a method call in particular, i.e. the () are already there. | 35 | /// If this is a call (method or function) in particular, i.e. the () are already there. |
36 | pub(super) is_method_call: bool, | 36 | pub(super) is_call: bool, |
37 | } | 37 | } |
38 | 38 | ||
39 | impl<'a> CompletionContext<'a> { | 39 | impl<'a> CompletionContext<'a> { |
@@ -60,7 +60,7 @@ impl<'a> CompletionContext<'a> { | |||
60 | can_be_stmt: false, | 60 | can_be_stmt: false, |
61 | is_new_item: false, | 61 | is_new_item: false, |
62 | dot_receiver: None, | 62 | dot_receiver: None, |
63 | is_method_call: false, | 63 | is_call: false, |
64 | }; | 64 | }; |
65 | ctx.fill(original_file, position.offset); | 65 | ctx.fill(original_file, position.offset); |
66 | Ok(Some(ctx)) | 66 | Ok(Some(ctx)) |
@@ -172,6 +172,12 @@ impl<'a> CompletionContext<'a> { | |||
172 | } | 172 | } |
173 | } | 173 | } |
174 | } | 174 | } |
175 | self.is_call = path | ||
176 | .syntax() | ||
177 | .parent() | ||
178 | .and_then(ast::PathExpr::cast) | ||
179 | .and_then(|it| it.syntax().parent().and_then(ast::CallExpr::cast)) | ||
180 | .is_some() | ||
175 | } | 181 | } |
176 | if let Some(field_expr) = ast::FieldExpr::cast(parent) { | 182 | if let Some(field_expr) = ast::FieldExpr::cast(parent) { |
177 | // The receiver comes before the point of insertion of the fake | 183 | // The receiver comes before the point of insertion of the fake |
@@ -187,7 +193,7 @@ impl<'a> CompletionContext<'a> { | |||
187 | .expr() | 193 | .expr() |
188 | .map(|e| e.syntax().range()) | 194 | .map(|e| e.syntax().range()) |
189 | .and_then(|r| find_node_with_range(original_file.syntax(), r)); | 195 | .and_then(|r| find_node_with_range(original_file.syntax(), r)); |
190 | self.is_method_call = true; | 196 | self.is_call = true; |
191 | } | 197 | } |
192 | } | 198 | } |
193 | } | 199 | } |