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_def/src/adt.rs | 8 ++++---- crates/ra_hir_def/src/body.rs | 12 ++++++------ crates/ra_hir_def/src/body/scope.rs | 9 +++++---- crates/ra_hir_def/src/diagnostics.rs | 2 +- crates/ra_hir_def/src/imp.rs | 8 ++++---- crates/ra_hir_def/src/lib.rs | 6 +++--- crates/ra_hir_def/src/nameres/raw.rs | 2 +- crates/ra_hir_def/src/path.rs | 2 +- 8 files changed, 25 insertions(+), 24 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index a29c4d41e..d04f54e15 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -54,8 +54,8 @@ impl StructData { id: StructOrUnionId, ) -> Arc { let src = id.source(db); - let name = src.ast.name().map(|n| n.as_name()); - let variant_data = VariantData::new(src.ast.kind()); + let name = src.value.name().map(|n| n.as_name()); + let variant_data = VariantData::new(src.value.kind()); let variant_data = Arc::new(variant_data); Arc::new(StructData { name, variant_data }) } @@ -64,9 +64,9 @@ impl StructData { impl EnumData { pub(crate) fn enum_data_query(db: &impl DefDatabase2, e: EnumId) -> Arc { let src = e.source(db); - let name = src.ast.name().map(|n| n.as_name()); + let name = src.value.name().map(|n| n.as_name()); let variants = src - .ast + .value .variant_list() .into_iter() .flat_map(|it| it.variants()) diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 85dc4feb0..3804b65c7 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -73,8 +73,8 @@ impl Expander { std::mem::forget(mark); } - fn to_source(&self, ast: T) -> Source { - Source { file_id: self.current_file_id, ast } + fn to_source(&self, value: T) -> Source { + Source { file_id: self.current_file_id, value } } fn parse_path(&mut self, path: ast::Path) -> Option { @@ -150,16 +150,16 @@ impl Body { let (file_id, module, body) = match def { DefWithBodyId::FunctionId(f) => { let src = f.source(db); - params = src.ast.param_list(); - (src.file_id, f.module(db), src.ast.body().map(ast::Expr::from)) + params = src.value.param_list(); + (src.file_id, f.module(db), src.value.body().map(ast::Expr::from)) } DefWithBodyId::ConstId(c) => { let src = c.source(db); - (src.file_id, c.module(db), src.ast.body()) + (src.file_id, c.module(db), src.value.body()) } DefWithBodyId::StaticId(s) => { let src = s.source(db); - (src.file_id, s.module(db), src.ast.body()) + (src.file_id, s.module(db), src.value.body()) } }; let expander = Expander::new(db, file_id, module); diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 10cb87d37..aeb71ff22 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -210,8 +210,9 @@ mod tests { let scopes = db.expr_scopes(function.into()); let (_body, source_map) = db.body_with_source_map(function.into()); - let expr_id = - source_map.node_expr(Source { file_id: file_id.into(), ast: &marker.into() }).unwrap(); + let expr_id = source_map + .node_expr(Source { file_id: file_id.into(), value: &marker.into() }) + .unwrap(); let scope = scopes.scope_for(expr_id); let actual = scopes @@ -317,14 +318,14 @@ mod tests { let expr_scope = { let expr_ast = name_ref.syntax().ancestors().find_map(ast::Expr::cast).unwrap(); let expr_id = - source_map.node_expr(Source { file_id: file_id.into(), ast: &expr_ast }).unwrap(); + source_map.node_expr(Source { file_id: file_id.into(), value: &expr_ast }).unwrap(); scopes.scope_for(expr_id).unwrap() }; let resolved = scopes.resolve_name_in_scope(expr_scope, &name_ref.as_name()).unwrap(); let pat_src = source_map.pat_syntax(resolved.pat()).unwrap(); - let local_name = pat_src.ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); + let local_name = pat_src.value.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); assert_eq!(local_name.range(), expected_name.syntax().text_range()); } diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index 9843009a5..eda9b2269 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -20,7 +20,7 @@ impl Diagnostic for UnresolvedModule { "unresolved module".to_string() } fn source(&self) -> Source { - Source { file_id: self.file, ast: self.decl.into() } + Source { file_id: self.file, value: self.decl.into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { self diff --git a/crates/ra_hir_def/src/imp.rs b/crates/ra_hir_def/src/imp.rs index 717991c40..4323dfcb6 100644 --- a/crates/ra_hir_def/src/imp.rs +++ b/crates/ra_hir_def/src/imp.rs @@ -25,11 +25,11 @@ impl ImplData { let src = id.source(db); let items = db.ast_id_map(src.file_id); - let target_trait = src.ast.target_trait().map(TypeRef::from_ast); - let target_type = TypeRef::from_ast_opt(src.ast.target_type()); - let negative = src.ast.is_negative(); + let target_trait = src.value.target_trait().map(TypeRef::from_ast); + let target_type = TypeRef::from_ast_opt(src.value.target_type()); + let negative = src.value.is_negative(); - let items = if let Some(item_list) = src.ast.item_list() { + let items = if let Some(item_list) = src.value.item_list() { let ctx = LocationCtx::new(db, id.module(db), src.file_id); item_list .impl_items() diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index a240a10b8..50caf4f83 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -80,7 +80,7 @@ impl ModuleSource { pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource { if let Some(m) = - child.ast.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) + child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) { ModuleSource::Module(m) } else { @@ -184,8 +184,8 @@ pub trait AstItemDef: salsa::InternKey + Clone { } fn source(self, db: &(impl AstDatabase + InternDatabase)) -> Source { let loc = self.lookup_intern(db); - let ast = loc.ast_id.to_node(db); - Source { file_id: loc.ast_id.file_id(), ast } + let value = loc.ast_id.to_node(db); + Source { file_id: loc.ast_id.file_id(), value } } fn module(self, db: &impl InternDatabase) -> ModuleId { let loc = self.lookup_intern(db); diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index a0a2c7273..7c68fd638 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -327,7 +327,7 @@ impl RawItemsCollector { let mut buf = Vec::new(); Path::expand_use_item( - Source { ast: use_item, file_id: self.file_id }, + Source { value: use_item, file_id: self.file_id }, &self.hygiene, |path, use_tree, is_glob, alias| { let import_data = ImportData { diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 04039376f..626ebffdc 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -71,7 +71,7 @@ impl Path { hygiene: &Hygiene, mut cb: impl FnMut(Path, &ast::UseTree, bool, Option), ) { - if let Some(tree) = item_src.ast.use_tree() { + if let Some(tree) = item_src.value.use_tree() { expand_use_tree(None, tree, hygiene, &mut cb); } } -- cgit v1.2.3