aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/completion_item.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/completion/completion_item.rs')
-rw-r--r--crates/ra_ide/src/completion/completion_item.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs
index 98348b349..7bdda316c 100644
--- a/crates/ra_ide/src/completion/completion_item.rs
+++ b/crates/ra_ide/src/completion/completion_item.rs
@@ -58,7 +58,7 @@ pub struct CompletionItem {
58 score: Option<CompletionScore>, 58 score: Option<CompletionScore>,
59} 59}
60 60
61// We use custom debug for CompletionItem to make `insta`'s diffs more readable. 61// We use custom debug for CompletionItem to make snapshot tests more readable.
62impl fmt::Debug for CompletionItem { 62impl fmt::Debug for CompletionItem {
63 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 63 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
64 let mut s = f.debug_struct("CompletionItem"); 64 let mut s = f.debug_struct("CompletionItem");
@@ -95,7 +95,7 @@ impl fmt::Debug for CompletionItem {
95 } 95 }
96} 96}
97 97
98#[derive(Debug, Clone, Copy)] 98#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq)]
99pub enum CompletionScore { 99pub enum CompletionScore {
100 /// If only type match 100 /// If only type match
101 TypeMatch, 101 TypeMatch,
@@ -123,30 +123,32 @@ pub enum CompletionItemKind {
123 TypeParam, 123 TypeParam,
124 Macro, 124 Macro,
125 Attribute, 125 Attribute,
126 UnresolvedReference,
126} 127}
127 128
128impl CompletionItemKind { 129impl CompletionItemKind {
129 #[cfg(test)] 130 #[cfg(test)]
130 pub(crate) fn tag(&self) -> &'static str { 131 pub(crate) fn tag(&self) -> &'static str {
131 match self { 132 match self {
132 CompletionItemKind::Snippet => "sn", 133 CompletionItemKind::Attribute => "at",
133 CompletionItemKind::Keyword => "kw", 134 CompletionItemKind::Binding => "bn",
134 CompletionItemKind::Module => "md",
135 CompletionItemKind::Function => "fn",
136 CompletionItemKind::BuiltinType => "bt", 135 CompletionItemKind::BuiltinType => "bt",
137 CompletionItemKind::Struct => "st", 136 CompletionItemKind::Const => "ct",
138 CompletionItemKind::Enum => "en", 137 CompletionItemKind::Enum => "en",
139 CompletionItemKind::EnumVariant => "ev", 138 CompletionItemKind::EnumVariant => "ev",
140 CompletionItemKind::Binding => "bn",
141 CompletionItemKind::Field => "fd", 139 CompletionItemKind::Field => "fd",
140 CompletionItemKind::Function => "fn",
141 CompletionItemKind::Keyword => "kw",
142 CompletionItemKind::Macro => "ma",
143 CompletionItemKind::Method => "me",
144 CompletionItemKind::Module => "md",
145 CompletionItemKind::Snippet => "sn",
142 CompletionItemKind::Static => "sc", 146 CompletionItemKind::Static => "sc",
143 CompletionItemKind::Const => "ct", 147 CompletionItemKind::Struct => "st",
144 CompletionItemKind::Trait => "tt", 148 CompletionItemKind::Trait => "tt",
145 CompletionItemKind::TypeAlias => "ta", 149 CompletionItemKind::TypeAlias => "ta",
146 CompletionItemKind::Method => "me",
147 CompletionItemKind::TypeParam => "tp", 150 CompletionItemKind::TypeParam => "tp",
148 CompletionItemKind::Macro => "ma", 151 CompletionItemKind::UnresolvedReference => "??",
149 CompletionItemKind::Attribute => "at",
150 } 152 }
151 } 153 }
152} 154}