make expr scope stuff private
This commit is contained in:
parent
a2cc76ce63
commit
4f8dc1b9f0
1 changed files with 9 additions and 11 deletions
|
@ -3,7 +3,6 @@ use std::sync::Arc;
|
||||||
use rustc_hash::{FxHashMap};
|
use rustc_hash::{FxHashMap};
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
TextRange, AstPtr,
|
TextRange, AstPtr,
|
||||||
algo::generate,
|
|
||||||
ast,
|
ast,
|
||||||
};
|
};
|
||||||
use ra_arena::{Arena, RawId, impl_arena_id};
|
use ra_arena::{Arena, RawId, impl_arena_id};
|
||||||
|
@ -26,13 +25,13 @@ pub struct ExprScopes {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct ScopeEntry {
|
pub(crate) struct ScopeEntry {
|
||||||
name: Name,
|
name: Name,
|
||||||
pat: PatId,
|
pat: PatId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct ScopeData {
|
pub(crate) struct ScopeData {
|
||||||
parent: Option<ScopeId>,
|
parent: Option<ScopeId>,
|
||||||
entries: Vec<ScopeEntry>,
|
entries: Vec<ScopeEntry>,
|
||||||
}
|
}
|
||||||
|
@ -57,16 +56,15 @@ impl ExprScopes {
|
||||||
scopes
|
scopes
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn body(&self) -> Arc<Body> {
|
pub(crate) fn entries(&self, scope: ScopeId) -> &[ScopeEntry] {
|
||||||
self.body.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn entries(&self, scope: ScopeId) -> &[ScopeEntry] {
|
|
||||||
&self.scopes[scope].entries
|
&self.scopes[scope].entries
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scope_chain<'a>(&'a self, scope: Option<ScopeId>) -> impl Iterator<Item = ScopeId> + 'a {
|
pub(crate) fn scope_chain<'a>(
|
||||||
generate(scope, move |&scope| self.scopes[scope].parent)
|
&'a self,
|
||||||
|
scope: Option<ScopeId>,
|
||||||
|
) -> impl Iterator<Item = ScopeId> + 'a {
|
||||||
|
std::iter::successors(scope, move |&scope| self.scopes[scope].parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root_scope(&mut self) -> ScopeId {
|
fn root_scope(&mut self) -> ScopeId {
|
||||||
|
@ -98,7 +96,7 @@ impl ExprScopes {
|
||||||
self.scope_for.insert(node, scope);
|
self.scope_for.insert(node, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scope_for(&self, expr: ExprId) -> Option<ScopeId> {
|
pub(crate) fn scope_for(&self, expr: ExprId) -> Option<ScopeId> {
|
||||||
self.scope_for.get(&expr).map(|&scope| scope)
|
self.scope_for.get(&expr).map(|&scope| scope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue