aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/completion_item.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_item.rs')
-rw-r--r--crates/ra_ide_api/src/completion/completion_item.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs
index 5c9c44704..93f336370 100644
--- a/crates/ra_ide_api/src/completion/completion_item.rs
+++ b/crates/ra_ide_api/src/completion/completion_item.rs
@@ -44,6 +44,9 @@ pub struct CompletionItem {
44 /// Additional info to show in the UI pop up. 44 /// Additional info to show in the UI pop up.
45 detail: Option<String>, 45 detail: Option<String>,
46 documentation: Option<Documentation>, 46 documentation: Option<Documentation>,
47
48 /// Whether this item is marked as deprecated
49 deprecated: bool,
47} 50}
48 51
49// We use custom debug for CompletionItem to make `insta`'s diffs more readable. 52// We use custom debug for CompletionItem to make `insta`'s diffs more readable.
@@ -70,6 +73,9 @@ impl fmt::Debug for CompletionItem {
70 if let Some(documentation) = self.documentation() { 73 if let Some(documentation) = self.documentation() {
71 s.field("documentation", &documentation); 74 s.field("documentation", &documentation);
72 } 75 }
76 if self.deprecated {
77 s.field("deprecated", &true);
78 }
73 s.finish() 79 s.finish()
74 } 80 }
75} 81}
@@ -132,6 +138,7 @@ impl CompletionItem {
132 lookup: None, 138 lookup: None,
133 kind: None, 139 kind: None,
134 text_edit: None, 140 text_edit: None,
141 deprecated: None,
135 } 142 }
136 } 143 }
137 /// What user sees in pop-up in the UI. 144 /// What user sees in pop-up in the UI.
@@ -166,6 +173,10 @@ impl CompletionItem {
166 pub fn kind(&self) -> Option<CompletionItemKind> { 173 pub fn kind(&self) -> Option<CompletionItemKind> {
167 self.kind 174 self.kind
168 } 175 }
176
177 pub fn deprecated(&self) -> bool {
178 self.deprecated
179 }
169} 180}
170 181
171/// A helper to make `CompletionItem`s. 182/// A helper to make `CompletionItem`s.
@@ -181,6 +192,7 @@ pub(crate) struct Builder {
181 lookup: Option<String>, 192 lookup: Option<String>,
182 kind: Option<CompletionItemKind>, 193 kind: Option<CompletionItemKind>,
183 text_edit: Option<TextEdit>, 194 text_edit: Option<TextEdit>,
195 deprecated: Option<bool>,
184} 196}
185 197
186impl Builder { 198impl Builder {
@@ -208,6 +220,7 @@ impl Builder {
208 lookup: self.lookup, 220 lookup: self.lookup,
209 kind: self.kind, 221 kind: self.kind,
210 completion_kind: self.completion_kind, 222 completion_kind: self.completion_kind,
223 deprecated: self.deprecated.unwrap_or(false),
211 } 224 }
212 } 225 }
213 pub(crate) fn lookup_by(mut self, lookup: impl Into<String>) -> Builder { 226 pub(crate) fn lookup_by(mut self, lookup: impl Into<String>) -> Builder {
@@ -254,6 +267,10 @@ impl Builder {
254 self.documentation = docs.map(Into::into); 267 self.documentation = docs.map(Into::into);
255 self 268 self
256 } 269 }
270 pub(crate) fn set_deprecated(mut self, deprecated: bool) -> Builder {
271 self.deprecated = Some(deprecated);
272 self
273 }
257} 274}
258 275
259impl<'a> Into<CompletionItem> for Builder { 276impl<'a> Into<CompletionItem> for Builder {