move ScopeEntryWithSyntax

This commit is contained in:
Aleksey Kladov 2019-04-13 11:24:09 +03:00
parent d387bdccba
commit f9e825d956
4 changed files with 34 additions and 37 deletions

View file

@ -14,9 +14,9 @@ use crate::{
name::AsName,
type_ref::{Mutability, TypeRef},
};
use crate::{ path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}};
use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}};
pub use self::scope::{ExprScopes, ScopeEntryWithSyntax};
pub use self::scope::ExprScopes;
pub(crate) mod scope;

View file

@ -1,14 +1,11 @@
use std::sync::Arc;
use rustc_hash::{FxHashMap};
use ra_syntax::{
TextRange, AstPtr,
ast,
};
use rustc_hash::FxHashMap;
use ra_syntax::TextRange;
use ra_arena::{Arena, RawId, impl_arena_id};
use crate::{
Name, DefWithBody, Either,
Name, DefWithBody,
expr::{PatId, ExprId, Pat, Expr, Body, Statement},
HirDatabase,
};
@ -30,6 +27,16 @@ pub(crate) struct ScopeEntry {
pat: PatId,
}
impl ScopeEntry {
pub(crate) fn name(&self) -> &Name {
&self.name
}
pub(crate) fn pat(&self) -> PatId {
self.pat
}
}
#[derive(Debug, PartialEq, Eq)]
pub(crate) struct ScopeData {
parent: Option<ScopeId>,
@ -100,32 +107,6 @@ impl ExprScopes {
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ScopeEntryWithSyntax {
pub(crate) name: Name,
pub(crate) ptr: Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>,
}
impl ScopeEntryWithSyntax {
pub fn name(&self) -> &Name {
&self.name
}
pub fn ptr(&self) -> Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>> {
self.ptr
}
}
impl ScopeEntry {
pub fn name(&self) -> &Name {
&self.name
}
pub fn pat(&self) -> PatId {
self.pat
}
}
fn compute_block_scopes(
statements: &[Statement],
tail: Option<ExprId>,

View file

@ -65,9 +65,9 @@ pub use self::{
impl_block::{ImplBlock, ImplItem},
docs::{Docs, Documentation},
adt::AdtDef,
expr::{ExprScopes, ScopeEntryWithSyntax},
expr::ExprScopes,
resolve::Resolution,
source_binder::{SourceAnalyzer, PathResolution},
source_binder::{SourceAnalyzer, PathResolution, ScopeEntryWithSyntax},
};
pub use self::code_model_api::{

View file

@ -19,7 +19,7 @@ use ra_syntax::{
use crate::{
HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name,
AsName, Module, HirFileId, Crate, Trait, Resolver,
expr::{BodySourceMap, scope::{ReferenceDescriptor, ScopeEntryWithSyntax, ScopeId, ExprScopes}},
expr::{BodySourceMap, scope::{ReferenceDescriptor, ScopeId, ExprScopes}},
ids::LocationCtx,
expr, AstId
};
@ -187,6 +187,22 @@ pub enum PathResolution {
AssocItem(crate::ImplItem),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ScopeEntryWithSyntax {
pub(crate) name: Name,
pub(crate) ptr: Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>,
}
impl ScopeEntryWithSyntax {
pub fn name(&self) -> &Name {
&self.name
}
pub fn ptr(&self) -> Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>> {
self.ptr
}
}
impl SourceAnalyzer {
pub fn new(
db: &impl HirDatabase,