use logisheets_base::{
BlockCellId, CellId, Range, RangeId, SheetId,
block_affect::BlockAffectTrait,
get_book_name::GetBookNameTrait,
id_fetcher::{IdFetcherTrait, SheetIdFetcherByIdxTrait, VertexFetcherTrait},
index_fetcher::IndexFetcherTrait,
};
use crate::block_manager::schema_manager::schema::BlockCellRole;
use crate::formula_manager::Vertex;
use crate::sid_assigner::ShadowKind;
pub trait FormulaExecCtx:
SheetIdFetcherByIdxTrait
+ IdFetcherTrait
+ IndexFetcherTrait
+ BlockAffectTrait
+ GetBookNameTrait
+ VertexFetcherTrait
+ logisheets_parser::context::ContextTrait
{
fn get_cell_id_by_shadow_id(&self, shadow_id: &u64) -> Option<(SheetId, CellId)>;
fn get_range_deps(&self, vertex: &Vertex) -> Vec<Vertex>;
fn lookup_range(&self, sheet_id: SheetId, range_id: RangeId) -> Option<Range>;
fn block_cell_role(&self, sheet_id: SheetId, cell: &BlockCellId) -> BlockCellRole;
fn analyzed_by(
&self,
sheet_id: SheetId,
block_id: logisheets_base::BlockId,
) -> Vec<logisheets_base::BlockId>;
fn block_is_analysis(&self, sheet_id: SheetId, block_id: logisheets_base::BlockId) -> bool;
fn is_block_cell_templated(&self, sheet_id: SheetId, cell: &BlockCellId) -> bool;
fn block_cell_template(
&self,
sheet_id: SheetId,
cell: &BlockCellId,
) -> Option<BlockCellTemplate>;
fn block_cell_row_substitutes(
&self,
sheet_id: SheetId,
cell: &BlockCellId,
) -> Option<BlockCellRowContext>;
fn block_cell_at_key(
&self,
sheet_id: SheetId,
cell: &BlockCellId,
key: &str,
field: &str,
) -> Option<BlockCellId>;
fn block_cell_shadow_template(
&self,
sheet_id: SheetId,
cell: &BlockCellId,
kind: ShadowKind,
) -> Option<String>;
fn allocate_block_cell_shadow_id(
&mut self,
sheet_id: SheetId,
cell: &BlockCellId,
kind: ShadowKind,
) -> u64;
fn find_block_cell_shadow_id(
&self,
sheet_id: SheetId,
cell: &BlockCellId,
kind: ShadowKind,
) -> Option<u64>;
}
pub struct BlockCellTemplate {
pub template: String,
pub siblings: Vec<(String, BlockCellId)>,
pub key_value: String,
}
pub struct BlockCellRowContext {
pub siblings: Vec<(String, BlockCellId)>,
pub key_value: String,
}