mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
rename scopes
This commit is contained in:
parent
ca957edf96
commit
fe5574b05a
4 changed files with 9 additions and 9 deletions
|
@ -5,7 +5,7 @@ use ra_db::{CrateId, SourceRootId, Edition};
|
||||||
use ra_syntax::{ast::self, TreeArc, SyntaxNode};
|
use ra_syntax::{ast::self, TreeArc, SyntaxNode};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Name, ScopesWithSyntaxMapping, Ty, HirFileId,
|
Name, ScopesWithSourceMap, Ty, HirFileId,
|
||||||
HirDatabase, PersistentHirDatabase,
|
HirDatabase, PersistentHirDatabase,
|
||||||
type_ref::TypeRef,
|
type_ref::TypeRef,
|
||||||
nameres::{ModuleScope, Namespace, lower::ImportId},
|
nameres::{ModuleScope, Namespace, lower::ImportId},
|
||||||
|
@ -495,10 +495,10 @@ impl Function {
|
||||||
db.type_for_def((*self).into(), Namespace::Values)
|
db.type_for_def((*self).into(), Namespace::Values)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSyntaxMapping {
|
pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSourceMap {
|
||||||
let scopes = db.expr_scopes(*self);
|
let scopes = db.expr_scopes(*self);
|
||||||
let source_map = db.body_with_source_map(*self).1;
|
let source_map = db.body_with_source_map(*self).1;
|
||||||
ScopesWithSyntaxMapping { scopes, source_map }
|
ScopesWithSourceMap { scopes, source_map }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signature(&self, db: &impl HirDatabase) -> Arc<FnSignature> {
|
pub fn signature(&self, db: &impl HirDatabase) -> Arc<FnSignature> {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use crate::{ path::GenericArgs, ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}};
|
use crate::{ path::GenericArgs, ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}};
|
||||||
|
|
||||||
pub use self::scope::{ExprScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax};
|
pub use self::scope::{ExprScopes, ScopesWithSourceMap, ScopeEntryWithSyntax};
|
||||||
|
|
||||||
pub(crate) mod scope;
|
pub(crate) mod scope;
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ impl ExprScopes {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct ScopesWithSyntaxMapping {
|
pub struct ScopesWithSourceMap {
|
||||||
pub source_map: Arc<BodySourceMap>,
|
pub source_map: Arc<BodySourceMap>,
|
||||||
pub scopes: Arc<ExprScopes>,
|
pub scopes: Arc<ExprScopes>,
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ impl ScopeEntryWithSyntax {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScopesWithSyntaxMapping {
|
impl ScopesWithSourceMap {
|
||||||
fn scope_chain<'a>(&'a self, node: &SyntaxNode) -> impl Iterator<Item = ScopeId> + 'a {
|
fn scope_chain<'a>(&'a self, node: &SyntaxNode) -> impl Iterator<Item = ScopeId> + 'a {
|
||||||
generate(self.scope_for(node), move |&scope| self.scopes.scopes[scope].parent)
|
generate(self.scope_for(node), move |&scope| self.scopes.scopes[scope].parent)
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ mod tests {
|
||||||
let (body, source_map) = expr::collect_fn_body_syntax(irrelevant_function, fn_def);
|
let (body, source_map) = expr::collect_fn_body_syntax(irrelevant_function, fn_def);
|
||||||
let scopes = ExprScopes::new(Arc::new(body));
|
let scopes = ExprScopes::new(Arc::new(body));
|
||||||
let scopes =
|
let scopes =
|
||||||
ScopesWithSyntaxMapping { scopes: Arc::new(scopes), source_map: Arc::new(source_map) };
|
ScopesWithSourceMap { scopes: Arc::new(scopes), source_map: Arc::new(source_map) };
|
||||||
let actual = scopes
|
let actual = scopes
|
||||||
.scope_chain(marker.syntax())
|
.scope_chain(marker.syntax())
|
||||||
.flat_map(|scope| scopes.scopes.entries(scope))
|
.flat_map(|scope| scopes.scopes.entries(scope))
|
||||||
|
@ -418,7 +418,7 @@ mod tests {
|
||||||
let (body, source_map) = expr::collect_fn_body_syntax(irrelevant_function, fn_def);
|
let (body, source_map) = expr::collect_fn_body_syntax(irrelevant_function, fn_def);
|
||||||
let scopes = ExprScopes::new(Arc::new(body));
|
let scopes = ExprScopes::new(Arc::new(body));
|
||||||
let scopes =
|
let scopes =
|
||||||
ScopesWithSyntaxMapping { scopes: Arc::new(scopes), source_map: Arc::new(source_map) };
|
ScopesWithSourceMap { scopes: Arc::new(scopes), source_map: Arc::new(source_map) };
|
||||||
let local_name_entry = scopes.resolve_local_name(name_ref).unwrap();
|
let local_name_entry = scopes.resolve_local_name(name_ref).unwrap();
|
||||||
let local_name = local_name_entry.ptr();
|
let local_name = local_name_entry.ptr();
|
||||||
assert_eq!(local_name.range(), expected_name.syntax().range());
|
assert_eq!(local_name.range(), expected_name.syntax().range());
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub use self::{
|
||||||
impl_block::{ImplBlock, ImplItem},
|
impl_block::{ImplBlock, ImplItem},
|
||||||
docs::{Docs, Documentation},
|
docs::{Docs, Documentation},
|
||||||
adt::AdtDef,
|
adt::AdtDef,
|
||||||
expr::{ExprScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax},
|
expr::{ExprScopes, ScopesWithSourceMap, ScopeEntryWithSyntax},
|
||||||
resolve::{Resolver, Resolution},
|
resolve::{Resolver, Resolution},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue