diff options
author | Aleksey Kladov <[email protected]> | 2019-03-02 12:14:37 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-03-02 12:40:40 +0000 |
commit | eaf1df26e9903772d40df30dd70c75c38d8cb887 (patch) | |
tree | 4e7a6f4bb15caf4e134305ab1c4ba749e9e1d5b0 /crates | |
parent | 592b906604d60a86af74c5dbb3bf40b2ddcf8061 (diff) |
rename syntax-mapping -> source-map
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/fill_match_arms.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 22 | ||||
-rw-r--r-- | crates/ra_hir/src/expr/scope.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide_api/src/change.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_struct_literal.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 2 |
11 files changed, 32 insertions, 32 deletions
diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs index 30020b56e..81b11956a 100644 --- a/crates/ra_assists/src/fill_match_arms.rs +++ b/crates/ra_assists/src/fill_match_arms.rs | |||
@@ -23,7 +23,7 @@ pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<As | |||
23 | let function = | 23 | let function = |
24 | source_binder::function_from_child_node(ctx.db, ctx.frange.file_id, expr.syntax())?; | 24 | source_binder::function_from_child_node(ctx.db, ctx.frange.file_id, expr.syntax())?; |
25 | let infer_result = function.infer(ctx.db); | 25 | let infer_result = function.infer(ctx.db); |
26 | let syntax_mapping = function.body_syntax_mapping(ctx.db); | 26 | let syntax_mapping = function.body_source_map(ctx.db); |
27 | let node_expr = syntax_mapping.node_expr(expr)?; | 27 | let node_expr = syntax_mapping.node_expr(expr)?; |
28 | let match_expr_ty = infer_result[node_expr].clone(); | 28 | let match_expr_ty = infer_result[node_expr].clone(); |
29 | let enum_def = match match_expr_ty { | 29 | let enum_def = match match_expr_ty { |
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index da0f1ec94..f8521e895 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -9,7 +9,7 @@ use crate::{ | |||
9 | HirDatabase, PersistentHirDatabase, | 9 | HirDatabase, PersistentHirDatabase, |
10 | type_ref::TypeRef, | 10 | type_ref::TypeRef, |
11 | nameres::{ModuleScope, Namespace, lower::ImportId}, | 11 | nameres::{ModuleScope, Namespace, lower::ImportId}, |
12 | expr::{Body, BodySyntaxMapping}, | 12 | expr::{Body, BodySourceMap}, |
13 | ty::InferenceResult, | 13 | ty::InferenceResult, |
14 | adt::{EnumVariantId, StructFieldId, VariantDef}, | 14 | adt::{EnumVariantId, StructFieldId, VariantDef}, |
15 | generics::GenericParams, | 15 | generics::GenericParams, |
@@ -483,8 +483,8 @@ impl Function { | |||
483 | self.signature(db).name.clone() | 483 | self.signature(db).name.clone() |
484 | } | 484 | } |
485 | 485 | ||
486 | pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Arc<BodySyntaxMapping> { | 486 | pub fn body_source_map(&self, db: &impl HirDatabase) -> Arc<BodySourceMap> { |
487 | db.body_syntax_mapping(*self) | 487 | db.body_source_map(*self) |
488 | } | 488 | } |
489 | 489 | ||
490 | pub fn body(&self, db: &impl HirDatabase) -> Arc<Body> { | 490 | pub fn body(&self, db: &impl HirDatabase) -> Arc<Body> { |
@@ -497,7 +497,7 @@ impl Function { | |||
497 | 497 | ||
498 | pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSyntaxMapping { | 498 | pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSyntaxMapping { |
499 | let scopes = db.expr_scopes(*self); | 499 | let scopes = db.expr_scopes(*self); |
500 | let syntax_mapping = db.body_syntax_mapping(*self); | 500 | let syntax_mapping = db.body_source_map(*self); |
501 | ScopesWithSyntaxMapping { scopes, syntax_mapping } | 501 | ScopesWithSyntaxMapping { scopes, syntax_mapping } |
502 | } | 502 | } |
503 | 503 | ||
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index ec848f1b2..cb1c24561 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -108,8 +108,8 @@ pub trait HirDatabase: PersistentHirDatabase { | |||
108 | #[salsa::invoke(crate::expr::body_hir)] | 108 | #[salsa::invoke(crate::expr::body_hir)] |
109 | fn body_hir(&self, func: Function) -> Arc<crate::expr::Body>; | 109 | fn body_hir(&self, func: Function) -> Arc<crate::expr::Body>; |
110 | 110 | ||
111 | #[salsa::invoke(crate::expr::body_syntax_mapping)] | 111 | #[salsa::invoke(crate::expr::body_source_map)] |
112 | fn body_syntax_mapping(&self, func: Function) -> Arc<crate::expr::BodySyntaxMapping>; | 112 | fn body_source_map(&self, func: Function) -> Arc<crate::expr::BodySourceMap>; |
113 | 113 | ||
114 | #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)] | 114 | #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)] |
115 | fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>; | 115 | fn impls_in_crate(&self, krate: Crate) -> Arc<CrateImplBlocks>; |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index aa39d28ed..b1398411b 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -49,7 +49,7 @@ pub struct Body { | |||
49 | /// a structure that is agnostic to the actual positions of expressions in the | 49 | /// a structure that is agnostic to the actual positions of expressions in the |
50 | /// file, so that we don't recompute types whenever some whitespace is typed. | 50 | /// file, so that we don't recompute types whenever some whitespace is typed. |
51 | #[derive(Debug, Eq, PartialEq)] | 51 | #[derive(Debug, Eq, PartialEq)] |
52 | pub struct BodySyntaxMapping { | 52 | pub struct BodySourceMap { |
53 | body: Arc<Body>, | 53 | body: Arc<Body>, |
54 | expr_syntax_mapping: FxHashMap<SyntaxNodePtr, ExprId>, | 54 | expr_syntax_mapping: FxHashMap<SyntaxNodePtr, ExprId>, |
55 | expr_syntax_mapping_back: ArenaMap<ExprId, SyntaxNodePtr>, | 55 | expr_syntax_mapping_back: ArenaMap<ExprId, SyntaxNodePtr>, |
@@ -78,8 +78,8 @@ impl Body { | |||
78 | self.pats.iter() | 78 | self.pats.iter() |
79 | } | 79 | } |
80 | 80 | ||
81 | pub fn syntax_mapping(&self, db: &impl HirDatabase) -> Arc<BodySyntaxMapping> { | 81 | pub fn syntax_mapping(&self, db: &impl HirDatabase) -> Arc<BodySourceMap> { |
82 | db.body_syntax_mapping(self.owner) | 82 | db.body_source_map(self.owner) |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
@@ -119,7 +119,7 @@ impl Index<PatId> for Body { | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | impl BodySyntaxMapping { | 122 | impl BodySourceMap { |
123 | pub fn expr_syntax(&self, expr: ExprId) -> Option<SyntaxNodePtr> { | 123 | pub fn expr_syntax(&self, expr: ExprId) -> Option<SyntaxNodePtr> { |
124 | self.expr_syntax_mapping_back.get(expr).cloned() | 124 | self.expr_syntax_mapping_back.get(expr).cloned() |
125 | } | 125 | } |
@@ -468,7 +468,7 @@ impl Pat { | |||
468 | // Queries | 468 | // Queries |
469 | 469 | ||
470 | pub(crate) fn body_hir(db: &impl HirDatabase, func: Function) -> Arc<Body> { | 470 | pub(crate) fn body_hir(db: &impl HirDatabase, func: Function) -> Arc<Body> { |
471 | Arc::clone(&body_syntax_mapping(db, func).body) | 471 | Arc::clone(&body_source_map(db, func).body) |
472 | } | 472 | } |
473 | 473 | ||
474 | struct ExprCollector { | 474 | struct ExprCollector { |
@@ -910,7 +910,7 @@ impl ExprCollector { | |||
910 | self.body_expr = Some(body); | 910 | self.body_expr = Some(body); |
911 | } | 911 | } |
912 | 912 | ||
913 | fn into_body_syntax_mapping(self) -> BodySyntaxMapping { | 913 | fn into_body_source_map(self) -> BodySourceMap { |
914 | let body = Body { | 914 | let body = Body { |
915 | owner: self.owner, | 915 | owner: self.owner, |
916 | exprs: self.exprs, | 916 | exprs: self.exprs, |
@@ -918,7 +918,7 @@ impl ExprCollector { | |||
918 | params: self.params, | 918 | params: self.params, |
919 | body_expr: self.body_expr.expect("A body should have been collected"), | 919 | body_expr: self.body_expr.expect("A body should have been collected"), |
920 | }; | 920 | }; |
921 | BodySyntaxMapping { | 921 | BodySourceMap { |
922 | body: Arc::new(body), | 922 | body: Arc::new(body), |
923 | expr_syntax_mapping: self.expr_syntax_mapping, | 923 | expr_syntax_mapping: self.expr_syntax_mapping, |
924 | expr_syntax_mapping_back: self.expr_syntax_mapping_back, | 924 | expr_syntax_mapping_back: self.expr_syntax_mapping_back, |
@@ -928,18 +928,18 @@ impl ExprCollector { | |||
928 | } | 928 | } |
929 | } | 929 | } |
930 | 930 | ||
931 | pub(crate) fn body_syntax_mapping(db: &impl HirDatabase, func: Function) -> Arc<BodySyntaxMapping> { | 931 | pub(crate) fn body_source_map(db: &impl HirDatabase, func: Function) -> Arc<BodySourceMap> { |
932 | let mut collector = ExprCollector::new(func); | 932 | let mut collector = ExprCollector::new(func); |
933 | 933 | ||
934 | // TODO: consts, etc. | 934 | // TODO: consts, etc. |
935 | collector.collect_fn_body(&func.source(db).1); | 935 | collector.collect_fn_body(&func.source(db).1); |
936 | 936 | ||
937 | Arc::new(collector.into_body_syntax_mapping()) | 937 | Arc::new(collector.into_body_source_map()) |
938 | } | 938 | } |
939 | 939 | ||
940 | #[cfg(test)] | 940 | #[cfg(test)] |
941 | pub(crate) fn collect_fn_body_syntax(function: Function, node: &ast::FnDef) -> BodySyntaxMapping { | 941 | pub(crate) fn collect_fn_body_syntax(function: Function, node: &ast::FnDef) -> BodySourceMap { |
942 | let mut collector = ExprCollector::new(function); | 942 | let mut collector = ExprCollector::new(function); |
943 | collector.collect_fn_body(node); | 943 | collector.collect_fn_body(node); |
944 | collector.into_body_syntax_mapping() | 944 | collector.into_body_source_map() |
945 | } | 945 | } |
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index bb8d50db8..bb919dcfa 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs | |||
@@ -11,7 +11,7 @@ use ra_arena::{Arena, RawId, impl_arena_id}; | |||
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | Name, AsName, Function, | 13 | Name, AsName, Function, |
14 | expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}, | 14 | expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySourceMap}, |
15 | HirDatabase, | 15 | HirDatabase, |
16 | }; | 16 | }; |
17 | 17 | ||
@@ -109,7 +109,7 @@ impl ExprScopes { | |||
109 | 109 | ||
110 | #[derive(Debug, Clone, PartialEq, Eq)] | 110 | #[derive(Debug, Clone, PartialEq, Eq)] |
111 | pub struct ScopesWithSyntaxMapping { | 111 | pub struct ScopesWithSyntaxMapping { |
112 | pub syntax_mapping: Arc<BodySyntaxMapping>, | 112 | pub syntax_mapping: Arc<BodySourceMap>, |
113 | pub scopes: Arc<ExprScopes>, | 113 | pub scopes: Arc<ExprScopes>, |
114 | } | 114 | } |
115 | 115 | ||
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 8de46a29e..2fdfb54f4 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -1045,11 +1045,11 @@ fn test() { | |||
1045 | 1045 | ||
1046 | fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { | 1046 | fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { |
1047 | let func = source_binder::function_from_position(db, pos).unwrap(); | 1047 | let func = source_binder::function_from_position(db, pos).unwrap(); |
1048 | let body_syntax_mapping = func.body_syntax_mapping(db); | 1048 | let body_source_map = func.body_source_map(db); |
1049 | let inference_result = func.infer(db); | 1049 | let inference_result = func.infer(db); |
1050 | let (_, syntax) = func.source(db); | 1050 | let (_, syntax) = func.source(db); |
1051 | let node = algo::find_node_at_offset::<ast::Expr>(syntax.syntax(), pos.offset).unwrap(); | 1051 | let node = algo::find_node_at_offset::<ast::Expr>(syntax.syntax(), pos.offset).unwrap(); |
1052 | let expr = body_syntax_mapping.node_expr(node).unwrap(); | 1052 | let expr = body_source_map.node_expr(node).unwrap(); |
1053 | let ty = &inference_result[expr]; | 1053 | let ty = &inference_result[expr]; |
1054 | ty.to_string() | 1054 | ty.to_string() |
1055 | } | 1055 | } |
@@ -1061,17 +1061,17 @@ fn infer(content: &str) -> String { | |||
1061 | for fn_def in source_file.syntax().descendants().filter_map(ast::FnDef::cast) { | 1061 | for fn_def in source_file.syntax().descendants().filter_map(ast::FnDef::cast) { |
1062 | let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap(); | 1062 | let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap(); |
1063 | let inference_result = func.infer(&db); | 1063 | let inference_result = func.infer(&db); |
1064 | let body_syntax_mapping = func.body_syntax_mapping(&db); | 1064 | let body_source_map = func.body_source_map(&db); |
1065 | let mut types = Vec::new(); | 1065 | let mut types = Vec::new(); |
1066 | for (pat, ty) in inference_result.type_of_pat.iter() { | 1066 | for (pat, ty) in inference_result.type_of_pat.iter() { |
1067 | let syntax_ptr = match body_syntax_mapping.pat_syntax(pat) { | 1067 | let syntax_ptr = match body_source_map.pat_syntax(pat) { |
1068 | Some(sp) => sp, | 1068 | Some(sp) => sp, |
1069 | None => continue, | 1069 | None => continue, |
1070 | }; | 1070 | }; |
1071 | types.push((syntax_ptr, ty)); | 1071 | types.push((syntax_ptr, ty)); |
1072 | } | 1072 | } |
1073 | for (expr, ty) in inference_result.type_of_expr.iter() { | 1073 | for (expr, ty) in inference_result.type_of_expr.iter() { |
1074 | let syntax_ptr = match body_syntax_mapping.expr_syntax(expr) { | 1074 | let syntax_ptr = match body_source_map.expr_syntax(expr) { |
1075 | Some(sp) => sp, | 1075 | Some(sp) => sp, |
1076 | None => continue, | 1076 | None => continue, |
1077 | }; | 1077 | }; |
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs index 3f041f9c3..3fe54d47b 100644 --- a/crates/ra_ide_api/src/change.rs +++ b/crates/ra_ide_api/src/change.rs | |||
@@ -225,6 +225,6 @@ impl RootDatabase { | |||
225 | 225 | ||
226 | self.query(hir::db::LowerModuleQuery).sweep(sweep); | 226 | self.query(hir::db::LowerModuleQuery).sweep(sweep); |
227 | self.query(hir::db::LowerModuleSourceMapQuery).sweep(sweep); | 227 | self.query(hir::db::LowerModuleSourceMapQuery).sweep(sweep); |
228 | self.query(hir::db::BodySyntaxMappingQuery).sweep(sweep); | 228 | self.query(hir::db::BodySourceMapQuery).sweep(sweep); |
229 | } | 229 | } |
230 | } | 230 | } |
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index d5ad2e79f..cf6a6a388 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -9,7 +9,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { | |||
9 | _ => return, | 9 | _ => return, |
10 | }; | 10 | }; |
11 | let infer_result = function.infer(ctx.db); | 11 | let infer_result = function.infer(ctx.db); |
12 | let syntax_mapping = function.body_syntax_mapping(ctx.db); | 12 | let syntax_mapping = function.body_source_map(ctx.db); |
13 | let expr = match syntax_mapping.node_expr(receiver) { | 13 | let expr = match syntax_mapping.node_expr(receiver) { |
14 | Some(expr) => expr, | 14 | Some(expr) => expr, |
15 | None => return, | 15 | None => return, |
diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs index afb092f59..573953bda 100644 --- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs +++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs | |||
@@ -9,7 +9,7 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon | |||
9 | _ => return, | 9 | _ => return, |
10 | }; | 10 | }; |
11 | let infer_result = function.infer(ctx.db); | 11 | let infer_result = function.infer(ctx.db); |
12 | let syntax_mapping = function.body_syntax_mapping(ctx.db); | 12 | let syntax_mapping = function.body_source_map(ctx.db); |
13 | let expr = match syntax_mapping.node_expr(struct_lit.into()) { | 13 | let expr = match syntax_mapping.node_expr(struct_lit.into()) { |
14 | Some(expr) => expr, | 14 | Some(expr) => expr, |
15 | None => return, | 15 | None => return, |
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 6fa430754..9957a5393 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -54,7 +54,7 @@ pub(crate) fn reference_definition( | |||
54 | if let Some(method_call) = name_ref.syntax().parent().and_then(ast::MethodCallExpr::cast) { | 54 | if let Some(method_call) = name_ref.syntax().parent().and_then(ast::MethodCallExpr::cast) { |
55 | tested_by!(goto_definition_works_for_methods); | 55 | tested_by!(goto_definition_works_for_methods); |
56 | let infer_result = function.infer(db); | 56 | let infer_result = function.infer(db); |
57 | let syntax_mapping = function.body_syntax_mapping(db); | 57 | let syntax_mapping = function.body_source_map(db); |
58 | let expr = ast::Expr::cast(method_call.syntax()).unwrap(); | 58 | let expr = ast::Expr::cast(method_call.syntax()).unwrap(); |
59 | if let Some(func) = | 59 | if let Some(func) = |
60 | syntax_mapping.node_expr(expr).and_then(|it| infer_result.method_resolution(it)) | 60 | syntax_mapping.node_expr(expr).and_then(|it| infer_result.method_resolution(it)) |
@@ -66,7 +66,7 @@ pub(crate) fn reference_definition( | |||
66 | if let Some(field_expr) = name_ref.syntax().parent().and_then(ast::FieldExpr::cast) { | 66 | if let Some(field_expr) = name_ref.syntax().parent().and_then(ast::FieldExpr::cast) { |
67 | tested_by!(goto_definition_works_for_fields); | 67 | tested_by!(goto_definition_works_for_fields); |
68 | let infer_result = function.infer(db); | 68 | let infer_result = function.infer(db); |
69 | let syntax_mapping = function.body_syntax_mapping(db); | 69 | let syntax_mapping = function.body_source_map(db); |
70 | let expr = ast::Expr::cast(field_expr.syntax()).unwrap(); | 70 | let expr = ast::Expr::cast(field_expr.syntax()).unwrap(); |
71 | if let Some(field) = | 71 | if let Some(field) = |
72 | syntax_mapping.node_expr(expr).and_then(|it| infer_result.field_resolution(it)) | 72 | syntax_mapping.node_expr(expr).and_then(|it| infer_result.field_resolution(it)) |
@@ -80,7 +80,7 @@ pub(crate) fn reference_definition( | |||
80 | tested_by!(goto_definition_works_for_named_fields); | 80 | tested_by!(goto_definition_works_for_named_fields); |
81 | 81 | ||
82 | let infer_result = function.infer(db); | 82 | let infer_result = function.infer(db); |
83 | let syntax_mapping = function.body_syntax_mapping(db); | 83 | let syntax_mapping = function.body_source_map(db); |
84 | 84 | ||
85 | let struct_lit = field_expr.syntax().ancestors().find_map(ast::StructLit::cast); | 85 | let struct_lit = field_expr.syntax().ancestors().find_map(ast::StructLit::cast); |
86 | 86 | ||
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 1a1853df3..cceec91b9 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -132,7 +132,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> { | |||
132 | let parent_fn = node.ancestors().find_map(ast::FnDef::cast)?; | 132 | let parent_fn = node.ancestors().find_map(ast::FnDef::cast)?; |
133 | let function = hir::source_binder::function_from_source(db, frange.file_id, parent_fn)?; | 133 | let function = hir::source_binder::function_from_source(db, frange.file_id, parent_fn)?; |
134 | let infer = function.infer(db); | 134 | let infer = function.infer(db); |
135 | let syntax_mapping = function.body_syntax_mapping(db); | 135 | let syntax_mapping = function.body_source_map(db); |
136 | if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) { | 136 | if let Some(expr) = ast::Expr::cast(node).and_then(|e| syntax_mapping.node_expr(e)) { |
137 | Some(infer[expr].to_string()) | 137 | Some(infer[expr].to_string()) |
138 | } else if let Some(pat) = ast::Pat::cast(node).and_then(|p| syntax_mapping.node_pat(p)) { | 138 | } else if let Some(pat) = ast::Pat::cast(node).and_then(|p| syntax_mapping.node_pat(p)) { |