
    cig                     z   d dl Z d dlZd dlZd dlmZmZmZmZmZm	Z	m
Z
mZmZmZ d dlmZ d dlmZ 	 	 	 	 d dZd Zd!d	Z	 	 	 	 d"dZd!dZd Zd Z G d d          ZeZ G d de          Zd#dZd Zd Z G d d          Z G d d          Z  G d d          Z! G d de          Z" G d d          Z#dS )$    N)
builtinsevaluate
exceptionslibutilspynames
pynamesdef	pyobjectspyobjectsdefpyscopesworder)	fixsyntax)functionutils   Tc                 |    |t          j        dt          d           t          | |||||          } |            S )am  Return python code completions as a list of `CodeAssistProposal`

    `resource` is a `rope.base.resources.Resource` object.  If
    provided, relative imports are handled.

    `maxfixes` is the maximum number of errors to fix if the code has
    errors in it.

    If `later_locals` is `False` names defined in this scope and after
    this line is ignored.

    Nz'Codeassist no longer supports templates   
stacklevel)resourcemaxfixeslater_locals)warningswarnDeprecationWarning_PythonCodeAssist)projectsource_codeoffsetr   	templatesr   r   assists           7lib/python3.11/site-packages/rope/contrib/codeassist.pycode_assistr!      sc    *  
57IVW	
 	
 	
 	
 !  F 688O    c                 b    t          j        | d          }|                    |          \  }}}|S )aN  Return the offset in which the completion should be inserted

    Usually code assist proposals should be inserted like::

        completion = proposal.name
        result = (source_code[:starting_offset] +
                  completion + source_code[offset:])

    Where starting_offset is the offset returned by this function.

    Tr   Worderget_splitted_primary_beforer   r   word_finder
expressionstartingstarting_offsets         r    r+   r+   9   s<     -T22K,7,S,S- -)J/ r"   c                     t          j        | |||          }|                    |          }|dS |                                }t	                                          |          S )zGet the pydocN)r   	FixSyntax	pyname_at
get_objectPyDocExtractorget_doc)r   r   r   r   r   fixerpynamepyobjects           r    r1   r1   L   sa    hIIE__V$$F t  ""H##H---r"   Fc                     t          j        | |||          }|                    |          }|dS |                                }	t	                                          |	||          S )ay  Get the calltip of a function

    The format of the returned string is
    ``module_name.holding_scope_names.function_name(arguments)``.  For
    classes `__init__()` and for normal objects `__call__()` function
    is used.

    Note that the offset is on the function itself *not* after the its
    open parenthesis.  (Actually it used to be the other way but it
    was easily confused when string literals were involved.  So I
    decided it is better for it not to try to be too clever when it
    cannot be clever enough).  You can use a simple search like::

        offset = source_code.rindex('(', 0, offset) - 1

    to handle simple situations.

    If `ignore_unknown` is `True`, `None` is returned for functions
    without source-code like builtins and extensions.

    If `remove_self` is `True`, the first parameter whose name is self
    will be removed for methods.
    N)r   r-   r.   r/   r0   get_calltip)
r   r   r   r   r   ignore_unknownremove_selfr2   r3   r4   s
             r    r6   r6   V   sh    @ hIIE__V$$F t  ""H''.+NNNr"   c                     t          j        | |||          }|                    |          }|A|                                \  }}|(|                                                                |fS dS )aS  Return the definition location of the python name at `offset`

    Return a (`rope.base.resources.Resource`, lineno) tuple.  If no
    `resource` is given and the definition is inside the same module,
    the first element of the returned tuple would be `None`.  If the
    location cannot be determined ``(None, None)`` is returned.

    NNN)r   r-   r.   get_definition_location
get_moduleget_resource)	r   r   r   r   r   r2   r3   modulelinenos	            r    r;   r;   ~   sx     hIIE__V$$F >7799 	>$$&&3355v==<r"   c                  p    dd l }t          j        dt          d            |j        j        j        | i |S )Nr   z4Use `rope.contrib.findit.find_occurrences()` insteadr   r   )rope.contrib.finditr   r   r   contribfinditfind_occurrences)argskwdsropes      r    rD   rD      sO    M>   
 04</>>>>r"   c                 v   |                      |          }t          j        ||          }|                                \  }}|sdS |                                                    |          }g }t          |t          j                  r+t          j
        |                                |          dfg}nDt          |t          j                  r*t          j
        |                                |          dfg}|j        rxt          |t          j                  rd}	nt          |t          j                  rd}	nd}	|                    |j                                        |	f           |j        }|j        x|                    |                                j        df           |                                 |S )a  Get the canonical path to an object.

    Given the offset of the object, this returns a list of
    (name, name_type) tuples representing the canonical path to the
    object. For example, the 'x' in the following code:

        class Foo(object):
            def bar(self):
                class Qux(object):
                    def mux(self, x):
                        pass

    we will return:

        [('Foo', 'CLASS'), ('bar', 'FUNCTION'), ('Qux', 'CLASS'),
         ('mux', 'FUNCTION'), ('x', 'PARAMETER')]

    `resource` is a `rope.base.resources.Resource` object.

    `offset` is the offset of the pyname you want the path to.

    N	PARAMETERVARIABLEFUNCTIONCLASSMODULE)get_pymoduler   eval_locationr;   	get_scopeget_inner_scope_for_line
isinstancer   ParameterNamer   get_name_atr=   AssignedNameparentr   FunctionScope
ClassScopeappendr4   get_name	real_pathreverse)
r   r   r   pymodr3   defmodr?   scopenames
scope_types
             r    get_canonical_pathrb      s   0   **E#E622F 3355NFF t77??E E&*233 Q$U%7%7%9%96BBKPQ	FJ3	4	4 Q$U%7%7%9%96BBJOP , eX344 	#JJx233 	 JJJen--//<=== ,  
LL&%%''18<===	MMOOOLr"   c                   t    e Zd ZdZddZd Zd Zed             Zed             Z	d Z
d	 Zed
             ZdS )CompletionProposala  A completion proposal

    The `scope` instance variable shows where proposed name came from
    and can be 'global', 'local', 'builtin', 'attribute', 'keyword',
    'imported', 'parameter_keyword'.

    The `type` instance variable shows the approximate type of the
    proposed object and can be 'instance', 'class', 'function', 'module',
    and `None`.

    All possible relations between proposal's `scope` and `type` are shown
    in the table below (different scopes in rows and types in columns):

                      | instance | class | function | module | None
                local |    +     |   +   |    +     |   +    |
               global |    +     |   +   |    +     |   +    |
              builtin |    +     |   +   |    +     |        |
            attribute |    +     |   +   |    +     |   +    |
             imported |    +     |   +   |    +     |   +    |
              keyword |          |       |          |        |  +
    parameter_keyword |          |       |          |        |  +

    Nc                 V    || _         || _        |                     |          | _        d S N)namer3   
_get_scoper_   )selfrg   r_   r3   s       r    __init__zCompletionProposal.__init__   s'    	__U++


r"   c                 6    | j          d| j         d| j         dS )Nz (, ))rg   r_   typeri   s    r    __str__zCompletionProposal.__str__   s'    )99tz99TY9999r"   c                      t          |           S rf   )strro   s    r    __repr__zCompletionProposal.__repr__   s    4yyr"   c                 ,   | j         }t          |t          j                  r|                                }t          |t          j                  rB|                                }t          |t          j                  r|	                                S dS dS )ztThe names of the parameters the function takes.

        Returns None if this completion is not a function.
        N)
r3   rR   r   ImportedName_get_imported_pynameDefinedNamer/   r	   AbstractFunctionget_param_namesri   r3   r4   s      r    
parameterszCompletionProposal.parameters   s     fg233 	30022Ffg122 	2((**H(I$>?? 2//111	2 	22 2r"   c                    | j         }t          |t          j                  r|                                }t          |t          j                  rdS t          |t          j                  rdS t          |t          j                  st          |t          j                  rdS nt          |t          j	                  rdS t          |t          j
                  st          |t          j                  rL|                                }t          |t          j                  rdS t          |t          j                  rdS dS )Nfunctionclassinstancer>   )r3   rR   r   BuiltinNamer/   BuiltinFunctionBuiltinClassBuiltinObjectr   ImportedModuleru   rw   r	   rx   AbstractClassrz   s      r    rn   zCompletionProposal.type  s5   fh233 	((**H(H$<== "!zHh&;<< "wHh&<== "(.B B " "z"  677 		8 455 	G':
 :
 	 ((**H(I$>?? "!z(I$;<< wzr"   c                     t          | j        t          j                  rdS t          | j        t          j                  st          | j        t          j                  rdS |S )Nbuiltinimported)rR   r3   r   r   r   r   ru   )ri   r_   s     r    rh   zCompletionProposal._get_scope  s\    dk8#788 	9dk7#9:: 	jK-?
 ?
 	 :r"   c                     | j         sdS | j                                         }t          |d          sdS | j                                                                         S )zYGet the proposed object's docstring.

        Returns None if it can not be get.
        Nr1   )r3   r/   hasattrr1   ri   r4   s     r    r1   zCompletionProposal.get_doc'  s]    
 { 	4;))++x++ 	4{%%''//111r"   c                 8    t          j        d           | j        S )NzAthe proposal's `kind` property is deprecated, use `scope` instead)r   r   r_   ro   s    r    kindzCompletionProposal.kind3  s#    R	
 	
 	
 zr"   rf   )__name__
__module____qualname____doc__rj   rp   rs   propertyr{   rn   rh   r1   r    r"   r    rd   rd      s         0, , , ,
: : :   2 2 X2   X0  
2 
2 
2   X  r"   rd   c                   (     e Zd ZdZ fdZd Z xZS )NamedParamProposalzA parameter keyword completion proposal

    Holds reference to ``_function`` -- the function which
    parameter ``name`` belongs to. This allows to determine
    default value for this parameter.
    c                 r    || _         d|z  }t                                          |d           || _        d S )Nz%s=parameter_keyword)argnamesuperrj   	_function)ri   rg   r}   	__class__s      r    rj   zNamedParamProposal.__init__G  s9    t|2333!r"   c                     t           j                            | j                  }|j        D ]\  }}| j        |k    r|c S dS )zGet a string representation of a param's default value.

        Returns None if there is no default value for this param.
        N)r   DefinitionInforeadr   args_with_defaultsr   )ri   definfoargdefaults       r    get_defaultzNamedParamProposal.get_defaultM  sT    
  .33DNCC#6 	 	LC|s" tr"   )r   r   r   r   rj   r   __classcell__r   s   @r    r   r   ?  sQ         " " " " "	 	 	 	 	 	 	r"   r   c                 L    t          | ||          }|                                S )a  Sort a list of proposals

    Return a sorted list of the given `CodeAssistProposal`.

    `scopepref` can be a list of proposal scopes.  Defaults to
    ``['parameter_keyword', 'local', 'global', 'imported',
    'attribute', 'builtin', 'keyword']``.

    `typepref` can be a list of proposal types.  Defaults to
    ``['class', 'function', 'instance', 'module', None]``.
    (`None` stands for completions with no type like keywords.)
    )_ProposalSorterget_sorted_proposal_list)	proposals	scopepreftypeprefsorters       r    sorted_proposalsr   Y  s'     Y	8<<F**,,,r"   c                 v    t          j        | d          }|                    |          \  }}}|r|dz   |z   S |S )z!Return the expression to completeT.r$   r'   s         r    starting_expressionr   j  sQ    -T22K,7,S,S- -)J/  +C(**Or"   c                  >    t          j        dt          d           i S )Nz"default_templates() is deprecated.r   r   )r   r   r   r   r"   r    default_templatesr   u  s*    M,.@Q    Ir"   c                   d    e Zd Z	 ddZej        Zd Zd Zd Z	d Z
dd	Zd
 Zd Zd Zd Zd ZdS )r   Nr   Tc                     || _         || _        || _        || _        || _        t          j        |d          | _        | j                            |          \  | _	        | _
        | _        d S )NT)r   coder   r   r   r   r%   r(   r&   r)   r*   r   )ri   r   r   r   r   r   r   s          r    rj   z_PythonCodeAssist.__init__}  sj     	  (!=d;;
 88@@		
OMKKKr"   c                     |dz
  }|dk    rS||                                          s
||         dv r/|dz  }|dk    r$||                                          %||         dv /|dz   S )Nr   r   _)isalnum)ri   r   r   current_offsets       r    _find_starting_offsetz'_PythonCodeAssist._find_starting_offset  s    !! 	 '//11	 5@5PTW5W	  aN ! 	 '//11	 5@5PTW5W	  !!r"   c                 *    fd| j         D             S )Nc                 Z    g | ]'}|                               t          |d           (S )keyword)
startswithrd   ).0kwr*   s     r    
<listcomp>z8_PythonCodeAssist._matching_keywords.<locals>.<listcomp>  sE     
 
 
}}X&&
r9--
 
 
r"   )keywords)ri   r*   s    `r    _matching_keywordsz$_PythonCodeAssist._matching_keywords  s0    
 
 
 
m
 
 
 	
r"   c                 x   | j         t          | j                  k    rg S t          |                                                                           }| j                                        dk    rJ| j                                        dk    r-|	                    | 
                    | j                             |S )N )r   lenr   list_code_completionsvaluesr)   stripr*   extendr   )ri   completionss     r    __call__z_PythonCodeAssist.__call__  s    ;TY' 	I41133::<<==?  ""b( 	GT]-@-@-B-Bb-H 	Gt66t}EEFFFr"   c                 r   i }t          j        || j                  }||                                }d}t	          |t
          j        t
          j        f          rd}|                                	                                D ]3\  }}|
                    | j                  rt          |||          ||<   4|S )N	attributer   )r   eval_strr)   r/   rR   r
   PyModule	PyPackageget_attributesitemsr   r*   rd   )	ri   module_scopeholding_scoperesultfound_pynameelementcompl_scoperg   r3   s	            r    _dotted_completionsz%_PythonCodeAssist._dotted_completions  s    (HH 	Q"--//G%K'L$9<;Q#RSS )( ' 6 6 8 8 > > @ @ Q Qf??4=11 Q#5dK#P#PF4Lr"   c                    |j         |                     |j         |           ||                                }n|                                }|                                D ]o\  }}|                    | j                  rPd}|                                dk    rd}|| j        s| 	                    |||          st          |||          ||<   pd S )NlocalModuleglobal)rV   _undotted_completionsget_propagated_names	get_namesr   r   r*   get_kindr   _is_defined_afterrd   )ri   r_   r   r?   r`   rg   r3   r   s           r    r   z'_PythonCodeAssist._undotted_completions  s    < 	=&&u|V<<< 	&..00EEOO%%E!KKMM 
	Q 
	QLD&t}-- 	Q%>>##x/ +"*KQ(Q  11%HHQ
 $6dK#P#PF4L
	Q 
	Qr"   c                     | j                             | j                  }|i S |                     ||          }i }|D ]7}|                    | j                  rt          |d||                   ||<   8|S )Nr   )r_   r3   )r(   get_from_moduler   _find_moduler   r*   rd   )ri   pymodulemodule_namer   rg   s        r    _from_import_completionsz*_PythonCodeAssist._from_import_completions  s    &66t{CC 	I$$X{;; 	 	Dt}-- 1$     t r"   c                     d}||         dk    r|dz  }||         dk    t          j        |||d          |          }|                                S )Nr   r   r   )r   r   r/   )ri   r   r   dotsr3   s        r    r   z_PythonCodeAssist._find_module  se    $3& 	AID $3& 	'+dee2DdKK  """r"   c                     |                                 }|V|d         P|d         |j                                        k    r/||d         cxk    r|                                k    rn d S dS d S d S d S d S )Nr   r   T)r;   r4   r<   get_end)ri   r_   r3   r?   locations        r    r   z#_PythonCodeAssist._is_defined_after  s    1133 	HQK 	u~88:::hqk   -2]]__      t	 	 	 	   r"   c                 B   | j                             dd| j                  dz   }t          j        | j        | j         | j        | j                  }|                                }|	                                }|j
        }|                    d          }i }t          j        ||          }t          j        ||dz
                     }	|                    ||	          }
| j                            | j                  r|                     |          S | j                                        dk    r*|                    |                     ||
                     nF|                    |                     |j        |
                     |                     |
||           |S )N
r   r   r   )r?   )r   countr   r   r-   r   r   r   rN   rP   r   split_logical_start_get_line_indentsrQ   r(   is_a_name_after_from_importr   r)   r   updater   _keyword_parametersr4   r   )ri   r?   r2   r   r   r   linesr   startindentsinner_scopes              r    r   z#_PythonCodeAssist._code_completions  sz   q$+66:#L$)T]DM
 
 %%''))++#

4  (77-eEAI.>??";;E7KK77DD 	;00:::?  ""b( 	KMM$22<MMNNNNMM$22<3H+VVWWW&&{F6&JJJr"   c                 T   | j         }|dk    ri S t          j        | j        d          }|                    |dz
            re|                    |dz
            }|                    |dz
            }	 t          j        ||          }n# t          j
        $ r i cY S w xY w||                                }t          |t          j                  rnWt          |t          j                  rd|v r|d                                         }nd|v r|d                                         }t          |t          j                  rdg }	|	                    |                    d                     i }
|	D ]2}|                    | j                  rt)          ||          |
|dz   <   3|
S i S )	Nr   Tr   rj   r   F)special_args=)r   r   r%   r   is_on_function_call_keywordfind_parens_start_from_insideget_primary_atr   r   r   BadIdentifierErrorr/   rR   r	   rx   r   r   ry   r   r*   r   )ri   r   r_   r   r(   function_parensprimaryfunction_pynamer4   param_namesr   rg   s               r    r   z%_PythonCodeAssist._keyword_parameters  s   Q; 	ImDIt44226A:>> 	")GGQR
SSO!0011DEEG"*"3E7"C"C0   			 "*5577h	(BCC Ax)@AAA"h.A  (
3>>@@HH8+ A'
3>>@@Hh	(BCC ""$K&&x'?'?U'?'S'STTTF + T T??4=99 T1CD(1S1SF4#:.!M	s   4B
 
BB)Nr   Trf   )r   r   r   rj   r   kwlistr   r   r   r   r   r   r   r   r   r   r   r   r"   r    r   r   |  s        TXA A A A ~H" " "
 
 
    Q Q Q Q&  # # #    ,    r"   r   c                   &    e Zd ZdZddZd Zd ZdS )r   z$Sort a list of code assist proposalsNc                 v    || _         |g d}|| _        |g d}d t          |          D             | _        d S )N)r   r   r   r   r   r   r   )r~   r}   r   r>   Nc                     i | ]\  }}||	S r   r   )r   indexrn   s      r    
<dictcomp>z,_ProposalSorter.__init__.<locals>.<dictcomp>,  s    LLLuLLLr"   )r   r   	enumeratetyperank)ri   code_assist_proposalsr   r   s       r    rj   z_ProposalSorter.__init__  s`    . 		  I # 	IHHHHLL	(8K8KLLLr"   c                 <    i } j         D ]0}|                    |j        g                               |           1g } j        D ]V}|                    |g           } fd|D             }|                     j                   |                    |           W|S )z%Return a list of `CodeAssistProposal`c                 0    g | ]}|j         j        v |S r   )rn   r  )r   proposalri   s     r    r   z<_ProposalSorter.get_sorted_proposal_list.<locals>.<listcomp>6  s8       =DM1  r"   )key)	r   
setdefaultr_   rY   r   getsort_proposal_keyr   )ri   r   r  r   r_   scope_proposalss   `     r    r   z(_ProposalSorter.get_sorted_proposal_list.  s    	 	F 	FH  44;;HEEEE^ 	+ 	+E'mmE266O    /  O
   T%7 888MM/****r"   c                 t    d }| j                             |j        d           ||j                  |j        fS )Nc                 4    t          d | D                       S )Nc              3   &   K   | ]}|d k    dV  dS )r   r   Nr   )r   cs     r    	<genexpr>zJ_ProposalSorter._proposal_key.<locals>._underline_count.<locals>.<genexpr>A  s+      33Q!s(3q333333r"   )sum)rg   s    r    _underline_countz7_ProposalSorter._proposal_key.<locals>._underline_count@  s    33$333333r"   d   )r  r  rn   rg   )ri   	proposal1r   s      r    r  z_ProposalSorter._proposal_key?  sI    	4 	4 	4 Minc22Y^,,N
 	
r"   r:   )r   r   r   r   rj   r   r  r   r"   r    r   r     sP        ..M M M M"  "
 
 
 
 
r"   r   c                   b     e Zd Zd ZddZ fdZd Zd Zd Zd Z	dd	Z
dd
Zd ZddZ xZS )r0   c                 D   t          |t          j                  r|                     |          S t          |t          j                  r|                     |          S t          |t          j                  r'|                     |                                          S d S rf   )	rR   r	   rx   _get_function_docstringr   _get_class_docstringAbstractModule_trim_docstringr1   r   s     r    r1   zPyDocExtractor.get_docP  s    h	 :;; 	<//999)"9:: 	<,,X666)":;; 	<''(8(8(:(:;;;tr"   Fc                 *   	 t          |t          j                  r|d                                         }t          |t          j                  s|d                                         }n# t
          j        $ r Y d S w xY w|rt          |t          j                  sd S t          |t          j                  rZ|                     |d          }|r?| 	                    |          r*|
                    dd          
                    dd          S |S d S )	Nrj   r   T)
add_modulez(self)z()z(self, ()rR   r	   r   r/   rx   r   AttributeNotFoundError
PyFunction_get_function_signature
_is_methodreplace)ri   r4   r7   r8   r   s        r    r6   zPyDocExtractor.get_calltipY  s!   	(I$;<< =#J/::<<h	(BCC =#J/::<<0 	 	 	44	 	*Xy7K"L"L 	Fh	 :;; 	11(t1LLF Ntx88 N~~h55==iMMMM		 	s   A(A+ +A>=A>c                 (   fd}|                      |                                d          } ||          }||z  }d|v rO|d                                         }t          |t          j                  r|d|                     |          z   z  }|S )Nc                     |                                  }fd|                                 D             }d                    |          }d| d| dS )Nc                 8    g | ]}|                                 S r   )rZ   )r   r   r   s     r    r   zRPyDocExtractor._get_class_docstring.<locals>._get_class_header.<locals>.<listcomp>m  s#    OOO5enn&&OOOr"   rl   zclass r+  z):

)rZ   get_superclassesjoin)pyclass
class_namesuperssuper_classesr   s       r    _get_class_headerz>PyDocExtractor._get_class_docstring.<locals>._get_class_headerj  sc     ))++JOOOOG4L4L4N4NOOOF IIf--M>J>>>>>>r"   r   rj   

)r(  r1   r/   rR   r	   rx   _get_single_function_docstring)ri   r6  r:  contentsdocinitr   s         r    r&  z#PyDocExtractor._get_class_docstringi  s    	? 	? 	? 	? 	? ''(9(91==((x  	J:&1133D$	 :;; Jv C CD I III
r"   c                      |g}                      |          r@|                                         |j        |                                                     d                     fd|D                       S )Nr;  c                 :    g | ]}                     |          S r   )r<  )r   r}   ri   s     r    r   z:PyDocExtractor._get_function_docstring.<locals>.<listcomp>  s'    UUUxT00::UUUr"   )r/  r   _get_super_methodsrV   rZ   r5  )ri   
pyfunction	functionss   `  r    r%  z&PyDocExtractor._get_function_docstring|  s    L	??:&& 	''
(9:;N;N;P;PQQ   {{UUUU9UUU
 
 	
r"   c                 t    t          |t          j                  ot          |j        t          j                  S rf   )rR   r	   r-  rV   PyClass)ri   rC  s     r    r/  zPyDocExtractor._is_method  s5    *i&:;; 

y0A
 A
 	
r"   c                     |                      |          }|                     |                                d          }|dz   |z   S )Nr   )r   z:

)r.  r(  r1   )ri   rC  	signaturedocss       r    r<  z-PyDocExtractor._get_single_function_docstring  sI    00<<	##J$6$6$8$8!#DD7"T))r"   c                 $   g }|                                 D ]x}||v rI||                                         }t          |t          j                  r|                    |           |                    |                     ||                     y|S rf   )r4  r/   rR   r	   rx   rY   r   rB  )ri   r6  rg   r   super_classr}   s         r    rB  z!PyDocExtractor._get_super_methods  s    "3355 	F 	FK{" ,&t,7799h	(BCC ,MM(+++MM$11+tDDEEEEr"   c                 n   |                      ||          }t          |t          j                  r6t          j                            |          }||                                z   S d                    ||	                                z   d
                    |                                                    S )Nz{}({})rl   )	_locationrR   r	   r-  r   r   r   	to_stringformatrZ   r5  ry   )ri   rC  r*  r   infos        r    r.  z&PyDocExtractor._get_function_signature  s    >>*j99j)"677 	 /44Z@@Ddnn....??:..000		*446677  r"   c                 H   g }|j         }|ryt          |t          j                  s_|                    |                                           |                    d           |j         }|rt          |t          j                  _|rt          |t          j                  r)|                    d|                     |                     t          |t          j
                  r+|                    d|                                dz              d                    |          S )Nr   r   r   )rV   rR   r	   r'  rY   rZ   r-  insert_get_moduler   BuiltinModuler5  )ri   r4   r*  r   rV   s        r    rM  zPyDocExtractor._location  s    	#Z	0HII 	#OOFOO--...OOC   ]F  	#Z	0HII 	#  	<(I$899 ?4#3#3H#=#=>>>&("899 <6??#4#4s#:;;;wwx   r"   c                     |                                 }|-|                                }|t          j        |          dz   S dS )Nr   r   )r<   r=   r   modname)ri   rC  r>   r   s       r    rS  zPyDocExtractor._get_module  sO    &&(( 	8**,,H 8'11C77rr"   r   c                    |sdS |                                                                 }t          j        }|dd         D ]E}|                                }|r-t          |t          |          t          |          z
            }F|d                                         g}|t          j        k     r<|dd         D ]1}|                    ||d         	                                           2|r&|d         s|
                                 |r|d         |r'|d         s|
                    d           |r|d         d                    fd|D                       S )zThe sample code from :PEP:`257`r   r   Nr   r   c              3   (   K   | ]}d z  |z   V  dS ) Nr   )r   liner   s     r    r  z1PyDocExtractor._trim_docstring.<locals>.<genexpr>  s,      BB$w-BBBBBBr"   )
