Minor
This commit is contained in:
parent
9b2bd022dc
commit
45e343a0ef
3 changed files with 10 additions and 5 deletions
|
@ -50,7 +50,12 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
|
|||
format!("Import `{}`", &import),
|
||||
range,
|
||||
|builder| {
|
||||
insert_use_statement(&auto_import_assets.syntax_under_caret, &import, ctx, builder);
|
||||
insert_use_statement(
|
||||
&auto_import_assets.syntax_under_caret,
|
||||
&import,
|
||||
ctx,
|
||||
builder.text_edit_builder(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ pub(crate) fn replace_qualified_name_with_use(
|
|||
target,
|
||||
|builder| {
|
||||
let path_to_import = hir_path.mod_path().clone();
|
||||
insert_use_statement(path.syntax(), &path_to_import, ctx, builder);
|
||||
insert_use_statement(path.syntax(), &path_to_import, ctx, builder.text_edit_builder());
|
||||
|
||||
if let Some(last) = path.segment() {
|
||||
// Here we are assuming the assist will provide a correct use statement
|
||||
|
|
|
@ -11,7 +11,7 @@ use ra_syntax::{
|
|||
};
|
||||
use ra_text_edit::TextEditBuilder;
|
||||
|
||||
use crate::assist_context::{AssistBuilder, AssistContext};
|
||||
use crate::assist_context::AssistContext;
|
||||
|
||||
/// Creates and inserts a use statement for the given path to import.
|
||||
/// The use statement is inserted in the scope most appropriate to the
|
||||
|
@ -21,7 +21,7 @@ pub(crate) fn insert_use_statement(
|
|||
position: &SyntaxNode,
|
||||
path_to_import: &ModPath,
|
||||
ctx: &AssistContext,
|
||||
builder: &mut AssistBuilder,
|
||||
builder: &mut TextEditBuilder,
|
||||
) {
|
||||
let target = path_to_import.to_string().split("::").map(SmolStr::new).collect::<Vec<_>>();
|
||||
let container = ctx.sema.ancestors_with_macros(position.clone()).find_map(|n| {
|
||||
|
@ -33,7 +33,7 @@ pub(crate) fn insert_use_statement(
|
|||
|
||||
if let Some(container) = container {
|
||||
let action = best_action_for_target(container, position.clone(), &target);
|
||||
make_assist(&action, &target, builder.text_edit_builder());
|
||||
make_assist(&action, &target, builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue