aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_hir/src/expr.rs4
-rw-r--r--crates/ra_hir/src/expr/scope.rs45
-rw-r--r--crates/ra_hir/src/lib.rs4
-rw-r--r--crates/ra_hir/src/source_binder.rs18
4 files changed, 34 insertions, 37 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 239874792..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};
17use crate::{ path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; 17use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}};
18 18
19pub use self::scope::{ExprScopes, ScopeEntryWithSyntax}; 19pub use self::scope::ExprScopes;
20 20
21pub(crate) mod scope; 21pub(crate) mod scope;
22 22
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 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use rustc_hash::{FxHashMap}; 3use rustc_hash::FxHashMap;
4use ra_syntax::{ 4use ra_syntax::TextRange;
5 TextRange, AstPtr,
6 ast,
7};
8use ra_arena::{Arena, RawId, impl_arena_id}; 5use ra_arena::{Arena, RawId, impl_arena_id};
9 6
10use crate::{ 7use 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
30impl 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)]
34pub(crate) struct ScopeData { 41pub(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)]
104pub struct ScopeEntryWithSyntax {
105 pub(crate) name: Name,
106 pub(crate) ptr: Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>,
107}
108
109impl 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
119impl ScopeEntry {
120 pub fn name(&self) -> &Name {
121 &self.name
122 }
123
124 pub fn pat(&self) -> PatId {
125 self.pat
126 }
127}
128
129fn compute_block_scopes( 110fn compute_block_scopes(
130 statements: &[Statement], 111 statements: &[Statement],
131 tail: Option<ExprId>, 112 tail: Option<ExprId>,
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 5eb2f32bd..a9db23060 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -65,9 +65,9 @@ pub use self::{
65 impl_block::{ImplBlock, ImplItem}, 65 impl_block::{ImplBlock, ImplItem},
66 docs::{Docs, Documentation}, 66 docs::{Docs, Documentation},
67 adt::AdtDef, 67 adt::AdtDef,
68 expr::{ExprScopes, ScopeEntryWithSyntax}, 68 expr::ExprScopes,
69 resolve::Resolution, 69 resolve::Resolution,
70 source_binder::{SourceAnalyzer, PathResolution}, 70 source_binder::{SourceAnalyzer, PathResolution, ScopeEntryWithSyntax},
71}; 71};
72 72
73pub use self::code_model_api::{ 73pub use self::code_model_api::{
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index a50287339..34a00a300 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -19,7 +19,7 @@ use ra_syntax::{
19use crate::{ 19use crate::{
20 HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, 20 HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name,
21 AsName, Module, HirFileId, Crate, Trait, Resolver, 21 AsName, Module, HirFileId, Crate, Trait, Resolver,
22 expr::{BodySourceMap, scope::{ReferenceDescriptor, ScopeEntryWithSyntax, ScopeId, ExprScopes}}, 22 expr::{BodySourceMap, scope::{ReferenceDescriptor, ScopeId, ExprScopes}},
23 ids::LocationCtx, 23 ids::LocationCtx,
24 expr, AstId 24 expr, AstId
25}; 25};
@@ -187,6 +187,22 @@ pub enum PathResolution {
187 AssocItem(crate::ImplItem), 187 AssocItem(crate::ImplItem),
188} 188}
189 189
190#[derive(Debug, Clone, PartialEq, Eq)]
191pub struct ScopeEntryWithSyntax {
192 pub(crate) name: Name,
193 pub(crate) ptr: Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>,
194}
195
196impl ScopeEntryWithSyntax {
197 pub fn name(&self) -> &Name {
198 &self.name
199 }
200
201 pub fn ptr(&self) -> Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>> {
202 self.ptr
203 }
204}
205
190impl SourceAnalyzer { 206impl SourceAnalyzer {
191 pub fn new( 207 pub fn new(
192 db: &impl HirDatabase, 208 db: &impl HirDatabase,