aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-10-27 14:50:27 +0000
committerGitHub <[email protected]>2019-10-27 14:50:27 +0000
commitf6588b86768fe426ff85dd0c5c838193a8f27d48 (patch)
tree97e3213d449e6237d1a20f99e9e82ede19215b20 /crates/ra_assists/src/assists
parentcf309b6a5f2d51e9509568ab82446cc3eae29f94 (diff)
parentb6fcacd96d26e7edaf37bda852b8b3ad104d4c90 (diff)
Merge #2095
2095: move all assists to use generated 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_import.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/add_import.rs b/crates/ra_assists/src/assists/add_import.rs
index c522d6a5a..e87fae1af 100644
--- a/crates/ra_assists/src/assists/add_import.rs
+++ b/crates/ra_assists/src/assists/add_import.rs
@@ -1,5 +1,3 @@
1//! FIXME: write short doc here
2
3use hir::{self, db::HirDatabase}; 1use hir::{self, db::HirDatabase};
4use ra_syntax::{ 2use ra_syntax::{
5 ast::{self, NameOwner}, 3 ast::{self, NameOwner},
@@ -14,9 +12,9 @@ use crate::{
14 AssistId, 12 AssistId,
15}; 13};
16 14
17// This function produces sequence of text edits into edit 15/// This function produces sequence of text edits into edit
18// to import the target path in the most appropriate scope given 16/// to import the target path in the most appropriate scope given
19// the cursor position 17/// the cursor position
20pub fn auto_import_text_edit( 18pub fn auto_import_text_edit(
21 // Ideally the position of the cursor, used to 19 // Ideally the position of the cursor, used to
22 position: &SyntaxNode, 20 position: &SyntaxNode,
@@ -39,6 +37,19 @@ pub fn auto_import_text_edit(
39 } 37 }
40} 38}
41 39
40// Assist: add_import
41//
42// Adds a use statement for a given fully-qualified path.
43//
44// ```
45// fn process(map: std::collections::<|>HashMap<String, String>) {}
46// ```
47// ->
48// ```
49// use std::collections::HashMap;
50//
51// fn process(map: HashMap<String, String>) {}
52// ```
42pub(crate) fn add_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 53pub(crate) fn add_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
43 let path: ast::Path = ctx.find_node_at_offset()?; 54 let path: ast::Path = ctx.find_node_at_offset()?;
44 // We don't want to mess with use statements 55 // We don't want to mess with use statements