
    c                     |   d dl Z d dlmZ d dlmZ d dlmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZmZmZmZmZ  G d	 d
          Z G d de          Z G d de          Z G d d          Z G d d          Z G d d          Z G d d          Z G d d          Z G d dej                  Z G d d          Z G d dej                  Z d Z! G d  d!ej                  Z" G d" d#ej                  Z# G d$ d%e#          Z$ G d& d'e#          Z% G d( d)ej                  Z&d* Z'd+ Z(d, Z)d- Z*dS ).    N)contextmanager)chain)astcodeanalyze)ChangeContents	ChangeSetRefactoringError)
OrderedSet)
patchedastsimilarfindersourceutilssuitesusefunctionc                   `    e Zd Zi Zd
dZd Zd ZddZd Ze	d             Z
ed	             ZdS )_ExtractRefactoringFc                     || _         || _        |                     |                                |          | _        |                     |                                |          | _        d S N)projectresource
_fix_startreadstart_offset_fix_end
end_offset)selfr   r   r   r   variables         5lib/python3.11/site-packages/rope/refactor/extract.py__init__z_ExtractRefactoring.__init__(   sO      OOHMMOO\JJ--DD    c                     |t          |          k     rL||                                         r2|dz  }|t          |          k     r||                                         2|S N   )lenisspacer   sourceoffsets      r   r   z_ExtractRefactoring._fix_start.   sf    s6{{" 	vf~'='='?'? 	aKF s6{{" 	vf~'='='?'? 	r    c                     |dk    rE||dz
                                            r(|dz  }|dk    r||dz
                                            (|S Nr   r#   )r%   r&   s      r   r   z_ExtractRefactoring._fix_end3   sb    qj 	VFQJ/7799 	aKF qj 	VFQJ/7799 	r    Nc           
         |                      ||          \  }}t          | j        | j        | j        | j        ||                     |          dk    ||          }|                     |          |_        t          |          	                                }t          d|j         d| d          }|                    t          | j        |                     |S )a  Get the changes this refactoring makes

        :parameters:
            - `extracted_name`: target name, when starts with @ - set kind to
            classmethod, $ - staticmethod
            - `similar`: if `True`, similar expressions/statements are also
              replaced.
            - `global_`: if `True`, the extracted method/variable will
              be global.
            - `kind`: kind of target refactoring to (staticmethod, classmethod)

        r   )r   similarmake_globalzExtract z <>)_get_kind_from_name_ExtractInfor   r   r   r   	_get_kindkind_ExtractPerformerextractr   
add_changer   )r   extracted_namer,   global_r2   infonew_contentschangess           r   get_changesz_ExtractRefactoring.get_changes8   s      $77MMLMO^^D))Z7	
 	
 	
 NN4((	(..6688EtyEENEEEFF>$-FFGGGr    c                     | j                                         D ]>\  }}|                    |          r$|                     ||           |dd          |fc S ?||fS r"   )kind_prefixesitems
startswith_validate_kind_prefix)r   r6   r2   signselected_kinds        r   r/   z'_ExtractRefactoring._get_kind_from_nameW   s}    #'#5#;#;#=#= 	9 	9D-((.. 9**4???%abb)=88889 t##r    c                 8    | r| |k    rt          d          d S d S )Nz"Kind and shortcut in name mismatchr	   )r2   rB   s     r   r@   z)_ExtractRefactoring._validate_kind_prefix^   s?     	IDM) 	I"#GHHH	I 	I 	I 	Ir    c                 &    t          d|            )NzYou have to subclass )NotImplementedErrorclsr2   s     r   r1   z_ExtractRefactoring._get_kindc   s    !"?#"?"?@@@r    F)FFN)__name__
__module____qualname__r=   r   r   r   r;   r/   staticmethodr@   classmethodr1    r    r   r   r   $   s        ME E E E  
  
   >$ $ $ I I \I A A [A A Ar    r   c                   6    e Zd ZdZdZdddZed             ZdS )ExtractMethodmethod)functionrQ   rL   rM   rM   rL   )@$c                 &    || j         v r|n| j        S r   )allowed_kindsr2   rF   s     r   r1   zExtractMethod._get_kindm   s    s00>ttch>r    N)rI   rJ   rK   r2   rV   r=   rM   r1   rN   r    r   rP   rP   h   sD        DIM'n==M? ? [? ? ?r    rP   c                   (     e Zd Z fdZdZd Z xZS )ExtractVariablec                 b    t          |          }d|d<    t                      j        |i | d S )NTr   )dictsuperr   )r   argskwds	__class__s      r   r   zExtractVariable.__init__s   s:    DzzZ$'$'''''r    r   c                     | j         S r   )r2   rF   s     r   r1   zExtractVariable._get_kindz   s	    xr    )rI   rJ   rK   r   r2   r1   __classcell__)r^   s   @r   rX   rX   r   sN        ( ( ( ( (
 D      r    rX   c                   4   e Zd ZdZd Zd Zed             Zd Zd Z	ddZ
ed	             Zed
             Zed             Zed             Zed             Zed             ZdZed             ZdZed             ZdZed             ZdZed             ZdS )r0   z3Holds information about the extract to be performedc	                 p   || _         || _        |                    |          | _        | j                                        | _        | j        j        | _        | j        j        | _        || _	        || _
        || _        |                     ||           d | _        |                                  || _        d S r   )r   r   get_pymodulepymodule	get_scopeglobal_scopesource_coder'   linesnew_namer   r,   _init_partsr2   _init_scoper-   )	r   r   r   startendri   r   r,   r-   s	            r   r   z_ExtractInfo.__init__   s      ,,X66 M3355m/](
  $$$	&r    c                 $   |                      |          |                      |d          f| _        | j                            | j                            | j        d                             d         }| j                            | j                            | j        d                             d         }||f| _        | j                            | j        d                   | j                            | j        d                   f| _	        d S )NT)rm   r   r#   )
_choose_closest_line_endregionlogical_lineslogical_line_inrh   get_line_numberregion_linesget_line_startget_line_endlines_region)r   rl   rm   s      r   rj   z_ExtractInfo._init_parts   s    ))%00))#4)88

 "22J&&t{1~66
 

  00J&&t{1~66
 

 #CL J%%d&7&:;;J##D$5a$899
r    c                     | j         j        S r   )rd   rq   r   s    r   rq   z_ExtractInfo.logical_lines   s    }**r    c                    | j         d         }| j                            |          }|                                dk    r|                                |k    r|j        }|| _        |                     | j                  | _        d S )Nr   Module)	rt   rf   get_inner_scope_for_lineget_kind	get_startparentscope_get_scope_regionscope_region)r   
start_liner   s      r   rk   z_ExtractInfo._init_scope   s~    &q)
!:::FF>>x' 	!EOO,=,=,K 	!LE
 224:>>r    c                     | j                             |                                          | j                             |                                          dz   fS r"   )rh   ru   r~   rv   get_end)r   r   s     r   r   z_ExtractInfo._get_scope_region   sI    J%%eoo&7&788J##EMMOO44q8
 	
r    Fc                    | j                             |          }| j                             |          }| j                             |          }| j        ||                                         dk    r	|r|dz
  S |S | j        ||                                         dk    r"t          |t          | j                            S |S )N r#   )rh   rs   ru   rv   r'   stripminr$   )r   r(   rm   lineno
line_startline_ends         r   ro   z%_ExtractInfo._choose_closest_line_end   s    ++F33Z..v66
:**622;z&()//11R7 	3 "!A~%!![)//11R7 	3xT[!1!1222r    c                     | j         | j        k    oK| j                            | j        d                   | j                            | j        d                   k    S r*   )rp   rw   rq   rr   rt   ry   s    r   one_linez_ExtractInfo.one_line   sW    {d// 
..t/@/CDD!11$2CA2FGGH	
r    c                     | j         j        d u S r   )r   r   ry   s    r   r7   z_ExtractInfo.global_   s    z D((r    c                 b    | j         j        d uo!| j         j                                        dk    S )NClass)r   r   r}   ry   s    r   rQ   z_ExtractInfo.method   s.    z ,X1B1K1K1M1MQX1XXr    c                 V    t          j        | j        j        | j        d                   S Nr   )r   get_indentsrd   rh   rt   ry   s    r   indentsz_ExtractInfo.indents   s"    &t}':D<Ma<PQQQr    c                     | j         rdS t          j        | j        j        | j                                                  S r   )r7   r   r   rd   rh   r   r~   ry   s    r   scope_indentsz_ExtractInfo.scope_indents   s7    < 	1&t}':DJ<P<P<R<RSSSr    c                 L    | j         | j        d         | j        d                  S r*   )r'   rp   ry   s    r   	extractedz_ExtractInfo.extracted   s     {4;q>DKN:;;r    Nc                 P    | j         t          | j                  | _         | j         S r   )_cached_parsed_extracted_parse_textr   ry   s    r   _parsed_extractedz_ExtractInfo._parsed_extracted   s)    ( 	H,7,G,GD),,r    c                 Z    | j         t          j        | j                  | _         | j         S )z1Does the extracted piece contain return statement)	_returnedr   _returns_lastr   ry   s    r   returnedz_ExtractInfo.returned   s,     > 	O(6t7MNNDN~r    c                 Z    | j         t          j        | j                  | _         | j         S )z?Does the extracted piece contains named expression/:= operator))_returning_named_exprr   _namedexpr_lastr   ry   s    r   returning_named_exprz!_ExtractInfo.returning_named_expr   s5     % 	)4)D&* *D& ))r    c                    | j         }t          | j        t          j                  oXt          | j        j        d         t          j                  o.t          | j        j        d         j        t          j                  | _         | j         S )z8Does the extracted piece contains a generator expressionNr   )	_returning_generator
isinstancer   r   r{   bodyExprvalueGeneratorExpry   s    r   returning_generator_expz$_ExtractInfo.returning_generator_exp   sx     $ 	413:>> Wt5:1=sxHHWt5:1=CSEUVV % ((r    rH   )rI   rJ   rK   __doc__r   rj   propertyrq   rk   r   ro   r   r7   rQ   r   r   r   r   r   r   r   r   r   r   r   rN   r    r   r0   r0   ~   s       ==' ' '"
 
 
& + + X+? ? ?
 
 
    
 
 X
 ) ) X) Y Y XY R R XR T T XT
 < < X<  $- - X-
 I  X !* * X*  	) 	) X	) 	) 	)r    r0   c                       e Zd ZdZd ZdS )_ExtractCollectorz6Collects information needed for performing the extractc                 h    d | _         d | _        i | _        d | _        d | _        d | _        d | _        d S r   )
definitionbody_patternchecksreplacement_patternmatchesreplacementsdefinition_locationr   r8   s     r   r   z_ExtractCollector.__init__  s=     #'  #'   r    N)rI   rJ   rK   r   r   rN   r    r   r   r     s)        @@( ( ( ( (r    r   c                   T    e Zd Zd Zd Zd Zd Zd Zed             Z	d Z
d Zd	 Zd
S )r3   c                 L    || _          t                      | j                    d S r   )r8   _ExceptionalConditionCheckerr   s     r   r   z_ExtractPerformer.__init__  s(    	&$&&ty11111r    c                 r   |                                  }t          j        | j        j                  }|j        }|j        \  }}| j        j                            |          }t          j
        ||          }|                    |||           |                     ||           |                                S r   )_collect_infor   ChangeCollectorr8   r'   r   r   rh   ru   r   fix_indentationr5   _replace_occurrencesget_changed)r   extract_infocontentr   r   r   r(   indenteds           r   r4   z_ExtractPerformer.extract  s    ))++-di.>??!,
&://77.z7CC668444!!'<888""$$$r    c                    |j         D ]}t          j        |j                  }i }|                                D ]`}|                    |          }|rBt          j        |                    |                    \  }}	| j        j	        ||	         ||<   [|||<   a|
                                }
