B
    ¤dÝSœ  ã               @   sh   d Z ddlZddlmZmZ e d¡dd„ ƒZe d¡dd„ ƒZe d	e 	¡ e 
¡ f ¡Ze d
¡ZdS )zRA module to ease code analysis

This module is here to help source code analysis.
é    N)ÚcodeanalyzeÚutilsé   c       	      C   s  t  | ¡}xPt| ƒD ]D\}}| | dkr6d||  }ndd|| d   }| |||¡ qW | ¡ pf| } t  | ¡}d}xdt | ¡D ]V}| ¡ }| ¡ }|dkr¦|d7 }|dkr¶|d8 }|d	kr‚|dkr‚| ||d d¡ q‚W | ¡ pæ| } |  	d
d¡ 	dd¡ 	dd	¡S )a7  Simplify `source` for analysis

    It replaces:

    * comments with spaces
    * strs with a new str filled with spaces
    * implicit and explicit continuations with spaces
    * tabs and semicolons with spaces

    The resulting code is a lot easier to analyze if we are interested
    only in offsets.
    ú#ú z"%s"é   r   z({[é   z)}]Ú
z\
z  ú	ú;)
r   ZChangeCollectorÚignored_regionsZ
add_changeZget_changedÚ_parensÚfinditerÚstartÚgroupÚreplace)	ÚsourceZ	collectorr   ÚendZreplacementZparensÚmatchÚiÚc© r   ú1lib/python3.7/site-packages/rope/base/simplify.pyÚ	real_code
   s(    

r   c             C   s   dd„ t  | ¡D ƒS )z=Return ignored regions like strings and comments in `source` c             S   s   g | ]}|  ¡ | ¡ f‘qS r   )r   r   )Ú.0r   r   r   r   ú
<listcomp>2   s    z#ignored_regions.<locals>.<listcomp>)Ú_strr   )r   r   r   r   r   /   s    r   z%s|%sz[\({\[\]}\)\n])Ú__doc__ÚreZ	rope.baser   r   Úcachedr   r   ÚcompileZget_comment_patternZget_string_patternr   r   r   r   r   r   Ú<module>   s   %