From 36e3fc9d5413f7e6e17e82867aae1318645880a3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 Nov 2019 09:40:36 +0300 Subject: Rename Source::ast -> Source::value --- crates/ra_hir/src/code_model/attrs.rs | 6 +++--- crates/ra_hir/src/code_model/docs.rs | 24 ++++++++++++------------ crates/ra_hir/src/code_model/src.rs | 24 ++++++++++++------------ 3 files changed, 27 insertions(+), 27 deletions(-) (limited to 'crates/ra_hir/src/code_model') diff --git a/crates/ra_hir/src/code_model/attrs.rs b/crates/ra_hir/src/code_model/attrs.rs index f7db36b66..9e304217c 100644 --- a/crates/ra_hir/src/code_model/attrs.rs +++ b/crates/ra_hir/src/code_model/attrs.rs @@ -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 + Copy> Attrs for T { diff --git a/crates/ra_hir/src/code_model/docs.rs b/crates/ra_hir/src/code_model/docs.rs index 8533b4f5e..e40efef34 100644 --- a/crates/ra_hir/src/code_model/docs.rs +++ b/crates/ra_hir/src/code_model/docs.rs @@ -70,23 +70,23 @@ pub(crate) fn documentation_query( def: DocDef, ) -> Option { 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), } } diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 247ae3e55..556417b0f 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs @@ -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> { 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 { 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 { - 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) } } } -- cgit v1.2.3