|                    |
d         |
d         |                    |                     d S r*   )r   r   CodeTemplater   	get_namesget_astr   node_regionr8   r'   
get_regionr5   
substitute)r   r   r   matchreplacementmappingnamenoderl   rm   rp   s              r   r   z&_ExtractPerformer._replace_occurrences)  s    !) 	V 	VE'4\5UVVKG#--// ) )}}T** )!+!7d8K8K!L!LJE3$(I$4U3Y$?GDMM$(GDMM%%''Fvay&)[5K5KG5T5TUUUU	V 	Vr    c                     t          | j                  }|                     |           |                     |           |                     |           |S r   )r   r8   _find_definition_find_matches_find_definition_location)r   extract_collectors     r   r   z_ExtractPerformer._collect_info7  sW    -di88/000,---&&'8999  r    c                    |                                  }t          j        | j        j                  }g }|D ]\  }}|                    |j        |j        ||          }d}|D ]X}	| j        j        r| 	                    |	          r$|	
                                \  }}||k     r|                    |	           |}Y||_        d S )N)_where_to_searchr   SimilarFinderr8   rd   get_matchesr   r   r   _is_assignmentr   appendr   )
r   	collectorregionsfinderr   rl   rm   region_matcheslast_match_endregion_matchs
             r   r   z_ExtractPerformer._find_matches>  s    '')),TY-?@@! 	) 	)JE3#//&	(8% N  N . ) )9% $*=*=l*K*K )4466
s!E) )NN<000%(N) $	r    c                     t          | j        t          j        t          j        f          o#t          | j        j        t          j                  S r   )r   r   	Attribute	SubscriptctxStore)r   s    r   r   z _ExtractPerformer._is_assignmentQ  s?    s}cm<
 
 :)-sy99	:r    c                    | j         j        rl| j         j        s| j         j        r!dt	          | j         j        j                  fgS | j         j        r| j         j        s| j         j	        j
        }g }t          | j         j	                  }|                                D ]}|dk    rt          |          dk    r| j         j                            |                                          }| j         j                            |                                          }|                    ||f           |S | j         j        r| j         j        gS | j                             | j         j	        j
                  gS | j         j        gS )Nr   rQ   )r8   r,   r-   r7   r$   rd   rg   rQ   r   r   r   _get_function_kind
get_scopesrh   ru   r~   rv   r   r   r   r   rp   )r   class_scoper   method_kindr   rl   rm   s          r   r   z"_ExtractPerformer._where_to_searchW  so   9 	&y$ B	(9 BC	 2 >??@AAy Q	(: Q"io40AA(3355 1 1E#x/!.u55A! ! IO::5??;L;LMME)/66u}}GGCNNE3<00009% Q I233 I77	8NOOPPI$%%r    c                    g }|j         D ]s}| j        j                            |                                d                   }| j        j                            |          d         }|                    |           tt          | j        |          }|	                                |
                                f|_        d S r   )r   r8   rh   rs   r   rq   rr   r   _DefinitionLocationFinderfind_linenofind_indentsr   )r   r   matched_linesr   rl   r   location_finders          r   r   z+_ExtractPerformer._find_definition_locationq  s    & 	- 	-EIO33E4D4D4F4Fq4IJJE0@@GGJJ  ,,,,3DI}MM''))((**)
	%%%r    c                 8   | j         j        rt          | j                   }nt          | j                   }|                                |_        |                                |_        |                                |_	        |
                                |_        d S r   )r8   r   _ExtractVariableParts_ExtractMethodPartsget_definitionr   get_body_patternr   get_replacement_patternr   
get_checksr   )r   r   partss      r   r   z"_ExtractPerformer._find_definition}  s    9 	3)$)44EE'	22E$3355	!&!7!7!9!9	(-(E(E(G(G	% ++--	r    N)rI   rJ   rK   r   r4   r   r   r   rL   r   r   r   r   rN   r    r   r3   r3     s        2 2 2	% 	% 	%V V V! ! !$ $ $& : : \:
& & &4

 

 

. . . . .r    r3   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )r   c                 ~    || _         || _        |s,| j                            | j         j        d                    d S d S r   )r8   r   r   rt   )r   r8   r   s      r   r   z"_DefinitionLocationFinder.__init__  sM    	* 	A%%di&<Q&?@@@@@	A 	Ar    c                    | j         j        r | j         j        s|                                 S | j         j        r|                     | j         j                  }| j         j                                        }t          | j
        |                                dz   gz             }t          j        ||          S | j         j        r6|                     | j         j                  }|                                dz   S |                                 S r"   )r8   r   r-   _get_before_liner7   _find_toplevelr   rd   r   sortedr   r   r   find_visible_get_after_scope)r   toplevelr   newliness       r   r   z%_DefinitionLocationFinder.find_lineno  s    9 	+di&; 	+((***9 	6**49?;;H)$,,..Cd0H4D4D4F4F4J3KKLLH&sH5559  	***49?;;H##%%))$$&&&r    c                 V    |}|j         |j         j         |j         }|j         j         |S r   )r   )r   r   r  s      r   r  z(_DefinitionLocationFinder._find_toplevel  s9    ? 	+/( +#? /( +r    c                     | j         j        r=| j         j        s1t          j        | j         j        |                                           S | j         j        s| j         j        rdS | j         j        S r   )	r8   r   r-   r   r   rh   r   r7   r   ry   s    r   r   z&_DefinitionLocationFinder.find_indents  sg    9 	di&; 	*49?D<Q<Q<S<STTTy  DI$9 qy&&r    c                 |    | j         j        j                                        }t	          j        || j                  S r   )r8   r   pyobjectr   r   r  r   )r   r   s     r   r   z*_DefinitionLocationFinder._get_before_line  s0    io&..00"3(:;;;r    c                 D    | j         j                                        dz   S r"   )r8   r   r   ry   s    r   r  z*_DefinitionLocationFinder._get_after_scope  s    y&&((1,,r    N)	rI   rJ   rK   r   r   r  r   r   r  rN   r    r   r   r     sq        A A A' ' '  ' ' '< < <- - - - -r    r   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )r   c                     |                      |           |j        r|                     |           d S |                     |           d S r   )base_conditionsr   one_line_conditionsmulti_line_conditionsr   s     r   __call__z%_ExceptionalConditionChecker.__call__  sT    T"""= 	-$$T*****&&t,,,,,r    c                    |j         d         |j        d         k    rt          d          |j        d         }|j                            |          }||j        k    r'|                                |k    rt          d          	 |j        }|j	        rd|z  }t                              |          rt          d          d S # t          $ r t          d          w xY w)Nr#   z&Bad region selected for extract method(%s)z:A break/continue without having a matching for/while loop.3Extracted piece should contain complete statements.)rp   r   r
   rt   rf   r|   r   r   r   r   _UnmatchedBreakOrContinueFinder
has_errorsSyntaxError)r   r8   end_line	end_scoper   s        r   r  z,_ExceptionalConditionChecker.base_conditions  s   ;q>D-a00 	M"#KLLL$Q'%>>xHH	
" 	My'8'8':':h'F 	M"#KLLL	I} /"Y.	.99)DD &P     	 	 	"E  	s   <C Cc                    |                      |          rt          d          |j        r|j        st          d          t	          j        |j                  t	          j        |j                  z
  rt          d          d S )Nz#Should extract complete statements.z0Extract variable should not span multiple lines.z>Extracted piece cannot contain named expression (:= operator).)_is_region_on_a_wordr
   r   r   r   _named_expr_countr   r   r   s     r   r  z0_ExceptionalConditionChecker.one_line_conditions  s    $$T** 	J"#HIII= 	W 	W"#UVVV("
 
'(>??@ 	 #P  	 	r    c                    t          |j        |j        d         |j        d                            }t          j        |          }|j        }|dk    rt          d          t          j        |          rt          d          t          t          d          s)t                              |          rt          d          |dk    r#t          j        |          st          d          |j        |j        k    rt          d          d S )	Nr   r#   z3Extracted piece can have only one return statement.z-Extracted piece cannot have yield statements.PyCF_ALLOW_TOP_LEVEL_AWAITz_Extracted piece can only have async/await statements if Rope is running on Python 3.8 or higherz$Return should be the last statement.r  )r   r'   rp   r   _return_countr   r
   _yield_counthasattrr   _AsyncStatementFinderr  r   rw   )r   r8   r   countr   s        r   r  z2_ExceptionalConditionChecker.multi_line_conditions  s-   4;t{1~A'FGHH)$//N	19 	"E   #D)) 	T"#RSSS-
 
 	#..y99	 #   
 A: 	Kk7== 	K"#IJJJ;$++ 	"E  	 	r    c                     |j         d         dk    r$|                     ||j         d         dz
            s$|                     ||j         d         dz
            rdS d S )Nr   r#   T)rp   _is_on_a_wordr   s     r   r  z1_ExceptionalConditionChecker._is_region_on_a_word  sn    KNQ	""4Q!);<<	 !!$A(:;;	
 4	 	r    c                     |j         |         }|                                s|dk    r|dz   t          |j                   k    rdS |j         |dz            }|                                p|dk    S )N_r#   F)r'   isalnumr$   )r   r8   r(   prevnexts        r   r%  z*_ExceptionalConditionChecker._is_on_a_word  so    {6" 	$#+ 	&1*DK@P@P2P 	5{6A:&||~~,,r    N)	rI   rJ   rK   r  r  r  r  r  r%  rN   r    r   r   r     sn        - - -  (
 
 
  2  - - - - -r    r   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z e!d             Z"d S )!r   c                     || _         |                                 | _        |                                 | j         _        |                                  d S r   )r8   _create_info_collectorinfo_collector_get_kind_by_scoper2   _check_constraintsr   s     r   r   z_ExtractMethodParts.__init__  sJ    	"99;;0022	!!!!!r    c                 r    |                                  rdS |                                 rdS | j        j        S )NrL   rM   )_extacting_from_staticmethod_extracting_from_classmethodr8   r2   ry   s    r   r/  z&_ExtractMethodParts._get_kind_by_scope  s>    ,,.. 	!!>..00 	! =y~r    c                     |                                  s|                                 r| j        j        st	          d          d S d S )Nz8Cannot extract to staticmethod/classmethod outside class)_extracting_staticmethod_extracting_classmethodr8   rQ   r
   ry   s    r   r0  z&_ExtractMethodParts._check_constraints  s_    ((** 	d.J.J.L.L 	9# &N   	 	r    c                 T    | j         j        ot          | j         j                  dk    S NrL   r8   rQ   r   r   ry   s    r   r2  z0_ExtractMethodParts._extacting_from_staticmethod  s&    IV!3DIO!D!D!V	
r    c                 T    | j         j        ot          | j         j                  dk    S NrM   r9  ry   s    r   r3  z0_ExtractMethodParts._extracting_from_classmethod  s$    yX$6ty$G$G=$XXr    c                 v    | j         j        rd|                                 z  S d|                                 z  S )Nz
%s
z
%s)r8   r7   _get_function_definitionry   s    r   r   z"_ExtractMethodParts.get_definition"  s=    9 	<d;;====D99;;;;r    c                     g }|                     |                                            |                     |                                            t          j        |                                 |          S r   )extend_find_function_arguments_find_function_returnsr   make_pattern	_get_callr   	variabless     r   r   z+_ExtractMethodParts.get_replacement_pattern(  sd    	66889994466777)$..*:*:IFFFr    c                 >   g }|                     |                                            |                     |                                            |                     |                                            t	          j        |                                 |          S r   )r?  r@  rA  _find_tempsr   rB  	_get_bodyrD  s     r   r   z$_ExtractMethodParts.get_body_pattern.  s    	66889994466777))++,,,)$..*:*:IFFFr    c                 f    t          j        | j        j        d          }| j        j        rd|z  }|S )Nr   r  )r   r   r8   r   r   r   results     r   rH  z_ExtractMethodParts._get_body5  s4    ,TY-@!DD9 	%f_Fr    c                 d    t          j        | j        j        |                                           S r   )r   
find_tempsr8   r   rH  ry   s    r   rG  z_ExtractMethodParts._find_temps;  s$    %di&79I9IJJJr    c                     | j         j        rj| j         j        s^t          | j         j                  dk    rAt          j        | j         j        j        j                  }| 	                                d|z   iS i S )NrQ   ztype=)
r8   rQ   r-   r   r   r   _pydefined_to_strr   r
  _get_self_name)r   
class_names     r   r   z_ExtractMethodParts.get_checks>  sy    9 	EDI$9 	E!$)/22h> E*<IO*3 
 ++--w/CDD	r    c                    | j         j                                        dz
  }| j         j        d         |z
  }| j         j        d         |z
  }t	          ||| j         j                  }| j         j        | j         j        d         | j         j        d                  }t          |          }|	                    |           |S )Nr#   r   )
r8   r   r~   rt   _FunctionInformationCollectorr7   r'   r   r   visit)r   zeror   r  r.  r   r   s          r   r-  z*_ExtractMethodParts._create_info_collectorG  s    y((**Q.Y+A.5
9)!,t36$)"3
 
 y	 6q 9DI<RST<U UV4  T"""r    c                    |                                  }|                                 }g }|                     |           |                    d|                     |          z             |                     |          }t          j        | j        j	                  }t          j
        ||          }|                    |           d                    |          }|dz   S )Nzdef %s:
r   
)r@  rA  _append_decoratorsr   _get_function_signature_get_unindented_function_bodyr   
get_indentr8   r   indent_linesjoin)r   r\   returnsrK  unindented_bodyr   function_bodyr   s           r   r=  z,_ExtractMethodParts._get_function_definitionS  s    ,,..--//'''kD$@$@$F$FFGGG<<WEE():;;#0'JJm$$$WWV__
D  r    c                     |                                  r|                    d           d S |                                 r|                    d           d S d S )Nz@staticmethod
z@classmethod
)r5  r   r6  rJ  s     r   rX  z&_ExtractMethodParts._append_decoratorsb  sf    ((** 	,MM+,,,,,))++ 	,MM*+++++	, 	,r    c                 "    | j         j        dk    S r;  r8   r2   ry   s    r   r6  z+_ExtractMethodParts._extracting_classmethodh  s    y~..r    c                 "    | j         j        dk    S r8  rc  ry   s    r   r5  z,_ExtractMethodParts._extracting_staticmethodk  s    y~//r    c                 l   t          |          }d}|                                 s|                                 rT|                                 }|t	          d          ||v r|                    |           |                    d|           || j        j        z   d| 	                    |          z  z   S )Nr   z:Extracting a method from a function with no self argument.r   r  )
list_extracting_methodr6  rP  r
   removeinsertr8   ri   _get_comma_formr   r\   prefix	self_names       r   rY  z+_ExtractMethodParts._get_function_signaturen  s    Dzz""$$ 	&(D(D(F(F 	&++--I &P   D  'I&&&KK9%%%	**Vd6J6J46P6P-PPPr    c                     |                                   o5| j        j        o)| j        j         ot	          | j        j                  dk    S )NrQ   )r5  r8   rQ   r-   r   r   ry   s    r   rg  z&_ExtractMethodParts._extracting_method|  sQ    00222 
I @I))@"49?33x?	
r    c                 V    |                                  rdS |                                 S )NrG   )r6  _get_scope_self_namery   s    r   rP  z"_ExtractMethodParts._get_self_name  s-    '')) 	5((***r    c                     | j         j        j                                        dk    rd S | j         j        j                                        }|r|d         S d S )NrL   r   )r8   r   r
  r}   get_param_names)r   param_namess     r   rp  z(_ExtractMethodParts._get_scope_self_name  s[    9?#,,...@ 	Fio.>>@@ 	"q>!	" 	"r    c                     d                     |                     |          | j        j        |                     |                    S )Nz{prefix}{name}({args}))rl  r   r\   )format_get_function_call_prefixr8   ri   rj  )r   r\   s     r   _get_function_callz&_ExtractMethodParts._get_function_call  sI    '..11$77#%%d++ / 
 
 	
r    c                 F   d}| j         j        r| j         j        s|                                 s|                                 r,| j         j        j        j                                        dz   }n2| 	                                }||v r|
                    |           |dz   }|S )Nr   .)r8   rQ   r-   r5  r6  r   r   r
  get_namerP  rh  rk  s       r   rv  z-_ExtractMethodParts._get_function_call_prefix  s    9 	)DI$9 	),,.. )$2N2N2P2P )/8AACCcI //11	$ +KK	***"Sr    c                 ,    d                     |          S )N, )r]  )r   namess     r   rj  z#_ExtractMethodParts._get_comma_form  s    yyr    c                 &   |                                  }|                                 }d}|r@| j        j        r| j        j        r(| j        j        rdnd}|                     |          |z   }| j        j        rd}||                     |          z   S )Nr   z :=  = return )r@  rA  r8   r   r   rj  r   rw  )r   r\   r^  call_prefixassignment_operators        r   rC  z_ExtractMethodParts._get_call  s    ,,..--// 	NDI. 	N$)2P 	N,0I,>"I&&E..w77:MMK9 	$#KT44T::::r    c                    | j         j        r?| j         j        s3t          | j        j        | j        j        z  | j        j        z            S | j         j        s^| j        j	        | j        j        z  }|| j        j	        | j        j        z  | j        j
        | j        j        z
  z  z  }t          |          S | j         j        d         }|| j         j        d         k    r4|t          j        d| j         j                                                  z   }| j         j        || j         j        d                  }t$                              |          }t          | j        j	                            |                    S )Nr   z\Sr#   )r8   r7   r-   rf  r.  r   postreadwrittenr   
prewrittenmaybe_writtenrp   rw   researchr   rl   r'   _VariableReadsAndWritesFinderfind_reads_for_one_linersintersection)r   rK  rl   function_definitionr   s        r   r@  z,_ExtractMethodParts._find_function_arguments  sk    9 	TY%: 	#(%./%-.  
 y! 	 (3d6I6NNF#.%./&4t7J7RRTF
 <<	 #DI*1-- 	JBIeTY-@AAGGIIIE"i.uty7G7J/JK,FF
 
 D'2??EEFFFr    c                 
   | j         j        r5| j        j        | j        j        z  }t          || j        j        z            S | j         j        rg S | j        j        | j        j        z  }t          || j        j        z            S r   )r8   r   r.  r  r  rf  r  r   )r   r  s     r   rA  z*_ExtractMethodParts._find_function_returns  s    9 	@)1D4G4UUG$"5">>???9 	I%-0C0QQGd1::;;;r    c                 l    | j         j        r|                                 S |                     |          S r   )r8   r   $_get_single_expression_function_body_get_multiline_function_body)r   r^  s     r   rZ  z1_ExtractMethodParts._get_unindented_function_body  s5    9 	?<<>>>00999r    c                     t          j        | j        j        d          }|                     |          }|r|d|                     |          z  z  }|S )Nr   z

return %s)r   r   r8   r   _insert_globalsrj  )r   r^  r_  s      r   r  z0_ExtractMethodParts._get_multiline_function_body  sX    %5di6I1MM..?? 	M}t/C/CG/L/LLLOr    c                 v    t          | j        j        | j                  }d|z   }|                     |          S )Nr8   r  )_get_single_expression_bodyr8   r   r  )r   r   r   s      r   r  z8_ExtractMethodParts._get_single_expression_function_body  s9    /	0C$)TTT	9$##D)))r    c                     |                      |          }| j        j        | j        j        | j        j        z  z  }||z
  }|r)d                    d                    |          |          }|S )Nzglobal {}
{}r|  )_get_globals_in_bodyr.  globals_r  r  ru  r]  )r   r_  globals_in_bodyr  s       r   r  z#_ExtractMethodParts._insert_globals  s{    33ODD&/'$*=*KK
 o- 	-44		(##_ O r    c                 t    t          |           }t                      }|                    |           |j        S r   )r   _GlobalFinderrT  r  )r_  r   visitors      r   r  z(_ExtractMethodParts._get_globals_in_body  s3    ?++//dr    N)#rI   rJ   rK   r   r/  r0  r2  r3  r   r   r   rH  rG  r   r-  r=  rX  r6  r5  rY  rg  rP  rp  rw  rv  rj  rC  r@  rA  rZ  r  r  r  rL   r  rN   r    r   r   r     s       " " "    
 
 

Y Y Y< < <G G GG G G  K K K  
 
 
! ! !, , ,/ / /0 0 0Q Q Q
 
 
+ + +
" " "
 
 

 
 
     	; 	; 	;G G G4< < <: : :
  * * *
       \     r    r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )r   c                     || _         d S r   r  r   s     r   r   z_ExtractVariableParts.__init__  s    			r    c                 l    t          | j        j        | j                  }| j        j        dz   |z   dz   S )Nr  r  rW  )r  r8   r   ri   )r   r   s     r   r   z$_ExtractVariableParts.get_definition  s5    /	0C$)TTT	y!E)I5<<r    c                 D    d| j         j                                        z  S )Nr  )r8   r   r   ry   s    r   r   z&_ExtractVariableParts.get_body_pattern  s    	+113333r    c                     | j         j        S r   )r8   ri   ry   s    r   r   z-_ExtractVariableParts.get_replacement_pattern  s    y!!r    c                     i S r   rN   ry   s    r   r   z _ExtractVariableParts.get_checks  s    	r    N)rI   rJ   rK   r   r   r   r   r   rN   r    r   r   r     s_          = = =4 4 4" " "    r    r   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zed             Zed             ZdS )rS  c                 r   || _         || _        || _        t                      | _        t                      | _        t                      | _        t                      | _        t                      | _        t                      | _	        d| _
        d| _        t                      | _        d| _        d| _        d S )NTFr   )rl   rm   	is_globalr   r  r  r  r   r  postwrittenhost_functionconditionalr  surrounded_by_loop
loop_depth)r   rl   rm   r  s       r   r   z&_FunctionInformationCollector.__init__  s    
"$,,'\\!||LL	"%<<! ""#r    c                    | j         |cxk    r| j        k    r6n n3|| j        vr*| j        r	|| j        vr| j                            |           | j        |k     r%|| j        vr| j                            |           d S d S d S r   )	rl   rm   r  r  r  r   addr  r  r   r   r   s      r   _read_variablez,_FunctionInformationCollector._read_variable  s    : 	( 	( 	( 	(48 	( 	( 	( 	( 	(4<' (' (4t7I+I (IMM$'''8f 	(4++ (!!$'''''	( 	(( (r    c                    | j         |cxk    r| j        k    rmn nj| j        r| j                            |           n| j                            |           | j        dk    r#|| j        v r| j                            |           | j         |k    r| j	                            |           | j        |k     r| j
                            |           d S d S r   )rl   rm   r  r  r  r  r  r   r  r  r  r  s      r   _written_variablez/_FunctionInformationCollector._written_variable&  s   : 	( 	( 	( 	(48 	( 	( 	( 	( 	( '"&&t,,,,  &&&" (tty'8 (!!$''': 	&O%%%8f 	'  &&&&&	' 	'r    c                    | j         sa| j        rZd| _        t          |j                  D ]}|                     ||j                   |j        D ]}|                     |           d S |                     |j        |j                   t                      }|j        D ]}|                    |           |j
        |j        z
  D ]}|                     ||j                   d S NF)r  r  _get_argnamesr\   r  r   r   rT  r   r  r   r  r  )r   r   r   childr  s        r   _FunctionDefz*_FunctionInformationCollector._FunctionDef3  s   ~ 	7$"4 	7!&D%di00 : :&&tT[9999 " "

5!!!!" " ""49dk:::355G % %e$$$$w6 7 7##D$+66667 7r    c                 .     | j         j        |j          d S r   r  r  r}  r   r   s     r   _Globalz%_FunctionInformationCollector._GlobalB      4:&&&&r    c                 0    |                      |           d S r   )r  r  s     r   _AsyncFunctionDefz/_FunctionInformationCollector._AsyncFunctionDefE  s    $r    c                    t          |j        t          j        t          j        f          r |                     |j        |j                   t          |j        t          j                  s"|                     |j        |j                   d S d S r   )	r   r   r   r   AugStorer  idr   r  r  s     r   _Namez#_FunctionInformationCollector._NameH  sy    dhCL 9:: 	9""47DK888$(CI.. 	655555	6 	6r    c                     |                      |j        |j                   |j        r|                     |j                   d S d S r   )r  r   r   patternrT  r  s     r   _MatchAsz&_FunctionInformationCollector._MatchAsN  sJ    ty$+666< 	%JJt|$$$$$	% 	%r    c                 x    |                      |j                   |j        D ]}|                      |           d S r   )rT  r   targetsr   r   r  s      r   _Assignz%_FunctionInformationCollector._AssignS  sF    

4:\ 	 	EJJu	 	r    c                 H   |                      |j                   t          |j        t          j                  rN|j        j        }|                     ||j        j                   | 	                    ||j        j                   d S |                      |j                   d S r   )
rT  r   r   targetr   Namer  r  r   r  )r   r   	target_ids      r   
_AugAssignz(_FunctionInformationCollector._AugAssignX  s    

4:dk38,, 	$I	4;+=>>>""9dk.@AAAAAJJt{#####r    c                 F    |                      |j        |j                   d S r   )r  r   r   r  s     r   	_ClassDefz'_FunctionInformationCollector._ClassDefa  s"    ty$+66666r    c                 0    |                      |           d S r   	_comp_expr  s     r   	_ListCompz'_FunctionInformationCollector._ListCompd      tr    c                 0    |                      |           d S r   r  r  s     r   _GeneratorExpz+_FunctionInformationCollector._GeneratorExpg  r  r    c                 0    |                      |           d S r   r  r  s     r   _SetCompz&_FunctionInformationCollector._SetCompj  r  r    c                 0    |                      |           d S r   r  r  s     r   	_DictCompz'_FunctionInformationCollector._DictCompm  r  r    c                     t           j                  }t           j                  }t           j                  }t	          j        |          D ]}                     |           t          t          j	         fd|j
        D                                 } j        |z
  |z   _         j        |z
  |z   _         j        |z
  |z   _        d S )Nc              3   L   K   | ]}                     |j                  V  d S r   )_flatten_nested_tuple_of_namesr  ).0	generatorr   s     r   	<genexpr>z:_FunctionInformationCollector._comp_exp.<locals>.<genexpr>y  sH           33I4DEE           r    )r   r   r  r  r   iter_child_nodesrT  rf  r   from_iterable
generators)r   r   r   r  r  r  
comp_namess   `      r   r  z'_FunctionInformationCollector._comp_expp  s    $)$$T\**"4#566)$// 	 	EJJu        !%       
 

 I
*T1	|j07:!/*<}Lr    c              #      K   t          |t          j                  r#|j        D ]}|                     |          V  d S t          |t          j                  r|j        V  d S J d|            )NFz3Unexpected node type in list comprehension target: )r   r   Tupleeltsr  r  r  )r   r   elts      r   r  z<_FunctionInformationCollector._flatten_nested_tuple_of_names  s      dCI&& 	Yy ? ?99#>>>>>>? ?ch'' 	Y'MMMMMXXPTXXXXXr    c                 0    |                      |           d S r   )_handle_conditional_noder  s     r   _Ifz!_FunctionInformationCollector._If  s    %%d+++++r    c                     |                      |          5  |                     |           d d d            d S # 1 swxY w Y   d S r   )_handle_loop_contextr  r  s     r   _Whilez$_FunctionInformationCollector._While  s    &&t,, 	0 	0))$///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s   9= =c                    |                      |          5  |                     |          5  |                     |j                   |                     |j                   |j        D ]}|                     |           |j        D ]}|                     |           	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r   )r  _handle_conditional_contextrT  iterr  r   orelser  s      r   _Forz"_FunctionInformationCollector._For  s[   &&t,, 	" 	"d.N.Nt.T.T 	" 	"JJty!!!JJt{### " "

5!!!! " "

5!!!!"	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s5   CA3B, C,B0	0C3B0	4CCCc                     |                      |          5  t          j        |          D ]}|                     |           	 d d d            d S # 1 swxY w Y   d S r   )r  r   r  rT  r  s      r   r  z6_FunctionInformationCollector._handle_conditional_node  s    --d33 	" 	"-d33 " "

5!!!!"	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   -AAAc              #      K   | j         |j        cxk    r| j        k    r
n nd| _        	 d V  d| _        d S # d| _        w xY w)NTF)rl   r   rm   r  r  s     r   r  z9_FunctionInformationCollector._handle_conditional_context  sx      : 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$#D	%EEE$DuD$$$$s	   7 	A c              #      K   |j         | j        k     r| xj        dz  c_        	 d V  | xj        dz  c_        d S # | xj        dz  c_        w xY wr"   )r   rl   r  r  s     r   r  z2_FunctionInformationCollector._handle_loop_context  sa      ;# 	!OOq OO	!EEEOOq OOOODOOq OOOOOOs	   : AN)rI   rJ   rK   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  rN   r    r   rS  rS    s          ( ( (' ' '7 7 7' ' '     6 6 6% % %
  
$ $ $7 7 7        M M M$Y Y Y, , ,0 0 0	" 	" 	"" " "
 % % ^% ! ! ^! ! !r    rS  c                    g }|                     d t          | dg           D                        |                     d | j        D                        | j        r|                    | j        j                   | j        r|                    | j        j                   |                     d | j        D                        |S )Nc              3   $   K   | ]}|j         V  d S r   argr  r   s     r   r  z _get_argnames.<locals>.<genexpr>  s$      MMt$(MMMMMMr    posonlyargsc              3   $   K   | ]}|j         V  d S r   r  r  s     r   r  z _get_argnames.<locals>.<genexpr>  s$      66t$(666666r    c              3   $   K   | ]}|j         V  d S r   r  r  s     r   r  z _get_argnames.<locals>.<genexpr>  s$      <<t$(<<<<<<r    )r?  getattrr\   varargr   r  kwarg
kwonlyargs)	argumentsrK  s     r   r  r    s    F
MMMMwy-'L'LMMMMMM
MM66y~666666 ,i&*+++ +io)***
MM<<y';<<<<<<Mr    c                   R    e Zd Zd Zd Zd Zd Zed             Zed             Z	dS )r  c                 R    t                      | _        t                      | _        d S r   )setr  r   ry   s    r   r   z&_VariableReadsAndWritesFinder.__init__  s    uuEE			r    c                    t          |j        t          j        t          j        f          r| j                            |j                   t          |t          j                  s!| j                            |j                   d S d S r   )	r   r   r   r   r  r  r  r  r   r  s     r   r  z#_VariableReadsAndWritesFinder._Name  sq    dhCL 9:: 	&LTW%%%$	** 	#IMM$'"""""	# 	#r    c                    | j                             |j                   t                      }t	          j        |          D ]}|                    |           | j                            |j        |j         z
             d S r   )	r  r  r   r  r   r  rT  r   update)r   r   r  r  s       r   r  z*_VariableReadsAndWritesFinder._FunctionDef  sy    ###/11)$// 	! 	!EMM%    	788888r    c                 D    | j                             |j                   d S r   )r  r  r   r  s     r   _Classz$_VariableReadsAndWritesFinder._Class  s     #####r    c                     |                                  dk    rt                      t                      fS t          |           }t                      }|                    |           |j        |j        fS Nr   )r   r  r   r  rT  r   r  coder   r  s      r   find_reads_and_writesz3_VariableReadsAndWritesFinder.find_reads_and_writes  sb    ::<<2 	 55#%%<4  /11d|W_,,r    c                     |                                  dk    rt                      t                      fS t          |           }t                      }|                    |           |j        S r  )r   r  r   r  rT  r   r  s      r   r  z7_VariableReadsAndWritesFinder.find_reads_for_one_liners  s[    ::<<2 	 55#%%<4  /11d|r    N)
