mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Run cargo fmt
This commit is contained in:
parent
bb00b09d22
commit
c8820d342f
2 changed files with 23 additions and 14 deletions
|
@ -1,8 +1,14 @@
|
|||
use hir::{ItemInNs, ModuleDef};
|
||||
use ide_db::{assists::{AssistId, AssistKind}, helpers::import_assets::item_for_path_search};
|
||||
use syntax::{AstNode, ast};
|
||||
use ide_db::{
|
||||
assists::{AssistId, AssistKind},
|
||||
helpers::import_assets::item_for_path_search,
|
||||
};
|
||||
use syntax::{ast, AstNode};
|
||||
|
||||
use crate::{assist_context::{AssistContext, Assists}, handlers::qualify_path::QualifyCandidate};
|
||||
use crate::{
|
||||
assist_context::{AssistContext, Assists},
|
||||
handlers::qualify_path::QualifyCandidate,
|
||||
};
|
||||
|
||||
// Assist: qualify_method_call
|
||||
//
|
||||
|
@ -40,7 +46,8 @@ pub(crate) fn qualify_method_call(acc: &mut Assists, ctx: &AssistContext) -> Opt
|
|||
let current_module = ctx.sema.scope(&call.syntax()).module()?;
|
||||
let target_module_def = ModuleDef::from(resolved_call);
|
||||
let item_in_ns = ItemInNs::from(target_module_def);
|
||||
let receiver_path = current_module.find_use_path(ctx.sema.db, item_for_path_search(ctx.sema.db, item_in_ns)?)?;
|
||||
let receiver_path = current_module
|
||||
.find_use_path(ctx.sema.db, item_for_path_search(ctx.sema.db, item_in_ns)?)?;
|
||||
|
||||
let qualify_candidate = QualifyCandidate::ImplMethod(ctx.sema.db, call, resolved_call);
|
||||
|
||||
|
@ -52,17 +59,17 @@ pub(crate) fn qualify_method_call(acc: &mut Assists, ctx: &AssistContext) -> Opt
|
|||
qualify_candidate.qualify(
|
||||
|replace_with: String| builder.replace(range, replace_with),
|
||||
&receiver_path,
|
||||
item_in_ns
|
||||
item_in_ns,
|
||||
)
|
||||
}
|
||||
},
|
||||
);
|
||||
Some(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tests::{check_assist};
|
||||
use super::*;
|
||||
use crate::tests::check_assist;
|
||||
|
||||
#[test]
|
||||
fn struct_method() {
|
||||
|
@ -478,4 +485,3 @@ fn main() {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
use std::iter;
|
||||
|
||||
use hir::AsAssocItem;
|
||||
use ide_db::helpers::{import_assets::{ImportCandidate, LocatedImport}, mod_path_to_ast};
|
||||
use ide_db::helpers::{
|
||||
import_assets::{ImportCandidate, LocatedImport},
|
||||
mod_path_to_ast,
|
||||
};
|
||||
use ide_db::RootDatabase;
|
||||
use syntax::{
|
||||
ast,
|
||||
|
|
Loading…
Reference in a new issue