+
    8Li*                        R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
HtHtHtHtHtHtHtHtHt ^ RIt^ RIHt ^ RIHt ^ RIHt ]P6                  R8  d   ^ RIHt M^ RIHt ]P<                  ! ]4      t ] PB                  ] PD                  ] PF                  ] PH                  3w  t!t"t#t% ! R	 R
]4      t& ! R R]4      t']]&]'3,          t( ! R R4      t) ! R R]*4      t+R# )z&Synchronous msgpack-rpc session layer.N)deque)
format_exc)AnyAnyStrCallableDequeList
NamedTupleOptionalSequenceTupleUnioncast)check_asyncAsyncSessionBaseEventLoop)Literalc                   0   a  ] tR t^t o RtV 3R ltRtV tR# )RequestzA request from Nvim.c                h   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   S[S[,          ;R&   S[;R&   # )   requesttypenameargsresponser   strr   r   )format__classdict__s   "</usr/lib/python3/dist-packages/pynvim/msgpack_rpc/session.py__annotate__Request.__annotate__   s?      )
  I	 
 s)O  M      N__name__
__module____qualname____firstlineno____doc____annotate_func____static_attributes____classdictcell__r!   s   @r"   r   r      s       r%   r   c                   0   a  ] tR t^#t o RtV 3R ltRtV tR# )NotificationzA notification from Nvim.c                \   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   S[S[,          ;R&   # )r   notificationr   r   r   r   )r    r!   s   "r"   r#   Notification.__annotate__#   s3      .
!!  I	 
 s)O r%   r&   Nr'   r0   s   @r"   r2   r2   #   s     #  r%   r2   c                   :  a  ] tR t^.t o RtV 3R lR lt]V 3R lR l4       tV 3R lR ltV 3R lR	 lt	V 3R
 lR lt
R"V 3R lR lltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R l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# )#SessionzMsgpack-rpc session layer that uses coroutines for a synchronous API.

This class provides the public msgpack-rpc API required by this library.
It uses the greenlet module to handle requests and notifications coming
from Nvim with a synchronous API.
c                    < V ^8  d   QhRS[ /# )r   async_sessionr   )r    r!   s   "r"   r#   Session.__annotate__7   s     
& 
&l 
&r%   c                    Wn         RV n        RV n        \        4       V n        RV n        RV n        RV n        R V n        R# )z<Wrap `async_session` on a synchronous msgpack-rpc interface.NFc                 &    \        V ^,          4      # )   	Exception)es   &r"   <lambda>"Session.__init__.<locals>.<lambda>A   s    i!or%   )	_async_session_request_cb_notification_cbr   _pending_messages_is_running_setup_exception_loop_threaderror_wrapper)selfr9   s   &&r"   __init__Session.__init__7   sE    +GKLP16 598<% 	r%   c                    < V ^8  d   QhRS[ /# r   returnr   )r    r!   s   "r"   r#   r:   D   s     ( (m (r%   c                .    V P                   P                  # )z%Get the underlying msgpack EventLoop.)rC   looprK   s   &r"   rR   Session.loopC   s     ""'''r%   c                D   < V ^8  d   QhRS[ RS[3,          RS[RS[RR/# )r   fn.r   kwargsrP   N)r   r   )r    r!   s   "r"   r#   r:   H   s6     > >38$>-0><?>	>r%   c                `   aaaa VVV3R loV3R lpV P                   P                  V4       R# )z.Wrapper around `AsyncSession.threadsafe_call`.c                  >   <  S! S / SB  R #   \          d     R # i ; iNr>   )r   rV   rW   s   r"   handler(Session.threadsafe_call.<locals>.handlerL   s'    D#F# s    c                  T   < \         P                   ! S4      p V P                  4        R # rZ   greenletswitch)grr[   s    r"   greenlet_wrapper1Session.threadsafe_call.<locals>.greenlet_wrapperT   s    ""7+BIIKr%   N)rC   threadsafe_call)rK   rV   r   rW   rb   r[   s   &fjl @r"   rd   Session.threadsafe_callH   s$    		 	++,<=r%   c                0   < V ^8  d   QhRS[ S[,          /# rO   )r
   Message)r    r!   s   "r"   r#   r:   Z   s      hw/ r%   c                P   V P                   '       d   \        R4      hV P                  '       d   V P                  P                  4       # V P                  P                  V P                  V P                  4       V P                  '       d   V P                  P                  4       # R# )zBlock until a message(request or notification) is available.