rI   rJ   rK   r   r  r  r  rL   r  r  rN   r    r   r  r    s          # # #9 9 9$ $ $ - - \-   \  r    r  c                   $    e Zd Zed             ZdS )_BaseErrorFinderc                     |                                 dk    rdS t          |          } |             }|                    |           |j        S )Nr   F)r   r   rT  error)rG   r  r   r  s       r   r  z_BaseErrorFinder.has_errors  sN    ::<<2 	54  #%%d}r    N)rI   rJ   rK   rM   r  rN   r    r   r  r    s-          [  r    r  c                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )r  c                 "    d| _         d| _        d S )NFr   )r  
loop_country   s    r   r   z(_UnmatchedBreakOrContinueFinder.__init__  s    
r    c                 0    |                      |           d S r   loop_encounteredr  s     r   r  z$_UnmatchedBreakOrContinueFinder._For      d#####r    c                 0    |                      |           d S r   r  r  s     r   r  z&_UnmatchedBreakOrContinueFinder._While  r  r    c                 N   | xj         dz  c_         |j        D ]}|                     |           | xj         dz  c_         |j        r^t	          |j        t
          t          f          r!|j        D ]}|                     |           d S |                     |j                   d S d S r"   )r  r   rT  r  r   rf  tuple)r   r   r  node_s       r   r  z0_UnmatchedBreakOrContinueFinder.loop_encountered  s    1Y 	 	EJJu1; 	($+e}55 (![ & &EJJu%%%%& & 

