Rename Source::ast -> Source::value
This commit is contained in:
@@ -49,9 +49,9 @@ pub(crate) fn attributes_query(
|
||||
AttrDef::Module(it) => {
|
||||
let src = it.declaration_source(db)?;
|
||||
let hygiene = Hygiene::new(db, src.file_id);
|
||||
Attr::from_attrs_owner(&src.ast, &hygiene)
|
||||
Attr::from_attrs_owner(&src.value, &hygiene)
|
||||
}
|
||||
AttrDef::StructField(it) => match it.source(db).ast {
|
||||
AttrDef::StructField(it) => match it.source(db).value {
|
||||
FieldSource::Named(named) => {
|
||||
let src = it.source(db);
|
||||
let hygiene = Hygiene::new(db, src.file_id);
|
||||
@@ -82,7 +82,7 @@ where
|
||||
{
|
||||
let src = node.source(db);
|
||||
let hygiene = Hygiene::new(db, src.file_id);
|
||||
Attr::from_attrs_owner(&src.ast, &hygiene)
|
||||
Attr::from_attrs_owner(&src.value, &hygiene)
|
||||
}
|
||||
|
||||
impl<T: Into<AttrDef> + Copy> Attrs for T {
|
||||
|
||||
@@ -70,23 +70,23 @@ pub(crate) fn documentation_query(
|
||||
def: DocDef,
|
||||
) -> Option<Documentation> {
|
||||
match def {
|
||||
DocDef::Module(it) => docs_from_ast(&it.declaration_source(db)?.ast),
|
||||
DocDef::StructField(it) => match it.source(db).ast {
|
||||
DocDef::Module(it) => docs_from_ast(&it.declaration_source(db)?.value),
|
||||
DocDef::StructField(it) => match it.source(db).value {
|
||||
FieldSource::Named(named) => docs_from_ast(&named),
|
||||
FieldSource::Pos(..) => None,
|
||||
},
|
||||
DocDef::Adt(it) => match it {
|
||||
Adt::Struct(it) => docs_from_ast(&it.source(db).ast),
|
||||
Adt::Enum(it) => docs_from_ast(&it.source(db).ast),
|
||||
Adt::Union(it) => docs_from_ast(&it.source(db).ast),
|
||||
Adt::Struct(it) => docs_from_ast(&it.source(db).value),
|
||||
Adt::Enum(it) => docs_from_ast(&it.source(db).value),
|
||||
Adt::Union(it) => docs_from_ast(&it.source(db).value),
|
||||
},
|
||||
DocDef::EnumVariant(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Static(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Const(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Function(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::Trait(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::TypeAlias(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::MacroDef(it) => docs_from_ast(&it.source(db).ast),
|
||||
DocDef::EnumVariant(it) => docs_from_ast(&it.source(db).value),
|
||||
DocDef::Static(it) => docs_from_ast(&it.source(db).value),
|
||||
DocDef::Const(it) => docs_from_ast(&it.source(db).value),
|
||||
DocDef::Function(it) => docs_from_ast(&it.source(db).value),
|
||||
DocDef::Trait(it) => docs_from_ast(&it.source(db).value),
|
||||
DocDef::TypeAlias(it) => docs_from_ast(&it.source(db).value),
|
||||
DocDef::MacroDef(it) => docs_from_ast(&it.source(db).value),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ impl Module {
|
||||
let def_map = db.crate_def_map(self.id.krate);
|
||||
let decl_id = def_map[self.id.module_id].declaration;
|
||||
let file_id = def_map[self.id.module_id].definition;
|
||||
let ast = ModuleSource::new(db, file_id, decl_id);
|
||||
let value = ModuleSource::new(db, file_id, decl_id);
|
||||
let file_id = file_id.map(HirFileId::from).unwrap_or_else(|| decl_id.unwrap().file_id());
|
||||
Source { file_id, ast }
|
||||
Source { file_id, value }
|
||||
}
|
||||
|
||||
/// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
|
||||
@@ -38,8 +38,8 @@ impl Module {
|
||||
) -> Option<Source<ast::Module>> {
|
||||
let def_map = db.crate_def_map(self.id.krate);
|
||||
let decl = def_map[self.id.module_id].declaration?;
|
||||
let ast = decl.to_node(db);
|
||||
Some(Source { file_id: decl.file_id(), ast })
|
||||
let value = decl.to_node(db);
|
||||
Some(Source { file_id: decl.file_id(), value })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ impl HasSource for StructField {
|
||||
let (file_id, struct_kind) = match self.parent {
|
||||
VariantDef::Struct(s) => {
|
||||
ss = s.source(db);
|
||||
(ss.file_id, ss.ast.kind())
|
||||
(ss.file_id, ss.value.kind())
|
||||
}
|
||||
VariantDef::EnumVariant(e) => {
|
||||
es = e.source(db);
|
||||
(es.file_id, es.ast.kind())
|
||||
(es.file_id, es.value.kind())
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,13 +66,13 @@ impl HasSource for StructField {
|
||||
ast::StructKind::Named(fl) => fl.fields().map(|it| FieldSource::Named(it)).collect(),
|
||||
ast::StructKind::Unit => Vec::new(),
|
||||
};
|
||||
let ast = field_sources
|
||||
let value = field_sources
|
||||
.into_iter()
|
||||
.zip(fields.iter())
|
||||
.find(|(_syntax, (id, _))| *id == self.id)
|
||||
.unwrap()
|
||||
.0;
|
||||
Source { file_id, ast }
|
||||
Source { file_id, value }
|
||||
}
|
||||
}
|
||||
impl HasSource for Struct {
|
||||
@@ -98,8 +98,8 @@ impl HasSource for EnumVariant {
|
||||
fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::EnumVariant> {
|
||||
let enum_data = db.enum_data(self.parent.id);
|
||||
let src = self.parent.id.source(db);
|
||||
let ast = src
|
||||
.ast
|
||||
let value = src
|
||||
.value
|
||||
.variant_list()
|
||||
.into_iter()
|
||||
.flat_map(|it| it.variants())
|
||||
@@ -107,7 +107,7 @@ impl HasSource for EnumVariant {
|
||||
.find(|(_syntax, (id, _))| *id == self.id)
|
||||
.unwrap()
|
||||
.0;
|
||||
Source { file_id: src.file_id, ast }
|
||||
Source { file_id: src.file_id, value }
|
||||
}
|
||||
}
|
||||
impl HasSource for Function {
|
||||
@@ -143,7 +143,7 @@ impl HasSource for TypeAlias {
|
||||
impl HasSource for MacroDef {
|
||||
type Ast = ast::MacroCall;
|
||||
fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<ast::MacroCall> {
|
||||
Source { file_id: self.id.ast_id.file_id(), ast: self.id.ast_id.to_node(db) }
|
||||
Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user