a
    ÷£BeïW  ã                   @   s6  d dl mZ d dlmZ d dlmZ d dlm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mZmZmZ d d
lmZmZmZmZmZ d dlmZmZ d dlm Z  d dl!m"Z"m#Z# d dl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* d dl+m,Z, d dl-m.Z. d dl/m0Z0m1Z1 G dd„ deƒZ2G dd„ deƒZ3G dd„ de(ƒZ4G dd„ de)ƒZ5G dd„ deƒZ6G dd„ de6ƒZ7G dd„ de6ƒZ8G d d!„ d!e8ƒZ9G d"d#„ d#e8ƒZ:G d$d%„ d%eƒZ;G d&d'„ d'eƒZ<G d(d)„ d)e&eƒZ=G d*d+„ d+eƒZ>G d,d-„ d-eƒZ?G d.d/„ d/eƒZ@G d0d1„ d1eƒZAG d2d3„ d3e,ƒZBG d4d5„ d5e#ƒZCd6S )7é    )Úabstractproperty)Úsearch_ancestor)Údebug)Úsettings)Úcompiled)ÚCompiledValueFilter)Úvalues_from_qualified_namesÚis_big_annoying_library)ÚAbstractFilterÚ AnonymousFunctionExecutionFilter)Ú	ValueNameÚTreeNameDefinitionÚ	ParamNameÚNameWrapper)ÚValueÚ	NO_VALUESÚValueSetÚiterator_to_value_setÚValueWrapper)ÚLazyKnownValueÚLazyKnownValues)Úinference_state_method_cache)ÚValuesArgumentsÚTreeArgumentsWrapper)ÚFunctionValueÚFunctionMixinÚOverloadedFunctionValueÚBaseFunctionExecutionContextÚFunctionExecutionContextÚFunctionNameInClass)ÚClassFilter)Úget_dynamic_array_instance)Úfunction_is_staticmethodÚfunction_is_classmethodc                       s,   e Zd Z‡ fdd„Zdd„ Zdd„ Z‡  ZS )ÚInstanceExecutedParamNamec                    s   t ƒ j||d d� || _d S )N©Ú	arguments©ÚsuperÚ__init__Ú	_instance)ÚselfÚinstanceZfunction_valueÚ	tree_name©Ú	__class__© ú`/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/jedi/inference/value/instance.pyr)      s    ÿz"InstanceExecutedParamName.__init__c                 C   s   t | jgƒS ©N)r   r*   ©r+   r0   r0   r1   Úinfer    s    zInstanceExecutedParamName.inferc                 C   s   dS ©NTr0   r3   r0   r0   r1   Úmatches_signature#   s    z+InstanceExecutedParamName.matches_signature)Ú__name__Ú
__module__Ú__qualname__r)   r4   r6   Ú__classcell__r0   r0   r.   r1   r$      s   r$   c                       s(   e Zd Z‡ fdd„Z‡ fdd„Z‡  ZS )ÚAnonymousMethodExecutionFilterc                    s   t ƒ j|i |¤Ž || _d S r2   r'   ©r+   r,   ÚargsÚkwargsr.   r0   r1   r)   (   s    z'AnonymousMethodExecutionFilter.__init__c                    sT   |j dkrFt| jjƒr*t| j ¡ | j|ƒS t| jjƒsFt| j| j|ƒS tƒ  	||¡S ©Nr   )
Úposition_indexr#   Z_function_valueÚ	tree_noder$   r*   Úpy__class__r"   r(   Ú_convert_param)r+   ÚparamÚnamer.   r0   r1   rC   ,   s    
ýýz-AnonymousMethodExecutionFilter._convert_param)r7   r8   r9   r)   rC   r:   r0   r0   r.   r1   r;   '   s   r;   c                       s.   e Zd Z‡ fdd„Zddd„Zdd„ Z‡  ZS )	ÚAnonymousMethodExecutionContextc                    s   t ƒ  |¡ || _d S r2   ©r(   r)   r,   )r+   r,   Úvaluer.   r0   r1   r)   >   s    z(AnonymousMethodExecutionContext.__init__Nc                 c   s   t | j| | j||d�V  d S )N)Úuntil_positionÚorigin_scope)r;   r,   Ú_value)r+   rI   rJ   r0   r0   r1   Úget_filtersB   s
    