If any messages were previously enqueued, return the first in queue.
If not, run the event loop until one is received.
zEvent loop already runningN)rG   r?   rF   popleftrC   run_enqueue_request_and_stop_enqueue_notification_and_stoprS   s   &r"   next_messageSession.next_messageZ   s     899!!!))1133 > > $ C C	E!!!))1133r%   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# )r   methodr   rW   rP   )r   r   )r    r!   s   "r"   r#   r:   j   s)     ' 'f 'S 'C 'C 'r%   c                   \        VP                  RR4      VR4      pV'       d   V P                  P                  W4       R# V'       d8   \	        RP                  RP                  VP                  4       4      4      4      hV P                  '       d   V P                  W4      pMV P                  W4      pV'       g   \        R4      hVw  rgV'       d    V P                  V4      hV# )a  Send a msgpack-rpc request and block until as response is received.

If the event loop is running, this method must have been called by a
request or notification handler running on a greenlet. In that case,
send the quest and yield to the parent greenlet until a response is
available.

When the event loop is not running, it will perform a blocking request
like this:
- Send the request
- Run the loop until the response is available
- Put requests/notifications received while waiting into a queue

If the `async_` flag is present and True, a asynchronous notification
is sent instead. This will never block, and the return value or error
is ignored.
async_NFz/request got unsupported keyword argument(s): {}z, EOF)r   poprC   notify
ValueErrorr    joinkeysrG   _yielding_request_blocking_requestOSErrorrJ   )rK   rp   r   rW   rr   verrrvs   &&*,    r"   r   Session.requestj   s    $ VZZ$7G&&v4N$fTYYv{{}%=>@ @ &&v4A&&v4A%. $$S))	r%   Nc          	         < V ^8  d   QhRS[ S[S[S[,          .R3,          RS[ S[S[S[,          .R3,          RS[S[ . R3,          ,          RR/# )r   
request_cbNnotification_cbsetup_cbrP   )r   r   r   r   r
   )r    r!   s   "r"   r#   r:      sf     -( -( #tCy!14!78-(%sDI&6&<=-( xD12-( ?C-(r%   c                  a a VS n         VS n        RS n        RS n        \        P
                  ! 4       S n        R V V3R llpS'       d'   \        P                  ! V4      pVP                  4        S P                  '       d    S P                  hS P                  '       dJ   S P                  P                  4       p\        S RP                  V^ ,          4      4      ! VR,          !   K[  S P                  P                  S P                  S P                   4       RS n        RS n         RS n        RS n        S P                  '       d   S P                  hR# )zRun the event loop to receive requests and notifications from Nvim.

Like `AsyncSession.run()`, but `request_cb` and `notification_cb` are
inside greenlets.
TNc                    V ^8  d   QhRR/# r   rP   Nr&   )r    s   "r"   r#   !Session.run.<locals>.__annotate__   s     	 	$ 	r%   c                  x   <  S! 4        R #   \          d#   p T Sn        SP                  4         R p ? R # R p ? ii ; irZ   )r?   rH   stop)r@   rK   r   s    r"   on_setupSession.run.<locals>.on_setup   s0    
 ()%		s    949z_on_{}:r=   NNF)rD   rE   rG   rH   	threadingcurrent_threadrI   r_   r`   rF   ri   getattrr    rC   rj   _on_request_on_notification)rK   r   r   r   r   ra   msgs   f&&f   r"   rj   Session.run   s    & / $%446	 	 ""8,BIIK    ''' $$$((002CD(//#a&12CG< 0 0$2G2GH  $    ''' !r%   c                   < V ^8  d   QhRR/# r   r&   )r    r!   s   "r"   r#   r:      s     # #d #r%   c                :    V P                   P                  4        R# )zStop the event loop.N)rC   r   rS   s   &r"   r   Session.stop   s      "r%   c                   < V ^8  d   QhRR/# r   r&   )r    r!   s   "r"   r#   r:      s     $ $t $r%   c                :    V P                   P                  4        R# )zClose the event loop.N)rC   closerS   s   &r"   r   Session.close   s    !!#r%   c          	      h   < V ^8  d   QhRS[ RS[S[,          RS[S[S[S[3,          S[3,          /# r   rp   r   rP   r   r   r   r   intr   )r    r!   s   "r"   r#   r:      s;      $,SM	uS#X#	$r%   c                   a \         P                  ! 4       oSP                  pV3R  lpV P                  P	                  WV4        VP                  4       # )c                 ,   <  SP                  W4       R # rZ   )r`   )r}   r~   ra   s   &&r"   response_cb.Session._yielding_request.<locals>.response_cb   s    IIcr%   )r_   
