diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-20 06:44:37 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-20 06:44:37 +0000 |
commit | 4dae39a609fb58b42cbe152e66d30fe6471a34d7 (patch) | |
tree | 166ee3c45f99611f7c20740c2a246f5b3bed41a3 /crates/ra_hir/src/source_binder.rs | |
parent | eec68e6f451ee7675ce2cb29b696df091e6aed13 (diff) | |
parent | 36e3fc9d5413f7e6e17e82867aae1318645880a3 (diff) |
Merge #2319
2319: Rename Source::ast -> Source::value r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 5d3196c2a..471b0b089 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -31,7 +31,7 @@ use crate::{ | |||
31 | 31 | ||
32 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { | 32 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { |
33 | match_ast! { | 33 | match_ast! { |
34 | match (node.ast) { | 34 | match (node.value) { |
35 | ast::Module(it) => { | 35 | ast::Module(it) => { |
36 | let src = node.with_ast(it); | 36 | let src = node.with_ast(it); |
37 | Some(crate::Module::from_declaration(db, src)?.resolver(db)) | 37 | Some(crate::Module::from_declaration(db, src)?.resolver(db)) |
@@ -48,7 +48,7 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) - | |||
48 | let src = node.with_ast(it); | 48 | let src = node.with_ast(it); |
49 | Some(Enum::from_source(db, src)?.resolver(db)) | 49 | Some(Enum::from_source(db, src)?.resolver(db)) |
50 | }, | 50 | }, |
51 | _ => match node.ast.kind() { | 51 | _ => match node.value.kind() { |
52 | FN_DEF | CONST_DEF | STATIC_DEF => { | 52 | FN_DEF | CONST_DEF | STATIC_DEF => { |
53 | Some(def_with_body_from_child_node(db, node)?.resolver(db)) | 53 | Some(def_with_body_from_child_node(db, node)?.resolver(db)) |
54 | } | 54 | } |
@@ -67,7 +67,7 @@ fn def_with_body_from_child_node( | |||
67 | let module = Module::from_definition(db, Source::new(child.file_id, module_source))?; | 67 | let module = Module::from_definition(db, Source::new(child.file_id, module_source))?; |
68 | let ctx = LocationCtx::new(db, module.id, child.file_id); | 68 | let ctx = LocationCtx::new(db, module.id, child.file_id); |
69 | 69 | ||
70 | child.ast.ancestors().find_map(|node| { | 70 | child.value.ancestors().find_map(|node| { |
71 | match_ast! { | 71 | match_ast! { |
72 | match node { | 72 | match node { |
73 | ast::FnDef(def) => { Some(Function {id: ctx.to_def(&def) }.into()) }, | 73 | ast::FnDef(def) => { Some(Function {id: ctx.to_def(&def) }.into()) }, |
@@ -171,7 +171,7 @@ impl SourceAnalyzer { | |||
171 | } else { | 171 | } else { |
172 | SourceAnalyzer { | 172 | SourceAnalyzer { |
173 | resolver: node | 173 | resolver: node |
174 | .ast | 174 | .value |
175 | .ancestors() | 175 | .ancestors() |
176 | .find_map(|it| try_get_resolver_for_node(db, node.with_ast(&it))) | 176 | .find_map(|it| try_get_resolver_for_node(db, node.with_ast(&it))) |
177 | .unwrap_or_default(), | 177 | .unwrap_or_default(), |
@@ -185,12 +185,12 @@ impl SourceAnalyzer { | |||
185 | } | 185 | } |
186 | 186 | ||
187 | fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> { | 187 | fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> { |
188 | let src = Source { file_id: self.file_id, ast: expr }; | 188 | let src = Source { file_id: self.file_id, value: expr }; |
189 | self.body_source_map.as_ref()?.node_expr(src) | 189 | self.body_source_map.as_ref()?.node_expr(src) |
190 | } | 190 | } |
191 | 191 | ||
192 | fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { | 192 | fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { |
193 | let src = Source { file_id: self.file_id, ast: pat }; | 193 | let src = Source { file_id: self.file_id, value: pat }; |
194 | self.body_source_map.as_ref()?.node_pat(src) | 194 | self.body_source_map.as_ref()?.node_pat(src) |
195 | } | 195 | } |
196 | 196 | ||
@@ -302,7 +302,7 @@ impl SourceAnalyzer { | |||
302 | let entry = scopes.resolve_name_in_scope(scope, &name)?; | 302 | let entry = scopes.resolve_name_in_scope(scope, &name)?; |
303 | Some(ScopeEntryWithSyntax { | 303 | Some(ScopeEntryWithSyntax { |
304 | name: entry.name().clone(), | 304 | name: entry.name().clone(), |
305 | ptr: source_map.pat_syntax(entry.pat())?.ast, | 305 | ptr: source_map.pat_syntax(entry.pat())?.value, |
306 | }) | 306 | }) |
307 | } | 307 | } |
308 | 308 | ||
@@ -428,7 +428,7 @@ fn scope_for( | |||
428 | source_map: &BodySourceMap, | 428 | source_map: &BodySourceMap, |
429 | node: Source<&SyntaxNode>, | 429 | node: Source<&SyntaxNode>, |
430 | ) -> Option<ScopeId> { | 430 | ) -> Option<ScopeId> { |
431 | node.ast | 431 | node.value |
432 | .ancestors() | 432 | .ancestors() |
433 | .filter_map(ast::Expr::cast) | 433 | .filter_map(ast::Expr::cast) |
434 | .filter_map(|it| source_map.node_expr(Source::new(node.file_id, &it))) | 434 | .filter_map(|it| source_map.node_expr(Source::new(node.file_id, &it))) |
@@ -450,18 +450,18 @@ fn scope_for_offset( | |||
450 | return None; | 450 | return None; |
451 | } | 451 | } |
452 | let syntax_node_ptr = | 452 | let syntax_node_ptr = |
453 | source.ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); | 453 | source.value.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); |
454 | Some((syntax_node_ptr, scope)) | 454 | Some((syntax_node_ptr, scope)) |
455 | }) | 455 | }) |
456 | // find containing scope | 456 | // find containing scope |
457 | .min_by_key(|(ptr, _scope)| { | 457 | .min_by_key(|(ptr, _scope)| { |
458 | ( | 458 | ( |
459 | !(ptr.range().start() <= offset.ast && offset.ast <= ptr.range().end()), | 459 | !(ptr.range().start() <= offset.value && offset.value <= ptr.range().end()), |
460 | ptr.range().len(), | 460 | ptr.range().len(), |
461 | ) | 461 | ) |
462 | }) | 462 | }) |
463 | .map(|(ptr, scope)| { | 463 | .map(|(ptr, scope)| { |
464 | adjust(scopes, source_map, ptr, offset.file_id, offset.ast).unwrap_or(*scope) | 464 | adjust(scopes, source_map, ptr, offset.file_id, offset.value).unwrap_or(*scope) |
465 | }) | 465 | }) |
466 | } | 466 | } |
467 | 467 | ||
@@ -485,7 +485,7 @@ fn adjust( | |||
485 | return None; | 485 | return None; |
486 | } | 486 | } |
487 | let syntax_node_ptr = | 487 | let syntax_node_ptr = |
488 | source.ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); | 488 | source.value.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); |
489 | Some((syntax_node_ptr, scope)) | 489 | Some((syntax_node_ptr, scope)) |
490 | }) | 490 | }) |
491 | .map(|(ptr, scope)| (ptr.range(), scope)) | 491 | .map(|(ptr, scope)| (ptr.range(), scope)) |