uBFj+>ddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z hdZd Zd!d Zd Zd ZdZdZdZdZ d"dZdZdZdZdZd!dZeeZdZdZdZ dZ!dZ"e"dZ#e"dZ$e"d Z%dS)#N) literal_eval)cleandocWeakKeyDictionary)tree) parser_cache) split_lines>atomexprtermtestpowerfactorfuncdefor_testand_exprand_testclassdefnot_testxor_expr atom_expr arith_expr comparison shift_expr import_from import_name) tryexceptfinallyelseifelifwithforwhileFcFg}|j}|dkrD|}|dur+|jjdkr|dkr||n|dkr4|||jD]}|t |dz }n|dkr7|jd d kr%|jd }|d kr|t |z }nV |j}|jt vr|s|||D]}|t ||z }n#t$rYnwxYw|S) z For static analysis. nameFparam= expr_stmtT) last_added decorator)()type get_next_leafparentappendchildrenget_executable_nodes_EXECUTE_NODESAttributeError)noder+resulttyp next_leafchildr5s ?C:\PYTHON\_runtimes\venv\Lib\site-packages\jedi/parser_utils.pyr6r6sF )C f}}&&((   4;#3w#>#>9PSCSCS MM$       d] C CE *5TBBB BFF C   =  # #=$Ds{{.t444 B}HyN**:* d###! B B.ujAAA B     D  Ms D DDc#K|V|jd} |jdkr|jdVn|jdkr|Vn |jdksdS|jd}F)NTcomp_for sync_comp_forcomp_ifr5r1)rAlasts r>get_sync_comp_forsrG:s NNN  R D! 9 " "-" " " " " Y/ ) )JJJJi'' E}R !c.|jdjdkS)z Returns True if only one name is returned: ``for x in y``. Returns False if the for loop is more complicated: ``for x, z in y``. :returns: bool rBr'rE)for_stmts r>for_stmt_defines_one_namerKGs  Q  $ ..rHc|j}|j|cxkr |jksntdd}t|jD]3\}}||jkr|cS|}|t vr|}4dS)Nz!The node is not part of the flow.) start_posend_pos ValueError enumerater5get_first_leaf_FLOW_KEYWORDS) flow_noder9rMkeywordir= first_leafs r>get_flow_branch_keywordrWQsI  ) @ @ @ @y/@ @ @ @ @<===Gi011!!5 u & &NNN))++  ' ' G 4rHct|}|!tt|jSdS)z3 Returns a cleaned version of the docstring token. N) get_doc_nodersafe_literal_evalvalue) scope_noder9s r>clean_scope_docstringr^`s9  " " $ $D  )$*55666 2rHc|jdkra|j}|}|D|jdkr9|jd}|jdkr!t t |jSdS)Nr* simple_stmtrstringrY)r1r3get_next_siblingr5rr[r\) tree_node maybe_strings r>find_statement_documentationrelsv~$$$  1133  # M11+4Q7 $00#$5l6H$I$IJJJ 2rHc||dd}|ddks|dvrdSt|S)Nrf)frrfrY)lowerr)r\ first_twos r>r[r[xsGbqb !!I|si<77r   rHHc||jdkrd}n |jj}|}|r |dd}ddd|Dzdz}t jd d |}|jr|sd |j z}nd}||z|z}d tj ||S) z Generate a string signature of a function. :param width: Fold lines if a line is longer than this value. :type width: int :arg func_name: Override function name when given. :type func_name: str :rtype: str NlambdefzrBr0rYc3>K|]}|VdSN)get_code).0r(s r> z get_signature..s,;;5enn&&;;;;;;rHr.z\s+ z -> ) r1r'r\ get_paramsjoinstripresub annotationrrtextwrapwrap) rwidth call_stringomit_first_paramomit_return_annotationparamsprtypecodes r> get_signaturers <9 $ $$KK!,,K    ! !F bgg;;F;;;;;AACCCcIA vsAA"8*33555 ?U "D 99X]4// 0 00rHc |j}|D]}t||dS#t$r|xj|z c_YdSwxYw)z$ Move the `Node` start_pos. N)r5mover8line)r9 line_offsetr5cs r>rrso!= ! !A K  ! ! !!! [ !s  >>c |jdkr%|jdj}n|jdkr%|jdj}nm|jdkr7|jdj}n+|j}n#t $rYdSt$rYdSwxYwd|vrdS||dd}d |vr|d|d }d |vr|d|d }|S) zl returns (as string) any comment that appears on the same line, after the node, including the # rJ with_stmtrN# rv) r1r5rQprefixr2 get_last_leafr8rOindex)r9 whitespacecomments r>get_following_comment_same_linersn  9 " "q)88::AJJ Y+ % %q)88::AJJ Y) # #q)88::HHJJQJJ++--;;==DJ tt tt *t))#..//0G w.7==.../ w.7==.../ NsC C C* C*)C*cP|j}|dkr|jdjdkS|dvS)NrArBrC) file_inputrrrorC)r1r5)r9ts r>is_scopers3 AJ}Q$77 Q QQrHc4tdfd }|S)NFc| ||S |}n#t$r ix}|<YnwxYw ||S#t$r||x}||<|cYSwxYwrq)KeyError)parso_cache_noder9 include_flows for_moduler:cachefuncs r>wrapperz(_get_parent_scope_cache..wrappers  #4m,, , 6/0JJ 6 6 635 5J/000 6 d# #   (,T=(A(A AFZ%MMM s..:AAFr)rrrs` @r>_get_parent_scope_cachers9   E        NrHcj}|dS t|r|jdvr|jd}|j|jjkrPjjdkrjjkrn/jjdkrjjdkrn|j}|S|rTt|tj r:|jdkr-tfd | Ds|S|j}) z' Returns the underlying scope. NT)rrro:r(tfpdefrif_stmtc3VK|]#}|jjcxko |jkncV$dSrq)rMrN)rsnr9s r>rtz#get_parent_scope..sY== !K4>EEEEAIEEEE======rH) r3rr1r5rrMr' isinstancerFlowanyget_test_nodes)r9rscopers` r>get_parent_scopers= KE }t E?? z???,,S11>%(2dnDD{'722t{7G47O7O)X55$+:Nq:QUY:Y:Y %  L  z%;; J)++====%*%9%9%;%;=====,  +rHc,t||jS)z Basically access the cached code lines in parso. This is not the nicest way to do this, but we avoid splitting all the lines again. )get_parso_cache_nodelinesgrammarpaths r>get_cached_code_linesrs  . . 44rHc2t|j|S)z This is of course not public. But as long as I control parso, this shouldn't be a problem. ~ Dave The reason for this is mostly caching. This is obviously also a sign of a broken caching architecture. )r_hashedrs r>rrs  ( ..rHct|jdd|d|jz dz}|d}|j|dkr ||jz}|sdS|dd||d<d|S)z3 Cuts of the value of the leaf at position T)keependsNrrBrYr@)r r\rcolumnrx)leafpositionrrs r>cut_value_at_positionr"s  T 2 2 23OHQK$)4Ka4O3O PE a[F yHQK$+ rb '6'"E"I 775>>rHch|jdkrEt|jdkr+|jddkrt|jdSdS|jdkrM|j}|ddkrdSt|dsdSt d |dd DS|jd kS) zP Checks if a path looks like `name` or `name.foo.bar` and not `name()`. r rrr0rBFrawaitc38K|]}|jddkVdS)r.N)r5)rsrs r>rtz!expr_is_dotted..?s->>A1:a=C'>>>>>>rHNr')r1lenr5expr_is_dottedall)r9r5s r>rr0s yF t}   " "t}Q'73'>'>!$-"233 3u yK= A;' ! !5hqk** 5>>!"">>>>>> 9 rHcfd}|S)Nc|D]/}|jd}|rdS0dS)z This is a heuristic. It will not hold ALL the times, but it will be correct pretty much for anyone that doesn't try to beat it. staticmethod/classmethod are builtins and unless overwritten, this will be correct. rBTF)get_decoratorsr5rr) function_noder, dotted_namedecorator_checkers r>rz&_function_is_x_method..wrapperDs]'5577  I#,Q/K  !5!5!7!788 tt urH)rrs` r>_function_is_x_methodrCs#      NrHc|dkS)N staticmethodrms r>rSs 1;NrHc|dkS)N classmethodrrs r>rrTs !}:LrHcD|dkp|dkp|dS)Npropertycached_propertyz.setter)endswithrs r>rrVs/a:o  9rHr)rmNFF)&rzr}astrinspectrweakrefr parso.pythonr parso.cacherparsor r7rRr6rGrKrWr^rer[rrrrrrget_cached_parent_scoperrrrrfunction_is_staticmethodfunction_is_classmethodfunction_is_propertyrrHr>rs, %%%%%%$$$$$$BBB  """"J ! ! !///         26AF1111B ! ! !>RRR(@212BCC555///   &    101N1NOO//0L0LMM,,rH