getcurrentparentrC   r   r`   )rK   rp   r   r   r   ra   s   &&&  @r"   ry   Session._yielding_request   sH       "	
 	##F+>}}r%   c          	      h   < V ^8  d   QhRS[ RS[S[,          RS[S[S[S[3,          S[3,          /# r   r   )r    r!   s   "r"   r#   r:      s@     @ @ @(0@	uS#X#	$@r%   c                &  a a . oVV 3R  lpS P                   P                  WV4       S P                   P                  S P                  S P                  4       \        \        \        \        \        3,          \        3,          \        S4      4      # )c                 L   < SP                  W.4       SP                  4        R # rZ   )extendr   )r}   r~   resultrK   s   &&r"   r   .Session._blocking_request.<locals>.response_cb   s    MM3)$IIKr%   )rC   r   rj   _enqueue_request_enqueue_notificationr   r   r   r   r   tuple)rK   rp   r   r   r   s   f&& @r"   rz   Session._blocking_request   so     	 	##F+> 5 5 $ : :	<E%S/3./v??r%   c                @   < V ^8  d   QhRS[ RS[S[,          RS[RR/# r   r   r   r   rP   Nr   r   r   )r    r!   s   "r"   r#   r:      s1      #Cy47	r%   c                J    V P                  WV4       V P                  4        R # rZ   )r   r   rK   r   r   r   s   &&&&r"   rk   !Session._enqueue_request_and_stop   s     	d(3		r%   c                :   < V ^8  d   QhRS[ RS[S[,          RR/# r   r   r   rP   Nr   )r    r!   s   "r"   r#   r:      s&      3 d3i D r%   c                H    V P                  W4       V P                  4        R # rZ   )r   r   rK   r   r   s   &&&r"   rl   &Session._enqueue_notification_and_stop   s    ""4.		r%   c                @   < V ^8  d   QhRS[ RS[S[,          RS[RR/# r   r   )r    r!   s   "r"   r#   r:      s3     Q QS QS	 QS QT Qr%   c                R    V P                   P                  \        R WV4      4       R# )r   N)rF   appendr   r   s   &&&&r"   r   Session._enqueue_request   s    %%giX&OPr%   c                :   < V ^8  d   QhRS[ RS[S[,          RR/# r   r   )r    r!   s   "r"   r#   r:      s+     Q Q# QT#Y Q4 Qr%   c                P    V P                   P                  \        R W4      4       R# )r4   N)rF   r   r2   r   s   &&&r"   r   Session._enqueue_notification   s    %%l>4&OPr%   c                n   a aaa VVVV 3R  lp\         P                   ! V4      p VP                  4        R# )c                  ^  <  SP                  SS4      p  SP                  V 4       R#   \         d1   p SP                  TP                  ^ ,          RR7        Rp?R# Rp?i\         d@   p SP                  \        T4      R,           \        ^4      ,           RR7        Rp?R# Rp?ii ; i)    T)errorN
)rD   sendErrorResponser   r?   reprr   )r~   r}   r   r   r   rK   s     r"   r[   $Session._on_request.<locals>.handler   s    L%%dD1 b!  ! 7 chhqk66   L d3i$.A>dKKLs&   $) B,%AB,,B,-4B''B,Nr^   )rK   r   r   r   r[   ra   s   ffff  r"   r   Session._on_request   s+    	 	* w'
		r%   c                j   a aa VVV 3R  lp\         P                   ! V4      p VP                  4        R# )c                  T   <  SP                  SS 4        R #   \         d     R # i ; irZ   )rE   r?   )r   r   rK   s   r"   r[   )Session._on_notification.<locals>.handler  s9    %%dD1    s    ''Nr^   )rK   r   r   r[   ra   s   fff  r"   r   Session._on_notification  s&    
	 w'
		r%   )rC   rG   rI   rE   rF   rD   rH   rJ   rZ   )r(   r)   r*   r+   r,   rL   propertyrR   rd   rm   r   rj   r   r   ry   rz   rk   rl   r   r   r   r   r.   r/   r0   s   @r"   r7   r7   .   s     
& 
& ( (> >$  ' 'R-( -(^# #$ $  @ @  Q QQ Q6 r%   r7   c                       ] tR tRtRtRtR# )r   i'  a  Raise this in a request handler to respond with a given error message.

Unlike when other exceptions are caught, this gives full control off the
error response sent. When "ErrorResponse(msg)" is caught "msg" will be
sent verbatim as the error response.No traceback will be appended.
r&   N)r(   r)   r*   r+   r,   r.   r&   r%   r"   r   r   '  s     	r%   r   )      ),r,   loggingsysr   collectionsr   	tracebackr   typingr   r   r   r   r   r	   r
   r   r   r   r   r_   pynvim.compatr    pynvim.msgpack_rpc.async_sessionr   "pynvim.msgpack_rpc.event_loop.baser   version_infotyping_extensionsr   	getLoggerr(   loggerr   debuginfowarningwarnr   r2   rg   r7   BaseExceptionr   r&   r%   r"   <module>r      s    ,  
    ( ( ( (  % 9 <f)			8	$"LL&,,"NN- udDj :  %
&v vr		M 		r%   