diff options
author | Aleksey Kladov <[email protected]> | 2019-04-13 09:24:09 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-04-13 09:24:09 +0100 |
commit | f9e825d95624129b66c34f25904f6ae46b9d5760 (patch) | |
tree | dd58a7e954b8479abf218a5da5245542c091f529 /crates | |
parent | d387bdccba2b5bb681e5b6c84cc1b0efe5c1a79a (diff) |
move ScopeEntryWithSyntax
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/expr/scope.rs | 45 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 18 |
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 | }; |
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, ScopeEntryWithSyntax}; | 19 | pub use self::scope::ExprScopes; |
20 | 20 | ||
21 | pub(crate) mod scope; | 21 | pub(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 @@ | |||
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>, |
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 | ||
73 | pub use self::code_model_api::{ | 73 | pub 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::{ | |||
19 | use crate::{ | 19 | use 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)] | ||
191 | pub struct ScopeEntryWithSyntax { | ||
192 | pub(crate) name: Name, | ||
193 | pub(crate) ptr: Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>, | ||
194 | } | ||
195 | |||
196 | impl 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 | |||
190 | impl SourceAnalyzer { | 206 | impl SourceAnalyzer { |
191 | pub fn new( | 207 | pub fn new( |
192 | db: &impl HirDatabase, | 208 | db: &impl HirDatabase, |