diff options
author | Aleksey Kladov <[email protected]> | 2019-11-20 06:40:36 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-20 06:42:30 +0000 |
commit | 36e3fc9d5413f7e6e17e82867aae1318645880a3 (patch) | |
tree | 166ee3c45f99611f7c20740c2a246f5b3bed41a3 /crates/ra_hir_def | |
parent | e975f6364cb3caf50467835afb0dafce887f51f0 (diff) |
Rename Source::ast -> Source::value
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/adt.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/scope.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir_def/src/diagnostics.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/imp.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/path.rs | 2 |
8 files changed, 25 insertions, 24 deletions
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 { | |||
54 | id: StructOrUnionId, | 54 | id: StructOrUnionId, |
55 | ) -> Arc<StructData> { | 55 | ) -> Arc<StructData> { |
56 | let src = id.source(db); | 56 | let src = id.source(db); |
57 | let name = src.ast.name().map(|n| n.as_name()); | 57 | let name = src.value.name().map(|n| n.as_name()); |
58 | let variant_data = VariantData::new(src.ast.kind()); | 58 | let variant_data = VariantData::new(src.value.kind()); |
59 | let variant_data = Arc::new(variant_data); | 59 | let variant_data = Arc::new(variant_data); |
60 | Arc::new(StructData { name, variant_data }) | 60 | Arc::new(StructData { name, variant_data }) |
61 | } | 61 | } |
@@ -64,9 +64,9 @@ impl StructData { | |||
64 | impl EnumData { | 64 | impl EnumData { |
65 | pub(crate) fn enum_data_query(db: &impl DefDatabase2, e: EnumId) -> Arc<EnumData> { | 65 | pub(crate) fn enum_data_query(db: &impl DefDatabase2, e: EnumId) -> Arc<EnumData> { |
66 | let src = e.source(db); | 66 | let src = e.source(db); |
67 | let name = src.ast.name().map(|n| n.as_name()); | 67 | let name = src.value.name().map(|n| n.as_name()); |
68 | let variants = src | 68 | let variants = src |
69 | .ast | 69 | .value |
70 | .variant_list() | 70 | .variant_list() |
71 | .into_iter() | 71 | .into_iter() |
72 | .flat_map(|it| it.variants()) | 72 | .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 { | |||
73 | std::mem::forget(mark); | 73 | std::mem::forget(mark); |
74 | } | 74 | } |
75 | 75 | ||
76 | fn to_source<T>(&self, ast: T) -> Source<T> { | 76 | fn to_source<T>(&self, value: T) -> Source<T> { |
77 | Source { file_id: self.current_file_id, ast } | 77 | Source { file_id: self.current_file_id, value } |
78 | } | 78 | } |
79 | 79 | ||
80 | fn parse_path(&mut self, path: ast::Path) -> Option<Path> { | 80 | fn parse_path(&mut self, path: ast::Path) -> Option<Path> { |
@@ -150,16 +150,16 @@ impl Body { | |||
150 | let (file_id, module, body) = match def { | 150 | let (file_id, module, body) = match def { |
151 | DefWithBodyId::FunctionId(f) => { | 151 | DefWithBodyId::FunctionId(f) => { |
152 | let src = f.source(db); | 152 | let src = f.source(db); |
153 | params = src.ast.param_list(); | 153 | params = src.value.param_list(); |
154 | (src.file_id, f.module(db), src.ast.body().map(ast::Expr::from)) | 154 | (src.file_id, f.module(db), src.value.body().map(ast::Expr::from)) |
155 | } | 155 | } |
156 | DefWithBodyId::ConstId(c) => { | 156 | DefWithBodyId::ConstId(c) => { |
157 | let src = c.source(db); | 157 | let src = c.source(db); |
158 | (src.file_id, c.module(db), src.ast.body()) | 158 | (src.file_id, c.module(db), src.value.body()) |
159 | } | 159 | } |
160 | DefWithBodyId::StaticId(s) => { | 160 | DefWithBodyId::StaticId(s) => { |
161 | let src = s.source(db); | 161 | let src = s.source(db); |
162 | (src.file_id, s.module(db), src.ast.body()) | 162 | (src.file_id, s.module(db), src.value.body()) |
163 | } | 163 | } |
164 | }; | 164 | }; |
165 | let expander = Expander::new(db, file_id, module); | 165 | 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 { | |||
210 | let scopes = db.expr_scopes(function.into()); | 210 | let scopes = db.expr_scopes(function.into()); |
211 | let (_body, source_map) = db.body_with_source_map(function.into()); | 211 | let (_body, source_map) = db.body_with_source_map(function.into()); |
212 | 212 | ||
213 | let expr_id = | 213 | let expr_id = source_map |
214 | source_map.node_expr(Source { file_id: file_id.into(), ast: &marker.into() }).unwrap(); | 214 | .node_expr(Source { file_id: file_id.into(), value: &marker.into() }) |
215 | .unwrap(); | ||
215 | let scope = scopes.scope_for(expr_id); | 216 | let scope = scopes.scope_for(expr_id); |
216 | 217 | ||
217 | let actual = scopes | 218 | let actual = scopes |
@@ -317,14 +318,14 @@ mod tests { | |||
317 | let expr_scope = { | 318 | let expr_scope = { |
318 | let expr_ast = name_ref.syntax().ancestors().find_map(ast::Expr::cast).unwrap(); | 319 | let expr_ast = name_ref.syntax().ancestors().find_map(ast::Expr::cast).unwrap(); |
319 | let expr_id = | 320 | let expr_id = |
320 | source_map.node_expr(Source { file_id: file_id.into(), ast: &expr_ast }).unwrap(); | 321 | source_map.node_expr(Source { file_id: file_id.into(), value: &expr_ast }).unwrap(); |
321 | scopes.scope_for(expr_id).unwrap() | 322 | scopes.scope_for(expr_id).unwrap() |
322 | }; | 323 | }; |
323 | 324 | ||
324 | let resolved = scopes.resolve_name_in_scope(expr_scope, &name_ref.as_name()).unwrap(); | 325 | let resolved = scopes.resolve_name_in_scope(expr_scope, &name_ref.as_name()).unwrap(); |
325 | let pat_src = source_map.pat_syntax(resolved.pat()).unwrap(); | 326 | let pat_src = source_map.pat_syntax(resolved.pat()).unwrap(); |
326 | 327 | ||
327 | let local_name = pat_src.ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); | 328 | let local_name = pat_src.value.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); |
328 | assert_eq!(local_name.range(), expected_name.syntax().text_range()); | 329 | assert_eq!(local_name.range(), expected_name.syntax().text_range()); |
329 | } | 330 | } |
330 | 331 | ||
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 { | |||
20 | "unresolved module".to_string() | 20 | "unresolved module".to_string() |
21 | } | 21 | } |
22 | fn source(&self) -> Source<SyntaxNodePtr> { | 22 | fn source(&self) -> Source<SyntaxNodePtr> { |
23 | Source { file_id: self.file, ast: self.decl.into() } | 23 | Source { file_id: self.file, value: self.decl.into() } |
24 | } | 24 | } |
25 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | 25 | fn as_any(&self) -> &(dyn Any + Send + 'static) { |
26 | self | 26 | 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 { | |||
25 | let src = id.source(db); | 25 | let src = id.source(db); |
26 | let items = db.ast_id_map(src.file_id); | 26 | let items = db.ast_id_map(src.file_id); |
27 | 27 | ||
28 | let target_trait = src.ast.target_trait().map(TypeRef::from_ast); | 28 | let target_trait = src.value.target_trait().map(TypeRef::from_ast); |
29 | let target_type = TypeRef::from_ast_opt(src.ast.target_type()); | 29 | let target_type = TypeRef::from_ast_opt(src.value.target_type()); |
30 | let negative = src.ast.is_negative(); | 30 | let negative = src.value.is_negative(); |
31 | 31 | ||
32 | let items = if let Some(item_list) = src.ast.item_list() { | 32 | let items = if let Some(item_list) = src.value.item_list() { |
33 | let ctx = LocationCtx::new(db, id.module(db), src.file_id); | 33 | let ctx = LocationCtx::new(db, id.module(db), src.file_id); |
34 | item_list | 34 | item_list |
35 | .impl_items() | 35 | .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 { | |||
80 | 80 | ||
81 | pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource { | 81 | pub fn from_child_node(db: &impl db::DefDatabase2, child: Source<&SyntaxNode>) -> ModuleSource { |
82 | if let Some(m) = | 82 | if let Some(m) = |
83 | child.ast.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) | 83 | child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) |
84 | { | 84 | { |
85 | ModuleSource::Module(m) | 85 | ModuleSource::Module(m) |
86 | } else { | 86 | } else { |
@@ -184,8 +184,8 @@ pub trait AstItemDef<N: AstNode>: salsa::InternKey + Clone { | |||
184 | } | 184 | } |
185 | fn source(self, db: &(impl AstDatabase + InternDatabase)) -> Source<N> { | 185 | fn source(self, db: &(impl AstDatabase + InternDatabase)) -> Source<N> { |
186 | let loc = self.lookup_intern(db); | 186 | let loc = self.lookup_intern(db); |
187 | let ast = loc.ast_id.to_node(db); | 187 | let value = loc.ast_id.to_node(db); |
188 | Source { file_id: loc.ast_id.file_id(), ast } | 188 | Source { file_id: loc.ast_id.file_id(), value } |
189 | } | 189 | } |
190 | fn module(self, db: &impl InternDatabase) -> ModuleId { | 190 | fn module(self, db: &impl InternDatabase) -> ModuleId { |
191 | let loc = self.lookup_intern(db); | 191 | 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 { | |||
327 | 327 | ||
328 | let mut buf = Vec::new(); | 328 | let mut buf = Vec::new(); |
329 | Path::expand_use_item( | 329 | Path::expand_use_item( |
330 | Source { ast: use_item, file_id: self.file_id }, | 330 | Source { value: use_item, file_id: self.file_id }, |
331 | &self.hygiene, | 331 | &self.hygiene, |
332 | |path, use_tree, is_glob, alias| { | 332 | |path, use_tree, is_glob, alias| { |
333 | let import_data = ImportData { | 333 | 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 { | |||
71 | hygiene: &Hygiene, | 71 | hygiene: &Hygiene, |
72 | mut cb: impl FnMut(Path, &ast::UseTree, bool, Option<Name>), | 72 | mut cb: impl FnMut(Path, &ast::UseTree, bool, Option<Name>), |
73 | ) { | 73 | ) { |
74 | if let Some(tree) = item_src.ast.use_tree() { | 74 | if let Some(tree) = item_src.value.use_tree() { |
75 | expand_use_tree(None, tree, hygiene, &mut cb); | 75 | expand_use_tree(None, tree, hygiene, &mut cb); |
76 | } | 76 | } |
77 | } | 77 | } |