+
    ek%                         ^ RI t ^ RIHt ^ RIHtHtHt ^ RIHt ^ RI	H
t
 ^ RIHt RP                  4       t ! R R	4      t ! R
 R4      tR tR tR tR tR R ltR# )    NPath)DictIterableTuple)split_lines)RefactoringError)ImplicitNSNamezmor_test and_test not_test comparison expr xor_expr and_expr shift_expr arith_expr term factor power atom_exprc                   >   a  ] tR t^t o R tR tR tR tR tRt	V t
R# )ChangedFilec                B    Wn         W n        W0n        W@n        WPn        R # N)_inference_state
_from_path_to_path_module_node_node_to_str_map)selfinference_state	from_pathto_pathmodule_nodenode_to_str_maps   &&&&&&?/usr/lib/python3/dist-packages/jedi/api/refactoring/__init__.py__init__ChangedFile.__init__   s     /#' /    c                   \        V P                  P                  4       R R7      p\        V P                  4       R R7      pVR,          R8w  d   VR;;,          R,          uu&   VR,          R8w  d   VR;;,          R,          uu&   V P                  P
                  P                  pV P                  f   RpM V P                  P                  V4      pV P                  f   RpM V P                  P                  V4      p\        P                  ! W\        V4      \        V4      R7      pRP                  V4      P                  R4      #   \         d    T P                  p Li ; i  \         d    T P                  p Li ; i)Tkeepends 
)fromfiletofile )r   r   get_codeget_new_coder   projectpathr   relative_to
ValueErrorr   difflibunified_diffstrjoinrstrip)r   	old_lines	new_linesproject_pathfrom_pto_pdiffs   &      r   get_diffChangedFile.get_diff   sB    1 1 : : <tL	 1 1 3dC	 R=BbMT!MR=BbMT!M,,4499??"F)44\B == D%}}00> ##[t9
 wwt}##C((!  ))  %}}%s$   9E &E) E&%E&)FFc                v    V P                   P                  P                  V P                  V P                  4      # r   )r   grammarrefactorr   r   r   s   &r   r(   ChangedFile.get_new_codeB   s-    $$,,55d6G6GI^I^__r   c                    V P                   f   \        R4      h\        V P                   RRR7      ;_uu_ 4       pVP                  V P	                  4       4       R R R 4       R #   + '       g   i     R # ; i)Nz5Cannot apply a refactoring on a Script with path=Nonewr!   )newline)r   r	   openwriter(   )r   fs   & r   applyChangedFile.applyE   sW    ??""G  $//333qGGD%%'( 4333s    A$$A5	c                T    R V P                   P                  : RV P                  : R2# )<z: >)	__class____name__r   r=   s   &r   __repr__ChangedFile.__repr__N   s    !^^44dooFFr   )r   r   r   r   r   N)rK   
__module____qualname____firstlineno__r   r8   r(   rE   rL   __static_attributes____classdictcell____classdict__s   @r   r   r      s'     0')R`)G Gr   r   c                   Z   a  ] tR t^Rt o R
R ltV 3R lR ltV 3R lR ltR tR tRt	V t
R	# )Refactoringc                *    Wn         W0n        W n        R # r   )r   _renames_file_to_node_changes)r   r   file_to_node_changesrenamess   &&&&r   r   Refactoring.__init__S   s     /%9"r   c                6   < V ^8  d   QhRS[ S[S[3,          /#    return)r   r   r   )formatrT   s   "r   __annotate__Refactoring.__annotate__X   s     
 
4k(9#: 
r   c                .  a V3R  lpV P                  4       o\        V P                  P                  4       R R7       UUu/ uFF  w  r#V\	        V P
                  VV! V4      \        \        V4      4      P                  4       VR7      bKH  	  upp# u uppi )c                    < V f   V # \        V 4      p S FN  w  rV P                  \        V4      4      '       g   K'  \        V4      V \        \        V4      4      R  ,           p KP  	  \        V 4      # r   )r/   
startswithlenr   )pfrom_tor[   s   &  r   calculate_to_path8Refactoring.get_changed_files.<locals>.calculate_to_pathY   s^    yAA$	<<E
++B!CE
O$4"55A % 7Nr   c                 :    V ^ ,          ;'       g    \        R4      # )r   r!   r   )xs   &r   <lambda>/Refactoring.get_changed_files.<locals>.<lambda>n   s    ad..d2h.r   )key)r   r   r   r   )	get_renamessortedrY   itemsr   r   nextiterget_root_node)r   rk   r*   map_r[   s   &   @r   get_changed_filesRefactoring.get_changed_filesX   s    	 ""$ %**002.

 +%%)$/ d,::< $ 
 	
 
s   ABc                F   < V ^8  d   QhRS[ S[S[S[3,          ,          /# r^   )r   r   r   )ra   rT   s   "r   rb   rc   r   s"     % %XeD$J&78 %r   c                ,    \        V P                  4      # )z(
Files can be renamed in a refactoring.
)rs   rX   r=   s   &r   rr   Refactoring.get_renamesr   s     dmm$$r   c           	     6   R pV P                   P                  P                  pV P                  4        F)  w  r4VR\	        W24      : R\	        WB4      : R2,          pK+  	  VR P                  R V P                  4       P                  4        4       4      ,           # )r!   zrename from z
rename to r"   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir   )r8   ).0rD   s   & r   	<genexpr>'Refactoring.get_diff.<locals>.<genexpr>   s     V4Uqjjll4Us   )r   r)   r*   rr   _try_relative_tor0   ry   values)r   textr4   ri   rj   s   &    r   r8   Refactoring.get_diffx   s    ,,4499))+IE#E8:J2:\^ ^D , bggVD4J4J4L4S4S4UVVVVr   c                    V P                  4       P                  4        F  pVP                  4        K  	  V P                  4        F  w  r#VP	                  V4       K  	  R# )zE
Applies the whole refactoring to the files, which includes renames.
N)ry   r   rE   rr   rename)r   rD   oldnews   &   r   rE   Refactoring.apply   sK     '')002AGGI 3 ((*HCJJsO +r   )rY   r   rX   N) )rK   rN   rO   rP   r   ry   rr   r8   rE   rQ   rR   rS   s   @r   rV   rV   R   s.     :

 
4% %W r   rV   c                     V P                   pV P                  R9   d   W"P                   P                  V4      3# WP                  WP                  ,           4      3# )__init__.py)r   z__init__.pyi)parentnamejoinpathsuffix)r*   new_namedir_s   && r   _calculate_renamer      sI    ;;Dyy33[[))(333x++5666r   c           	         \        4       p/ pV'       g   \        R 4      hV EF  pVP                  P                  pVP                  R8X  dD   Vf@   VP
                  e2   \        VP
                  4      pVP                  \        Wr4      4       Kn  \        VP                  \        4      '       dR   VP                  P                  P                  4        F'  pVP                  \        \        V4      V4      4       K)  	  K  Vf   K  VP                  VP
                  / 4      pVP                  V,           W&   EK  	  \        WV4      # )!There is no name under the cursormodule)setr	   _name	tree_nametypemodule_pathr   addr   
isinstancer
   _value
py__path__
setdefaultprefixrV   )	r   definitionsr   file_renamesfile_tree_name_mapdr   rh   fmaps	   &&&      r   r   r      s    5LBCC GG%%	66X)"38QQ]]#A.q;<00WW^^..0  !247H!EF 1 $)44Q]]BG"+"2"2X"=  LIIr   c                 	   V'       g   \        R 4      h\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        R4      h\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        R4      hV Uu. uF&  q"P                  P                  4       '       g   K$  VNK(  	  pp\	        V4      ^ 8X  d   \        R4      h\	        V4      ^8  d   \        R4      h\	        V4      ^8X  d   \        R	4      hV^ ,          P                  pVP                  4       pVP                  R
8w  dD   \        RRR7      P                  VP                  VP                  4      p\        RV,          4      h\	        VP                  RR7      4      ^8  d   \        R4      hVP                  ^,          pVP                  R8X  d.   \	        VP                  4      ^8X  d   VP                  ^,          pVR8w  d?   VP                  R8X  d   \        R4      h\        RVP                  RR7      ,          4      hVP                  4       pVP                  RR7      p	V Uu. uF&  q"P                  P                  4       '       d   K$  VNK(  	  p
p/ pV
 EFx  pVP                  pVP                  4       P                  4       pT	pVP                  R8X  gW   VP                  P                  \         9   g8   VP                  P                  R8X  d-   VP                  P#                  4       e   RV	,           R,           pVP%                  V/ 4      pTpVP&                  pVP                  pVP                  R8X  d   VP                  ^ ,          R8X  dr   VP                  P                  ^ ,          P&                  pTpVP                  P                  RVP                  P                  P)                  V4        F  pRVV&   K
  	  VV,           W&   EK{  	  V^ ,          P                  4       P                  4       pVP%                  V/ 4      p\+        VP-                  4       P&                  4      VV&   VP/                  4       pVP&                  P1                  R4      R8X  d   VP                  R8X  g   VR8X  d   RVV&   \3        W4      # u upi u upi ) r   c              3   >   "   T F  qP                   R9   x  K  	  R# 5i)r   N)r   	namespace)api_typer   ns   & r   r   inline.<locals>.<genexpr>   s     
@%Q::00%s   TFz,Cannot inline imports, modules or namespacesc              3   <   "   T F  qP                   R J x  K  	  R # 5ir   )r   r   s   & r   r   r      s     
.1;;$s   z!Cannot inline builtins/extensionszNo definition found to inlinez.Cannot inline a name with multiple definitionsz$There are no references to this name	expr_stmtfunctionclass)funcdefclassdefzCannot inline a %s)include_setitemz3Cannot inline a statement with multiple definitions	annassign=z:Cannot inline a statement that is defined by an annotationz#Cannot inline a statement with "%s")include_prefixtestlist_star_exprtrailerN().r!   z 	rA   ;)r	   anyr   is_definitionrg   get_definitionr   dictgetget_defined_nameschildrenr'   get_rhsget_root_context
py__file__r   EXPRESSION_PARTSget_next_siblingr   r   index_remove_indent_of_prefixget_first_leafget_next_leafstriprV   )r   namesr   r   r   r   type_first_childrhsreplace_code
referencesrZ   r   r*   sof_pathr   par	some_nodechanges	next_leafs   &&                   r   inliner      s   BCC
s
@%
@sss
@%
@@@MNN
s
.
.sss
.
...BCC#Ce{{'@'@'B11eKC
;1>??
;!OPP
5zQEFFA((I((*I~~$
 #inninn
- 	 3e;<<
9&&t&<=ATUU$$Q'K;&3{/C/C+D+I!**1-c{*"L  #5&&e&<= 
 


C<<u<5L"FU++*C*C*E!!UJFNN	$$&11388++##((,<<##((I5$$557Cl"S(A&11$;hh88y S\\!_%;ZZ((+22FA ZZ001P#**2E2E2K2KC2PQ	%'	" RaZ
) , q>**,779D"--dB7G1)2J2J2L2S2STGI'')I e$*9,	S0@	==O DJ Gs   "!S#S#?!S(%S(c                @    RP                  \        V RR7      RR 4      # )zL
Removes the last indentation of a prefix, e.g. " \n \n " becomes " \n \n".
r!   Tr   Nr&   )r0   r   )r   s   &r   r   r      s!     77;v5cr:;;r   c                <    V ^8  d   QhR\         R\         R\         /# )r_   r*   baser`   r   )ra   s   "r   rb   rb     s!      4 t  r   c                 L     V P                  V4      #   \         d    T u # i ; ir   )r+   r,   )r*   r   s   &&r   r   r     s,    %% s    ##)r-   pathlibr   typingr   r   r   parsor   jedi.api.exceptionsr	   jedi.inference.value.namespacer
   splitr   r   rV   r   r   r   r   r   r   r   r   <module>r      s`      ( (  0 9O%' ?G ?GD7 7t7J0O>d<r   