From d385438bcc8d302fbcb91114e19ac0cc30528822 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 25 Oct 2019 23:38:15 +0300 Subject: generate more assists docs --- crates/ra_assists/src/assists/apply_demorgan.rs | 26 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'crates/ra_assists/src/assists/apply_demorgan.rs') diff --git a/crates/ra_assists/src/assists/apply_demorgan.rs b/crates/ra_assists/src/assists/apply_demorgan.rs index 5f2b0dd18..a072f63e7 100644 --- a/crates/ra_assists/src/assists/apply_demorgan.rs +++ b/crates/ra_assists/src/assists/apply_demorgan.rs @@ -1,18 +1,26 @@ -//! This contains the functions associated with the demorgan assist. -//! This assist transforms boolean expressions of the form `!a || !b` into -//! `!(a && b)`. use hir::db::HirDatabase; use ra_syntax::ast::{self, AstNode}; use ra_syntax::SyntaxNode; use crate::{Assist, AssistCtx, AssistId}; -/// Assist for applying demorgan's law -/// -/// This transforms expressions of the form `!l || !r` into `!(l && r)`. -/// This also works with `&&`. This assist can only be applied with the cursor -/// on either `||` or `&&`, with both operands being a negation of some kind. -/// This means something of the form `!x` or `x != y`. +// Assist: apply_demorgan +// Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). +// This transforms expressions of the form `!l || !r` into `!(l && r)`. +// This also works with `&&`. This assist can only be applied with the cursor +// on either `||` or `&&`, with both operands being a negation of some kind. +// This means something of the form `!x` or `x != y`. +// ``` +// fn main() { +// if x != 4 ||<|> !y {} +// } +// ``` +// -> +// ``` +// fn main() { +// if !(x == 4 && y) {} +// } +// ``` pub(crate) fn apply_demorgan(mut ctx: AssistCtx) -> Option { let expr = ctx.node_at_offset::()?; let op = expr.op_kind()?; -- cgit v1.2.3