ýz+AnonymousMethodExecutionContext.get_filtersc                 C   s,   t | j ¡ ƒ}t| j| j|d jƒ|d< |S r?   )ÚlistrK   Úget_param_namesr$   r,   r-   )r+   Zparam_namesr0   r0   r1   rN   I   s    ýz/AnonymousMethodExecutionContext.get_param_names)NN)r7   r8   r9   r)   rL   rN   r:   r0   r0   r.   r1   rF   =   s   
rF   c                       s   e Zd Z‡ fdd„Z‡  ZS )ÚMethodExecutionContextc                    s   t ƒ j|i |¤Ž || _d S r2   rG   r<   r.   r0   r1   r)   U   s    zMethodExecutionContext.__init__)r7   r8   r9   r)   r:   r0   r0   r.   r1   rO   T   s   rO   c                       s˜   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	e
dd„ ƒZdd„ Zdd„ Zdd„ Zd dd„Z‡ fdd„Zd!‡ fdd„	Zdd„ Z‡  ZS )"ÚAbstractInstanceValuer,   c                    s   t ƒ  ||¡ || _d S r2   )r(   r)   Úclass_value)r+   Úinference_stateÚparent_contextrQ   r.   r0   r1   r)   ]   s    zAbstractInstanceValue.__init__c                 C   s   dS r5   r0   r3   r0   r0   r1   Úis_instancec   s    z!AbstractInstanceValue.is_instancec                 C   s
   | j  ¡ S r2   )rQ   Úget_qualified_namesr3   r0   r0   r1   rU   f   s    z)AbstractInstanceValue.get_qualified_namesc                 C   s   | j S r2   ©rQ   r3   r0   r0   r1   Úget_annotated_class_objecti   s    z0AbstractInstanceValue.get_annotated_class_objectc                 C   s   | j S r2   rV   r3   r0   r0   r1   rB   l   s    z!AbstractInstanceValue.py__class__c                 C   s   d S r2   r0   r3   r0   r0   r1   Ú
