Ë
    oPêjÙ  ã                  ó~   — d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 dZ
e G d„ d	«      «       Z G d
„ d«      Zdd„Zy)z*Find functions and classes in Python code.é    )ÚannotationsN)Ú	dataclass)Úcast)Ú
CodeRegion)ÚbodyÚorelseÚ	finalbodyÚhandlersÚcasesc                  ó0   — e Zd ZU dZded<   ded<   ded<   y)ÚContextz0The nested named context of a function or class.ÚstrÚnameÚkindzset[int]ÚlinesN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    úU/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/coverage/regions.pyr   r      s   … á:à
ƒIØ
ƒIØ„Or   r   c                  óH   — e Zd ZdZd
d„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
y	)ÚRegionFinderz™An ast visitor that will find and track regions of code.

    Functions and classes are tracked by name. Results are in the .regions
    attribute.

    c                ó    — g | _         g | _        y ©N)ÚregionsÚcontext©Úselfs    r   Ú__init__zRegionFinder.__init__'   s   € Ø)+ˆŒØ&(ˆ�r   c                óL   — | j                  t        j                  |«      «       y)zCParse `source` and walk the ast to populate the .regions attribute.N)Úhandle_nodeÚastÚparse)r!   Úsources     r   Úparse_sourcezRegionFinder.parse_source+   s   € à×ÑœŸ™ 6Ó*Õ+r   c                óF   — dj                  d„ | j                  D «       «      S )z6Get the current fully qualified name we're processing.ú.c              3  ó4   K  — | ]  }|j                   –— Œ y ­wr   )r   )Ú.0Úcs     r   ú	<genexpr>z,RegionFinder.fq_node_name.<locals>.<genexpr>1   s   è ø€ Ò5 1˜Ÿ�Ñ5ùs   ‚)Újoinr   r    s    r   Úfq_node_namezRegionFinder.fq_node_name/   s   € à�x‰xÑ5¨¯©Ô5Ó5Ð5r   c                óö   — t        |t        j                  t        j                  f«      r| j	                  |«       yt        |t        j
                  «      r| j                  |«       y| j                  |«       y)zRecursively handle any node.N)Ú
isinstancer%   ÚFunctionDefÚAsyncFunctionDefÚhandle_FunctionDefÚClassDefÚhandle_ClassDefÚhandle_node_body)r!   Únodes     r   r$   zRegionFinder.handle_node3   sS   € ä�dœSŸ_™_¬c×.BÑ.BÐCÔDØ×#Ñ# DÕ)Ü˜œcŸl™lÔ+Ø× Ñ  Õ&à×!Ñ! $Õ'r   c                ó`   — t         D ]%  }t        ||d«      D ]  }| j                  |«       Œ Œ' y)zDRecursively handle the nodes in this node's statement lists, if any.r   N)ÚSTATEMENT_FIELDSÚgetattrr$   )r!   r9   ÚfieldÚ
stmts_nodes       r   r8   zRegionFinder.handle_node_body<   s7   € ä%ò 	-ˆEÜ% d¨E°2Ó6ò -�
Ø× Ñ  Õ,ñ-ñ	-r   c           
     óö  — t        t        |j                  d   j                  t	        t
        |j                  d   j                  «      dz   «      «      }| j                  r>| j                  d   j                  dk(  r"| j                  d   xj                  |z  c_	        t        | j                  «      D ](  }|j                  dk(  sŒ|xj                  |z  c_	         n | j                  j                  t        |j                  d|«      «       | j                  j                  t        d| j!                  «       |j                  |¬«      «       | j#                  |«       | j                  j%                  «        y)z Called for `def` or `async def`.r   éÿÿÿÿé   ÚclassÚfunction©r   r   Ústartr   N)ÚsetÚranger   Úlinenor   ÚintÚ
end_linenor   r   r   ÚreversedÚappendr   r   r   r   r0   r8   Úpop©r!   r9   r   Úancestors       r   r5   zRegionFinder.handle_FunctionDefB   s  € ä”E˜$Ÿ)™) A™,×-Ñ-¬t´C¸¿¹À2¹×9QÑ9QÓ/RÐUVÑ/VÓWÓXˆØ�<Š<˜DŸL™L¨Ñ,×1Ñ1°WÒ<à�L‰L˜Ñ×"Ò" eÑ+Õ"ä  §¡Ó.ò 	ˆHØ�}‰} 
Ó*Ø—’ %Ñ'•Ùð	ð 	�‰×ÑœG D§I¡I¨z¸5ÓAÔBØ�‰×ÑÜØØ×&Ñ&Ó(Ø—k‘kØô	ô	
ð 	×Ñ˜dÔ#Ø�‰×ÑÕr   c                óÌ  — t        «       }| j                  j                  t        |j                  d|«      «       | j
                  j                  t        d| j                  «       |j                  |¬«      «       | j                  |«       | j                  j                  «        t        | j                  «      D ]'  }|j                  dk(  sŒ|xj                  |z  c_        Œ) y)zCalled for `class`.rB   rD   N)rF   r   rL   r   r   r   r   r0   rH   r8   rM   rK   r   r   rN   s       r   r7   zRegionFinder.handle_ClassDefY   s¯   € ô
 ›%ˆØ�‰×ÑœG D§I¡I¨w¸Ó>Ô?Ø�‰×ÑÜØØ×&Ñ&Ó(Ø—k‘kØô	ô	
ð 	×Ñ˜dÔ#Ø�‰×ÑÔä  §¡Ó.ò 	(ˆHØ�}‰} Ó'Ø—’ %Ñ'–ñ	(r   N)ÚreturnÚNone)r'   r   rQ   rR   )rQ   r   )r9   zast.ASTrQ   rR   )r9   z&ast.FunctionDef | ast.AsyncFunctionDefrQ   rR   )r9   zast.ClassDefrQ   rR   )r   r   r   r   r"   r(   r0   r$   r8   r5   r7   r   r   r   r   r      s*   „ ñó)ó,ó6ó(ó-óô.(r   r   c                óP   — t        «       }|j                  | «       |j                  S )a]  Find function and class regions in source code.

    Analyzes the code in `source`, and returns a list of :class:`CodeRegion`
    objects describing functions and classes as regions of the code::

        [
            CodeRegion(kind="function", name="func1", start=8, lines={10, 11, 12}),
            CodeRegion(kind="function", name="MyClass.method", start=30, lines={34, 35, 36}),
            CodeRegion(kind="class", name="MyClass", start=25, lines={34, 35, 36}),
        ]

    The line numbers will include comments and blank lines.  Later processing
    will need to ignore those lines as needed.

    Nested functions and classes are excluded from their enclosing region.  No
    line should be reported as being part of more than one function, or more
    than one class.  Lines in methods are reported as being in a function and
    in a class.

    )r   r(   r   )r'   Úrfs     r   Úcode_regionsrU   p   s!   € ô* 
‹€BØ‡O�O�FÔØ�:‰:Ðr   )r'   r   rQ   zlist[CodeRegion])r   Ú
__future__r   r%   Údataclassesr   Útypingr   Úcoverage.pluginr   r;   r   r   rU   r   r   r   ú<module>rZ      sO   ðñ 1õ #ã 
Ý !Ý å &ð
 HÐ ð ÷ð ó ð÷N(ñ N(ôbr   