diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-26 17:12:17 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-26 17:12:17 +0100 |
commit | 568ef921acb8d35eed434089c1b1947c585c3f4c (patch) | |
tree | a3dfa55e7fadcb7e7e8299ce03d9f7beaee4a79b /crates/ra_assists/src/assists | |
parent | 2f7d1f10c1614d9448604da5c105b75c43cc6f2b (diff) | |
parent | a5cbd8d5e8aca0d0d8dde175ba13bfa995a753c0 (diff) |
Merge #2077
2077: check style for assist docs r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/assists')
-rw-r--r-- | crates/ra_assists/src/assists/add_explicit_type.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/assists/add_impl.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/assists/add_missing_impl_members.rs | 6 | ||||
-rw-r--r-- | crates/ra_assists/src/assists/early_return.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/assists/flip_binexpr.rs | 18 | ||||
-rw-r--r-- | crates/ra_assists/src/assists/flip_comma.rs | 17 | ||||
-rw-r--r-- | crates/ra_assists/src/assists/inline_local_variable.rs | 18 |
7 files changed, 54 insertions, 11 deletions
diff --git a/crates/ra_assists/src/assists/add_explicit_type.rs b/crates/ra_assists/src/assists/add_explicit_type.rs index 302b95579..2903c1781 100644 --- a/crates/ra_assists/src/assists/add_explicit_type.rs +++ b/crates/ra_assists/src/assists/add_explicit_type.rs | |||
@@ -8,7 +8,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
8 | 8 | ||
9 | // Assist: add_explicit_type | 9 | // Assist: add_explicit_type |
10 | // | 10 | // |
11 | // Specify type for a let binding | 11 | // Specify type for a let binding. |
12 | // | 12 | // |
13 | // ``` | 13 | // ``` |
14 | // fn main() { | 14 | // fn main() { |
diff --git a/crates/ra_assists/src/assists/add_impl.rs b/crates/ra_assists/src/assists/add_impl.rs index 43aeac7bd..142777b06 100644 --- a/crates/ra_assists/src/assists/add_impl.rs +++ b/crates/ra_assists/src/assists/add_impl.rs | |||
@@ -10,7 +10,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
10 | 10 | ||
11 | // Assist: add_impl | 11 | // Assist: add_impl |
12 | // | 12 | // |
13 | // Adds a new inherent impl for a type | 13 | // Adds a new inherent impl for a type. |
14 | // | 14 | // |
15 | // ``` | 15 | // ``` |
16 | // struct Ctx<T: Clone> { | 16 | // struct Ctx<T: Clone> { |
diff --git a/crates/ra_assists/src/assists/add_missing_impl_members.rs b/crates/ra_assists/src/assists/add_missing_impl_members.rs index fe1f2e72e..4ee4d47fa 100644 --- a/crates/ra_assists/src/assists/add_missing_impl_members.rs +++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs | |||
@@ -14,7 +14,7 @@ enum AddMissingImplMembersMode { | |||
14 | 14 | ||
15 | // Assist: add_impl_missing_members | 15 | // Assist: add_impl_missing_members |
16 | // | 16 | // |
17 | // Adds scaffold for required impl members | 17 | // Adds scaffold for required impl members. |
18 | // | 18 | // |
19 | // ``` | 19 | // ``` |
20 | // trait T { | 20 | // trait T { |
@@ -50,7 +50,9 @@ pub(crate) fn add_missing_impl_members(ctx: AssistCtx<impl HirDatabase>) -> Opti | |||
50 | } | 50 | } |
51 | 51 | ||
52 | // Assist: add_impl_default_members | 52 | // Assist: add_impl_default_members |
53 | // Adds scaffold for overriding default impl members | 53 | // |
54 | // Adds scaffold for overriding default impl members. | ||
55 | // | ||
54 | // ``` | 56 | // ``` |
55 | // trait T { | 57 | // trait T { |
56 | // Type X; | 58 | // Type X; |
diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs index b3d025340..48782db42 100644 --- a/crates/ra_assists/src/assists/early_return.rs +++ b/crates/ra_assists/src/assists/early_return.rs | |||
@@ -14,7 +14,9 @@ use crate::{ | |||
14 | }; | 14 | }; |
15 | 15 | ||
16 | // Assist: convert_to_guarded_return | 16 | // Assist: convert_to_guarded_return |
17 | // | ||
17 | // Replace a large conditional with a guarded return. | 18 | // Replace a large conditional with a guarded return. |
19 | // | ||
18 | // ``` | 20 | // ``` |
19 | // fn main() { | 21 | // fn main() { |
20 | // <|>if cond { | 22 | // <|>if cond { |
diff --git a/crates/ra_assists/src/assists/flip_binexpr.rs b/crates/ra_assists/src/assists/flip_binexpr.rs index c51035282..3a1e5cbe1 100644 --- a/crates/ra_assists/src/assists/flip_binexpr.rs +++ b/crates/ra_assists/src/assists/flip_binexpr.rs | |||
@@ -1,11 +1,23 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
4 | use ra_syntax::ast::{AstNode, BinExpr, BinOp}; | 2 | use ra_syntax::ast::{AstNode, BinExpr, BinOp}; |
5 | 3 | ||
6 | use crate::{Assist, AssistCtx, AssistId}; | 4 | use crate::{Assist, AssistCtx, AssistId}; |
7 | 5 | ||
8 | /// Flip binary expression assist. | 6 | // Assist: flip_binexpr |
7 | // | ||
8 | // Flips operands of a binary expression. | ||
9 | // | ||
10 | // ``` | ||
11 | // fn main() { | ||
12 | // let _ = 90 +<|> 2; | ||
13 | // } | ||
14 | // ``` | ||
15 | // -> | ||
16 | // ``` | ||
17 | // fn main() { | ||
18 | // let _ = 2 + 90; | ||
19 | // } | ||
20 | // ``` | ||
9 | pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 21 | pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
10 | let expr = ctx.node_at_offset::<BinExpr>()?; | 22 | let expr = ctx.node_at_offset::<BinExpr>()?; |
11 | let lhs = expr.lhs()?.syntax().clone(); | 23 | let lhs = expr.lhs()?.syntax().clone(); |
diff --git a/crates/ra_assists/src/assists/flip_comma.rs b/crates/ra_assists/src/assists/flip_comma.rs index e31cc5e7d..d06c5a0e1 100644 --- a/crates/ra_assists/src/assists/flip_comma.rs +++ b/crates/ra_assists/src/assists/flip_comma.rs | |||
@@ -1,10 +1,23 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
4 | use ra_syntax::{algo::non_trivia_sibling, Direction, T}; | 2 | use ra_syntax::{algo::non_trivia_sibling, Direction, T}; |
5 | 3 | ||
6 | use crate::{Assist, AssistCtx, AssistId}; | 4 | use crate::{Assist, AssistCtx, AssistId}; |
7 | 5 | ||
6 | // Assist: flip_comma | ||
7 | // | ||
8 | // Flips two comma-separated items. | ||
9 | // | ||
10 | // ``` | ||
11 | // fn main() { | ||
12 | // ((1, 2),<|> (3, 4)); | ||
13 | // } | ||
14 | // ``` | ||
15 | // -> | ||
16 | // ``` | ||
17 | // fn main() { | ||
18 | // ((3, 4), (1, 2)); | ||
19 | // } | ||
20 | // ``` | ||
8 | pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 21 | pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
9 | let comma = ctx.token_at_offset().find(|leaf| leaf.kind() == T![,])?; | 22 | let comma = ctx.token_at_offset().find(|leaf| leaf.kind() == T![,])?; |
10 | let prev = non_trivia_sibling(comma.clone().into(), Direction::Prev)?; | 23 | let prev = non_trivia_sibling(comma.clone().into(), Direction::Prev)?; |
diff --git a/crates/ra_assists/src/assists/inline_local_variable.rs b/crates/ra_assists/src/assists/inline_local_variable.rs index 9bd64decc..1997781db 100644 --- a/crates/ra_assists/src/assists/inline_local_variable.rs +++ b/crates/ra_assists/src/assists/inline_local_variable.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, AstToken}, | 3 | ast::{self, AstNode, AstToken}, |
@@ -9,6 +7,22 @@ use ra_syntax::{ | |||
9 | use crate::assist_ctx::AssistBuilder; | 7 | use crate::assist_ctx::AssistBuilder; |
10 | use crate::{Assist, AssistCtx, AssistId}; | 8 | use crate::{Assist, AssistCtx, AssistId}; |
11 | 9 | ||
10 | // Assist: inline_local_variable | ||
11 | // | ||
12 | // Inlines local variable. | ||
13 | // | ||
14 | // ``` | ||
15 | // fn main() { | ||
16 | // let x<|> = 1 + 2; | ||
17 | // x * 4; | ||
18 | // } | ||
19 | // ``` | ||
20 | // -> | ||
21 | // ``` | ||
22 | // fn main() { | ||
23 | // (1 + 2) * 4; | ||
24 | // } | ||
25 | // ``` | ||
12 | pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 26 | pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
13 | let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?; | 27 | let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?; |
14 | let bind_pat = match let_stmt.pat()? { | 28 | let bind_pat = match let_stmt.pat()? { |