diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/completion/completion_item.rs | 15 | ||||
-rw-r--r-- | crates/ra_ide/src/completion/presentation.rs | 1 | ||||
-rw-r--r-- | crates/rust-analyzer/src/conv.rs | 10 |
3 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs index 61867c0ff..19bbb2517 100644 --- a/crates/ra_ide/src/completion/completion_item.rs +++ b/crates/ra_ide/src/completion/completion_item.rs | |||
@@ -47,6 +47,10 @@ pub struct CompletionItem { | |||
47 | 47 | ||
48 | /// Whether this item is marked as deprecated | 48 | /// Whether this item is marked as deprecated |
49 | deprecated: bool, | 49 | deprecated: bool, |
50 | |||
51 | /// If completing a function call, ask the editor to show parameter popup | ||
52 | /// after completion. | ||
53 | trigger_call_info: bool, | ||
50 | } | 54 | } |
51 | 55 | ||
52 | // We use custom debug for CompletionItem to make `insta`'s diffs more readable. | 56 | // We use custom debug for CompletionItem to make `insta`'s diffs more readable. |
@@ -139,6 +143,7 @@ impl CompletionItem { | |||
139 | kind: None, | 143 | kind: None, |
140 | text_edit: None, | 144 | text_edit: None, |
141 | deprecated: None, | 145 | deprecated: None, |
146 | trigger_call_info: None, | ||
142 | } | 147 | } |
143 | } | 148 | } |
144 | /// What user sees in pop-up in the UI. | 149 | /// What user sees in pop-up in the UI. |
@@ -177,6 +182,10 @@ impl CompletionItem { | |||
177 | pub fn deprecated(&self) -> bool { | 182 | pub fn deprecated(&self) -> bool { |
178 | self.deprecated | 183 | self.deprecated |
179 | } | 184 | } |
185 | |||
186 | pub fn trigger_call_info(&self) -> bool { | ||
187 | self.trigger_call_info | ||
188 | } | ||
180 | } | 189 | } |
181 | 190 | ||
182 | /// A helper to make `CompletionItem`s. | 191 | /// A helper to make `CompletionItem`s. |
@@ -193,6 +202,7 @@ pub(crate) struct Builder { | |||
193 | kind: Option<CompletionItemKind>, | 202 | kind: Option<CompletionItemKind>, |
194 | text_edit: Option<TextEdit>, | 203 | text_edit: Option<TextEdit>, |
195 | deprecated: Option<bool>, | 204 | deprecated: Option<bool>, |
205 | trigger_call_info: Option<bool>, | ||
196 | } | 206 | } |
197 | 207 | ||
198 | impl Builder { | 208 | impl Builder { |
@@ -221,6 +231,7 @@ impl Builder { | |||
221 | kind: self.kind, | 231 | kind: self.kind, |
222 | completion_kind: self.completion_kind, | 232 | completion_kind: self.completion_kind, |
223 | deprecated: self.deprecated.unwrap_or(false), | 233 | deprecated: self.deprecated.unwrap_or(false), |
234 | trigger_call_info: self.trigger_call_info.unwrap_or(false), | ||
224 | } | 235 | } |
225 | } | 236 | } |
226 | pub(crate) fn lookup_by(mut self, lookup: impl Into<String>) -> Builder { | 237 | pub(crate) fn lookup_by(mut self, lookup: impl Into<String>) -> Builder { |
@@ -271,6 +282,10 @@ impl Builder { | |||
271 | self.deprecated = Some(deprecated); | 282 | self.deprecated = Some(deprecated); |
272 | self | 283 | self |
273 | } | 284 | } |
285 | pub(crate) fn trigger_call_info(mut self) -> Builder { | ||
286 | self.trigger_call_info = Some(true); | ||
287 | self | ||
288 | } | ||
274 | } | 289 | } |
275 | 290 | ||
276 | impl<'a> Into<CompletionItem> for Builder { | 291 | impl<'a> Into<CompletionItem> for Builder { |
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 841d36c8f..d6196a5ce 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -221,6 +221,7 @@ impl Completions { | |||
221 | let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 { | 221 | let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 { |
222 | (format!("{}()$0", name), format!("{}()", name)) | 222 | (format!("{}()$0", name), format!("{}()", name)) |
223 | } else { | 223 | } else { |
224 | builder = builder.trigger_call_info(); | ||
224 | let snippet = if ctx | 225 | let snippet = if ctx |
225 | .db | 226 | .db |
226 | .feature_flags | 227 | .feature_flags |
diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs index eeeb33e8f..fe3b588e4 100644 --- a/crates/rust-analyzer/src/conv.rs +++ b/crates/rust-analyzer/src/conv.rs | |||
@@ -150,6 +150,16 @@ impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem { | |||
150 | additional_text_edits: Some(additional_text_edits), | 150 | additional_text_edits: Some(additional_text_edits), |
151 | documentation: self.documentation().map(|it| it.conv()), | 151 | documentation: self.documentation().map(|it| it.conv()), |
152 | deprecated: Some(self.deprecated()), | 152 | deprecated: Some(self.deprecated()), |
153 | command: if self.trigger_call_info() { | ||
154 | let cmd = lsp_types::Command { | ||
155 | title: "triggerParameterHints".into(), | ||
156 | command: "editor.action.triggerParameterHints".into(), | ||
157 | arguments: None, | ||
158 | }; | ||
159 | Some(cmd) | ||
160 | } else { | ||
161 | None | ||
162 | }, | ||
153 | ..Default::default() | 163 | ..Default::default() |
154 | }; | 164 | }; |
155 | 165 | ||