pub struct ParsedDocument<D: Doc> {
pub ast_root: Root<D>,
pub file_path: PathBuf,
pub language: SupportLang,
pub content_fingerprint: Fingerprint,
pub metadata: DocumentMetadata,
/* private fields */
}Expand description
A parsed document that wraps ast-grep Root with additional codebase-level metadata.
This type preserves all ast-grep functionality while adding context needed for cross-file analysis and graph intelligence. It acts as the bridge between file-level AST operations and codebase-level relational analysis.
Fields§
§ast_root: Root<D>The underlying ast-grep Root - preserves all ast-grep functionality
file_path: PathBufSource file path for this document
language: SupportLangLanguage of this document
content_fingerprint: FingerprintContent fingerprint for deduplication and change detection (blake3 hash)
metadata: DocumentMetadataCodebase-level metadata (symbols, imports, exports, etc.)
Implementations§
Source§impl<D: Doc> ParsedDocument<D>
impl<D: Doc> ParsedDocument<D>
Sourcepub fn new(
ast_root: Root<D>,
file_path: PathBuf,
language: SupportLang,
content_fingerprint: Fingerprint,
) -> Self
pub fn new( ast_root: Root<D>, file_path: PathBuf, language: SupportLang, content_fingerprint: Fingerprint, ) -> Self
Create a new ParsedDocument wrapping an ast-grep Root
Sourcepub fn ast_grep_root(&self) -> &Root<D>
pub fn ast_grep_root(&self) -> &Root<D>
Get the underlying ast-grep Root for full access to capabilities
Sourcepub fn ast_grep_root_mut(&mut self) -> &mut Root<D>
pub fn ast_grep_root_mut(&mut self) -> &mut Root<D>
Get mutable access to ast-grep Root for replacements
Sourcepub fn pin_for_threading(&self) -> PinnedNodeResult<D>
pub fn pin_for_threading(&self) -> PinnedNodeResult<D>
Create a pinned version for cross-thread/FFI usage
Sourcepub fn generate(&self) -> String
pub fn generate(&self) -> String
Generate the source code (preserves ast-grep replacement functionality)
Sourcepub fn metadata(&self) -> &DocumentMetadata
pub fn metadata(&self) -> &DocumentMetadata
Get document metadata for codebase-level analysis
Sourcepub fn metadata_mut(&mut self) -> &mut DocumentMetadata
pub fn metadata_mut(&mut self) -> &mut DocumentMetadata
Get mutable document metadata