mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
rename persistent hir database -> def database
This commit is contained in:
parent
331220fee2
commit
3f0cf6ebe1
18 changed files with 106 additions and 160 deletions
|
@ -12,7 +12,7 @@ use ra_syntax::{
|
|||
use crate::{
|
||||
Name, AsName, Struct, Enum, EnumVariant, Crate,
|
||||
HirDatabase, HirFileId, StructField, FieldSource,
|
||||
type_ref::TypeRef, PersistentHirDatabase,
|
||||
type_ref::TypeRef, DefDatabase,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -33,7 +33,7 @@ impl AdtDef {
|
|||
}
|
||||
|
||||
impl Struct {
|
||||
pub(crate) fn variant_data(&self, db: &impl PersistentHirDatabase) -> Arc<VariantData> {
|
||||
pub(crate) fn variant_data(&self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.struct_data((*self).into()).variant_data.clone()
|
||||
}
|
||||
}
|
||||
|
@ -52,10 +52,7 @@ impl StructData {
|
|||
StructData { name, variant_data }
|
||||
}
|
||||
|
||||
pub(crate) fn struct_data_query(
|
||||
db: &impl PersistentHirDatabase,
|
||||
struct_: Struct,
|
||||
) -> Arc<StructData> {
|
||||
pub(crate) fn struct_data_query(db: &impl DefDatabase, struct_: Struct) -> Arc<StructData> {
|
||||
let (_, struct_def) = struct_.source(db);
|
||||
Arc::new(StructData::new(&*struct_def))
|
||||
}
|
||||
|
@ -68,7 +65,7 @@ fn variants(enum_def: &ast::EnumDef) -> impl Iterator<Item = &ast::EnumVariant>
|
|||
impl EnumVariant {
|
||||
pub(crate) fn source_impl(
|
||||
&self,
|
||||
db: &impl PersistentHirDatabase,
|
||||
db: &impl DefDatabase,
|
||||
) -> (HirFileId, TreeArc<ast::EnumVariant>) {
|
||||
let (file_id, enum_def) = self.parent.source(db);
|
||||
let var = variants(&*enum_def)
|
||||
|
@ -79,7 +76,7 @@ impl EnumVariant {
|
|||
.to_owned();
|
||||
(file_id, var)
|
||||
}
|
||||
pub(crate) fn variant_data(&self, db: &impl PersistentHirDatabase) -> Arc<VariantData> {
|
||||
pub(crate) fn variant_data(&self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
db.enum_data(self.parent).variants[self.id].variant_data.clone()
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +88,7 @@ pub struct EnumData {
|
|||
}
|
||||
|
||||
impl EnumData {
|
||||
pub(crate) fn enum_data_query(db: &impl PersistentHirDatabase, e: Enum) -> Arc<EnumData> {
|
||||
pub(crate) fn enum_data_query(db: &impl DefDatabase, e: Enum) -> Arc<EnumData> {
|
||||
let (_file_id, enum_def) = e.source(db);
|
||||
let name = enum_def.name().map(|n| n.as_name());
|
||||
let variants = variants(&*enum_def)
|
||||
|
@ -189,7 +186,7 @@ impl VariantDef {
|
|||
VariantDef::EnumVariant(it) => it.field(db, name),
|
||||
}
|
||||
}
|
||||
pub(crate) fn variant_data(self, db: &impl PersistentHirDatabase) -> Arc<VariantData> {
|
||||
pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> {
|
||||
match self {
|
||||
VariantDef::Struct(it) => it.variant_data(db),
|
||||
VariantDef::EnumVariant(it) => it.variant_data(db),
|
||||
|
@ -198,7 +195,7 @@ impl VariantDef {
|
|||
}
|
||||
|
||||
impl StructField {
|
||||
pub(crate) fn source_impl(&self, db: &impl PersistentHirDatabase) -> (HirFileId, FieldSource) {
|
||||
pub(crate) fn source_impl(&self, db: &impl DefDatabase) -> (HirFileId, FieldSource) {
|
||||
let var_data = self.parent.variant_data(db);
|
||||
let fields = var_data.fields().unwrap();
|
||||
let ss;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue