aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-09 18:55:44 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-09 18:55:44 +0100
commit2fc2d4373b2c4e96bebf320a84270eee3afe34aa (patch)
tree5bdb33ae377b4004f0b28ec5e2edff71b41e8c4e /crates/ra_ide_api/src/completion
parent5f700179fc7ed16d2848a6dbc7cf23da3b8df6c7 (diff)
parent45a2b9252401cc580dfa2e0e761313cc8334d47c (diff)
Merge #1110
1110: Introduce display module and implement new FunctionSignature for CallInfo's r=matklad a=vipentti This introduces a new module `display` in `ra_ide_api` that contains UI-related things, in addition this refactors CallInfo's function signatures into a new `FunctionSignature` type, which implements `Display` and can be converted into `lsp_types::SignatureInformation` in the `conv` layer. Currently only `CallInfo` uses the `FunctionSignature` directly, but `function_label` now uses the same signature and returns it as a string, using the `Display` implementation. This also fixes #960 I think this similar structure could be applied to other UI-displayable items, so instead of the `ra_ide_api` returning `Strings` we could return some intermediate structures that can be converted into a UI-displayable `String` easily, but that could also provide some additional information. Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion')
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs2
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs5
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap14
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap6
4 files changed, 15 insertions, 12 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 6146b7bb6..9d82f2270 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -145,7 +145,7 @@ mod tests {
145 check_reference_completion( 145 check_reference_completion(
146 "dont_show_both_completions_for_shadowing", 146 "dont_show_both_completions_for_shadowing",
147 r" 147 r"
148 fn foo() -> { 148 fn foo() {
149 let bar = 92; 149 let bar = 92;
150 { 150 {
151 let bar = 62; 151 let bar = 62;
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index 28c8f83ab..9aa346688 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -6,6 +6,9 @@ use ra_syntax::ast::NameOwner;
6 6
7use crate::completion::{ 7use crate::completion::{
8 Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem, 8 Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem,
9};
10
11use crate::display::{
9 function_label, const_label, type_label, 12 function_label, const_label, type_label,
10}; 13};
11 14
@@ -101,7 +104,7 @@ impl Completions {
101 CompletionItemKind::Function 104 CompletionItemKind::Function
102 }) 105 })
103 .set_documentation(func.docs(ctx.db)) 106 .set_documentation(func.docs(ctx.db))
104 .set_detail(detail); 107 .detail(detail);
105 // If not an import, add parenthesis automatically. 108 // If not an import, add parenthesis automatically.
106 if ctx.use_item_syntax.is_none() && !ctx.is_call { 109 if ctx.use_item_syntax.is_none() && !ctx.is_call {
107 tested_by!(inserts_parens_for_function_calls); 110 tested_by!(inserts_parens_for_function_calls);
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap
index 87691b304..34adcda6c 100644
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap
+++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__dont_show_both_completions_for_shadowing.snap
@@ -1,23 +1,23 @@
1--- 1---
2created: "2019-02-18T09:22:24.188564584Z" 2created: "2019-04-04T14:52:24.531844100Z"
3creator: insta@0.6.2 3creator: insta@0.7.4
4source: crates/ra_ide_api/src/completion/completion_item.rs 4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions 5expression: kind_completions
6--- 6---
7[ 7[
8 CompletionItem { 8 CompletionItem {
9 label: "bar", 9 label: "bar",
10 source_range: [129; 129), 10 source_range: [126; 126),
11 delete: [129; 129), 11 delete: [126; 126),
12 insert: "bar", 12 insert: "bar",
13 kind: Binding 13 kind: Binding
14 }, 14 },
15 CompletionItem { 15 CompletionItem {
16 label: "foo", 16 label: "foo",
17 source_range: [129; 129), 17 source_range: [126; 126),
18 delete: [129; 129), 18 delete: [126; 126),
19 insert: "foo()$0", 19 insert: "foo()$0",
20 kind: Function, 20 kind: Function,
21 detail: "fn foo() ->" 21 detail: "fn foo()"
22 } 22 }
23] 23]
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap
index 0738cf466..ff36df707 100644
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap
+++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__return_type.snap
@@ -1,6 +1,6 @@
1--- 1---
2created: "2019-02-18T09:22:24.182964414Z" 2created: "2019-04-04T14:52:24.525395600Z"
3creator: insta@0.6.2 3creator: insta@0.7.4
4source: crates/ra_ide_api/src/completion/completion_item.rs 4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions 5expression: kind_completions
6--- 6---
@@ -18,6 +18,6 @@ expression: kind_completions
18 delete: [47; 47), 18 delete: [47; 47),
19 insert: "x()$0", 19 insert: "x()$0",
20 kind: Function, 20 kind: Function,
21 detail: "fn x() ->" 21 detail: "fn x()"
22 } 22 }
23] 23]