mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Move expr_scopes query to its module
This commit is contained in:
parent
65864d85f9
commit
1acff307fe
3 changed files with 17 additions and 11 deletions
|
@ -9,7 +9,11 @@ use ra_syntax::{
|
|||
};
|
||||
use ra_arena::{Arena, RawId, impl_arena_id};
|
||||
|
||||
use crate::{Name, AsName, expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}};
|
||||
use crate::{
|
||||
Name, AsName, Function,
|
||||
expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping},
|
||||
db::HirDatabase,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct ScopeId(RawId);
|
||||
|
@ -35,7 +39,14 @@ pub struct ScopeData {
|
|||
}
|
||||
|
||||
impl ExprScopes {
|
||||
pub(crate) fn new(body: Arc<Body>) -> ExprScopes {
|
||||
// TODO: This should take something more general than Function
|
||||
pub(crate) fn expr_scopes_query(db: &impl HirDatabase, function: Function) -> Arc<ExprScopes> {
|
||||
let body = db.body_hir(function);
|
||||
let res = ExprScopes::new(body);
|
||||
Arc::new(res)
|
||||
}
|
||||
|
||||
fn new(body: Arc<Body>) -> ExprScopes {
|
||||
let mut scopes = ExprScopes {
|
||||
body: body.clone(),
|
||||
scopes: Arena::default(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue