pub struct Context {
pub file_path: PathBuf,
pub config: QuickmarkConfig,
pub lines: RefCell<Vec<String>>,
pub node_cache: RefCell<HashMap<String, Vec<NodeInfo>>>,
pub document_content: RefCell<String>,
}Expand description
SINGLE-USE CONTRACT: Context instances are designed for one-time use only.
Each Context instance should be used to analyze exactly one source document. The lazy initialization of caches (lines, node_cache) happens once and the context becomes immutable after that point.
Fields§
§file_path: PathBuf§config: QuickmarkConfig§lines: RefCell<Vec<String>>Raw text lines for line-based rules (MD013, MD010, etc.) - initialized once per document
node_cache: RefCell<HashMap<String, Vec<NodeInfo>>>Cached AST nodes filtered by type for efficient access - initialized once per document
document_content: RefCell<String>Original document content for byte-based access - initialized once per document
Implementations§
Source§impl Context
impl Context
pub fn new( file_path: PathBuf, config: QuickmarkConfig, source: &str, root_node: &Node<'_>, ) -> Self
Sourcepub fn get_document_content(&self) -> Ref<'_, String>
pub fn get_document_content(&self) -> Ref<'_, String>
Get the full document content as a string reference Returns a reference to the original document content stored during initialization
Sourcepub fn get_nodes(&self, node_types: &[&str]) -> Vec<NodeInfo>
pub fn get_nodes(&self, node_types: &[&str]) -> Vec<NodeInfo>
Get cached nodes of specific types - optimized equivalent of filterByTypesCached
Sourcepub fn get_node_type_for_line(&self, line_number: usize) -> String
pub fn get_node_type_for_line(&self, line_number: usize) -> String
Get the most specific node type that contains a given line number