mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
use Source for TypeAlias
This commit is contained in:
parent
647c8f3df8
commit
f2ccc54468
7 changed files with 22 additions and 38 deletions
|
@ -141,13 +141,12 @@ impl Completions {
|
|||
}
|
||||
|
||||
pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) {
|
||||
let (_file_id, type_def) = type_alias.source(ctx.db);
|
||||
let type_def = type_alias.source(ctx.db).ast;
|
||||
let name = match type_def.name() {
|
||||
Some(name) => name,
|
||||
_ => return,
|
||||
};
|
||||
let (_, ast_node) = type_alias.source(ctx.db);
|
||||
let detail = type_label(&ast_node);
|
||||
let detail = type_label(&type_def);
|
||||
|
||||
CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string())
|
||||
.kind(CompletionItemKind::TypeAlias)
|
||||
|
|
|
@ -232,15 +232,7 @@ impl NavigationTarget {
|
|||
node.short_label(),
|
||||
)
|
||||
}
|
||||
hir::ModuleDef::TypeAlias(e) => {
|
||||
let (file_id, node) = e.source(db);
|
||||
NavigationTarget::from_named(
|
||||
file_id.original_file(db),
|
||||
&*node,
|
||||
node.doc_comment_text(),
|
||||
node.short_label(),
|
||||
)
|
||||
}
|
||||
hir::ModuleDef::TypeAlias(it) => NavigationTarget::from_def_source(db, it),
|
||||
hir::ModuleDef::BuiltinType(..) => {
|
||||
return None;
|
||||
}
|
||||
|
@ -267,15 +259,7 @@ impl NavigationTarget {
|
|||
match impl_item {
|
||||
ImplItem::Method(it) => NavigationTarget::from_function(db, it),
|
||||
ImplItem::Const(it) => NavigationTarget::from_def_source(db, it),
|
||||
ImplItem::TypeAlias(a) => {
|
||||
let (file_id, node) = a.source(db);
|
||||
NavigationTarget::from_named(
|
||||
file_id.original_file(db),
|
||||
&*node,
|
||||
node.doc_comment_text(),
|
||||
node.short_label(),
|
||||
)
|
||||
}
|
||||
ImplItem::TypeAlias(it) => NavigationTarget::from_def_source(db, it),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,14 +107,11 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
|||
res.extend(hover_text(it.doc_comment_text(), it.short_label()));
|
||||
}
|
||||
}
|
||||
Some(AssocItem(it)) => match it {
|
||||
hir::ImplItem::Method(it) => res.extend(from_def_source(db, it)),
|
||||
hir::ImplItem::Const(it) => res.extend(from_def_source(db, it)),
|
||||
hir::ImplItem::TypeAlias(it) => {
|
||||
let it = it.source(db).1;
|
||||
res.extend(hover_text(it.doc_comment_text(), it.short_label()))
|
||||
}
|
||||
},
|
||||
Some(AssocItem(it)) => res.extend(match it {
|
||||
hir::ImplItem::Method(it) => from_def_source(db, it),
|
||||
hir::ImplItem::Const(it) => from_def_source(db, it),
|
||||
hir::ImplItem::TypeAlias(it) => from_def_source(db, it),
|
||||
}),
|
||||
Some(Def(it)) => {
|
||||
match it {
|
||||
hir::ModuleDef::Module(it) => {
|
||||
|
@ -137,10 +134,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
|||
let it = it.source(db).1;
|
||||
res.extend(hover_text(it.doc_comment_text(), it.short_label()))
|
||||
}
|
||||
hir::ModuleDef::TypeAlias(it) => {
|
||||
let it = it.source(db).1;
|
||||
res.extend(hover_text(it.doc_comment_text(), it.short_label()))
|
||||
}
|
||||
hir::ModuleDef::TypeAlias(it) => res.extend(from_def_source(db, it)),
|
||||
hir::ModuleDef::BuiltinType(_) => {
|
||||
// FIXME: hover for builtin Type ?
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue