mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Make the Resolution variants tuple variants
This commit is contained in:
parent
d3df80dfe4
commit
d571d26955
7 changed files with 41 additions and 53 deletions
|
@ -12,7 +12,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
_ => return,
|
||||
};
|
||||
let def = match ctx.resolver.resolve_path(ctx.db, &path).take_types() {
|
||||
Some(Resolution::Def { def }) => def,
|
||||
Some(Resolution::Def(def)) => def,
|
||||
_ => return,
|
||||
};
|
||||
match def {
|
||||
|
@ -24,7 +24,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
ctx.source_range(),
|
||||
name.to_string(),
|
||||
)
|
||||
.from_resolution(ctx, &res.def.map(|def| hir::Resolution::Def { def }))
|
||||
.from_resolution(ctx, &res.def.map(hir::Resolution::Def))
|
||||
.add_to(acc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,22 +223,18 @@ impl Builder {
|
|||
Some(it) => it,
|
||||
};
|
||||
let (kind, docs) = match def {
|
||||
Resolution::Def { def: Module(it) } => (CompletionItemKind::Module, it.docs(ctx.db)),
|
||||
Resolution::Def {
|
||||
def: Function(func),
|
||||
} => return self.from_function(ctx, *func),
|
||||
Resolution::Def { def: Struct(it) } => (CompletionItemKind::Struct, it.docs(ctx.db)),
|
||||
Resolution::Def { def: Enum(it) } => (CompletionItemKind::Enum, it.docs(ctx.db)),
|
||||
Resolution::Def {
|
||||
def: EnumVariant(it),
|
||||
} => (CompletionItemKind::EnumVariant, it.docs(ctx.db)),
|
||||
Resolution::Def { def: Const(it) } => (CompletionItemKind::Const, it.docs(ctx.db)),
|
||||
Resolution::Def { def: Static(it) } => (CompletionItemKind::Static, it.docs(ctx.db)),
|
||||
Resolution::Def { def: Trait(it) } => (CompletionItemKind::Trait, it.docs(ctx.db)),
|
||||
Resolution::Def { def: Type(it) } => (CompletionItemKind::TypeAlias, it.docs(ctx.db)),
|
||||
Resolution::GenericParam { .. } => (CompletionItemKind::TypeParam, None),
|
||||
Resolution::LocalBinding { .. } => (CompletionItemKind::Binding, None),
|
||||
Resolution::SelfType { .. } => (
|
||||
Resolution::Def(Module(it)) => (CompletionItemKind::Module, it.docs(ctx.db)),
|
||||
Resolution::Def(Function(func)) => return self.from_function(ctx, *func),
|
||||
Resolution::Def(Struct(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)),
|
||||
Resolution::Def(Enum(it)) => (CompletionItemKind::Enum, it.docs(ctx.db)),
|
||||
Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)),
|
||||
Resolution::Def(Const(it)) => (CompletionItemKind::Const, it.docs(ctx.db)),
|
||||
Resolution::Def(Static(it)) => (CompletionItemKind::Static, it.docs(ctx.db)),
|
||||
Resolution::Def(Trait(it)) => (CompletionItemKind::Trait, it.docs(ctx.db)),
|
||||
Resolution::Def(Type(it)) => (CompletionItemKind::TypeAlias, it.docs(ctx.db)),
|
||||
Resolution::GenericParam(..) => (CompletionItemKind::TypeParam, None),
|
||||
Resolution::LocalBinding(..) => (CompletionItemKind::Binding, None),
|
||||
Resolution::SelfType(..) => (
|
||||
CompletionItemKind::TypeParam, // (does this need its own kind?)
|
||||
None,
|
||||
),
|
||||
|
|
|
@ -90,8 +90,8 @@ pub(crate) fn reference_definition(
|
|||
{
|
||||
let resolved = resolver.resolve_path(db, &path);
|
||||
match resolved.clone().take_types().or(resolved.take_values()) {
|
||||
Some(Resolution::Def { def }) => return Exact(NavigationTarget::from_def(db, def)),
|
||||
Some(Resolution::LocalBinding { pat }) => {
|
||||
Some(Resolution::Def(def)) => return Exact(NavigationTarget::from_def(db, def)),
|
||||
Some(Resolution::LocalBinding(pat)) => {
|
||||
let body = resolver.body().expect("no body for local binding");
|
||||
let syntax_mapping = body.syntax_mapping(db);
|
||||
let ptr = syntax_mapping
|
||||
|
@ -104,7 +104,7 @@ pub(crate) fn reference_definition(
|
|||
let nav = NavigationTarget::from_scope_entry(file_id, name, ptr);
|
||||
return Exact(nav);
|
||||
}
|
||||
Some(Resolution::GenericParam { .. }) => {
|
||||
Some(Resolution::GenericParam(..)) => {
|
||||
// TODO go to the generic param def
|
||||
}
|
||||
Some(Resolution::SelfType(_impl_block)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue