From 3126152a84e08a80659d49d735d03628154564ed Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Oct 2019 17:37:04 +0300 Subject: document a couple of assists --- crates/ra_assists/src/assists/change_visibility.rs | 13 ++++++++++-- crates/ra_assists/src/assists/fill_match_arms.rs | 24 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) (limited to 'crates/ra_assists/src/assists') diff --git a/crates/ra_assists/src/assists/change_visibility.rs b/crates/ra_assists/src/assists/change_visibility.rs index df92c6b67..88118cdf7 100644 --- a/crates/ra_assists/src/assists/change_visibility.rs +++ b/crates/ra_assists/src/assists/change_visibility.rs @@ -1,5 +1,3 @@ -//! FIXME: write short doc here - use hir::db::HirDatabase; use ra_syntax::{ ast::{self, NameOwner, VisibilityOwner}, @@ -13,6 +11,17 @@ use ra_syntax::{ use crate::{Assist, AssistCtx, AssistId}; +// Assist: change_visibility +// +// Adds or changes existing visibility specifier. +// +// ``` +// fn<|> frobnicate() {} +// ``` +// -> +// ``` +// pub(crate) fn frobnicate() {} +// ``` pub(crate) fn change_visibility(ctx: AssistCtx) -> Option { if let Some(vis) = ctx.node_at_offset::() { return change_vis(ctx, vis); diff --git a/crates/ra_assists/src/assists/fill_match_arms.rs b/crates/ra_assists/src/assists/fill_match_arms.rs index e3f30b5de..13b98d033 100644 --- a/crates/ra_assists/src/assists/fill_match_arms.rs +++ b/crates/ra_assists/src/assists/fill_match_arms.rs @@ -7,6 +7,30 @@ use ra_syntax::ast::{self, edit::IndentLevel, make, AstNode, NameOwner}; use crate::{Assist, AssistCtx, AssistId}; +// Assist: fill_match_arms +// +// Adds missing clauses to a `match` expression. +// +// ``` +// enum Action { Move { distance: u32 }, Stop } +// +// fn handle(action: Action) { +// match action { +// <|> +// } +// } +// ``` +// -> +// ``` +// enum Action { Move { distance: u32 }, Stop } +// +// fn handle(action: Action) { +// match action { +// Action::Move{ distance } => (), +// Action::Stop => (), +// } +// } +// ``` pub(crate) fn fill_match_arms(mut ctx: AssistCtx) -> Option { let match_expr = ctx.node_at_offset::()?; let match_arm_list = match_expr.match_arm_list()?; -- cgit v1.2.3