Move expr_scopes query to its module
This commit is contained in:
parent
65864d85f9
commit
1acff307fe
@ -27,7 +27,7 @@ pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> {
|
||||
#[salsa::invoke(crate::macros::expand_macro_invocation)]
|
||||
fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>;
|
||||
|
||||
#[salsa::invoke(query_definitions::expr_scopes)]
|
||||
#[salsa::invoke(ExprScopes::expr_scopes_query)]
|
||||
fn expr_scopes(&self, func: Function) -> Arc<ExprScopes>;
|
||||
|
||||
#[salsa::invoke(crate::adt::StructData::struct_data_query)]
|
||||
|
@ -9,7 +9,11 @@
|
||||
};
|
||||
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(),
|
||||
|
@ -1,19 +1,14 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_syntax::{SyntaxNode, TreeArc};
|
||||
use ra_syntax::{
|
||||
SyntaxNode, TreeArc,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
SourceFileItems, SourceItemId, HirFileId,
|
||||
Function, ExprScopes,
|
||||
db::HirDatabase,
|
||||
};
|
||||
|
||||
pub(super) fn expr_scopes(db: &impl HirDatabase, func: Function) -> Arc<ExprScopes> {
|
||||
let body = db.body_hir(func);
|
||||
let res = ExprScopes::new(body);
|
||||
Arc::new(res)
|
||||
}
|
||||
|
||||
pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> {
|
||||
let source_file = db.hir_parse(file_id);
|
||||
let res = SourceFileItems::new(file_id, &source_file);
|
||||
|
Loading…
Reference in New Issue
Block a user