get_or_parse_tree

Function get_or_parse_tree 

Source
pub fn get_or_parse_tree(
    file_path: &str,
    content: &str,
    parser: &mut Parser,
) -> Result<Tree>
Expand description

Get a cached tree if available, otherwise parse and cache the result

This function checks if a valid cached tree exists for the given file path and content. If found and the content hash matches, it returns the cached tree. Otherwise, it parses the content, caches the result, and returns the new tree.

§Arguments

  • file_path - The path of the file being parsed
  • content - The content to parse
  • parser - The tree-sitter parser to use if parsing is needed

§Returns

A Result containing the parsed tree, either from cache or freshly parsed