aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists/add_derive.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/assists/add_derive.rs')
-rw-r--r--crates/ra_assists/src/assists/add_derive.rs18
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
3use hir::db::HirDatabase; 1use hir::db::HirDatabase;
4use ra_syntax::{ 2use ra_syntax::{
5 ast::{self, AstNode, AttrsOwner}, 3 ast::{self, AstNode, AttrsOwner},
@@ -9,6 +7,22 @@ use ra_syntax::{
9 7
10use crate::{Assist, AssistCtx, AssistId}; 8use 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// ```
12pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 26pub(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)?;