aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/auto_import.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-20 10:59:10 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-20 10:59:10 +0100
commit6b352ffeb346eb7c7e46e00e790c2f395907eaa6 (patch)
treef19271365126259a7975dda9ee3e1e1496a299dd /crates/ra_assists/src/auto_import.rs
parent2830d1376b05794c7bf1467fe52ad3bc0eb4ca41 (diff)
parentf3bdbec1b68fa0e20f0b7b6c6ef64e1507970b0d (diff)
Merge #1560
1560: move debug_dump to fmt::Debug r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/auto_import.rs')
-rw-r--r--crates/ra_assists/src/auto_import.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs
index 0eb4bdb62..43e75eee1 100644
--- a/crates/ra_assists/src/auto_import.rs
+++ b/crates/ra_assists/src/auto_import.rs
@@ -356,7 +356,7 @@ fn best_action_for_target(
356 // todo: we should include even whitespace blocks as anchor candidates 356 // todo: we should include even whitespace blocks as anchor candidates
357 let anchor = container 357 let anchor = container
358 .children() 358 .children()
359 .find(|n| n.range().start() < anchor.range().start()) 359 .find(|n| n.text_range().start() < anchor.text_range().start())
360 .or_else(|| Some(anchor)); 360 .or_else(|| Some(anchor));
361 361
362 ImportAction::add_new_use(anchor, false) 362 ImportAction::add_new_use(anchor, false)
@@ -418,7 +418,7 @@ fn make_assist_add_new_use(
418 buf.push_str(&spaces); 418 buf.push_str(&spaces);
419 } 419 }
420 } 420 }
421 let position = if after { anchor.range().end() } else { anchor.range().start() }; 421 let position = if after { anchor.text_range().end() } else { anchor.text_range().start() };
422 edit.insert(position, buf); 422 edit.insert(position, buf);
423 } 423 }
424} 424}
@@ -434,10 +434,10 @@ fn make_assist_add_in_tree_list(
434 let mut buf = String::new(); 434 let mut buf = String::new();
435 let comma = last.syntax().siblings(Direction::Next).find(|n| n.kind() == T![,]); 435 let comma = last.syntax().siblings(Direction::Next).find(|n| n.kind() == T![,]);
436 let offset = if let Some(comma) = comma { 436 let offset = if let Some(comma) = comma {
437 comma.range().end() 437 comma.text_range().end()
438 } else { 438 } else {
439 buf.push_str(","); 439 buf.push_str(",");
440 last.syntax().range().end() 440 last.syntax().text_range().end()
441 }; 441 };
442 if add_self { 442 if add_self {
443 buf.push_str(" self") 443 buf.push_str(" self")
@@ -462,11 +462,11 @@ fn make_assist_add_nested_import(
462 if let Some(use_tree) = use_tree { 462 if let Some(use_tree) = use_tree {
463 let (start, add_colon_colon) = if let Some(first_segment_to_split) = first_segment_to_split 463 let (start, add_colon_colon) = if let Some(first_segment_to_split) = first_segment_to_split
464 { 464 {
465 (first_segment_to_split.syntax().range().start(), false) 465 (first_segment_to_split.syntax().text_range().start(), false)
466 } else { 466 } else {
467 (use_tree.syntax().range().end(), true) 467 (use_tree.syntax().text_range().end(), true)
468 }; 468 };
469 let end = use_tree.syntax().range().end(); 469 let end = use_tree.syntax().text_range().end();
470 470
471 let mut buf = String::new(); 471 let mut buf = String::new();
472 if add_colon_colon { 472 if add_colon_colon {
@@ -497,8 +497,8 @@ fn apply_auto_import(
497 // Here we are assuming the assist will provide a correct use statement 497 // Here we are assuming the assist will provide a correct use statement
498 // so we can delete the path qualifier 498 // so we can delete the path qualifier
499 edit.delete(TextRange::from_to( 499 edit.delete(TextRange::from_to(
500 path.syntax().range().start(), 500 path.syntax().text_range().start(),
501 last.syntax().range().start(), 501 last.syntax().text_range().start(),
502 )); 502 ));
503 } 503 }
504} 504}