4;'''''	( 	(r    c                 .    |                                   d S r   
check_loopr  s     r   _Breakz&_UnmatchedBreakOrContinueFinder._Break      r    c                 .    |                                   d S r   r"  r  s     r   	_Continuez)_UnmatchedBreakOrContinueFinder._Continue  r%  r    c                 .    | j         dk     r	d| _        d S d S )Nr#   T)r  r  ry   s    r   r#  z*_UnmatchedBreakOrContinueFinder.check_loop  s&    ?Q 	DJJJ	 	r    c                     d S r   rN   r  s     r   r  z,_UnmatchedBreakOrContinueFinder._FunctionDef      r    c                     d S r   rN   r  s     r   r  z)_UnmatchedBreakOrContinueFinder._ClassDef  r*  r    N)rI   rJ   rK   r   r  r  r  r$  r'  r#  r  r  rN   r    r   r  r    s          $ $ $$ $ $
( 
( 
(            r    r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )r"  c                     d| _         d S r  r  ry   s    r   r   z_AsyncStatementFinder.__init__  s    


r    c                     d| _         d S NTr.  r  s     r   	_AsyncForz_AsyncStatementFinder._AsyncFor       


r    c                     d| _         d S r0  r.  r  s     r   
_AsyncWithz _AsyncStatementFinder._AsyncWith#  r2  r    c                     d S r   rN   r  s     r   r  z"_AsyncStatementFinder._FunctionDef&  r*  r    c                     d S r   rN   r  s     r   r  z_AsyncStatementFinder._ClassDef)  r*  r    N)rI   rJ   rK   r   r1  r4  r  r  rN   r    r   r"  r"    s_                    r    r"  c                       e Zd Zd Zd ZdS )r  c                 ,    t                      | _        d S r   )r   r  ry   s    r   r   z_GlobalFinder.__init__.  s    "r    c                 .     | j         j        |j          d S r   r  r  s     r   r  z_GlobalFinder._Global1  r  r    N)rI   rJ   rK   r   r  rN   r    r   r  r  -  s2        % % %' ' ' ' 'r    r  c                 4    | j                                         S r   )r
  r}   )r   s    r   r   r   5  s    >""$$$r    c           	      V   t          j        | d          } 	 t          j        |           }n}# t          $ rp 	 t          j        d| z   dz             }nQ# t          $ rD t          j        dt          j        | d          z             }|j        d         j        |_        Y nw xY wY nw xY w|S )Nr   ()z"async def __rope_placeholder__():
   )r   r   r   parser  r   )r   r   s     r   r   r   9  s    &tQ//D*y 	* 	* 	*	*9S4Z#-..DD 	* 	* 	*95-dA667 D 	!)DIII	*		* Ks3   , 
B&AB&AB B&B  B&%B&c                 6   g }|                                  D ]n}|                    d          r0|                    |d d                                                    G|                    |                                           od                    |          S )N\r    )
splitlinesendswithr   r   r]  )r  rh   lines      r   _join_linesrF  J  s    E!! ' '== 	'LLcrc**++++LL&&&&88E??r    c                 4   t          j        | d          } |                                 d         dv o|                                 d         dv }|                     d          dk    o|}|st          |           } d| v }|j        s|j        s|r
|sd| z   dz   } | S )	Nr   z({[r   z)}]rW     r<  r=  )r   r   lstriprstripr#  rF  r   r   )r   r8   already_parenthesizedlarge_multilinemultiline_expressions        r   r  r  T  s    +Iq99I1&J9+;+;+=+=b+AU+J   ood++q0J5JO +	**	9,!*'* !* *9*
 )Oc)	r    )+r  
contextlibr   	itertoolsr   	rope.baser   r   rope.base.changer   r   rope.base.exceptionsr
   rope.base.utils.datastructuresr   rope.refactorr   r   r   r   r   r   rP   rX   r0   r   r3   r   r   RopeNodeVisitorr   r   rS  r  r  r  r  r"  r  r   r   rF  r  rN   r    r   <module>rV     s   				 % % % % % %       & & & & & & & & 6 6 6 6 6 6 6 6 1 1 1 1 1 1 5 5 5 5 5 5 U U U U U U U U U U U U U U6AA AA AA AA AA AA AA AAH? ? ? ? ?' ? ? ?	 	 	 	 	) 	 	 	K) K) K) K) K) K) K) K)\
( 
( 
( 
( 
( 
( 
( 
(l. l. l. l. l. l. l. l.^)- )- )- )- )- )- )- )-XN- N- N- N- N- N- N- N-br  r  r  r  r #- r  r  r j       $f! f! f! f! f!C$7 f! f! f!R	 	 	% % % % %C$7 % % %P    s*   % % % % %&6 % % %P    ,   "' ' ' ' 'C' ' ' '% % %  "      r    