mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Work towards better import labels
This commit is contained in:
parent
4d4ac1d4fa
commit
33c83e72b9
13 changed files with 242 additions and 238 deletions
|
@ -53,18 +53,20 @@ pub(crate) fn render_resolution<'a>(
|
|||
pub(crate) fn render_resolution_with_import<'a>(
|
||||
ctx: RenderContext<'a>,
|
||||
import_edit: ImportEdit,
|
||||
resolution: &ScopeDef,
|
||||
) -> Option<CompletionItem> {
|
||||
let resolution = ScopeDef::from(import_edit.import.original_item);
|
||||
let local_name = match resolution {
|
||||
ScopeDef::ModuleDef(ModuleDef::Function(f)) => f.name(ctx.completion.db).to_string(),
|
||||
ScopeDef::ModuleDef(ModuleDef::Const(c)) => c.name(ctx.completion.db)?.to_string(),
|
||||
ScopeDef::ModuleDef(ModuleDef::TypeAlias(t)) => t.name(ctx.completion.db).to_string(),
|
||||
_ => item_name(ctx.db(), import_edit.import.item_to_display())?.to_string(),
|
||||
_ => item_name(ctx.db(), import_edit.import.original_item)?.to_string(),
|
||||
};
|
||||
Render::new(ctx).render_resolution(local_name, Some(import_edit), resolution).map(|mut item| {
|
||||
item.completion_kind = CompletionKind::Magic;
|
||||
item
|
||||
})
|
||||
Render::new(ctx).render_resolution(local_name, Some(import_edit), &resolution).map(
|
||||
|mut item| {
|
||||
item.completion_kind = CompletionKind::Magic;
|
||||
item
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// Interface for data and methods required for items rendering.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue