aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/inlay_hints.rs
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2019-07-21 18:51:27 +0100
committerKirill Bulatov <[email protected]>2019-07-21 18:51:27 +0100
commit24784c60df583d1807faa889a84312df1d2e3b22 (patch)
tree69fee254755a8db21a8ad55e894b3a26a3c9a2b0 /crates/ra_ide_api/src/inlay_hints.rs
parent201b344f2b0c9e84606115d135cd658d0a955d2c (diff)
Code review fixes
Diffstat (limited to 'crates/ra_ide_api/src/inlay_hints.rs')
-rw-r--r--crates/ra_ide_api/src/inlay_hints.rs64
1 files changed, 60 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide_api/src/inlay_hints.rs
index 4d1df65d0..739a44b19 100644
--- a/crates/ra_ide_api/src/inlay_hints.rs
+++ b/crates/ra_ide_api/src/inlay_hints.rs
@@ -61,7 +61,7 @@ fn get_inlay_hints(node: &SyntaxNode) -> Vec<InlayHint> {
61 } 61 }
62 }) 62 })
63 .accept(&node) 63 .accept(&node)
64 .unwrap_or_else(Vec::new) 64 .unwrap_or_default()
65} 65}
66 66
67#[cfg(test)] 67#[cfg(test)]
@@ -93,7 +93,7 @@ fn main() {
93 let i_squared = i * i; 93 let i_squared = i * i;
94 i_squared 94 i_squared
95 }); 95 });
96 96
97 let test: i32 = 33; 97 let test: i32 = 33;
98 98
99 let (x, c) = (42, 'a'); 99 let (x, c) = (42, 'a');
@@ -104,7 +104,63 @@ fn main() {
104 ) 104 )
105 .ok() 105 .ok()
106 .unwrap(); 106 .unwrap();
107 let hints = inlay_hints(&file); 107 assert_debug_snapshot_matches!(inlay_hints(&file), @r#"[
108 assert_debug_snapshot_matches!("inlay_hints", hints); 108 InlayHint {
109 range: [71; 75),
110 text: "let test = 54;",
111 inlay_kind: LetBinding,
112 },
113 InlayHint {
114 range: [90; 94),
115 text: "let test = InnerStruct {};",
116 inlay_kind: LetBinding,
117 },
118 InlayHint {
119 range: [121; 125),
120 text: "let test = OuterStruct {};",
121 inlay_kind: LetBinding,
122 },
123 InlayHint {
124 range: [152; 156),
125 text: "let test = vec![222];",
126 inlay_kind: LetBinding,
127 },
128 InlayHint {
129 range: [178; 186),
130 text: "let mut test = Vec::new();",
131 inlay_kind: LetBinding,
132 },
133 InlayHint {
134 range: [229; 233),
135 text: "let test = test.into_iter().map(|i| i * i).collect::<Vec<_>>();",
136 inlay_kind: LetBinding,
137 },
138 InlayHint {
139 range: [258; 259),
140 text: "i",
141 inlay_kind: ClosureParameter,
142 },
143 InlayHint {
144 range: [297; 305),
145 text: "let mut test = 33;",
146 inlay_kind: LetBinding,
147 },
148 InlayHint {
149 range: [417; 426),
150 text: "let i_squared = i * i;",
151 inlay_kind: LetBinding,
152 },
153 InlayHint {
154 range: [496; 502),
155 text: "let (x, c) = (42, \'a\');",
156 inlay_kind: LetBinding,
157 },
158 InlayHint {
159 range: [524; 528),
160 text: "let test = (42, \'a\');",
161 inlay_kind: LetBinding,
162 },
163]"#
164 );
109 } 165 }
110} 166}