diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index a8e115e47..817e660f9 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -14,9 +14,9 @@ use crate::{ | |||
14 | name::AsName, | 14 | name::AsName, |
15 | type_ref::{Mutability, TypeRef}, | 15 | type_ref::{Mutability, TypeRef}, |
16 | }; | 16 | }; |
17 | use crate::{ path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; | 17 | use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; |
18 | 18 | ||
19 | pub use self::scope::{ExprScopes, ScopesWithSourceMap, ScopeEntryWithSyntax}; | 19 | pub use self::scope::ExprScopes; |
20 | 20 | ||
21 | pub(crate) mod scope; | 21 | pub(crate) mod scope; |
22 | 22 | ||
@@ -81,19 +81,23 @@ impl Body { | |||
81 | } | 81 | } |
82 | 82 | ||
83 | // needs arbitrary_self_types to be a method... or maybe move to the def? | 83 | // needs arbitrary_self_types to be a method... or maybe move to the def? |
84 | pub fn resolver_for_expr(body: Arc<Body>, db: &impl HirDatabase, expr_id: ExprId) -> Resolver { | 84 | pub(crate) fn resolver_for_expr( |
85 | body: Arc<Body>, | ||
86 | db: &impl HirDatabase, | ||
87 | expr_id: ExprId, | ||
88 | ) -> Resolver { | ||
85 | let scopes = db.expr_scopes(body.owner); | 89 | let scopes = db.expr_scopes(body.owner); |
86 | resolver_for_scope(body, db, scopes.scope_for(expr_id)) | 90 | resolver_for_scope(body, db, scopes.scope_for(expr_id)) |
87 | } | 91 | } |
88 | 92 | ||
89 | pub fn resolver_for_scope( | 93 | pub(crate) fn resolver_for_scope( |
90 | body: Arc<Body>, | 94 | body: Arc<Body>, |
91 | db: &impl HirDatabase, | 95 | db: &impl HirDatabase, |
92 | scope_id: Option<scope::ScopeId>, | 96 | scope_id: Option<scope::ScopeId>, |
93 | ) -> Resolver { | 97 | ) -> Resolver { |
94 | let mut r = body.owner.resolver(db); | 98 | let mut r = body.owner.resolver(db); |
95 | let scopes = db.expr_scopes(body.owner); | 99 | let scopes = db.expr_scopes(body.owner); |
96 | let scope_chain = scopes.scope_chain_for(scope_id).collect::<Vec<_>>(); | 100 | let scope_chain = scopes.scope_chain(scope_id).collect::<Vec<_>>(); |
97 | for scope in scope_chain.into_iter().rev() { | 101 | for scope in scope_chain.into_iter().rev() { |
98 | r = r.push_expr_scope(Arc::clone(&scopes), scope); | 102 | r = r.push_expr_scope(Arc::clone(&scopes), scope); |
99 | } | 103 | } |
@@ -117,31 +121,27 @@ impl Index<PatId> for Body { | |||
117 | } | 121 | } |
118 | 122 | ||
119 | impl BodySourceMap { | 123 | impl BodySourceMap { |
120 | pub fn expr_syntax(&self, expr: ExprId) -> Option<SyntaxNodePtr> { | 124 | pub(crate) fn expr_syntax(&self, expr: ExprId) -> Option<SyntaxNodePtr> { |
121 | self.expr_map_back.get(expr).cloned() | 125 | self.expr_map_back.get(expr).cloned() |
122 | } | 126 | } |
123 | 127 | ||
124 | pub fn syntax_expr(&self, ptr: SyntaxNodePtr) -> Option<ExprId> { | 128 | pub(crate) fn syntax_expr(&self, ptr: SyntaxNodePtr) -> Option<ExprId> { |
125 | self.expr_map.get(&ptr).cloned() | 129 | self.expr_map.get(&ptr).cloned() |
126 | } | 130 | } |
127 | 131 | ||
128 | pub fn node_expr(&self, node: &ast::Expr) -> Option<ExprId> { | 132 | pub(crate) fn node_expr(&self, node: &ast::Expr) -> Option<ExprId> { |
129 | self.expr_map.get(&SyntaxNodePtr::new(node.syntax())).cloned() | 133 | self.expr_map.get(&SyntaxNodePtr::new(node.syntax())).cloned() |
130 | } | 134 | } |
131 | 135 | ||
132 | pub fn pat_syntax(&self, pat: PatId) -> Option<PatPtr> { | 136 | pub(crate) fn pat_syntax(&self, pat: PatId) -> Option<PatPtr> { |
133 | self.pat_map_back.get(pat).cloned() | 137 | self.pat_map_back.get(pat).cloned() |
134 | } | 138 | } |
135 | 139 | ||
136 | pub fn syntax_pat(&self, ptr: PatPtr) -> Option<PatId> { | 140 | pub(crate) fn node_pat(&self, node: &ast::Pat) -> Option<PatId> { |
137 | self.pat_map.get(&ptr).cloned() | ||
138 | } | ||
139 | |||
140 | pub fn node_pat(&self, node: &ast::Pat) -> Option<PatId> { | ||
141 | self.pat_map.get(&Either::A(AstPtr::new(node))).cloned() | 141 | self.pat_map.get(&Either::A(AstPtr::new(node))).cloned() |
142 | } | 142 | } |
143 | 143 | ||
144 | pub fn field_syntax(&self, expr: ExprId, field: usize) -> AstPtr<ast::NamedField> { | 144 | pub(crate) fn field_syntax(&self, expr: ExprId, field: usize) -> AstPtr<ast::NamedField> { |
145 | self.field_map[&(expr, field)].clone() | 145 | self.field_map[&(expr, field)].clone() |
146 | } | 146 | } |
147 | } | 147 | } |