diff options
author | Florian Diebold <[email protected]> | 2019-01-23 22:08:41 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-02-01 21:17:48 +0000 |
commit | 758bc72873efe36f579236d1abf240d14866fd82 (patch) | |
tree | a8c416c5c2c3dfb834bf29ed2ca4fae666048a59 /crates/ra_hir/src/expr/scope.rs | |
parent | 5208c2aa930ae452e062dcdc2563c1bbb67d2e4a (diff) |
Implement methods to build a resolver
Diffstat (limited to 'crates/ra_hir/src/expr/scope.rs')
-rw-r--r-- | crates/ra_hir/src/expr/scope.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 504a087a3..887ad8dd8 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs | |||
@@ -338,6 +338,7 @@ pub struct ReferenceDescriptor { | |||
338 | mod tests { | 338 | mod tests { |
339 | use ra_syntax::{SourceFile, algo::find_node_at_offset}; | 339 | use ra_syntax::{SourceFile, algo::find_node_at_offset}; |
340 | use test_utils::{extract_offset, assert_eq_text}; | 340 | use test_utils::{extract_offset, assert_eq_text}; |
341 | use ra_arena::ArenaId; | ||
341 | 342 | ||
342 | use crate::expr; | 343 | use crate::expr; |
343 | 344 | ||
@@ -356,7 +357,10 @@ mod tests { | |||
356 | let file = SourceFile::parse(&code); | 357 | let file = SourceFile::parse(&code); |
357 | let marker: &ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap(); | 358 | let marker: &ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap(); |
358 | let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); | 359 | let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); |
359 | let body_hir = expr::collect_fn_body_syntax(fn_def); | 360 | let irrelevant_function = Function { |
361 | id: crate::ids::FunctionId::from_raw(0.into()), | ||
362 | }; | ||
363 | let body_hir = expr::collect_fn_body_syntax(irrelevant_function, fn_def); | ||
360 | let scopes = ExprScopes::new(Arc::clone(body_hir.body())); | 364 | let scopes = ExprScopes::new(Arc::clone(body_hir.body())); |
361 | let scopes = ScopesWithSyntaxMapping { | 365 | let scopes = ScopesWithSyntaxMapping { |
362 | scopes: Arc::new(scopes), | 366 | scopes: Arc::new(scopes), |
@@ -456,7 +460,10 @@ mod tests { | |||
456 | let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); | 460 | let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); |
457 | let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); | 461 | let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); |
458 | 462 | ||
459 | let body_hir = expr::collect_fn_body_syntax(fn_def); | 463 | let irrelevant_function = Function { |
464 | id: crate::ids::FunctionId::from_raw(0.into()), | ||
465 | }; | ||
466 | let body_hir = expr::collect_fn_body_syntax(irrelevant_function, fn_def); | ||
460 | let scopes = ExprScopes::new(Arc::clone(body_hir.body())); | 467 | let scopes = ExprScopes::new(Arc::clone(body_hir.body())); |
461 | let scopes = ScopesWithSyntaxMapping { | 468 | let scopes = ScopesWithSyntaxMapping { |
462 | scopes: Arc::new(scopes), | 469 | scopes: Arc::new(scopes), |