expandtabs
splitlinessysmaxsizelstripminr   r   rY   rstrippopr5  )ri   	docstringr   r   indentr[  strippedtrimmeds     `     r    r(  zPyDocExtractor._trim_docstring  s    	2 $$&&1133!""I 	@ 	@D{{}}H @VSYYX%>??8>>##$CK 	7abb	 7 7tFGG}33556666 	gbk 	KKMMM  	gbk 	 	gaj 	KKNNN  	gaj 	 yyBBBB'BBBBBBr"   )FF)F)r   )r   r   r   r1   r6   r&  r%  r/  r<  rB  r.  rM  rS  r(  r   r   s   @r    r0   r0   O  s                  &
 
 

 
 

* * *
  	 	 	 	! ! ! !  C C C C C C C Cr"   r0   c                        e Zd Z fdZ xZS )TemplateProposalc                     t          j        dt          d           t                                          |d           || _        d S )NzTemplateProposal is deprecated.r   r   template)r   r   r   r   rj   rk  )ri   rg   rk  r   s      r    rj   zTemplateProposal.__init__  sK    -/Aa	
 	
 	
 	
 	z*** r"   )r   r   r   rj   r   r   s   @r    ri  ri    s8        ! ! ! ! ! ! ! ! !r"   ri  c                   &    e Zd Zd Zd Zd Zd ZdS )Templatec                 L    || _         t          j        dt          d           d S )NzTemplate is deprecated.r   r   )rk  r   r   r   )ri   rk  s     r    rj   zTemplate.__init__  s)     /1CPQRRRRRRr"   c                     g S rf   r   ro   s    r    	variableszTemplate.variables  s    	r"   c                     | j         S rf   )rk  ri   mappings     r    
substitutezTemplate.substitute  s
    }r"   c                 *    t          | j                  S rf   )r   rk  rr  s     r    get_cursor_locationzTemplate.get_cursor_location  s    4=!!!r"   N)r   r   r   rj   rp  rt  rv  r   r"   r    rm  rm    sS        S S S    " " " " "r"   rm  )NNr   T)Nr   )Nr   FFr:   )$r   r^  r   	rope.baser   r   r   r   r   r   r	   r
   r   r   rope.contribr   rope.refactorr   r!   r+   r1   r6   r;   rD   rb   rd   CodeAssistProposalr   r   r   r   r   r   r0   ri  rm  r   r"   r    <module>r{     s    



                         # " " " " " ' ' ' ' ' ' ! ! ! !H  &. . . . %O %O %O %OP   $? ? ?5 5 5pe e e e e e e eR (     +   4- - - -"    [ [ [ [ [ [ [ [|-
 -
 -
 -
 -
 -
 -
 -
jDC DC DC DC DC DC DC DCT! ! ! ! !) ! ! !" " " " " " " " " "r"   