mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
rename AdtDef -> Adt
This commit is contained in:
parent
bcf30d389c
commit
114a1b878e
20 changed files with 90 additions and 99 deletions
|
@ -1,4 +1,4 @@
|
|||
use hir::{AdtDef, Ty, TypeCtor};
|
||||
use hir::{Adt, Ty, TypeCtor};
|
||||
|
||||
use crate::completion::completion_item::CompletionKind;
|
||||
use crate::{
|
||||
|
@ -37,7 +37,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
|
|||
for receiver in ctx.analyzer.autoderef(ctx.db, receiver) {
|
||||
if let Ty::Apply(a_ty) = receiver {
|
||||
match a_ty.ctor {
|
||||
TypeCtor::Adt(AdtDef::Struct(s)) => {
|
||||
TypeCtor::Adt(Adt::Struct(s)) => {
|
||||
for field in s.fields(ctx.db) {
|
||||
acc.add_field(ctx, field, &a_ty.parameters);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use hir::{AdtDef, Either, Resolution};
|
||||
use hir::{Adt, Either, Resolution};
|
||||
use ra_syntax::AstNode;
|
||||
use test_utils::tested_by;
|
||||
|
||||
|
@ -37,14 +37,14 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def));
|
||||
}
|
||||
}
|
||||
hir::ModuleDef::AdtDef(_) | hir::ModuleDef::TypeAlias(_) => {
|
||||
if let hir::ModuleDef::AdtDef(AdtDef::Enum(e)) = def {
|
||||
hir::ModuleDef::Adt(_) | hir::ModuleDef::TypeAlias(_) => {
|
||||
if let hir::ModuleDef::Adt(Adt::Enum(e)) = def {
|
||||
for variant in e.variants(ctx.db) {
|
||||
acc.add_enum_variant(ctx, variant);
|
||||
}
|
||||
}
|
||||
let ty = match def {
|
||||
hir::ModuleDef::AdtDef(adt) => adt.ty(ctx.db),
|
||||
hir::ModuleDef::Adt(adt) => adt.ty(ctx.db),
|
||||
hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
_ => continue,
|
||||
};
|
||||
match def {
|
||||
hir::ModuleDef::AdtDef(hir::AdtDef::Enum(..))
|
||||
hir::ModuleDef::Adt(hir::Adt::Enum(..))
|
||||
| hir::ModuleDef::EnumVariant(..)
|
||||
| hir::ModuleDef::Const(..)
|
||||
| hir::ModuleDef::Module(..) => (),
|
||||
|
|
|
@ -67,15 +67,13 @@ impl Completions {
|
|||
Resolution::Def(Function(func)) => {
|
||||
return self.add_function_with_name(ctx, Some(local_name), *func);
|
||||
}
|
||||
Resolution::Def(AdtDef(hir::AdtDef::Struct(it))) => {
|
||||
Resolution::Def(Adt(hir::Adt::Struct(it))) => {
|
||||
(CompletionItemKind::Struct, it.docs(ctx.db))
|
||||
}
|
||||
Resolution::Def(AdtDef(hir::AdtDef::Union(it))) => {
|
||||
Resolution::Def(Adt(hir::Adt::Union(it))) => {
|
||||
(CompletionItemKind::Struct, it.docs(ctx.db))
|
||||
}
|
||||
Resolution::Def(AdtDef(hir::AdtDef::Enum(it))) => {
|
||||
(CompletionItemKind::Enum, it.docs(ctx.db))
|
||||
}
|
||||
Resolution::Def(Adt(hir::Adt::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)),
|
||||
|
|
|
@ -178,11 +178,11 @@ impl NavigationTarget {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn from_adt_def(db: &RootDatabase, adt_def: hir::AdtDef) -> NavigationTarget {
|
||||
pub(crate) fn from_adt_def(db: &RootDatabase, adt_def: hir::Adt) -> NavigationTarget {
|
||||
match adt_def {
|
||||
hir::AdtDef::Struct(it) => NavigationTarget::from_def_source(db, it),
|
||||
hir::AdtDef::Union(it) => NavigationTarget::from_def_source(db, it),
|
||||
hir::AdtDef::Enum(it) => NavigationTarget::from_def_source(db, it),
|
||||
hir::Adt::Struct(it) => NavigationTarget::from_def_source(db, it),
|
||||
hir::Adt::Union(it) => NavigationTarget::from_def_source(db, it),
|
||||
hir::Adt::Enum(it) => NavigationTarget::from_def_source(db, it),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ impl NavigationTarget {
|
|||
let nav = match module_def {
|
||||
hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module),
|
||||
hir::ModuleDef::Function(func) => NavigationTarget::from_def_source(db, func),
|
||||
hir::ModuleDef::AdtDef(it) => NavigationTarget::from_adt_def(db, it),
|
||||
hir::ModuleDef::Adt(it) => NavigationTarget::from_adt_def(db, it),
|
||||
hir::ModuleDef::Const(it) => NavigationTarget::from_def_source(db, it),
|
||||
hir::ModuleDef::Static(it) => NavigationTarget::from_def_source(db, it),
|
||||
hir::ModuleDef::EnumVariant(it) => NavigationTarget::from_def_source(db, it),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use hir::{AdtDef, HasSource, HirDisplay};
|
||||
use hir::{Adt, HasSource, HirDisplay};
|
||||
use ra_db::SourceDatabase;
|
||||
use ra_syntax::{
|
||||
algo::{
|
||||
|
@ -129,13 +129,9 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
|||
}
|
||||
}
|
||||
hir::ModuleDef::Function(it) => res.extend(from_def_source(db, it)),
|
||||
hir::ModuleDef::AdtDef(AdtDef::Struct(it)) => {
|
||||
res.extend(from_def_source(db, it))
|
||||
}
|
||||
hir::ModuleDef::AdtDef(AdtDef::Union(it)) => {
|
||||
res.extend(from_def_source(db, it))
|
||||
}
|
||||
hir::ModuleDef::AdtDef(AdtDef::Enum(it)) => res.extend(from_def_source(db, it)),
|
||||
hir::ModuleDef::Adt(Adt::Struct(it)) => res.extend(from_def_source(db, it)),
|
||||
hir::ModuleDef::Adt(Adt::Union(it)) => res.extend(from_def_source(db, it)),
|
||||
hir::ModuleDef::Adt(Adt::Enum(it)) => res.extend(from_def_source(db, it)),
|
||||
hir::ModuleDef::EnumVariant(it) => res.extend(from_def_source(db, it)),
|
||||
hir::ModuleDef::Const(it) => res.extend(from_def_source(db, it)),
|
||||
hir::ModuleDef::Static(it) => res.extend(from_def_source(db, it)),
|
||||
|
@ -149,9 +145,9 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
|||
Some(SelfType(ty)) => {
|
||||
if let Some((adt_def, _)) = ty.as_adt() {
|
||||
res.extend(match adt_def {
|
||||
hir::AdtDef::Struct(it) => from_def_source(db, it),
|
||||
hir::AdtDef::Union(it) => from_def_source(db, it),
|
||||
hir::AdtDef::Enum(it) => from_def_source(db, it),
|
||||
hir::Adt::Struct(it) => from_def_source(db, it),
|
||||
hir::Adt::Union(it) => from_def_source(db, it),
|
||||
hir::Adt::Enum(it) => from_def_source(db, it),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ pub(crate) fn classify_name_ref(
|
|||
let record_lit = field_expr.syntax().ancestors().find_map(ast::RecordLit::cast);
|
||||
|
||||
if let Some(ty) = record_lit.and_then(|lit| analyzer.type_of(db, &lit.into())) {
|
||||
if let Some((hir::AdtDef::Struct(s), _)) = ty.as_adt() {
|
||||
if let Some((hir::Adt::Struct(s), _)) = ty.as_adt() {
|
||||
let hir_path = hir::Path::from_name_ref(name_ref);
|
||||
let hir_name = hir_path.as_ident().unwrap();
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
|
|||
Some(AssocItem(hir::ImplItem::TypeAlias(_))) => "type",
|
||||
Some(Def(hir::ModuleDef::Module(_))) => "module",
|
||||
Some(Def(hir::ModuleDef::Function(_))) => "function",
|
||||
Some(Def(hir::ModuleDef::AdtDef(_))) => "type",
|
||||
Some(Def(hir::ModuleDef::Adt(_))) => "type",
|
||||
Some(Def(hir::ModuleDef::EnumVariant(_))) => "constant",
|
||||
Some(Def(hir::ModuleDef::Const(_))) => "constant",
|
||||
Some(Def(hir::ModuleDef::Static(_))) => "constant",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue