diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-06 20:28:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-06 20:28:28 +0000 |
commit | f18b7e18c479144325ec150be00837aae3329ae2 (patch) | |
tree | 2c8fbda35c5d9f43b70fe3c6e91ce3e4a8bb3226 /crates/ra_hir_ty | |
parent | d3702c02cdff158f05d2af1bd7106cca8a3e4ba9 (diff) | |
parent | 8c86963d47953045f2f33ee6620d305a6589641e (diff) |
Merge #2484
2484: DynMap r=matklad a=matklad
Implement a `DynMap` a semi-dynamic, semi-static map, which helps to thread heterogeneously typed info in a uniform way. Totally inspired by https://github.com/JetBrains/kotlin/blob/df3bee30384787d8951ea548a4257c2cb52a16a3/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java.
@flodiebold wdyt? Seems like a potentially useful pattern for various source-map-like things.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index f1b67555f..d724ee122 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -11,8 +11,8 @@ use std::fmt::Write; | |||
11 | use std::sync::Arc; | 11 | use std::sync::Arc; |
12 | 12 | ||
13 | use hir_def::{ | 13 | use hir_def::{ |
14 | body::BodySourceMap, child_from_source::ChildFromSource, db::DefDatabase, nameres::CrateDefMap, | 14 | body::BodySourceMap, child_by_source::ChildBySource, db::DefDatabase, keys, |
15 | AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, | 15 | nameres::CrateDefMap, AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, |
16 | }; | 16 | }; |
17 | use hir_expand::InFile; | 17 | use hir_expand::InFile; |
18 | use insta::assert_snapshot; | 18 | use insta::assert_snapshot; |
@@ -33,7 +33,9 @@ fn type_at_pos(db: &TestDB, pos: FilePosition) -> String { | |||
33 | let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); | 33 | let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); |
34 | let fn_def = expr.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); | 34 | let fn_def = expr.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); |
35 | let module = db.module_for_file(pos.file_id); | 35 | let module = db.module_for_file(pos.file_id); |
36 | let func = module.child_from_source(db, InFile::new(pos.file_id.into(), fn_def)).unwrap(); | 36 | let func = *module.child_by_source(db)[keys::FUNCTION] |
37 | .get(&InFile::new(pos.file_id.into(), fn_def)) | ||
38 | .unwrap(); | ||
37 | 39 | ||
38 | let (_body, source_map) = db.body_with_source_map(func.into()); | 40 | let (_body, source_map) = db.body_with_source_map(func.into()); |
39 | if let Some(expr_id) = source_map.node_expr(InFile::new(pos.file_id.into(), &expr)) { | 41 | if let Some(expr_id) = source_map.node_expr(InFile::new(pos.file_id.into(), &expr)) { |