mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Generate and use TargetInfo::new
This commit is contained in:
parent
2e4a4f1a9c
commit
d8e7419c64
@ -86,6 +86,18 @@ struct TargetInfo {
|
|||||||
insert_offset: TextSize,
|
insert_offset: TextSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TargetInfo {
|
||||||
|
fn new(
|
||||||
|
target_module: Option<Module>,
|
||||||
|
adt_name: Option<hir::Name>,
|
||||||
|
target: GeneratedFunctionTarget,
|
||||||
|
file: FileId,
|
||||||
|
insert_offset: TextSize,
|
||||||
|
) -> Self {
|
||||||
|
Self { target_module, adt_name, target, file, insert_offset }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn fn_target_info(
|
fn fn_target_info(
|
||||||
ctx: &AssistContext<'_>,
|
ctx: &AssistContext<'_>,
|
||||||
path: ast::Path,
|
path: ast::Path,
|
||||||
@ -123,7 +135,7 @@ fn fn_target_info(
|
|||||||
get_fn_target(ctx, &target_module, call.clone())?
|
get_fn_target(ctx, &target_module, call.clone())?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Some(TargetInfo { target_module, adt_name, target, file, insert_offset })
|
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<()> {
|
||||||
@ -427,7 +439,7 @@ fn assoc_fn_target_info(
|
|||||||
let (impl_, file) = get_adt_source(ctx, &adt, fn_name)?;
|
let (impl_, file) = get_adt_source(ctx, &adt, fn_name)?;
|
||||||
let (target, insert_offset) = get_method_target(ctx, &module, &impl_)?;
|
let (target, insert_offset) = get_method_target(ctx, &module, &impl_)?;
|
||||||
let adt_name = if impl_.is_none() { Some(adt.name(ctx.sema.db)) } else { None };
|
let adt_name = if impl_.is_none() { Some(adt.name(ctx.sema.db)) } else { None };
|
||||||
Some(TargetInfo { target_module, adt_name, target, file, insert_offset })
|
Some(TargetInfo::new(target_module, adt_name, target, file, insert_offset))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_insert_offset(target: &GeneratedFunctionTarget) -> TextSize {
|
fn get_insert_offset(target: &GeneratedFunctionTarget) -> TextSize {
|
||||||
|
Loading…
Reference in New Issue
Block a user