[docs]classSourceFile:"""Represents a parsed source file. Parses the given file into a translation unit and provides access to recognized top-level node elements. Parameters ---------- file_path: Path to the Zig source file to parse. lazy_parsing: If True, the underlying `PyTranslationUnit` will **not** be created during construction. Instead, parsing is deferred until the translation unit or other derived properties (like `.content`) are first accessed. .. versionadded:: 0.1.3 """def__init__(self,file_path:str,lazy_parsing:bool=False)->None:self._file_path=file_pathself._unit:Optional[PyTranslationUnit]=Noneiflazy_parsingelse(PyTranslationUnit.from_path(lib=get_native_library(),path=file_path))self._content:Optional[list[INodeElement]]=Noneself._errors:Optional[list[ErrorReport]]=Nonedef__repr__(self)->str:returnf"SourceFile(path={self.path})"@propertydefcontent(self)->list[INodeElement]:"""A list of top-level elements parsed from the file."""ifself._contentisNone:self._content=[]fornodeinself.unit.root_nodes():fornode_typeinself.types:ifnode_type.is_node_valid(node):self._content.append(node_type.from_node(node))returnself._content@propertydefpath(self)->str:"""The parsed file path."""returnself._file_path@propertydeferrors(self)->list[ErrorReport]:"""A list of error reports that occurred during parsing this file."""ifself._errorsisNone:self._errors=self.unit.errors()returnself._errors@propertydefunit(self)->PyTranslationUnit:""" The parsed translation unit for this file. .. versionadded:: 0.1.3 """ifself._unitisNone:self._unit=PyTranslationUnit.from_path(lib=get_native_library(),path=self._file_path)returnself._unit@propertydeftypes(self)->tuple[type[INodeElement],...]:"""Supported top-level node element types."""returnFunctionDeclaration,VariableDeclaration,TestDeclaration