
    8@d[                         d dl Z d dlmZmZ d dlmZmZmZ  e j        e	          Z
ed             Zd Zed             Zed             Zd Zd	 ZdS )
    N)code_assistsorted_proposals)_utilshookimpllspc                      dddddiiS )Npluginsrope_completionF)enabledeager r       =lib/python3.11/site-packages/pylsp/plugins/rope_completion.pypylsp_settingsr      s     )uu+M+MNOOr   c                    	 t          j        |                                |          }n4# t          $ r'}t                              d|           d}Y d }~nd }~ww xY wd                    |j        pd|j                  | d<   || d<   | S )N)markup_kindz%Failed to resolve Rope completion: %s z{0} {1}detaildocumentation)	r   format_docstringget_doc	Exceptionlogdebugformatscopename)
completiondatar   doces        r   _resolve_completionr"      s    %LLNN#
 
 
    		91=== %++DJ,<"diHHJx"%Js   (+ 
AAAc                 `   |                      d|j                  }|                    dd          }|                    |d         t	          |d         dz
  d          d	          }|d
k    rd S |                    |          }|                     |j                                      di           }|                    |          }	|                    |          }
| j	                            di                               di           }|                    di           }|                    ddg          }t          j        |          }	 t          |	|j        ||
d          }n4# t          $ r'}t                              d|           g cY d }~S d }~ww xY wt#          |          }g }|D ]W}|j        t'          |          t)          |          d|j        id}|rt-          |||          }|                    |           Xd t1          ||          D             |j        d<   |}|pd S )Nr
   )document_pathr   Fline	character   r   )r%   r&   importropetextDocumentr   completionItemdocumentationFormatmarkdown   )maxfixesz"Failed to run Rope code assist: %sdoc_uri)labelkindsortTextr   c                 *    i | ]\  }}|d          ||fS )r1   r   ).0r   r   s      r   
<dictcomp>z%pylsp_completions.<locals>.<dictcomp>R   s:     5 5 5 J 	7j$/5 5 5r   LAST_ROPE_COMPLETIONS)plugin_settingspathgetword_at_positionmaxoffset_at_positionsettings_rope_project_builder_rope_resourcecapabilitiesr   choose_markup_kindr   sourcer   r   r   r   r   _kind
_sort_texturir"   appendzipshared_data)config	workspacedocumentpositionr>   resolve_eagerlywordoffsetrope_configrope_projectdocument_ropecompletion_capabilitiesitem_capabilitiessupported_markup_kindspreferred_markup_kinddefinitionsr!   new_definitionsditems                       r   pylsp_completionsr\   "   s    %%&7x}%UUHll7E22O $$  s8K3H13La/P/P& &  D
 xt((22F///>>BB62NNK22;??L++K88M$155nbIIMMl\^__/334DbII.223H:,WW"56LMM!,abccc   		6:::						 #;//KO % %V!HH"18<	
 
  	G&tQ0EFFDt$$$$5 5 !$O[ A A5 5 5H01 "K$s   E) )
F3FFFc                 b   |j         d                             |d                   }| j                            di                               di           }|                    di           }|                    ddg          }t          j        |          }|r|\  }}	t          ||	|          S |S )z>Resolve formatted completion for given non-resolved completionr7   r1   r*   r   r+   r,   r-   )rI   r:   rA   r   rB   r"   )
rJ   completion_itemrL   rI   rT   rU   rV   rW   r   r   s
             r   pylsp_completion_item_resolver_   ]   s     &'>?CCOT[D\]]K$155nbIIMMl\^__/334DbII.223H:,WW"56LMM L&
D":t5JKKKr   c                     | j                             d          r
d| j         z   S | j        dk    r
d| j         z   S d| j         z   S )z` Ensure builtins appear at the bottom.
    Description is of format <type>: <module>.<item>
    _zbuiltinya)r   
startswithr   )
definitions    r   rE   rE   m   sS     !!#&& %Z_$$9$$Z_$$   r   c                 D   i dt           j        j        dt           j        j        dt           j        j        dt           j        j        dt           j        j        dt           j        j        dt           j        j        dt           j        j        d	t           j        j        d
t           j        j        dt           j        j        dt           j        j        dt           j        j        dt           j        j        dt           j        j        dt           j        j        dt           j        j        t           j        j        t           j        j        t           j        j        t           j        j        t           j        j        t           j        j	        t           j        j        t           j        j
        t           j        j        t           j        j        t           j        j        t           j        j        t           j        j
        d}|                    | j                  S )z Return the LSP type nonetypetupledict
dictionaryfunctionlambda	generatorclassinstancemethodrc   builtinfunctionmodulefilexrangeslice)	tracebackframebuffer	dictproxyfuncdefpropertyr(   keywordconstantvariablevalueparam	statement)r   CompletionItemKindValueClassFunction	ReferenceMethodModuleFilePropertyKeywordVariabler:   rj   )rZ   MAPs     r   rD   rD   {   s   &,&, 	'- 	&,	
 	c,2 	C*3 	#(1 	S+4 	'- 	C*4 	#(/ 	3)/ 	31: 	#(/ 	&+  	#(.!" 	'-#$ +1'-(.+1)2*3(/)1*3*3'-'0+3=  CB 7716??r   )loggingrope.contrib.codeassistr   r   pylspr   r   r   	getLogger__name__r   r   r"   r\   r_   rE   rD   r   r   r   <module>r      s     A A A A A A A A ' ' ' ' ' ' ' ' ' ' g!! 
P P 
P
   
7 7 
7t 
  
! ! !# # # # #r   