diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 22 |
1 files changed, 11 insertions, 11 deletions
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 | } |