aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2019-07-22 19:52:47 +0100
committerKirill Bulatov <[email protected]>2019-07-22 21:25:13 +0100
commit8f3377d9f93a256f8e68ae183808fd767b529d18 (patch)
treea56a828eeba4301bbd816383abc8674a25996d85 /crates/ra_ide_api/src
parent25398ad30d6ffc07b3ca9ceee6a55f301973c155 (diff)
Code review fixes
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/inlay_hints.rs49
1 files changed, 20 insertions, 29 deletions
diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide_api/src/inlay_hints.rs
index 1b1f28951..174662beb 100644
--- a/crates/ra_ide_api/src/inlay_hints.rs
+++ b/crates/ra_ide_api/src/inlay_hints.rs
@@ -9,16 +9,15 @@ use ra_syntax::{
9 9
10#[derive(Debug, PartialEq, Eq)] 10#[derive(Debug, PartialEq, Eq)]
11pub enum InlayKind { 11pub enum InlayKind {
12 LetBinding, 12 LetBindingType,
13 ClosureParameter, 13 ClosureParameterType,
14} 14}
15 15
16#[derive(Debug)] 16#[derive(Debug)]
17pub struct InlayHint { 17pub struct InlayHint {
18 pub range: TextRange, 18 pub range: TextRange,
19 pub text: SmolStr, 19 pub kind: InlayKind,
20 pub inlay_kind: InlayKind, 20 pub label: SmolStr,
21 pub inlay_type_string: SmolStr,
22} 21}
23 22
24pub(crate) fn inlay_hints(db: &RootDatabase, file_id: FileId, file: &SourceFile) -> Vec<InlayHint> { 23pub(crate) fn inlay_hints(db: &RootDatabase, file_id: FileId, file: &SourceFile) -> Vec<InlayHint> {
@@ -56,9 +55,8 @@ fn get_inlay_hints(
56 55
57 Some(vec![InlayHint { 56 Some(vec![InlayHint {
58 range: pat_range, 57 range: pat_range,
59 text: let_syntax.text().to_string().into(), 58 kind: InlayKind::LetBindingType,
60 inlay_kind: InlayKind::LetBinding, 59 label: inlay_type_string,
61 inlay_type_string,
62 }]) 60 }])
63 }) 61 })
64 .visit(|closure_parameter: ast::LambdaExpr| match closure_parameter.param_list() { 62 .visit(|closure_parameter: ast::LambdaExpr| match closure_parameter.param_list() {
@@ -80,9 +78,8 @@ fn get_inlay_hints(
80 78
81 Some(InlayHint { 79 Some(InlayHint {
82 range: closure_param_syntax.text_range(), 80 range: closure_param_syntax.text_range(),
83 text: closure_param_syntax.text().to_string().into(), 81 kind: InlayKind::ClosureParameterType,
84 inlay_kind: InlayKind::ClosureParameter, 82 label: inlay_type_string,
85 inlay_type_string,
86 }) 83 })
87 }) 84 })
88 .collect(), 85 .collect(),
@@ -149,39 +146,33 @@ fn main() {
149 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 146 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[
150 InlayHint { 147 InlayHint {
151 range: [71; 75), 148 range: [71; 75),
152 text: "let test = 54;", 149 kind: LetBindingType,
153 inlay_kind: LetBinding, 150 label: "i32",
154 inlay_type_string: "i32",
155 }, 151 },
156 InlayHint { 152 InlayHint {
157 range: [121; 125), 153 range: [121; 125),
158 text: "let test = OuterStruct {};", 154 kind: LetBindingType,
159 inlay_kind: LetBinding, 155 label: "OuterStruct",
160 inlay_type_string: "OuterStruct",
161 }, 156 },
162 InlayHint { 157 InlayHint {
163 range: [297; 305), 158 range: [297; 305),
164 text: "let mut test = 33;", 159 kind: LetBindingType,
165 inlay_kind: LetBinding, 160 label: "i32",
166 inlay_type_string: "i32",
167 }, 161 },
168 InlayHint { 162 InlayHint {
169 range: [417; 426), 163 range: [417; 426),
170 text: "let i_squared = i * i;", 164 kind: LetBindingType,
171 inlay_kind: LetBinding, 165 label: "u32",
172 inlay_type_string: "u32",
173 }, 166 },
174 InlayHint { 167 InlayHint {
175 range: [496; 502), 168 range: [496; 502),
176 text: "let (x, c) = (42, \'a\');", 169 kind: LetBindingType,
177 inlay_kind: LetBinding, 170 label: "(i32, char)",
178 inlay_type_string: "(i32, char)",
179 }, 171 },
180 InlayHint { 172 InlayHint {
181 range: [524; 528), 173 range: [524; 528),
182 text: "let test = (42, \'a\');", 174 kind: LetBindingType,
183 inlay_kind: LetBinding, 175 label: "(i32, char)",
184 inlay_type_string: "(i32, char)",
185 }, 176 },
186]"# 177]"#
187 ); 178 );