diff options
Diffstat (limited to 'crates/ra_hir/src/expr')
-rw-r--r-- | crates/ra_hir/src/expr/scope.rs | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 6a6de5772..090343d12 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs | |||
@@ -1,14 +1,11 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use rustc_hash::{FxHashMap}; | 3 | use rustc_hash::FxHashMap; |
4 | use ra_syntax::{ | 4 | use ra_syntax::TextRange; |
5 | TextRange, AstPtr, | ||
6 | ast, | ||
7 | }; | ||
8 | use ra_arena::{Arena, RawId, impl_arena_id}; | 5 | use ra_arena::{Arena, RawId, impl_arena_id}; |
9 | 6 | ||
10 | use crate::{ | 7 | use crate::{ |
11 | Name, DefWithBody, Either, | 8 | Name, DefWithBody, |
12 | expr::{PatId, ExprId, Pat, Expr, Body, Statement}, | 9 | expr::{PatId, ExprId, Pat, Expr, Body, Statement}, |
13 | HirDatabase, | 10 | HirDatabase, |
14 | }; | 11 | }; |
@@ -30,6 +27,16 @@ pub(crate) struct ScopeEntry { | |||
30 | pat: PatId, | 27 | pat: PatId, |
31 | } | 28 | } |
32 | 29 | ||
30 | impl ScopeEntry { | ||
31 | pub(crate) fn name(&self) -> &Name { | ||
32 | &self.name | ||
33 | } | ||
34 | |||
35 | pub(crate) fn pat(&self) -> PatId { | ||
36 | self.pat | ||
37 | } | ||
38 | } | ||
39 | |||
33 | #[derive(Debug, PartialEq, Eq)] | 40 | #[derive(Debug, PartialEq, Eq)] |
34 | pub(crate) struct ScopeData { | 41 | pub(crate) struct ScopeData { |
35 | parent: Option<ScopeId>, | 42 | parent: Option<ScopeId>, |
@@ -100,32 +107,6 @@ impl ExprScopes { | |||
100 | } | 107 | } |
101 | } | 108 | } |
102 | 109 | ||
103 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
104 | pub struct ScopeEntryWithSyntax { | ||
105 | pub(crate) name: Name, | ||
106 | pub(crate) ptr: Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>, | ||
107 | } | ||
108 | |||
109 | impl ScopeEntryWithSyntax { | ||
110 | pub fn name(&self) -> &Name { | ||
111 | &self.name | ||
112 | } | ||
113 | |||
114 | pub fn ptr(&self) -> Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>> { | ||
115 | self.ptr | ||
116 | } | ||
117 | } | ||
118 | |||
119 | impl ScopeEntry { | ||
120 | pub fn name(&self) -> &Name { | ||
121 | &self.name | ||
122 | } | ||
123 | |||
124 | pub fn pat(&self) -> PatId { | ||
125 | self.pat | ||
126 | } | ||
127 | } | ||
128 | |||
129 | fn compute_block_scopes( | 110 | fn compute_block_scopes( |
130 | statements: &[Statement], | 111 | statements: &[Statement], |
131 | tail: Option<ExprId>, | 112 | tail: Option<ExprId>, |