py__bool__o   s    z AbstractInstanceValue.py__bool__c                 C   s   t ‚d S r2   )ÚNotImplementedErrorr3   r0   r0   r1   rE   s   s    zAbstractInstanceValue.namec                    s*   ˆ   d¡ ˆ ˆ j¡}‡ fdd„| ¡ D ƒS )NÚ__call__c                    s   g | ]}|  ˆ ¡‘qS r0   ©Úbind)Ú.0Úsr3   r0   r1   Ú
<listcomp>y   ó    z8AbstractInstanceValue.get_signatures.<locals>.<listcomp>)Úpy__getattribute__Ú	py__get__rQ   Úget_signatures)r+   Z
call_funcsr0   r3   r1   rc   w   s    z$AbstractInstanceValue.get_signaturesc                 C   s,   | j dd�D ]}| |¡}|r|  S qg S )NF)Úinclude_self_names)rL   Úget)r+   rE   ÚfilterÚnamesr0   r0   r1   Úget_function_slot_names{   s
    

z-AbstractInstanceValue.get_function_slot_namesc                    s   t  ‡ fdd„|D ƒ¡S )Nc                 3   s   | ]}|  ¡ jˆ Ž V  qd S r2   )r4   Zexecute_with_values©r]   rE   ©Úinferred_argsr0   r1   Ú	<genexpr>†   s   ÿz?AbstractInstanceValue.execute_function_slots.<locals>.<genexpr>)r   Ú	from_sets)r+   rg   rk   r0   rj   r1   Úexecute_function_slots…   s    þz,AbstractInstanceValue.execute_function_slotsTc                 C   s   |   ¡ S r2   )Ú
py__name__)r+   Zadd_class_infor0   r0   r1   Úget_type_hint‹   s    z#AbstractInstanceValue.get_type_hintc                    s>   |   d¡}|stƒ  ||¡S t|gƒ‰ t ‡ fdd„|D ƒ¡S )NÚ__getitem__c                 3   s   | ]}|  ¡  ˆ ¡V  qd S r2   ©r4   Úexecuteri   ©r=   r0   r1   rl   —   r`   z6AbstractInstanceValue.py__getitem__.<locals>.<genexpr>)rh   r(   Úpy__getitem__r   r   rm   )r+   Zindex_value_setÚcontextualized_noderg   r.   rt   r1   ru   Ž   s    
þ
z#AbstractInstanceValue.py__getitem__Nc                    s0   ˆ  d¡‰ˆstƒ  ˆ ¡S ‡ ‡‡fdd„}|ƒ S )NÚ__iter__c                  3   s$   ˆ  ˆ¡D ]} |  ˆ ¡E d H  q
d S r2   )rn   Ú
py__next__)Ú	generator©rv   Ziter_slot_namesr+   r0   r1   Úiteratež   s    z1AbstractInstanceValue.py__iter__.<locals>.iterate)rh   r(   Ú
py__iter__)r+   rv   r{   r.   rz   r1   r|   ™   s
    
z AbstractInstanceValue.py__iter__c                 C   s   d| j j| jf S )Nz
<%s of %s>)r/   r7   rQ   r3   r0   r0   r1   Ú__repr__£   s    zAbstractInstanceValue.__repr__)T)N)r7   r8   r9   Úapi_typer)   rT   rU   rW   rB   rX   r   rE   rc   rh   rn   rp   ru   r|   r}   r:   r0   r0   r.   r1   rP   Z   s    



rP   c                       s:   e Zd Z‡ fdd„Zddd„Zedd„ ƒZd	d
„ Z‡  ZS )ÚCompiledInstancec                    s   t ƒ  |||¡ || _d S r2   )r(   r)   Ú
_arguments©r+   rR   rS   rQ   r&   r.   r0   r1   r)   ª   s    zCompiledInstance.__init__NTc                 c   s0   |   ¡ }|j|dd�}|D ]}t| |ƒV  qd S ©NT)rJ   rT   )rW   rL   ÚCompiledInstanceClassFilter)r+   rJ   rd   rQ   Úclass_filtersÚfr0   r0   r1   rL   ®   s    þzCompiledInstance.get_filtersc                 C   s   t  | | jjj¡S r2   )r   ZCompiledValueNamerQ   rE   Ústring_namer3   r0   r0   r1   rE   ·   s    zCompiledInstance.namec                 C   s   dS )NFr0   r3   r0   r0   r1   Úis_stub»   s    zCompiledInstance.is_stub)NT)	r7   r8   r9   r)   rL   ÚpropertyrE   r‡   r:   r0   r0   r.   r1   r   §   s
   
	
r   c                       sf   e Zd Zedd„ ƒZedd„ ƒZddd„Zeƒ d	d
„ ƒZdd„ Z	ddd„Z
‡ fdd„Zdd„ Z‡  ZS )Ú_BaseTreeInstancec                 C   s(   | j  ¡ }|dv r$| j ¡  ¡ r$|S d S )N)rM   ÚsetÚdict)rQ   ro   rS   Úget_root_contextÚis_builtins_module©r+   rE   r0   r0   r1   Ú
array_typeÀ   s    
ÿz_BaseTreeInstance.array_typec                 C   s   t | | jjjƒS r2   )r   rQ   rE   r-   r3   r0   r0   r1   rE   È   s    z_BaseTreeInstance.nameNTc                 c   sˆ   |   ¡ }|r6| ¡ D ] }| ¡ st| || ¡ |ƒV  q|j|dd�}|D ]:}t|tƒrdt| |ƒV  qHt|t	ƒr|t
| |ƒV  qH|V  qHd S r‚   )rW   Ú	py__mro__Zis_compiledÚSelfAttributeFilterÚ
as_contextrL   Ú
isinstancer    ÚInstanceClassFilterr   rƒ   )r+   rJ   rd   rQ   Úclsr„   r…   r0   r0   r1   rL   Ì   s    þ

z_BaseTreeInstance.get_filtersc                 C   sf   |}|}t |ddƒ}|j|u rt ||¡}t| ||ƒ}|jjdkrP| | j¡}q\| ¡ }q\q| 	|¡S )NÚfuncdefZclassdefr)   )
r   rA   r   Zfrom_contextÚBoundMethodrE   rH   r’   r€   Úcreate_context)r+   Úclass_contextÚnodeÚnewZ	func_nodeÚfuncÚbound_methodÚcontextr0   r0   r1   Úcreate_instance_contextã   s    
z)_BaseTreeInstance.create_instance_contextc                 C   sH   |   ¡ rtS t | j|¡}t| jƒr(tS |  d¡p:|  d¡}|  ||¡S )z»
        Since nothing was inferred, now check the __getattr__ and
        __getattribute__ methods. Stubs don't need to be checked, because
        they don't contain any logic.
        Ú__getattr__Ú__getattribute__)	r‡   r   r   Úcreate_simple_objectrR   r	   rS   rh   rn   )r+   r†   rE   rg   r0   r0   r1   Úpy__getattribute__alternativesó   s    	

ÿz0_BaseTreeInstance.py__getattribute__alternativesc                 c   s4   d}|   |¡}|r$t|  |¡ƒV  nt d| ¡ d S )NÚ__next__z(Instance has no __next__ function in %s.)rh   r   rn   r   Úwarning)r+   rv   rE   Znext_slot_namesr0   r0   r1   rx     s    
ÿz_BaseTreeInstance.py__next__c                    s2   |   d¡}|stƒ  ˆ ¡S t ‡ fdd„|D ƒ¡S )NrZ   c                 3   s   | ]}|  ¡  ˆ ¡V  qd S r2   rr   ri   r%   r0   r1   rl     r`   z/_BaseTreeInstance.py__call__.<locals>.<genexpr>)rh   r(   Ú
py__call__r   rm   )r+   r&   rg   r.   r%   r1   r¦     s    
z_BaseTreeInstance.py__call__c                 C   sn   | j  ¡ D ]"}| | ||¡}|tur
|  S q
|  d¡}|r`|du rRt | jd¡}|  |||¡S t	| gƒS dS )z"
        obj may be None.
        Ú__get__NÚNone)
rQ   r�   Zpy__get__on_classÚNotImplementedrh   r   Zbuiltin_from_namerR   rn   r   )r+   r,   rQ   r•   Úresultrg   r0   r0   r1   rb     s    

z_BaseTreeInstance.py__get__)NT)N)r7   r8   r9   rˆ   r�   rE   rL   r   rŸ   r£   rx   r¦   rb   r:   r0   r0   r.   r1   r‰   ¿   s   





r‰   c                       sR   e Zd Z‡ fdd„Zedd�dd„ ƒZdd„ Zd	d
„ Z‡ fdd„Zdd„ Z	‡  Z
S )ÚTreeInstancec                    sJ   |  ¡ dv r(| ¡  ¡ r(tjr(t| |ƒ}tƒ  |||¡ || _|j	| _	d S )N)rM   rŠ   )
ro   rŒ   r�   r   Zdynamic_array_additionsr!   r(   r)   r€   rA   r�   r.   r0   r1   r)   2  s    
ÿ
zTreeInstance.__init__N)Údefaultc           
      C   s¸   ddl m}m} t| | jƒ}| j d¡ ¡ D ]†}|jj	}|d u s,|j
dks,| |¡sVq,t| | j ¡ |jƒ}||ƒ}||||ƒ}|r,| j ||j||ƒ¡\}	tjd|	dd� |	  S q,d S )Nr   )Úpy__annotations__Úinfer_type_vars_for_executionr)   r–   zInferred instance value as %sZBLUE)Úcolor)Ú!jedi.inference.gradual.annotationr­   r®   ÚInstanceArgumentsr€   rQ   ra   rc   rH   rA   Útyper6   r—   r’   Zdefine_genericsr   Zdbg)
r+   r­   r®   r=   Ú	signaturer–   r�   Zall_annotationsZtype_var_dictZdefinedr0   r0   r1   Ú_get_annotated_class_objectA  s$    ÿÿ
z(TreeInstance._get_annotated_class_objectc                 C   s   |   ¡ p| jS r2   )r´   rQ   r3   r0   r0   r1   rW   [  s    z'TreeInstance.get_annotated_class_objectc                 C   sv   t }| jdkrrt| j ¡ ƒD ]T\}\}}|d u rT|dkrT|t dd„ | ¡ D ƒ¡O }|r|tt 	| j
|¡gƒO }q|S )Nr‹   r   c                 s   s    | ]}|j d kr| ¡ V  qdS ©r‹   N)r�   Úget_key_values)r]   Úvr0   r0   r1   rl   c  s   
þz.TreeInstance.get_key_values.<locals>.<genexpr>)r   r�   Ú	enumerater€   Úunpackr   rm   r4   r   r¢   rR   )r+   ÚvaluesÚiÚkeyr,   r0   r0   r1   r¶   ^  s    
þ
þzTreeInstance.get_key_valuesc                    sx   | j dkrltt| j ¡ ƒƒD ]N\}}|d u rVt ‡ fdd„| ¡ D ƒ¡}|rj|  S q|ˆ kr| ¡   S qtƒ  	ˆ ¡S )Nr‹   c                 3   s"   | ]}|j d kr| ˆ ¡V  qdS rµ   )r�   Úpy__simple_getitem__)r]   Z	dct_value©Úindexr0   r1   rl   {  s   
þz4TreeInstance.py__simple_getitem__.<locals>.<genexpr>)
r�   ÚreversedrM   r€   r¹   r   rm   r4   r(   r½   )r+   r¿   r¼   Zlazy_contextrº   r.   r¾   r1   r½   p  s    
þ
z!TreeInstance.py__simple_getitem__c                 C   s   d| j j| j| jf S )Nz<%s of %s(%s)>)r/   r7   rQ   r€   r3   r0   r0   r1   r}   ‡  s    ÿzTreeInstance.__repr__)r7   r8   r9   r)   r   r´   rW   r¶   r½   r}   r:   r0   r0   r.   r1   r«   1  s   
r«   c                   @   s   e Zd ZdZdS )ÚAnonymousInstanceN)r7   r8   r9   r€   r0   r0   r0   r1   rÁ   Œ  s   rÁ   c                   @   s   e Zd Zedd„ ƒZdS )ÚCompiledInstanceNamec                 c   s0   | j  ¡ D ] }|jdkr$t|ƒV  q
|V  q
d S )NÚfunction)Ú_wrapped_namer4   r~   ÚCompiledBoundMethod©r+   Zresult_valuer0   r0   r1   r4   ‘  s    
zCompiledInstanceName.inferN)r7   r8   r9   r   r4   r0   r0   r0   r1   rÂ   �  s   rÂ   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
rƒ   c                 C   s   || _ || _d S r2   ©r*   Ú_class_filter)r+   r,   r…   r0   r0   r1   r)   ›  s    z$CompiledInstanceClassFilter.__init__c                 C   s   |   | j |¡¡S r2   ©Ú_convertrÈ   re   rŽ   r0   r0   r1   re   Ÿ  s    zCompiledInstanceClassFilter.getc                 C   s   |   | j ¡ ¡S r2   ©rÊ   rÈ   rº   r3   r0   r0   r1   rº   ¢  s    z"CompiledInstanceClassFilter.valuesc                 C   s   dd„ |D ƒS )Nc                 S   s   g | ]}t |ƒ‘qS r0   )rÂ   ©r]   Únr0   r0   r1   r_   ¦  r`   z8CompiledInstanceClassFilter._convert.<locals>.<listcomp>r0   ©r+   rg   r0   r0   r1   rÊ   ¥  s    z$CompiledInstanceClassFilter._convertN)r7   r8   r9   r)   re   rº   rÊ   r0   r0   r0   r1   rƒ   š  s   rƒ   c                       sr   e Zd Z‡ fdd„Zdd„ Ze‡ fdd„ƒZdd„ Zd	d
„ Zddd„Z	dd„ Z
dd„ Z‡ fdd„Zdd„ Z‡  ZS )r—   c                    s   t ƒ  |¡ || _|| _d S r2   )r(   r)   r,   Ú_class_context)r+   r,   r™   rÃ   r.   r0   r1   r)   ª  s    zBoundMethod.__init__c                 C   s   dS r5   r0   r3   r0   r0   r1   Úis_bound_method¯  s    zBoundMethod.is_bound_methodc                    s   t | jtƒ jƒS r2   )r   rÏ   r(   rE   r3   r.   r0   r1   rE   ²  s    þzBoundMethod.namec                 C   s   t | jddƒ\}|S )NÚtypesÚ
MethodType)r   rR   )r+   Úcr0   r0   r1   rB   ¹  s    zBoundMethod.py__class__c                 C   s   |d usJ ‚t | j|ƒS r2   )r±   r,   ©r+   r&   r0   r0   r1   Ú_get_arguments½  s    zBoundMethod._get_argumentsNc                 C   s,   |d u rt | j| ƒS |  |¡}t| j| |ƒS r2   )rF   r,   rÕ   rO   rÔ   r0   r0   r1   Ú_as_contextÁ  s    
zBoundMethod._as_contextc                 C   s0   t | jtƒr| j |  |¡¡S |  |¡}| ¡ S r2   )r“   Ú_wrapped_valuer   r¦   rÕ   r’   r4   )r+   r&   Zfunction_executionr0   r0   r1   r¦   È  s    
zBoundMethod.py__call__c                    s   ‡ fdd„ˆ j  ¡ D ƒS )Nc                    s   g | ]}t ˆ jˆ j|ƒ‘qS r0   )r—   r,   rÏ   )r]   r…   r3   r0   r1   r_   Ð  s   ÿz7BoundMethod.get_signature_functions.<locals>.<listcomp>)r×   Úget_signature_functionsr3   r0   r3   r1   rØ   Ï  s    
þz#BoundMethod.get_signature_functionsc                    s   ‡ fdd„t ƒ  ¡ D ƒS )Nc                    s   g | ]}|  ˆ ¡‘qS r0   r[   ©r]   Úsigr3   r0   r1   r_   Ö  r`   z.BoundMethod.get_signatures.<locals>.<listcomp>)r(   rc   r3   r.   r3   r1   rc   Õ  s    zBoundMethod.get_signaturesc                 C   s   d| j j| jf S )Nz<%s: %s>)r/   r7   r×   r3   r0   r0   r1   r}   Ø  s    zBoundMethod.__repr__)N)r7   r8   r9   r)   rÐ   rˆ   rE   rB   rÕ   rÖ   r¦   rØ   rc   r}   r:   r0   r0   r.   r1   r—   ©  s   
r—   c                   @   s   e Zd Zdd„ Zdd„ ZdS )rÅ   c                 C   s   dS r5   r0   r3   r0   r0   r1   rÐ   Ý  s    z#CompiledBoundMethod.is_bound_methodc                    s   ‡ fdd„ˆ j  ¡ D ƒS )Nc                    s   g | ]}|  ˆ ¡‘qS r0   r[   rÙ   r3   r0   r1   r_   á  r`   z6CompiledBoundMethod.get_signatures.<locals>.<listcomp>)r×   rc   r3   r0   r3   r1   rc   à  s    z"CompiledBoundMethod.get_signaturesN)r7   r8   r9   rÐ   rc   r0   r0   r0   r1   rÅ   Ü  s   rÅ   c                       s<   e Zd ZdZdd„ Zedd„ ƒZdd„ Z‡ fdd	„Z‡  Z	S )
ÚSelfNamez9
    This name calculates the parent_context lazily.
    c                 C   s   || _ || _|| _d S r2   )r*   r™   r-   )r+   r,   r™   r-   r0   r0   r1   r)   è  s    zSelfName.__init__c                 C   s   | j  | j| j¡S r2   )r*   rŸ   r™   r-   r3   r0   r0   r1   rS   í  s    zSelfName.parent_contextc                 C   s   | j S r2   ©r*   r3   r0   r0   r1   Úget_defining_qualified_valueñ  s    z%SelfName.get_defining_qualified_valuec                    s^   t | jdƒ}|d urT|jd jdkrTddlm} || j|jd jd ƒ ¡ }|rT|S tƒ  	¡ S )NZ	expr_stmté   Z	annassignr   )Úinfer_annotation)
r   r-   Úchildrenr²   r°   rß   rS   Zexecute_annotationr(   r4   )r+   Ústmtrß   rº   r.   r0   r1   r4   ô  s    ÿzSelfName.infer)
r7   r8   r9   Ú__doc__r)   rˆ   rS   rÝ   r4   r:   r0   r0   r.   r1   rÛ   ä  s   
rÛ   c                       s8   e Zd Z‡ fdd„Zedd„ ƒZdd„ Zdd„ Z‡  ZS )	ÚLazyInstanceClassNamec                    s   t ƒ  |¡ || _d S r2   r'   )r+   r,   Zclass_member_namer.   r0   r1   r)     s    zLazyInstanceClassName.__init__c                 c   s.   | j  ¡ D ]}| | j| j ¡ ¡E d H  q
d S r2   )rÄ   r4   rb   r*   rB   rÆ   r0   r0   r1   r4     s    zLazyInstanceClassName.inferc                 C   s   |   ¡  ¡ S r2   )r4   rc   r3   r0   r0   r1   rc     s    z$LazyInstanceClassName.get_signaturesc                 C   s   | j S r2   rÜ   r3   r0   r0   r1   rÝ     s    z2LazyInstanceClassName.get_defining_qualified_value)	r7   r8   r9   r)   r   r4   rc   rÝ   r:   r0   r0   r.   r1   rã     s
   
rã   c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )r”   zæ
    This filter is special in that it uses the class filter and wraps the
    resulting names in LazyInstanceClassName. The idea is that the class name
    filtering can be very flexible and always be reflected in instances.
    c                 C   s   || _ || _d S r2   rÇ   )r+   r,   Zclass_filterr0   r0   r1   r)     s    zInstanceClassFilter.__init__c                 C   s   |   | j |¡¡S r2   rÉ   rŽ   r0   r0   r1   re     s    zInstanceClassFilter.getc                 C   s   |   | j ¡ ¡S r2   rË   r3   r0   r0   r1   rº     s    zInstanceClassFilter.valuesc                    s   ‡ fdd„|D ƒS )Nc                    s   g | ]}t ˆ j|ƒ‘qS r0   )rã   r*   rÌ   r3   r0   r1   r_   #  s   ÿz0InstanceClassFilter._convert.<locals>.<listcomp>r0   rÎ   r0   r3   r1   rÊ   "  s    
þzInstanceClassFilter._convertc                 C   s   d| j j| jf S )Nz<%s for %s>)r/   r7   rÈ   r3   r0   r0   r1   r}   (  s    zInstanceClassFilter.__repr__N)	r7   r8   r9   râ   r)   re   rº   rÊ   r}   r0   r0   r0   r1   r”     s   r”   c                       sH   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	‡  Z
S )r‘   zU
    This class basically filters all the use cases where `self.*` was assigned.
    c                    s   t ƒ j|||dd� || _d S )NT)rQ   Únode_contextrJ   rT   r'   )r+   r,   Zinstance_classrä   rJ   r.   r0   r1   r)   0  s    üzSelfAttributeFilter.__init__c                    s0   | j j| j j ‰‰ ‡ ‡fdd„|D ƒ}|  |¡S )Nc                    s*   g | ]"}ˆ|j   k rˆ k rn q|‘qS r0   )Ú	start_posrÌ   ©ÚendÚstartr0   r1   r_   ;  r`   z/SelfAttributeFilter._filter.<locals>.<listcomp>)Ú_parser_scoperå   Úend_posÚ_filter_self_namesrÎ   r0   ræ   r1   Ú_filter9  s    zSelfAttributeFilter._filterc                 c   sh   |D ]^}|j }|jdkrt|j jƒdkr|jd dkr| ¡ r|  |¡r|  |j jd |¡r|V  qd S )NÚtraileré   r   Ú.)Úparentr²   Úlenrà   Zis_definitionZ_access_possibleÚ_is_in_right_scope)r+   rg   rE   rí   r0   r0   r1   rë   >  s    
ÿþz&SelfAttributeFilter._filter_self_namesc                    s2   ˆ j  |¡}|j||jd�}t‡ fdd„|D ƒƒS )N)Úpositionc                 3   s6   | ].}|j d ko,|j ¡ jdko,|jjˆ ju V  qdS )rD   r   N)r~   r-   Zget_definitionr@   rS   rA   ré   rÌ   r3   r0   r1   rl   M  s
   ý
ÿz9SelfAttributeFilter._is_in_right_scope.<locals>.<genexpr>)Ú_node_contextr˜   Zgotorå   Úany)r+   Ú	self_namerE   Zself_contextrg   r0   r3   r1   rò   J  s
    üz&SelfAttributeFilter._is_in_right_scopec                    s   ‡ fdd„|D ƒS )Nc                    s   g | ]}t ˆ jˆ j|ƒ‘qS r0   )rÛ   r*   rô   ri   r3   r0   r1   r_   U  r`   z6SelfAttributeFilter._convert_names.<locals>.<listcomp>r0   rÎ   r0   r3   r1   Ú_convert_namesT  s    z"SelfAttributeFilter._convert_namesc                 C   s   |S r2   r0   rÎ   r0   r0   r1   Ú_check_flowsW  s    z SelfAttributeFilter._check_flows)r7   r8   r9   râ   r)   rì   rë   rò   r÷   rø   r:   r0   r0   r.   r1   r‘   ,  s   	
r‘   c                       s&   e Zd Z‡ fdd„Zddd„Z‡  ZS )r±   c                    s   t ƒ  |¡ || _d S r2   rG   )r+   r,   r&   r.   r0   r1   r)   \  s    zInstanceArguments.__init__Nc                 c   s&   d t | jƒfV  | j |¡E d H  d S r2   )r   r,   Z_wrapped_argumentsr¹   )r+   rœ   r0   r0   r1   r¹   `  s    zInstanceArguments.unpack)N)r7   r8   r9   r)   r¹   r:   r0   r0   r.   r1   r±   [  s   r±   N)DÚabcr   Z
parso.treer   Zjedir   r   Zjedi.inferencer   Zjedi.inference.compiled.valuer   Zjedi.inference.helpersr   r	   Zjedi.inference.filtersr
   r   Zjedi.inference.namesr   r   r   r   Zjedi.inference.base_valuer   r   r   r   r   Zjedi.inference.lazy_valuer   r   Zjedi.inference.cacher   Zjedi.inference.argumentsr   r   Zjedi.inference.value.functionr   r   r   r   r   r   Zjedi.inference.value.klassr    Z#jedi.inference.value.dynamic_arraysr!   Zjedi.parser_utilsr"   r#   r$   r;   rF   rO   rP   r   r‰   r«   rÁ   rÂ   rƒ   r—   rÅ   rÛ   rã   r”   r‘   r±   r0   r0   r0   r1   Ú<module>   sD    Mr[
3/