
    c                         d dl mZmZmZmZmZ d dlmZ d dlm	Z	 dddej
        fdZdej
        fdZdd	Z G d
 d          Zd ZdS )    )evaluate
exceptions	pyobjects
taskhandleworder)	fixsyntax)occurrencesFNc                 \   t          j        ||          }|                     |          }t          j        ||          \  }	}
fd}t          j        | ||
|||	          }||                                 }|                    dt          |                    }t          |||          S )aM  Return a list of `Location`

    If `unsure` is `True`, possible matches are returned, too.  You
    can use `Location.unsure` to see which are unsure occurrences.
    `resources` can be a list of `rope.base.resource.File` that
    should be searched for occurrences; if `None` all python files
    in the project are searched.

    c                     S N )
occurrenceunsures    3lib/python3.11/site-packages/rope/contrib/findit.pyis_matchz"find_occurrences.<locals>.is_match   s        )r   in_hierarchyinstanceNzFinding Occurrencescount)r   get_name_atget_pymoduler   eval_location2r	   create_finderget_python_filescreate_jobsetlen_find_locations)projectresourceoffsetr   	resourcesr   task_handlenamethis_pymoduleprimarypynamer   finderjob_sets      `          r   find_occurrencesr*      s    $ h//D((22M-mVDDOGV     &!  F  /,,..	''(=S^^'TTG69g666r   c                 h   t          j        ||          }|                     |          }t          j        ||          [                                }t          |t          j                  r|	                                dk    rt          j        d          nt          j        d          d }fd}	||	t          j        d          g}
t          j        | ||
          }||                                 }|                    d	t#          |          
          }t%          |||          S )zFind the places a given method is overridden.

    Finds the places a method is implemented.  Returns a list of
    `Location`.
    NmethodzNot a method!zCannot resolve the identifier!c                 2    |                                  sdS d S NF)
is_defined)r   s    r   r/   z(find_implementations.<locals>.is_definedF   s%    $$&& 	5	 	r   c                     |                                                                                                  k    rdS d S r.   )
get_pyname
get_object)r   r'   s    r   not_selfz&find_implementations.<locals>.not_selfJ   sC      ""--//63D3D3F3FF 	5	 	r   T)filterszFinding Implementationsr   )r   r   r   r   eval_locationr2   
isinstancer   
PyFunctionget_kindr   BadIdentifierErrorr	   InHierarchyFilterFinderr   r   r   r   )r   r    r!   r"   r#   r$   r%   pyobjectr/   r3   r4   r(   r)   r'   s                @r   find_implementationsr=   -   sW    h//D((22M#M6::F N$$&&8Y%9::	A  ""h.	A /@@@		A +,LMMM       8[%B64%P%PQGw???F /,,..	''(AY'XXG69g666r      c                    t          j        | |||          }|                    |          }||                                \  }}t	          j        |                              |          }	|v|j                            |          fd}
t          j
        |          }t          j        | |	|
|g          }|                    |          D ]}t          |          c S dS dS dS )zReturn the definition location of the python name at `offset`

    A `Location` object is returned if the definition location can be
    determined, otherwise ``None`` is returned.
    Nc                 "    | j         k     rdS d S r.   )r!   )r   starts    r   check_offsetz%find_definition.<locals>.check_offsetd   s"    $u, ! 5! !r   )pymodule)r   	FixSyntax	pyname_atget_definition_locationr   Worderget_word_atlinesget_line_startr	   PyNameFilterr;   r*   Location)r   coder!   r    maxfixesfixerr'   modulelinenor$   rB   pyname_filterr(   r   rA   s                 @r   find_definitionrS   V   s    xBBE__V$$F ,7799}T""..v66 
	,L//77E! ! ! ! ! (4V<<M 'm7TUUF$55v5FF , ,

+++++, ,
	, 
	,, ,r   c                       e Zd Zd Zd ZdS )rL   c                     |j         | _         |                                | _        | j        d         | _        |                                | _        |j        | _        d S )Nr   )r    get_word_rangeregionr!   	is_unsurer   rQ   )selfr   s     r   __init__zLocation.__init__o   sM    "+ //11k!n **,, 'r   c                     d                     | j        j        | j        j        | j        j        | j        | j        d         | j        d         t          t          |                               S )Nz<{}.{} "{}:{} ({}-{})" at {}>r   r>   )
format	__class__
__module____name__r    pathrQ   rW   hexid)rY   s    r   __repr__zLocation.__repr__v   sX    .55N%N#MKKNKN4MM
 
 	
r   N)r_   r^   __qualname__rZ   rc   r   r   r   rL   rL   n   s2        ( ( (	
 	
 	
 	
 	
r   rL   c           	          g }|D ]k}|                     |j                   |                    t          t          |                     |                               |                                 l|S r   )started_jobr`   extendmaprL   r*   finished_job)r(   r"   r)   resultr    s        r   r   r      sp    F  HM***c(F$;$;H$E$EFFGGGMr   )Nr>   )	rope.baser   r   r   r   r   rope.contribr   rope.refactorr	   DEFAULT_TASK_HANDLEr*   r=   rS   rL   r   r   r   r   <module>ro      s    I I I I I I I I I I I I I I " " " " " " % % % % % % .$7 $7 $7 $7V .&7 &7 &7 &7R, , , ,0
 
 
 
 
 
 
 
(    r   