aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/completion_item.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-23 13:21:20 +0000
committerAleksey Kladov <[email protected]>2019-01-23 13:21:20 +0000
commit71b9f06c89735b78439d0720e314b71969c17eb3 (patch)
tree407c0ed2edf70d73c78224a9934c4a8c9e7eac2c /crates/ra_ide_api/src/completion/completion_item.rs
parent2dbf58c579d6fe6a8acefcd9ae17eef7e984bca1 (diff)
don't insert parens for self methods
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_item.rs')
-rw-r--r--crates/ra_ide_api/src/completion/completion_item.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs
index 48be812a0..e3bf82304 100644
--- a/crates/ra_ide_api/src/completion/completion_item.rs
+++ b/crates/ra_ide_api/src/completion/completion_item.rs
@@ -257,7 +257,8 @@ impl Builder {
257 // If not an import, add parenthesis automatically. 257 // If not an import, add parenthesis automatically.
258 if ctx.use_item_syntax.is_none() && !ctx.is_call { 258 if ctx.use_item_syntax.is_none() && !ctx.is_call {
259 tested_by!(inserts_parens_for_function_calls); 259 tested_by!(inserts_parens_for_function_calls);
260 if function.signature(ctx.db).params().is_empty() { 260 let sig = function.signature(ctx.db);
261 if sig.params().is_empty() || sig.has_self_param() && sig.params().len() == 1 {
261 self.insert_text = Some(format!("{}()$0", self.label)); 262 self.insert_text = Some(format!("{}()$0", self.label));
262 } else { 263 } else {
263 self.insert_text = Some(format!("{}($0)", self.label)); 264 self.insert_text = Some(format!("{}($0)", self.label));
@@ -374,6 +375,18 @@ mod tests {
374 fn main() { with_<|> } 375 fn main() { with_<|> }
375 ", 376 ",
376 ); 377 );
378 check_reference_completion(
379 "inserts_parens_for_function_calls3",
380 r"
381 struct S {}
382 impl S {
383 fn foo(&self) {}
384 }
385 fn bar(s: &S) {
386 s.f<|>
387 }
388 ",
389 )
377 } 390 }
378 391
379 #[test] 392 #[test]