diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index a31f086f7..ebb83d084 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -33,8 +33,7 @@ pub struct Body { | |||
33 | /// IDs. This is needed to go from e.g. a position in a file to the HIR | 33 | /// IDs. This is needed to go from e.g. a position in a file to the HIR |
34 | /// expression containing it; but for type inference etc., we want to operate on | 34 | /// expression containing it; but for type inference etc., we want to operate on |
35 | /// a structure that is agnostic to the actual positions of expressions in the | 35 | /// a structure that is agnostic to the actual positions of expressions in the |
36 | /// file, so that we don't recompute the type inference whenever some whitespace | 36 | /// file, so that we don't recompute types whenever some whitespace is typed. |
37 | /// is typed. | ||
38 | #[derive(Debug, Eq, PartialEq)] | 37 | #[derive(Debug, Eq, PartialEq)] |
39 | pub struct BodySyntaxMapping { | 38 | pub struct BodySyntaxMapping { |
40 | body: Arc<Body>, | 39 | body: Arc<Body>, |
@@ -74,20 +73,25 @@ impl BodySyntaxMapping { | |||
74 | pub fn expr_syntax(&self, expr: ExprId) -> Option<LocalSyntaxPtr> { | 73 | pub fn expr_syntax(&self, expr: ExprId) -> Option<LocalSyntaxPtr> { |
75 | self.expr_syntax_mapping_back.get(expr).cloned() | 74 | self.expr_syntax_mapping_back.get(expr).cloned() |
76 | } | 75 | } |
76 | |||
77 | pub fn syntax_expr(&self, ptr: LocalSyntaxPtr) -> Option<ExprId> { | 77 | pub fn syntax_expr(&self, ptr: LocalSyntaxPtr) -> Option<ExprId> { |
78 | self.expr_syntax_mapping.get(&ptr).cloned() | 78 | self.expr_syntax_mapping.get(&ptr).cloned() |
79 | } | 79 | } |
80 | |||
80 | pub fn node_expr(&self, node: &ast::Expr) -> Option<ExprId> { | 81 | pub fn node_expr(&self, node: &ast::Expr) -> Option<ExprId> { |
81 | self.expr_syntax_mapping | 82 | self.expr_syntax_mapping |
82 | .get(&LocalSyntaxPtr::new(node.syntax())) | 83 | .get(&LocalSyntaxPtr::new(node.syntax())) |
83 | .cloned() | 84 | .cloned() |
84 | } | 85 | } |
86 | |||
85 | pub fn pat_syntax(&self, pat: PatId) -> Option<LocalSyntaxPtr> { | 87 | pub fn pat_syntax(&self, pat: PatId) -> Option<LocalSyntaxPtr> { |
86 | self.pat_syntax_mapping_back.get(pat).cloned() | 88 | self.pat_syntax_mapping_back.get(pat).cloned() |
87 | } | 89 | } |
90 | |||
88 | pub fn syntax_pat(&self, ptr: LocalSyntaxPtr) -> Option<PatId> { | 91 | pub fn syntax_pat(&self, ptr: LocalSyntaxPtr) -> Option<PatId> { |
89 | self.pat_syntax_mapping.get(&ptr).cloned() | 92 | self.pat_syntax_mapping.get(&ptr).cloned() |
90 | } | 93 | } |
94 | |||
91 | pub fn node_pat(&self, node: &ast::Pat) -> Option<PatId> { | 95 | pub fn node_pat(&self, node: &ast::Pat) -> Option<PatId> { |
92 | self.pat_syntax_mapping | 96 | self.pat_syntax_mapping |
93 | .get(&LocalSyntaxPtr::new(node.syntax())) | 97 | .get(&LocalSyntaxPtr::new(node.syntax())) |