diff options
author | Edwin Cheng <[email protected]> | 2020-02-27 02:06:48 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-02-27 02:06:48 +0000 |
commit | 61fd6c6270f9ebc37f4156ae1a4d41053a78cdb1 (patch) | |
tree | 714d8787e9f26bf2e57aaf6bd1aa14d70f6abde0 /crates/ra_hir/src | |
parent | 05388b4ea46c886fa4ec8a1d49b71eb816cf7c6d (diff) |
Use text_range::extend_to
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/semantics.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 5b0b94e34..c3d8ee1ae 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs | |||
@@ -388,7 +388,7 @@ fn original_range_and_origin( | |||
388 | let single = skip_trivia_token(node.value.first_token()?, Direction::Next)? | 388 | let single = skip_trivia_token(node.value.first_token()?, Direction::Next)? |
389 | == skip_trivia_token(node.value.last_token()?, Direction::Prev)?; | 389 | == skip_trivia_token(node.value.last_token()?, Direction::Prev)?; |
390 | 390 | ||
391 | return Some(node.value.descendants().find_map(|it| { | 391 | Some(node.value.descendants().find_map(|it| { |
392 | let first = skip_trivia_token(it.first_token()?, Direction::Next)?; | 392 | let first = skip_trivia_token(it.first_token()?, Direction::Next)?; |
393 | let last = skip_trivia_token(it.last_token()?, Direction::Prev)?; | 393 | let last = skip_trivia_token(it.last_token()?, Direction::Prev)?; |
394 | 394 | ||
@@ -404,16 +404,9 @@ fn original_range_and_origin( | |||
404 | return None; | 404 | return None; |
405 | } | 405 | } |
406 | 406 | ||
407 | // FIXME: Add union method in TextRange | ||
408 | Some(( | 407 | Some(( |
409 | first.with_value(union_range(first.value.text_range(), last.value.text_range())), | 408 | first.with_value(first.value.text_range().extend_to(&last.value.text_range())), |
410 | first_origin, | 409 | first_origin, |
411 | )) | 410 | )) |
412 | })?); | 411 | })?) |
413 | |||
414 | fn union_range(a: TextRange, b: TextRange) -> TextRange { | ||
415 | let start = a.start().min(b.start()); | ||
416 | let end = a.end().max(b.end()); | ||
417 | TextRange::from_to(start, end) | ||
418 | } | ||
419 | } | 412 | } |