mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +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 hir::{ItemInNs, ModuleDef};
|
||||||
use ide_db::{assists::{AssistId, AssistKind}, helpers::import_assets::item_for_path_search};
|
use ide_db::{
|
||||||
use syntax::{AstNode, ast};
|
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
|
// 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 current_module = ctx.sema.scope(&call.syntax()).module()?;
|
||||||
let target_module_def = ModuleDef::from(resolved_call);
|
let target_module_def = ModuleDef::from(resolved_call);
|
||||||
let item_in_ns = ItemInNs::from(target_module_def);
|
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);
|
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(
|
qualify_candidate.qualify(
|
||||||
|replace_with: String| builder.replace(range, replace_with),
|
|replace_with: String| builder.replace(range, replace_with),
|
||||||
&receiver_path,
|
&receiver_path,
|
||||||
item_in_ns
|
item_in_ns,
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::tests::{check_assist};
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::tests::check_assist;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn struct_method() {
|
fn struct_method() {
|
||||||
|
@ -478,4 +485,3 @@ fn main() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use hir::AsAssocItem;
|
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 ide_db::RootDatabase;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast,
|
ast,
|
||||||
|
|
Loading…
Reference in a new issue