aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/render/function.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/render/function.rs')
-rw-r--r--crates/ide_completion/src/render/function.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs
index e46e21d24..f4dabe3d1 100644
--- a/crates/ide_completion/src/render/function.rs
+++ b/crates/ide_completion/src/render/function.rs
@@ -3,7 +3,6 @@
3use hir::{HasSource, HirDisplay, Type}; 3use hir::{HasSource, HirDisplay, Type};
4use ide_db::SymbolKind; 4use ide_db::SymbolKind;
5use syntax::ast::Fn; 5use syntax::ast::Fn;
6use test_utils::mark;
7 6
8use crate::{ 7use crate::{
9 item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit}, 8 item::{CompletionItem, CompletionItemKind, CompletionKind, ImportEdit},
@@ -42,16 +41,21 @@ impl<'a> FunctionRender<'a> {
42 41
43 fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem { 42 fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem {
44 let params = self.params(); 43 let params = self.params();
45 CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), self.name.clone()) 44 let mut item = CompletionItem::new(
46 .kind(self.kind()) 45 CompletionKind::Reference,
46 self.ctx.source_range(),
47 self.name.clone(),
48 );
49 item.kind(self.kind())
47 .set_documentation(self.ctx.docs(self.func)) 50 .set_documentation(self.ctx.docs(self.func))
48 .set_deprecated( 51 .set_deprecated(
49 self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func), 52 self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func),
50 ) 53 )
51 .detail(self.detail()) 54 .detail(self.detail())
52 .add_call_parens(self.ctx.completion, self.name, params) 55 .add_call_parens(self.ctx.completion, self.name, params)
53 .add_import(import_to_add) 56 .add_import(import_to_add);
54 .build() 57
58 item.build()
55 } 59 }
56 60
57 fn detail(&self) -> String { 61 fn detail(&self) -> String {
@@ -82,7 +86,7 @@ impl<'a> FunctionRender<'a> {
82 self.func.method_params(self.ctx.db()).unwrap_or_default() 86 self.func.method_params(self.ctx.db()).unwrap_or_default()
83 } else { 87 } else {
84 if let Some(s) = ast_params.self_param() { 88 if let Some(s) = ast_params.self_param() {
85 mark::hit!(parens_for_method_call_as_assoc_fn); 89 cov_mark::hit!(parens_for_method_call_as_assoc_fn);
86 params_pats.push(Some(s.to_string())); 90 params_pats.push(Some(s.to_string()));
87 } 91 }
88 self.func.assoc_fn_params(self.ctx.db()) 92 self.func.assoc_fn_params(self.ctx.db())
@@ -114,8 +118,6 @@ impl<'a> FunctionRender<'a> {
114 118
115#[cfg(test)] 119#[cfg(test)]
116mod tests { 120mod tests {
117 use test_utils::mark;
118
119 use crate::{ 121 use crate::{
120 test_utils::{check_edit, check_edit_with_config, TEST_CONFIG}, 122 test_utils::{check_edit, check_edit_with_config, TEST_CONFIG},
121 CompletionConfig, 123 CompletionConfig,
@@ -123,7 +125,7 @@ mod tests {
123 125
124 #[test] 126 #[test]
125 fn inserts_parens_for_function_calls() { 127 fn inserts_parens_for_function_calls() {
126 mark::check!(inserts_parens_for_function_calls); 128 cov_mark::check!(inserts_parens_for_function_calls);
127 check_edit( 129 check_edit(
128 "no_args", 130 "no_args",
129 r#" 131 r#"
@@ -191,7 +193,7 @@ fn bar(s: &S) {
191 193
192 #[test] 194 #[test]
193 fn parens_for_method_call_as_assoc_fn() { 195 fn parens_for_method_call_as_assoc_fn() {
194 mark::check!(parens_for_method_call_as_assoc_fn); 196 cov_mark::check!(parens_for_method_call_as_assoc_fn);
195 check_edit( 197 check_edit(
196 "foo", 198 "foo",
197 r#" 199 r#"
@@ -213,7 +215,7 @@ fn main() { S::foo(${1:&self})$0 }
213 215
214 #[test] 216 #[test]
215 fn suppress_arg_snippets() { 217 fn suppress_arg_snippets() {
216 mark::check!(suppress_arg_snippets); 218 cov_mark::check!(suppress_arg_snippets);
217 check_edit_with_config( 219 check_edit_with_config(
218 CompletionConfig { add_call_argument_snippets: false, ..TEST_CONFIG }, 220 CompletionConfig { add_call_argument_snippets: false, ..TEST_CONFIG },
219 "with_args", 221 "with_args",