diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-25 11:16:02 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-25 11:16:02 +0100 |
commit | 29fc409e7fe5b12dcf6bfbcca622d79c4c8fcb72 (patch) | |
tree | e42f7bd1490bca66e0786d5bf2b3194aeaa57a93 /crates/ra_assists/src/handlers/add_derive.rs | |
parent | 27a7718880d93f55f905da606d108d3b3c682ab4 (diff) | |
parent | e87346950039a54c3f0b02d6056cbb92ca38eb28 (diff) |
Merge #4131
4131: Switch to text-size r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/handlers/add_derive.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/add_derive.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_assists/src/handlers/add_derive.rs b/crates/ra_assists/src/handlers/add_derive.rs index b0d1a0a80..6254eb7c4 100644 --- a/crates/ra_assists/src/handlers/add_derive.rs +++ b/crates/ra_assists/src/handlers/add_derive.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode, AttrsOwner}, | 2 | ast::{self, AstNode, AttrsOwner}, |
3 | SyntaxKind::{COMMENT, WHITESPACE}, | 3 | SyntaxKind::{COMMENT, WHITESPACE}, |
4 | TextUnit, | 4 | TextSize, |
5 | }; | 5 | }; |
6 | 6 | ||
7 | use crate::{Assist, AssistCtx, AssistId}; | 7 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -37,9 +37,9 @@ pub(crate) fn add_derive(ctx: AssistCtx) -> Option<Assist> { | |||
37 | let offset = match derive_attr { | 37 | let offset = match derive_attr { |
38 | None => { | 38 | None => { |
39 | edit.insert(node_start, "#[derive()]\n"); | 39 | edit.insert(node_start, "#[derive()]\n"); |
40 | node_start + TextUnit::of_str("#[derive(") | 40 | node_start + TextSize::of("#[derive(") |
41 | } | 41 | } |
42 | Some(tt) => tt.syntax().text_range().end() - TextUnit::of_char(')'), | 42 | Some(tt) => tt.syntax().text_range().end() - TextSize::of(')'), |
43 | }; | 43 | }; |
44 | edit.target(nominal.syntax().text_range()); | 44 | edit.target(nominal.syntax().text_range()); |
45 | edit.set_cursor(offset) | 45 | edit.set_cursor(offset) |
@@ -47,7 +47,7 @@ pub(crate) fn add_derive(ctx: AssistCtx) -> Option<Assist> { | |||
47 | } | 47 | } |
48 | 48 | ||
49 | // Insert `derive` after doc comments. | 49 | // Insert `derive` after doc comments. |
50 | fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option<TextUnit> { | 50 | fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option<TextSize> { |
51 | let non_ws_child = nominal | 51 | let non_ws_child = nominal |
52 | .syntax() | 52 | .syntax() |
53 | .children_with_tokens() | 53 | .children_with_tokens() |