diff options
Diffstat (limited to 'crates/ra_ide/src')
41 files changed, 1294 insertions, 1337 deletions
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index b00b6d431..85d1f0cb1 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs | |||
@@ -183,8 +183,8 @@ mod tests { | |||
183 | call<|>ee(); | 183 | call<|>ee(); |
184 | } | 184 | } |
185 | "#, | 185 | "#, |
186 | "callee FN_DEF FileId(1) [0; 14) [3; 9)", | 186 | "callee FN_DEF FileId(1) 0..14 3..9", |
187 | &["caller FN_DEF FileId(1) [15; 44) [18; 24) : [[33; 39)]"], | 187 | &["caller FN_DEF FileId(1) 15..44 18..24 : [33..39]"], |
188 | &[], | 188 | &[], |
189 | ); | 189 | ); |
190 | } | 190 | } |
@@ -199,8 +199,8 @@ mod tests { | |||
199 | callee(); | 199 | callee(); |
200 | } | 200 | } |
201 | "#, | 201 | "#, |
202 | "callee FN_DEF FileId(1) [0; 14) [3; 9)", | 202 | "callee FN_DEF FileId(1) 0..14 3..9", |
203 | &["caller FN_DEF FileId(1) [15; 44) [18; 24) : [[33; 39)]"], | 203 | &["caller FN_DEF FileId(1) 15..44 18..24 : [33..39]"], |
204 | &[], | 204 | &[], |
205 | ); | 205 | ); |
206 | } | 206 | } |
@@ -216,8 +216,8 @@ mod tests { | |||
216 | callee(); | 216 | callee(); |
217 | } | 217 | } |
218 | "#, | 218 | "#, |
219 | "callee FN_DEF FileId(1) [0; 14) [3; 9)", | 219 | "callee FN_DEF FileId(1) 0..14 3..9", |
220 | &["caller FN_DEF FileId(1) [15; 58) [18; 24) : [[33; 39), [47; 53)]"], | 220 | &["caller FN_DEF FileId(1) 15..58 18..24 : [33..39, 47..53]"], |
221 | &[], | 221 | &[], |
222 | ); | 222 | ); |
223 | } | 223 | } |
@@ -236,10 +236,10 @@ mod tests { | |||
236 | callee(); | 236 | callee(); |
237 | } | 237 | } |
238 | "#, | 238 | "#, |
239 | "callee FN_DEF FileId(1) [0; 14) [3; 9)", | 239 | "callee FN_DEF FileId(1) 0..14 3..9", |
240 | &[ | 240 | &[ |
241 | "caller1 FN_DEF FileId(1) [15; 45) [18; 25) : [[34; 40)]", | 241 | "caller1 FN_DEF FileId(1) 15..45 18..25 : [34..40]", |
242 | "caller2 FN_DEF FileId(1) [46; 76) [49; 56) : [[65; 71)]", | 242 | "caller2 FN_DEF FileId(1) 46..76 49..56 : [65..71]", |
243 | ], | 243 | ], |
244 | &[], | 244 | &[], |
245 | ); | 245 | ); |
@@ -260,8 +260,8 @@ mod tests { | |||
260 | //- /foo/mod.rs | 260 | //- /foo/mod.rs |
261 | pub fn callee() {} | 261 | pub fn callee() {} |
262 | "#, | 262 | "#, |
263 | "callee FN_DEF FileId(2) [0; 18) [7; 13)", | 263 | "callee FN_DEF FileId(2) 0..18 7..13", |
264 | &["caller FN_DEF FileId(1) [26; 55) [29; 35) : [[44; 50)]"], | 264 | &["caller FN_DEF FileId(1) 26..55 29..35 : [44..50]"], |
265 | &[], | 265 | &[], |
266 | ); | 266 | ); |
267 | } | 267 | } |
@@ -277,9 +277,9 @@ mod tests { | |||
277 | callee(); | 277 | callee(); |
278 | } | 278 | } |
279 | "#, | 279 | "#, |
280 | "caller FN_DEF FileId(1) [15; 58) [18; 24)", | 280 | "caller FN_DEF FileId(1) 15..58 18..24", |
281 | &[], | 281 | &[], |
282 | &["callee FN_DEF FileId(1) [0; 14) [3; 9) : [[33; 39), [47; 53)]"], | 282 | &["callee FN_DEF FileId(1) 0..14 3..9 : [33..39, 47..53]"], |
283 | ); | 283 | ); |
284 | } | 284 | } |
285 | 285 | ||
@@ -298,9 +298,9 @@ mod tests { | |||
298 | //- /foo/mod.rs | 298 | //- /foo/mod.rs |
299 | pub fn callee() {} | 299 | pub fn callee() {} |
300 | "#, | 300 | "#, |
301 | "caller FN_DEF FileId(1) [26; 55) [29; 35)", | 301 | "caller FN_DEF FileId(1) 26..55 29..35", |
302 | &[], | 302 | &[], |
303 | &["callee FN_DEF FileId(2) [0; 18) [7; 13) : [[44; 50)]"], | 303 | &["callee FN_DEF FileId(2) 0..18 7..13 : [44..50]"], |
304 | ); | 304 | ); |
305 | } | 305 | } |
306 | 306 | ||
@@ -321,9 +321,9 @@ mod tests { | |||
321 | 321 | ||
322 | } | 322 | } |
323 | "#, | 323 | "#, |
324 | "caller2 FN_DEF FileId(1) [32; 63) [35; 42)", | 324 | "caller2 FN_DEF FileId(1) 32..63 35..42", |
325 | &["caller1 FN_DEF FileId(1) [0; 31) [3; 10) : [[19; 26)]"], | 325 | &["caller1 FN_DEF FileId(1) 0..31 3..10 : [19..26]"], |
326 | &["caller3 FN_DEF FileId(1) [64; 80) [67; 74) : [[51; 58)]"], | 326 | &["caller3 FN_DEF FileId(1) 64..80 67..74 : [51..58]"], |
327 | ); | 327 | ); |
328 | } | 328 | } |
329 | } | 329 | } |
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index 5da254a6e..780a03c13 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs | |||
@@ -126,7 +126,7 @@ impl FnCallNode { | |||
126 | ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), | 126 | ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), |
127 | ast::MethodCallExpr(it) => { | 127 | ast::MethodCallExpr(it) => { |
128 | let arg_list = it.arg_list()?; | 128 | let arg_list = it.arg_list()?; |
129 | if !syntax.text_range().is_subrange(&arg_list.syntax().text_range()) { | 129 | if !arg_list.syntax().text_range().contains_range(syntax.text_range()) { |
130 | return None; | 130 | return None; |
131 | } | 131 | } |
132 | Some(FnCallNode::MethodCallExpr(it)) | 132 | Some(FnCallNode::MethodCallExpr(it)) |
diff --git a/crates/ra_ide/src/completion/complete_attribute.rs b/crates/ra_ide/src/completion/complete_attribute.rs index b405042e8..8bf952798 100644 --- a/crates/ra_ide/src/completion/complete_attribute.rs +++ b/crates/ra_ide/src/completion/complete_attribute.rs | |||
@@ -147,190 +147,190 @@ mod tests { | |||
147 | [ | 147 | [ |
148 | CompletionItem { | 148 | CompletionItem { |
149 | label: "allow", | 149 | label: "allow", |
150 | source_range: [19; 19), | 150 | source_range: 19..19, |
151 | delete: [19; 19), | 151 | delete: 19..19, |
152 | insert: "allow(${0:lint})", | 152 | insert: "allow(${0:lint})", |
153 | kind: Attribute, | 153 | kind: Attribute, |
154 | }, | 154 | }, |
155 | CompletionItem { | 155 | CompletionItem { |
156 | label: "cfg", | 156 | label: "cfg", |
157 | source_range: [19; 19), | 157 | source_range: 19..19, |
158 | delete: [19; 19), | 158 | delete: 19..19, |
159 | insert: "cfg(${0:predicate})", | 159 | insert: "cfg(${0:predicate})", |
160 | kind: Attribute, | 160 | kind: Attribute, |
161 | }, | 161 | }, |
162 | CompletionItem { | 162 | CompletionItem { |
163 | label: "cfg_attr", | 163 | label: "cfg_attr", |
164 | source_range: [19; 19), | 164 | source_range: 19..19, |
165 | delete: [19; 19), | 165 | delete: 19..19, |
166 | insert: "cfg_attr(${1:predicate}, ${0:attr})", | 166 | insert: "cfg_attr(${1:predicate}, ${0:attr})", |
167 | kind: Attribute, | 167 | kind: Attribute, |
168 | }, | 168 | }, |
169 | CompletionItem { | 169 | CompletionItem { |
170 | label: "deny", | 170 | label: "deny", |
171 | source_range: [19; 19), | 171 | source_range: 19..19, |
172 | delete: [19; 19), | 172 | delete: 19..19, |
173 | insert: "deny(${0:lint})", | 173 | insert: "deny(${0:lint})", |
174 | kind: Attribute, | 174 | kind: Attribute, |
175 | }, | 175 | }, |
176 | CompletionItem { | 176 | CompletionItem { |
177 | label: "deprecated", | 177 | label: "deprecated", |
178 | source_range: [19; 19), | 178 | source_range: 19..19, |
179 | delete: [19; 19), | 179 | delete: 19..19, |
180 | insert: "deprecated = \"${0:reason}\"", | 180 | insert: "deprecated = \"${0:reason}\"", |
181 | kind: Attribute, | 181 | kind: Attribute, |
182 | }, | 182 | }, |
183 | CompletionItem { | 183 | CompletionItem { |
184 | label: "derive", | 184 | label: "derive", |
185 | source_range: [19; 19), | 185 | source_range: 19..19, |
186 | delete: [19; 19), | 186 | delete: 19..19, |
187 | insert: "derive(${0:Debug})", | 187 | insert: "derive(${0:Debug})", |
188 | kind: Attribute, | 188 | kind: Attribute, |
189 | }, | 189 | }, |
190 | CompletionItem { | 190 | CompletionItem { |
191 | label: "doc", | 191 | label: "doc", |
192 | source_range: [19; 19), | 192 | source_range: 19..19, |
193 | delete: [19; 19), | 193 | delete: 19..19, |
194 | insert: "doc = \"${0:docs}\"", | 194 | insert: "doc = \"${0:docs}\"", |
195 | kind: Attribute, | 195 | kind: Attribute, |
196 | }, | 196 | }, |
197 | CompletionItem { | 197 | CompletionItem { |
198 | label: "forbid", | 198 | label: "forbid", |
199 | source_range: [19; 19), | 199 | source_range: 19..19, |
200 | delete: [19; 19), | 200 | delete: 19..19, |
201 | insert: "forbid(${0:lint})", | 201 | insert: "forbid(${0:lint})", |
202 | kind: Attribute, | 202 | kind: Attribute, |
203 | }, | 203 | }, |
204 | CompletionItem { | 204 | CompletionItem { |
205 | label: "ignore", | 205 | label: "ignore", |
206 | source_range: [19; 19), | 206 | source_range: 19..19, |
207 | delete: [19; 19), | 207 | delete: 19..19, |
208 | insert: "ignore(${0:lint})", | 208 | insert: "ignore(${0:lint})", |
209 | kind: Attribute, | 209 | kind: Attribute, |
210 | }, | 210 | }, |
211 | CompletionItem { | 211 | CompletionItem { |
212 | label: "inline", | 212 | label: "inline", |
213 | source_range: [19; 19), | 213 | source_range: 19..19, |
214 | delete: [19; 19), | 214 | delete: 19..19, |
215 | insert: "inline(${0:lint})", | 215 | insert: "inline(${0:lint})", |
216 | kind: Attribute, | 216 | kind: Attribute, |
217 | }, | 217 | }, |
218 | CompletionItem { | 218 | CompletionItem { |
219 | label: "link", | 219 | label: "link", |
220 | source_range: [19; 19), | 220 | source_range: 19..19, |
221 | delete: [19; 19), | 221 | delete: 19..19, |
222 | insert: "link", | 222 | insert: "link", |
223 | kind: Attribute, | 223 | kind: Attribute, |
224 | }, | 224 | }, |
225 | CompletionItem { | 225 | CompletionItem { |
226 | label: "link_name", | 226 | label: "link_name", |
227 | source_range: [19; 19), | 227 | source_range: 19..19, |
228 | delete: [19; 19), | 228 | delete: 19..19, |
229 | insert: "link_name = \"${0:symbol_name}\"", | 229 | insert: "link_name = \"${0:symbol_name}\"", |
230 | kind: Attribute, | 230 | kind: Attribute, |
231 | }, | 231 | }, |
232 | CompletionItem { | 232 | CompletionItem { |
233 | label: "macro_export", | 233 | label: "macro_export", |
234 | source_range: [19; 19), | 234 | source_range: 19..19, |
235 | delete: [19; 19), | 235 | delete: 19..19, |
236 | insert: "macro_export", | 236 | insert: "macro_export", |
237 | kind: Attribute, | 237 | kind: Attribute, |
238 | }, | 238 | }, |
239 | CompletionItem { | 239 | CompletionItem { |
240 | label: "macro_use", | 240 | label: "macro_use", |
241 | source_range: [19; 19), | 241 | source_range: 19..19, |
242 | delete: [19; 19), | 242 | delete: 19..19, |
243 | insert: "macro_use", | 243 | insert: "macro_use", |
244 | kind: Attribute, | 244 | kind: Attribute, |
245 | }, | 245 | }, |
246 | CompletionItem { | 246 | CompletionItem { |
247 | label: "must_use", | 247 | label: "must_use", |
248 | source_range: [19; 19), | 248 | source_range: 19..19, |
249 | delete: [19; 19), | 249 | delete: 19..19, |
250 | insert: "must_use = \"${0:reason}\"", | 250 | insert: "must_use = \"${0:reason}\"", |
251 | kind: Attribute, | 251 | kind: Attribute, |
252 | }, | 252 | }, |
253 | CompletionItem { | 253 | CompletionItem { |
254 | label: "no_mangle", | 254 | label: "no_mangle", |
255 | source_range: [19; 19), | 255 | source_range: 19..19, |
256 | delete: [19; 19), | 256 | delete: 19..19, |
257 | insert: "no_mangle", | 257 | insert: "no_mangle", |
258 | kind: Attribute, | 258 | kind: Attribute, |
259 | }, | 259 | }, |
260 | CompletionItem { | 260 | CompletionItem { |
261 | label: "non_exhaustive", | 261 | label: "non_exhaustive", |
262 | source_range: [19; 19), | 262 | source_range: 19..19, |
263 | delete: [19; 19), | 263 | delete: 19..19, |
264 | insert: "non_exhaustive", | 264 | insert: "non_exhaustive", |
265 | kind: Attribute, | 265 | kind: Attribute, |
266 | }, | 266 | }, |
267 | CompletionItem { | 267 | CompletionItem { |
268 | label: "path", | 268 | label: "path", |
269 | source_range: [19; 19), | 269 | source_range: 19..19, |
270 | delete: [19; 19), | 270 | delete: 19..19, |
271 | insert: "path =\"${0:path}\"", | 271 | insert: "path =\"${0:path}\"", |
272 | kind: Attribute, | 272 | kind: Attribute, |
273 | }, | 273 | }, |
274 | CompletionItem { | 274 | CompletionItem { |
275 | label: "proc_macro", | 275 | label: "proc_macro", |
276 | source_range: [19; 19), | 276 | source_range: 19..19, |
277 | delete: [19; 19), | 277 | delete: 19..19, |
278 | insert: "proc_macro", | 278 | insert: "proc_macro", |
279 | kind: Attribute, | 279 | kind: Attribute, |
280 | }, | 280 | }, |
281 | CompletionItem { | 281 | CompletionItem { |
282 | label: "proc_macro_attribute", | 282 | label: "proc_macro_attribute", |
283 | source_range: [19; 19), | 283 | source_range: 19..19, |
284 | delete: [19; 19), | 284 | delete: 19..19, |
285 | insert: "proc_macro_attribute", | 285 | insert: "proc_macro_attribute", |
286 | kind: Attribute, | 286 | kind: Attribute, |
287 | }, | 287 | }, |
288 | CompletionItem { | 288 | CompletionItem { |
289 | label: "proc_macro_derive", | 289 | label: "proc_macro_derive", |
290 | source_range: [19; 19), | 290 | source_range: 19..19, |
291 | delete: [19; 19), | 291 | delete: 19..19, |
292 | insert: "proc_macro_derive(${0:Trait})", | 292 | insert: "proc_macro_derive(${0:Trait})", |
293 | kind: Attribute, | 293 | kind: Attribute, |
294 | }, | 294 | }, |
295 | CompletionItem { | 295 | CompletionItem { |
296 | label: "repr", | 296 | label: "repr", |
297 | source_range: [19; 19), | 297 | source_range: 19..19, |
298 | delete: [19; 19), | 298 | delete: 19..19, |
299 | insert: "repr(${0:C})", | 299 | insert: "repr(${0:C})", |
300 | kind: Attribute, | 300 | kind: Attribute, |
301 | }, | 301 | }, |
302 | CompletionItem { | 302 | CompletionItem { |
303 | label: "should_panic", | 303 | label: "should_panic", |
304 | source_range: [19; 19), | 304 | source_range: 19..19, |
305 | delete: [19; 19), | 305 | delete: 19..19, |
306 | insert: "expected = \"${0:reason}\"", | 306 | insert: "expected = \"${0:reason}\"", |
307 | kind: Attribute, | 307 | kind: Attribute, |
308 | }, | 308 | }, |
309 | CompletionItem { | 309 | CompletionItem { |
310 | label: "target_feature", | 310 | label: "target_feature", |
311 | source_range: [19; 19), | 311 | source_range: 19..19, |
312 | delete: [19; 19), | 312 | delete: 19..19, |
313 | insert: "target_feature = \"${0:feature}\"", | 313 | insert: "target_feature = \"${0:feature}\"", |
314 | kind: Attribute, | 314 | kind: Attribute, |
315 | }, | 315 | }, |
316 | CompletionItem { | 316 | CompletionItem { |
317 | label: "test", | 317 | label: "test", |
318 | source_range: [19; 19), | 318 | source_range: 19..19, |
319 | delete: [19; 19), | 319 | delete: 19..19, |
320 | insert: "test", | 320 | insert: "test", |
321 | kind: Attribute, | 321 | kind: Attribute, |
322 | }, | 322 | }, |
323 | CompletionItem { | 323 | CompletionItem { |
324 | label: "used", | 324 | label: "used", |
325 | source_range: [19; 19), | 325 | source_range: 19..19, |
326 | delete: [19; 19), | 326 | delete: 19..19, |
327 | insert: "used", | 327 | insert: "used", |
328 | kind: Attribute, | 328 | kind: Attribute, |
329 | }, | 329 | }, |
330 | CompletionItem { | 330 | CompletionItem { |
331 | label: "warn", | 331 | label: "warn", |
332 | source_range: [19; 19), | 332 | source_range: 19..19, |
333 | delete: [19; 19), | 333 | delete: 19..19, |
334 | insert: "warn(${0:lint})", | 334 | insert: "warn(${0:lint})", |
335 | kind: Attribute, | 335 | kind: Attribute, |
336 | }, | 336 | }, |
@@ -351,232 +351,232 @@ mod tests { | |||
351 | [ | 351 | [ |
352 | CompletionItem { | 352 | CompletionItem { |
353 | label: "allow", | 353 | label: "allow", |
354 | source_range: [20; 20), | 354 | source_range: 20..20, |
355 | delete: [20; 20), | 355 | delete: 20..20, |
356 | insert: "allow(${0:lint})", | 356 | insert: "allow(${0:lint})", |
357 | kind: Attribute, | 357 | kind: Attribute, |
358 | }, | 358 | }, |
359 | CompletionItem { | 359 | CompletionItem { |
360 | label: "cfg", | 360 | label: "cfg", |
361 | source_range: [20; 20), | 361 | source_range: 20..20, |
362 | delete: [20; 20), | 362 | delete: 20..20, |
363 | insert: "cfg(${0:predicate})", | 363 | insert: "cfg(${0:predicate})", |
364 | kind: Attribute, | 364 | kind: Attribute, |
365 | }, | 365 | }, |
366 | CompletionItem { | 366 | CompletionItem { |
367 | label: "cfg_attr", | 367 | label: "cfg_attr", |
368 | source_range: [20; 20), | 368 | source_range: 20..20, |
369 | delete: [20; 20), | 369 | delete: 20..20, |
370 | insert: "cfg_attr(${1:predicate}, ${0:attr})", | 370 | insert: "cfg_attr(${1:predicate}, ${0:attr})", |
371 | kind: Attribute, | 371 | kind: Attribute, |
372 | }, | 372 | }, |
373 | CompletionItem { | 373 | CompletionItem { |
374 | label: "deny", | 374 | label: "deny", |
375 | source_range: [20; 20), | 375 | source_range: 20..20, |
376 | delete: [20; 20), | 376 | delete: 20..20, |
377 | insert: "deny(${0:lint})", | 377 | insert: "deny(${0:lint})", |
378 | kind: Attribute, | 378 | kind: Attribute, |
379 | }, | 379 | }, |
380 | CompletionItem { | 380 | CompletionItem { |
381 | label: "deprecated", | 381 | label: "deprecated", |
382 | source_range: [20; 20), | 382 | source_range: 20..20, |
383 | delete: [20; 20), | 383 | delete: 20..20, |
384 | insert: "deprecated = \"${0:reason}\"", | 384 | insert: "deprecated = \"${0:reason}\"", |
385 | kind: Attribute, | 385 | kind: Attribute, |
386 | }, | 386 | }, |
387 | CompletionItem { | 387 | CompletionItem { |
388 | label: "derive", | 388 | label: "derive", |
389 | source_range: [20; 20), | 389 | source_range: 20..20, |
390 | delete: [20; 20), | 390 | delete: 20..20, |
391 | insert: "derive(${0:Debug})", | 391 | insert: "derive(${0:Debug})", |
392 | kind: Attribute, | 392 | kind: Attribute, |
393 | }, | 393 | }, |
394 | CompletionItem { | 394 | CompletionItem { |
395 | label: "doc", | 395 | label: "doc", |
396 | source_range: [20; 20), | 396 | source_range: 20..20, |
397 | delete: [20; 20), | 397 | delete: 20..20, |
398 | insert: "doc = \"${0:docs}\"", | 398 | insert: "doc = \"${0:docs}\"", |
399 | kind: Attribute, | 399 | kind: Attribute, |
400 | }, | 400 | }, |
401 | CompletionItem { | 401 | CompletionItem { |
402 | label: "feature", | 402 | label: "feature", |
403 | source_range: [20; 20), | 403 | source_range: 20..20, |
404 | delete: [20; 20), | 404 | delete: 20..20, |
405 | insert: "feature(${0:flag})", | 405 | insert: "feature(${0:flag})", |
406 | kind: Attribute, | 406 | kind: Attribute, |
407 | }, | 407 | }, |
408 | CompletionItem { | 408 | CompletionItem { |
409 | label: "forbid", | 409 | label: "forbid", |
410 | source_range: [20; 20), | 410 | source_range: 20..20, |
411 | delete: [20; 20), | 411 | delete: 20..20, |
412 | insert: "forbid(${0:lint})", | 412 | insert: "forbid(${0:lint})", |
413 | kind: Attribute, | 413 | kind: Attribute, |
414 | }, | 414 | }, |
415 | CompletionItem { | 415 | CompletionItem { |
416 | label: "global_allocator", | 416 | label: "global_allocator", |
417 | source_range: [20; 20), | 417 | source_range: 20..20, |
418 | delete: [20; 20), | 418 | delete: 20..20, |
419 | insert: "global_allocator", | 419 | insert: "global_allocator", |
420 | kind: Attribute, | 420 | kind: Attribute, |
421 | }, | 421 | }, |
422 | CompletionItem { | 422 | CompletionItem { |
423 | label: "ignore", | 423 | label: "ignore", |
424 | source_range: [20; 20), | 424 | source_range: 20..20, |
425 | delete: [20; 20), | 425 | delete: 20..20, |
426 | insert: "ignore(${0:lint})", | 426 | insert: "ignore(${0:lint})", |
427 | kind: Attribute, | 427 | kind: Attribute, |
428 | }, | 428 | }, |
429 | CompletionItem { | 429 | CompletionItem { |
430 | label: "inline", | 430 | label: "inline", |
431 | source_range: [20; 20), | 431 | source_range: 20..20, |
432 | delete: [20; 20), | 432 | delete: 20..20, |
433 | insert: "inline(${0:lint})", | 433 | insert: "inline(${0:lint})", |
434 | kind: Attribute, | 434 | kind: Attribute, |
435 | }, | 435 | }, |
436 | CompletionItem { | 436 | CompletionItem { |
437 | label: "link", | 437 | label: "link", |
438 | source_range: [20; 20), | 438 | source_range: 20..20, |
439 | delete: [20; 20), | 439 | delete: 20..20, |
440 | insert: "link", | 440 | insert: "link", |
441 | kind: Attribute, | 441 | kind: Attribute, |
442 | }, | 442 | }, |
443 | CompletionItem { | 443 | CompletionItem { |
444 | label: "link_name", | 444 | label: "link_name", |
445 | source_range: [20; 20), | 445 | source_range: 20..20, |
446 | delete: [20; 20), | 446 | delete: 20..20, |
447 | insert: "link_name = \"${0:symbol_name}\"", | 447 | insert: "link_name = \"${0:symbol_name}\"", |
448 | kind: Attribute, | 448 | kind: Attribute, |
449 | }, | 449 | }, |
450 | CompletionItem { | 450 | CompletionItem { |
451 | label: "macro_export", | 451 | label: "macro_export", |
452 | source_range: [20; 20), | 452 | source_range: 20..20, |
453 | delete: [20; 20), | 453 | delete: 20..20, |
454 | insert: "macro_export", | 454 | insert: "macro_export", |
455 | kind: Attribute, | 455 | kind: Attribute, |
456 | }, | 456 | }, |
457 | CompletionItem { | 457 | CompletionItem { |
458 | label: "macro_use", | 458 | label: "macro_use", |
459 | source_range: [20; 20), | 459 | source_range: 20..20, |
460 | delete: [20; 20), | 460 | delete: 20..20, |
461 | insert: "macro_use", | 461 | insert: "macro_use", |
462 | kind: Attribute, | 462 | kind: Attribute, |
463 | }, | 463 | }, |
464 | CompletionItem { | 464 | CompletionItem { |
465 | label: "must_use", | 465 | label: "must_use", |
466 | source_range: [20; 20), | 466 | source_range: 20..20, |
467 | delete: [20; 20), | 467 | delete: 20..20, |
468 | insert: "must_use = \"${0:reason}\"", | 468 | insert: "must_use = \"${0:reason}\"", |
469 | kind: Attribute, | 469 | kind: Attribute, |
470 | }, | 470 | }, |
471 | CompletionItem { | 471 | CompletionItem { |
472 | label: "no_mangle", | 472 | label: "no_mangle", |
473 | source_range: [20; 20), | 473 | source_range: 20..20, |
474 | delete: [20; 20), | 474 | delete: 20..20, |
475 | insert: "no_mangle", | 475 | insert: "no_mangle", |
476 | kind: Attribute, | 476 | kind: Attribute, |
477 | }, | 477 | }, |
478 | CompletionItem { | 478 | CompletionItem { |
479 | label: "no_std", | 479 | label: "no_std", |
480 | source_range: [20; 20), | 480 | source_range: 20..20, |
481 | delete: [20; 20), | 481 | delete: 20..20, |
482 | insert: "no_std", | 482 | insert: "no_std", |
483 | kind: Attribute, | 483 | kind: Attribute, |
484 | }, | 484 | }, |
485 | CompletionItem { | 485 | CompletionItem { |
486 | label: "non_exhaustive", | 486 | label: "non_exhaustive", |
487 | source_range: [20; 20), | 487 | source_range: 20..20, |
488 | delete: [20; 20), | 488 | delete: 20..20, |
489 | insert: "non_exhaustive", | 489 | insert: "non_exhaustive", |
490 | kind: Attribute, | 490 | kind: Attribute, |
491 | }, | 491 | }, |
492 | CompletionItem { | 492 | CompletionItem { |
493 | label: "panic_handler", | 493 | label: "panic_handler", |
494 | source_range: [20; 20), | 494 | source_range: 20..20, |
495 | delete: [20; 20), | 495 | delete: 20..20, |
496 | insert: "panic_handler", | 496 | insert: "panic_handler", |
497 | kind: Attribute, | 497 | kind: Attribute, |
498 | }, | 498 | }, |
499 | CompletionItem { | 499 | CompletionItem { |
500 | label: "path", | 500 | label: "path", |
501 | source_range: [20; 20), | 501 | source_range: 20..20, |
502 | delete: [20; 20), | 502 | delete: 20..20, |
503 | insert: "path =\"${0:path}\"", | 503 | insert: "path =\"${0:path}\"", |
504 | kind: Attribute, | 504 | kind: Attribute, |
505 | }, | 505 | }, |
506 | CompletionItem { | 506 | CompletionItem { |
507 | label: "proc_macro", | 507 | label: "proc_macro", |
508 | source_range: [20; 20), | 508 | source_range: 20..20, |
509 | delete: [20; 20), | 509 | delete: 20..20, |
510 | insert: "proc_macro", | 510 | insert: "proc_macro", |
511 | kind: Attribute, | 511 | kind: Attribute, |
512 | }, | 512 | }, |
513 | CompletionItem { | 513 | CompletionItem { |
514 | label: "proc_macro_attribute", | 514 | label: "proc_macro_attribute", |
515 | source_range: [20; 20), | 515 | source_range: 20..20, |
516 | delete: [20; 20), | 516 | delete: 20..20, |
517 | insert: "proc_macro_attribute", | 517 | insert: "proc_macro_attribute", |
518 | kind: Attribute, | 518 | kind: Attribute, |
519 | }, | 519 | }, |
520 | CompletionItem { | 520 | CompletionItem { |
521 | label: "proc_macro_derive", | 521 | label: "proc_macro_derive", |
522 | source_range: [20; 20), | 522 | source_range: 20..20, |
523 | delete: [20; 20), | 523 | delete: 20..20, |
524 | insert: "proc_macro_derive(${0:Trait})", | 524 | insert: "proc_macro_derive(${0:Trait})", |
525 | kind: Attribute, | 525 | kind: Attribute, |
526 | }, | 526 | }, |
527 | CompletionItem { | 527 | CompletionItem { |
528 | label: "recursion_limit", | 528 | label: "recursion_limit", |
529 | source_range: [20; 20), | 529 | source_range: 20..20, |
530 | delete: [20; 20), | 530 | delete: 20..20, |
531 | insert: "recursion_limit = ${0:128}", | 531 | insert: "recursion_limit = ${0:128}", |
532 | kind: Attribute, | 532 | kind: Attribute, |
533 | }, | 533 | }, |
534 | CompletionItem { | 534 | CompletionItem { |
535 | label: "repr", | 535 | label: "repr", |
536 | source_range: [20; 20), | 536 | source_range: 20..20, |
537 | delete: [20; 20), | 537 | delete: 20..20, |
538 | insert: "repr(${0:C})", | 538 | insert: "repr(${0:C})", |
539 | kind: Attribute, | 539 | kind: Attribute, |
540 | }, | 540 | }, |
541 | CompletionItem { | 541 | CompletionItem { |
542 | label: "should_panic", | 542 | label: "should_panic", |
543 | source_range: [20; 20), | 543 | source_range: 20..20, |
544 | delete: [20; 20), | 544 | delete: 20..20, |
545 | insert: "expected = \"${0:reason}\"", | 545 | insert: "expected = \"${0:reason}\"", |
546 | kind: Attribute, | 546 | kind: Attribute, |
547 | }, | 547 | }, |
548 | CompletionItem { | 548 | CompletionItem { |
549 | label: "target_feature", | 549 | label: "target_feature", |
550 | source_range: [20; 20), | 550 | source_range: 20..20, |
551 | delete: [20; 20), | 551 | delete: 20..20, |
552 | insert: "target_feature = \"${0:feature}\"", | 552 | insert: "target_feature = \"${0:feature}\"", |
553 | kind: Attribute, | 553 | kind: Attribute, |
554 | }, | 554 | }, |
555 | CompletionItem { | 555 | CompletionItem { |
556 | label: "test", | 556 | label: "test", |
557 | source_range: [20; 20), | 557 | source_range: 20..20, |
558 | delete: [20; 20), | 558 | delete: 20..20, |
559 | insert: "test", | 559 | insert: "test", |
560 | kind: Attribute, | 560 | kind: Attribute, |
561 | }, | 561 | }, |
562 | CompletionItem { | 562 | CompletionItem { |
563 | label: "used", | 563 | label: "used", |
564 | source_range: [20; 20), | 564 | source_range: 20..20, |
565 | delete: [20; 20), | 565 | delete: 20..20, |
566 | insert: "used", | 566 | insert: "used", |
567 | kind: Attribute, | 567 | kind: Attribute, |
568 | }, | 568 | }, |
569 | CompletionItem { | 569 | CompletionItem { |
570 | label: "warn", | 570 | label: "warn", |
571 | source_range: [20; 20), | 571 | source_range: 20..20, |
572 | delete: [20; 20), | 572 | delete: 20..20, |
573 | insert: "warn(${0:lint})", | 573 | insert: "warn(${0:lint})", |
574 | kind: Attribute, | 574 | kind: Attribute, |
575 | }, | 575 | }, |
576 | CompletionItem { | 576 | CompletionItem { |
577 | label: "windows_subsystem", | 577 | label: "windows_subsystem", |
578 | source_range: [20; 20), | 578 | source_range: 20..20, |
579 | delete: [20; 20), | 579 | delete: 20..20, |
580 | insert: "windows_subsystem = \"${0:subsystem}\"", | 580 | insert: "windows_subsystem = \"${0:subsystem}\"", |
581 | kind: Attribute, | 581 | kind: Attribute, |
582 | }, | 582 | }, |
diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index b93153b48..814354ffa 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs | |||
@@ -94,8 +94,8 @@ mod tests { | |||
94 | [ | 94 | [ |
95 | CompletionItem { | 95 | CompletionItem { |
96 | label: "the_field", | 96 | label: "the_field", |
97 | source_range: [94; 94), | 97 | source_range: 94..94, |
98 | delete: [94; 94), | 98 | delete: 94..94, |
99 | insert: "the_field", | 99 | insert: "the_field", |
100 | kind: Field, | 100 | kind: Field, |
101 | detail: "u32", | 101 | detail: "u32", |
@@ -125,8 +125,8 @@ mod tests { | |||
125 | [ | 125 | [ |
126 | CompletionItem { | 126 | CompletionItem { |
127 | label: "foo()", | 127 | label: "foo()", |
128 | source_range: [187; 187), | 128 | source_range: 187..187, |
129 | delete: [187; 187), | 129 | delete: 187..187, |
130 | insert: "foo()$0", | 130 | insert: "foo()$0", |
131 | kind: Method, | 131 | kind: Method, |
132 | lookup: "foo", | 132 | lookup: "foo", |
@@ -134,8 +134,8 @@ mod tests { | |||
134 | }, | 134 | }, |
135 | CompletionItem { | 135 | CompletionItem { |
136 | label: "the_field", | 136 | label: "the_field", |
137 | source_range: [187; 187), | 137 | source_range: 187..187, |
138 | delete: [187; 187), | 138 | delete: 187..187, |
139 | insert: "the_field", | 139 | insert: "the_field", |
140 | kind: Field, | 140 | kind: Field, |
141 | detail: "(u32,)", | 141 | detail: "(u32,)", |
@@ -165,8 +165,8 @@ mod tests { | |||
165 | [ | 165 | [ |
166 | CompletionItem { | 166 | CompletionItem { |
167 | label: "foo()", | 167 | label: "foo()", |
168 | source_range: [126; 126), | 168 | source_range: 126..126, |
169 | delete: [126; 126), | 169 | delete: 126..126, |
170 | insert: "foo()$0", | 170 | insert: "foo()$0", |
171 | kind: Method, | 171 | kind: Method, |
172 | lookup: "foo", | 172 | lookup: "foo", |
@@ -174,8 +174,8 @@ mod tests { | |||
174 | }, | 174 | }, |
175 | CompletionItem { | 175 | CompletionItem { |
176 | label: "the_field", | 176 | label: "the_field", |
177 | source_range: [126; 126), | 177 | source_range: 126..126, |
178 | delete: [126; 126), | 178 | delete: 126..126, |
179 | insert: "the_field", | 179 | insert: "the_field", |
180 | kind: Field, | 180 | kind: Field, |
181 | detail: "(u32, i32)", | 181 | detail: "(u32, i32)", |
@@ -222,24 +222,24 @@ mod tests { | |||
222 | [ | 222 | [ |
223 | CompletionItem { | 223 | CompletionItem { |
224 | label: "crate_field", | 224 | label: "crate_field", |
225 | source_range: [313; 313), | 225 | source_range: 313..313, |
226 | delete: [313; 313), | 226 | delete: 313..313, |
227 | insert: "crate_field", | 227 | insert: "crate_field", |
228 | kind: Field, | 228 | kind: Field, |
229 | detail: "u32", | 229 | detail: "u32", |
230 | }, | 230 | }, |
231 | CompletionItem { | 231 | CompletionItem { |
232 | label: "pub_field", | 232 | label: "pub_field", |
233 | source_range: [313; 313), | 233 | source_range: 313..313, |
234 | delete: [313; 313), | 234 | delete: 313..313, |
235 | insert: "pub_field", | 235 | insert: "pub_field", |
236 | kind: Field, | 236 | kind: Field, |
237 | detail: "u32", | 237 | detail: "u32", |
238 | }, | 238 | }, |
239 | CompletionItem { | 239 | CompletionItem { |
240 | label: "super_field", | 240 | label: "super_field", |
241 | source_range: [313; 313), | 241 | source_range: 313..313, |
242 | delete: [313; 313), | 242 | delete: 313..313, |
243 | insert: "super_field", | 243 | insert: "super_field", |
244 | kind: Field, | 244 | kind: Field, |
245 | detail: "u32", | 245 | detail: "u32", |
@@ -267,8 +267,8 @@ mod tests { | |||
267 | [ | 267 | [ |
268 | CompletionItem { | 268 | CompletionItem { |
269 | label: "the_method()", | 269 | label: "the_method()", |
270 | source_range: [144; 144), | 270 | source_range: 144..144, |
271 | delete: [144; 144), | 271 | delete: 144..144, |
272 | insert: "the_method()$0", | 272 | insert: "the_method()$0", |
273 | kind: Method, | 273 | kind: Method, |
274 | lookup: "the_method", | 274 | lookup: "the_method", |
@@ -300,8 +300,8 @@ mod tests { | |||
300 | [ | 300 | [ |
301 | CompletionItem { | 301 | CompletionItem { |
302 | label: "the_method()", | 302 | label: "the_method()", |
303 | source_range: [243; 243), | 303 | source_range: 243..243, |
304 | delete: [243; 243), | 304 | delete: 243..243, |
305 | insert: "the_method()$0", | 305 | insert: "the_method()$0", |
306 | kind: Method, | 306 | kind: Method, |
307 | lookup: "the_method", | 307 | lookup: "the_method", |
@@ -333,8 +333,8 @@ mod tests { | |||
333 | [ | 333 | [ |
334 | CompletionItem { | 334 | CompletionItem { |
335 | label: "the_method()", | 335 | label: "the_method()", |
336 | source_range: [256; 256), | 336 | source_range: 256..256, |
337 | delete: [256; 256), | 337 | delete: 256..256, |
338 | insert: "the_method()$0", | 338 | insert: "the_method()$0", |
339 | kind: Method, | 339 | kind: Method, |
340 | lookup: "the_method", | 340 | lookup: "the_method", |
@@ -362,8 +362,8 @@ mod tests { | |||
362 | [ | 362 | [ |
363 | CompletionItem { | 363 | CompletionItem { |
364 | label: "the_method()", | 364 | label: "the_method()", |
365 | source_range: [151; 151), | 365 | source_range: 151..151, |
366 | delete: [151; 151), | 366 | delete: 151..151, |
367 | insert: "the_method()$0", | 367 | insert: "the_method()$0", |
368 | kind: Method, | 368 | kind: Method, |
369 | lookup: "the_method", | 369 | lookup: "the_method", |
@@ -391,8 +391,8 @@ mod tests { | |||
391 | [ | 391 | [ |
392 | CompletionItem { | 392 | CompletionItem { |
393 | label: "the_method()", | 393 | label: "the_method()", |
394 | source_range: [155; 155), | 394 | source_range: 155..155, |
395 | delete: [155; 155), | 395 | delete: 155..155, |
396 | insert: "the_method()$0", | 396 | insert: "the_method()$0", |
397 | kind: Method, | 397 | kind: Method, |
398 | lookup: "the_method", | 398 | lookup: "the_method", |
@@ -423,8 +423,8 @@ mod tests { | |||
423 | [ | 423 | [ |
424 | CompletionItem { | 424 | CompletionItem { |
425 | label: "the_method()", | 425 | label: "the_method()", |
426 | source_range: [219; 219), | 426 | source_range: 219..219, |
427 | delete: [219; 219), | 427 | delete: 219..219, |
428 | insert: "the_method()$0", | 428 | insert: "the_method()$0", |
429 | kind: Method, | 429 | kind: Method, |
430 | lookup: "the_method", | 430 | lookup: "the_method", |
@@ -475,8 +475,8 @@ mod tests { | |||
475 | [ | 475 | [ |
476 | CompletionItem { | 476 | CompletionItem { |
477 | label: "the_method()", | 477 | label: "the_method()", |
478 | source_range: [249; 249), | 478 | source_range: 249..249, |
479 | delete: [249; 249), | 479 | delete: 249..249, |
480 | insert: "the_method()$0", | 480 | insert: "the_method()$0", |
481 | kind: Method, | 481 | kind: Method, |
482 | lookup: "the_method", | 482 | lookup: "the_method", |
@@ -502,16 +502,16 @@ mod tests { | |||
502 | [ | 502 | [ |
503 | CompletionItem { | 503 | CompletionItem { |
504 | label: "0", | 504 | label: "0", |
505 | source_range: [75; 75), | 505 | source_range: 75..75, |
506 | delete: [75; 75), | 506 | delete: 75..75, |
507 | insert: "0", | 507 | insert: "0", |
508 | kind: Field, | 508 | kind: Field, |
509 | detail: "i32", | 509 | detail: "i32", |
510 | }, | 510 | }, |
511 | CompletionItem { | 511 | CompletionItem { |
512 | label: "1", | 512 | label: "1", |
513 | source_range: [75; 75), | 513 | source_range: 75..75, |
514 | delete: [75; 75), | 514 | delete: 75..75, |
515 | insert: "1", | 515 | insert: "1", |
516 | kind: Field, | 516 | kind: Field, |
517 | detail: "f64", | 517 | detail: "f64", |
@@ -545,8 +545,8 @@ mod tests { | |||
545 | [ | 545 | [ |
546 | CompletionItem { | 546 | CompletionItem { |
547 | label: "blah()", | 547 | label: "blah()", |
548 | source_range: [299; 300), | 548 | source_range: 299..300, |
549 | delete: [299; 300), | 549 | delete: 299..300, |
550 | insert: "blah()$0", | 550 | insert: "blah()$0", |
551 | kind: Method, | 551 | kind: Method, |
552 | lookup: "blah", | 552 | lookup: "blah", |
@@ -572,8 +572,8 @@ mod tests { | |||
572 | [ | 572 | [ |
573 | CompletionItem { | 573 | CompletionItem { |
574 | label: "the_field", | 574 | label: "the_field", |
575 | source_range: [106; 106), | 575 | source_range: 106..106, |
576 | delete: [106; 106), | 576 | delete: 106..106, |
577 | insert: "the_field", | 577 | insert: "the_field", |
578 | kind: Field, | 578 | kind: Field, |
579 | detail: "u32", | 579 | detail: "u32", |
@@ -606,8 +606,8 @@ mod tests { | |||
606 | [ | 606 | [ |
607 | CompletionItem { | 607 | CompletionItem { |
608 | label: "await", | 608 | label: "await", |
609 | source_range: [74; 74), | 609 | source_range: 74..74, |
610 | delete: [74; 74), | 610 | delete: 74..74, |
611 | insert: "await", | 611 | insert: "await", |
612 | detail: "expr.await", | 612 | detail: "expr.await", |
613 | }, | 613 | }, |
@@ -638,15 +638,15 @@ mod tests { | |||
638 | [ | 638 | [ |
639 | CompletionItem { | 639 | CompletionItem { |
640 | label: "A", | 640 | label: "A", |
641 | source_range: [217; 217), | 641 | source_range: 217..217, |
642 | delete: [217; 217), | 642 | delete: 217..217, |
643 | insert: "A", | 643 | insert: "A", |
644 | kind: Const, | 644 | kind: Const, |
645 | }, | 645 | }, |
646 | CompletionItem { | 646 | CompletionItem { |
647 | label: "b", | 647 | label: "b", |
648 | source_range: [217; 217), | 648 | source_range: 217..217, |
649 | delete: [217; 217), | 649 | delete: 217..217, |
650 | insert: "b", | 650 | insert: "b", |
651 | kind: Module, | 651 | kind: Module, |
652 | }, | 652 | }, |
@@ -671,8 +671,8 @@ mod tests { | |||
671 | [ | 671 | [ |
672 | CompletionItem { | 672 | CompletionItem { |
673 | label: "the_field", | 673 | label: "the_field", |
674 | source_range: [156; 157), | 674 | source_range: 156..157, |
675 | delete: [156; 157), | 675 | delete: 156..157, |
676 | insert: "the_field", | 676 | insert: "the_field", |
677 | kind: Field, | 677 | kind: Field, |
678 | detail: "u32", | 678 | detail: "u32", |
@@ -698,8 +698,8 @@ mod tests { | |||
698 | [ | 698 | [ |
699 | CompletionItem { | 699 | CompletionItem { |
700 | label: "the_field", | 700 | label: "the_field", |
701 | source_range: [156; 157), | 701 | source_range: 156..157, |
702 | delete: [156; 157), | 702 | delete: 156..157, |
703 | insert: "the_field", | 703 | insert: "the_field", |
704 | kind: Field, | 704 | kind: Field, |
705 | detail: "u32", | 705 | detail: "u32", |
@@ -726,8 +726,8 @@ mod tests { | |||
726 | [ | 726 | [ |
727 | CompletionItem { | 727 | CompletionItem { |
728 | label: "the_field", | 728 | label: "the_field", |
729 | source_range: [156; 156), | 729 | source_range: 156..156, |
730 | delete: [156; 156), | 730 | delete: 156..156, |
731 | insert: "the_field", | 731 | insert: "the_field", |
732 | kind: Field, | 732 | kind: Field, |
733 | detail: "u32", | 733 | detail: "u32", |
@@ -753,8 +753,8 @@ mod tests { | |||
753 | [ | 753 | [ |
754 | CompletionItem { | 754 | CompletionItem { |
755 | label: "the_field", | 755 | label: "the_field", |
756 | source_range: [162; 163), | 756 | source_range: 162..163, |
757 | delete: [162; 163), | 757 | delete: 162..163, |
758 | insert: "the_field", | 758 | insert: "the_field", |
759 | kind: Field, | 759 | kind: Field, |
760 | detail: "u32", | 760 | detail: "u32", |
@@ -790,8 +790,8 @@ mod tests { | |||
790 | [ | 790 | [ |
791 | CompletionItem { | 791 | CompletionItem { |
792 | label: "the_field", | 792 | label: "the_field", |
793 | source_range: [552; 552), | 793 | source_range: 552..552, |
794 | delete: [552; 552), | 794 | delete: 552..552, |
795 | insert: "the_field", | 795 | insert: "the_field", |
796 | kind: Field, | 796 | kind: Field, |
797 | detail: "u32", | 797 | detail: "u32", |
@@ -820,8 +820,8 @@ mod tests { | |||
820 | [ | 820 | [ |
821 | CompletionItem { | 821 | CompletionItem { |
822 | label: "the_method()", | 822 | label: "the_method()", |
823 | source_range: [201; 201), | 823 | source_range: 201..201, |
824 | delete: [201; 201), | 824 | delete: 201..201, |
825 | insert: "the_method()$0", | 825 | insert: "the_method()$0", |
826 | kind: Method, | 826 | kind: Method, |
827 | lookup: "the_method", | 827 | lookup: "the_method", |
diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs index f84b559fc..a661932a3 100644 --- a/crates/ra_ide/src/completion/complete_fn_param.rs +++ b/crates/ra_ide/src/completion/complete_fn_param.rs | |||
@@ -75,8 +75,8 @@ mod tests { | |||
75 | [ | 75 | [ |
76 | CompletionItem { | 76 | CompletionItem { |
77 | label: "file_id: FileId", | 77 | label: "file_id: FileId", |
78 | source_range: [110; 114), | 78 | source_range: 110..114, |
79 | delete: [110; 114), | 79 | delete: 110..114, |
80 | insert: "file_id: FileId", | 80 | insert: "file_id: FileId", |
81 | lookup: "file_id", | 81 | lookup: "file_id", |
82 | }, | 82 | }, |
@@ -99,8 +99,8 @@ mod tests { | |||
99 | [ | 99 | [ |
100 | CompletionItem { | 100 | CompletionItem { |
101 | label: "file_id: FileId", | 101 | label: "file_id: FileId", |
102 | source_range: [110; 114), | 102 | source_range: 110..114, |
103 | delete: [110; 114), | 103 | delete: 110..114, |
104 | insert: "file_id: FileId", | 104 | insert: "file_id: FileId", |
105 | lookup: "file_id", | 105 | lookup: "file_id", |
106 | }, | 106 | }, |
@@ -126,8 +126,8 @@ mod tests { | |||
126 | [ | 126 | [ |
127 | CompletionItem { | 127 | CompletionItem { |
128 | label: "file_id: FileId", | 128 | label: "file_id: FileId", |
129 | source_range: [289; 293), | 129 | source_range: 289..293, |
130 | delete: [289; 293), | 130 | delete: 289..293, |
131 | insert: "file_id: FileId", | 131 | insert: "file_id: FileId", |
132 | lookup: "file_id", | 132 | lookup: "file_id", |
133 | }, | 133 | }, |
diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs index adefb290e..fd95bc410 100644 --- a/crates/ra_ide/src/completion/complete_keyword.rs +++ b/crates/ra_ide/src/completion/complete_keyword.rs | |||
@@ -97,7 +97,7 @@ fn is_in_loop_body(leaf: &SyntaxToken) -> bool { | |||
97 | } | 97 | } |
98 | }; | 98 | }; |
99 | if let Some(body) = loop_body { | 99 | if let Some(body) = loop_body { |
100 | if leaf.text_range().is_subrange(&body.syntax().text_range()) { | 100 | if body.syntax().text_range().contains_range(leaf.text_range()) { |
101 | return true; | 101 | return true; |
102 | } | 102 | } |
103 | } | 103 | } |
@@ -140,22 +140,22 @@ mod tests { | |||
140 | [ | 140 | [ |
141 | CompletionItem { | 141 | CompletionItem { |
142 | label: "crate", | 142 | label: "crate", |
143 | source_range: [21; 21), | 143 | source_range: 21..21, |
144 | delete: [21; 21), | 144 | delete: 21..21, |
145 | insert: "crate::", | 145 | insert: "crate::", |
146 | kind: Keyword, | 146 | kind: Keyword, |
147 | }, | 147 | }, |
148 | CompletionItem { | 148 | CompletionItem { |
149 | label: "self", | 149 | label: "self", |
150 | source_range: [21; 21), | 150 | source_range: 21..21, |
151 | delete: [21; 21), | 151 | delete: 21..21, |
152 | insert: "self", | 152 | insert: "self", |
153 | kind: Keyword, | 153 | kind: Keyword, |
154 | }, | 154 | }, |
155 | CompletionItem { | 155 | CompletionItem { |
156 | label: "super", | 156 | label: "super", |
157 | source_range: [21; 21), | 157 | source_range: 21..21, |
158 | delete: [21; 21), | 158 | delete: 21..21, |
159 | insert: "super::", | 159 | insert: "super::", |
160 | kind: Keyword, | 160 | kind: Keyword, |
161 | }, | 161 | }, |
@@ -173,15 +173,15 @@ mod tests { | |||
173 | [ | 173 | [ |
174 | CompletionItem { | 174 | CompletionItem { |
175 | label: "self", | 175 | label: "self", |
176 | source_range: [24; 24), | 176 | source_range: 24..24, |
177 | delete: [24; 24), | 177 | delete: 24..24, |
178 | insert: "self", | 178 | insert: "self", |
179 | kind: Keyword, | 179 | kind: Keyword, |
180 | }, | 180 | }, |
181 | CompletionItem { | 181 | CompletionItem { |
182 | label: "super", | 182 | label: "super", |
183 | source_range: [24; 24), | 183 | source_range: 24..24, |
184 | delete: [24; 24), | 184 | delete: 24..24, |
185 | insert: "super::", | 185 | insert: "super::", |
186 | kind: Keyword, | 186 | kind: Keyword, |
187 | }, | 187 | }, |
@@ -199,15 +199,15 @@ mod tests { | |||
199 | [ | 199 | [ |
200 | CompletionItem { | 200 | CompletionItem { |
201 | label: "self", | 201 | label: "self", |
202 | source_range: [28; 28), | 202 | source_range: 28..28, |
203 | delete: [28; 28), | 203 | delete: 28..28, |
204 | insert: "self", | 204 | insert: "self", |
205 | kind: Keyword, | 205 | kind: Keyword, |
206 | }, | 206 | }, |
207 | CompletionItem { | 207 | CompletionItem { |
208 | label: "super", | 208 | label: "super", |
209 | source_range: [28; 28), | 209 | source_range: 28..28, |
210 | delete: [28; 28), | 210 | delete: 28..28, |
211 | insert: "super::", | 211 | insert: "super::", |
212 | kind: Keyword, | 212 | kind: Keyword, |
213 | }, | 213 | }, |
@@ -230,36 +230,36 @@ mod tests { | |||
230 | [ | 230 | [ |
231 | CompletionItem { | 231 | CompletionItem { |
232 | label: "if", | 232 | label: "if", |
233 | source_range: [49; 49), | 233 | source_range: 49..49, |
234 | delete: [49; 49), | 234 | delete: 49..49, |
235 | insert: "if $0 {}", | 235 | insert: "if $0 {}", |
236 | kind: Keyword, | 236 | kind: Keyword, |
237 | }, | 237 | }, |
238 | CompletionItem { | 238 | CompletionItem { |
239 | label: "loop", | 239 | label: "loop", |
240 | source_range: [49; 49), | 240 | source_range: 49..49, |
241 | delete: [49; 49), | 241 | delete: 49..49, |
242 | insert: "loop {$0}", | 242 | insert: "loop {$0}", |
243 | kind: Keyword, | 243 | kind: Keyword, |
244 | }, | 244 | }, |
245 | CompletionItem { | 245 | CompletionItem { |
246 | label: "match", | 246 | label: "match", |
247 | source_range: [49; 49), | 247 | source_range: 49..49, |
248 | delete: [49; 49), | 248 | delete: 49..49, |
249 | insert: "match $0 {}", | 249 | insert: "match $0 {}", |
250 | kind: Keyword, | 250 | kind: Keyword, |
251 | }, | 251 | }, |
252 | CompletionItem { | 252 | CompletionItem { |
253 | label: "return", | 253 | label: "return", |
254 | source_range: [49; 49), | 254 | source_range: 49..49, |
255 | delete: [49; 49), | 255 | delete: 49..49, |
256 | insert: "return;", | 256 | insert: "return;", |
257 | kind: Keyword, | 257 | kind: Keyword, |
258 | }, | 258 | }, |
259 | CompletionItem { | 259 | CompletionItem { |
260 | label: "while", | 260 | label: "while", |
261 | source_range: [49; 49), | 261 | source_range: 49..49, |
262 | delete: [49; 49), | 262 | delete: 49..49, |
263 | insert: "while $0 {}", | 263 | insert: "while $0 {}", |
264 | kind: Keyword, | 264 | kind: Keyword, |
265 | }, | 265 | }, |
@@ -284,50 +284,50 @@ mod tests { | |||
284 | [ | 284 | [ |
285 | CompletionItem { | 285 | CompletionItem { |
286 | label: "else", | 286 | label: "else", |
287 | source_range: [108; 108), | 287 | source_range: 108..108, |
288 | delete: [108; 108), | 288 | delete: 108..108, |
289 | insert: "else {$0}", | 289 | insert: "else {$0}", |
290 | kind: Keyword, | 290 | kind: Keyword, |
291 | }, | 291 | }, |
292 | CompletionItem { | 292 | CompletionItem { |
293 | label: "else if", | 293 | label: "else if", |
294 | source_range: [108; 108), | 294 | source_range: 108..108, |
295 | delete: [108; 108), | 295 | delete: 108..108, |
296 | insert: "else if $0 {}", | 296 | insert: "else if $0 {}", |
297 | kind: Keyword, | 297 | kind: Keyword, |
298 | }, | 298 | }, |
299 | CompletionItem { | 299 | CompletionItem { |
300 | label: "if", | 300 | label: "if", |
301 | source_range: [108; 108), | 301 | source_range: 108..108, |
302 | delete: [108; 108), | 302 | delete: 108..108, |
303 | insert: "if $0 {}", | 303 | insert: "if $0 {}", |
304 | kind: Keyword, | 304 | kind: Keyword, |
305 | }, | 305 | }, |
306 | CompletionItem { | 306 | CompletionItem { |
307 | label: "loop", | 307 | label: "loop", |
308 | source_range: [108; 108), | 308 | source_range: 108..108, |
309 | delete: [108; 108), | 309 | delete: 108..108, |
310 | insert: "loop {$0}", | 310 | insert: "loop {$0}", |
311 | kind: Keyword, | 311 | kind: Keyword, |
312 | }, | 312 | }, |
313 | CompletionItem { | 313 | CompletionItem { |
314 | label: "match", | 314 | label: "match", |
315 | source_range: [108; 108), | 315 | source_range: 108..108, |
316 | delete: [108; 108), | 316 | delete: 108..108, |
317 | insert: "match $0 {}", | 317 | insert: "match $0 {}", |
318 | kind: Keyword, | 318 | kind: Keyword, |
319 | }, | 319 | }, |
320 | CompletionItem { | 320 | CompletionItem { |
321 | label: "return", | 321 | label: "return", |
322 | source_range: [108; 108), | 322 | source_range: 108..108, |
323 | delete: [108; 108), | 323 | delete: 108..108, |
324 | insert: "return;", | 324 | insert: "return;", |
325 | kind: Keyword, | 325 | kind: Keyword, |
326 | }, | 326 | }, |
327 | CompletionItem { | 327 | CompletionItem { |
328 | label: "while", | 328 | label: "while", |
329 | source_range: [108; 108), | 329 | source_range: 108..108, |
330 | delete: [108; 108), | 330 | delete: 108..108, |
331 | insert: "while $0 {}", | 331 | insert: "while $0 {}", |
332 | kind: Keyword, | 332 | kind: Keyword, |
333 | }, | 333 | }, |
@@ -351,36 +351,36 @@ mod tests { | |||
351 | [ | 351 | [ |
352 | CompletionItem { | 352 | CompletionItem { |
353 | label: "if", | 353 | label: "if", |
354 | source_range: [56; 56), | 354 | source_range: 56..56, |
355 | delete: [56; 56), | 355 | delete: 56..56, |
356 | insert: "if $0 {}", | 356 | insert: "if $0 {}", |
357 | kind: Keyword, | 357 | kind: Keyword, |
358 | }, | 358 | }, |
359 | CompletionItem { | 359 | CompletionItem { |
360 | label: "loop", | 360 | label: "loop", |
361 | source_range: [56; 56), | 361 | source_range: 56..56, |
362 | delete: [56; 56), | 362 | delete: 56..56, |
363 | insert: "loop {$0}", | 363 | insert: "loop {$0}", |
364 | kind: Keyword, | 364 | kind: Keyword, |
365 | }, | 365 | }, |
366 | CompletionItem { | 366 | CompletionItem { |
367 | label: "match", | 367 | label: "match", |
368 | source_range: [56; 56), | 368 | source_range: 56..56, |
369 | delete: [56; 56), | 369 | delete: 56..56, |
370 | insert: "match $0 {}", | 370 | insert: "match $0 {}", |
371 | kind: Keyword, | 371 | kind: Keyword, |
372 | }, | 372 | }, |
373 | CompletionItem { | 373 | CompletionItem { |
374 | label: "return", | 374 | label: "return", |
375 | source_range: [56; 56), | 375 | source_range: 56..56, |
376 | delete: [56; 56), | 376 | delete: 56..56, |
377 | insert: "return $0;", | 377 | insert: "return $0;", |
378 | kind: Keyword, | 378 | kind: Keyword, |
379 | }, | 379 | }, |
380 | CompletionItem { | 380 | CompletionItem { |
381 | label: "while", | 381 | label: "while", |
382 | source_range: [56; 56), | 382 | source_range: 56..56, |
383 | delete: [56; 56), | 383 | delete: 56..56, |
384 | insert: "while $0 {}", | 384 | insert: "while $0 {}", |
385 | kind: Keyword, | 385 | kind: Keyword, |
386 | }, | 386 | }, |
@@ -400,36 +400,36 @@ mod tests { | |||
400 | [ | 400 | [ |
401 | CompletionItem { | 401 | CompletionItem { |
402 | label: "if", | 402 | label: "if", |
403 | source_range: [49; 49), | 403 | source_range: 49..49, |
404 | delete: [49; 49), | 404 | delete: 49..49, |
405 | insert: "if $0 {}", | 405 | insert: "if $0 {}", |
406 | kind: Keyword, | 406 | kind: Keyword, |
407 | }, | 407 | }, |
408 | CompletionItem { | 408 | CompletionItem { |
409 | label: "loop", | 409 | label: "loop", |
410 | source_range: [49; 49), | 410 | source_range: 49..49, |
411 | delete: [49; 49), | 411 | delete: 49..49, |
412 | insert: "loop {$0}", | 412 | insert: "loop {$0}", |
413 | kind: Keyword, | 413 | kind: Keyword, |
414 | }, | 414 | }, |
415 | CompletionItem { | 415 | CompletionItem { |
416 | label: "match", | 416 | label: "match", |
417 | source_range: [49; 49), | 417 | source_range: 49..49, |
418 | delete: [49; 49), | 418 | delete: 49..49, |
419 | insert: "match $0 {}", | 419 | insert: "match $0 {}", |
420 | kind: Keyword, | 420 | kind: Keyword, |
421 | }, | 421 | }, |
422 | CompletionItem { | 422 | CompletionItem { |
423 | label: "return", | 423 | label: "return", |
424 | source_range: [49; 49), | 424 | source_range: 49..49, |
425 | delete: [49; 49), | 425 | delete: 49..49, |
426 | insert: "return;", | 426 | insert: "return;", |
427 | kind: Keyword, | 427 | kind: Keyword, |
428 | }, | 428 | }, |
429 | CompletionItem { | 429 | CompletionItem { |
430 | label: "while", | 430 | label: "while", |
431 | source_range: [49; 49), | 431 | source_range: 49..49, |
432 | delete: [49; 49), | 432 | delete: 49..49, |
433 | insert: "while $0 {}", | 433 | insert: "while $0 {}", |
434 | kind: Keyword, | 434 | kind: Keyword, |
435 | }, | 435 | }, |
@@ -454,36 +454,36 @@ mod tests { | |||
454 | [ | 454 | [ |
455 | CompletionItem { | 455 | CompletionItem { |
456 | label: "if", | 456 | label: "if", |
457 | source_range: [97; 97), | 457 | source_range: 97..97, |
458 | delete: [97; 97), | 458 | delete: 97..97, |
459 | insert: "if $0 {}", | 459 | insert: "if $0 {}", |
460 | kind: Keyword, | 460 | kind: Keyword, |
461 | }, | 461 | }, |
462 | CompletionItem { | 462 | CompletionItem { |
463 | label: "loop", | 463 | label: "loop", |
464 | source_range: [97; 97), | 464 | source_range: 97..97, |
465 | delete: [97; 97), | 465 | delete: 97..97, |
466 | insert: "loop {$0}", | 466 | insert: "loop {$0}", |
467 | kind: Keyword, | 467 | kind: Keyword, |
468 | }, | 468 | }, |
469 | CompletionItem { | 469 | CompletionItem { |
470 | label: "match", | 470 | label: "match", |
471 | source_range: [97; 97), | 471 | source_range: 97..97, |
472 | delete: [97; 97), | 472 | delete: 97..97, |
473 | insert: "match $0 {}", | 473 | insert: "match $0 {}", |
474 | kind: Keyword, | 474 | kind: Keyword, |
475 | }, | 475 | }, |
476 | CompletionItem { | 476 | CompletionItem { |
477 | label: "return", | 477 | label: "return", |
478 | source_range: [97; 97), | 478 | source_range: 97..97, |
479 | delete: [97; 97), | 479 | delete: 97..97, |
480 | insert: "return $0", | 480 | insert: "return $0", |
481 | kind: Keyword, | 481 | kind: Keyword, |
482 | }, | 482 | }, |
483 | CompletionItem { | 483 | CompletionItem { |
484 | label: "while", | 484 | label: "while", |
485 | source_range: [97; 97), | 485 | source_range: 97..97, |
486 | delete: [97; 97), | 486 | delete: 97..97, |
487 | insert: "while $0 {}", | 487 | insert: "while $0 {}", |
488 | kind: Keyword, | 488 | kind: Keyword, |
489 | }, | 489 | }, |
@@ -508,36 +508,36 @@ mod tests { | |||
508 | [ | 508 | [ |
509 | CompletionItem { | 509 | CompletionItem { |
510 | label: "if", | 510 | label: "if", |
511 | source_range: [95; 95), | 511 | source_range: 95..95, |
512 | delete: [95; 95), | 512 | delete: 95..95, |
513 | insert: "if $0 {}", | 513 | insert: "if $0 {}", |
514 | kind: Keyword, | 514 | kind: Keyword, |
515 | }, | 515 | }, |
516 | CompletionItem { | 516 | CompletionItem { |
517 | label: "loop", | 517 | label: "loop", |
518 | source_range: [95; 95), | 518 | source_range: 95..95, |
519 | delete: [95; 95), | 519 | delete: 95..95, |
520 | insert: "loop {$0}", | 520 | insert: "loop {$0}", |
521 | kind: Keyword, | 521 | kind: Keyword, |
522 | }, | 522 | }, |
523 | CompletionItem { | 523 | CompletionItem { |
524 | label: "match", | 524 | label: "match", |
525 | source_range: [95; 95), | 525 | source_range: 95..95, |
526 | delete: [95; 95), | 526 | delete: 95..95, |
527 | insert: "match $0 {}", | 527 | insert: "match $0 {}", |
528 | kind: Keyword, | 528 | kind: Keyword, |
529 | }, | 529 | }, |
530 | CompletionItem { | 530 | CompletionItem { |
531 | label: "return", | 531 | label: "return", |
532 | source_range: [95; 95), | 532 | source_range: 95..95, |
533 | delete: [95; 95), | 533 | delete: 95..95, |
534 | insert: "return $0;", | 534 | insert: "return $0;", |
535 | kind: Keyword, | 535 | kind: Keyword, |
536 | }, | 536 | }, |
537 | CompletionItem { | 537 | CompletionItem { |
538 | label: "while", | 538 | label: "while", |
539 | source_range: [95; 95), | 539 | source_range: 95..95, |
540 | delete: [95; 95), | 540 | delete: 95..95, |
541 | insert: "while $0 {}", | 541 | insert: "while $0 {}", |
542 | kind: Keyword, | 542 | kind: Keyword, |
543 | }, | 543 | }, |
@@ -560,36 +560,36 @@ mod tests { | |||
560 | [ | 560 | [ |
561 | CompletionItem { | 561 | CompletionItem { |
562 | label: "if", | 562 | label: "if", |
563 | source_range: [95; 95), | 563 | source_range: 95..95, |
564 | delete: [95; 95), | 564 | delete: 95..95, |
565 | insert: "if $0 {}", | 565 | insert: "if $0 {}", |
566 | kind: Keyword, | 566 | kind: Keyword, |
567 | }, | 567 | }, |
568 | CompletionItem { | 568 | CompletionItem { |
569 | label: "loop", | 569 | label: "loop", |
570 | source_range: [95; 95), | 570 | source_range: 95..95, |
571 | delete: [95; 95), | 571 | delete: 95..95, |
572 | insert: "loop {$0}", | 572 | insert: "loop {$0}", |
573 | kind: Keyword, | 573 | kind: Keyword, |
574 | }, | 574 | }, |
575 | CompletionItem { | 575 | CompletionItem { |
576 | label: "match", | 576 | label: "match", |
577 | source_range: [95; 95), | 577 | source_range: 95..95, |
578 | delete: [95; 95), | 578 | delete: 95..95, |
579 | insert: "match $0 {}", | 579 | insert: "match $0 {}", |
580 | kind: Keyword, | 580 | kind: Keyword, |
581 | }, | 581 | }, |
582 | CompletionItem { | 582 | CompletionItem { |
583 | label: "return", | 583 | label: "return", |
584 | source_range: [95; 95), | 584 | source_range: 95..95, |
585 | delete: [95; 95), | 585 | delete: 95..95, |
586 | insert: "return $0;", | 586 | insert: "return $0;", |
587 | kind: Keyword, | 587 | kind: Keyword, |
588 | }, | 588 | }, |
589 | CompletionItem { | 589 | CompletionItem { |
590 | label: "while", | 590 | label: "while", |
591 | source_range: [95; 95), | 591 | source_range: 95..95, |
592 | delete: [95; 95), | 592 | delete: 95..95, |
593 | insert: "while $0 {}", | 593 | insert: "while $0 {}", |
594 | kind: Keyword, | 594 | kind: Keyword, |
595 | }, | 595 | }, |
@@ -612,50 +612,50 @@ mod tests { | |||
612 | [ | 612 | [ |
613 | CompletionItem { | 613 | CompletionItem { |
614 | label: "break", | 614 | label: "break", |
615 | source_range: [63; 63), | 615 | source_range: 63..63, |
616 | delete: [63; 63), | 616 | delete: 63..63, |
617 | insert: "break;", | 617 | insert: "break;", |
618 | kind: Keyword, | 618 | kind: Keyword, |
619 | }, | 619 | }, |
620 | CompletionItem { | 620 | CompletionItem { |
621 | label: "continue", | 621 | label: "continue", |
622 | source_range: [63; 63), | 622 | source_range: 63..63, |
623 | delete: [63; 63), | 623 | delete: 63..63, |
624 | insert: "continue;", | 624 | insert: "continue;", |
625 | kind: Keyword, | 625 | kind: Keyword, |
626 | }, | 626 | }, |
627 | CompletionItem { | 627 | CompletionItem { |
628 | label: "if", | 628 | label: "if", |
629 | source_range: [63; 63), | 629 | source_range: 63..63, |
630 | delete: [63; 63), | 630 | delete: 63..63, |
631 | insert: "if $0 {}", | 631 | insert: "if $0 {}", |
632 | kind: Keyword, | 632 | kind: Keyword, |
633 | }, | 633 | }, |
634 | CompletionItem { | 634 | CompletionItem { |
635 | label: "loop", | 635 | label: "loop", |
636 | source_range: [63; 63), | 636 | source_range: 63..63, |
637 | delete: [63; 63), | 637 | delete: 63..63, |
638 | insert: "loop {$0}", | 638 | insert: "loop {$0}", |
639 | kind: Keyword, | 639 | kind: Keyword, |
640 | }, | 640 | }, |
641 | CompletionItem { | 641 | CompletionItem { |
642 | label: "match", | 642 | label: "match", |
643 | source_range: [63; 63), | 643 | source_range: 63..63, |
644 | delete: [63; 63), | 644 | delete: 63..63, |
645 | insert: "match $0 {}", | 645 | insert: "match $0 {}", |
646 | kind: Keyword, | 646 | kind: Keyword, |
647 | }, | 647 | }, |
648 | CompletionItem { | 648 | CompletionItem { |
649 | label: "return", | 649 | label: "return", |
650 | source_range: [63; 63), | 650 | source_range: 63..63, |
651 | delete: [63; 63), | 651 | delete: 63..63, |
652 | insert: "return $0;", | 652 | insert: "return $0;", |
653 | kind: Keyword, | 653 | kind: Keyword, |
654 | }, | 654 | }, |
655 | CompletionItem { | 655 | CompletionItem { |
656 | label: "while", | 656 | label: "while", |
657 | source_range: [63; 63), | 657 | source_range: 63..63, |
658 | delete: [63; 63), | 658 | delete: 63..63, |
659 | insert: "while $0 {}", | 659 | insert: "while $0 {}", |
660 | kind: Keyword, | 660 | kind: Keyword, |
661 | }, | 661 | }, |
@@ -676,36 +676,36 @@ mod tests { | |||
676 | [ | 676 | [ |
677 | CompletionItem { | 677 | CompletionItem { |
678 | label: "if", | 678 | label: "if", |
679 | source_range: [68; 68), | 679 | source_range: 68..68, |
680 | delete: [68; 68), | 680 | delete: 68..68, |
681 | insert: "if $0 {}", | 681 | insert: "if $0 {}", |
682 | kind: Keyword, | 682 | kind: Keyword, |
683 | }, | 683 | }, |
684 | CompletionItem { | 684 | CompletionItem { |
685 | label: "loop", | 685 | label: "loop", |
686 | source_range: [68; 68), | 686 | source_range: 68..68, |
687 | delete: [68; 68), | 687 | delete: 68..68, |
688 | insert: "loop {$0}", | 688 | insert: "loop {$0}", |
689 | kind: Keyword, | 689 | kind: Keyword, |
690 | }, | 690 | }, |
691 | CompletionItem { | 691 | CompletionItem { |
692 | label: "match", | 692 | label: "match", |
693 | source_range: [68; 68), | 693 | source_range: 68..68, |
694 | delete: [68; 68), | 694 | delete: 68..68, |
695 | insert: "match $0 {}", | 695 | insert: "match $0 {}", |
696 | kind: Keyword, | 696 | kind: Keyword, |
697 | }, | 697 | }, |
698 | CompletionItem { | 698 | CompletionItem { |
699 | label: "return", | 699 | label: "return", |
700 | source_range: [68; 68), | 700 | source_range: 68..68, |
701 | delete: [68; 68), | 701 | delete: 68..68, |
702 | insert: "return $0;", | 702 | insert: "return $0;", |
703 | kind: Keyword, | 703 | kind: Keyword, |
704 | }, | 704 | }, |
705 | CompletionItem { | 705 | CompletionItem { |
706 | label: "while", | 706 | label: "while", |
707 | source_range: [68; 68), | 707 | source_range: 68..68, |
708 | delete: [68; 68), | 708 | delete: 68..68, |
709 | insert: "while $0 {}", | 709 | insert: "while $0 {}", |
710 | kind: Keyword, | 710 | kind: Keyword, |
711 | }, | 711 | }, |
@@ -732,50 +732,50 @@ mod tests { | |||
732 | [ | 732 | [ |
733 | CompletionItem { | 733 | CompletionItem { |
734 | label: "break", | 734 | label: "break", |
735 | source_range: [122; 124), | 735 | source_range: 122..124, |
736 | delete: [122; 124), | 736 | delete: 122..124, |
737 | insert: "break", | 737 | insert: "break", |
738 | kind: Keyword, | 738 | kind: Keyword, |
739 | }, | 739 | }, |
740 | CompletionItem { | 740 | CompletionItem { |
741 | label: "continue", | 741 | label: "continue", |
742 | source_range: [122; 124), | 742 | source_range: 122..124, |
743 | delete: [122; 124), | 743 | delete: 122..124, |
744 | insert: "continue", | 744 | insert: "continue", |
745 | kind: Keyword, | 745 | kind: Keyword, |
746 | }, | 746 | }, |
747 | CompletionItem { | 747 | CompletionItem { |
748 | label: "if", | 748 | label: "if", |
749 | source_range: [122; 124), | 749 | source_range: 122..124, |
750 | delete: [122; 124), | 750 | delete: 122..124, |
751 | insert: "if $0 {}", | 751 | insert: "if $0 {}", |
752 | kind: Keyword, | 752 | kind: Keyword, |
753 | }, | 753 | }, |
754 | CompletionItem { | 754 | CompletionItem { |
755 | label: "loop", | 755 | label: "loop", |
756 | source_range: [122; 124), | 756 | source_range: 122..124, |
757 | delete: [122; 124), | 757 | delete: 122..124, |
758 | insert: "loop {$0}", | 758 | insert: "loop {$0}", |
759 | kind: Keyword, | 759 | kind: Keyword, |
760 | }, | 760 | }, |
761 | CompletionItem { | 761 | CompletionItem { |
762 | label: "match", | 762 | label: "match", |
763 | source_range: [122; 124), | 763 | source_range: 122..124, |
764 | delete: [122; 124), | 764 | delete: 122..124, |
765 | insert: "match $0 {}", | 765 | insert: "match $0 {}", |
766 | kind: Keyword, | 766 | kind: Keyword, |
767 | }, | 767 | }, |
768 | CompletionItem { | 768 | CompletionItem { |
769 | label: "return", | 769 | label: "return", |
770 | source_range: [122; 124), | 770 | source_range: 122..124, |
771 | delete: [122; 124), | 771 | delete: 122..124, |
772 | insert: "return", | 772 | insert: "return", |
773 | kind: Keyword, | 773 | kind: Keyword, |
774 | }, | 774 | }, |
775 | CompletionItem { | 775 | CompletionItem { |
776 | label: "while", | 776 | label: "while", |
777 | source_range: [122; 124), | 777 | source_range: 122..124, |
778 | delete: [122; 124), | 778 | delete: 122..124, |
779 | insert: "while $0 {}", | 779 | insert: "while $0 {}", |
780 | kind: Keyword, | 780 | kind: Keyword, |
781 | }, | 781 | }, |
diff --git a/crates/ra_ide/src/completion/complete_macro_in_item_position.rs b/crates/ra_ide/src/completion/complete_macro_in_item_position.rs index 6000106d0..d9bb5fd25 100644 --- a/crates/ra_ide/src/completion/complete_macro_in_item_position.rs +++ b/crates/ra_ide/src/completion/complete_macro_in_item_position.rs | |||
@@ -42,8 +42,8 @@ mod tests { | |||
42 | [ | 42 | [ |
43 | CompletionItem { | 43 | CompletionItem { |
44 | label: "foo!(…)", | 44 | label: "foo!(…)", |
45 | source_range: [46; 46), | 45 | source_range: 46..46, |
46 | delete: [46; 46), | 46 | delete: 46..46, |
47 | insert: "foo!($0)", | 47 | insert: "foo!($0)", |
48 | kind: Macro, | 48 | kind: Macro, |
49 | detail: "macro_rules! foo", | 49 | detail: "macro_rules! foo", |
@@ -82,8 +82,8 @@ mod tests { | |||
82 | [ | 82 | [ |
83 | CompletionItem { | 83 | CompletionItem { |
84 | label: "vec![…]", | 84 | label: "vec![…]", |
85 | source_range: [280; 280), | 85 | source_range: 280..280, |
86 | delete: [280; 280), | 86 | delete: 280..280, |
87 | insert: "vec![$0]", | 87 | insert: "vec![$0]", |
88 | kind: Macro, | 88 | kind: Macro, |
89 | detail: "macro_rules! vec", | 89 | detail: "macro_rules! vec", |
@@ -119,8 +119,8 @@ mod tests { | |||
119 | [ | 119 | [ |
120 | CompletionItem { | 120 | CompletionItem { |
121 | label: "foo! {…}", | 121 | label: "foo! {…}", |
122 | source_range: [163; 163), | 122 | source_range: 163..163, |
123 | delete: [163; 163), | 123 | delete: 163..163, |
124 | insert: "foo! {$0}", | 124 | insert: "foo! {$0}", |
125 | kind: Macro, | 125 | kind: Macro, |
126 | detail: "macro_rules! foo", | 126 | detail: "macro_rules! foo", |
@@ -130,8 +130,8 @@ mod tests { | |||
130 | }, | 130 | }, |
131 | CompletionItem { | 131 | CompletionItem { |
132 | label: "main()", | 132 | label: "main()", |
133 | source_range: [163; 163), | 133 | source_range: 163..163, |
134 | delete: [163; 163), | 134 | delete: 163..163, |
135 | insert: "main()$0", | 135 | insert: "main()$0", |
136 | kind: Function, | 136 | kind: Function, |
137 | lookup: "main", | 137 | lookup: "main", |
diff --git a/crates/ra_ide/src/completion/complete_pattern.rs b/crates/ra_ide/src/completion/complete_pattern.rs index 218829b10..fdd9e928b 100644 --- a/crates/ra_ide/src/completion/complete_pattern.rs +++ b/crates/ra_ide/src/completion/complete_pattern.rs | |||
@@ -63,37 +63,37 @@ mod tests { | |||
63 | [ | 63 | [ |
64 | CompletionItem { | 64 | CompletionItem { |
65 | label: "Bar", | 65 | label: "Bar", |
66 | source_range: [246; 246), | 66 | source_range: 246..246, |
67 | delete: [246; 246), | 67 | delete: 246..246, |
68 | insert: "Bar", | 68 | insert: "Bar", |
69 | kind: Struct, | 69 | kind: Struct, |
70 | }, | 70 | }, |
71 | CompletionItem { | 71 | CompletionItem { |
72 | label: "E", | 72 | label: "E", |
73 | source_range: [246; 246), | 73 | source_range: 246..246, |
74 | delete: [246; 246), | 74 | delete: 246..246, |
75 | insert: "E", | 75 | insert: "E", |
76 | kind: Enum, | 76 | kind: Enum, |
77 | }, | 77 | }, |
78 | CompletionItem { | 78 | CompletionItem { |
79 | label: "X", | 79 | label: "X", |
80 | source_range: [246; 246), | 80 | source_range: 246..246, |
81 | delete: [246; 246), | 81 | delete: 246..246, |
82 | insert: "X", | 82 | insert: "X", |
83 | kind: EnumVariant, | 83 | kind: EnumVariant, |
84 | detail: "()", | 84 | detail: "()", |
85 | }, | 85 | }, |
86 | CompletionItem { | 86 | CompletionItem { |
87 | label: "Z", | 87 | label: "Z", |
88 | source_range: [246; 246), | 88 | source_range: 246..246, |
89 | delete: [246; 246), | 89 | delete: 246..246, |
90 | insert: "Z", | 90 | insert: "Z", |
91 | kind: Const, | 91 | kind: Const, |
92 | }, | 92 | }, |
93 | CompletionItem { | 93 | CompletionItem { |
94 | label: "m", | 94 | label: "m", |
95 | source_range: [246; 246), | 95 | source_range: 246..246, |
96 | delete: [246; 246), | 96 | delete: 246..246, |
97 | insert: "m", | 97 | insert: "m", |
98 | kind: Module, | 98 | kind: Module, |
99 | }, | 99 | }, |
@@ -119,15 +119,15 @@ mod tests { | |||
119 | [ | 119 | [ |
120 | CompletionItem { | 120 | CompletionItem { |
121 | label: "E", | 121 | label: "E", |
122 | source_range: [151; 151), | 122 | source_range: 151..151, |
123 | delete: [151; 151), | 123 | delete: 151..151, |
124 | insert: "E", | 124 | insert: "E", |
125 | kind: Enum, | 125 | kind: Enum, |
126 | }, | 126 | }, |
127 | CompletionItem { | 127 | CompletionItem { |
128 | label: "m!(…)", | 128 | label: "m!(…)", |
129 | source_range: [151; 151), | 129 | source_range: 151..151, |
130 | delete: [151; 151), | 130 | delete: 151..151, |
131 | insert: "m!($0)", | 131 | insert: "m!($0)", |
132 | kind: Macro, | 132 | kind: Macro, |
133 | detail: "macro_rules! m", | 133 | detail: "macro_rules! m", |
diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs index 8d397b0fe..6a0f0c72e 100644 --- a/crates/ra_ide/src/completion/complete_postfix.rs +++ b/crates/ra_ide/src/completion/complete_postfix.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | ast::{self, AstNode}, | 4 | ast::{self, AstNode}, |
5 | TextRange, TextUnit, | 5 | TextRange, TextSize, |
6 | }; | 6 | }; |
7 | use ra_text_edit::TextEdit; | 7 | use ra_text_edit::TextEdit; |
8 | 8 | ||
@@ -115,7 +115,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { | |||
115 | fn get_receiver_text(receiver: &ast::Expr, receiver_is_ambiguous_float_literal: bool) -> String { | 115 | fn get_receiver_text(receiver: &ast::Expr, receiver_is_ambiguous_float_literal: bool) -> String { |
116 | if receiver_is_ambiguous_float_literal { | 116 | if receiver_is_ambiguous_float_literal { |
117 | let text = receiver.syntax().text(); | 117 | let text = receiver.syntax().text(); |
118 | let without_dot = ..text.len() - TextUnit::of_char('.'); | 118 | let without_dot = ..text.len() - TextSize::of('.'); |
119 | text.slice(without_dot).to_string() | 119 | text.slice(without_dot).to_string() |
120 | } else { | 120 | } else { |
121 | receiver.to_string() | 121 | receiver.to_string() |
@@ -143,7 +143,7 @@ fn postfix_snippet( | |||
143 | let edit = { | 143 | let edit = { |
144 | let receiver_syntax = receiver.syntax(); | 144 | let receiver_syntax = receiver.syntax(); |
145 | let receiver_range = ctx.sema.original_range(receiver_syntax).range; | 145 | let receiver_range = ctx.sema.original_range(receiver_syntax).range; |
146 | let delete_range = TextRange::from_to(receiver_range.start(), ctx.source_range().end()); | 146 | let delete_range = TextRange::new(receiver_range.start(), ctx.source_range().end()); |
147 | TextEdit::replace(delete_range, snippet.to_string()) | 147 | TextEdit::replace(delete_range, snippet.to_string()) |
148 | }; | 148 | }; |
149 | CompletionItem::new(CompletionKind::Postfix, ctx.source_range(), label) | 149 | CompletionItem::new(CompletionKind::Postfix, ctx.source_range(), label) |
@@ -176,57 +176,57 @@ mod tests { | |||
176 | [ | 176 | [ |
177 | CompletionItem { | 177 | CompletionItem { |
178 | label: "box", | 178 | label: "box", |
179 | source_range: [89; 89), | 179 | source_range: 89..89, |
180 | delete: [85; 89), | 180 | delete: 85..89, |
181 | insert: "Box::new(bar)", | 181 | insert: "Box::new(bar)", |
182 | detail: "Box::new(expr)", | 182 | detail: "Box::new(expr)", |
183 | }, | 183 | }, |
184 | CompletionItem { | 184 | CompletionItem { |
185 | label: "dbg", | 185 | label: "dbg", |
186 | source_range: [89; 89), | 186 | source_range: 89..89, |
187 | delete: [85; 89), | 187 | delete: 85..89, |
188 | insert: "dbg!(bar)", | 188 | insert: "dbg!(bar)", |
189 | detail: "dbg!(expr)", | 189 | detail: "dbg!(expr)", |
190 | }, | 190 | }, |
191 | CompletionItem { | 191 | CompletionItem { |
192 | label: "if", | 192 | label: "if", |
193 | source_range: [89; 89), | 193 | source_range: 89..89, |
194 | delete: [85; 89), | 194 | delete: 85..89, |
195 | insert: "if bar {$0}", | 195 | insert: "if bar {$0}", |
196 | detail: "if expr {}", | 196 | detail: "if expr {}", |
197 | }, | 197 | }, |
198 | CompletionItem { | 198 | CompletionItem { |
199 | label: "match", | 199 | label: "match", |
200 | source_range: [89; 89), | 200 | source_range: 89..89, |
201 | delete: [85; 89), | 201 | delete: 85..89, |
202 | insert: "match bar {\n ${1:_} => {$0\\},\n}", | 202 | insert: "match bar {\n ${1:_} => {$0\\},\n}", |
203 | detail: "match expr {}", | 203 | detail: "match expr {}", |
204 | }, | 204 | }, |
205 | CompletionItem { | 205 | CompletionItem { |
206 | label: "not", | 206 | label: "not", |
207 | source_range: [89; 89), | 207 | source_range: 89..89, |
208 | delete: [85; 89), | 208 | delete: 85..89, |
209 | insert: "!bar", | 209 | insert: "!bar", |
210 | detail: "!expr", | 210 | detail: "!expr", |
211 | }, | 211 | }, |
212 | CompletionItem { | 212 | CompletionItem { |
213 | label: "ref", | 213 | label: "ref", |
214 | source_range: [89; 89), | 214 | source_range: 89..89, |
215 | delete: [85; 89), | 215 | delete: 85..89, |
216 | insert: "&bar", | 216 | insert: "&bar", |
217 | detail: "&expr", | 217 | detail: "&expr", |
218 | }, | 218 | }, |
219 | CompletionItem { | 219 | CompletionItem { |
220 | label: "refm", | 220 | label: "refm", |
221 | source_range: [89; 89), | 221 | source_range: 89..89, |
222 | delete: [85; 89), | 222 | delete: 85..89, |
223 | insert: "&mut bar", | 223 | insert: "&mut bar", |
224 | detail: "&mut expr", | 224 | detail: "&mut expr", |
225 | }, | 225 | }, |
226 | CompletionItem { | 226 | CompletionItem { |
227 | label: "while", | 227 | label: "while", |
228 | source_range: [89; 89), | 228 | source_range: 89..89, |
229 | delete: [85; 89), | 229 | delete: 85..89, |
230 | insert: "while bar {\n$0\n}", | 230 | insert: "while bar {\n$0\n}", |
231 | detail: "while expr {}", | 231 | detail: "while expr {}", |
232 | }, | 232 | }, |
@@ -250,43 +250,43 @@ mod tests { | |||
250 | [ | 250 | [ |
251 | CompletionItem { | 251 | CompletionItem { |
252 | label: "box", | 252 | label: "box", |
253 | source_range: [91; 91), | 253 | source_range: 91..91, |
254 | delete: [87; 91), | 254 | delete: 87..91, |
255 | insert: "Box::new(bar)", | 255 | insert: "Box::new(bar)", |
256 | detail: "Box::new(expr)", | 256 | detail: "Box::new(expr)", |
257 | }, | 257 | }, |
258 | CompletionItem { | 258 | CompletionItem { |
259 | label: "dbg", | 259 | label: "dbg", |
260 | source_range: [91; 91), | 260 | source_range: 91..91, |
261 | delete: [87; 91), | 261 | delete: 87..91, |
262 | insert: "dbg!(bar)", | 262 | insert: "dbg!(bar)", |
263 | detail: "dbg!(expr)", | 263 | detail: "dbg!(expr)", |
264 | }, | 264 | }, |
265 | CompletionItem { | 265 | CompletionItem { |
266 | label: "match", | 266 | label: "match", |
267 | source_range: [91; 91), | 267 | source_range: 91..91, |
268 | delete: [87; 91), | 268 | delete: 87..91, |
269 | insert: "match bar {\n ${1:_} => {$0\\},\n}", | 269 | insert: "match bar {\n ${1:_} => {$0\\},\n}", |
270 | detail: "match expr {}", | 270 | detail: "match expr {}", |
271 | }, | 271 | }, |
272 | CompletionItem { | 272 | CompletionItem { |
273 | label: "not", | 273 | label: "not", |
274 | source_range: [91; 91), | 274 | source_range: 91..91, |
275 | delete: [87; 91), | 275 | delete: 87..91, |
276 | insert: "!bar", | 276 | insert: "!bar", |
277 | detail: "!expr", | 277 | detail: "!expr", |
278 | }, | 278 | }, |
279 | CompletionItem { | 279 | CompletionItem { |
280 | label: "ref", | 280 | label: "ref", |
281 | source_range: [91; 91), | 281 | source_range: 91..91, |
282 | delete: [87; 91), | 282 | delete: 87..91, |
283 | insert: "&bar", | 283 | insert: "&bar", |
284 | detail: "&expr", | 284 | detail: "&expr", |
285 | }, | 285 | }, |
286 | CompletionItem { | 286 | CompletionItem { |
287 | label: "refm", | 287 | label: "refm", |
288 | source_range: [91; 91), | 288 | source_range: 91..91, |
289 | delete: [87; 91), | 289 | delete: 87..91, |
290 | insert: "&mut bar", | 290 | insert: "&mut bar", |
291 | detail: "&mut expr", | 291 | detail: "&mut expr", |
292 | }, | 292 | }, |
@@ -309,43 +309,43 @@ mod tests { | |||
309 | [ | 309 | [ |
310 | CompletionItem { | 310 | CompletionItem { |
311 | label: "box", | 311 | label: "box", |
312 | source_range: [52; 52), | 312 | source_range: 52..52, |
313 | delete: [49; 52), | 313 | delete: 49..52, |
314 | insert: "Box::new(42)", | 314 | insert: "Box::new(42)", |
315 | detail: "Box::new(expr)", | 315 | detail: "Box::new(expr)", |
316 | }, | 316 | }, |
317 | CompletionItem { | 317 | CompletionItem { |
318 | label: "dbg", | 318 | label: "dbg", |
319 | source_range: [52; 52), | 319 | source_range: 52..52, |
320 | delete: [49; 52), | 320 | delete: 49..52, |
321 | insert: "dbg!(42)", | 321 | insert: "dbg!(42)", |
322 | detail: "dbg!(expr)", | 322 | detail: "dbg!(expr)", |
323 | }, | 323 | }, |
324 | CompletionItem { | 324 | CompletionItem { |
325 | label: "match", | 325 | label: "match", |
326 | source_range: [52; 52), | 326 | source_range: 52..52, |
327 | delete: [49; 52), | 327 | delete: 49..52, |
328 | insert: "match 42 {\n ${1:_} => {$0\\},\n}", | 328 | insert: "match 42 {\n ${1:_} => {$0\\},\n}", |
329 | detail: "match expr {}", | 329 | detail: "match expr {}", |
330 | }, | 330 | }, |
331 | CompletionItem { | 331 | CompletionItem { |
332 | label: "not", | 332 | label: "not", |
333 | source_range: [52; 52), | 333 | source_range: 52..52, |
334 | delete: [49; 52), | 334 | delete: 49..52, |
335 | insert: "!42", | 335 | insert: "!42", |
336 | detail: "!expr", | 336 | detail: "!expr", |
337 | }, | 337 | }, |
338 | CompletionItem { | 338 | CompletionItem { |
339 | label: "ref", | 339 | label: "ref", |
340 | source_range: [52; 52), | 340 | source_range: 52..52, |
341 | delete: [49; 52), | 341 | delete: 49..52, |
342 | insert: "&42", | 342 | insert: "&42", |
343 | detail: "&expr", | 343 | detail: "&expr", |
344 | }, | 344 | }, |
345 | CompletionItem { | 345 | CompletionItem { |
346 | label: "refm", | 346 | label: "refm", |
347 | source_range: [52; 52), | 347 | source_range: 52..52, |
348 | delete: [49; 52), | 348 | delete: 49..52, |
349 | insert: "&mut 42", | 349 | insert: "&mut 42", |
350 | detail: "&mut expr", | 350 | detail: "&mut expr", |
351 | }, | 351 | }, |
@@ -370,43 +370,43 @@ mod tests { | |||
370 | [ | 370 | [ |
371 | CompletionItem { | 371 | CompletionItem { |
372 | label: "box", | 372 | label: "box", |
373 | source_range: [149; 150), | 373 | source_range: 149..150, |
374 | delete: [145; 150), | 374 | delete: 145..150, |
375 | insert: "Box::new(bar)", | 375 | insert: "Box::new(bar)", |
376 | detail: "Box::new(expr)", | 376 | detail: "Box::new(expr)", |
377 | }, | 377 | }, |
378 | CompletionItem { | 378 | CompletionItem { |
379 | label: "dbg", | 379 | label: "dbg", |
380 | source_range: [149; 150), | 380 | source_range: 149..150, |
381 | delete: [145; 150), | 381 | delete: 145..150, |
382 | insert: "dbg!(bar)", | 382 | insert: "dbg!(bar)", |
383 | detail: "dbg!(expr)", | 383 | detail: "dbg!(expr)", |
384 | }, | 384 | }, |
385 | CompletionItem { | 385 | CompletionItem { |
386 | label: "match", | 386 | label: "match", |
387 | source_range: [149; 150), | 387 | source_range: 149..150, |
388 | delete: [145; 150), | 388 | delete: 145..150, |
389 | insert: "match bar {\n ${1:_} => {$0\\},\n}", | 389 | insert: "match bar {\n ${1:_} => {$0\\},\n}", |
390 | detail: "match expr {}", | 390 | detail: "match expr {}", |
391 | }, | 391 | }, |
392 | CompletionItem { | 392 | CompletionItem { |
393 | label: "not", | 393 | label: "not", |
394 | source_range: [149; 150), | 394 | source_range: 149..150, |
395 | delete: [145; 150), | 395 | delete: 145..150, |
396 | insert: "!bar", | 396 | insert: "!bar", |
397 | detail: "!expr", | 397 | detail: "!expr", |
398 | }, | 398 | }, |
399 | CompletionItem { | 399 | CompletionItem { |
400 | label: "ref", | 400 | label: "ref", |
401 | source_range: [149; 150), | 401 | source_range: 149..150, |
402 | delete: [145; 150), | 402 | delete: 145..150, |
403 | insert: "&bar", | 403 | insert: "&bar", |
404 | detail: "&expr", | 404 | detail: "&expr", |
405 | }, | 405 | }, |
406 | CompletionItem { | 406 | CompletionItem { |
407 | label: "refm", | 407 | label: "refm", |
408 | source_range: [149; 150), | 408 | source_range: 149..150, |
409 | delete: [145; 150), | 409 | delete: 145..150, |
410 | insert: "&mut bar", | 410 | insert: "&mut bar", |
411 | detail: "&mut expr", | 411 | detail: "&mut expr", |
412 | }, | 412 | }, |
@@ -429,43 +429,43 @@ mod tests { | |||
429 | [ | 429 | [ |
430 | CompletionItem { | 430 | CompletionItem { |
431 | label: "box", | 431 | label: "box", |
432 | source_range: [56; 56), | 432 | source_range: 56..56, |
433 | delete: [49; 56), | 433 | delete: 49..56, |
434 | insert: "Box::new(&&&&42)", | 434 | insert: "Box::new(&&&&42)", |
435 | detail: "Box::new(expr)", | 435 | detail: "Box::new(expr)", |
436 | }, | 436 | }, |
437 | CompletionItem { | 437 | CompletionItem { |
438 | label: "dbg", | 438 | label: "dbg", |
439 | source_range: [56; 56), | 439 | source_range: 56..56, |
440 | delete: [49; 56), | 440 | delete: 49..56, |
441 | insert: "dbg!(&&&&42)", | 441 | insert: "dbg!(&&&&42)", |
442 | detail: "dbg!(expr)", | 442 | detail: "dbg!(expr)", |
443 | }, | 443 | }, |
444 | CompletionItem { | 444 | CompletionItem { |
445 | label: "match", | 445 | label: "match", |
446 | source_range: [56; 56), | 446 | source_range: 56..56, |
447 | delete: [49; 56), | 447 | delete: 49..56, |
448 | insert: "match &&&&42 {\n ${1:_} => {$0\\},\n}", | 448 | insert: "match &&&&42 {\n ${1:_} => {$0\\},\n}", |
449 | detail: "match expr {}", | 449 | detail: "match expr {}", |
450 | }, | 450 | }, |
451 | CompletionItem { | 451 | CompletionItem { |
452 | label: "not", | 452 | label: "not", |
453 | source_range: [56; 56), | 453 | source_range: 56..56, |
454 | delete: [53; 56), | 454 | delete: 53..56, |
455 | insert: "!42", | 455 | insert: "!42", |
456 | detail: "!expr", | 456 | detail: "!expr", |
457 | }, | 457 | }, |
458 | CompletionItem { | 458 | CompletionItem { |
459 | label: "ref", | 459 | label: "ref", |
460 | source_range: [56; 56), | 460 | source_range: 56..56, |
461 | delete: [53; 56), | 461 | delete: 53..56, |
462 | insert: "&42", | 462 | insert: "&42", |
463 | detail: "&expr", | 463 | detail: "&expr", |
464 | }, | 464 | }, |
465 | CompletionItem { | 465 | CompletionItem { |
466 | label: "refm", | 466 | label: "refm", |
467 | source_range: [56; 56), | 467 | source_range: 56..56, |
468 | delete: [53; 56), | 468 | delete: 53..56, |
469 | insert: "&mut 42", | 469 | insert: "&mut 42", |
470 | detail: "&mut expr", | 470 | detail: "&mut expr", |
471 | }, | 471 | }, |
diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs index 5a5139e14..dd10f74e6 100644 --- a/crates/ra_ide/src/completion/complete_qualified_path.rs +++ b/crates/ra_ide/src/completion/complete_qualified_path.rs | |||
@@ -162,8 +162,8 @@ mod tests { | |||
162 | [ | 162 | [ |
163 | CompletionItem { | 163 | CompletionItem { |
164 | label: "my", | 164 | label: "my", |
165 | source_range: [27; 29), | 165 | source_range: 27..29, |
166 | delete: [27; 29), | 166 | delete: 27..29, |
167 | insert: "my", | 167 | insert: "my", |
168 | kind: Module, | 168 | kind: Module, |
169 | documentation: Documentation( | 169 | documentation: Documentation( |
@@ -193,15 +193,15 @@ mod tests { | |||
193 | [ | 193 | [ |
194 | CompletionItem { | 194 | CompletionItem { |
195 | label: "Foo", | 195 | label: "Foo", |
196 | source_range: [31; 31), | 196 | source_range: 31..31, |
197 | delete: [31; 31), | 197 | delete: 31..31, |
198 | insert: "Foo", | 198 | insert: "Foo", |
199 | kind: Struct, | 199 | kind: Struct, |
200 | }, | 200 | }, |
201 | CompletionItem { | 201 | CompletionItem { |
202 | label: "PublicBar", | 202 | label: "PublicBar", |
203 | source_range: [31; 31), | 203 | source_range: 31..31, |
204 | delete: [31; 31), | 204 | delete: 31..31, |
205 | insert: "PublicBar", | 205 | insert: "PublicBar", |
206 | kind: Struct, | 206 | kind: Struct, |
207 | }, | 207 | }, |
@@ -226,8 +226,8 @@ mod tests { | |||
226 | [ | 226 | [ |
227 | CompletionItem { | 227 | CompletionItem { |
228 | label: "Bar", | 228 | label: "Bar", |
229 | source_range: [30; 30), | 229 | source_range: 30..30, |
230 | delete: [30; 30), | 230 | delete: 30..30, |
231 | insert: "Bar", | 231 | insert: "Bar", |
232 | kind: Struct, | 232 | kind: Struct, |
233 | }, | 233 | }, |
@@ -252,15 +252,15 @@ mod tests { | |||
252 | [ | 252 | [ |
253 | CompletionItem { | 253 | CompletionItem { |
254 | label: "Spam", | 254 | label: "Spam", |
255 | source_range: [11; 13), | 255 | source_range: 11..13, |
256 | delete: [11; 13), | 256 | delete: 11..13, |
257 | insert: "Spam", | 257 | insert: "Spam", |
258 | kind: Struct, | 258 | kind: Struct, |
259 | }, | 259 | }, |
260 | CompletionItem { | 260 | CompletionItem { |
261 | label: "foo", | 261 | label: "foo", |
262 | source_range: [11; 13), | 262 | source_range: 11..13, |
263 | delete: [11; 13), | 263 | delete: 11..13, |
264 | insert: "foo", | 264 | insert: "foo", |
265 | kind: Module, | 265 | kind: Module, |
266 | }, | 266 | }, |
@@ -285,15 +285,15 @@ mod tests { | |||
285 | [ | 285 | [ |
286 | CompletionItem { | 286 | CompletionItem { |
287 | label: "Spam", | 287 | label: "Spam", |
288 | source_range: [12; 14), | 288 | source_range: 12..14, |
289 | delete: [12; 14), | 289 | delete: 12..14, |
290 | insert: "Spam", | 290 | insert: "Spam", |
291 | kind: Struct, | 291 | kind: Struct, |
292 | }, | 292 | }, |
293 | CompletionItem { | 293 | CompletionItem { |
294 | label: "foo", | 294 | label: "foo", |
295 | source_range: [12; 14), | 295 | source_range: 12..14, |
296 | delete: [12; 14), | 296 | delete: 12..14, |
297 | insert: "foo", | 297 | insert: "foo", |
298 | kind: Module, | 298 | kind: Module, |
299 | }, | 299 | }, |
@@ -322,8 +322,8 @@ mod tests { | |||
322 | [ | 322 | [ |
323 | CompletionItem { | 323 | CompletionItem { |
324 | label: "Spam", | 324 | label: "Spam", |
325 | source_range: [23; 25), | 325 | source_range: 23..25, |
326 | delete: [23; 25), | 326 | delete: 23..25, |
327 | insert: "Spam", | 327 | insert: "Spam", |
328 | kind: Struct, | 328 | kind: Struct, |
329 | }, | 329 | }, |
@@ -352,8 +352,8 @@ mod tests { | |||
352 | [ | 352 | [ |
353 | CompletionItem { | 353 | CompletionItem { |
354 | label: "Bar(…)", | 354 | label: "Bar(…)", |
355 | source_range: [116; 116), | 355 | source_range: 116..116, |
356 | delete: [116; 116), | 356 | delete: 116..116, |
357 | insert: "Bar($0)", | 357 | insert: "Bar($0)", |
358 | kind: EnumVariant, | 358 | kind: EnumVariant, |
359 | lookup: "Bar", | 359 | lookup: "Bar", |
@@ -365,8 +365,8 @@ mod tests { | |||
365 | }, | 365 | }, |
366 | CompletionItem { | 366 | CompletionItem { |
367 | label: "Foo", | 367 | label: "Foo", |
368 | source_range: [116; 116), | 368 | source_range: 116..116, |
369 | delete: [116; 116), | 369 | delete: 116..116, |
370 | insert: "Foo", | 370 | insert: "Foo", |
371 | kind: EnumVariant, | 371 | kind: EnumVariant, |
372 | detail: "()", | 372 | detail: "()", |
@@ -402,8 +402,8 @@ mod tests { | |||
402 | [ | 402 | [ |
403 | CompletionItem { | 403 | CompletionItem { |
404 | label: "Bar(…)", | 404 | label: "Bar(…)", |
405 | source_range: [180; 180), | 405 | source_range: 180..180, |
406 | delete: [180; 180), | 406 | delete: 180..180, |
407 | insert: "Bar($0)", | 407 | insert: "Bar($0)", |
408 | kind: EnumVariant, | 408 | kind: EnumVariant, |
409 | lookup: "Bar", | 409 | lookup: "Bar", |
@@ -415,8 +415,8 @@ mod tests { | |||
415 | }, | 415 | }, |
416 | CompletionItem { | 416 | CompletionItem { |
417 | label: "Foo", | 417 | label: "Foo", |
418 | source_range: [180; 180), | 418 | source_range: 180..180, |
419 | delete: [180; 180), | 419 | delete: 180..180, |
420 | insert: "Foo", | 420 | insert: "Foo", |
421 | kind: EnumVariant, | 421 | kind: EnumVariant, |
422 | detail: "()", | 422 | detail: "()", |
@@ -426,8 +426,8 @@ mod tests { | |||
426 | }, | 426 | }, |
427 | CompletionItem { | 427 | CompletionItem { |
428 | label: "S(…)", | 428 | label: "S(…)", |
429 | source_range: [180; 180), | 429 | source_range: 180..180, |
430 | delete: [180; 180), | 430 | delete: 180..180, |
431 | insert: "S($0)", | 431 | insert: "S($0)", |
432 | kind: EnumVariant, | 432 | kind: EnumVariant, |
433 | lookup: "S", | 433 | lookup: "S", |
@@ -463,8 +463,8 @@ mod tests { | |||
463 | [ | 463 | [ |
464 | CompletionItem { | 464 | CompletionItem { |
465 | label: "m()", | 465 | label: "m()", |
466 | source_range: [100; 100), | 466 | source_range: 100..100, |
467 | delete: [100; 100), | 467 | delete: 100..100, |
468 | insert: "m()$0", | 468 | insert: "m()$0", |
469 | kind: Function, | 469 | kind: Function, |
470 | lookup: "m", | 470 | lookup: "m", |
@@ -499,8 +499,8 @@ mod tests { | |||
499 | [ | 499 | [ |
500 | CompletionItem { | 500 | CompletionItem { |
501 | label: "m()", | 501 | label: "m()", |
502 | source_range: [105; 105), | 502 | source_range: 105..105, |
503 | delete: [105; 105), | 503 | delete: 105..105, |
504 | insert: "m()$0", | 504 | insert: "m()$0", |
505 | kind: Method, | 505 | kind: Method, |
506 | lookup: "m", | 506 | lookup: "m", |
@@ -535,8 +535,8 @@ mod tests { | |||
535 | [ | 535 | [ |
536 | CompletionItem { | 536 | CompletionItem { |
537 | label: "C", | 537 | label: "C", |
538 | source_range: [107; 107), | 538 | source_range: 107..107, |
539 | delete: [107; 107), | 539 | delete: 107..107, |
540 | insert: "C", | 540 | insert: "C", |
541 | kind: Const, | 541 | kind: Const, |
542 | detail: "const C: i32 = 42;", | 542 | detail: "const C: i32 = 42;", |
@@ -570,8 +570,8 @@ mod tests { | |||
570 | [ | 570 | [ |
571 | CompletionItem { | 571 | CompletionItem { |
572 | label: "T", | 572 | label: "T", |
573 | source_range: [101; 101), | 573 | source_range: 101..101, |
574 | delete: [101; 101), | 574 | delete: 101..101, |
575 | insert: "T", | 575 | insert: "T", |
576 | kind: TypeAlias, | 576 | kind: TypeAlias, |
577 | detail: "type T = i32;", | 577 | detail: "type T = i32;", |
@@ -610,24 +610,24 @@ mod tests { | |||
610 | [ | 610 | [ |
611 | CompletionItem { | 611 | CompletionItem { |
612 | label: "PUBLIC_CONST", | 612 | label: "PUBLIC_CONST", |
613 | source_range: [302; 302), | 613 | source_range: 302..302, |
614 | delete: [302; 302), | 614 | delete: 302..302, |
615 | insert: "PUBLIC_CONST", | 615 | insert: "PUBLIC_CONST", |
616 | kind: Const, | 616 | kind: Const, |
617 | detail: "pub(super) const PUBLIC_CONST: u32 = 1;", | 617 | detail: "pub(super) const PUBLIC_CONST: u32 = 1;", |
618 | }, | 618 | }, |
619 | CompletionItem { | 619 | CompletionItem { |
620 | label: "PublicType", | 620 | label: "PublicType", |
621 | source_range: [302; 302), | 621 | source_range: 302..302, |
622 | delete: [302; 302), | 622 | delete: 302..302, |
623 | insert: "PublicType", | 623 | insert: "PublicType", |
624 | kind: TypeAlias, | 624 | kind: TypeAlias, |
625 | detail: "pub(super) type PublicType = u32;", | 625 | detail: "pub(super) type PublicType = u32;", |
626 | }, | 626 | }, |
627 | CompletionItem { | 627 | CompletionItem { |
628 | label: "public_method()", | 628 | label: "public_method()", |
629 | source_range: [302; 302), | 629 | source_range: 302..302, |
630 | delete: [302; 302), | 630 | delete: 302..302, |
631 | insert: "public_method()$0", | 631 | insert: "public_method()$0", |
632 | kind: Function, | 632 | kind: Function, |
633 | lookup: "public_method", | 633 | lookup: "public_method", |
@@ -659,8 +659,8 @@ mod tests { | |||
659 | [ | 659 | [ |
660 | CompletionItem { | 660 | CompletionItem { |
661 | label: "m()", | 661 | label: "m()", |
662 | source_range: [100; 100), | 662 | source_range: 100..100, |
663 | delete: [100; 100), | 663 | delete: 100..100, |
664 | insert: "m()$0", | 664 | insert: "m()$0", |
665 | kind: Function, | 665 | kind: Function, |
666 | lookup: "m", | 666 | lookup: "m", |
@@ -695,8 +695,8 @@ mod tests { | |||
695 | [ | 695 | [ |
696 | CompletionItem { | 696 | CompletionItem { |
697 | label: "m()", | 697 | label: "m()", |
698 | source_range: [101; 101), | 698 | source_range: 101..101, |
699 | delete: [101; 101), | 699 | delete: 101..101, |
700 | insert: "m()$0", | 700 | insert: "m()$0", |
701 | kind: Function, | 701 | kind: Function, |
702 | lookup: "m", | 702 | lookup: "m", |
@@ -728,8 +728,8 @@ mod tests { | |||
728 | [ | 728 | [ |
729 | CompletionItem { | 729 | CompletionItem { |
730 | label: "bar", | 730 | label: "bar", |
731 | source_range: [9; 9), | 731 | source_range: 9..9, |
732 | delete: [9; 9), | 732 | delete: 9..9, |
733 | insert: "bar", | 733 | insert: "bar", |
734 | kind: Module, | 734 | kind: Module, |
735 | }, | 735 | }, |
@@ -756,8 +756,8 @@ mod tests { | |||
756 | [ | 756 | [ |
757 | CompletionItem { | 757 | CompletionItem { |
758 | label: "m()", | 758 | label: "m()", |
759 | source_range: [73; 73), | 759 | source_range: 73..73, |
760 | delete: [73; 73), | 760 | delete: 73..73, |
761 | insert: "m()$0", | 761 | insert: "m()$0", |
762 | kind: Function, | 762 | kind: Function, |
763 | lookup: "m", | 763 | lookup: "m", |
@@ -792,8 +792,8 @@ mod tests { | |||
792 | [ | 792 | [ |
793 | CompletionItem { | 793 | CompletionItem { |
794 | label: "m()", | 794 | label: "m()", |
795 | source_range: [99; 99), | 795 | source_range: 99..99, |
796 | delete: [99; 99), | 796 | delete: 99..99, |
797 | insert: "m()$0", | 797 | insert: "m()$0", |
798 | kind: Function, | 798 | kind: Function, |
799 | lookup: "m", | 799 | lookup: "m", |
@@ -828,8 +828,8 @@ mod tests { | |||
828 | [ | 828 | [ |
829 | CompletionItem { | 829 | CompletionItem { |
830 | label: "m()", | 830 | label: "m()", |
831 | source_range: [110; 110), | 831 | source_range: 110..110, |
832 | delete: [110; 110), | 832 | delete: 110..110, |
833 | insert: "m()$0", | 833 | insert: "m()$0", |
834 | kind: Function, | 834 | kind: Function, |
835 | lookup: "m", | 835 | lookup: "m", |
@@ -862,8 +862,8 @@ mod tests { | |||
862 | [ | 862 | [ |
863 | CompletionItem { | 863 | CompletionItem { |
864 | label: "bar()", | 864 | label: "bar()", |
865 | source_range: [185; 185), | 865 | source_range: 185..185, |
866 | delete: [185; 185), | 866 | delete: 185..185, |
867 | insert: "bar()$0", | 867 | insert: "bar()$0", |
868 | kind: Function, | 868 | kind: Function, |
869 | lookup: "bar", | 869 | lookup: "bar", |
@@ -871,8 +871,8 @@ mod tests { | |||
871 | }, | 871 | }, |
872 | CompletionItem { | 872 | CompletionItem { |
873 | label: "foo()", | 873 | label: "foo()", |
874 | source_range: [185; 185), | 874 | source_range: 185..185, |
875 | delete: [185; 185), | 875 | delete: 185..185, |
876 | insert: "foo()$0", | 876 | insert: "foo()$0", |
877 | kind: Function, | 877 | kind: Function, |
878 | lookup: "foo", | 878 | lookup: "foo", |
@@ -902,16 +902,16 @@ mod tests { | |||
902 | [ | 902 | [ |
903 | CompletionItem { | 903 | CompletionItem { |
904 | label: "foo!(…)", | 904 | label: "foo!(…)", |
905 | source_range: [179; 179), | 905 | source_range: 179..179, |
906 | delete: [179; 179), | 906 | delete: 179..179, |
907 | insert: "foo!($0)", | 907 | insert: "foo!($0)", |
908 | kind: Macro, | 908 | kind: Macro, |
909 | detail: "#[macro_export]\nmacro_rules! foo", | 909 | detail: "#[macro_export]\nmacro_rules! foo", |
910 | }, | 910 | }, |
911 | CompletionItem { | 911 | CompletionItem { |
912 | label: "main()", | 912 | label: "main()", |
913 | source_range: [179; 179), | 913 | source_range: 179..179, |
914 | delete: [179; 179), | 914 | delete: 179..179, |
915 | insert: "main()$0", | 915 | insert: "main()$0", |
916 | kind: Function, | 916 | kind: Function, |
917 | lookup: "main", | 917 | lookup: "main", |
@@ -947,22 +947,22 @@ mod tests { | |||
947 | [ | 947 | [ |
948 | CompletionItem { | 948 | CompletionItem { |
949 | label: "RIGHT_CONST", | 949 | label: "RIGHT_CONST", |
950 | source_range: [57; 57), | 950 | source_range: 57..57, |
951 | delete: [57; 57), | 951 | delete: 57..57, |
952 | insert: "RIGHT_CONST", | 952 | insert: "RIGHT_CONST", |
953 | kind: Const, | 953 | kind: Const, |
954 | }, | 954 | }, |
955 | CompletionItem { | 955 | CompletionItem { |
956 | label: "RightType", | 956 | label: "RightType", |
957 | source_range: [57; 57), | 957 | source_range: 57..57, |
958 | delete: [57; 57), | 958 | delete: 57..57, |
959 | insert: "RightType", | 959 | insert: "RightType", |
960 | kind: Struct, | 960 | kind: Struct, |
961 | }, | 961 | }, |
962 | CompletionItem { | 962 | CompletionItem { |
963 | label: "right_fn()", | 963 | label: "right_fn()", |
964 | source_range: [57; 57), | 964 | source_range: 57..57, |
965 | delete: [57; 57), | 965 | delete: 57..57, |
966 | insert: "right_fn()$0", | 966 | insert: "right_fn()$0", |
967 | kind: Function, | 967 | kind: Function, |
968 | lookup: "right_fn", | 968 | lookup: "right_fn", |
@@ -986,8 +986,8 @@ mod tests { | |||
986 | [ | 986 | [ |
987 | CompletionItem { | 987 | CompletionItem { |
988 | label: "foo()", | 988 | label: "foo()", |
989 | source_range: [93; 94), | 989 | source_range: 93..94, |
990 | delete: [93; 94), | 990 | delete: 93..94, |
991 | insert: "foo()$0", | 991 | insert: "foo()$0", |
992 | kind: Function, | 992 | kind: Function, |
993 | lookup: "foo", | 993 | lookup: "foo", |
@@ -995,8 +995,8 @@ mod tests { | |||
995 | }, | 995 | }, |
996 | CompletionItem { | 996 | CompletionItem { |
997 | label: "main()", | 997 | label: "main()", |
998 | source_range: [93; 94), | 998 | source_range: 93..94, |
999 | delete: [93; 94), | 999 | delete: 93..94, |
1000 | insert: "main()$0", | 1000 | insert: "main()$0", |
1001 | kind: Function, | 1001 | kind: Function, |
1002 | lookup: "main", | 1002 | lookup: "main", |
@@ -1025,15 +1025,15 @@ mod tests { | |||
1025 | [ | 1025 | [ |
1026 | CompletionItem { | 1026 | CompletionItem { |
1027 | label: "z", | 1027 | label: "z", |
1028 | source_range: [57; 57), | 1028 | source_range: 57..57, |
1029 | delete: [57; 57), | 1029 | delete: 57..57, |
1030 | insert: "z", | 1030 | insert: "z", |
1031 | kind: Module, | 1031 | kind: Module, |
1032 | }, | 1032 | }, |
1033 | CompletionItem { | 1033 | CompletionItem { |
1034 | label: "z()", | 1034 | label: "z()", |
1035 | source_range: [57; 57), | 1035 | source_range: 57..57, |
1036 | delete: [57; 57), | 1036 | delete: 57..57, |
1037 | insert: "z()$0", | 1037 | insert: "z()$0", |
1038 | kind: Function, | 1038 | kind: Function, |
1039 | lookup: "z", | 1039 | lookup: "z", |
@@ -1064,8 +1064,8 @@ mod tests { | |||
1064 | [ | 1064 | [ |
1065 | CompletionItem { | 1065 | CompletionItem { |
1066 | label: "new()", | 1066 | label: "new()", |
1067 | source_range: [292; 292), | 1067 | source_range: 292..292, |
1068 | delete: [292; 292), | 1068 | delete: 292..292, |
1069 | insert: "new()$0", | 1069 | insert: "new()$0", |
1070 | kind: Function, | 1070 | kind: Function, |
1071 | lookup: "new", | 1071 | lookup: "new", |
diff --git a/crates/ra_ide/src/completion/complete_record.rs b/crates/ra_ide/src/completion/complete_record.rs index 83a553155..b7ab654c5 100644 --- a/crates/ra_ide/src/completion/complete_record.rs +++ b/crates/ra_ide/src/completion/complete_record.rs | |||
@@ -44,8 +44,8 @@ mod tests { | |||
44 | [ | 44 | [ |
45 | CompletionItem { | 45 | CompletionItem { |
46 | label: "foo", | 46 | label: "foo", |
47 | source_range: [117; 118), | 47 | source_range: 117..118, |
48 | delete: [117; 118), | 48 | delete: 117..118, |
49 | insert: "foo", | 49 | insert: "foo", |
50 | kind: Field, | 50 | kind: Field, |
51 | detail: "u32", | 51 | detail: "u32", |
@@ -73,16 +73,16 @@ mod tests { | |||
73 | [ | 73 | [ |
74 | CompletionItem { | 74 | CompletionItem { |
75 | label: "bar", | 75 | label: "bar", |
76 | source_range: [161; 161), | 76 | source_range: 161..161, |
77 | delete: [161; 161), | 77 | delete: 161..161, |
78 | insert: "bar", | 78 | insert: "bar", |
79 | kind: Field, | 79 | kind: Field, |
80 | detail: "()", | 80 | detail: "()", |
81 | }, | 81 | }, |
82 | CompletionItem { | 82 | CompletionItem { |
83 | label: "foo", | 83 | label: "foo", |
84 | source_range: [161; 161), | 84 | source_range: 161..161, |
85 | delete: [161; 161), | 85 | delete: 161..161, |
86 | insert: "foo", | 86 | insert: "foo", |
87 | kind: Field, | 87 | kind: Field, |
88 | detail: "u32", | 88 | detail: "u32", |
@@ -109,8 +109,8 @@ mod tests { | |||
109 | [ | 109 | [ |
110 | CompletionItem { | 110 | CompletionItem { |
111 | label: "foo", | 111 | label: "foo", |
112 | source_range: [171; 172), | 112 | source_range: 171..172, |
113 | delete: [171; 172), | 113 | delete: 171..172, |
114 | insert: "foo", | 114 | insert: "foo", |
115 | kind: Field, | 115 | kind: Field, |
116 | detail: "u32", | 116 | detail: "u32", |
@@ -145,16 +145,16 @@ mod tests { | |||
145 | [ | 145 | [ |
146 | CompletionItem { | 146 | CompletionItem { |
147 | label: "bar", | 147 | label: "bar", |
148 | source_range: [372; 372), | 148 | source_range: 372..372, |
149 | delete: [372; 372), | 149 | delete: 372..372, |
150 | insert: "bar", | 150 | insert: "bar", |
151 | kind: Field, | 151 | kind: Field, |
152 | detail: "u32", | 152 | detail: "u32", |
153 | }, | 153 | }, |
154 | CompletionItem { | 154 | CompletionItem { |
155 | label: "baz", | 155 | label: "baz", |
156 | source_range: [372; 372), | 156 | source_range: 372..372, |
157 | delete: [372; 372), | 157 | delete: 372..372, |
158 | insert: "baz", | 158 | insert: "baz", |
159 | kind: Field, | 159 | kind: Field, |
160 | detail: "u32", | 160 | detail: "u32", |
@@ -190,8 +190,8 @@ mod tests { | |||
190 | [ | 190 | [ |
191 | CompletionItem { | 191 | CompletionItem { |
192 | label: "the_field", | 192 | label: "the_field", |
193 | source_range: [142; 145), | 193 | source_range: 142..145, |
194 | delete: [142; 145), | 194 | delete: 142..145, |
195 | insert: "the_field", | 195 | insert: "the_field", |
196 | kind: Field, | 196 | kind: Field, |
197 | detail: "u32", | 197 | detail: "u32", |
@@ -215,8 +215,8 @@ mod tests { | |||
215 | [ | 215 | [ |
216 | CompletionItem { | 216 | CompletionItem { |
217 | label: "the_field", | 217 | label: "the_field", |
218 | source_range: [83; 86), | 218 | source_range: 83..86, |
219 | delete: [83; 86), | 219 | delete: 83..86, |
220 | insert: "the_field", | 220 | insert: "the_field", |
221 | kind: Field, | 221 | kind: Field, |
222 | detail: "u32", | 222 | detail: "u32", |
@@ -241,8 +241,8 @@ mod tests { | |||
241 | [ | 241 | [ |
242 | CompletionItem { | 242 | CompletionItem { |
243 | label: "a", | 243 | label: "a", |
244 | source_range: [119; 119), | 244 | source_range: 119..119, |
245 | delete: [119; 119), | 245 | delete: 119..119, |
246 | insert: "a", | 246 | insert: "a", |
247 | kind: Field, | 247 | kind: Field, |
248 | detail: "u32", | 248 | detail: "u32", |
@@ -267,8 +267,8 @@ mod tests { | |||
267 | [ | 267 | [ |
268 | CompletionItem { | 268 | CompletionItem { |
269 | label: "b", | 269 | label: "b", |
270 | source_range: [119; 119), | 270 | source_range: 119..119, |
271 | delete: [119; 119), | 271 | delete: 119..119, |
272 | insert: "b", | 272 | insert: "b", |
273 | kind: Field, | 273 | kind: Field, |
274 | detail: "u32", | 274 | detail: "u32", |
@@ -292,8 +292,8 @@ mod tests { | |||
292 | [ | 292 | [ |
293 | CompletionItem { | 293 | CompletionItem { |
294 | label: "a", | 294 | label: "a", |
295 | source_range: [93; 93), | 295 | source_range: 93..93, |
296 | delete: [93; 93), | 296 | delete: 93..93, |
297 | insert: "a", | 297 | insert: "a", |
298 | kind: Field, | 298 | kind: Field, |
299 | detail: "u32", | 299 | detail: "u32", |
@@ -317,8 +317,8 @@ mod tests { | |||
317 | [ | 317 | [ |
318 | CompletionItem { | 318 | CompletionItem { |
319 | label: "the_field", | 319 | label: "the_field", |
320 | source_range: [137; 140), | 320 | source_range: 137..140, |
321 | delete: [137; 140), | 321 | delete: 137..140, |
322 | insert: "the_field", | 322 | insert: "the_field", |
323 | kind: Field, | 323 | kind: Field, |
324 | detail: "u32", | 324 | detail: "u32", |
@@ -352,16 +352,16 @@ mod tests { | |||
352 | [ | 352 | [ |
353 | CompletionItem { | 353 | CompletionItem { |
354 | label: "bar", | 354 | label: "bar", |
355 | source_range: [302; 302), | 355 | source_range: 302..302, |
356 | delete: [302; 302), | 356 | delete: 302..302, |
357 | insert: "bar", | 357 | insert: "bar", |
358 | kind: Field, | 358 | kind: Field, |
359 | detail: "u32", | 359 | detail: "u32", |
360 | }, | 360 | }, |
361 | CompletionItem { | 361 | CompletionItem { |
362 | label: "baz", | 362 | label: "baz", |
363 | source_range: [302; 302), | 363 | source_range: 302..302, |
364 | delete: [302; 302), | 364 | delete: 302..302, |
365 | insert: "baz", | 365 | insert: "baz", |
366 | kind: Field, | 366 | kind: Field, |
367 | detail: "u32", | 367 | detail: "u32", |
@@ -393,8 +393,8 @@ mod tests { | |||
393 | [ | 393 | [ |
394 | CompletionItem { | 394 | CompletionItem { |
395 | label: "foo2", | 395 | label: "foo2", |
396 | source_range: [221; 221), | 396 | source_range: 221..221, |
397 | delete: [221; 221), | 397 | delete: 221..221, |
398 | insert: "foo2", | 398 | insert: "foo2", |
399 | kind: Field, | 399 | kind: Field, |
400 | detail: "u32", | 400 | detail: "u32", |
diff --git a/crates/ra_ide/src/completion/complete_snippet.rs b/crates/ra_ide/src/completion/complete_snippet.rs index 4bccfbfed..a3f5d1b6a 100644 --- a/crates/ra_ide/src/completion/complete_snippet.rs +++ b/crates/ra_ide/src/completion/complete_snippet.rs | |||
@@ -67,15 +67,15 @@ mod tests { | |||
67 | [ | 67 | [ |
68 | CompletionItem { | 68 | CompletionItem { |
69 | label: "pd", | 69 | label: "pd", |
70 | source_range: [17; 17), | 70 | source_range: 17..17, |
71 | delete: [17; 17), | 71 | delete: 17..17, |
72 | insert: "eprintln!(\"$0 = {:?}\", $0);", | 72 | insert: "eprintln!(\"$0 = {:?}\", $0);", |
73 | kind: Snippet, | 73 | kind: Snippet, |
74 | }, | 74 | }, |
75 | CompletionItem { | 75 | CompletionItem { |
76 | label: "ppd", | 76 | label: "ppd", |
77 | source_range: [17; 17), | 77 | source_range: 17..17, |
78 | delete: [17; 17), | 78 | delete: 17..17, |
79 | insert: "eprintln!(\"$0 = {:#?}\", $0);", | 79 | insert: "eprintln!(\"$0 = {:#?}\", $0);", |
80 | kind: Snippet, | 80 | kind: Snippet, |
81 | }, | 81 | }, |
@@ -111,23 +111,23 @@ mod tests { | |||
111 | [ | 111 | [ |
112 | CompletionItem { | 112 | CompletionItem { |
113 | label: "Test function", | 113 | label: "Test function", |
114 | source_range: [78; 78), | 114 | source_range: 78..78, |
115 | delete: [78; 78), | 115 | delete: 78..78, |
116 | insert: "#[test]\nfn ${1:feature}() {\n $0\n}", | 116 | insert: "#[test]\nfn ${1:feature}() {\n $0\n}", |
117 | kind: Snippet, | 117 | kind: Snippet, |
118 | lookup: "tfn", | 118 | lookup: "tfn", |
119 | }, | 119 | }, |
120 | CompletionItem { | 120 | CompletionItem { |
121 | label: "macro_rules", | 121 | label: "macro_rules", |
122 | source_range: [78; 78), | 122 | source_range: 78..78, |
123 | delete: [78; 78), | 123 | delete: 78..78, |
124 | insert: "macro_rules! $1 {\n\t($2) => {\n\t\t$0\n\t};\n}", | 124 | insert: "macro_rules! $1 {\n\t($2) => {\n\t\t$0\n\t};\n}", |
125 | kind: Snippet, | 125 | kind: Snippet, |
126 | }, | 126 | }, |
127 | CompletionItem { | 127 | CompletionItem { |
128 | label: "pub(crate)", | 128 | label: "pub(crate)", |
129 | source_range: [78; 78), | 129 | source_range: 78..78, |
130 | delete: [78; 78), | 130 | delete: 78..78, |
131 | insert: "pub(crate) $0", | 131 | insert: "pub(crate) $0", |
132 | kind: Snippet, | 132 | kind: Snippet, |
133 | }, | 133 | }, |
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index c39943252..ee32d1ff6 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs | |||
@@ -141,7 +141,7 @@ fn add_function_impl( | |||
141 | } else { | 141 | } else { |
142 | CompletionItemKind::Function | 142 | CompletionItemKind::Function |
143 | }; | 143 | }; |
144 | let range = TextRange::from_to(fn_def_node.text_range().start(), ctx.source_range().end()); | 144 | let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end()); |
145 | 145 | ||
146 | match ctx.config.snippet_cap { | 146 | match ctx.config.snippet_cap { |
147 | Some(cap) => { | 147 | Some(cap) => { |
@@ -167,7 +167,7 @@ fn add_type_alias_impl( | |||
167 | 167 | ||
168 | let snippet = format!("type {} = ", alias_name); | 168 | let snippet = format!("type {} = ", alias_name); |
169 | 169 | ||
170 | let range = TextRange::from_to(type_def_node.text_range().start(), ctx.source_range().end()); | 170 | let range = TextRange::new(type_def_node.text_range().start(), ctx.source_range().end()); |
171 | 171 | ||
172 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) | 172 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) |
173 | .text_edit(TextEdit::replace(range, snippet)) | 173 | .text_edit(TextEdit::replace(range, snippet)) |
@@ -188,8 +188,7 @@ fn add_const_impl( | |||
188 | if let Some(const_name) = const_name { | 188 | if let Some(const_name) = const_name { |
189 | let snippet = make_const_compl_syntax(&const_.source(ctx.db).value); | 189 | let snippet = make_const_compl_syntax(&const_.source(ctx.db).value); |
190 | 190 | ||
191 | let range = | 191 | let range = TextRange::new(const_def_node.text_range().start(), ctx.source_range().end()); |
192 | TextRange::from_to(const_def_node.text_range().start(), ctx.source_range().end()); | ||
193 | 192 | ||
194 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) | 193 | CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) |
195 | .text_edit(TextEdit::replace(range, snippet)) | 194 | .text_edit(TextEdit::replace(range, snippet)) |
@@ -216,7 +215,7 @@ fn make_const_compl_syntax(const_: &ast::ConstDef) -> String { | |||
216 | .map_or(const_end, |f| f.text_range().start()); | 215 | .map_or(const_end, |f| f.text_range().start()); |
217 | 216 | ||
218 | let len = end - start; | 217 | let len = end - start; |
219 | let range = TextRange::from_to(0.into(), len); | 218 | let range = TextRange::new(0.into(), len); |
220 | 219 | ||
221 | let syntax = const_.syntax().text().slice(range).to_string(); | 220 | let syntax = const_.syntax().text().slice(range).to_string(); |
222 | 221 | ||
@@ -254,24 +253,24 @@ mod tests { | |||
254 | [ | 253 | [ |
255 | CompletionItem { | 254 | CompletionItem { |
256 | label: "const TEST_CONST: u16 = ", | 255 | label: "const TEST_CONST: u16 = ", |
257 | source_range: [209; 210), | 256 | source_range: 209..210, |
258 | delete: [209; 210), | 257 | delete: 209..210, |
259 | insert: "const TEST_CONST: u16 = ", | 258 | insert: "const TEST_CONST: u16 = ", |
260 | kind: Const, | 259 | kind: Const, |
261 | lookup: "TEST_CONST", | 260 | lookup: "TEST_CONST", |
262 | }, | 261 | }, |
263 | CompletionItem { | 262 | CompletionItem { |
264 | label: "fn test()", | 263 | label: "fn test()", |
265 | source_range: [209; 210), | 264 | source_range: 209..210, |
266 | delete: [209; 210), | 265 | delete: 209..210, |
267 | insert: "fn test() {\n $0\n}", | 266 | insert: "fn test() {\n $0\n}", |
268 | kind: Function, | 267 | kind: Function, |
269 | lookup: "test", | 268 | lookup: "test", |
270 | }, | 269 | }, |
271 | CompletionItem { | 270 | CompletionItem { |
272 | label: "type TestType = ", | 271 | label: "type TestType = ", |
273 | source_range: [209; 210), | 272 | source_range: 209..210, |
274 | delete: [209; 210), | 273 | delete: 209..210, |
275 | insert: "type TestType = ", | 274 | insert: "type TestType = ", |
276 | kind: TypeAlias, | 275 | kind: TypeAlias, |
277 | lookup: "TestType", | 276 | lookup: "TestType", |
@@ -320,8 +319,8 @@ mod tests { | |||
320 | [ | 319 | [ |
321 | CompletionItem { | 320 | CompletionItem { |
322 | label: "fn test()", | 321 | label: "fn test()", |
323 | source_range: [139; 140), | 322 | source_range: 139..140, |
324 | delete: [139; 140), | 323 | delete: 139..140, |
325 | insert: "fn test() {\n $0\n}", | 324 | insert: "fn test() {\n $0\n}", |
326 | kind: Function, | 325 | kind: Function, |
327 | lookup: "test", | 326 | lookup: "test", |
@@ -349,8 +348,8 @@ mod tests { | |||
349 | [ | 348 | [ |
350 | CompletionItem { | 349 | CompletionItem { |
351 | label: "fn foo()", | 350 | label: "fn foo()", |
352 | source_range: [141; 142), | 351 | source_range: 141..142, |
353 | delete: [138; 142), | 352 | delete: 138..142, |
354 | insert: "fn foo() {\n $0\n}", | 353 | insert: "fn foo() {\n $0\n}", |
355 | kind: Function, | 354 | kind: Function, |
356 | lookup: "foo", | 355 | lookup: "foo", |
@@ -381,8 +380,8 @@ mod tests { | |||
381 | [ | 380 | [ |
382 | CompletionItem { | 381 | CompletionItem { |
383 | label: "fn foo_bar()", | 382 | label: "fn foo_bar()", |
384 | source_range: [200; 201), | 383 | source_range: 200..201, |
385 | delete: [197; 201), | 384 | delete: 197..201, |
386 | insert: "fn foo_bar() {\n $0\n}", | 385 | insert: "fn foo_bar() {\n $0\n}", |
387 | kind: Function, | 386 | kind: Function, |
388 | lookup: "foo_bar", | 387 | lookup: "foo_bar", |
@@ -432,8 +431,8 @@ mod tests { | |||
432 | [ | 431 | [ |
433 | CompletionItem { | 432 | CompletionItem { |
434 | label: "fn foo()", | 433 | label: "fn foo()", |
435 | source_range: [144; 145), | 434 | source_range: 144..145, |
436 | delete: [141; 145), | 435 | delete: 141..145, |
437 | insert: "fn foo<T>() {\n $0\n}", | 436 | insert: "fn foo<T>() {\n $0\n}", |
438 | kind: Function, | 437 | kind: Function, |
439 | lookup: "foo", | 438 | lookup: "foo", |
@@ -461,8 +460,8 @@ mod tests { | |||
461 | [ | 460 | [ |
462 | CompletionItem { | 461 | CompletionItem { |
463 | label: "fn foo()", | 462 | label: "fn foo()", |
464 | source_range: [166; 167), | 463 | source_range: 166..167, |
465 | delete: [163; 167), | 464 | delete: 163..167, |
466 | insert: "fn foo<T>()\nwhere T: Into<String> {\n $0\n}", | 465 | insert: "fn foo<T>()\nwhere T: Into<String> {\n $0\n}", |
467 | kind: Function, | 466 | kind: Function, |
468 | lookup: "foo", | 467 | lookup: "foo", |
@@ -488,8 +487,8 @@ mod tests { | |||
488 | [ | 487 | [ |
489 | CompletionItem { | 488 | CompletionItem { |
490 | label: "type SomeType = ", | 489 | label: "type SomeType = ", |
491 | source_range: [124; 125), | 490 | source_range: 124..125, |
492 | delete: [119; 125), | 491 | delete: 119..125, |
493 | insert: "type SomeType = ", | 492 | insert: "type SomeType = ", |
494 | kind: TypeAlias, | 493 | kind: TypeAlias, |
495 | lookup: "SomeType", | 494 | lookup: "SomeType", |
@@ -515,8 +514,8 @@ mod tests { | |||
515 | [ | 514 | [ |
516 | CompletionItem { | 515 | CompletionItem { |
517 | label: "const SOME_CONST: u16 = ", | 516 | label: "const SOME_CONST: u16 = ", |
518 | source_range: [133; 134), | 517 | source_range: 133..134, |
519 | delete: [127; 134), | 518 | delete: 127..134, |
520 | insert: "const SOME_CONST: u16 = ", | 519 | insert: "const SOME_CONST: u16 = ", |
521 | kind: Const, | 520 | kind: Const, |
522 | lookup: "SOME_CONST", | 521 | lookup: "SOME_CONST", |
@@ -542,8 +541,8 @@ mod tests { | |||
542 | [ | 541 | [ |
543 | CompletionItem { | 542 | CompletionItem { |
544 | label: "const SOME_CONST: u16 = ", | 543 | label: "const SOME_CONST: u16 = ", |
545 | source_range: [138; 139), | 544 | source_range: 138..139, |
546 | delete: [132; 139), | 545 | delete: 132..139, |
547 | insert: "const SOME_CONST: u16 = ", | 546 | insert: "const SOME_CONST: u16 = ", |
548 | kind: Const, | 547 | kind: Const, |
549 | lookup: "SOME_CONST", | 548 | lookup: "SOME_CONST", |
diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs index 8e3dcf96e..56cd086c6 100644 --- a/crates/ra_ide/src/completion/complete_unqualified_path.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs | |||
@@ -85,8 +85,8 @@ mod tests { | |||
85 | [ | 85 | [ |
86 | CompletionItem { | 86 | CompletionItem { |
87 | label: "collections", | 87 | label: "collections", |
88 | source_range: [21; 24), | 88 | source_range: 21..24, |
89 | delete: [21; 24), | 89 | delete: 21..24, |
90 | insert: "collections", | 90 | insert: "collections", |
91 | }, | 91 | }, |
92 | ] | 92 | ] |
@@ -157,8 +157,8 @@ mod tests { | |||
157 | [ | 157 | [ |
158 | CompletionItem { | 158 | CompletionItem { |
159 | label: "Enum", | 159 | label: "Enum", |
160 | source_range: [231; 233), | 160 | source_range: 231..233, |
161 | delete: [231; 233), | 161 | delete: 231..233, |
162 | insert: "Enum", | 162 | insert: "Enum", |
163 | kind: Enum, | 163 | kind: Enum, |
164 | }, | 164 | }, |
@@ -183,8 +183,8 @@ mod tests { | |||
183 | [ | 183 | [ |
184 | CompletionItem { | 184 | CompletionItem { |
185 | label: "quux(…)", | 185 | label: "quux(…)", |
186 | source_range: [91; 91), | 186 | source_range: 91..91, |
187 | delete: [91; 91), | 187 | delete: 91..91, |
188 | insert: "quux(${1:x})$0", | 188 | insert: "quux(${1:x})$0", |
189 | kind: Function, | 189 | kind: Function, |
190 | lookup: "quux", | 190 | lookup: "quux", |
@@ -193,16 +193,16 @@ mod tests { | |||
193 | }, | 193 | }, |
194 | CompletionItem { | 194 | CompletionItem { |
195 | label: "x", | 195 | label: "x", |
196 | source_range: [91; 91), | 196 | source_range: 91..91, |
197 | delete: [91; 91), | 197 | delete: 91..91, |
198 | insert: "x", | 198 | insert: "x", |
199 | kind: Binding, | 199 | kind: Binding, |
200 | detail: "i32", | 200 | detail: "i32", |
201 | }, | 201 | }, |
202 | CompletionItem { | 202 | CompletionItem { |
203 | label: "y", | 203 | label: "y", |
204 | source_range: [91; 91), | 204 | source_range: 91..91, |
205 | delete: [91; 91), | 205 | delete: 91..91, |
206 | insert: "y", | 206 | insert: "y", |
207 | kind: Binding, | 207 | kind: Binding, |
208 | detail: "i32", | 208 | detail: "i32", |
@@ -232,23 +232,23 @@ mod tests { | |||
232 | [ | 232 | [ |
233 | CompletionItem { | 233 | CompletionItem { |
234 | label: "a", | 234 | label: "a", |
235 | source_range: [242; 242), | 235 | source_range: 242..242, |
236 | delete: [242; 242), | 236 | delete: 242..242, |
237 | insert: "a", | 237 | insert: "a", |
238 | kind: Binding, | 238 | kind: Binding, |
239 | }, | 239 | }, |
240 | CompletionItem { | 240 | CompletionItem { |
241 | label: "b", | 241 | label: "b", |
242 | source_range: [242; 242), | 242 | source_range: 242..242, |
243 | delete: [242; 242), | 243 | delete: 242..242, |
244 | insert: "b", | 244 | insert: "b", |
245 | kind: Binding, | 245 | kind: Binding, |
246 | detail: "i32", | 246 | detail: "i32", |
247 | }, | 247 | }, |
248 | CompletionItem { | 248 | CompletionItem { |
249 | label: "quux()", | 249 | label: "quux()", |
250 | source_range: [242; 242), | 250 | source_range: 242..242, |
251 | delete: [242; 242), | 251 | delete: 242..242, |
252 | insert: "quux()$0", | 252 | insert: "quux()$0", |
253 | kind: Function, | 253 | kind: Function, |
254 | lookup: "quux", | 254 | lookup: "quux", |
@@ -275,8 +275,8 @@ mod tests { | |||
275 | [ | 275 | [ |
276 | CompletionItem { | 276 | CompletionItem { |
277 | label: "quux()", | 277 | label: "quux()", |
278 | source_range: [95; 95), | 278 | source_range: 95..95, |
279 | delete: [95; 95), | 279 | delete: 95..95, |
280 | insert: "quux()$0", | 280 | insert: "quux()$0", |
281 | kind: Function, | 281 | kind: Function, |
282 | lookup: "quux", | 282 | lookup: "quux", |
@@ -284,8 +284,8 @@ mod tests { | |||
284 | }, | 284 | }, |
285 | CompletionItem { | 285 | CompletionItem { |
286 | label: "x", | 286 | label: "x", |
287 | source_range: [95; 95), | 287 | source_range: 95..95, |
288 | delete: [95; 95), | 288 | delete: 95..95, |
289 | insert: "x", | 289 | insert: "x", |
290 | kind: Binding, | 290 | kind: Binding, |
291 | }, | 291 | }, |
@@ -308,15 +308,15 @@ mod tests { | |||
308 | [ | 308 | [ |
309 | CompletionItem { | 309 | CompletionItem { |
310 | label: "T", | 310 | label: "T", |
311 | source_range: [52; 52), | 311 | source_range: 52..52, |
312 | delete: [52; 52), | 312 | delete: 52..52, |
313 | insert: "T", | 313 | insert: "T", |
314 | kind: TypeParam, | 314 | kind: TypeParam, |
315 | }, | 315 | }, |
316 | CompletionItem { | 316 | CompletionItem { |
317 | label: "quux()", | 317 | label: "quux()", |
318 | source_range: [52; 52), | 318 | source_range: 52..52, |
319 | delete: [52; 52), | 319 | delete: 52..52, |
320 | insert: "quux()$0", | 320 | insert: "quux()$0", |
321 | kind: Function, | 321 | kind: Function, |
322 | lookup: "quux", | 322 | lookup: "quux", |
@@ -341,22 +341,22 @@ mod tests { | |||
341 | [ | 341 | [ |
342 | CompletionItem { | 342 | CompletionItem { |
343 | label: "Self", | 343 | label: "Self", |
344 | source_range: [54; 54), | 344 | source_range: 54..54, |
345 | delete: [54; 54), | 345 | delete: 54..54, |
346 | insert: "Self", | 346 | insert: "Self", |
347 | kind: TypeParam, | 347 | kind: TypeParam, |
348 | }, | 348 | }, |
349 | CompletionItem { | 349 | CompletionItem { |
350 | label: "T", | 350 | label: "T", |
351 | source_range: [54; 54), | 351 | source_range: 54..54, |
352 | delete: [54; 54), | 352 | delete: 54..54, |
353 | insert: "T", | 353 | insert: "T", |
354 | kind: TypeParam, | 354 | kind: TypeParam, |
355 | }, | 355 | }, |
356 | CompletionItem { | 356 | CompletionItem { |
357 | label: "X<…>", | 357 | label: "X<…>", |
358 | source_range: [54; 54), | 358 | source_range: 54..54, |
359 | delete: [54; 54), | 359 | delete: 54..54, |
360 | insert: "X<$0>", | 360 | insert: "X<$0>", |
361 | kind: Struct, | 361 | kind: Struct, |
362 | lookup: "X", | 362 | lookup: "X", |
@@ -380,15 +380,15 @@ mod tests { | |||
380 | [ | 380 | [ |
381 | CompletionItem { | 381 | CompletionItem { |
382 | label: "Self", | 382 | label: "Self", |
383 | source_range: [48; 48), | 383 | source_range: 48..48, |
384 | delete: [48; 48), | 384 | delete: 48..48, |
385 | insert: "Self", | 385 | insert: "Self", |
386 | kind: TypeParam, | 386 | kind: TypeParam, |
387 | }, | 387 | }, |
388 | CompletionItem { | 388 | CompletionItem { |
389 | label: "X", | 389 | label: "X", |
390 | source_range: [48; 48), | 390 | source_range: 48..48, |
391 | delete: [48; 48), | 391 | delete: 48..48, |
392 | insert: "X", | 392 | insert: "X", |
393 | kind: Enum, | 393 | kind: Enum, |
394 | }, | 394 | }, |
@@ -413,22 +413,22 @@ mod tests { | |||
413 | [ | 413 | [ |
414 | CompletionItem { | 414 | CompletionItem { |
415 | label: "Baz", | 415 | label: "Baz", |
416 | source_range: [105; 105), | 416 | source_range: 105..105, |
417 | delete: [105; 105), | 417 | delete: 105..105, |
418 | insert: "Baz", | 418 | insert: "Baz", |
419 | kind: Enum, | 419 | kind: Enum, |
420 | }, | 420 | }, |
421 | CompletionItem { | 421 | CompletionItem { |
422 | label: "Foo", | 422 | label: "Foo", |
423 | source_range: [105; 105), | 423 | source_range: 105..105, |
424 | delete: [105; 105), | 424 | delete: 105..105, |
425 | insert: "Foo", | 425 | insert: "Foo", |
426 | kind: Struct, | 426 | kind: Struct, |
427 | }, | 427 | }, |
428 | CompletionItem { | 428 | CompletionItem { |
429 | label: "quux()", | 429 | label: "quux()", |
430 | source_range: [105; 105), | 430 | source_range: 105..105, |
431 | delete: [105; 105), | 431 | delete: 105..105, |
432 | insert: "quux()$0", | 432 | insert: "quux()$0", |
433 | kind: Function, | 433 | kind: Function, |
434 | lookup: "quux", | 434 | lookup: "quux", |
@@ -455,8 +455,8 @@ mod tests { | |||
455 | [ | 455 | [ |
456 | CompletionItem { | 456 | CompletionItem { |
457 | label: "other_crate", | 457 | label: "other_crate", |
458 | source_range: [4; 4), | 458 | source_range: 4..4, |
459 | delete: [4; 4), | 459 | delete: 4..4, |
460 | insert: "other_crate", | 460 | insert: "other_crate", |
461 | kind: Module, | 461 | kind: Module, |
462 | }, | 462 | }, |
@@ -481,15 +481,15 @@ mod tests { | |||
481 | [ | 481 | [ |
482 | CompletionItem { | 482 | CompletionItem { |
483 | label: "Bar", | 483 | label: "Bar", |
484 | source_range: [117; 117), | 484 | source_range: 117..117, |
485 | delete: [117; 117), | 485 | delete: 117..117, |
486 | insert: "Bar", | 486 | insert: "Bar", |
487 | kind: Struct, | 487 | kind: Struct, |
488 | }, | 488 | }, |
489 | CompletionItem { | 489 | CompletionItem { |
490 | label: "quux()", | 490 | label: "quux()", |
491 | source_range: [117; 117), | 491 | source_range: 117..117, |
492 | delete: [117; 117), | 492 | delete: 117..117, |
493 | insert: "quux()$0", | 493 | insert: "quux()$0", |
494 | kind: Function, | 494 | kind: Function, |
495 | lookup: "quux", | 495 | lookup: "quux", |
@@ -513,15 +513,15 @@ mod tests { | |||
513 | [ | 513 | [ |
514 | CompletionItem { | 514 | CompletionItem { |
515 | label: "Foo", | 515 | label: "Foo", |
516 | source_range: [55; 55), | 516 | source_range: 55..55, |
517 | delete: [55; 55), | 517 | delete: 55..55, |
518 | insert: "Foo", | 518 | insert: "Foo", |
519 | kind: Struct, | 519 | kind: Struct, |
520 | }, | 520 | }, |
521 | CompletionItem { | 521 | CompletionItem { |
522 | label: "x()", | 522 | label: "x()", |
523 | source_range: [55; 55), | 523 | source_range: 55..55, |
524 | delete: [55; 55), | 524 | delete: 55..55, |
525 | insert: "x()$0", | 525 | insert: "x()$0", |
526 | kind: Function, | 526 | kind: Function, |
527 | lookup: "x", | 527 | lookup: "x", |
@@ -550,16 +550,16 @@ mod tests { | |||
550 | [ | 550 | [ |
551 | CompletionItem { | 551 | CompletionItem { |
552 | label: "bar", | 552 | label: "bar", |
553 | source_range: [146; 146), | 553 | source_range: 146..146, |
554 | delete: [146; 146), | 554 | delete: 146..146, |
555 | insert: "bar", | 555 | insert: "bar", |
556 | kind: Binding, | 556 | kind: Binding, |
557 | detail: "i32", | 557 | detail: "i32", |
558 | }, | 558 | }, |
559 | CompletionItem { | 559 | CompletionItem { |
560 | label: "foo()", | 560 | label: "foo()", |
561 | source_range: [146; 146), | 561 | source_range: 146..146, |
562 | delete: [146; 146), | 562 | delete: 146..146, |
563 | insert: "foo()$0", | 563 | insert: "foo()$0", |
564 | kind: Function, | 564 | kind: Function, |
565 | lookup: "foo", | 565 | lookup: "foo", |
@@ -578,15 +578,15 @@ mod tests { | |||
578 | [ | 578 | [ |
579 | CompletionItem { | 579 | CompletionItem { |
580 | label: "Self", | 580 | label: "Self", |
581 | source_range: [25; 25), | 581 | source_range: 25..25, |
582 | delete: [25; 25), | 582 | delete: 25..25, |
583 | insert: "Self", | 583 | insert: "Self", |
584 | kind: TypeParam, | 584 | kind: TypeParam, |
585 | }, | 585 | }, |
586 | CompletionItem { | 586 | CompletionItem { |
587 | label: "self", | 587 | label: "self", |
588 | source_range: [25; 25), | 588 | source_range: 25..25, |
589 | delete: [25; 25), | 589 | delete: 25..25, |
590 | insert: "self", | 590 | insert: "self", |
591 | kind: Binding, | 591 | kind: Binding, |
592 | detail: "&{unknown}", | 592 | detail: "&{unknown}", |
@@ -617,15 +617,15 @@ mod tests { | |||
617 | [ | 617 | [ |
618 | CompletionItem { | 618 | CompletionItem { |
619 | label: "Option", | 619 | label: "Option", |
620 | source_range: [18; 18), | 620 | source_range: 18..18, |
621 | delete: [18; 18), | 621 | delete: 18..18, |
622 | insert: "Option", | 622 | insert: "Option", |
623 | kind: Struct, | 623 | kind: Struct, |
624 | }, | 624 | }, |
625 | CompletionItem { | 625 | CompletionItem { |
626 | label: "foo()", | 626 | label: "foo()", |
627 | source_range: [18; 18), | 627 | source_range: 18..18, |
628 | delete: [18; 18), | 628 | delete: 18..18, |
629 | insert: "foo()$0", | 629 | insert: "foo()$0", |
630 | kind: Function, | 630 | kind: Function, |
631 | lookup: "foo", | 631 | lookup: "foo", |
@@ -633,8 +633,8 @@ mod tests { | |||
633 | }, | 633 | }, |
634 | CompletionItem { | 634 | CompletionItem { |
635 | label: "std", | 635 | label: "std", |
636 | source_range: [18; 18), | 636 | source_range: 18..18, |
637 | delete: [18; 18), | 637 | delete: 18..18, |
638 | insert: "std", | 638 | insert: "std", |
639 | kind: Module, | 639 | kind: Module, |
640 | }, | 640 | }, |
@@ -672,22 +672,22 @@ mod tests { | |||
672 | [ | 672 | [ |
673 | CompletionItem { | 673 | CompletionItem { |
674 | label: "String", | 674 | label: "String", |
675 | source_range: [18; 18), | 675 | source_range: 18..18, |
676 | delete: [18; 18), | 676 | delete: 18..18, |
677 | insert: "String", | 677 | insert: "String", |
678 | kind: Struct, | 678 | kind: Struct, |
679 | }, | 679 | }, |
680 | CompletionItem { | 680 | CompletionItem { |
681 | label: "core", | 681 | label: "core", |
682 | source_range: [18; 18), | 682 | source_range: 18..18, |
683 | delete: [18; 18), | 683 | delete: 18..18, |
684 | insert: "core", | 684 | insert: "core", |
685 | kind: Module, | 685 | kind: Module, |
686 | }, | 686 | }, |
687 | CompletionItem { | 687 | CompletionItem { |
688 | label: "foo()", | 688 | label: "foo()", |
689 | source_range: [18; 18), | 689 | source_range: 18..18, |
690 | delete: [18; 18), | 690 | delete: 18..18, |
691 | insert: "foo()$0", | 691 | insert: "foo()$0", |
692 | kind: Function, | 692 | kind: Function, |
693 | lookup: "foo", | 693 | lookup: "foo", |
@@ -695,8 +695,8 @@ mod tests { | |||
695 | }, | 695 | }, |
696 | CompletionItem { | 696 | CompletionItem { |
697 | label: "std", | 697 | label: "std", |
698 | source_range: [18; 18), | 698 | source_range: 18..18, |
699 | delete: [18; 18), | 699 | delete: 18..18, |
700 | insert: "std", | 700 | insert: "std", |
701 | kind: Module, | 701 | kind: Module, |
702 | }, | 702 | }, |
@@ -742,46 +742,46 @@ mod tests { | |||
742 | [ | 742 | [ |
743 | CompletionItem { | 743 | CompletionItem { |
744 | label: "bar!(…)", | 744 | label: "bar!(…)", |
745 | source_range: [252; 252), | 745 | source_range: 252..252, |
746 | delete: [252; 252), | 746 | delete: 252..252, |
747 | insert: "bar!($0)", | 747 | insert: "bar!($0)", |
748 | kind: Macro, | 748 | kind: Macro, |
749 | detail: "macro_rules! bar", | 749 | detail: "macro_rules! bar", |
750 | }, | 750 | }, |
751 | CompletionItem { | 751 | CompletionItem { |
752 | label: "baz!(…)", | 752 | label: "baz!(…)", |
753 | source_range: [252; 252), | 753 | source_range: 252..252, |
754 | delete: [252; 252), | 754 | delete: 252..252, |
755 | insert: "baz!($0)", | 755 | insert: "baz!($0)", |
756 | kind: Macro, | 756 | kind: Macro, |
757 | detail: "#[macro_export]\nmacro_rules! baz", | 757 | detail: "#[macro_export]\nmacro_rules! baz", |
758 | }, | 758 | }, |
759 | CompletionItem { | 759 | CompletionItem { |
760 | label: "foo!(…)", | 760 | label: "foo!(…)", |
761 | source_range: [252; 252), | 761 | source_range: 252..252, |
762 | delete: [252; 252), | 762 | delete: 252..252, |
763 | insert: "foo!($0)", | 763 | insert: "foo!($0)", |
764 | kind: Macro, | 764 | kind: Macro, |
765 | detail: "macro_rules! foo", | 765 | detail: "macro_rules! foo", |
766 | }, | 766 | }, |
767 | CompletionItem { | 767 | CompletionItem { |
768 | label: "m1", | 768 | label: "m1", |
769 | source_range: [252; 252), | 769 | source_range: 252..252, |
770 | delete: [252; 252), | 770 | delete: 252..252, |
771 | insert: "m1", | 771 | insert: "m1", |
772 | kind: Module, | 772 | kind: Module, |
773 | }, | 773 | }, |
774 | CompletionItem { | 774 | CompletionItem { |
775 | label: "m2", | 775 | label: "m2", |
776 | source_range: [252; 252), | 776 | source_range: 252..252, |
777 | delete: [252; 252), | 777 | delete: 252..252, |
778 | insert: "m2", | 778 | insert: "m2", |
779 | kind: Module, | 779 | kind: Module, |
780 | }, | 780 | }, |
781 | CompletionItem { | 781 | CompletionItem { |
782 | label: "main()", | 782 | label: "main()", |
783 | source_range: [252; 252), | 783 | source_range: 252..252, |
784 | delete: [252; 252), | 784 | delete: 252..252, |
785 | insert: "main()$0", | 785 | insert: "main()$0", |
786 | kind: Function, | 786 | kind: Function, |
787 | lookup: "main", | 787 | lookup: "main", |
@@ -811,16 +811,16 @@ mod tests { | |||
811 | [ | 811 | [ |
812 | CompletionItem { | 812 | CompletionItem { |
813 | label: "foo!(…)", | 813 | label: "foo!(…)", |
814 | source_range: [49; 49), | 814 | source_range: 49..49, |
815 | delete: [49; 49), | 815 | delete: 49..49, |
816 | insert: "foo!($0)", | 816 | insert: "foo!($0)", |
817 | kind: Macro, | 817 | kind: Macro, |
818 | detail: "macro_rules! foo", | 818 | detail: "macro_rules! foo", |
819 | }, | 819 | }, |
820 | CompletionItem { | 820 | CompletionItem { |
821 | label: "foo()", | 821 | label: "foo()", |
822 | source_range: [49; 49), | 822 | source_range: 49..49, |
823 | delete: [49; 49), | 823 | delete: 49..49, |
824 | insert: "foo()$0", | 824 | insert: "foo()$0", |
825 | kind: Function, | 825 | kind: Function, |
826 | lookup: "foo", | 826 | lookup: "foo", |
@@ -850,16 +850,16 @@ mod tests { | |||
850 | [ | 850 | [ |
851 | CompletionItem { | 851 | CompletionItem { |
852 | label: "foo!(…)", | 852 | label: "foo!(…)", |
853 | source_range: [57; 57), | 853 | source_range: 57..57, |
854 | delete: [57; 57), | 854 | delete: 57..57, |
855 | insert: "foo!($0)", | 855 | insert: "foo!($0)", |
856 | kind: Macro, | 856 | kind: Macro, |
857 | detail: "macro_rules! foo", | 857 | detail: "macro_rules! foo", |
858 | }, | 858 | }, |
859 | CompletionItem { | 859 | CompletionItem { |
860 | label: "main()", | 860 | label: "main()", |
861 | source_range: [57; 57), | 861 | source_range: 57..57, |
862 | delete: [57; 57), | 862 | delete: 57..57, |
863 | insert: "main()$0", | 863 | insert: "main()$0", |
864 | kind: Function, | 864 | kind: Function, |
865 | lookup: "main", | 865 | lookup: "main", |
@@ -889,16 +889,16 @@ mod tests { | |||
889 | [ | 889 | [ |
890 | CompletionItem { | 890 | CompletionItem { |
891 | label: "foo!(…)", | 891 | label: "foo!(…)", |
892 | source_range: [50; 50), | 892 | source_range: 50..50, |
893 | delete: [50; 50), | 893 | delete: 50..50, |
894 | insert: "foo!($0)", | 894 | insert: "foo!($0)", |
895 | kind: Macro, | 895 | kind: Macro, |
896 | detail: "macro_rules! foo", | 896 | detail: "macro_rules! foo", |
897 | }, | 897 | }, |
898 | CompletionItem { | 898 | CompletionItem { |
899 | label: "main()", | 899 | label: "main()", |
900 | source_range: [50; 50), | 900 | source_range: 50..50, |
901 | delete: [50; 50), | 901 | delete: 50..50, |
902 | insert: "main()$0", | 902 | insert: "main()$0", |
903 | kind: Function, | 903 | kind: Function, |
904 | lookup: "main", | 904 | lookup: "main", |
@@ -925,8 +925,8 @@ mod tests { | |||
925 | [ | 925 | [ |
926 | CompletionItem { | 926 | CompletionItem { |
927 | label: "frobnicate()", | 927 | label: "frobnicate()", |
928 | source_range: [23; 24), | 928 | source_range: 23..24, |
929 | delete: [23; 24), | 929 | delete: 23..24, |
930 | insert: "frobnicate()$0", | 930 | insert: "frobnicate()$0", |
931 | kind: Function, | 931 | kind: Function, |
932 | lookup: "frobnicate", | 932 | lookup: "frobnicate", |
@@ -934,8 +934,8 @@ mod tests { | |||
934 | }, | 934 | }, |
935 | CompletionItem { | 935 | CompletionItem { |
936 | label: "main()", | 936 | label: "main()", |
937 | source_range: [23; 24), | 937 | source_range: 23..24, |
938 | delete: [23; 24), | 938 | delete: 23..24, |
939 | insert: "main()$0", | 939 | insert: "main()$0", |
940 | kind: Function, | 940 | kind: Function, |
941 | lookup: "main", | 941 | lookup: "main", |
@@ -962,16 +962,16 @@ mod tests { | |||
962 | [ | 962 | [ |
963 | CompletionItem { | 963 | CompletionItem { |
964 | label: "m!(…)", | 964 | label: "m!(…)", |
965 | source_range: [145; 145), | 965 | source_range: 145..145, |
966 | delete: [145; 145), | 966 | delete: 145..145, |
967 | insert: "m!($0)", | 967 | insert: "m!($0)", |
968 | kind: Macro, | 968 | kind: Macro, |
969 | detail: "macro_rules! m", | 969 | detail: "macro_rules! m", |
970 | }, | 970 | }, |
971 | CompletionItem { | 971 | CompletionItem { |
972 | label: "quux(…)", | 972 | label: "quux(…)", |
973 | source_range: [145; 145), | 973 | source_range: 145..145, |
974 | delete: [145; 145), | 974 | delete: 145..145, |
975 | insert: "quux(${1:x})$0", | 975 | insert: "quux(${1:x})$0", |
976 | kind: Function, | 976 | kind: Function, |
977 | lookup: "quux", | 977 | lookup: "quux", |
@@ -980,16 +980,16 @@ mod tests { | |||
980 | }, | 980 | }, |
981 | CompletionItem { | 981 | CompletionItem { |
982 | label: "x", | 982 | label: "x", |
983 | source_range: [145; 145), | 983 | source_range: 145..145, |
984 | delete: [145; 145), | 984 | delete: 145..145, |
985 | insert: "x", | 985 | insert: "x", |
986 | kind: Binding, | 986 | kind: Binding, |
987 | detail: "i32", | 987 | detail: "i32", |
988 | }, | 988 | }, |
989 | CompletionItem { | 989 | CompletionItem { |
990 | label: "y", | 990 | label: "y", |
991 | source_range: [145; 145), | 991 | source_range: 145..145, |
992 | delete: [145; 145), | 992 | delete: 145..145, |
993 | insert: "y", | 993 | insert: "y", |
994 | kind: Binding, | 994 | kind: Binding, |
995 | detail: "i32", | 995 | detail: "i32", |
@@ -1015,16 +1015,16 @@ mod tests { | |||
1015 | [ | 1015 | [ |
1016 | CompletionItem { | 1016 | CompletionItem { |
1017 | label: "m!(…)", | 1017 | label: "m!(…)", |
1018 | source_range: [145; 146), | 1018 | source_range: 145..146, |
1019 | delete: [145; 146), | 1019 | delete: 145..146, |
1020 | insert: "m!($0)", | 1020 | insert: "m!($0)", |
1021 | kind: Macro, | 1021 | kind: Macro, |
1022 | detail: "macro_rules! m", | 1022 | detail: "macro_rules! m", |
1023 | }, | 1023 | }, |
1024 | CompletionItem { | 1024 | CompletionItem { |
1025 | label: "quux(…)", | 1025 | label: "quux(…)", |
1026 | source_range: [145; 146), | 1026 | source_range: 145..146, |
1027 | delete: [145; 146), | 1027 | delete: 145..146, |
1028 | insert: "quux(${1:x})$0", | 1028 | insert: "quux(${1:x})$0", |
1029 | kind: Function, | 1029 | kind: Function, |
1030 | lookup: "quux", | 1030 | lookup: "quux", |
@@ -1033,16 +1033,16 @@ mod tests { | |||
1033 | }, | 1033 | }, |
1034 | CompletionItem { | 1034 | CompletionItem { |
1035 | label: "x", | 1035 | label: "x", |
1036 | source_range: [145; 146), | 1036 | source_range: 145..146, |
1037 | delete: [145; 146), | 1037 | delete: 145..146, |
1038 | insert: "x", | 1038 | insert: "x", |
1039 | kind: Binding, | 1039 | kind: Binding, |
1040 | detail: "i32", | 1040 | detail: "i32", |
1041 | }, | 1041 | }, |
1042 | CompletionItem { | 1042 | CompletionItem { |
1043 | label: "y", | 1043 | label: "y", |
1044 | source_range: [145; 146), | 1044 | source_range: 145..146, |
1045 | delete: [145; 146), | 1045 | delete: 145..146, |
1046 | insert: "y", | 1046 | insert: "y", |
1047 | kind: Binding, | 1047 | kind: Binding, |
1048 | detail: "i32", | 1048 | detail: "i32", |
@@ -1068,16 +1068,16 @@ mod tests { | |||
1068 | [ | 1068 | [ |
1069 | CompletionItem { | 1069 | CompletionItem { |
1070 | label: "m!(…)", | 1070 | label: "m!(…)", |
1071 | source_range: [145; 146), | 1071 | source_range: 145..146, |
1072 | delete: [145; 146), | 1072 | delete: 145..146, |
1073 | insert: "m!($0)", | 1073 | insert: "m!($0)", |
1074 | kind: Macro, | 1074 | kind: Macro, |
1075 | detail: "macro_rules! m", | 1075 | detail: "macro_rules! m", |
1076 | }, | 1076 | }, |
1077 | CompletionItem { | 1077 | CompletionItem { |
1078 | label: "quux(…)", | 1078 | label: "quux(…)", |
1079 | source_range: [145; 146), | 1079 | source_range: 145..146, |
1080 | delete: [145; 146), | 1080 | delete: 145..146, |
1081 | insert: "quux(${1:x})$0", | 1081 | insert: "quux(${1:x})$0", |
1082 | kind: Function, | 1082 | kind: Function, |
1083 | lookup: "quux", | 1083 | lookup: "quux", |
@@ -1086,16 +1086,16 @@ mod tests { | |||
1086 | }, | 1086 | }, |
1087 | CompletionItem { | 1087 | CompletionItem { |
1088 | label: "x", | 1088 | label: "x", |
1089 | source_range: [145; 146), | 1089 | source_range: 145..146, |
1090 | delete: [145; 146), | 1090 | delete: 145..146, |
1091 | insert: "x", | 1091 | insert: "x", |
1092 | kind: Binding, | 1092 | kind: Binding, |
1093 | detail: "i32", | 1093 | detail: "i32", |
1094 | }, | 1094 | }, |
1095 | CompletionItem { | 1095 | CompletionItem { |
1096 | label: "y", | 1096 | label: "y", |
1097 | source_range: [145; 146), | 1097 | source_range: 145..146, |
1098 | delete: [145; 146), | 1098 | delete: 145..146, |
1099 | insert: "y", | 1099 | insert: "y", |
1100 | kind: Binding, | 1100 | kind: Binding, |
1101 | detail: "i32", | 1101 | detail: "i32", |
@@ -1121,14 +1121,14 @@ mod tests { | |||
1121 | [ | 1121 | [ |
1122 | CompletionItem { | 1122 | CompletionItem { |
1123 | label: "Quux", | 1123 | label: "Quux", |
1124 | source_range: [82; 82), | 1124 | source_range: 82..82, |
1125 | delete: [82; 82), | 1125 | delete: 82..82, |
1126 | insert: "Quux", | 1126 | insert: "Quux", |
1127 | }, | 1127 | }, |
1128 | CompletionItem { | 1128 | CompletionItem { |
1129 | label: "main()", | 1129 | label: "main()", |
1130 | source_range: [82; 82), | 1130 | source_range: 82..82, |
1131 | delete: [82; 82), | 1131 | delete: 82..82, |
1132 | insert: "main()$0", | 1132 | insert: "main()$0", |
1133 | kind: Function, | 1133 | kind: Function, |
1134 | lookup: "main", | 1134 | lookup: "main", |
@@ -1162,31 +1162,31 @@ mod tests { | |||
1162 | [ | 1162 | [ |
1163 | CompletionItem { | 1163 | CompletionItem { |
1164 | label: "Foo", | 1164 | label: "Foo", |
1165 | source_range: [248; 250), | 1165 | source_range: 248..250, |
1166 | delete: [248; 250), | 1166 | delete: 248..250, |
1167 | insert: "Foo", | 1167 | insert: "Foo", |
1168 | kind: Enum, | 1168 | kind: Enum, |
1169 | }, | 1169 | }, |
1170 | CompletionItem { | 1170 | CompletionItem { |
1171 | label: "Foo::Bar", | 1171 | label: "Foo::Bar", |
1172 | source_range: [248; 250), | 1172 | source_range: 248..250, |
1173 | delete: [248; 250), | 1173 | delete: 248..250, |
1174 | insert: "Foo::Bar", | 1174 | insert: "Foo::Bar", |
1175 | kind: EnumVariant, | 1175 | kind: EnumVariant, |
1176 | detail: "()", | 1176 | detail: "()", |
1177 | }, | 1177 | }, |
1178 | CompletionItem { | 1178 | CompletionItem { |
1179 | label: "Foo::Baz", | 1179 | label: "Foo::Baz", |
1180 | source_range: [248; 250), | 1180 | source_range: 248..250, |
1181 | delete: [248; 250), | 1181 | delete: 248..250, |
1182 | insert: "Foo::Baz", | 1182 | insert: "Foo::Baz", |
1183 | kind: EnumVariant, | 1183 | kind: EnumVariant, |
1184 | detail: "()", | 1184 | detail: "()", |
1185 | }, | 1185 | }, |
1186 | CompletionItem { | 1186 | CompletionItem { |
1187 | label: "Foo::Quux", | 1187 | label: "Foo::Quux", |
1188 | source_range: [248; 250), | 1188 | source_range: 248..250, |
1189 | delete: [248; 250), | 1189 | delete: 248..250, |
1190 | insert: "Foo::Quux", | 1190 | insert: "Foo::Quux", |
1191 | kind: EnumVariant, | 1191 | kind: EnumVariant, |
1192 | detail: "()", | 1192 | detail: "()", |
@@ -1220,31 +1220,31 @@ mod tests { | |||
1220 | [ | 1220 | [ |
1221 | CompletionItem { | 1221 | CompletionItem { |
1222 | label: "Foo", | 1222 | label: "Foo", |
1223 | source_range: [219; 221), | 1223 | source_range: 219..221, |
1224 | delete: [219; 221), | 1224 | delete: 219..221, |
1225 | insert: "Foo", | 1225 | insert: "Foo", |
1226 | kind: Enum, | 1226 | kind: Enum, |
1227 | }, | 1227 | }, |
1228 | CompletionItem { | 1228 | CompletionItem { |
1229 | label: "Foo::Bar", | 1229 | label: "Foo::Bar", |
1230 | source_range: [219; 221), | 1230 | source_range: 219..221, |
1231 | delete: [219; 221), | 1231 | delete: 219..221, |
1232 | insert: "Foo::Bar", | 1232 | insert: "Foo::Bar", |
1233 | kind: EnumVariant, | 1233 | kind: EnumVariant, |
1234 | detail: "()", | 1234 | detail: "()", |
1235 | }, | 1235 | }, |
1236 | CompletionItem { | 1236 | CompletionItem { |
1237 | label: "Foo::Baz", | 1237 | label: "Foo::Baz", |
1238 | source_range: [219; 221), | 1238 | source_range: 219..221, |
1239 | delete: [219; 221), | 1239 | delete: 219..221, |
1240 | insert: "Foo::Baz", | 1240 | insert: "Foo::Baz", |
1241 | kind: EnumVariant, | 1241 | kind: EnumVariant, |
1242 | detail: "()", | 1242 | detail: "()", |
1243 | }, | 1243 | }, |
1244 | CompletionItem { | 1244 | CompletionItem { |
1245 | label: "Foo::Quux", | 1245 | label: "Foo::Quux", |
1246 | source_range: [219; 221), | 1246 | source_range: 219..221, |
1247 | delete: [219; 221), | 1247 | delete: 219..221, |
1248 | insert: "Foo::Quux", | 1248 | insert: "Foo::Quux", |
1249 | kind: EnumVariant, | 1249 | kind: EnumVariant, |
1250 | detail: "()", | 1250 | detail: "()", |
@@ -1274,39 +1274,39 @@ mod tests { | |||
1274 | [ | 1274 | [ |
1275 | CompletionItem { | 1275 | CompletionItem { |
1276 | label: "Foo", | 1276 | label: "Foo", |
1277 | source_range: [185; 186), | 1277 | source_range: 185..186, |
1278 | delete: [185; 186), | 1278 | delete: 185..186, |
1279 | insert: "Foo", | 1279 | insert: "Foo", |
1280 | kind: Enum, | 1280 | kind: Enum, |
1281 | }, | 1281 | }, |
1282 | CompletionItem { | 1282 | CompletionItem { |
1283 | label: "Foo::Bar", | 1283 | label: "Foo::Bar", |
1284 | source_range: [185; 186), | 1284 | source_range: 185..186, |
1285 | delete: [185; 186), | 1285 | delete: 185..186, |
1286 | insert: "Foo::Bar", | 1286 | insert: "Foo::Bar", |
1287 | kind: EnumVariant, | 1287 | kind: EnumVariant, |
1288 | detail: "()", | 1288 | detail: "()", |
1289 | }, | 1289 | }, |
1290 | CompletionItem { | 1290 | CompletionItem { |
1291 | label: "Foo::Baz", | 1291 | label: "Foo::Baz", |
1292 | source_range: [185; 186), | 1292 | source_range: 185..186, |
1293 | delete: [185; 186), | 1293 | delete: 185..186, |
1294 | insert: "Foo::Baz", | 1294 | insert: "Foo::Baz", |
1295 | kind: EnumVariant, | 1295 | kind: EnumVariant, |
1296 | detail: "()", | 1296 | detail: "()", |
1297 | }, | 1297 | }, |
1298 | CompletionItem { | 1298 | CompletionItem { |
1299 | label: "Foo::Quux", | 1299 | label: "Foo::Quux", |
1300 | source_range: [185; 186), | 1300 | source_range: 185..186, |
1301 | delete: [185; 186), | 1301 | delete: 185..186, |
1302 | insert: "Foo::Quux", | 1302 | insert: "Foo::Quux", |
1303 | kind: EnumVariant, | 1303 | kind: EnumVariant, |
1304 | detail: "()", | 1304 | detail: "()", |
1305 | }, | 1305 | }, |
1306 | CompletionItem { | 1306 | CompletionItem { |
1307 | label: "main()", | 1307 | label: "main()", |
1308 | source_range: [185; 186), | 1308 | source_range: 185..186, |
1309 | delete: [185; 186), | 1309 | delete: 185..186, |
1310 | insert: "main()$0", | 1310 | insert: "main()$0", |
1311 | kind: Function, | 1311 | kind: Function, |
1312 | lookup: "main", | 1312 | lookup: "main", |
@@ -1333,8 +1333,8 @@ mod tests { | |||
1333 | [ | 1333 | [ |
1334 | CompletionItem { | 1334 | CompletionItem { |
1335 | label: "f()", | 1335 | label: "f()", |
1336 | source_range: [98; 99), | 1336 | source_range: 98..99, |
1337 | delete: [98; 99), | 1337 | delete: 98..99, |
1338 | insert: "f()$0", | 1338 | insert: "f()$0", |
1339 | kind: Function, | 1339 | kind: Function, |
1340 | lookup: "f", | 1340 | lookup: "f", |
@@ -1342,15 +1342,15 @@ mod tests { | |||
1342 | }, | 1342 | }, |
1343 | CompletionItem { | 1343 | CompletionItem { |
1344 | label: "m", | 1344 | label: "m", |
1345 | source_range: [98; 99), | 1345 | source_range: 98..99, |
1346 | delete: [98; 99), | 1346 | delete: 98..99, |
1347 | insert: "m", | 1347 | insert: "m", |
1348 | kind: Module, | 1348 | kind: Module, |
1349 | }, | 1349 | }, |
1350 | CompletionItem { | 1350 | CompletionItem { |
1351 | label: "m::E::V", | 1351 | label: "m::E::V", |
1352 | source_range: [98; 99), | 1352 | source_range: 98..99, |
1353 | delete: [98; 99), | 1353 | delete: 98..99, |
1354 | insert: "m::E::V", | 1354 | insert: "m::E::V", |
1355 | kind: EnumVariant, | 1355 | kind: EnumVariant, |
1356 | detail: "()", | 1356 | detail: "()", |
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 37880448a..5f2797e41 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -7,7 +7,7 @@ use ra_syntax::{ | |||
7 | algo::{find_covering_element, find_node_at_offset}, | 7 | algo::{find_covering_element, find_node_at_offset}, |
8 | ast, AstNode, | 8 | ast, AstNode, |
9 | SyntaxKind::*, | 9 | SyntaxKind::*, |
10 | SyntaxNode, SyntaxToken, TextRange, TextUnit, | 10 | SyntaxNode, SyntaxToken, TextRange, TextSize, |
11 | }; | 11 | }; |
12 | use ra_text_edit::AtomTextEdit; | 12 | use ra_text_edit::AtomTextEdit; |
13 | 13 | ||
@@ -20,7 +20,7 @@ pub(crate) struct CompletionContext<'a> { | |||
20 | pub(super) sema: Semantics<'a, RootDatabase>, | 20 | pub(super) sema: Semantics<'a, RootDatabase>, |
21 | pub(super) db: &'a RootDatabase, | 21 | pub(super) db: &'a RootDatabase, |
22 | pub(super) config: &'a CompletionConfig, | 22 | pub(super) config: &'a CompletionConfig, |
23 | pub(super) offset: TextUnit, | 23 | pub(super) offset: TextSize, |
24 | /// The token before the cursor, in the original file. | 24 | /// The token before the cursor, in the original file. |
25 | pub(super) original_token: SyntaxToken, | 25 | pub(super) original_token: SyntaxToken, |
26 | /// The token before the cursor, in the macro-expanded file. | 26 | /// The token before the cursor, in the macro-expanded file. |
@@ -167,7 +167,7 @@ impl<'a> CompletionContext<'a> { | |||
167 | match self.token.kind() { | 167 | match self.token.kind() { |
168 | // workaroud when completion is triggered by trigger characters. | 168 | // workaroud when completion is triggered by trigger characters. |
169 | IDENT => self.original_token.text_range(), | 169 | IDENT => self.original_token.text_range(), |
170 | _ => TextRange::offset_len(self.offset, 0.into()), | 170 | _ => TextRange::empty(self.offset), |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
@@ -190,7 +190,7 @@ impl<'a> CompletionContext<'a> { | |||
190 | &mut self, | 190 | &mut self, |
191 | original_file: &SyntaxNode, | 191 | original_file: &SyntaxNode, |
192 | file_with_fake_ident: SyntaxNode, | 192 | file_with_fake_ident: SyntaxNode, |
193 | offset: TextUnit, | 193 | offset: TextSize, |
194 | ) { | 194 | ) { |
195 | // First, let's try to complete a reference to some declaration. | 195 | // First, let's try to complete a reference to some declaration. |
196 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(&file_with_fake_ident, offset) { | 196 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(&file_with_fake_ident, offset) { |
@@ -224,7 +224,8 @@ impl<'a> CompletionContext<'a> { | |||
224 | } | 224 | } |
225 | if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) { | 225 | if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) { |
226 | if let Some(pat) = let_stmt.pat() { | 226 | if let Some(pat) = let_stmt.pat() { |
227 | if bind_pat.syntax().text_range().is_subrange(&pat.syntax().text_range()) { | 227 | if pat.syntax().text_range().contains_range(bind_pat.syntax().text_range()) |
228 | { | ||
228 | self.is_pat_binding_or_const = false; | 229 | self.is_pat_binding_or_const = false; |
229 | } | 230 | } |
230 | } | 231 | } |
@@ -246,7 +247,7 @@ impl<'a> CompletionContext<'a> { | |||
246 | &mut self, | 247 | &mut self, |
247 | original_file: &SyntaxNode, | 248 | original_file: &SyntaxNode, |
248 | name_ref: ast::NameRef, | 249 | name_ref: ast::NameRef, |
249 | offset: TextUnit, | 250 | offset: TextSize, |
250 | ) { | 251 | ) { |
251 | self.name_ref_syntax = | 252 | self.name_ref_syntax = |
252 | find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); | 253 | find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); |
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 6a6ddc7bd..7633cd7fd 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs | |||
@@ -15,12 +15,7 @@ use crate::{ | |||
15 | }; | 15 | }; |
16 | 16 | ||
17 | impl Completions { | 17 | impl Completions { |
18 | pub(crate) fn add_field( | 18 | pub(crate) fn add_field(&mut self, ctx: &CompletionContext, field: hir::Field, ty: &Type) { |
19 | &mut self, | ||
20 | ctx: &CompletionContext, | ||
21 | field: hir::StructField, | ||
22 | ty: &Type, | ||
23 | ) { | ||
24 | let is_deprecated = is_deprecated(field, ctx.db); | 19 | let is_deprecated = is_deprecated(field, ctx.db); |
25 | let ty = ty.display(ctx.db).to_string(); | 20 | let ty = ty.display(ctx.db).to_string(); |
26 | let name = field.name(ctx.db); | 21 | let name = field.name(ctx.db); |
@@ -452,8 +447,8 @@ mod tests { | |||
452 | [ | 447 | [ |
453 | CompletionItem { | 448 | CompletionItem { |
454 | label: "Foo", | 449 | label: "Foo", |
455 | source_range: [121; 123), | 450 | source_range: 121..123, |
456 | delete: [121; 123), | 451 | delete: 121..123, |
457 | insert: "Foo", | 452 | insert: "Foo", |
458 | kind: EnumVariant, | 453 | kind: EnumVariant, |
459 | detail: "{ x: i32, y: i32 }", | 454 | detail: "{ x: i32, y: i32 }", |
@@ -478,8 +473,8 @@ mod tests { | |||
478 | [ | 473 | [ |
479 | CompletionItem { | 474 | CompletionItem { |
480 | label: "Foo(…)", | 475 | label: "Foo(…)", |
481 | source_range: [115; 117), | 476 | source_range: 115..117, |
482 | delete: [115; 117), | 477 | delete: 115..117, |
483 | insert: "Foo($0)", | 478 | insert: "Foo($0)", |
484 | kind: EnumVariant, | 479 | kind: EnumVariant, |
485 | lookup: "Foo", | 480 | lookup: "Foo", |
@@ -506,8 +501,8 @@ mod tests { | |||
506 | [ | 501 | [ |
507 | CompletionItem { | 502 | CompletionItem { |
508 | label: "Foo", | 503 | label: "Foo", |
509 | source_range: [104; 106), | 504 | source_range: 104..106, |
510 | delete: [104; 106), | 505 | delete: 104..106, |
511 | insert: "Foo", | 506 | insert: "Foo", |
512 | kind: EnumVariant, | 507 | kind: EnumVariant, |
513 | detail: "()", | 508 | detail: "()", |
@@ -534,8 +529,8 @@ mod tests { | |||
534 | [ | 529 | [ |
535 | CompletionItem { | 530 | CompletionItem { |
536 | label: "main()", | 531 | label: "main()", |
537 | source_range: [203; 206), | 532 | source_range: 203..206, |
538 | delete: [203; 206), | 533 | delete: 203..206, |
539 | insert: "main()$0", | 534 | insert: "main()$0", |
540 | kind: Function, | 535 | kind: Function, |
541 | lookup: "main", | 536 | lookup: "main", |
@@ -543,8 +538,8 @@ mod tests { | |||
543 | }, | 538 | }, |
544 | CompletionItem { | 539 | CompletionItem { |
545 | label: "something_deprecated()", | 540 | label: "something_deprecated()", |
546 | source_range: [203; 206), | 541 | source_range: 203..206, |
547 | delete: [203; 206), | 542 | delete: 203..206, |
548 | insert: "something_deprecated()$0", | 543 | insert: "something_deprecated()$0", |
549 | kind: Function, | 544 | kind: Function, |
550 | lookup: "something_deprecated", | 545 | lookup: "something_deprecated", |
@@ -553,8 +548,8 @@ mod tests { | |||
553 | }, | 548 | }, |
554 | CompletionItem { | 549 | CompletionItem { |
555 | label: "something_else_deprecated()", | 550 | label: "something_else_deprecated()", |
556 | source_range: [203; 206), | 551 | source_range: 203..206, |
557 | delete: [203; 206), | 552 | delete: 203..206, |
558 | insert: "something_else_deprecated()$0", | 553 | insert: "something_else_deprecated()$0", |
559 | kind: Function, | 554 | kind: Function, |
560 | lookup: "something_else_deprecated", | 555 | lookup: "something_else_deprecated", |
@@ -580,8 +575,8 @@ mod tests { | |||
580 | [ | 575 | [ |
581 | CompletionItem { | 576 | CompletionItem { |
582 | label: "main()", | 577 | label: "main()", |
583 | source_range: [61; 64), | 578 | source_range: 61..64, |
584 | delete: [61; 64), | 579 | delete: 61..64, |
585 | insert: "main()$0", | 580 | insert: "main()$0", |
586 | kind: Function, | 581 | kind: Function, |
587 | lookup: "main", | 582 | lookup: "main", |
@@ -589,8 +584,8 @@ mod tests { | |||
589 | }, | 584 | }, |
590 | CompletionItem { | 585 | CompletionItem { |
591 | label: "no_args()", | 586 | label: "no_args()", |
592 | source_range: [61; 64), | 587 | source_range: 61..64, |
593 | delete: [61; 64), | 588 | delete: 61..64, |
594 | insert: "no_args()$0", | 589 | insert: "no_args()$0", |
595 | kind: Function, | 590 | kind: Function, |
596 | lookup: "no_args", | 591 | lookup: "no_args", |
@@ -610,8 +605,8 @@ mod tests { | |||
610 | [ | 605 | [ |
611 | CompletionItem { | 606 | CompletionItem { |
612 | label: "main()", | 607 | label: "main()", |
613 | source_range: [80; 85), | 608 | source_range: 80..85, |
614 | delete: [80; 85), | 609 | delete: 80..85, |
615 | insert: "main()$0", | 610 | insert: "main()$0", |
616 | kind: Function, | 611 | kind: Function, |
617 | lookup: "main", | 612 | lookup: "main", |
@@ -619,8 +614,8 @@ mod tests { | |||
619 | }, | 614 | }, |
620 | CompletionItem { | 615 | CompletionItem { |
621 | label: "with_args(…)", | 616 | label: "with_args(…)", |
622 | source_range: [80; 85), | 617 | source_range: 80..85, |
623 | delete: [80; 85), | 618 | delete: 80..85, |
624 | insert: "with_args(${1:x}, ${2:y})$0", | 619 | insert: "with_args(${1:x}, ${2:y})$0", |
625 | kind: Function, | 620 | kind: Function, |
626 | lookup: "with_args", | 621 | lookup: "with_args", |
@@ -646,8 +641,8 @@ mod tests { | |||
646 | [ | 641 | [ |
647 | CompletionItem { | 642 | CompletionItem { |
648 | label: "foo()", | 643 | label: "foo()", |
649 | source_range: [163; 164), | 644 | source_range: 163..164, |
650 | delete: [163; 164), | 645 | delete: 163..164, |
651 | insert: "foo()$0", | 646 | insert: "foo()$0", |
652 | kind: Method, | 647 | kind: Method, |
653 | lookup: "foo", | 648 | lookup: "foo", |
@@ -674,23 +669,23 @@ mod tests { | |||
674 | [ | 669 | [ |
675 | CompletionItem { | 670 | CompletionItem { |
676 | label: "None", | 671 | label: "None", |
677 | source_range: [144; 147), | 672 | source_range: 144..147, |
678 | delete: [144; 147), | 673 | delete: 144..147, |
679 | insert: "None", | 674 | insert: "None", |
680 | kind: EnumVariant, | 675 | kind: EnumVariant, |
681 | detail: "()", | 676 | detail: "()", |
682 | }, | 677 | }, |
683 | CompletionItem { | 678 | CompletionItem { |
684 | label: "Option", | 679 | label: "Option", |
685 | source_range: [144; 147), | 680 | source_range: 144..147, |
686 | delete: [144; 147), | 681 | delete: 144..147, |
687 | insert: "Option", | 682 | insert: "Option", |
688 | kind: Enum, | 683 | kind: Enum, |
689 | }, | 684 | }, |
690 | CompletionItem { | 685 | CompletionItem { |
691 | label: "Some(…)", | 686 | label: "Some(…)", |
692 | source_range: [144; 147), | 687 | source_range: 144..147, |
693 | delete: [144; 147), | 688 | delete: 144..147, |
694 | insert: "Some($0)", | 689 | insert: "Some($0)", |
695 | kind: EnumVariant, | 690 | kind: EnumVariant, |
696 | lookup: "Some", | 691 | lookup: "Some", |
@@ -699,8 +694,8 @@ mod tests { | |||
699 | }, | 694 | }, |
700 | CompletionItem { | 695 | CompletionItem { |
701 | label: "main()", | 696 | label: "main()", |
702 | source_range: [144; 147), | 697 | source_range: 144..147, |
703 | delete: [144; 147), | 698 | delete: 144..147, |
704 | insert: "main()$0", | 699 | insert: "main()$0", |
705 | kind: Function, | 700 | kind: Function, |
706 | lookup: "main", | 701 | lookup: "main", |
@@ -725,23 +720,23 @@ mod tests { | |||
725 | [ | 720 | [ |
726 | CompletionItem { | 721 | CompletionItem { |
727 | label: "None", | 722 | label: "None", |
728 | source_range: [185; 188), | 723 | source_range: 185..188, |
729 | delete: [185; 188), | 724 | delete: 185..188, |
730 | insert: "None", | 725 | insert: "None", |
731 | kind: EnumVariant, | 726 | kind: EnumVariant, |
732 | detail: "()", | 727 | detail: "()", |
733 | }, | 728 | }, |
734 | CompletionItem { | 729 | CompletionItem { |
735 | label: "Option", | 730 | label: "Option", |
736 | source_range: [185; 188), | 731 | source_range: 185..188, |
737 | delete: [185; 188), | 732 | delete: 185..188, |
738 | insert: "Option", | 733 | insert: "Option", |
739 | kind: Enum, | 734 | kind: Enum, |
740 | }, | 735 | }, |
741 | CompletionItem { | 736 | CompletionItem { |
742 | label: "Some(…)", | 737 | label: "Some(…)", |
743 | source_range: [185; 188), | 738 | source_range: 185..188, |
744 | delete: [185; 188), | 739 | delete: 185..188, |
745 | insert: "Some($0)", | 740 | insert: "Some($0)", |
746 | kind: EnumVariant, | 741 | kind: EnumVariant, |
747 | lookup: "Some", | 742 | lookup: "Some", |
@@ -771,8 +766,8 @@ mod tests { | |||
771 | [ | 766 | [ |
772 | CompletionItem { | 767 | CompletionItem { |
773 | label: "foo(…)", | 768 | label: "foo(…)", |
774 | source_range: [171; 172), | 769 | source_range: 171..172, |
775 | delete: [171; 172), | 770 | delete: 171..172, |
776 | insert: "foo(${1:x})$0", | 771 | insert: "foo(${1:x})$0", |
777 | kind: Method, | 772 | kind: Method, |
778 | lookup: "foo", | 773 | lookup: "foo", |
@@ -806,8 +801,8 @@ mod tests { | |||
806 | [ | 801 | [ |
807 | CompletionItem { | 802 | CompletionItem { |
808 | label: "foo(…)", | 803 | label: "foo(…)", |
809 | source_range: [171; 172), | 804 | source_range: 171..172, |
810 | delete: [171; 172), | 805 | delete: 171..172, |
811 | insert: "foo($0)", | 806 | insert: "foo($0)", |
812 | kind: Method, | 807 | kind: Method, |
813 | lookup: "foo", | 808 | lookup: "foo", |
@@ -833,8 +828,8 @@ mod tests { | |||
833 | [ | 828 | [ |
834 | CompletionItem { | 829 | CompletionItem { |
835 | label: "foo", | 830 | label: "foo", |
836 | source_range: [40; 41), | 831 | source_range: 40..41, |
837 | delete: [40; 41), | 832 | delete: 40..41, |
838 | insert: "foo", | 833 | insert: "foo", |
839 | kind: Function, | 834 | kind: Function, |
840 | detail: "pub fn foo()", | 835 | detail: "pub fn foo()", |
@@ -860,16 +855,16 @@ mod tests { | |||
860 | [ | 855 | [ |
861 | CompletionItem { | 856 | CompletionItem { |
862 | label: "frobnicate", | 857 | label: "frobnicate", |
863 | source_range: [35; 39), | 858 | source_range: 35..39, |
864 | delete: [35; 39), | 859 | delete: 35..39, |
865 | insert: "frobnicate", | 860 | insert: "frobnicate", |
866 | kind: Function, | 861 | kind: Function, |
867 | detail: "fn frobnicate()", | 862 | detail: "fn frobnicate()", |
868 | }, | 863 | }, |
869 | CompletionItem { | 864 | CompletionItem { |
870 | label: "main", | 865 | label: "main", |
871 | source_range: [35; 39), | 866 | source_range: 35..39, |
872 | delete: [35; 39), | 867 | delete: 35..39, |
873 | insert: "main", | 868 | insert: "main", |
874 | kind: Function, | 869 | kind: Function, |
875 | detail: "fn main()", | 870 | detail: "fn main()", |
@@ -892,8 +887,8 @@ mod tests { | |||
892 | [ | 887 | [ |
893 | CompletionItem { | 888 | CompletionItem { |
894 | label: "new", | 889 | label: "new", |
895 | source_range: [67; 69), | 890 | source_range: 67..69, |
896 | delete: [67; 69), | 891 | delete: 67..69, |
897 | insert: "new", | 892 | insert: "new", |
898 | kind: Function, | 893 | kind: Function, |
899 | detail: "fn new() -> Foo", | 894 | detail: "fn new() -> Foo", |
@@ -917,16 +912,16 @@ mod tests { | |||
917 | [ | 912 | [ |
918 | CompletionItem { | 913 | CompletionItem { |
919 | label: "Vec<…>", | 914 | label: "Vec<…>", |
920 | source_range: [61; 63), | 915 | source_range: 61..63, |
921 | delete: [61; 63), | 916 | delete: 61..63, |
922 | insert: "Vec<$0>", | 917 | insert: "Vec<$0>", |
923 | kind: Struct, | 918 | kind: Struct, |
924 | lookup: "Vec", | 919 | lookup: "Vec", |
925 | }, | 920 | }, |
926 | CompletionItem { | 921 | CompletionItem { |
927 | label: "foo(…)", | 922 | label: "foo(…)", |
928 | source_range: [61; 63), | 923 | source_range: 61..63, |
929 | delete: [61; 63), | 924 | delete: 61..63, |
930 | insert: "foo(${1:xs})$0", | 925 | insert: "foo(${1:xs})$0", |
931 | kind: Function, | 926 | kind: Function, |
932 | lookup: "foo", | 927 | lookup: "foo", |
@@ -947,16 +942,16 @@ mod tests { | |||
947 | [ | 942 | [ |
948 | CompletionItem { | 943 | CompletionItem { |
949 | label: "Vec<…>", | 944 | label: "Vec<…>", |
950 | source_range: [64; 66), | 945 | source_range: 64..66, |
951 | delete: [64; 66), | 946 | delete: 64..66, |
952 | insert: "Vec<$0>", | 947 | insert: "Vec<$0>", |
953 | kind: TypeAlias, | 948 | kind: TypeAlias, |
954 | lookup: "Vec", | 949 | lookup: "Vec", |
955 | }, | 950 | }, |
956 | CompletionItem { | 951 | CompletionItem { |
957 | label: "foo(…)", | 952 | label: "foo(…)", |
958 | source_range: [64; 66), | 953 | source_range: 64..66, |
959 | delete: [64; 66), | 954 | delete: 64..66, |
960 | insert: "foo(${1:xs})$0", | 955 | insert: "foo(${1:xs})$0", |
961 | kind: Function, | 956 | kind: Function, |
962 | lookup: "foo", | 957 | lookup: "foo", |
@@ -977,15 +972,15 @@ mod tests { | |||
977 | [ | 972 | [ |
978 | CompletionItem { | 973 | CompletionItem { |
979 | label: "Vec", | 974 | label: "Vec", |
980 | source_range: [68; 70), | 975 | source_range: 68..70, |
981 | delete: [68; 70), | 976 | delete: 68..70, |
982 | insert: "Vec", | 977 | insert: "Vec", |
983 | kind: Struct, | 978 | kind: Struct, |
984 | }, | 979 | }, |
985 | CompletionItem { | 980 | CompletionItem { |
986 | label: "foo(…)", | 981 | label: "foo(…)", |
987 | source_range: [68; 70), | 982 | source_range: 68..70, |
988 | delete: [68; 70), | 983 | delete: 68..70, |
989 | insert: "foo(${1:xs})$0", | 984 | insert: "foo(${1:xs})$0", |
990 | kind: Function, | 985 | kind: Function, |
991 | lookup: "foo", | 986 | lookup: "foo", |
@@ -1006,15 +1001,15 @@ mod tests { | |||
1006 | [ | 1001 | [ |
1007 | CompletionItem { | 1002 | CompletionItem { |
1008 | label: "Vec", | 1003 | label: "Vec", |
1009 | source_range: [61; 63), | 1004 | source_range: 61..63, |
1010 | delete: [61; 63), | 1005 | delete: 61..63, |
1011 | insert: "Vec", | 1006 | insert: "Vec", |
1012 | kind: Struct, | 1007 | kind: Struct, |
1013 | }, | 1008 | }, |
1014 | CompletionItem { | 1009 | CompletionItem { |
1015 | label: "foo(…)", | 1010 | label: "foo(…)", |
1016 | source_range: [61; 63), | 1011 | source_range: 61..63, |
1017 | delete: [61; 63), | 1012 | delete: 61..63, |
1018 | insert: "foo(${1:xs})$0", | 1013 | insert: "foo(${1:xs})$0", |
1019 | kind: Function, | 1014 | kind: Function, |
1020 | lookup: "foo", | 1015 | lookup: "foo", |
@@ -1046,8 +1041,8 @@ mod tests { | |||
1046 | [ | 1041 | [ |
1047 | CompletionItem { | 1042 | CompletionItem { |
1048 | label: "frobnicate!", | 1043 | label: "frobnicate!", |
1049 | source_range: [9; 9), | 1044 | source_range: 9..9, |
1050 | delete: [9; 9), | 1045 | delete: 9..9, |
1051 | insert: "frobnicate", | 1046 | insert: "frobnicate", |
1052 | kind: Macro, | 1047 | kind: Macro, |
1053 | detail: "#[macro_export]\nmacro_rules! frobnicate", | 1048 | detail: "#[macro_export]\nmacro_rules! frobnicate", |
@@ -1072,16 +1067,16 @@ mod tests { | |||
1072 | [ | 1067 | [ |
1073 | CompletionItem { | 1068 | CompletionItem { |
1074 | label: "frobnicate!", | 1069 | label: "frobnicate!", |
1075 | source_range: [56; 60), | 1070 | source_range: 56..60, |
1076 | delete: [56; 60), | 1071 | delete: 56..60, |
1077 | insert: "frobnicate", | 1072 | insert: "frobnicate", |
1078 | kind: Macro, | 1073 | kind: Macro, |
1079 | detail: "macro_rules! frobnicate", | 1074 | detail: "macro_rules! frobnicate", |
1080 | }, | 1075 | }, |
1081 | CompletionItem { | 1076 | CompletionItem { |
1082 | label: "main()", | 1077 | label: "main()", |
1083 | source_range: [56; 60), | 1078 | source_range: 56..60, |
1084 | delete: [56; 60), | 1079 | delete: 56..60, |
1085 | insert: "main()$0", | 1080 | insert: "main()$0", |
1086 | kind: Function, | 1081 | kind: Function, |
1087 | lookup: "main", | 1082 | lookup: "main", |
@@ -1109,24 +1104,24 @@ mod tests { | |||
1109 | [ | 1104 | [ |
1110 | CompletionItem { | 1105 | CompletionItem { |
1111 | label: "another_field", | 1106 | label: "another_field", |
1112 | source_range: [201; 201), | 1107 | source_range: 201..201, |
1113 | delete: [201; 201), | 1108 | delete: 201..201, |
1114 | insert: "another_field", | 1109 | insert: "another_field", |
1115 | kind: Field, | 1110 | kind: Field, |
1116 | detail: "i64", | 1111 | detail: "i64", |
1117 | }, | 1112 | }, |
1118 | CompletionItem { | 1113 | CompletionItem { |
1119 | label: "my_string", | 1114 | label: "my_string", |
1120 | source_range: [201; 201), | 1115 | source_range: 201..201, |
1121 | delete: [201; 201), | 1116 | delete: 201..201, |
1122 | insert: "my_string", | 1117 | insert: "my_string", |
1123 | kind: Field, | 1118 | kind: Field, |
1124 | detail: "{unknown}", | 1119 | detail: "{unknown}", |
1125 | }, | 1120 | }, |
1126 | CompletionItem { | 1121 | CompletionItem { |
1127 | label: "the_field", | 1122 | label: "the_field", |
1128 | source_range: [201; 201), | 1123 | source_range: 201..201, |
1129 | delete: [201; 201), | 1124 | delete: 201..201, |
1130 | insert: "the_field", | 1125 | insert: "the_field", |
1131 | kind: Field, | 1126 | kind: Field, |
1132 | detail: "u32", | 1127 | detail: "u32", |
@@ -1153,16 +1148,16 @@ mod tests { | |||
1153 | [ | 1148 | [ |
1154 | CompletionItem { | 1149 | CompletionItem { |
1155 | label: "another_field", | 1150 | label: "another_field", |
1156 | source_range: [208; 208), | 1151 | source_range: 208..208, |
1157 | delete: [208; 208), | 1152 | delete: 208..208, |
1158 | insert: "another_field", | 1153 | insert: "another_field", |
1159 | kind: Field, | 1154 | kind: Field, |
1160 | detail: "i64", | 1155 | detail: "i64", |
1161 | }, | 1156 | }, |
1162 | CompletionItem { | 1157 | CompletionItem { |
1163 | label: "another_good_type", | 1158 | label: "another_good_type", |
1164 | source_range: [208; 208), | 1159 | source_range: 208..208, |
1165 | delete: [208; 208), | 1160 | delete: 208..208, |
1166 | insert: "another_good_type", | 1161 | insert: "another_good_type", |
1167 | kind: Field, | 1162 | kind: Field, |
1168 | detail: "u32", | 1163 | detail: "u32", |
@@ -1170,8 +1165,8 @@ mod tests { | |||
1170 | }, | 1165 | }, |
1171 | CompletionItem { | 1166 | CompletionItem { |
1172 | label: "the_field", | 1167 | label: "the_field", |
1173 | source_range: [208; 208), | 1168 | source_range: 208..208, |
1174 | delete: [208; 208), | 1169 | delete: 208..208, |
1175 | insert: "the_field", | 1170 | insert: "the_field", |
1176 | kind: Field, | 1171 | kind: Field, |
1177 | detail: "u32", | 1172 | detail: "u32", |
@@ -1201,16 +1196,16 @@ mod tests { | |||
1201 | [ | 1196 | [ |
1202 | CompletionItem { | 1197 | CompletionItem { |
1203 | label: "another_field", | 1198 | label: "another_field", |
1204 | source_range: [270; 270), | 1199 | source_range: 270..270, |
1205 | delete: [270; 270), | 1200 | delete: 270..270, |
1206 | insert: "another_field", | 1201 | insert: "another_field", |
1207 | kind: Field, | 1202 | kind: Field, |
1208 | detail: "i64", | 1203 | detail: "i64", |
1209 | }, | 1204 | }, |
1210 | CompletionItem { | 1205 | CompletionItem { |
1211 | label: "another_good_type", | 1206 | label: "another_good_type", |
1212 | source_range: [270; 270), | 1207 | source_range: 270..270, |
1213 | delete: [270; 270), | 1208 | delete: 270..270, |
1214 | insert: "another_good_type", | 1209 | insert: "another_good_type", |
1215 | kind: Field, | 1210 | kind: Field, |
1216 | detail: "u32", | 1211 | detail: "u32", |
@@ -1218,8 +1213,8 @@ mod tests { | |||
1218 | }, | 1213 | }, |
1219 | CompletionItem { | 1214 | CompletionItem { |
1220 | label: "the_field", | 1215 | label: "the_field", |
1221 | source_range: [270; 270), | 1216 | source_range: 270..270, |
1222 | delete: [270; 270), | 1217 | delete: 270..270, |
1223 | insert: "the_field", | 1218 | insert: "the_field", |
1224 | kind: Field, | 1219 | kind: Field, |
1225 | detail: "u32", | 1220 | detail: "u32", |
@@ -1249,8 +1244,8 @@ mod tests { | |||
1249 | [ | 1244 | [ |
1250 | CompletionItem { | 1245 | CompletionItem { |
1251 | label: "another_field", | 1246 | label: "another_field", |
1252 | source_range: [336; 336), | 1247 | source_range: 336..336, |
1253 | delete: [336; 336), | 1248 | delete: 336..336, |
1254 | insert: "another_field", | 1249 | insert: "another_field", |
1255 | kind: Field, | 1250 | kind: Field, |
1256 | detail: "i64", | 1251 | detail: "i64", |
@@ -1258,16 +1253,16 @@ mod tests { | |||
1258 | }, | 1253 | }, |
1259 | CompletionItem { | 1254 | CompletionItem { |
1260 | label: "another_good_type", | 1255 | label: "another_good_type", |
1261 | source_range: [336; 336), | 1256 | source_range: 336..336, |
1262 | delete: [336; 336), | 1257 | delete: 336..336, |
1263 | insert: "another_good_type", | 1258 | insert: "another_good_type", |
1264 | kind: Field, | 1259 | kind: Field, |
1265 | detail: "u32", | 1260 | detail: "u32", |
1266 | }, | 1261 | }, |
1267 | CompletionItem { | 1262 | CompletionItem { |
1268 | label: "the_field", | 1263 | label: "the_field", |
1269 | source_range: [336; 336), | 1264 | source_range: 336..336, |
1270 | delete: [336; 336), | 1265 | delete: 336..336, |
1271 | insert: "the_field", | 1266 | insert: "the_field", |
1272 | kind: Field, | 1267 | kind: Field, |
1273 | detail: "u32", | 1268 | detail: "u32", |
@@ -1296,16 +1291,16 @@ mod tests { | |||
1296 | [ | 1291 | [ |
1297 | CompletionItem { | 1292 | CompletionItem { |
1298 | label: "another_field", | 1293 | label: "another_field", |
1299 | source_range: [328; 328), | 1294 | source_range: 328..328, |
1300 | delete: [328; 328), | 1295 | delete: 328..328, |
1301 | insert: "another_field", | 1296 | insert: "another_field", |
1302 | kind: Field, | 1297 | kind: Field, |
1303 | detail: "i64", | 1298 | detail: "i64", |
1304 | }, | 1299 | }, |
1305 | CompletionItem { | 1300 | CompletionItem { |
1306 | label: "another_good_type", | 1301 | label: "another_good_type", |
1307 | source_range: [328; 328), | 1302 | source_range: 328..328, |
1308 | delete: [328; 328), | 1303 | delete: 328..328, |
1309 | insert: "another_good_type", | 1304 | insert: "another_good_type", |
1310 | kind: Field, | 1305 | kind: Field, |
1311 | detail: "u32", | 1306 | detail: "u32", |
@@ -1313,8 +1308,8 @@ mod tests { | |||
1313 | }, | 1308 | }, |
1314 | CompletionItem { | 1309 | CompletionItem { |
1315 | label: "the_field", | 1310 | label: "the_field", |
1316 | source_range: [328; 328), | 1311 | source_range: 328..328, |
1317 | delete: [328; 328), | 1312 | delete: 328..328, |
1318 | insert: "the_field", | 1313 | insert: "the_field", |
1319 | kind: Field, | 1314 | kind: Field, |
1320 | detail: "u32", | 1315 | detail: "u32", |
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index e7e201709..a6b4c2c28 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs | |||
@@ -171,7 +171,7 @@ fn text_edit_for_remove_unnecessary_braces_with_self_in_use_statement( | |||
171 | if single_use_tree.path()?.segment()?.syntax().first_child_or_token()?.kind() == T![self] { | 171 | if single_use_tree.path()?.segment()?.syntax().first_child_or_token()?.kind() == T![self] { |
172 | let start = use_tree_list_node.prev_sibling_or_token()?.text_range().start(); | 172 | let start = use_tree_list_node.prev_sibling_or_token()?.text_range().start(); |
173 | let end = use_tree_list_node.text_range().end(); | 173 | let end = use_tree_list_node.text_range().end(); |
174 | let range = TextRange::from_to(start, end); | 174 | let range = TextRange::new(start, end); |
175 | return Some(TextEdit::delete(range)); | 175 | return Some(TextEdit::delete(range)); |
176 | } | 176 | } |
177 | None | 177 | None |
@@ -277,7 +277,7 @@ mod tests { | |||
277 | assert!( | 277 | assert!( |
278 | diagnostic.range.start() <= file_position.offset | 278 | diagnostic.range.start() <= file_position.offset |
279 | && diagnostic.range.end() >= file_position.offset, | 279 | && diagnostic.range.end() >= file_position.offset, |
280 | "diagnostic range {} does not touch cursor position {}", | 280 | "diagnostic range {:?} does not touch cursor position {:?}", |
281 | diagnostic.range, | 281 | diagnostic.range, |
282 | file_position.offset | 282 | file_position.offset |
283 | ); | 283 | ); |
@@ -603,7 +603,7 @@ mod tests { | |||
603 | [ | 603 | [ |
604 | Diagnostic { | 604 | Diagnostic { |
605 | message: "unresolved module", | 605 | message: "unresolved module", |
606 | range: [0; 8), | 606 | range: 0..8, |
607 | fix: Some( | 607 | fix: Some( |
608 | SourceChange { | 608 | SourceChange { |
609 | label: "create module", | 609 | label: "create module", |
@@ -652,7 +652,7 @@ mod tests { | |||
652 | [ | 652 | [ |
653 | Diagnostic { | 653 | Diagnostic { |
654 | message: "Missing structure fields:\n- b", | 654 | message: "Missing structure fields:\n- b", |
655 | range: [224; 233), | 655 | range: 224..233, |
656 | fix: Some( | 656 | fix: Some( |
657 | SourceChange { | 657 | SourceChange { |
658 | label: "fill struct fields", | 658 | label: "fill struct fields", |
@@ -664,7 +664,7 @@ mod tests { | |||
664 | edit: TextEdit { | 664 | edit: TextEdit { |
665 | atoms: [ | 665 | atoms: [ |
666 | AtomTextEdit { | 666 | AtomTextEdit { |
667 | delete: [3; 9), | 667 | delete: 3..9, |
668 | insert: "{a:42, b: ()}", | 668 | insert: "{a:42, b: ()}", |
669 | }, | 669 | }, |
670 | ], | 670 | ], |
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 67bc9c31b..914a8b471 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -189,7 +189,7 @@ impl TryToNav for Definition { | |||
189 | fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> { | 189 | fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> { |
190 | match self { | 190 | match self { |
191 | Definition::Macro(it) => Some(it.to_nav(db)), | 191 | Definition::Macro(it) => Some(it.to_nav(db)), |
192 | Definition::StructField(it) => Some(it.to_nav(db)), | 192 | Definition::Field(it) => Some(it.to_nav(db)), |
193 | Definition::ModuleDef(it) => it.try_to_nav(db), | 193 | Definition::ModuleDef(it) => it.try_to_nav(db), |
194 | Definition::SelfType(it) => Some(it.to_nav(db)), | 194 | Definition::SelfType(it) => Some(it.to_nav(db)), |
195 | Definition::Local(it) => Some(it.to_nav(db)), | 195 | Definition::Local(it) => Some(it.to_nav(db)), |
@@ -286,7 +286,7 @@ impl ToNav for hir::ImplDef { | |||
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | impl ToNav for hir::StructField { | 289 | impl ToNav for hir::Field { |
290 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { | 290 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { |
291 | let src = self.source(db); | 291 | let src = self.source(db); |
292 | 292 | ||
diff --git a/crates/ra_ide/src/display/structure.rs b/crates/ra_ide/src/display/structure.rs index 7a774785c..967eee5d2 100644 --- a/crates/ra_ide/src/display/structure.rs +++ b/crates/ra_ide/src/display/structure.rs | |||
@@ -224,8 +224,8 @@ fn very_obsolete() {} | |||
224 | StructureNode { | 224 | StructureNode { |
225 | parent: None, | 225 | parent: None, |
226 | label: "Foo", | 226 | label: "Foo", |
227 | navigation_range: [8; 11), | 227 | navigation_range: 8..11, |
228 | node_range: [1; 26), | 228 | node_range: 1..26, |
229 | kind: STRUCT_DEF, | 229 | kind: STRUCT_DEF, |
230 | detail: None, | 230 | detail: None, |
231 | deprecated: false, | 231 | deprecated: false, |
@@ -235,8 +235,8 @@ fn very_obsolete() {} | |||
235 | 0, | 235 | 0, |
236 | ), | 236 | ), |
237 | label: "x", | 237 | label: "x", |
238 | navigation_range: [18; 19), | 238 | navigation_range: 18..19, |
239 | node_range: [18; 24), | 239 | node_range: 18..24, |
240 | kind: RECORD_FIELD_DEF, | 240 | kind: RECORD_FIELD_DEF, |
241 | detail: Some( | 241 | detail: Some( |
242 | "i32", | 242 | "i32", |
@@ -246,8 +246,8 @@ fn very_obsolete() {} | |||
246 | StructureNode { | 246 | StructureNode { |
247 | parent: None, | 247 | parent: None, |
248 | label: "m", | 248 | label: "m", |
249 | navigation_range: [32; 33), | 249 | navigation_range: 32..33, |
250 | node_range: [28; 158), | 250 | node_range: 28..158, |
251 | kind: MODULE, | 251 | kind: MODULE, |
252 | detail: None, | 252 | detail: None, |
253 | deprecated: false, | 253 | deprecated: false, |
@@ -257,8 +257,8 @@ fn very_obsolete() {} | |||
257 | 2, | 257 | 2, |
258 | ), | 258 | ), |
259 | label: "bar1", | 259 | label: "bar1", |
260 | navigation_range: [43; 47), | 260 | navigation_range: 43..47, |
261 | node_range: [40; 52), | 261 | node_range: 40..52, |
262 | kind: FN_DEF, | 262 | kind: FN_DEF, |
263 | detail: Some( | 263 | detail: Some( |
264 | "fn()", | 264 | "fn()", |
@@ -270,8 +270,8 @@ fn very_obsolete() {} | |||
270 | 2, | 270 | 2, |
271 | ), | 271 | ), |
272 | label: "bar2", | 272 | label: "bar2", |
273 | navigation_range: [60; 64), | 273 | navigation_range: 60..64, |
274 | node_range: [57; 81), | 274 | node_range: 57..81, |
275 | kind: FN_DEF, | 275 | kind: FN_DEF, |
276 | detail: Some( | 276 | detail: Some( |
277 | "fn<T>(t: T) -> T", | 277 | "fn<T>(t: T) -> T", |
@@ -283,8 +283,8 @@ fn very_obsolete() {} | |||
283 | 2, | 283 | 2, |
284 | ), | 284 | ), |
285 | label: "bar3", | 285 | label: "bar3", |
286 | navigation_range: [89; 93), | 286 | navigation_range: 89..93, |
287 | node_range: [86; 156), | 287 | node_range: 86..156, |
288 | kind: FN_DEF, | 288 | kind: FN_DEF, |
289 | detail: Some( | 289 | detail: Some( |
290 | "fn<A, B>(a: A, b: B) -> Vec< u32 >", | 290 | "fn<A, B>(a: A, b: B) -> Vec< u32 >", |
@@ -294,8 +294,8 @@ fn very_obsolete() {} | |||
294 | StructureNode { | 294 | StructureNode { |
295 | parent: None, | 295 | parent: None, |
296 | label: "E", | 296 | label: "E", |
297 | navigation_range: [165; 166), | 297 | navigation_range: 165..166, |
298 | node_range: [160; 180), | 298 | node_range: 160..180, |
299 | kind: ENUM_DEF, | 299 | kind: ENUM_DEF, |
300 | detail: None, | 300 | detail: None, |
301 | deprecated: false, | 301 | deprecated: false, |
@@ -305,8 +305,8 @@ fn very_obsolete() {} | |||
305 | 6, | 305 | 6, |
306 | ), | 306 | ), |
307 | label: "X", | 307 | label: "X", |
308 | navigation_range: [169; 170), | 308 | navigation_range: 169..170, |
309 | node_range: [169; 170), | 309 | node_range: 169..170, |
310 | kind: ENUM_VARIANT, | 310 | kind: ENUM_VARIANT, |
311 | detail: None, | 311 | detail: None, |
312 | deprecated: false, | 312 | deprecated: false, |
@@ -316,8 +316,8 @@ fn very_obsolete() {} | |||
316 | 6, | 316 | 6, |
317 | ), | 317 | ), |
318 | label: "Y", | 318 | label: "Y", |
319 | navigation_range: [172; 173), | 319 | navigation_range: 172..173, |
320 | node_range: [172; 178), | 320 | node_range: 172..178, |
321 | kind: ENUM_VARIANT, | 321 | kind: ENUM_VARIANT, |
322 | detail: None, | 322 | detail: None, |
323 | deprecated: false, | 323 | deprecated: false, |
@@ -325,8 +325,8 @@ fn very_obsolete() {} | |||
325 | StructureNode { | 325 | StructureNode { |
326 | parent: None, | 326 | parent: None, |
327 | label: "T", | 327 | label: "T", |
328 | navigation_range: [186; 187), | 328 | navigation_range: 186..187, |
329 | node_range: [181; 193), | 329 | node_range: 181..193, |
330 | kind: TYPE_ALIAS_DEF, | 330 | kind: TYPE_ALIAS_DEF, |
331 | detail: Some( | 331 | detail: Some( |
332 | "()", | 332 | "()", |
@@ -336,8 +336,8 @@ fn very_obsolete() {} | |||
336 | StructureNode { | 336 | StructureNode { |
337 | parent: None, | 337 | parent: None, |
338 | label: "S", | 338 | label: "S", |
339 | navigation_range: [201; 202), | 339 | navigation_range: 201..202, |
340 | node_range: [194; 213), | 340 | node_range: 194..213, |
341 | kind: STATIC_DEF, | 341 | kind: STATIC_DEF, |
342 | detail: Some( | 342 | detail: Some( |
343 | "i32", | 343 | "i32", |
@@ -347,8 +347,8 @@ fn very_obsolete() {} | |||
347 | StructureNode { | 347 | StructureNode { |
348 | parent: None, | 348 | parent: None, |
349 | label: "C", | 349 | label: "C", |
350 | navigation_range: [220; 221), | 350 | navigation_range: 220..221, |
351 | node_range: [214; 232), | 351 | node_range: 214..232, |
352 | kind: CONST_DEF, | 352 | kind: CONST_DEF, |
353 | detail: Some( | 353 | detail: Some( |
354 | "i32", | 354 | "i32", |
@@ -358,8 +358,8 @@ fn very_obsolete() {} | |||
358 | StructureNode { | 358 | StructureNode { |
359 | parent: None, | 359 | parent: None, |
360 | label: "impl E", | 360 | label: "impl E", |
361 | navigation_range: [239; 240), | 361 | navigation_range: 239..240, |
362 | node_range: [234; 243), | 362 | node_range: 234..243, |
363 | kind: IMPL_DEF, | 363 | kind: IMPL_DEF, |
364 | detail: None, | 364 | detail: None, |
365 | deprecated: false, | 365 | deprecated: false, |
@@ -367,8 +367,8 @@ fn very_obsolete() {} | |||
367 | StructureNode { | 367 | StructureNode { |
368 | parent: None, | 368 | parent: None, |
369 | label: "impl fmt::Debug for E", | 369 | label: "impl fmt::Debug for E", |
370 | navigation_range: [265; 266), | 370 | navigation_range: 265..266, |
371 | node_range: [245; 269), | 371 | node_range: 245..269, |
372 | kind: IMPL_DEF, | 372 | kind: IMPL_DEF, |
373 | detail: None, | 373 | detail: None, |
374 | deprecated: false, | 374 | deprecated: false, |
@@ -376,8 +376,8 @@ fn very_obsolete() {} | |||
376 | StructureNode { | 376 | StructureNode { |
377 | parent: None, | 377 | parent: None, |
378 | label: "mc", | 378 | label: "mc", |
379 | navigation_range: [284; 286), | 379 | navigation_range: 284..286, |
380 | node_range: [271; 303), | 380 | node_range: 271..303, |
381 | kind: MACRO_CALL, | 381 | kind: MACRO_CALL, |
382 | detail: None, | 382 | detail: None, |
383 | deprecated: false, | 383 | deprecated: false, |
@@ -385,8 +385,8 @@ fn very_obsolete() {} | |||
385 | StructureNode { | 385 | StructureNode { |
386 | parent: None, | 386 | parent: None, |
387 | label: "mcexp", | 387 | label: "mcexp", |
388 | navigation_range: [334; 339), | 388 | navigation_range: 334..339, |
389 | node_range: [305; 356), | 389 | node_range: 305..356, |
390 | kind: MACRO_CALL, | 390 | kind: MACRO_CALL, |
391 | detail: None, | 391 | detail: None, |
392 | deprecated: false, | 392 | deprecated: false, |
@@ -394,8 +394,8 @@ fn very_obsolete() {} | |||
394 | StructureNode { | 394 | StructureNode { |
395 | parent: None, | 395 | parent: None, |
396 | label: "mcexp", | 396 | label: "mcexp", |
397 | navigation_range: [387; 392), | 397 | navigation_range: 387..392, |
398 | node_range: [358; 409), | 398 | node_range: 358..409, |
399 | kind: MACRO_CALL, | 399 | kind: MACRO_CALL, |
400 | detail: None, | 400 | detail: None, |
401 | deprecated: false, | 401 | deprecated: false, |
@@ -403,8 +403,8 @@ fn very_obsolete() {} | |||
403 | StructureNode { | 403 | StructureNode { |
404 | parent: None, | 404 | parent: None, |
405 | label: "obsolete", | 405 | label: "obsolete", |
406 | navigation_range: [428; 436), | 406 | navigation_range: 428..436, |
407 | node_range: [411; 441), | 407 | node_range: 411..441, |
408 | kind: FN_DEF, | 408 | kind: FN_DEF, |
409 | detail: Some( | 409 | detail: Some( |
410 | "fn()", | 410 | "fn()", |
@@ -414,8 +414,8 @@ fn very_obsolete() {} | |||
414 | StructureNode { | 414 | StructureNode { |
415 | parent: None, | 415 | parent: None, |
416 | label: "very_obsolete", | 416 | label: "very_obsolete", |
417 | navigation_range: [481; 494), | 417 | navigation_range: 481..494, |
418 | node_range: [443; 499), | 418 | node_range: 443..499, |
419 | kind: FN_DEF, | 419 | kind: FN_DEF, |
420 | detail: Some( | 420 | detail: Some( |
421 | "fn()", | 421 | "fn()", |
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index 753d2ef6a..554594a43 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs | |||
@@ -9,7 +9,7 @@ use ra_syntax::{ | |||
9 | ast::{self, AstNode, AstToken}, | 9 | ast::{self, AstNode, AstToken}, |
10 | Direction, NodeOrToken, | 10 | Direction, NodeOrToken, |
11 | SyntaxKind::{self, *}, | 11 | SyntaxKind::{self, *}, |
12 | SyntaxNode, SyntaxToken, TextRange, TextUnit, TokenAtOffset, T, | 12 | SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, T, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | use crate::FileRange; | 15 | use crate::FileRange; |
@@ -121,10 +121,10 @@ fn extend_tokens_from_range( | |||
121 | let mut first_token = skip_trivia_token(first_token, Direction::Next)?; | 121 | let mut first_token = skip_trivia_token(first_token, Direction::Next)?; |
122 | let mut last_token = skip_trivia_token(last_token, Direction::Prev)?; | 122 | let mut last_token = skip_trivia_token(last_token, Direction::Prev)?; |
123 | 123 | ||
124 | while !first_token.text_range().is_subrange(&original_range) { | 124 | while !original_range.contains_range(first_token.text_range()) { |
125 | first_token = skip_trivia_token(first_token.next_token()?, Direction::Next)?; | 125 | first_token = skip_trivia_token(first_token.next_token()?, Direction::Next)?; |
126 | } | 126 | } |
127 | while !last_token.text_range().is_subrange(&original_range) { | 127 | while !original_range.contains_range(last_token.text_range()) { |
128 | last_token = skip_trivia_token(last_token.prev_token()?, Direction::Prev)?; | 128 | last_token = skip_trivia_token(last_token.prev_token()?, Direction::Prev)?; |
129 | } | 129 | } |
130 | 130 | ||
@@ -161,8 +161,8 @@ fn extend_tokens_from_range( | |||
161 | .take_while(validate) | 161 | .take_while(validate) |
162 | .last()?; | 162 | .last()?; |
163 | 163 | ||
164 | let range = first.text_range().extend_to(&last.text_range()); | 164 | let range = first.text_range().cover(last.text_range()); |
165 | if original_range.is_subrange(&range) && original_range != range { | 165 | if range.contains_range(original_range) && original_range != range { |
166 | Some(range) | 166 | Some(range) |
167 | } else { | 167 | } else { |
168 | None | 168 | None |
@@ -176,7 +176,7 @@ fn shallowest_node(node: &SyntaxNode) -> SyntaxNode { | |||
176 | 176 | ||
177 | fn extend_single_word_in_comment_or_string( | 177 | fn extend_single_word_in_comment_or_string( |
178 | leaf: &SyntaxToken, | 178 | leaf: &SyntaxToken, |
179 | offset: TextUnit, | 179 | offset: TextSize, |
180 | ) -> Option<TextRange> { | 180 | ) -> Option<TextRange> { |
181 | let text: &str = leaf.text(); | 181 | let text: &str = leaf.text(); |
182 | let cursor_position: u32 = (offset - leaf.text_range().start()).into(); | 182 | let cursor_position: u32 = (offset - leaf.text_range().start()).into(); |
@@ -190,10 +190,10 @@ fn extend_single_word_in_comment_or_string( | |||
190 | let start_idx = before.rfind(non_word_char)? as u32; | 190 | let start_idx = before.rfind(non_word_char)? as u32; |
191 | let end_idx = after.find(non_word_char).unwrap_or_else(|| after.len()) as u32; | 191 | let end_idx = after.find(non_word_char).unwrap_or_else(|| after.len()) as u32; |
192 | 192 | ||
193 | let from: TextUnit = (start_idx + 1).into(); | 193 | let from: TextSize = (start_idx + 1).into(); |
194 | let to: TextUnit = (cursor_position + end_idx).into(); | 194 | let to: TextSize = (cursor_position + end_idx).into(); |
195 | 195 | ||
196 | let range = TextRange::from_to(from, to); | 196 | let range = TextRange::new(from, to); |
197 | if range.is_empty() { | 197 | if range.is_empty() { |
198 | None | 198 | None |
199 | } else { | 199 | } else { |
@@ -201,24 +201,24 @@ fn extend_single_word_in_comment_or_string( | |||
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | fn extend_ws(root: &SyntaxNode, ws: SyntaxToken, offset: TextUnit) -> TextRange { | 204 | fn extend_ws(root: &SyntaxNode, ws: SyntaxToken, offset: TextSize) -> TextRange { |
205 | let ws_text = ws.text(); | 205 | let ws_text = ws.text(); |
206 | let suffix = TextRange::from_to(offset, ws.text_range().end()) - ws.text_range().start(); | 206 | let suffix = TextRange::new(offset, ws.text_range().end()) - ws.text_range().start(); |
207 | let prefix = TextRange::from_to(ws.text_range().start(), offset) - ws.text_range().start(); | 207 | let prefix = TextRange::new(ws.text_range().start(), offset) - ws.text_range().start(); |
208 | let ws_suffix = &ws_text.as_str()[suffix]; | 208 | let ws_suffix = &ws_text.as_str()[suffix]; |
209 | let ws_prefix = &ws_text.as_str()[prefix]; | 209 | let ws_prefix = &ws_text.as_str()[prefix]; |
210 | if ws_text.contains('\n') && !ws_suffix.contains('\n') { | 210 | if ws_text.contains('\n') && !ws_suffix.contains('\n') { |
211 | if let Some(node) = ws.next_sibling_or_token() { | 211 | if let Some(node) = ws.next_sibling_or_token() { |
212 | let start = match ws_prefix.rfind('\n') { | 212 | let start = match ws_prefix.rfind('\n') { |
213 | Some(idx) => ws.text_range().start() + TextUnit::from((idx + 1) as u32), | 213 | Some(idx) => ws.text_range().start() + TextSize::from((idx + 1) as u32), |
214 | None => node.text_range().start(), | 214 | None => node.text_range().start(), |
215 | }; | 215 | }; |
216 | let end = if root.text().char_at(node.text_range().end()) == Some('\n') { | 216 | let end = if root.text().char_at(node.text_range().end()) == Some('\n') { |
217 | node.text_range().end() + TextUnit::of_char('\n') | 217 | node.text_range().end() + TextSize::of('\n') |
218 | } else { | 218 | } else { |
219 | node.text_range().end() | 219 | node.text_range().end() |
220 | }; | 220 | }; |
221 | return TextRange::from_to(start, end); | 221 | return TextRange::new(start, end); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | ws.text_range() | 224 | ws.text_range() |
@@ -270,13 +270,10 @@ fn extend_list_item(node: &SyntaxNode) -> Option<TextRange> { | |||
270 | .filter(|node| is_single_line_ws(node)) | 270 | .filter(|node| is_single_line_ws(node)) |
271 | .unwrap_or(delimiter_node); | 271 | .unwrap_or(delimiter_node); |
272 | 272 | ||
273 | return Some(TextRange::from_to(node.text_range().start(), final_node.text_range().end())); | 273 | return Some(TextRange::new(node.text_range().start(), final_node.text_range().end())); |
274 | } | 274 | } |
275 | if let Some(delimiter_node) = nearby_delimiter(delimiter, node, Direction::Prev) { | 275 | if let Some(delimiter_node) = nearby_delimiter(delimiter, node, Direction::Prev) { |
276 | return Some(TextRange::from_to( | 276 | return Some(TextRange::new(delimiter_node.text_range().start(), node.text_range().end())); |
277 | delimiter_node.text_range().start(), | ||
278 | node.text_range().end(), | ||
279 | )); | ||
280 | } | 277 | } |
281 | 278 | ||
282 | None | 279 | None |
@@ -286,10 +283,7 @@ fn extend_comments(comment: ast::Comment) -> Option<TextRange> { | |||
286 | let prev = adj_comments(&comment, Direction::Prev); | 283 | let prev = adj_comments(&comment, Direction::Prev); |
287 | let next = adj_comments(&comment, Direction::Next); | 284 | let next = adj_comments(&comment, Direction::Next); |
288 | if prev != next { | 285 | if prev != next { |
289 | Some(TextRange::from_to( | 286 | Some(TextRange::new(prev.syntax().text_range().start(), next.syntax().text_range().end())) |
290 | prev.syntax().text_range().start(), | ||
291 | next.syntax().text_range().end(), | ||
292 | )) | ||
293 | } else { | 287 | } else { |
294 | None | 288 | None |
295 | } | 289 | } |
@@ -322,7 +316,7 @@ mod tests { | |||
322 | fn do_check(before: &str, afters: &[&str]) { | 316 | fn do_check(before: &str, afters: &[&str]) { |
323 | let (cursor, before) = extract_offset(before); | 317 | let (cursor, before) = extract_offset(before); |
324 | let (analysis, file_id) = single_file(&before); | 318 | let (analysis, file_id) = single_file(&before); |
325 | let range = TextRange::offset_len(cursor, 0.into()); | 319 | let range = TextRange::empty(cursor); |
326 | let mut frange = FileRange { file_id, range }; | 320 | let mut frange = FileRange { file_id, range }; |
327 | 321 | ||
328 | for &after in afters { | 322 | for &after in afters { |
diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs index 4eeb76d14..4379005aa 100644 --- a/crates/ra_ide/src/folding_ranges.rs +++ b/crates/ra_ide/src/folding_ranges.rs | |||
@@ -141,7 +141,7 @@ fn contiguous_range_for_group_unless( | |||
141 | } | 141 | } |
142 | 142 | ||
143 | if first != &last { | 143 | if first != &last { |
144 | Some(TextRange::from_to(first.text_range().start(), last.text_range().end())) | 144 | Some(TextRange::new(first.text_range().start(), last.text_range().end())) |
145 | } else { | 145 | } else { |
146 | // The group consists of only one element, therefore it cannot be folded | 146 | // The group consists of only one element, therefore it cannot be folded |
147 | None | 147 | None |
@@ -187,10 +187,7 @@ fn contiguous_range_for_comment( | |||
187 | } | 187 | } |
188 | 188 | ||
189 | if first != last { | 189 | if first != last { |
190 | Some(TextRange::from_to( | 190 | Some(TextRange::new(first.syntax().text_range().start(), last.syntax().text_range().end())) |
191 | first.syntax().text_range().start(), | ||
192 | last.syntax().text_range().end(), | ||
193 | )) | ||
194 | } else { | 191 | } else { |
195 | // The group consists of only one element, therefore it cannot be folded | 192 | // The group consists of only one element, therefore it cannot be folded |
196 | None | 193 | None |
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 9998ca5a3..1dfca819d 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs | |||
@@ -140,7 +140,7 @@ mod tests { | |||
140 | struct Foo; | 140 | struct Foo; |
141 | enum E { X(Foo<|>) } | 141 | enum E { X(Foo<|>) } |
142 | ", | 142 | ", |
143 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | 143 | "Foo STRUCT_DEF FileId(1) 0..11 7..10", |
144 | "struct Foo;|Foo", | 144 | "struct Foo;|Foo", |
145 | ); | 145 | ); |
146 | } | 146 | } |
@@ -153,7 +153,7 @@ mod tests { | |||
153 | struct Foo; | 153 | struct Foo; |
154 | enum E { X(<|>Foo) } | 154 | enum E { X(<|>Foo) } |
155 | ", | 155 | ", |
156 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | 156 | "Foo STRUCT_DEF FileId(1) 0..11 7..10", |
157 | "struct Foo;|Foo", | 157 | "struct Foo;|Foo", |
158 | ); | 158 | ); |
159 | } | 159 | } |
@@ -174,7 +174,7 @@ mod tests { | |||
174 | //- /b.rs | 174 | //- /b.rs |
175 | struct Foo; | 175 | struct Foo; |
176 | ", | 176 | ", |
177 | "Foo STRUCT_DEF FileId(2) [0; 11) [7; 10)", | 177 | "Foo STRUCT_DEF FileId(2) 0..11 7..10", |
178 | "struct Foo;|Foo", | 178 | "struct Foo;|Foo", |
179 | ); | 179 | ); |
180 | } | 180 | } |
@@ -189,7 +189,7 @@ mod tests { | |||
189 | //- /foo.rs | 189 | //- /foo.rs |
190 | // empty | 190 | // empty |
191 | ", | 191 | ", |
192 | "foo SOURCE_FILE FileId(2) [0; 10)", | 192 | "foo SOURCE_FILE FileId(2) 0..10", |
193 | "// empty\n\n", | 193 | "// empty\n\n", |
194 | ); | 194 | ); |
195 | 195 | ||
@@ -201,7 +201,7 @@ mod tests { | |||
201 | //- /foo/mod.rs | 201 | //- /foo/mod.rs |
202 | // empty | 202 | // empty |
203 | ", | 203 | ", |
204 | "foo SOURCE_FILE FileId(2) [0; 10)", | 204 | "foo SOURCE_FILE FileId(2) 0..10", |
205 | "// empty\n\n", | 205 | "// empty\n\n", |
206 | ); | 206 | ); |
207 | } | 207 | } |
@@ -218,7 +218,7 @@ mod tests { | |||
218 | <|>foo!(); | 218 | <|>foo!(); |
219 | } | 219 | } |
220 | ", | 220 | ", |
221 | "foo MACRO_CALL FileId(1) [0; 33) [13; 16)", | 221 | "foo MACRO_CALL FileId(1) 0..33 13..16", |
222 | "macro_rules! foo { () => { () } }|foo", | 222 | "macro_rules! foo { () => { () } }|foo", |
223 | ); | 223 | ); |
224 | } | 224 | } |
@@ -238,7 +238,7 @@ mod tests { | |||
238 | #[macro_export] | 238 | #[macro_export] |
239 | macro_rules! foo { () => { () } } | 239 | macro_rules! foo { () => { () } } |
240 | ", | 240 | ", |
241 | "foo MACRO_CALL FileId(2) [0; 49) [29; 32)", | 241 | "foo MACRO_CALL FileId(2) 0..49 29..32", |
242 | "#[macro_export]\nmacro_rules! foo { () => { () } }|foo", | 242 | "#[macro_export]\nmacro_rules! foo { () => { () } }|foo", |
243 | ); | 243 | ); |
244 | } | 244 | } |
@@ -254,7 +254,7 @@ mod tests { | |||
254 | #[macro_export] | 254 | #[macro_export] |
255 | macro_rules! foo { () => { () } } | 255 | macro_rules! foo { () => { () } } |
256 | ", | 256 | ", |
257 | "foo MACRO_CALL FileId(2) [0; 49) [29; 32)", | 257 | "foo MACRO_CALL FileId(2) 0..49 29..32", |
258 | "#[macro_export]\nmacro_rules! foo { () => { () } }|foo", | 258 | "#[macro_export]\nmacro_rules! foo { () => { () } }|foo", |
259 | ); | 259 | ); |
260 | } | 260 | } |
@@ -274,7 +274,7 @@ mod tests { | |||
274 | <|>foo(); | 274 | <|>foo(); |
275 | } | 275 | } |
276 | ", | 276 | ", |
277 | "foo FN_DEF FileId(1) [64; 80) [75; 78)", | 277 | "foo FN_DEF FileId(1) 64..80 75..78", |
278 | "define_fn!(foo);|foo", | 278 | "define_fn!(foo);|foo", |
279 | ); | 279 | ); |
280 | } | 280 | } |
@@ -294,7 +294,7 @@ mod tests { | |||
294 | <|>foo(); | 294 | <|>foo(); |
295 | } | 295 | } |
296 | ", | 296 | ", |
297 | "foo FN_DEF FileId(1) [51; 64) [51; 64)", | 297 | "foo FN_DEF FileId(1) 51..64 51..64", |
298 | "define_fn!();|define_fn!();", | 298 | "define_fn!();|define_fn!();", |
299 | ); | 299 | ); |
300 | } | 300 | } |
@@ -312,7 +312,7 @@ mod tests { | |||
312 | } | 312 | } |
313 | } | 313 | } |
314 | ", | 314 | ", |
315 | "foo MACRO_CALL FileId(1) [0; 28) [13; 16)", | 315 | "foo MACRO_CALL FileId(1) 0..28 13..16", |
316 | "macro_rules! foo {() => {0}}|foo", | 316 | "macro_rules! foo {() => {0}}|foo", |
317 | ); | 317 | ); |
318 | } | 318 | } |
@@ -330,7 +330,7 @@ mod tests { | |||
330 | } | 330 | } |
331 | } | 331 | } |
332 | ", | 332 | ", |
333 | "foo MACRO_CALL FileId(1) [0; 28) [13; 16)", | 333 | "foo MACRO_CALL FileId(1) 0..28 13..16", |
334 | "macro_rules! foo {() => {0}}|foo", | 334 | "macro_rules! foo {() => {0}}|foo", |
335 | ); | 335 | ); |
336 | } | 336 | } |
@@ -350,7 +350,7 @@ mod tests { | |||
350 | foo.frobnicate<|>(); | 350 | foo.frobnicate<|>(); |
351 | } | 351 | } |
352 | ", | 352 | ", |
353 | "frobnicate FN_DEF FileId(1) [27; 51) [30; 40)", | 353 | "frobnicate FN_DEF FileId(1) 27..51 30..40", |
354 | "fn frobnicate(&self) { }|frobnicate", | 354 | "fn frobnicate(&self) { }|frobnicate", |
355 | ); | 355 | ); |
356 | } | 356 | } |
@@ -369,7 +369,7 @@ mod tests { | |||
369 | foo.spam<|>; | 369 | foo.spam<|>; |
370 | } | 370 | } |
371 | ", | 371 | ", |
372 | "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", | 372 | "spam RECORD_FIELD_DEF FileId(1) 17..26 17..21", |
373 | "spam: u32|spam", | 373 | "spam: u32|spam", |
374 | ); | 374 | ); |
375 | } | 375 | } |
@@ -390,7 +390,7 @@ mod tests { | |||
390 | } | 390 | } |
391 | } | 391 | } |
392 | ", | 392 | ", |
393 | "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", | 393 | "spam RECORD_FIELD_DEF FileId(1) 17..26 17..21", |
394 | "spam: u32|spam", | 394 | "spam: u32|spam", |
395 | ); | 395 | ); |
396 | } | 396 | } |
@@ -409,7 +409,7 @@ mod tests { | |||
409 | let Foo { spam<|>: _, } = foo | 409 | let Foo { spam<|>: _, } = foo |
410 | } | 410 | } |
411 | ", | 411 | ", |
412 | "spam RECORD_FIELD_DEF FileId(1) [17; 26) [17; 21)", | 412 | "spam RECORD_FIELD_DEF FileId(1) 17..26 17..21", |
413 | "spam: u32|spam", | 413 | "spam: u32|spam", |
414 | ); | 414 | ); |
415 | } | 415 | } |
@@ -426,7 +426,7 @@ mod tests { | |||
426 | Foo { spam<|>: m!() } | 426 | Foo { spam<|>: m!() } |
427 | } | 427 | } |
428 | ", | 428 | ", |
429 | "spam RECORD_FIELD_DEF FileId(1) [45; 54) [45; 49)", | 429 | "spam RECORD_FIELD_DEF FileId(1) 45..54 45..49", |
430 | "spam: u32|spam", | 430 | "spam: u32|spam", |
431 | ); | 431 | ); |
432 | } | 432 | } |
@@ -443,7 +443,7 @@ mod tests { | |||
443 | foo.<|>0; | 443 | foo.<|>0; |
444 | } | 444 | } |
445 | ", | 445 | ", |
446 | "TUPLE_FIELD_DEF FileId(1) [11; 14)", | 446 | "TUPLE_FIELD_DEF FileId(1) 11..14", |
447 | "u32", | 447 | "u32", |
448 | ); | 448 | ); |
449 | } | 449 | } |
@@ -462,7 +462,7 @@ mod tests { | |||
462 | Foo::frobnicate<|>(); | 462 | Foo::frobnicate<|>(); |
463 | } | 463 | } |
464 | ", | 464 | ", |
465 | "frobnicate FN_DEF FileId(1) [27; 46) [30; 40)", | 465 | "frobnicate FN_DEF FileId(1) 27..46 30..40", |
466 | "fn frobnicate() { }|frobnicate", | 466 | "fn frobnicate() { }|frobnicate", |
467 | ); | 467 | ); |
468 | } | 468 | } |
@@ -480,7 +480,7 @@ mod tests { | |||
480 | Foo::frobnicate<|>(); | 480 | Foo::frobnicate<|>(); |
481 | } | 481 | } |
482 | ", | 482 | ", |
483 | "frobnicate FN_DEF FileId(1) [16; 32) [19; 29)", | 483 | "frobnicate FN_DEF FileId(1) 16..32 19..29", |
484 | "fn frobnicate();|frobnicate", | 484 | "fn frobnicate();|frobnicate", |
485 | ); | 485 | ); |
486 | } | 486 | } |
@@ -500,7 +500,7 @@ mod tests { | |||
500 | Foo::frobnicate<|>(); | 500 | Foo::frobnicate<|>(); |
501 | } | 501 | } |
502 | ", | 502 | ", |
503 | "frobnicate FN_DEF FileId(1) [30; 46) [33; 43)", | 503 | "frobnicate FN_DEF FileId(1) 30..46 33..43", |
504 | "fn frobnicate();|frobnicate", | 504 | "fn frobnicate();|frobnicate", |
505 | ); | 505 | ); |
506 | } | 506 | } |
@@ -517,7 +517,7 @@ mod tests { | |||
517 | } | 517 | } |
518 | } | 518 | } |
519 | ", | 519 | ", |
520 | "impl IMPL_DEF FileId(1) [12; 73)", | 520 | "impl IMPL_DEF FileId(1) 12..73", |
521 | "impl Foo {...}", | 521 | "impl Foo {...}", |
522 | ); | 522 | ); |
523 | 523 | ||
@@ -531,7 +531,7 @@ mod tests { | |||
531 | } | 531 | } |
532 | } | 532 | } |
533 | ", | 533 | ", |
534 | "impl IMPL_DEF FileId(1) [12; 73)", | 534 | "impl IMPL_DEF FileId(1) 12..73", |
535 | "impl Foo {...}", | 535 | "impl Foo {...}", |
536 | ); | 536 | ); |
537 | 537 | ||
@@ -545,7 +545,7 @@ mod tests { | |||
545 | } | 545 | } |
546 | } | 546 | } |
547 | ", | 547 | ", |
548 | "impl IMPL_DEF FileId(1) [15; 75)", | 548 | "impl IMPL_DEF FileId(1) 15..75", |
549 | "impl Foo {...}", | 549 | "impl Foo {...}", |
550 | ); | 550 | ); |
551 | 551 | ||
@@ -558,7 +558,7 @@ mod tests { | |||
558 | } | 558 | } |
559 | } | 559 | } |
560 | ", | 560 | ", |
561 | "impl IMPL_DEF FileId(1) [15; 62)", | 561 | "impl IMPL_DEF FileId(1) 15..62", |
562 | "impl Foo {...}", | 562 | "impl Foo {...}", |
563 | ); | 563 | ); |
564 | } | 564 | } |
@@ -578,7 +578,7 @@ mod tests { | |||
578 | } | 578 | } |
579 | } | 579 | } |
580 | ", | 580 | ", |
581 | "impl IMPL_DEF FileId(1) [49; 115)", | 581 | "impl IMPL_DEF FileId(1) 49..115", |
582 | "impl Make for Foo {...}", | 582 | "impl Make for Foo {...}", |
583 | ); | 583 | ); |
584 | 584 | ||
@@ -595,7 +595,7 @@ mod tests { | |||
595 | } | 595 | } |
596 | } | 596 | } |
597 | ", | 597 | ", |
598 | "impl IMPL_DEF FileId(1) [49; 115)", | 598 | "impl IMPL_DEF FileId(1) 49..115", |
599 | "impl Make for Foo {...}", | 599 | "impl Make for Foo {...}", |
600 | ); | 600 | ); |
601 | } | 601 | } |
@@ -607,7 +607,7 @@ mod tests { | |||
607 | //- /lib.rs | 607 | //- /lib.rs |
608 | struct Foo<|> { value: u32 } | 608 | struct Foo<|> { value: u32 } |
609 | ", | 609 | ", |
610 | "Foo STRUCT_DEF FileId(1) [0; 25) [7; 10)", | 610 | "Foo STRUCT_DEF FileId(1) 0..25 7..10", |
611 | "struct Foo { value: u32 }|Foo", | 611 | "struct Foo { value: u32 }|Foo", |
612 | ); | 612 | ); |
613 | 613 | ||
@@ -618,7 +618,7 @@ mod tests { | |||
618 | field<|>: string, | 618 | field<|>: string, |
619 | } | 619 | } |
620 | "#, | 620 | "#, |
621 | "field RECORD_FIELD_DEF FileId(1) [17; 30) [17; 22)", | 621 | "field RECORD_FIELD_DEF FileId(1) 17..30 17..22", |
622 | "field: string|field", | 622 | "field: string|field", |
623 | ); | 623 | ); |
624 | 624 | ||
@@ -627,7 +627,7 @@ mod tests { | |||
627 | //- /lib.rs | 627 | //- /lib.rs |
628 | fn foo_test<|>() { } | 628 | fn foo_test<|>() { } |
629 | ", | 629 | ", |
630 | "foo_test FN_DEF FileId(1) [0; 17) [3; 11)", | 630 | "foo_test FN_DEF FileId(1) 0..17 3..11", |
631 | "fn foo_test() { }|foo_test", | 631 | "fn foo_test() { }|foo_test", |
632 | ); | 632 | ); |
633 | 633 | ||
@@ -638,7 +638,7 @@ mod tests { | |||
638 | Variant, | 638 | Variant, |
639 | } | 639 | } |
640 | ", | 640 | ", |
641 | "Foo ENUM_DEF FileId(1) [0; 25) [5; 8)", | 641 | "Foo ENUM_DEF FileId(1) 0..25 5..8", |
642 | "enum Foo {...}|Foo", | 642 | "enum Foo {...}|Foo", |
643 | ); | 643 | ); |
644 | 644 | ||
@@ -651,7 +651,7 @@ mod tests { | |||
651 | Variant3, | 651 | Variant3, |
652 | } | 652 | } |
653 | ", | 653 | ", |
654 | "Variant2 ENUM_VARIANT FileId(1) [29; 37) [29; 37)", | 654 | "Variant2 ENUM_VARIANT FileId(1) 29..37 29..37", |
655 | "Variant2|Variant2", | 655 | "Variant2|Variant2", |
656 | ); | 656 | ); |
657 | 657 | ||
@@ -660,7 +660,7 @@ mod tests { | |||
660 | //- /lib.rs | 660 | //- /lib.rs |
661 | static INNER<|>: &str = ""; | 661 | static INNER<|>: &str = ""; |
662 | "#, | 662 | "#, |
663 | "INNER STATIC_DEF FileId(1) [0; 24) [7; 12)", | 663 | "INNER STATIC_DEF FileId(1) 0..24 7..12", |
664 | "static INNER: &str = \"\";|INNER", | 664 | "static INNER: &str = \"\";|INNER", |
665 | ); | 665 | ); |
666 | 666 | ||
@@ -669,7 +669,7 @@ mod tests { | |||
669 | //- /lib.rs | 669 | //- /lib.rs |
670 | const INNER<|>: &str = ""; | 670 | const INNER<|>: &str = ""; |
671 | "#, | 671 | "#, |
672 | "INNER CONST_DEF FileId(1) [0; 23) [6; 11)", | 672 | "INNER CONST_DEF FileId(1) 0..23 6..11", |
673 | "const INNER: &str = \"\";|INNER", | 673 | "const INNER: &str = \"\";|INNER", |
674 | ); | 674 | ); |
675 | 675 | ||
@@ -678,7 +678,7 @@ mod tests { | |||
678 | //- /lib.rs | 678 | //- /lib.rs |
679 | type Thing<|> = Option<()>; | 679 | type Thing<|> = Option<()>; |
680 | "#, | 680 | "#, |
681 | "Thing TYPE_ALIAS_DEF FileId(1) [0; 24) [5; 10)", | 681 | "Thing TYPE_ALIAS_DEF FileId(1) 0..24 5..10", |
682 | "type Thing = Option<()>;|Thing", | 682 | "type Thing = Option<()>;|Thing", |
683 | ); | 683 | ); |
684 | 684 | ||
@@ -687,7 +687,7 @@ mod tests { | |||
687 | //- /lib.rs | 687 | //- /lib.rs |
688 | trait Foo<|> { } | 688 | trait Foo<|> { } |
689 | "#, | 689 | "#, |
690 | "Foo TRAIT_DEF FileId(1) [0; 13) [6; 9)", | 690 | "Foo TRAIT_DEF FileId(1) 0..13 6..9", |
691 | "trait Foo { }|Foo", | 691 | "trait Foo { }|Foo", |
692 | ); | 692 | ); |
693 | 693 | ||
@@ -696,7 +696,7 @@ mod tests { | |||
696 | //- /lib.rs | 696 | //- /lib.rs |
697 | mod bar<|> { } | 697 | mod bar<|> { } |
698 | "#, | 698 | "#, |
699 | "bar MODULE FileId(1) [0; 11) [4; 7)", | 699 | "bar MODULE FileId(1) 0..11 4..7", |
700 | "mod bar { }|bar", | 700 | "mod bar { }|bar", |
701 | ); | 701 | ); |
702 | } | 702 | } |
@@ -717,7 +717,7 @@ mod tests { | |||
717 | } | 717 | } |
718 | mod confuse_index { fn foo(); } | 718 | mod confuse_index { fn foo(); } |
719 | ", | 719 | ", |
720 | "foo FN_DEF FileId(1) [52; 63) [55; 58)", | 720 | "foo FN_DEF FileId(1) 52..63 55..58", |
721 | "fn foo() {}|foo", | 721 | "fn foo() {}|foo", |
722 | ); | 722 | ); |
723 | } | 723 | } |
@@ -746,7 +746,7 @@ mod tests { | |||
746 | format!(\"{}\", fo<|>o()) | 746 | format!(\"{}\", fo<|>o()) |
747 | } | 747 | } |
748 | ", | 748 | ", |
749 | "foo FN_DEF FileId(1) [398; 415) [401; 404)", | 749 | "foo FN_DEF FileId(1) 398..415 401..404", |
750 | "fn foo() -> i8 {}|foo", | 750 | "fn foo() -> i8 {}|foo", |
751 | ); | 751 | ); |
752 | } | 752 | } |
@@ -760,7 +760,7 @@ mod tests { | |||
760 | t: <|>T, | 760 | t: <|>T, |
761 | } | 761 | } |
762 | ", | 762 | ", |
763 | "T TYPE_PARAM FileId(1) [11; 12)", | 763 | "T TYPE_PARAM FileId(1) 11..12", |
764 | "T", | 764 | "T", |
765 | ); | 765 | ); |
766 | } | 766 | } |
@@ -782,7 +782,7 @@ mod tests { | |||
782 | }); | 782 | }); |
783 | } | 783 | } |
784 | ", | 784 | ", |
785 | "x BIND_PAT FileId(1) [69; 70)", | 785 | "x BIND_PAT FileId(1) 69..70", |
786 | "x", | 786 | "x", |
787 | ); | 787 | ); |
788 | 788 | ||
@@ -801,7 +801,7 @@ mod tests { | |||
801 | }); | 801 | }); |
802 | } | 802 | } |
803 | ", | 803 | ", |
804 | "y BIND_PAT FileId(1) [98; 99)", | 804 | "y BIND_PAT FileId(1) 98..99", |
805 | "y", | 805 | "y", |
806 | ); | 806 | ); |
807 | } | 807 | } |
@@ -818,7 +818,7 @@ mod tests { | |||
818 | } | 818 | } |
819 | } | 819 | } |
820 | ", | 820 | ", |
821 | "x BIND_PAT FileId(1) [39; 40)", | 821 | "x BIND_PAT FileId(1) 39..40", |
822 | "x", | 822 | "x", |
823 | ); | 823 | ); |
824 | } | 824 | } |
@@ -833,7 +833,7 @@ mod tests { | |||
833 | <|>foo!(); | 833 | <|>foo!(); |
834 | } | 834 | } |
835 | ", | 835 | ", |
836 | "foo MACRO_CALL FileId(1) [15; 48) [28; 31)", | 836 | "foo MACRO_CALL FileId(1) 15..48 28..31", |
837 | "macro_rules! foo { () => { () } }|foo", | 837 | "macro_rules! foo { () => { () } }|foo", |
838 | ); | 838 | ); |
839 | } | 839 | } |
@@ -850,7 +850,7 @@ mod tests { | |||
850 | Foo { x<|> }; | 850 | Foo { x<|> }; |
851 | } | 851 | } |
852 | ", | 852 | ", |
853 | "x BIND_PAT FileId(1) [42; 43)", | 853 | "x BIND_PAT FileId(1) 42..43", |
854 | "x", | 854 | "x", |
855 | ) | 855 | ) |
856 | } | 856 | } |
diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index bd2688df1..a84637489 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs | |||
@@ -68,7 +68,7 @@ mod tests { | |||
68 | f<|> | 68 | f<|> |
69 | } | 69 | } |
70 | ", | 70 | ", |
71 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | 71 | "Foo STRUCT_DEF FileId(1) 0..11 7..10", |
72 | ); | 72 | ); |
73 | } | 73 | } |
74 | 74 | ||
@@ -83,7 +83,7 @@ mod tests { | |||
83 | f<|> | 83 | f<|> |
84 | } | 84 | } |
85 | ", | 85 | ", |
86 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | 86 | "Foo STRUCT_DEF FileId(1) 0..11 7..10", |
87 | ); | 87 | ); |
88 | } | 88 | } |
89 | 89 | ||
@@ -102,7 +102,7 @@ mod tests { | |||
102 | } | 102 | } |
103 | } | 103 | } |
104 | ", | 104 | ", |
105 | "Foo STRUCT_DEF FileId(1) [52; 65) [59; 62)", | 105 | "Foo STRUCT_DEF FileId(1) 52..65 59..62", |
106 | ); | 106 | ); |
107 | } | 107 | } |
108 | 108 | ||
@@ -114,7 +114,7 @@ mod tests { | |||
114 | struct Foo; | 114 | struct Foo; |
115 | fn foo(<|>f: Foo) {} | 115 | fn foo(<|>f: Foo) {} |
116 | ", | 116 | ", |
117 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | 117 | "Foo STRUCT_DEF FileId(1) 0..11 7..10", |
118 | ); | 118 | ); |
119 | } | 119 | } |
120 | 120 | ||
@@ -130,7 +130,7 @@ mod tests { | |||
130 | bar.<|>0; | 130 | bar.<|>0; |
131 | } | 131 | } |
132 | ", | 132 | ", |
133 | "Foo STRUCT_DEF FileId(1) [0; 11) [7; 10)", | 133 | "Foo STRUCT_DEF FileId(1) 0..11 7..10", |
134 | ); | 134 | ); |
135 | } | 135 | } |
136 | } | 136 | } |
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a31187994..58c799eca 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -76,7 +76,7 @@ fn hover_text( | |||
76 | 76 | ||
77 | fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String> { | 77 | fn definition_owner_name(db: &RootDatabase, def: &Definition) -> Option<String> { |
78 | match def { | 78 | match def { |
79 | Definition::StructField(f) => Some(f.parent_def(db).name(db)), | 79 | Definition::Field(f) => Some(f.parent_def(db).name(db)), |
80 | Definition::Local(l) => l.parent(db).name(db), | 80 | Definition::Local(l) => l.parent(db).name(db), |
81 | Definition::ModuleDef(md) => match md { | 81 | Definition::ModuleDef(md) => match md { |
82 | ModuleDef::Function(f) => match f.as_assoc_item(db)?.container(db) { | 82 | ModuleDef::Function(f) => match f.as_assoc_item(db)?.container(db) { |
@@ -116,7 +116,7 @@ fn hover_text_from_name_kind(db: &RootDatabase, def: Definition) -> Option<Strin | |||
116 | let src = it.source(db); | 116 | let src = it.source(db); |
117 | hover_text(src.value.doc_comment_text(), Some(macro_label(&src.value)), mod_path) | 117 | hover_text(src.value.doc_comment_text(), Some(macro_label(&src.value)), mod_path) |
118 | } | 118 | } |
119 | Definition::StructField(it) => { | 119 | Definition::Field(it) => { |
120 | let src = it.source(db); | 120 | let src = it.source(db); |
121 | match src.value { | 121 | match src.value { |
122 | FieldSource::Named(it) => { | 122 | FieldSource::Named(it) => { |
@@ -275,7 +275,7 @@ mod tests { | |||
275 | ", | 275 | ", |
276 | ); | 276 | ); |
277 | let hover = analysis.hover(position).unwrap().unwrap(); | 277 | let hover = analysis.hover(position).unwrap().unwrap(); |
278 | assert_eq!(hover.range, TextRange::from_to(95.into(), 100.into())); | 278 | assert_eq!(hover.range, TextRange::new(95.into(), 100.into())); |
279 | assert_eq!(trim_markup_opt(hover.info.first()), Some("u32")); | 279 | assert_eq!(trim_markup_opt(hover.info.first()), Some("u32")); |
280 | } | 280 | } |
281 | 281 | ||
diff --git a/crates/ra_ide/src/impls.rs b/crates/ra_ide/src/impls.rs index 68529c8a5..ea2225f70 100644 --- a/crates/ra_ide/src/impls.rs +++ b/crates/ra_ide/src/impls.rs | |||
@@ -86,7 +86,7 @@ mod tests { | |||
86 | struct Foo<|>; | 86 | struct Foo<|>; |
87 | impl Foo {} | 87 | impl Foo {} |
88 | ", | 88 | ", |
89 | &["impl IMPL_DEF FileId(1) [12; 23)"], | 89 | &["impl IMPL_DEF FileId(1) 12..23"], |
90 | ); | 90 | ); |
91 | } | 91 | } |
92 | 92 | ||
@@ -99,7 +99,7 @@ mod tests { | |||
99 | impl Foo {} | 99 | impl Foo {} |
100 | impl Foo {} | 100 | impl Foo {} |
101 | ", | 101 | ", |
102 | &["impl IMPL_DEF FileId(1) [12; 23)", "impl IMPL_DEF FileId(1) [24; 35)"], | 102 | &["impl IMPL_DEF FileId(1) 12..23", "impl IMPL_DEF FileId(1) 24..35"], |
103 | ); | 103 | ); |
104 | } | 104 | } |
105 | 105 | ||
@@ -116,7 +116,7 @@ mod tests { | |||
116 | impl super::Foo {} | 116 | impl super::Foo {} |
117 | } | 117 | } |
118 | ", | 118 | ", |
119 | &["impl IMPL_DEF FileId(1) [24; 42)", "impl IMPL_DEF FileId(1) [57; 75)"], | 119 | &["impl IMPL_DEF FileId(1) 24..42", "impl IMPL_DEF FileId(1) 57..75"], |
120 | ); | 120 | ); |
121 | } | 121 | } |
122 | 122 | ||
@@ -133,7 +133,7 @@ mod tests { | |||
133 | //- /b.rs | 133 | //- /b.rs |
134 | impl crate::Foo {} | 134 | impl crate::Foo {} |
135 | ", | 135 | ", |
136 | &["impl IMPL_DEF FileId(2) [0; 18)", "impl IMPL_DEF FileId(3) [0; 18)"], | 136 | &["impl IMPL_DEF FileId(2) 0..18", "impl IMPL_DEF FileId(3) 0..18"], |
137 | ); | 137 | ); |
138 | } | 138 | } |
139 | 139 | ||
@@ -146,7 +146,7 @@ mod tests { | |||
146 | struct Foo; | 146 | struct Foo; |
147 | impl T for Foo {} | 147 | impl T for Foo {} |
148 | ", | 148 | ", |
149 | &["impl IMPL_DEF FileId(1) [23; 40)"], | 149 | &["impl IMPL_DEF FileId(1) 23..40"], |
150 | ); | 150 | ); |
151 | } | 151 | } |
152 | 152 | ||
@@ -164,7 +164,7 @@ mod tests { | |||
164 | //- /b.rs | 164 | //- /b.rs |
165 | impl crate::T for crate::Foo {} | 165 | impl crate::T for crate::Foo {} |
166 | ", | 166 | ", |
167 | &["impl IMPL_DEF FileId(2) [0; 31)", "impl IMPL_DEF FileId(3) [0; 31)"], | 167 | &["impl IMPL_DEF FileId(2) 0..31", "impl IMPL_DEF FileId(3) 0..31"], |
168 | ); | 168 | ); |
169 | } | 169 | } |
170 | 170 | ||
@@ -180,9 +180,9 @@ mod tests { | |||
180 | impl T for &Foo {} | 180 | impl T for &Foo {} |
181 | ", | 181 | ", |
182 | &[ | 182 | &[ |
183 | "impl IMPL_DEF FileId(1) [23; 34)", | 183 | "impl IMPL_DEF FileId(1) 23..34", |
184 | "impl IMPL_DEF FileId(1) [35; 52)", | 184 | "impl IMPL_DEF FileId(1) 35..52", |
185 | "impl IMPL_DEF FileId(1) [53; 71)", | 185 | "impl IMPL_DEF FileId(1) 53..71", |
186 | ], | 186 | ], |
187 | ); | 187 | ); |
188 | } | 188 | } |
@@ -195,7 +195,7 @@ mod tests { | |||
195 | #[derive(Copy)] | 195 | #[derive(Copy)] |
196 | struct Foo<|>; | 196 | struct Foo<|>; |
197 | ", | 197 | ", |
198 | &["impl IMPL_DEF FileId(1) [0; 15)"], | 198 | &["impl IMPL_DEF FileId(1) 0..15"], |
199 | ); | 199 | ); |
200 | } | 200 | } |
201 | } | 201 | } |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 0774fa0a1..98483df32 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -322,12 +322,12 @@ mod tests { | |||
322 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: true, type_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###" | 322 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: true, type_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###" |
323 | [ | 323 | [ |
324 | InlayHint { | 324 | InlayHint { |
325 | range: [106; 107), | 325 | range: 106..107, |
326 | kind: ParameterHint, | 326 | kind: ParameterHint, |
327 | label: "a", | 327 | label: "a", |
328 | }, | 328 | }, |
329 | InlayHint { | 329 | InlayHint { |
330 | range: [109; 110), | 330 | range: 109..110, |
331 | kind: ParameterHint, | 331 | kind: ParameterHint, |
332 | label: "b", | 332 | label: "b", |
333 | }, | 333 | }, |
@@ -358,7 +358,7 @@ mod tests { | |||
358 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ type_hints: true, parameter_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###" | 358 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ type_hints: true, parameter_hints: false, chaining_hints: false, max_length: None}).unwrap(), @r###" |
359 | [ | 359 | [ |
360 | InlayHint { | 360 | InlayHint { |
361 | range: [97; 99), | 361 | range: 97..99, |
362 | kind: TypeHint, | 362 | kind: TypeHint, |
363 | label: "i32", | 363 | label: "i32", |
364 | }, | 364 | }, |
@@ -382,12 +382,12 @@ fn main() { | |||
382 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" | 382 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" |
383 | [ | 383 | [ |
384 | InlayHint { | 384 | InlayHint { |
385 | range: [69; 71), | 385 | range: 69..71, |
386 | kind: TypeHint, | 386 | kind: TypeHint, |
387 | label: "Test<i32>", | 387 | label: "Test<i32>", |
388 | }, | 388 | }, |
389 | InlayHint { | 389 | InlayHint { |
390 | range: [105; 111), | 390 | range: 105..111, |
391 | kind: TypeHint, | 391 | kind: TypeHint, |
392 | label: "&Test<i32>", | 392 | label: "&Test<i32>", |
393 | }, | 393 | }, |
@@ -439,57 +439,57 @@ fn main() { | |||
439 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" | 439 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" |
440 | [ | 440 | [ |
441 | InlayHint { | 441 | InlayHint { |
442 | range: [193; 197), | 442 | range: 193..197, |
443 | kind: TypeHint, | 443 | kind: TypeHint, |
444 | label: "i32", | 444 | label: "i32", |
445 | }, | 445 | }, |
446 | InlayHint { | 446 | InlayHint { |
447 | range: [236; 244), | 447 | range: 236..244, |
448 | kind: TypeHint, | 448 | kind: TypeHint, |
449 | label: "i32", | 449 | label: "i32", |
450 | }, | 450 | }, |
451 | InlayHint { | 451 | InlayHint { |
452 | range: [275; 279), | 452 | range: 275..279, |
453 | kind: TypeHint, | 453 | kind: TypeHint, |
454 | label: "&str", | 454 | label: "&str", |
455 | }, | 455 | }, |
456 | InlayHint { | 456 | InlayHint { |
457 | range: [539; 543), | 457 | range: 539..543, |
458 | kind: TypeHint, | 458 | kind: TypeHint, |
459 | label: "(i32, char)", | 459 | label: "(i32, char)", |
460 | }, | 460 | }, |
461 | InlayHint { | 461 | InlayHint { |
462 | range: [566; 567), | 462 | range: 566..567, |
463 | kind: TypeHint, | 463 | kind: TypeHint, |
464 | label: "i32", | 464 | label: "i32", |
465 | }, | 465 | }, |
466 | InlayHint { | 466 | InlayHint { |
467 | range: [570; 571), | 467 | range: 570..571, |
468 | kind: TypeHint, | 468 | kind: TypeHint, |
469 | label: "i32", | 469 | label: "i32", |
470 | }, | 470 | }, |
471 | InlayHint { | 471 | InlayHint { |
472 | range: [573; 574), | 472 | range: 573..574, |
473 | kind: TypeHint, | 473 | kind: TypeHint, |
474 | label: "i32", | 474 | label: "i32", |
475 | }, | 475 | }, |
476 | InlayHint { | 476 | InlayHint { |
477 | range: [577; 578), | 477 | range: 577..578, |
478 | kind: TypeHint, | 478 | kind: TypeHint, |
479 | label: "f64", | 479 | label: "f64", |
480 | }, | 480 | }, |
481 | InlayHint { | 481 | InlayHint { |
482 | range: [580; 581), | 482 | range: 580..581, |
483 | kind: TypeHint, | 483 | kind: TypeHint, |
484 | label: "f64", | 484 | label: "f64", |
485 | }, | 485 | }, |
486 | InlayHint { | 486 | InlayHint { |
487 | range: [584; 585), | 487 | range: 584..585, |
488 | kind: TypeHint, | 488 | kind: TypeHint, |
489 | label: "i32", | 489 | label: "i32", |
490 | }, | 490 | }, |
491 | InlayHint { | 491 | InlayHint { |
492 | range: [627; 628), | 492 | range: 627..628, |
493 | kind: TypeHint, | 493 | kind: TypeHint, |
494 | label: "i32", | 494 | label: "i32", |
495 | }, | 495 | }, |
@@ -519,47 +519,47 @@ fn main() { | |||
519 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" | 519 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" |
520 | [ | 520 | [ |
521 | InlayHint { | 521 | InlayHint { |
522 | range: [21; 30), | 522 | range: 21..30, |
523 | kind: TypeHint, | 523 | kind: TypeHint, |
524 | label: "i32", | 524 | label: "i32", |
525 | }, | 525 | }, |
526 | InlayHint { | 526 | InlayHint { |
527 | range: [57; 66), | 527 | range: 57..66, |
528 | kind: TypeHint, | 528 | kind: TypeHint, |
529 | label: "i32", | 529 | label: "i32", |
530 | }, | 530 | }, |
531 | InlayHint { | 531 | InlayHint { |
532 | range: [115; 123), | 532 | range: 115..123, |
533 | kind: TypeHint, | 533 | kind: TypeHint, |
534 | label: "|…| -> i32", | 534 | label: "|…| -> i32", |
535 | }, | 535 | }, |
536 | InlayHint { | 536 | InlayHint { |
537 | range: [127; 128), | 537 | range: 127..128, |
538 | kind: TypeHint, | 538 | kind: TypeHint, |
539 | label: "i32", | 539 | label: "i32", |
540 | }, | 540 | }, |
541 | InlayHint { | 541 | InlayHint { |
542 | range: [130; 131), | 542 | range: 130..131, |
543 | kind: TypeHint, | 543 | kind: TypeHint, |
544 | label: "i32", | 544 | label: "i32", |
545 | }, | 545 | }, |
546 | InlayHint { | 546 | InlayHint { |
547 | range: [133; 134), | 547 | range: 133..134, |
548 | kind: TypeHint, | 548 | kind: TypeHint, |
549 | label: "i32", | 549 | label: "i32", |
550 | }, | 550 | }, |
551 | InlayHint { | 551 | InlayHint { |
552 | range: [136; 137), | 552 | range: 136..137, |
553 | kind: TypeHint, | 553 | kind: TypeHint, |
554 | label: "i32", | 554 | label: "i32", |
555 | }, | 555 | }, |
556 | InlayHint { | 556 | InlayHint { |
557 | range: [201; 213), | 557 | range: 201..213, |
558 | kind: TypeHint, | 558 | kind: TypeHint, |
559 | label: "&|…| -> i32", | 559 | label: "&|…| -> i32", |
560 | }, | 560 | }, |
561 | InlayHint { | 561 | InlayHint { |
562 | range: [236; 245), | 562 | range: 236..245, |
563 | kind: TypeHint, | 563 | kind: TypeHint, |
564 | label: "|| -> i32", | 564 | label: "|| -> i32", |
565 | }, | 565 | }, |
@@ -583,12 +583,12 @@ fn main() { | |||
583 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" | 583 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" |
584 | [ | 584 | [ |
585 | InlayHint { | 585 | InlayHint { |
586 | range: [21; 30), | 586 | range: 21..30, |
587 | kind: TypeHint, | 587 | kind: TypeHint, |
588 | label: "i32", | 588 | label: "i32", |
589 | }, | 589 | }, |
590 | InlayHint { | 590 | InlayHint { |
591 | range: [44; 53), | 591 | range: 44..53, |
592 | kind: TypeHint, | 592 | kind: TypeHint, |
593 | label: "i32", | 593 | label: "i32", |
594 | }, | 594 | }, |
@@ -633,57 +633,57 @@ fn main() { | |||
633 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" | 633 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" |
634 | [ | 634 | [ |
635 | InlayHint { | 635 | InlayHint { |
636 | range: [188; 192), | 636 | range: 188..192, |
637 | kind: TypeHint, | 637 | kind: TypeHint, |
638 | label: "CustomOption<Test>", | 638 | label: "CustomOption<Test>", |
639 | }, | 639 | }, |
640 | InlayHint { | 640 | InlayHint { |
641 | range: [267; 271), | 641 | range: 267..271, |
642 | kind: TypeHint, | 642 | kind: TypeHint, |
643 | label: "&CustomOption<Test>", | 643 | label: "&CustomOption<Test>", |
644 | }, | 644 | }, |
645 | InlayHint { | 645 | InlayHint { |
646 | range: [300; 304), | 646 | range: 300..304, |
647 | kind: TypeHint, | 647 | kind: TypeHint, |
648 | label: "&Test", | 648 | label: "&Test", |
649 | }, | 649 | }, |
650 | InlayHint { | 650 | InlayHint { |
651 | range: [341; 342), | 651 | range: 341..342, |
652 | kind: TypeHint, | 652 | kind: TypeHint, |
653 | label: "&CustomOption<u32>", | 653 | label: "&CustomOption<u32>", |
654 | }, | 654 | }, |
655 | InlayHint { | 655 | InlayHint { |
656 | range: [344; 345), | 656 | range: 344..345, |
657 | kind: TypeHint, | 657 | kind: TypeHint, |
658 | label: "&u8", | 658 | label: "&u8", |
659 | }, | 659 | }, |
660 | InlayHint { | 660 | InlayHint { |
661 | range: [387; 388), | 661 | range: 387..388, |
662 | kind: TypeHint, | 662 | kind: TypeHint, |
663 | label: "&CustomOption<u32>", | 663 | label: "&CustomOption<u32>", |
664 | }, | 664 | }, |
665 | InlayHint { | 665 | InlayHint { |
666 | range: [393; 394), | 666 | range: 393..394, |
667 | kind: TypeHint, | 667 | kind: TypeHint, |
668 | label: "&u8", | 668 | label: "&u8", |
669 | }, | 669 | }, |
670 | InlayHint { | 670 | InlayHint { |
671 | range: [441; 442), | 671 | range: 441..442, |
672 | kind: TypeHint, | 672 | kind: TypeHint, |
673 | label: "&u32", | 673 | label: "&u32", |
674 | }, | 674 | }, |
675 | InlayHint { | 675 | InlayHint { |
676 | range: [448; 449), | 676 | range: 448..449, |
677 | kind: TypeHint, | 677 | kind: TypeHint, |
678 | label: "&u8", | 678 | label: "&u8", |
679 | }, | 679 | }, |
680 | InlayHint { | 680 | InlayHint { |
681 | range: [500; 501), | 681 | range: 500..501, |
682 | kind: TypeHint, | 682 | kind: TypeHint, |
683 | label: "&u8", | 683 | label: "&u8", |
684 | }, | 684 | }, |
685 | InlayHint { | 685 | InlayHint { |
686 | range: [543; 544), | 686 | range: 543..544, |
687 | kind: TypeHint, | 687 | kind: TypeHint, |
688 | label: "&u8", | 688 | label: "&u8", |
689 | }, | 689 | }, |
@@ -728,57 +728,57 @@ fn main() { | |||
728 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" | 728 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" |
729 | [ | 729 | [ |
730 | InlayHint { | 730 | InlayHint { |
731 | range: [188; 192), | 731 | range: 188..192, |
732 | kind: TypeHint, | 732 | kind: TypeHint, |
733 | label: "CustomOption<Test>", | 733 | label: "CustomOption<Test>", |
734 | }, | 734 | }, |
735 | InlayHint { | 735 | InlayHint { |
736 | range: [273; 277), | 736 | range: 273..277, |
737 | kind: TypeHint, | 737 | kind: TypeHint, |
738 | label: "&CustomOption<Test>", | 738 | label: "&CustomOption<Test>", |
739 | }, | 739 | }, |
740 | InlayHint { | 740 | InlayHint { |
741 | range: [309; 313), | 741 | range: 309..313, |
742 | kind: TypeHint, | 742 | kind: TypeHint, |
743 | label: "&Test", | 743 | label: "&Test", |
744 | }, | 744 | }, |
745 | InlayHint { | 745 | InlayHint { |
746 | range: [353; 354), | 746 | range: 353..354, |
747 | kind: TypeHint, | 747 | kind: TypeHint, |
748 | label: "&CustomOption<u32>", | 748 | label: "&CustomOption<u32>", |
749 | }, | 749 | }, |
750 | InlayHint { | 750 | InlayHint { |
751 | range: [356; 357), | 751 | range: 356..357, |
752 | kind: TypeHint, | 752 | kind: TypeHint, |
753 | label: "&u8", | 753 | label: "&u8", |
754 | }, | 754 | }, |
755 | InlayHint { | 755 | InlayHint { |
756 | range: [402; 403), | 756 | range: 402..403, |
757 | kind: TypeHint, | 757 | kind: TypeHint, |
758 | label: "&CustomOption<u32>", | 758 | label: "&CustomOption<u32>", |
759 | }, | 759 | }, |
760 | InlayHint { | 760 | InlayHint { |
761 | range: [408; 409), | 761 | range: 408..409, |
762 | kind: TypeHint, | 762 | kind: TypeHint, |
763 | label: "&u8", | 763 | label: "&u8", |
764 | }, | 764 | }, |
765 | InlayHint { | 765 | InlayHint { |
766 | range: [459; 460), | 766 | range: 459..460, |
767 | kind: TypeHint, | 767 | kind: TypeHint, |
768 | label: "&u32", | 768 | label: "&u32", |
769 | }, | 769 | }, |
770 | InlayHint { | 770 | InlayHint { |
771 | range: [466; 467), | 771 | range: 466..467, |
772 | kind: TypeHint, | 772 | kind: TypeHint, |
773 | label: "&u8", | 773 | label: "&u8", |
774 | }, | 774 | }, |
775 | InlayHint { | 775 | InlayHint { |
776 | range: [521; 522), | 776 | range: 521..522, |
777 | kind: TypeHint, | 777 | kind: TypeHint, |
778 | label: "&u8", | 778 | label: "&u8", |
779 | }, | 779 | }, |
780 | InlayHint { | 780 | InlayHint { |
781 | range: [567; 568), | 781 | range: 567..568, |
782 | kind: TypeHint, | 782 | kind: TypeHint, |
783 | label: "&u8", | 783 | label: "&u8", |
784 | }, | 784 | }, |
@@ -823,52 +823,52 @@ fn main() { | |||
823 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" | 823 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" |
824 | [ | 824 | [ |
825 | InlayHint { | 825 | InlayHint { |
826 | range: [252; 256), | 826 | range: 252..256, |
827 | kind: TypeHint, | 827 | kind: TypeHint, |
828 | label: "CustomOption<Test>", | 828 | label: "CustomOption<Test>", |
829 | }, | 829 | }, |
830 | InlayHint { | 830 | InlayHint { |
831 | range: [277; 281), | 831 | range: 277..281, |
832 | kind: TypeHint, | 832 | kind: TypeHint, |
833 | label: "Test", | 833 | label: "Test", |
834 | }, | 834 | }, |
835 | InlayHint { | 835 | InlayHint { |
836 | range: [310; 311), | 836 | range: 310..311, |
837 | kind: TypeHint, | 837 | kind: TypeHint, |
838 | label: "CustomOption<u32>", | 838 | label: "CustomOption<u32>", |
839 | }, | 839 | }, |
840 | InlayHint { | 840 | InlayHint { |
841 | range: [313; 314), | 841 | range: 313..314, |
842 | kind: TypeHint, | 842 | kind: TypeHint, |
843 | label: "u8", | 843 | label: "u8", |
844 | }, | 844 | }, |
845 | InlayHint { | 845 | InlayHint { |
846 | range: [348; 349), | 846 | range: 348..349, |
847 | kind: TypeHint, | 847 | kind: TypeHint, |
848 | label: "CustomOption<u32>", | 848 | label: "CustomOption<u32>", |
849 | }, | 849 | }, |
850 | InlayHint { | 850 | InlayHint { |
851 | range: [354; 355), | 851 | range: 354..355, |
852 | kind: TypeHint, | 852 | kind: TypeHint, |
853 | label: "u8", | 853 | label: "u8", |
854 | }, | 854 | }, |
855 | InlayHint { | 855 | InlayHint { |
856 | range: [394; 395), | 856 | range: 394..395, |
857 | kind: TypeHint, | 857 | kind: TypeHint, |
858 | label: "u32", | 858 | label: "u32", |
859 | }, | 859 | }, |
860 | InlayHint { | 860 | InlayHint { |
861 | range: [401; 402), | 861 | range: 401..402, |
862 | kind: TypeHint, | 862 | kind: TypeHint, |
863 | label: "u8", | 863 | label: "u8", |
864 | }, | 864 | }, |
865 | InlayHint { | 865 | InlayHint { |
866 | range: [445; 446), | 866 | range: 445..446, |
867 | kind: TypeHint, | 867 | kind: TypeHint, |
868 | label: "u8", | 868 | label: "u8", |
869 | }, | 869 | }, |
870 | InlayHint { | 870 | InlayHint { |
871 | range: [480; 481), | 871 | range: 480..481, |
872 | kind: TypeHint, | 872 | kind: TypeHint, |
873 | label: "u8", | 873 | label: "u8", |
874 | }, | 874 | }, |
@@ -895,17 +895,17 @@ fn main() { | |||
895 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###" | 895 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig { max_length: Some(8), ..Default::default() }).unwrap(), @r###" |
896 | [ | 896 | [ |
897 | InlayHint { | 897 | InlayHint { |
898 | range: [74; 75), | 898 | range: 74..75, |
899 | kind: TypeHint, | 899 | kind: TypeHint, |
900 | label: "Smol<u32>", | 900 | label: "Smol<u32>", |
901 | }, | 901 | }, |
902 | InlayHint { | 902 | InlayHint { |
903 | range: [98; 99), | 903 | range: 98..99, |
904 | kind: TypeHint, | 904 | kind: TypeHint, |
905 | label: "VeryLongOuterName<…>", | 905 | label: "VeryLongOuterName<…>", |
906 | }, | 906 | }, |
907 | InlayHint { | 907 | InlayHint { |
908 | range: [137; 138), | 908 | range: 137..138, |
909 | kind: TypeHint, | 909 | kind: TypeHint, |
910 | label: "Smol<Smol<…>>", | 910 | label: "Smol<Smol<…>>", |
911 | }, | 911 | }, |
@@ -983,77 +983,77 @@ fn main() { | |||
983 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" | 983 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig::default()).unwrap(), @r###" |
984 | [ | 984 | [ |
985 | InlayHint { | 985 | InlayHint { |
986 | range: [798; 809), | 986 | range: 798..809, |
987 | kind: TypeHint, | 987 | kind: TypeHint, |
988 | label: "i32", | 988 | label: "i32", |
989 | }, | 989 | }, |
990 | InlayHint { | 990 | InlayHint { |
991 | range: [842; 843), | 991 | range: 842..843, |
992 | kind: ParameterHint, | 992 | kind: ParameterHint, |
993 | label: "foo", | 993 | label: "foo", |
994 | }, | 994 | }, |
995 | InlayHint { | 995 | InlayHint { |
996 | range: [845; 846), | 996 | range: 845..846, |
997 | kind: ParameterHint, | 997 | kind: ParameterHint, |
998 | label: "bar", | 998 | label: "bar", |
999 | }, | 999 | }, |
1000 | InlayHint { | 1000 | InlayHint { |
1001 | range: [848; 855), | 1001 | range: 848..855, |
1002 | kind: ParameterHint, | 1002 | kind: ParameterHint, |
1003 | label: "msg", | 1003 | label: "msg", |
1004 | }, | 1004 | }, |
1005 | InlayHint { | 1005 | InlayHint { |
1006 | range: [860; 871), | 1006 | range: 860..871, |
1007 | kind: ParameterHint, | 1007 | kind: ParameterHint, |
1008 | label: "last", | 1008 | label: "last", |
1009 | }, | 1009 | }, |
1010 | InlayHint { | 1010 | InlayHint { |
1011 | range: [914; 917), | 1011 | range: 914..917, |
1012 | kind: ParameterHint, | 1012 | kind: ParameterHint, |
1013 | label: "param", | 1013 | label: "param", |
1014 | }, | 1014 | }, |
1015 | InlayHint { | 1015 | InlayHint { |
1016 | range: [937; 939), | 1016 | range: 937..939, |
1017 | kind: ParameterHint, | 1017 | kind: ParameterHint, |
1018 | label: "&self", | 1018 | label: "&self", |
1019 | }, | 1019 | }, |
1020 | InlayHint { | 1020 | InlayHint { |
1021 | range: [941; 945), | 1021 | range: 941..945, |
1022 | kind: ParameterHint, | 1022 | kind: ParameterHint, |
1023 | label: "param", | 1023 | label: "param", |
1024 | }, | 1024 | }, |
1025 | InlayHint { | 1025 | InlayHint { |
1026 | range: [980; 989), | 1026 | range: 980..989, |
1027 | kind: ParameterHint, | 1027 | kind: ParameterHint, |
1028 | label: "file_id", | 1028 | label: "file_id", |
1029 | }, | 1029 | }, |
1030 | InlayHint { | 1030 | InlayHint { |
1031 | range: [999; 1012), | 1031 | range: 999..1012, |
1032 | kind: ParameterHint, | 1032 | kind: ParameterHint, |
1033 | label: "name", | 1033 | label: "name", |
1034 | }, | 1034 | }, |
1035 | InlayHint { | 1035 | InlayHint { |
1036 | range: [1022; 1026), | 1036 | range: 1022..1026, |
1037 | kind: ParameterHint, | 1037 | kind: ParameterHint, |
1038 | label: "focus_range", | 1038 | label: "focus_range", |
1039 | }, | 1039 | }, |
1040 | InlayHint { | 1040 | InlayHint { |
1041 | range: [1036; 1048), | 1041 | range: 1036..1048, |
1042 | kind: ParameterHint, | 1042 | kind: ParameterHint, |
1043 | label: "full_range", | 1043 | label: "full_range", |
1044 | }, | 1044 | }, |
1045 | InlayHint { | 1045 | InlayHint { |
1046 | range: [1058; 1071), | 1046 | range: 1058..1071, |
1047 | kind: ParameterHint, | 1047 | kind: ParameterHint, |
1048 | label: "kind", | 1048 | label: "kind", |
1049 | }, | 1049 | }, |
1050 | InlayHint { | 1050 | InlayHint { |
1051 | range: [1081; 1085), | 1051 | range: 1081..1085, |
1052 | kind: ParameterHint, | 1052 | kind: ParameterHint, |
1053 | label: "docs", | 1053 | label: "docs", |
1054 | }, | 1054 | }, |
1055 | InlayHint { | 1055 | InlayHint { |
1056 | range: [1095; 1099), | 1056 | range: 1095..1099, |
1057 | kind: ParameterHint, | 1057 | kind: ParameterHint, |
1058 | label: "description", | 1058 | label: "description", |
1059 | }, | 1059 | }, |
@@ -1184,12 +1184,12 @@ fn main() { | |||
1184 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" | 1184 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" |
1185 | [ | 1185 | [ |
1186 | InlayHint { | 1186 | InlayHint { |
1187 | range: [232; 269), | 1187 | range: 232..269, |
1188 | kind: ChainingHint, | 1188 | kind: ChainingHint, |
1189 | label: "B", | 1189 | label: "B", |
1190 | }, | 1190 | }, |
1191 | InlayHint { | 1191 | InlayHint { |
1192 | range: [232; 239), | 1192 | range: 232..239, |
1193 | kind: ChainingHint, | 1193 | kind: ChainingHint, |
1194 | label: "A", | 1194 | label: "A", |
1195 | }, | 1195 | }, |
@@ -1238,12 +1238,12 @@ fn main() { | |||
1238 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" | 1238 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" |
1239 | [ | 1239 | [ |
1240 | InlayHint { | 1240 | InlayHint { |
1241 | range: [252; 323), | 1241 | range: 252..323, |
1242 | kind: ChainingHint, | 1242 | kind: ChainingHint, |
1243 | label: "C", | 1243 | label: "C", |
1244 | }, | 1244 | }, |
1245 | InlayHint { | 1245 | InlayHint { |
1246 | range: [252; 300), | 1246 | range: 252..300, |
1247 | kind: ChainingHint, | 1247 | kind: ChainingHint, |
1248 | label: "B", | 1248 | label: "B", |
1249 | }, | 1249 | }, |
@@ -1276,12 +1276,12 @@ fn main() { | |||
1276 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" | 1276 | assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsConfig{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" |
1277 | [ | 1277 | [ |
1278 | InlayHint { | 1278 | InlayHint { |
1279 | range: [403; 452), | 1279 | range: 403..452, |
1280 | kind: ChainingHint, | 1280 | kind: ChainingHint, |
1281 | label: "B<X<i32, bool>>", | 1281 | label: "B<X<i32, bool>>", |
1282 | }, | 1282 | }, |
1283 | InlayHint { | 1283 | InlayHint { |
1284 | range: [403; 422), | 1284 | range: 403..422, |
1285 | kind: ChainingHint, | 1285 | kind: ChainingHint, |
1286 | label: "A<X<i32, bool>>", | 1286 | label: "A<X<i32, bool>>", |
1287 | }, | 1287 | }, |
diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs index 7d70dab9c..fde0bfa98 100644 --- a/crates/ra_ide/src/join_lines.rs +++ b/crates/ra_ide/src/join_lines.rs | |||
@@ -7,7 +7,7 @@ use ra_syntax::{ | |||
7 | ast::{self, AstNode, AstToken}, | 7 | ast::{self, AstNode, AstToken}, |
8 | Direction, NodeOrToken, SourceFile, | 8 | Direction, NodeOrToken, SourceFile, |
9 | SyntaxKind::{self, WHITESPACE}, | 9 | SyntaxKind::{self, WHITESPACE}, |
10 | SyntaxNode, SyntaxToken, TextRange, TextUnit, T, | 10 | SyntaxNode, SyntaxToken, TextRange, TextSize, T, |
11 | }; | 11 | }; |
12 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 12 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
13 | 13 | ||
@@ -19,7 +19,7 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { | |||
19 | None => return TextEditBuilder::default().finish(), | 19 | None => return TextEditBuilder::default().finish(), |
20 | Some(pos) => pos, | 20 | Some(pos) => pos, |
21 | }; | 21 | }; |
22 | TextRange::offset_len(range.start() + pos, TextUnit::of_char('\n')) | 22 | TextRange::at(range.start() + pos, TextSize::of('\n')) |
23 | } else { | 23 | } else { |
24 | range | 24 | range |
25 | }; | 25 | }; |
@@ -30,13 +30,13 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { | |||
30 | }; | 30 | }; |
31 | let mut edit = TextEditBuilder::default(); | 31 | let mut edit = TextEditBuilder::default(); |
32 | for token in node.descendants_with_tokens().filter_map(|it| it.into_token()) { | 32 | for token in node.descendants_with_tokens().filter_map(|it| it.into_token()) { |
33 | let range = match range.intersection(&token.text_range()) { | 33 | let range = match range.intersect(token.text_range()) { |
34 | Some(range) => range, | 34 | Some(range) => range, |
35 | None => continue, | 35 | None => continue, |
36 | } - token.text_range().start(); | 36 | } - token.text_range().start(); |
37 | let text = token.text(); | 37 | let text = token.text(); |
38 | for (pos, _) in text[range].bytes().enumerate().filter(|&(_, b)| b == b'\n') { | 38 | for (pos, _) in text[range].bytes().enumerate().filter(|&(_, b)| b == b'\n') { |
39 | let pos: TextUnit = (pos as u32).into(); | 39 | let pos: TextSize = (pos as u32).into(); |
40 | let off = token.text_range().start() + range.start() + pos; | 40 | let off = token.text_range().start() + range.start() + pos; |
41 | if !edit.invalidates_offset(off) { | 41 | if !edit.invalidates_offset(off) { |
42 | remove_newline(&mut edit, &token, off); | 42 | remove_newline(&mut edit, &token, off); |
@@ -47,16 +47,16 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { | |||
47 | edit.finish() | 47 | edit.finish() |
48 | } | 48 | } |
49 | 49 | ||
50 | fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextUnit) { | 50 | fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextSize) { |
51 | if token.kind() != WHITESPACE || token.text().bytes().filter(|&b| b == b'\n').count() != 1 { | 51 | if token.kind() != WHITESPACE || token.text().bytes().filter(|&b| b == b'\n').count() != 1 { |
52 | // The node is either the first or the last in the file | 52 | // The node is either the first or the last in the file |
53 | let suff = &token.text()[TextRange::from_to( | 53 | let suff = &token.text()[TextRange::new( |
54 | offset - token.text_range().start() + TextUnit::of_char('\n'), | 54 | offset - token.text_range().start() + TextSize::of('\n'), |
55 | TextUnit::of_str(token.text()), | 55 | TextSize::of(token.text().as_str()), |
56 | )]; | 56 | )]; |
57 | let spaces = suff.bytes().take_while(|&b| b == b' ').count(); | 57 | let spaces = suff.bytes().take_while(|&b| b == b' ').count(); |
58 | 58 | ||
59 | edit.replace(TextRange::offset_len(offset, ((spaces + 1) as u32).into()), " ".to_string()); | 59 | edit.replace(TextRange::at(offset, ((spaces + 1) as u32).into()), " ".to_string()); |
60 | return; | 60 | return; |
61 | } | 61 | } |
62 | 62 | ||
@@ -65,7 +65,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextU | |||
65 | let next = token.next_sibling_or_token().unwrap(); | 65 | let next = token.next_sibling_or_token().unwrap(); |
66 | if is_trailing_comma(prev.kind(), next.kind()) { | 66 | if is_trailing_comma(prev.kind(), next.kind()) { |
67 | // Removes: trailing comma, newline (incl. surrounding whitespace) | 67 | // Removes: trailing comma, newline (incl. surrounding whitespace) |
68 | edit.delete(TextRange::from_to(prev.text_range().start(), token.text_range().end())); | 68 | edit.delete(TextRange::new(prev.text_range().start(), token.text_range().end())); |
69 | return; | 69 | return; |
70 | } | 70 | } |
71 | if prev.kind() == T![,] && next.kind() == T!['}'] { | 71 | if prev.kind() == T![,] && next.kind() == T!['}'] { |
@@ -76,7 +76,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextU | |||
76 | " " | 76 | " " |
77 | }; | 77 | }; |
78 | edit.replace( | 78 | edit.replace( |
79 | TextRange::from_to(prev.text_range().start(), token.text_range().end()), | 79 | TextRange::new(prev.text_range().start(), token.text_range().end()), |
80 | space.to_string(), | 80 | space.to_string(), |
81 | ); | 81 | ); |
82 | return; | 82 | return; |
@@ -87,9 +87,9 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextU | |||
87 | next.as_token().cloned().and_then(ast::Comment::cast), | 87 | next.as_token().cloned().and_then(ast::Comment::cast), |
88 | ) { | 88 | ) { |
89 | // Removes: newline (incl. surrounding whitespace), start of the next comment | 89 | // Removes: newline (incl. surrounding whitespace), start of the next comment |
90 | edit.delete(TextRange::from_to( | 90 | edit.delete(TextRange::new( |
91 | token.text_range().start(), | 91 | token.text_range().start(), |
92 | next.syntax().text_range().start() + TextUnit::of_str(next.prefix()), | 92 | next.syntax().text_range().start() + TextSize::of(next.prefix()), |
93 | )); | 93 | )); |
94 | return; | 94 | return; |
95 | } | 95 | } |
@@ -170,7 +170,7 @@ mod tests { | |||
170 | 170 | ||
171 | fn check_join_lines(before: &str, after: &str) { | 171 | fn check_join_lines(before: &str, after: &str) { |
172 | check_action(before, after, |file, offset| { | 172 | check_action(before, after, |file, offset| { |
173 | let range = TextRange::offset_len(offset, 0.into()); | 173 | let range = TextRange::empty(offset); |
174 | let res = join_lines(file, range); | 174 | let res = join_lines(file, range); |
175 | Some(res) | 175 | Some(res) |
176 | }) | 176 | }) |
@@ -420,10 +420,10 @@ fn foo() { | |||
420 | check_join_lines( | 420 | check_join_lines( |
421 | r" | 421 | r" |
422 | <|>use ra_syntax::{ | 422 | <|>use ra_syntax::{ |
423 | TextUnit, TextRange, | 423 | TextSize, TextRange, |
424 | };", | 424 | };", |
425 | r" | 425 | r" |
426 | <|>use ra_syntax::{TextUnit, TextRange, | 426 | <|>use ra_syntax::{TextSize, TextRange, |
427 | };", | 427 | };", |
428 | ); | 428 | ); |
429 | } | 429 | } |
@@ -434,11 +434,11 @@ fn foo() { | |||
434 | check_join_lines( | 434 | check_join_lines( |
435 | r" | 435 | r" |
436 | use ra_syntax::{ | 436 | use ra_syntax::{ |
437 | <|> TextUnit, TextRange | 437 | <|> TextSize, TextRange |
438 | };", | 438 | };", |
439 | r" | 439 | r" |
440 | use ra_syntax::{ | 440 | use ra_syntax::{ |
441 | <|> TextUnit, TextRange};", | 441 | <|> TextSize, TextRange};", |
442 | ); | 442 | ); |
443 | } | 443 | } |
444 | 444 | ||
@@ -448,11 +448,11 @@ use ra_syntax::{ | |||
448 | check_join_lines( | 448 | check_join_lines( |
449 | r" | 449 | r" |
450 | use ra_syntax::{ | 450 | use ra_syntax::{ |
451 | <|> TextUnit, TextRange, | 451 | <|> TextSize, TextRange, |
452 | };", | 452 | };", |
453 | r" | 453 | r" |
454 | use ra_syntax::{ | 454 | use ra_syntax::{ |
455 | <|> TextUnit, TextRange};", | 455 | <|> TextSize, TextRange};", |
456 | ); | 456 | ); |
457 | } | 457 | } |
458 | 458 | ||
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index f692fbaa2..09f602fe1 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -60,7 +60,7 @@ use ra_ide_db::{ | |||
60 | symbol_index::{self, FileSymbol}, | 60 | symbol_index::{self, FileSymbol}, |
61 | LineIndexDatabase, | 61 | LineIndexDatabase, |
62 | }; | 62 | }; |
63 | use ra_syntax::{SourceFile, TextRange, TextUnit}; | 63 | use ra_syntax::{SourceFile, TextRange, TextSize}; |
64 | 64 | ||
65 | use crate::display::ToNav; | 65 | use crate::display::ToNav; |
66 | 66 | ||
@@ -265,7 +265,7 @@ impl Analysis { | |||
265 | 265 | ||
266 | /// Returns position of the matching brace (all types of braces are | 266 | /// Returns position of the matching brace (all types of braces are |
267 | /// supported). | 267 | /// supported). |
268 | pub fn matching_brace(&self, position: FilePosition) -> Cancelable<Option<TextUnit>> { | 268 | pub fn matching_brace(&self, position: FilePosition) -> Cancelable<Option<TextSize>> { |
269 | self.with_db(|db| { | 269 | self.with_db(|db| { |
270 | let parse = db.parse(position.file_id); | 270 | let parse = db.parse(position.file_id); |
271 | let file = parse.tree(); | 271 | let file = parse.tree(); |
diff --git a/crates/ra_ide/src/matching_brace.rs b/crates/ra_ide/src/matching_brace.rs index d1204fac0..b85348706 100644 --- a/crates/ra_ide/src/matching_brace.rs +++ b/crates/ra_ide/src/matching_brace.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use ra_syntax::{ast::AstNode, SourceFile, SyntaxKind, TextUnit, T}; | 3 | use ra_syntax::{ast::AstNode, SourceFile, SyntaxKind, TextSize, T}; |
4 | 4 | ||
5 | pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { | 5 | pub fn matching_brace(file: &SourceFile, offset: TextSize) -> Option<TextSize> { |
6 | const BRACES: &[SyntaxKind] = | 6 | const BRACES: &[SyntaxKind] = |
7 | &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>]]; | 7 | &[T!['{'], T!['}'], T!['['], T![']'], T!['('], T![')'], T![<], T![>]]; |
8 | let (brace_node, brace_idx) = file | 8 | let (brace_node, brace_idx) = file |
diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index 958b92bed..aaf4460df 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs | |||
@@ -76,7 +76,7 @@ mod tests { | |||
76 | ", | 76 | ", |
77 | ); | 77 | ); |
78 | let nav = analysis.parent_module(pos).unwrap().pop().unwrap(); | 78 | let nav = analysis.parent_module(pos).unwrap().pop().unwrap(); |
79 | nav.assert_match("foo MODULE FileId(1) [0; 8)"); | 79 | nav.assert_match("foo MODULE FileId(1) 0..8"); |
80 | } | 80 | } |
81 | 81 | ||
82 | #[test] | 82 | #[test] |
@@ -95,7 +95,7 @@ mod tests { | |||
95 | ", | 95 | ", |
96 | ); | 96 | ); |
97 | let nav = analysis.parent_module(pos).unwrap().pop().unwrap(); | 97 | let nav = analysis.parent_module(pos).unwrap().pop().unwrap(); |
98 | nav.assert_match("foo MODULE FileId(1) [0; 8)"); | 98 | nav.assert_match("foo MODULE FileId(1) 0..8"); |
99 | } | 99 | } |
100 | 100 | ||
101 | #[test] | 101 | #[test] |
@@ -111,7 +111,7 @@ mod tests { | |||
111 | ", | 111 | ", |
112 | ); | 112 | ); |
113 | let nav = analysis.parent_module(pos).unwrap().pop().unwrap(); | 113 | let nav = analysis.parent_module(pos).unwrap().pop().unwrap(); |
114 | nav.assert_match("baz MODULE FileId(1) [32; 44)"); | 114 | nav.assert_match("baz MODULE FileId(1) 32..44"); |
115 | } | 115 | } |
116 | 116 | ||
117 | #[test] | 117 | #[test] |
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 7d0544ff4..555ccf295 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs | |||
@@ -144,7 +144,7 @@ fn find_name( | |||
144 | 144 | ||
145 | fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Option<ReferenceAccess> { | 145 | fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Option<ReferenceAccess> { |
146 | match def { | 146 | match def { |
147 | Definition::Local(_) | Definition::StructField(_) => {} | 147 | Definition::Local(_) | Definition::Field(_) => {} |
148 | _ => return None, | 148 | _ => return None, |
149 | }; | 149 | }; |
150 | 150 | ||
@@ -214,8 +214,8 @@ mod tests { | |||
214 | let refs = get_all_refs(code); | 214 | let refs = get_all_refs(code); |
215 | check_result( | 215 | check_result( |
216 | refs, | 216 | refs, |
217 | "Foo STRUCT_DEF FileId(1) [5; 39) [12; 15) Other", | 217 | "Foo STRUCT_DEF FileId(1) 5..39 12..15 Other", |
218 | &["FileId(1) [138; 141) StructLiteral"], | 218 | &["FileId(1) 138..141 StructLiteral"], |
219 | ); | 219 | ); |
220 | } | 220 | } |
221 | 221 | ||
@@ -231,8 +231,8 @@ mod tests { | |||
231 | let refs = get_all_refs(code); | 231 | let refs = get_all_refs(code); |
232 | check_result( | 232 | check_result( |
233 | refs, | 233 | refs, |
234 | "Foo STRUCT_DEF FileId(1) [5; 18) [12; 15) Other", | 234 | "Foo STRUCT_DEF FileId(1) 5..18 12..15 Other", |
235 | &["FileId(1) [54; 57) Other", "FileId(1) [71; 74) StructLiteral"], | 235 | &["FileId(1) 54..57 Other", "FileId(1) 71..74 StructLiteral"], |
236 | ); | 236 | ); |
237 | } | 237 | } |
238 | 238 | ||
@@ -248,8 +248,8 @@ mod tests { | |||
248 | let refs = get_all_refs(code); | 248 | let refs = get_all_refs(code); |
249 | check_result( | 249 | check_result( |
250 | refs, | 250 | refs, |
251 | "Foo STRUCT_DEF FileId(1) [5; 21) [12; 15) Other", | 251 | "Foo STRUCT_DEF FileId(1) 5..21 12..15 Other", |
252 | &["FileId(1) [81; 84) StructLiteral"], | 252 | &["FileId(1) 81..84 StructLiteral"], |
253 | ); | 253 | ); |
254 | } | 254 | } |
255 | 255 | ||
@@ -266,8 +266,8 @@ mod tests { | |||
266 | let refs = get_all_refs(code); | 266 | let refs = get_all_refs(code); |
267 | check_result( | 267 | check_result( |
268 | refs, | 268 | refs, |
269 | "Foo STRUCT_DEF FileId(1) [5; 21) [12; 15) Other", | 269 | "Foo STRUCT_DEF FileId(1) 5..21 12..15 Other", |
270 | &["FileId(1) [71; 74) StructLiteral"], | 270 | &["FileId(1) 71..74 StructLiteral"], |
271 | ); | 271 | ); |
272 | } | 272 | } |
273 | 273 | ||
@@ -289,12 +289,12 @@ mod tests { | |||
289 | let refs = get_all_refs(code); | 289 | let refs = get_all_refs(code); |
290 | check_result( | 290 | check_result( |
291 | refs, | 291 | refs, |
292 | "i BIND_PAT FileId(1) [33; 34) Other Write", | 292 | "i BIND_PAT FileId(1) 33..34 Other Write", |
293 | &[ | 293 | &[ |
294 | "FileId(1) [67; 68) Other Write", | 294 | "FileId(1) 67..68 Other Write", |
295 | "FileId(1) [71; 72) Other Read", | 295 | "FileId(1) 71..72 Other Read", |
296 | "FileId(1) [101; 102) Other Write", | 296 | "FileId(1) 101..102 Other Write", |
297 | "FileId(1) [127; 128) Other Write", | 297 | "FileId(1) 127..128 Other Write", |
298 | ], | 298 | ], |
299 | ); | 299 | ); |
300 | } | 300 | } |
@@ -315,8 +315,8 @@ mod tests { | |||
315 | let refs = get_all_refs(code); | 315 | let refs = get_all_refs(code); |
316 | check_result( | 316 | check_result( |
317 | refs, | 317 | refs, |
318 | "spam BIND_PAT FileId(1) [44; 48) Other", | 318 | "spam BIND_PAT FileId(1) 44..48 Other", |
319 | &["FileId(1) [71; 75) Other Read", "FileId(1) [78; 82) Other Read"], | 319 | &["FileId(1) 71..75 Other Read", "FileId(1) 78..82 Other Read"], |
320 | ); | 320 | ); |
321 | } | 321 | } |
322 | 322 | ||
@@ -328,11 +328,7 @@ mod tests { | |||
328 | }"#; | 328 | }"#; |
329 | 329 | ||
330 | let refs = get_all_refs(code); | 330 | let refs = get_all_refs(code); |
331 | check_result( | 331 | check_result(refs, "i BIND_PAT FileId(1) 12..13 Other", &["FileId(1) 38..39 Other Read"]); |
332 | refs, | ||
333 | "i BIND_PAT FileId(1) [12; 13) Other", | ||
334 | &["FileId(1) [38; 39) Other Read"], | ||
335 | ); | ||
336 | } | 332 | } |
337 | 333 | ||
338 | #[test] | 334 | #[test] |
@@ -343,11 +339,7 @@ mod tests { | |||
343 | }"#; | 339 | }"#; |
344 | 340 | ||
345 | let refs = get_all_refs(code); | 341 | let refs = get_all_refs(code); |
346 | check_result( | 342 | check_result(refs, "i BIND_PAT FileId(1) 12..13 Other", &["FileId(1) 38..39 Other Read"]); |
347 | refs, | ||
348 | "i BIND_PAT FileId(1) [12; 13) Other", | ||
349 | &["FileId(1) [38; 39) Other Read"], | ||
350 | ); | ||
351 | } | 343 | } |
352 | 344 | ||
353 | #[test] | 345 | #[test] |
@@ -366,8 +358,8 @@ mod tests { | |||
366 | let refs = get_all_refs(code); | 358 | let refs = get_all_refs(code); |
367 | check_result( | 359 | check_result( |
368 | refs, | 360 | refs, |
369 | "spam RECORD_FIELD_DEF FileId(1) [66; 79) [70; 74) Other", | 361 | "spam RECORD_FIELD_DEF FileId(1) 66..79 70..74 Other", |
370 | &["FileId(1) [152; 156) Other Read"], | 362 | &["FileId(1) 152..156 Other Read"], |
371 | ); | 363 | ); |
372 | } | 364 | } |
373 | 365 | ||
@@ -382,7 +374,7 @@ mod tests { | |||
382 | "#; | 374 | "#; |
383 | 375 | ||
384 | let refs = get_all_refs(code); | 376 | let refs = get_all_refs(code); |
385 | check_result(refs, "f FN_DEF FileId(1) [88; 104) [91; 92) Other", &[]); | 377 | check_result(refs, "f FN_DEF FileId(1) 88..104 91..92 Other", &[]); |
386 | } | 378 | } |
387 | 379 | ||
388 | #[test] | 380 | #[test] |
@@ -397,7 +389,7 @@ mod tests { | |||
397 | "#; | 389 | "#; |
398 | 390 | ||
399 | let refs = get_all_refs(code); | 391 | let refs = get_all_refs(code); |
400 | check_result(refs, "B ENUM_VARIANT FileId(1) [83; 84) [83; 84) Other", &[]); | 392 | check_result(refs, "B ENUM_VARIANT FileId(1) 83..84 83..84 Other", &[]); |
401 | } | 393 | } |
402 | 394 | ||
403 | #[test] | 395 | #[test] |
@@ -438,8 +430,8 @@ mod tests { | |||
438 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); | 430 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); |
439 | check_result( | 431 | check_result( |
440 | refs, | 432 | refs, |
441 | "Foo STRUCT_DEF FileId(2) [16; 50) [27; 30) Other", | 433 | "Foo STRUCT_DEF FileId(2) 16..50 27..30 Other", |
442 | &["FileId(1) [52; 55) StructLiteral", "FileId(3) [77; 80) StructLiteral"], | 434 | &["FileId(1) 52..55 StructLiteral", "FileId(3) 77..80 StructLiteral"], |
443 | ); | 435 | ); |
444 | } | 436 | } |
445 | 437 | ||
@@ -466,11 +458,7 @@ mod tests { | |||
466 | 458 | ||
467 | let (analysis, pos) = analysis_and_position(code); | 459 | let (analysis, pos) = analysis_and_position(code); |
468 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); | 460 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); |
469 | check_result( | 461 | check_result(refs, "foo SOURCE_FILE FileId(2) 0..35 Other", &["FileId(1) 13..16 Other"]); |
470 | refs, | ||
471 | "foo SOURCE_FILE FileId(2) [0; 35) Other", | ||
472 | &["FileId(1) [13; 16) Other"], | ||
473 | ); | ||
474 | } | 462 | } |
475 | 463 | ||
476 | #[test] | 464 | #[test] |
@@ -497,8 +485,8 @@ mod tests { | |||
497 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); | 485 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); |
498 | check_result( | 486 | check_result( |
499 | refs, | 487 | refs, |
500 | "Foo STRUCT_DEF FileId(3) [0; 41) [18; 21) Other", | 488 | "Foo STRUCT_DEF FileId(3) 0..41 18..21 Other", |
501 | &["FileId(2) [20; 23) Other", "FileId(2) [46; 49) StructLiteral"], | 489 | &["FileId(2) 20..23 Other", "FileId(2) 46..49 StructLiteral"], |
502 | ); | 490 | ); |
503 | } | 491 | } |
504 | 492 | ||
@@ -525,16 +513,16 @@ mod tests { | |||
525 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); | 513 | let refs = analysis.find_all_refs(pos, None).unwrap().unwrap(); |
526 | check_result( | 514 | check_result( |
527 | refs, | 515 | refs, |
528 | "quux FN_DEF FileId(1) [18; 34) [25; 29) Other", | 516 | "quux FN_DEF FileId(1) 18..34 25..29 Other", |
529 | &["FileId(2) [16; 20) StructLiteral", "FileId(3) [16; 20) StructLiteral"], | 517 | &["FileId(2) 16..20 StructLiteral", "FileId(3) 16..20 StructLiteral"], |
530 | ); | 518 | ); |
531 | 519 | ||
532 | let refs = | 520 | let refs = |
533 | analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap(); | 521 | analysis.find_all_refs(pos, Some(SearchScope::single_file(bar))).unwrap().unwrap(); |
534 | check_result( | 522 | check_result( |
535 | refs, | 523 | refs, |
536 | "quux FN_DEF FileId(1) [18; 34) [25; 29) Other", | 524 | "quux FN_DEF FileId(1) 18..34 25..29 Other", |
537 | &["FileId(3) [16; 20) StructLiteral"], | 525 | &["FileId(3) 16..20 StructLiteral"], |
538 | ); | 526 | ); |
539 | } | 527 | } |
540 | 528 | ||
@@ -552,8 +540,8 @@ mod tests { | |||
552 | let refs = get_all_refs(code); | 540 | let refs = get_all_refs(code); |
553 | check_result( | 541 | check_result( |
554 | refs, | 542 | refs, |
555 | "m1 MACRO_CALL FileId(1) [9; 63) [46; 48) Other", | 543 | "m1 MACRO_CALL FileId(1) 9..63 46..48 Other", |
556 | &["FileId(1) [96; 98) StructLiteral", "FileId(1) [114; 116) StructLiteral"], | 544 | &["FileId(1) 96..98 StructLiteral", "FileId(1) 114..116 StructLiteral"], |
557 | ); | 545 | ); |
558 | } | 546 | } |
559 | 547 | ||
@@ -568,8 +556,8 @@ mod tests { | |||
568 | let refs = get_all_refs(code); | 556 | let refs = get_all_refs(code); |
569 | check_result( | 557 | check_result( |
570 | refs, | 558 | refs, |
571 | "i BIND_PAT FileId(1) [40; 41) Other Write", | 559 | "i BIND_PAT FileId(1) 40..41 Other Write", |
572 | &["FileId(1) [59; 60) Other Write", "FileId(1) [63; 64) Other Read"], | 560 | &["FileId(1) 59..60 Other Write", "FileId(1) 63..64 Other Read"], |
573 | ); | 561 | ); |
574 | } | 562 | } |
575 | 563 | ||
@@ -588,8 +576,8 @@ mod tests { | |||
588 | let refs = get_all_refs(code); | 576 | let refs = get_all_refs(code); |
589 | check_result( | 577 | check_result( |
590 | refs, | 578 | refs, |
591 | "f RECORD_FIELD_DEF FileId(1) [32; 38) [32; 33) Other", | 579 | "f RECORD_FIELD_DEF FileId(1) 32..38 32..33 Other", |
592 | &["FileId(1) [96; 97) Other Read", "FileId(1) [117; 118) Other Write"], | 580 | &["FileId(1) 96..97 Other Read", "FileId(1) 117..118 Other Write"], |
593 | ); | 581 | ); |
594 | } | 582 | } |
595 | 583 | ||
@@ -602,11 +590,7 @@ mod tests { | |||
602 | }"#; | 590 | }"#; |
603 | 591 | ||
604 | let refs = get_all_refs(code); | 592 | let refs = get_all_refs(code); |
605 | check_result( | 593 | check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]); |
606 | refs, | ||
607 | "i BIND_PAT FileId(1) [36; 37) Other", | ||
608 | &["FileId(1) [51; 52) Other Write"], | ||
609 | ); | ||
610 | } | 594 | } |
611 | 595 | ||
612 | fn get_all_refs(text: &str) -> ReferenceSearchResult { | 596 | fn get_all_refs(text: &str) -> ReferenceSearchResult { |
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 9acc6158a..fd17bc9f2 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -51,18 +51,15 @@ fn source_edit_from_reference(reference: Reference, new_name: &str) -> SourceFil | |||
51 | let mut replacement_text = String::new(); | 51 | let mut replacement_text = String::new(); |
52 | let file_id = reference.file_range.file_id; | 52 | let file_id = reference.file_range.file_id; |
53 | let range = match reference.kind { | 53 | let range = match reference.kind { |
54 | ReferenceKind::StructFieldShorthandForField => { | 54 | ReferenceKind::FieldShorthandForField => { |
55 | replacement_text.push_str(new_name); | 55 | replacement_text.push_str(new_name); |
56 | replacement_text.push_str(": "); | 56 | replacement_text.push_str(": "); |
57 | TextRange::from_to( | 57 | TextRange::new(reference.file_range.range.start(), reference.file_range.range.start()) |
58 | reference.file_range.range.start(), | ||
59 | reference.file_range.range.start(), | ||
60 | ) | ||
61 | } | 58 | } |
62 | ReferenceKind::StructFieldShorthandForLocal => { | 59 | ReferenceKind::FieldShorthandForLocal => { |
63 | replacement_text.push_str(": "); | 60 | replacement_text.push_str(": "); |
64 | replacement_text.push_str(new_name); | 61 | replacement_text.push_str(new_name); |
65 | TextRange::from_to(reference.file_range.range.end(), reference.file_range.range.end()) | 62 | TextRange::new(reference.file_range.range.end(), reference.file_range.range.end()) |
66 | } | 63 | } |
67 | _ => { | 64 | _ => { |
68 | replacement_text.push_str(new_name); | 65 | replacement_text.push_str(new_name); |
@@ -528,7 +525,7 @@ mod tests { | |||
528 | @r###" | 525 | @r###" |
529 | Some( | 526 | Some( |
530 | RangeInfo { | 527 | RangeInfo { |
531 | range: [4; 7), | 528 | range: 4..7, |
532 | info: SourceChange { | 529 | info: SourceChange { |
533 | label: "rename", | 530 | label: "rename", |
534 | source_file_edits: [ | 531 | source_file_edits: [ |
@@ -539,7 +536,7 @@ mod tests { | |||
539 | edit: TextEdit { | 536 | edit: TextEdit { |
540 | atoms: [ | 537 | atoms: [ |
541 | AtomTextEdit { | 538 | AtomTextEdit { |
542 | delete: [4; 7), | 539 | delete: 4..7, |
543 | insert: "foo2", | 540 | insert: "foo2", |
544 | }, | 541 | }, |
545 | ], | 542 | ], |
@@ -580,7 +577,7 @@ mod tests { | |||
580 | @r###" | 577 | @r###" |
581 | Some( | 578 | Some( |
582 | RangeInfo { | 579 | RangeInfo { |
583 | range: [4; 7), | 580 | range: 4..7, |
584 | info: SourceChange { | 581 | info: SourceChange { |
585 | label: "rename", | 582 | label: "rename", |
586 | source_file_edits: [ | 583 | source_file_edits: [ |
@@ -591,7 +588,7 @@ mod tests { | |||
591 | edit: TextEdit { | 588 | edit: TextEdit { |
592 | atoms: [ | 589 | atoms: [ |
593 | AtomTextEdit { | 590 | AtomTextEdit { |
594 | delete: [4; 7), | 591 | delete: 4..7, |
595 | insert: "foo2", | 592 | insert: "foo2", |
596 | }, | 593 | }, |
597 | ], | 594 | ], |
@@ -663,7 +660,7 @@ mod tests { | |||
663 | @r###" | 660 | @r###" |
664 | Some( | 661 | Some( |
665 | RangeInfo { | 662 | RangeInfo { |
666 | range: [8; 11), | 663 | range: 8..11, |
667 | info: SourceChange { | 664 | info: SourceChange { |
668 | label: "rename", | 665 | label: "rename", |
669 | source_file_edits: [ | 666 | source_file_edits: [ |
@@ -674,7 +671,7 @@ mod tests { | |||
674 | edit: TextEdit { | 671 | edit: TextEdit { |
675 | atoms: [ | 672 | atoms: [ |
676 | AtomTextEdit { | 673 | AtomTextEdit { |
677 | delete: [8; 11), | 674 | delete: 8..11, |
678 | insert: "foo2", | 675 | insert: "foo2", |
679 | }, | 676 | }, |
680 | ], | 677 | ], |
@@ -687,7 +684,7 @@ mod tests { | |||
687 | edit: TextEdit { | 684 | edit: TextEdit { |
688 | atoms: [ | 685 | atoms: [ |
689 | AtomTextEdit { | 686 | AtomTextEdit { |
690 | delete: [27; 30), | 687 | delete: 27..30, |
691 | insert: "foo2", | 688 | insert: "foo2", |
692 | }, | 689 | }, |
693 | ], | 690 | ], |
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 05a66e03c..38637c19c 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs | |||
@@ -164,11 +164,11 @@ mod tests { | |||
164 | @r###" | 164 | @r###" |
165 | [ | 165 | [ |
166 | Runnable { | 166 | Runnable { |
167 | range: [1; 21), | 167 | range: 1..21, |
168 | kind: Bin, | 168 | kind: Bin, |
169 | }, | 169 | }, |
170 | Runnable { | 170 | Runnable { |
171 | range: [22; 46), | 171 | range: 22..46, |
172 | kind: Test { | 172 | kind: Test { |
173 | test_id: Path( | 173 | test_id: Path( |
174 | "test_foo", | 174 | "test_foo", |
@@ -179,7 +179,7 @@ mod tests { | |||
179 | }, | 179 | }, |
180 | }, | 180 | }, |
181 | Runnable { | 181 | Runnable { |
182 | range: [47; 81), | 182 | range: 47..81, |
183 | kind: Test { | 183 | kind: Test { |
184 | test_id: Path( | 184 | test_id: Path( |
185 | "test_foo", | 185 | "test_foo", |
@@ -211,13 +211,13 @@ mod tests { | |||
211 | @r###" | 211 | @r###" |
212 | [ | 212 | [ |
213 | Runnable { | 213 | Runnable { |
214 | range: [1; 59), | 214 | range: 1..59, |
215 | kind: TestMod { | 215 | kind: TestMod { |
216 | path: "test_mod", | 216 | path: "test_mod", |
217 | }, | 217 | }, |
218 | }, | 218 | }, |
219 | Runnable { | 219 | Runnable { |
220 | range: [28; 57), | 220 | range: 28..57, |
221 | kind: Test { | 221 | kind: Test { |
222 | test_id: Path( | 222 | test_id: Path( |
223 | "test_mod::test_foo1", | 223 | "test_mod::test_foo1", |
@@ -251,13 +251,13 @@ mod tests { | |||
251 | @r###" | 251 | @r###" |
252 | [ | 252 | [ |
253 | Runnable { | 253 | Runnable { |
254 | range: [23; 85), | 254 | range: 23..85, |
255 | kind: TestMod { | 255 | kind: TestMod { |
256 | path: "foo::test_mod", | 256 | path: "foo::test_mod", |
257 | }, | 257 | }, |
258 | }, | 258 | }, |
259 | Runnable { | 259 | Runnable { |
260 | range: [46; 79), | 260 | range: 46..79, |
261 | kind: Test { | 261 | kind: Test { |
262 | test_id: Path( | 262 | test_id: Path( |
263 | "foo::test_mod::test_foo1", | 263 | "foo::test_mod::test_foo1", |
@@ -293,13 +293,13 @@ mod tests { | |||
293 | @r###" | 293 | @r###" |
294 | [ | 294 | [ |
295 | Runnable { | 295 | Runnable { |
296 | range: [41; 115), | 296 | range: 41..115, |
297 | kind: TestMod { | 297 | kind: TestMod { |
298 | path: "foo::bar::test_mod", | 298 | path: "foo::bar::test_mod", |
299 | }, | 299 | }, |
300 | }, | 300 | }, |
301 | Runnable { | 301 | Runnable { |
302 | range: [68; 105), | 302 | range: 68..105, |
303 | kind: Test { | 303 | kind: Test { |
304 | test_id: Path( | 304 | test_id: Path( |
305 | "foo::bar::test_mod::test_foo1", | 305 | "foo::bar::test_mod::test_foo1", |
diff --git a/crates/ra_ide/src/source_change.rs b/crates/ra_ide/src/source_change.rs index f5f7f8807..71b0e8f75 100644 --- a/crates/ra_ide/src/source_change.rs +++ b/crates/ra_ide/src/source_change.rs | |||
@@ -6,7 +6,7 @@ | |||
6 | use ra_db::RelativePathBuf; | 6 | use ra_db::RelativePathBuf; |
7 | use ra_text_edit::TextEdit; | 7 | use ra_text_edit::TextEdit; |
8 | 8 | ||
9 | use crate::{FileId, FilePosition, SourceRootId, TextUnit}; | 9 | use crate::{FileId, FilePosition, SourceRootId, TextSize}; |
10 | 10 | ||
11 | #[derive(Debug)] | 11 | #[derive(Debug)] |
12 | pub struct SourceChange { | 12 | pub struct SourceChange { |
@@ -104,7 +104,7 @@ pub enum FileSystemEdit { | |||
104 | pub(crate) struct SingleFileChange { | 104 | pub(crate) struct SingleFileChange { |
105 | pub label: String, | 105 | pub label: String, |
106 | pub edit: TextEdit, | 106 | pub edit: TextEdit, |
107 | pub cursor_position: Option<TextUnit>, | 107 | pub cursor_position: Option<TextSize>, |
108 | } | 108 | } |
109 | 109 | ||
110 | impl SingleFileChange { | 110 | impl SingleFileChange { |
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index c0728bfb1..be0f8c827 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -61,16 +61,16 @@ impl HighlightedRangeStack { | |||
61 | let prev = self.stack.last_mut().unwrap(); | 61 | let prev = self.stack.last_mut().unwrap(); |
62 | let needs_flattening = !children.is_empty() | 62 | let needs_flattening = !children.is_empty() |
63 | && !prev.is_empty() | 63 | && !prev.is_empty() |
64 | && children.first().unwrap().range.is_subrange(&prev.last().unwrap().range); | 64 | && prev.last().unwrap().range.contains_range(children.first().unwrap().range); |
65 | if !needs_flattening { | 65 | if !needs_flattening { |
66 | prev.extend(children); | 66 | prev.extend(children); |
67 | } else { | 67 | } else { |
68 | let mut parent = prev.pop().unwrap(); | 68 | let mut parent = prev.pop().unwrap(); |
69 | for ele in children { | 69 | for ele in children { |
70 | assert!(ele.range.is_subrange(&parent.range)); | 70 | assert!(parent.range.contains_range(ele.range)); |
71 | let mut cloned = parent.clone(); | 71 | let mut cloned = parent.clone(); |
72 | parent.range = TextRange::from_to(parent.range.start(), ele.range.start()); | 72 | parent.range = TextRange::new(parent.range.start(), ele.range.start()); |
73 | cloned.range = TextRange::from_to(ele.range.end(), cloned.range.end()); | 73 | cloned.range = TextRange::new(ele.range.end(), cloned.range.end()); |
74 | if !parent.range.is_empty() { | 74 | if !parent.range.is_empty() { |
75 | prev.push(parent); | 75 | prev.push(parent); |
76 | } | 76 | } |
@@ -152,7 +152,7 @@ pub(crate) fn highlight( | |||
152 | }; | 152 | }; |
153 | 153 | ||
154 | // Element outside of the viewport, no need to highlight | 154 | // Element outside of the viewport, no need to highlight |
155 | if range_to_highlight.intersection(&event_range).is_none() { | 155 | if range_to_highlight.intersect(event_range).is_none() { |
156 | continue; | 156 | continue; |
157 | } | 157 | } |
158 | 158 | ||
@@ -309,7 +309,7 @@ fn macro_call_range(macro_call: &ast::MacroCall) -> Option<TextRange> { | |||
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | Some(TextRange::from_to(range_start, range_end)) | 312 | Some(TextRange::new(range_start, range_end)) |
313 | } | 313 | } |
314 | 314 | ||
315 | fn highlight_element( | 315 | fn highlight_element( |
@@ -422,7 +422,7 @@ fn highlight_element( | |||
422 | fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { | 422 | fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight { |
423 | match def { | 423 | match def { |
424 | Definition::Macro(_) => HighlightTag::Macro, | 424 | Definition::Macro(_) => HighlightTag::Macro, |
425 | Definition::StructField(_) => HighlightTag::Field, | 425 | Definition::Field(_) => HighlightTag::Field, |
426 | Definition::ModuleDef(def) => match def { | 426 | Definition::ModuleDef(def) => match def { |
427 | hir::ModuleDef::Module(_) => HighlightTag::Module, | 427 | hir::ModuleDef::Module(_) => HighlightTag::Module, |
428 | hir::ModuleDef::Function(_) => HighlightTag::Function, | 428 | hir::ModuleDef::Function(_) => HighlightTag::Function, |
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 4496529a1..010db4017 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs | |||
@@ -1,11 +1,9 @@ | |||
1 | //! Renders a bit of code as HTML. | 1 | //! Renders a bit of code as HTML. |
2 | 2 | ||
3 | use ra_db::SourceDatabase; | 3 | use ra_db::SourceDatabase; |
4 | use ra_syntax::{AstNode, TextUnit}; | 4 | use ra_syntax::{AstNode, TextRange, TextSize}; |
5 | 5 | ||
6 | use crate::{FileId, RootDatabase}; | 6 | use crate::{syntax_highlighting::highlight, FileId, RootDatabase}; |
7 | |||
8 | use super::highlight; | ||
9 | 7 | ||
10 | pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: bool) -> String { | 8 | pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: bool) -> String { |
11 | let parse = db.parse(file_id); | 9 | let parse = db.parse(file_id); |
@@ -23,17 +21,17 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo | |||
23 | 21 | ||
24 | let ranges = highlight(db, file_id, None); | 22 | let ranges = highlight(db, file_id, None); |
25 | let text = parse.tree().syntax().to_string(); | 23 | let text = parse.tree().syntax().to_string(); |
26 | let mut prev_pos = TextUnit::from(0); | 24 | let mut prev_pos = TextSize::from(0); |
27 | let mut buf = String::new(); | 25 | let mut buf = String::new(); |
28 | buf.push_str(&STYLE); | 26 | buf.push_str(&STYLE); |
29 | buf.push_str("<pre><code>"); | 27 | buf.push_str("<pre><code>"); |
30 | for range in &ranges { | 28 | for range in &ranges { |
31 | if range.range.start() > prev_pos { | 29 | if range.range.start() > prev_pos { |
32 | let curr = &text[prev_pos.to_usize()..range.range.start().to_usize()]; | 30 | let curr = &text[TextRange::new(prev_pos, range.range.start())]; |
33 | let text = html_escape(curr); | 31 | let text = html_escape(curr); |
34 | buf.push_str(&text); | 32 | buf.push_str(&text); |
35 | } | 33 | } |
36 | let curr = &text[range.range.start().to_usize()..range.range.end().to_usize()]; | 34 | let curr = &text[TextRange::new(range.range.start(), range.range.end())]; |
37 | 35 | ||
38 | let class = range.highlight.to_string().replace('.', " "); | 36 | let class = range.highlight.to_string().replace('.', " "); |
39 | let color = match (rainbow, range.binding_hash) { | 37 | let color = match (rainbow, range.binding_hash) { |
@@ -47,7 +45,7 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo | |||
47 | prev_pos = range.range.end(); | 45 | prev_pos = range.range.end(); |
48 | } | 46 | } |
49 | // Add the remaining (non-highlighted) text | 47 | // Add the remaining (non-highlighted) text |
50 | let curr = &text[prev_pos.to_usize()..]; | 48 | let curr = &text[TextRange::new(prev_pos, TextSize::of(&text))]; |
51 | let text = html_escape(curr); | 49 | let text = html_escape(curr); |
52 | buf.push_str(&text); | 50 | buf.push_str(&text); |
53 | buf.push_str("</code></pre>"); | 51 | buf.push_str("</code></pre>"); |
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index a9aae957f..d2926ba78 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -126,7 +126,7 @@ fn test_ranges() { | |||
126 | 126 | ||
127 | // The "x" | 127 | // The "x" |
128 | let highlights = &analysis | 128 | let highlights = &analysis |
129 | .highlight_range(FileRange { file_id, range: TextRange::offset_len(82.into(), 1.into()) }) | 129 | .highlight_range(FileRange { file_id, range: TextRange::at(82.into(), 1.into()) }) |
130 | .unwrap(); | 130 | .unwrap(); |
131 | 131 | ||
132 | assert_eq!(&highlights[0].highlight.to_string(), "field.declaration"); | 132 | assert_eq!(&highlights[0].highlight.to_string(), "field.declaration"); |
diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs index 5842ae2e8..bf97f8c56 100644 --- a/crates/ra_ide/src/syntax_tree.rs +++ b/crates/ra_ide/src/syntax_tree.rs | |||
@@ -5,7 +5,7 @@ use ra_ide_db::RootDatabase; | |||
5 | use ra_syntax::{ | 5 | use ra_syntax::{ |
6 | algo, AstNode, NodeOrToken, SourceFile, | 6 | algo, AstNode, NodeOrToken, SourceFile, |
7 | SyntaxKind::{RAW_STRING, STRING}, | 7 | SyntaxKind::{RAW_STRING, STRING}, |
8 | SyntaxToken, TextRange, TextUnit, | 8 | SyntaxToken, TextRange, TextSize, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | pub use ra_db::FileId; | 11 | pub use ra_db::FileId; |
@@ -66,13 +66,10 @@ fn syntax_tree_for_token(node: &SyntaxToken, text_range: TextRange) -> Option<St | |||
66 | let len = len.min(node_len); | 66 | let len = len.min(node_len); |
67 | 67 | ||
68 | // Ensure our slice is inside the actual string | 68 | // Ensure our slice is inside the actual string |
69 | let end = if start + len < TextUnit::of_str(&text) { | 69 | let end = |
70 | start + len | 70 | if start + len < TextSize::of(&text) { start + len } else { TextSize::of(&text) - start }; |
71 | } else { | ||
72 | TextUnit::of_str(&text) - start | ||
73 | }; | ||
74 | 71 | ||
75 | let text = &text[TextRange::from_to(start, end)]; | 72 | let text = &text[TextRange::new(start, end)]; |
76 | 73 | ||
77 | // Remove possible extra string quotes from the start | 74 | // Remove possible extra string quotes from the start |
78 | // and the end of the string | 75 | // and the end of the string |
@@ -112,20 +109,20 @@ mod tests { | |||
112 | assert_eq_text!( | 109 | assert_eq_text!( |
113 | syn.trim(), | 110 | syn.trim(), |
114 | r#" | 111 | r#" |
115 | SOURCE_FILE@[0; 11) | 112 | SOURCE_FILE@0..11 |
116 | FN_DEF@[0; 11) | 113 | FN_DEF@0..11 |
117 | FN_KW@[0; 2) "fn" | 114 | FN_KW@0..2 "fn" |
118 | WHITESPACE@[2; 3) " " | 115 | WHITESPACE@2..3 " " |
119 | NAME@[3; 6) | 116 | NAME@3..6 |
120 | IDENT@[3; 6) "foo" | 117 | IDENT@3..6 "foo" |
121 | PARAM_LIST@[6; 8) | 118 | PARAM_LIST@6..8 |
122 | L_PAREN@[6; 7) "(" | 119 | L_PAREN@6..7 "(" |
123 | R_PAREN@[7; 8) ")" | 120 | R_PAREN@7..8 ")" |
124 | WHITESPACE@[8; 9) " " | 121 | WHITESPACE@8..9 " " |
125 | BLOCK_EXPR@[9; 11) | 122 | BLOCK_EXPR@9..11 |
126 | BLOCK@[9; 11) | 123 | BLOCK@9..11 |
127 | L_CURLY@[9; 10) "{" | 124 | L_CURLY@9..10 "{" |
128 | R_CURLY@[10; 11) "}" | 125 | R_CURLY@10..11 "}" |
129 | "# | 126 | "# |
130 | .trim() | 127 | .trim() |
131 | ); | 128 | ); |
@@ -145,37 +142,37 @@ fn test() { | |||
145 | assert_eq_text!( | 142 | assert_eq_text!( |
146 | syn.trim(), | 143 | syn.trim(), |
147 | r#" | 144 | r#" |
148 | SOURCE_FILE@[0; 60) | 145 | SOURCE_FILE@0..60 |
149 | FN_DEF@[0; 60) | 146 | FN_DEF@0..60 |
150 | FN_KW@[0; 2) "fn" | 147 | FN_KW@0..2 "fn" |
151 | WHITESPACE@[2; 3) " " | 148 | WHITESPACE@2..3 " " |
152 | NAME@[3; 7) | 149 | NAME@3..7 |
153 | IDENT@[3; 7) "test" | 150 | IDENT@3..7 "test" |
154 | PARAM_LIST@[7; 9) | 151 | PARAM_LIST@7..9 |
155 | L_PAREN@[7; 8) "(" | 152 | L_PAREN@7..8 "(" |
156 | R_PAREN@[8; 9) ")" | 153 | R_PAREN@8..9 ")" |
157 | WHITESPACE@[9; 10) " " | 154 | WHITESPACE@9..10 " " |
158 | BLOCK_EXPR@[10; 60) | 155 | BLOCK_EXPR@10..60 |
159 | BLOCK@[10; 60) | 156 | BLOCK@10..60 |
160 | L_CURLY@[10; 11) "{" | 157 | L_CURLY@10..11 "{" |
161 | WHITESPACE@[11; 16) "\n " | 158 | WHITESPACE@11..16 "\n " |
162 | EXPR_STMT@[16; 58) | 159 | EXPR_STMT@16..58 |
163 | MACRO_CALL@[16; 57) | 160 | MACRO_CALL@16..57 |
164 | PATH@[16; 22) | 161 | PATH@16..22 |
165 | PATH_SEGMENT@[16; 22) | 162 | PATH_SEGMENT@16..22 |
166 | NAME_REF@[16; 22) | 163 | NAME_REF@16..22 |
167 | IDENT@[16; 22) "assert" | 164 | IDENT@16..22 "assert" |
168 | BANG@[22; 23) "!" | 165 | BANG@22..23 "!" |
169 | TOKEN_TREE@[23; 57) | 166 | TOKEN_TREE@23..57 |
170 | L_PAREN@[23; 24) "(" | 167 | L_PAREN@23..24 "(" |
171 | STRING@[24; 52) "\"\n fn foo() {\n ..." | 168 | STRING@24..52 "\"\n fn foo() {\n ..." |
172 | COMMA@[52; 53) "," | 169 | COMMA@52..53 "," |
173 | WHITESPACE@[53; 54) " " | 170 | WHITESPACE@53..54 " " |
174 | STRING@[54; 56) "\"\"" | 171 | STRING@54..56 "\"\"" |
175 | R_PAREN@[56; 57) ")" | 172 | R_PAREN@56..57 ")" |
176 | SEMICOLON@[57; 58) ";" | 173 | SEMICOLON@57..58 ";" |
177 | WHITESPACE@[58; 59) "\n" | 174 | WHITESPACE@58..59 "\n" |
178 | R_CURLY@[59; 60) "}" | 175 | R_CURLY@59..60 "}" |
179 | "# | 176 | "# |
180 | .trim() | 177 | .trim() |
181 | ); | 178 | ); |
@@ -189,19 +186,19 @@ SOURCE_FILE@[0; 60) | |||
189 | assert_eq_text!( | 186 | assert_eq_text!( |
190 | syn.trim(), | 187 | syn.trim(), |
191 | r#" | 188 | r#" |
192 | FN_DEF@[0; 11) | 189 | FN_DEF@0..11 |
193 | FN_KW@[0; 2) "fn" | 190 | FN_KW@0..2 "fn" |
194 | WHITESPACE@[2; 3) " " | 191 | WHITESPACE@2..3 " " |
195 | NAME@[3; 6) | 192 | NAME@3..6 |
196 | IDENT@[3; 6) "foo" | 193 | IDENT@3..6 "foo" |
197 | PARAM_LIST@[6; 8) | 194 | PARAM_LIST@6..8 |
198 | L_PAREN@[6; 7) "(" | 195 | L_PAREN@6..7 "(" |
199 | R_PAREN@[7; 8) ")" | 196 | R_PAREN@7..8 ")" |
200 | WHITESPACE@[8; 9) " " | 197 | WHITESPACE@8..9 " " |
201 | BLOCK_EXPR@[9; 11) | 198 | BLOCK_EXPR@9..11 |
202 | BLOCK@[9; 11) | 199 | BLOCK@9..11 |
203 | L_CURLY@[9; 10) "{" | 200 | L_CURLY@9..10 "{" |
204 | R_CURLY@[10; 11) "}" | 201 | R_CURLY@10..11 "}" |
205 | "# | 202 | "# |
206 | .trim() | 203 | .trim() |
207 | ); | 204 | ); |
@@ -220,21 +217,21 @@ FN_DEF@[0; 11) | |||
220 | assert_eq_text!( | 217 | assert_eq_text!( |
221 | syn.trim(), | 218 | syn.trim(), |
222 | r#" | 219 | r#" |
223 | EXPR_STMT@[16; 58) | 220 | EXPR_STMT@16..58 |
224 | MACRO_CALL@[16; 57) | 221 | MACRO_CALL@16..57 |
225 | PATH@[16; 22) | 222 | PATH@16..22 |
226 | PATH_SEGMENT@[16; 22) | 223 | PATH_SEGMENT@16..22 |
227 | NAME_REF@[16; 22) | 224 | NAME_REF@16..22 |
228 | IDENT@[16; 22) "assert" | 225 | IDENT@16..22 "assert" |
229 | BANG@[22; 23) "!" | 226 | BANG@22..23 "!" |
230 | TOKEN_TREE@[23; 57) | 227 | TOKEN_TREE@23..57 |
231 | L_PAREN@[23; 24) "(" | 228 | L_PAREN@23..24 "(" |
232 | STRING@[24; 52) "\"\n fn foo() {\n ..." | 229 | STRING@24..52 "\"\n fn foo() {\n ..." |
233 | COMMA@[52; 53) "," | 230 | COMMA@52..53 "," |
234 | WHITESPACE@[53; 54) " " | 231 | WHITESPACE@53..54 " " |
235 | STRING@[54; 56) "\"\"" | 232 | STRING@54..56 "\"\"" |
236 | R_PAREN@[56; 57) ")" | 233 | R_PAREN@56..57 ")" |
237 | SEMICOLON@[57; 58) ";" | 234 | SEMICOLON@57..58 ";" |
238 | "# | 235 | "# |
239 | .trim() | 236 | .trim() |
240 | ); | 237 | ); |
@@ -257,21 +254,21 @@ fn bar() { | |||
257 | assert_eq_text!( | 254 | assert_eq_text!( |
258 | syn.trim(), | 255 | syn.trim(), |
259 | r#" | 256 | r#" |
260 | SOURCE_FILE@[0; 12) | 257 | SOURCE_FILE@0..12 |
261 | FN_DEF@[0; 12) | 258 | FN_DEF@0..12 |
262 | FN_KW@[0; 2) "fn" | 259 | FN_KW@0..2 "fn" |
263 | WHITESPACE@[2; 3) " " | 260 | WHITESPACE@2..3 " " |
264 | NAME@[3; 6) | 261 | NAME@3..6 |
265 | IDENT@[3; 6) "foo" | 262 | IDENT@3..6 "foo" |
266 | PARAM_LIST@[6; 8) | 263 | PARAM_LIST@6..8 |
267 | L_PAREN@[6; 7) "(" | 264 | L_PAREN@6..7 "(" |
268 | R_PAREN@[7; 8) ")" | 265 | R_PAREN@7..8 ")" |
269 | WHITESPACE@[8; 9) " " | 266 | WHITESPACE@8..9 " " |
270 | BLOCK_EXPR@[9; 12) | 267 | BLOCK_EXPR@9..12 |
271 | BLOCK@[9; 12) | 268 | BLOCK@9..12 |
272 | L_CURLY@[9; 10) "{" | 269 | L_CURLY@9..10 "{" |
273 | WHITESPACE@[10; 11) "\n" | 270 | WHITESPACE@10..11 "\n" |
274 | R_CURLY@[11; 12) "}" | 271 | R_CURLY@11..12 "}" |
275 | "# | 272 | "# |
276 | .trim() | 273 | .trim() |
277 | ); | 274 | ); |
@@ -292,21 +289,21 @@ fn bar() { | |||
292 | assert_eq_text!( | 289 | assert_eq_text!( |
293 | syn.trim(), | 290 | syn.trim(), |
294 | r#" | 291 | r#" |
295 | SOURCE_FILE@[0; 12) | 292 | SOURCE_FILE@0..12 |
296 | FN_DEF@[0; 12) | 293 | FN_DEF@0..12 |
297 | FN_KW@[0; 2) "fn" | 294 | FN_KW@0..2 "fn" |
298 | WHITESPACE@[2; 3) " " | 295 | WHITESPACE@2..3 " " |
299 | NAME@[3; 6) | 296 | NAME@3..6 |
300 | IDENT@[3; 6) "foo" | 297 | IDENT@3..6 "foo" |
301 | PARAM_LIST@[6; 8) | 298 | PARAM_LIST@6..8 |
302 | L_PAREN@[6; 7) "(" | 299 | L_PAREN@6..7 "(" |
303 | R_PAREN@[7; 8) ")" | 300 | R_PAREN@7..8 ")" |
304 | WHITESPACE@[8; 9) " " | 301 | WHITESPACE@8..9 " " |
305 | BLOCK_EXPR@[9; 12) | 302 | BLOCK_EXPR@9..12 |
306 | BLOCK@[9; 12) | 303 | BLOCK@9..12 |
307 | L_CURLY@[9; 10) "{" | 304 | L_CURLY@9..10 "{" |
308 | WHITESPACE@[10; 11) "\n" | 305 | WHITESPACE@10..11 "\n" |
309 | R_CURLY@[11; 12) "}" | 306 | R_CURLY@11..12 "}" |
310 | "# | 307 | "# |
311 | .trim() | 308 | .trim() |
312 | ); | 309 | ); |
@@ -326,36 +323,36 @@ fn bar() { | |||
326 | assert_eq_text!( | 323 | assert_eq_text!( |
327 | syn.trim(), | 324 | syn.trim(), |
328 | r#" | 325 | r#" |
329 | SOURCE_FILE@[0; 25) | 326 | SOURCE_FILE@0..25 |
330 | FN_DEF@[0; 12) | 327 | FN_DEF@0..12 |
331 | FN_KW@[0; 2) "fn" | 328 | FN_KW@0..2 "fn" |
332 | WHITESPACE@[2; 3) " " | 329 | WHITESPACE@2..3 " " |
333 | NAME@[3; 6) | 330 | NAME@3..6 |
334 | IDENT@[3; 6) "foo" | 331 | IDENT@3..6 "foo" |
335 | PARAM_LIST@[6; 8) | 332 | PARAM_LIST@6..8 |
336 | L_PAREN@[6; 7) "(" | 333 | L_PAREN@6..7 "(" |
337 | R_PAREN@[7; 8) ")" | 334 | R_PAREN@7..8 ")" |
338 | WHITESPACE@[8; 9) " " | 335 | WHITESPACE@8..9 " " |
339 | BLOCK_EXPR@[9; 12) | 336 | BLOCK_EXPR@9..12 |
340 | BLOCK@[9; 12) | 337 | BLOCK@9..12 |
341 | L_CURLY@[9; 10) "{" | 338 | L_CURLY@9..10 "{" |
342 | WHITESPACE@[10; 11) "\n" | 339 | WHITESPACE@10..11 "\n" |
343 | R_CURLY@[11; 12) "}" | 340 | R_CURLY@11..12 "}" |
344 | WHITESPACE@[12; 13) "\n" | 341 | WHITESPACE@12..13 "\n" |
345 | FN_DEF@[13; 25) | 342 | FN_DEF@13..25 |
346 | FN_KW@[13; 15) "fn" | 343 | FN_KW@13..15 "fn" |
347 | WHITESPACE@[15; 16) " " | 344 | WHITESPACE@15..16 " " |
348 | NAME@[16; 19) | 345 | NAME@16..19 |
349 | IDENT@[16; 19) "bar" | 346 | IDENT@16..19 "bar" |
350 | PARAM_LIST@[19; 21) | 347 | PARAM_LIST@19..21 |
351 | L_PAREN@[19; 20) "(" | 348 | L_PAREN@19..20 "(" |
352 | R_PAREN@[20; 21) ")" | 349 | R_PAREN@20..21 ")" |
353 | WHITESPACE@[21; 22) " " | 350 | WHITESPACE@21..22 " " |
354 | BLOCK_EXPR@[22; 25) | 351 | BLOCK_EXPR@22..25 |
355 | BLOCK@[22; 25) | 352 | BLOCK@22..25 |
356 | L_CURLY@[22; 23) "{" | 353 | L_CURLY@22..23 "{" |
357 | WHITESPACE@[23; 24) "\n" | 354 | WHITESPACE@23..24 "\n" |
358 | R_CURLY@[24; 25) "}" | 355 | R_CURLY@24..25 "}" |
359 | "# | 356 | "# |
360 | .trim() | 357 | .trim() |
361 | ); | 358 | ); |
diff --git a/crates/ra_ide/src/test_utils.rs b/crates/ra_ide/src/test_utils.rs index 8adb214d4..f14533e14 100644 --- a/crates/ra_ide/src/test_utils.rs +++ b/crates/ra_ide/src/test_utils.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use ra_syntax::{SourceFile, TextUnit}; | 3 | use ra_syntax::{SourceFile, TextSize}; |
4 | use ra_text_edit::TextEdit; | 4 | use ra_text_edit::TextEdit; |
5 | 5 | ||
6 | pub use test_utils::*; | 6 | pub use test_utils::*; |
7 | 7 | ||
8 | pub fn check_action<F: Fn(&SourceFile, TextUnit) -> Option<TextEdit>>( | 8 | pub fn check_action<F: Fn(&SourceFile, TextSize) -> Option<TextEdit>>( |
9 | before: &str, | 9 | before: &str, |
10 | after: &str, | 10 | after: &str, |
11 | f: F, | 11 | f: F, |
diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index f55cd3bf5..2a8b4327f 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs | |||
@@ -21,7 +21,7 @@ use ra_ide_db::RootDatabase; | |||
21 | use ra_syntax::{ | 21 | use ra_syntax::{ |
22 | algo::find_node_at_offset, | 22 | algo::find_node_at_offset, |
23 | ast::{self, AstToken}, | 23 | ast::{self, AstToken}, |
24 | AstNode, SourceFile, TextRange, TextUnit, | 24 | AstNode, SourceFile, TextRange, TextSize, |
25 | }; | 25 | }; |
26 | use ra_text_edit::TextEdit; | 26 | use ra_text_edit::TextEdit; |
27 | 27 | ||
@@ -45,7 +45,7 @@ pub(crate) fn on_char_typed( | |||
45 | 45 | ||
46 | fn on_char_typed_inner( | 46 | fn on_char_typed_inner( |
47 | file: &SourceFile, | 47 | file: &SourceFile, |
48 | offset: TextUnit, | 48 | offset: TextSize, |
49 | char_typed: char, | 49 | char_typed: char, |
50 | ) -> Option<SingleFileChange> { | 50 | ) -> Option<SingleFileChange> { |
51 | assert!(TRIGGER_CHARS.contains(char_typed)); | 51 | assert!(TRIGGER_CHARS.contains(char_typed)); |
@@ -60,7 +60,7 @@ fn on_char_typed_inner( | |||
60 | /// Returns an edit which should be applied after `=` was typed. Primarily, | 60 | /// Returns an edit which should be applied after `=` was typed. Primarily, |
61 | /// this works when adding `let =`. | 61 | /// this works when adding `let =`. |
62 | // FIXME: use a snippet completion instead of this hack here. | 62 | // FIXME: use a snippet completion instead of this hack here. |
63 | fn on_eq_typed(file: &SourceFile, offset: TextUnit) -> Option<SingleFileChange> { | 63 | fn on_eq_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChange> { |
64 | assert_eq!(file.syntax().text().char_at(offset), Some('=')); | 64 | assert_eq!(file.syntax().text().char_at(offset), Some('=')); |
65 | let let_stmt: ast::LetStmt = find_node_at_offset(file.syntax(), offset)?; | 65 | let let_stmt: ast::LetStmt = find_node_at_offset(file.syntax(), offset)?; |
66 | if let_stmt.semicolon_token().is_some() { | 66 | if let_stmt.semicolon_token().is_some() { |
@@ -86,7 +86,7 @@ fn on_eq_typed(file: &SourceFile, offset: TextUnit) -> Option<SingleFileChange> | |||
86 | } | 86 | } |
87 | 87 | ||
88 | /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. | 88 | /// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately. |
89 | fn on_dot_typed(file: &SourceFile, offset: TextUnit) -> Option<SingleFileChange> { | 89 | fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChange> { |
90 | assert_eq!(file.syntax().text().char_at(offset), Some('.')); | 90 | assert_eq!(file.syntax().text().char_at(offset), Some('.')); |
91 | let whitespace = | 91 | let whitespace = |
92 | file.syntax().token_at_offset(offset).left_biased().and_then(ast::Whitespace::cast)?; | 92 | file.syntax().token_at_offset(offset).left_biased().and_then(ast::Whitespace::cast)?; |
@@ -96,34 +96,29 @@ fn on_dot_typed(file: &SourceFile, offset: TextUnit) -> Option<SingleFileChange> | |||
96 | let newline = text.rfind('\n')?; | 96 | let newline = text.rfind('\n')?; |
97 | &text[newline + 1..] | 97 | &text[newline + 1..] |
98 | }; | 98 | }; |
99 | let current_indent_len = TextUnit::of_str(current_indent); | 99 | let current_indent_len = TextSize::of(current_indent); |
100 | 100 | ||
101 | // Make sure dot is a part of call chain | 101 | // Make sure dot is a part of call chain |
102 | let field_expr = ast::FieldExpr::cast(whitespace.syntax().parent())?; | 102 | let field_expr = ast::FieldExpr::cast(whitespace.syntax().parent())?; |
103 | let prev_indent = leading_indent(field_expr.syntax())?; | 103 | let prev_indent = leading_indent(field_expr.syntax())?; |
104 | let target_indent = format!(" {}", prev_indent); | 104 | let target_indent = format!(" {}", prev_indent); |
105 | let target_indent_len = TextUnit::of_str(&target_indent); | 105 | let target_indent_len = TextSize::of(&target_indent); |
106 | if current_indent_len == target_indent_len { | 106 | if current_indent_len == target_indent_len { |
107 | return None; | 107 | return None; |
108 | } | 108 | } |
109 | 109 | ||
110 | Some(SingleFileChange { | 110 | Some(SingleFileChange { |
111 | label: "reindent dot".to_string(), | 111 | label: "reindent dot".to_string(), |
112 | edit: TextEdit::replace( | 112 | edit: TextEdit::replace(TextRange::new(offset - current_indent_len, offset), target_indent), |
113 | TextRange::from_to(offset - current_indent_len, offset), | 113 | cursor_position: Some(offset + target_indent_len - current_indent_len + TextSize::of('.')), |
114 | target_indent, | ||
115 | ), | ||
116 | cursor_position: Some( | ||
117 | offset + target_indent_len - current_indent_len + TextUnit::of_char('.'), | ||
118 | ), | ||
119 | }) | 114 | }) |
120 | } | 115 | } |
121 | 116 | ||
122 | /// Adds a space after an arrow when `fn foo() { ... }` is turned into `fn foo() -> { ... }` | 117 | /// Adds a space after an arrow when `fn foo() { ... }` is turned into `fn foo() -> { ... }` |
123 | fn on_arrow_typed(file: &SourceFile, offset: TextUnit) -> Option<SingleFileChange> { | 118 | fn on_arrow_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChange> { |
124 | let file_text = file.syntax().text(); | 119 | let file_text = file.syntax().text(); |
125 | assert_eq!(file_text.char_at(offset), Some('>')); | 120 | assert_eq!(file_text.char_at(offset), Some('>')); |
126 | let after_arrow = offset + TextUnit::of_char('>'); | 121 | let after_arrow = offset + TextSize::of('>'); |
127 | if file_text.char_at(after_arrow) != Some('{') { | 122 | if file_text.char_at(after_arrow) != Some('{') { |
128 | return None; | 123 | return None; |
129 | } | 124 | } |
diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index 6bcf2d72b..30c8c5572 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs | |||
@@ -7,7 +7,7 @@ use ra_syntax::{ | |||
7 | ast::{self, AstToken}, | 7 | ast::{self, AstToken}, |
8 | AstNode, SmolStr, SourceFile, | 8 | AstNode, SmolStr, SourceFile, |
9 | SyntaxKind::*, | 9 | SyntaxKind::*, |
10 | SyntaxToken, TextUnit, TokenAtOffset, | 10 | SyntaxToken, TextSize, TokenAtOffset, |
11 | }; | 11 | }; |
12 | use ra_text_edit::TextEdit; | 12 | use ra_text_edit::TextEdit; |
13 | 13 | ||
@@ -28,7 +28,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour | |||
28 | 28 | ||
29 | let prefix = comment.prefix(); | 29 | let prefix = comment.prefix(); |
30 | let comment_range = comment.syntax().text_range(); | 30 | let comment_range = comment.syntax().text_range(); |
31 | if position.offset < comment_range.start() + TextUnit::of_str(prefix) { | 31 | if position.offset < comment_range.start() + TextSize::of(prefix) { |
32 | return None; | 32 | return None; |
33 | } | 33 | } |
34 | 34 | ||
@@ -39,7 +39,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour | |||
39 | 39 | ||
40 | let indent = node_indent(&file, comment.syntax())?; | 40 | let indent = node_indent(&file, comment.syntax())?; |
41 | let inserted = format!("\n{}{} ", indent, prefix); | 41 | let inserted = format!("\n{}{} ", indent, prefix); |
42 | let cursor_position = position.offset + TextUnit::of_str(&inserted); | 42 | let cursor_position = position.offset + TextSize::of(&inserted); |
43 | let edit = TextEdit::insert(position.offset, inserted); | 43 | let edit = TextEdit::insert(position.offset, inserted); |
44 | 44 | ||
45 | Some( | 45 | Some( |