aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/complete_postfix.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/completion/complete_postfix.rs')
-rw-r--r--crates/ra_ide/src/completion/complete_postfix.rs134
1 files changed, 67 insertions, 67 deletions
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
3use ra_syntax::{ 3use ra_syntax::{
4 ast::{self, AstNode}, 4 ast::{self, AstNode},
5 TextRange, TextUnit, 5 TextRange, TextSize,
6}; 6};
7use ra_text_edit::TextEdit; 7use ra_text_edit::TextEdit;
8 8
@@ -115,7 +115,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
115fn get_receiver_text(receiver: &ast::Expr, receiver_is_ambiguous_float_literal: bool) -> String { 115fn 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 },