diff options
Diffstat (limited to 'crates/ra_assists/src/assists/add_derive.rs')
-rw-r--r-- | crates/ra_assists/src/assists/add_derive.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_assists/src/assists/add_derive.rs b/crates/ra_assists/src/assists/add_derive.rs index 77ecc33c9..d3ba634c4 100644 --- a/crates/ra_assists/src/assists/add_derive.rs +++ b/crates/ra_assists/src/assists/add_derive.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
4 | use ra_syntax::{ | 2 | use ra_syntax::{ |
5 | ast::{self, AstNode, AttrsOwner}, | 3 | ast::{self, AstNode, AttrsOwner}, |
@@ -9,6 +7,22 @@ use ra_syntax::{ | |||
9 | 7 | ||
10 | use crate::{Assist, AssistCtx, AssistId}; | 8 | use crate::{Assist, AssistCtx, AssistId}; |
11 | 9 | ||
10 | // Assist: add_derive | ||
11 | // Adds a new `#[derive()]` clause to a struct or enum. | ||
12 | // ``` | ||
13 | // struct Point { | ||
14 | // x: u32, | ||
15 | // y: u32,<|> | ||
16 | // } | ||
17 | // ``` | ||
18 | // -> | ||
19 | // ``` | ||
20 | // #[derive()] | ||
21 | // struct Point { | ||
22 | // x: u32, | ||
23 | // y: u32, | ||
24 | // } | ||
25 | // ``` | ||
12 | pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 26 | pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
13 | let nominal = ctx.node_at_offset::<ast::NominalDef>()?; | 27 | let nominal = ctx.node_at_offset::<ast::NominalDef>()?; |
14 | let node_start = derive_insertion_offset(&nominal)?; | 28 | let node_start = derive_insertion_offset(&nominal)?; |