mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Introduce and use get_fn_target_info
This commit is contained in:
parent
d8e7419c64
commit
48ea3825b8
1 changed files with 16 additions and 16 deletions
|
@ -104,13 +104,10 @@ fn fn_target_info(
|
||||||
call: &CallExpr,
|
call: &CallExpr,
|
||||||
fn_name: &str,
|
fn_name: &str,
|
||||||
) -> Option<TargetInfo> {
|
) -> Option<TargetInfo> {
|
||||||
let target_module;
|
match path.qualifier() {
|
||||||
let adt_name = None;
|
|
||||||
let (target, file, insert_offset) = match path.qualifier() {
|
|
||||||
Some(qualifier) => match ctx.sema.resolve_path(&qualifier) {
|
Some(qualifier) => match ctx.sema.resolve_path(&qualifier) {
|
||||||
Some(hir::PathResolution::Def(hir::ModuleDef::Module(module))) => {
|
Some(hir::PathResolution::Def(hir::ModuleDef::Module(module))) => {
|
||||||
target_module = Some(module);
|
get_fn_target_info(ctx, &Some(module), call.clone())
|
||||||
get_fn_target(ctx, &target_module, call.clone())?
|
|
||||||
}
|
}
|
||||||
Some(hir::PathResolution::Def(hir::ModuleDef::Adt(adt))) => {
|
Some(hir::PathResolution::Def(hir::ModuleDef::Adt(adt))) => {
|
||||||
if let hir::Adt::Enum(_) = adt {
|
if let hir::Adt::Enum(_) = adt {
|
||||||
|
@ -120,22 +117,16 @@ fn fn_target_info(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return assoc_fn_target_info(ctx, call, adt, fn_name);
|
assoc_fn_target_info(ctx, call, adt, fn_name)
|
||||||
}
|
}
|
||||||
Some(hir::PathResolution::SelfType(impl_)) => {
|
Some(hir::PathResolution::SelfType(impl_)) => {
|
||||||
let adt = impl_.self_ty(ctx.db()).as_adt()?;
|
let adt = impl_.self_ty(ctx.db()).as_adt()?;
|
||||||
return assoc_fn_target_info(ctx, call, adt, fn_name);
|
assoc_fn_target_info(ctx, call, adt, fn_name)
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
|
_ => None,
|
||||||
},
|
},
|
||||||
_ => {
|
_ => get_fn_target_info(ctx, &None, call.clone()),
|
||||||
target_module = None;
|
|
||||||
get_fn_target(ctx, &target_module, call.clone())?
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
Some(TargetInfo::new(target_module, adt_name, target, file, insert_offset))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
|
fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
|
||||||
|
@ -391,6 +382,15 @@ fn make_return_type(
|
||||||
(ret_type, should_focus_return_type)
|
(ret_type, should_focus_return_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_fn_target_info(
|
||||||
|
ctx: &AssistContext<'_>,
|
||||||
|
target_module: &Option<Module>,
|
||||||
|
call: CallExpr,
|
||||||
|
) -> Option<TargetInfo> {
|
||||||
|
let (target, file, insert_offset) = get_fn_target(ctx, target_module, call)?;
|
||||||
|
Some(TargetInfo::new(*target_module, None, target, file, insert_offset))
|
||||||
|
}
|
||||||
|
|
||||||
fn get_fn_target(
|
fn get_fn_target(
|
||||||
ctx: &AssistContext<'_>,
|
ctx: &AssistContext<'_>,
|
||||||
target_module: &Option<Module>,
|
target_module: &Option<Module>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue