
    Je/~                     r   d Z ddlZddlZddlmZ ddl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mZmZ ddlmZ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  ddl!m"Z"  ejF                  e$      Z%i ejL                   ed      ejN                   ed      ejP                   ed      ejR                   ed      ejT                   ed      ejV                   ed      ejX                   ed      ejZ                   ed      ej\                   ed      ej^                   ed      ej`                   ed      ejb                   ed      ejd                   ed      ejf                   ed      ejh                   ed      ejj                   ed      ejl                   ed      ejn                   ed      ejp                   ed       ejr                   ed!      ejt                   ed"      ejv                   ed#      ejx                   ed$      ejz                   ed%      ej|                   ed&      ej~                   ed'      ej                   ed(      ej                   ed)      iZB G d* d+      ZC G d, d-e      ZD G d. d/eD      ZE G d0 d1eD      ZF G d2 d3e"      ZGy)4zOutline explorer widgets.    N)IntervalTree)parse)PYSIDE2PYSIDE_VERSION)QtQTimerSignalSlot)QTreeWidgetItemQTreeWidgetItemIterator)on_conf_change)_)ima)
SymbolKindSYMBOL_KIND_ICON)set_item_user_text)OneColumnTreeFileModule	NamespacePackageClassMethodProperty	AttributeconstructorEnum	InterfaceFunctionVariableConstantStringNumberBooleanArrayObjectKeyNullzEnum memberStructEventOperatorzType parameterCellzBlock commentc                   V    e Zd ZddZd Zd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zy)SymbolStatusNc                     || _         || _        || _        || _        || _        t        t        j                               | _        d | _	        g | _
        d| _        d| _        d | _        y NF)namepositionkindnodepathstruuiduuid4idindexchildrenstatusselectedparent)selfr1   r3   r2   r5   r4   s         H/usr/lib/python3/dist-packages/spyder/plugins/outlineexplorer/widgets.py__init__zSymbolStatus.__init__H   sZ    	 			djjl#
    c                    | j                   D ]	  }d |_         g | _         | j                  j                          | j                  "| j                  j	                  |        d | _        | j                  j                  Qt        | j                  j                  d      r0| j                  j                  j                  | j                         y y y )Nremove_children)r;   r>   r4   takeChildrenremove_nodehasattrrD   )r?   childs     r@   deletezSymbolStatus.deleteU   s    ]] 	 EEL	  		 ;;"KK##D)DK II(		((*;<II,,TYY7 = )rB   c                    |j                   | j                   k(  r| j                  j                  |       y | |_        | j                  |_        | j                  }| j
                  D cg c]  }|j                   d    }}|j                   d   }t        j                  ||      }||_        | j
                  |d  D ]  }|xj                  dz  c_         |j                  ||j                         | j
                  j                  ||       t        | j
                  | j
                  dd        D ]   \  }}	|j                  |	j                  k  r J  y c c}w Nr      )r2   r>   add_noder5   r4   r;   bisectbisect_leftr:   append_childreninsertzip)
r?   r4   	this_nodecchildren_ranges
node_range	new_indexrH   idxnext_idxs
             r@   rM   zSymbolStatus.add_nodef   s   ==DMM)KK  &DK		DI		I6:mmDqzz!}DODq)J**?JGI"DJyz2 !q !%%i;MM  D1!$T]]DMM!"4E!F 2Xyy8>>1112 Es   (Ec                 F   | j                   |j                  dz   d  D ]  }|xj                  dz  c_         | j                   j                  |j                         t        | j                   | j                   dd        D ]   \  }}|j                  |j                  k  r J  y )NrL   )r;   r:   poprR   )r?   r4   rH   rX   rY   s        r@   rF   zSymbolStatus.remove_nodey   s    ]]4::>?3 	EKK1K	$**% ab0AB 	.MC99x~~---	.rB   c                 z   |j                   | _         |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _        | j                  j                  | j                  | j                  | j                  d   dz   | j                  | j
                         | | j                  _        | j                  D ]	  }| |_         | j                  '| j                  j                  | j                  |        y y rK   )r9   r:   r5   r;   r<   r=   r4   r>   update_infor1   r3   r2   refreplace_node)r?   r4   rH   s      r@   
clone_nodezSymbolStatus.clone_node   s    ''ZZ
II	kkII	kk		diiDMM!4Dq4H"kk4==	:		]] 	 EEL	  ;;"KK$$TZZ6 #rB   c                     | j                   j                  | j                  | j                  | j                  d   dz   | j
                  | j                         y rK   )r4   r]   r1   r3   r2   r<   r=   r?   s    r@   refreshzSymbolStatus.refresh   s=    		diiDMM!4Dq4H"kk4==	:rB   c                 "    || j                   |<   y N)r;   r?   r:   r4   s      r@   r_   zSymbolStatus.replace_node   s    #erB   c           	          t        d | | j                  | j                  | j                  d   dz   | j                  | j
                        | _        y rK   )
SymbolItemr1   r3   r2   r<   r=   r4   rb   s    r@   create_nodezSymbolStatus.create_node   s<    tT499dii#}}Q/!3T[[#}}.	rB   c                      || _         || _        y re   )r1   r5   )r?   new_paths     r@   set_pathzSymbolStatus.set_path   s    		rB   c                     t        |       S re   )r6   rb   s    r@   __repr__zSymbolStatus.__repr__   s    4yrB   c                 z    dj                  | j                  | j                  | j                  | j                        S )Nz({0}, {1}, {2}, {3}))formatr2   r1   r9   r<   rb   s    r@   __str__zSymbolStatus.__str__   s.    %,,MM499dggt{{< 	<rB   c                     | j                   |j                   k(  xr4 | j                  |j                  k(  xr | j                  |j                  k(  S re   )r1   r3   r2   )r?   others     r@   __eq__zSymbolStatus.__eq__   sA    II# 0		UZZ'0/	
rB   re   )__name__
__module____qualname__rA   rI   rM   rF   r`   rc   r_   ri   rl   rn   rq   rt    rB   r@   r.   r.   G   s>    8"2&.7&:$.
<
rB   r.   c                       e Zd Zd Zd Zd Zy)BaseTreeItemc                 $    | j                          y re   )rE   rb   s    r@   clearzBaseTreeItem.clear   s    rB   c                 6    | j                  ||       | |_        y re   )insertChildr>   rf   s      r@   rP   zBaseTreeItem.append_children   s    %rB   c                 4    | j                  |       d |_        y re   )removeChildr>   )r?   r4   s     r@   rD   zBaseTreeItem.remove_children   s    rB   N)ru   rv   rw   r|   rP   rD   rx   rB   r@   rz   rz      s    rB   rz   c                        e Zd ZddZd Zd Zy)FileRootItemc                    t        j                  | |t         j                         || _        || _        | j                  d|rt        j                  d      nt        j                  d             | j                  d|       t        | |       y )Nr   pythonTextFileIcon)
r   rA   Typer5   r^   setIconr   icon
setToolTipr   )r?   r5   r^   
treewidget	is_pythons        r@   rA   zFileRootItem.__init__   sh      z?3G3GH	Ysxx!CHH^4L	N4 4&rB   c                 4    || _         | j                  |       y re   )r5   set_text)r?   r5   fullpaths      r@   rl   zFileRootItem.set_path   s    	hrB   c                     | j                  d|r| j                         y t        j                  | j                               y Nr   )setTextr5   ospbasename)r?   r   s     r@   r   zFileRootItem.set_text   s(    QX		K3<<		3JKrB   N)T)ru   rv   rw   rA   rl   r   rx   rB   r@   r   r      s    ' LrB   r   c                       e Zd ZdZd Zd Zy)rh   zGeneric symbol tree item.c                     t        j                  | |t         j                         || _        || _        d| _        | j                  |||||       y r   )r   rA   r   r>   r^   num_childrenr]   )r?   r>   r^   r1   r3   r2   r<   r=   s           r@   rA   zSymbolItem.__init__   sF      v/C/CDtXvx@rB   c                    | j                  dt        j                  t        j                  |d                   t
        j	                  |d      }|j                  dd      j                         }| j                  ddj                  |||t        d                   t        | |       | j                  d|       | j                  |       | j                  |       y )Nr   no_match r    z{3} {2}: {0} {1}Line)r   r   r   r   getSYMBOL_NAME_MAPreplace
capitalizer   rp   r   r   r   setExpandedsetSelected)r?   r1   r3   r2   r<   r=   
identifiers          r@   r]   zSymbolItem.update_info   s    Q!1!5!5dJ!GHI$((r2
''S1<<>
-44h&	3 	44&Q "rB   N)ru   rv   rw   __doc__rA   r]   rx   rB   r@   rh   rh      s    #A	#rB   rh   c                   X    e Zd Z e       Z e       Z e       Z e       ZdZ fdZ	e
d        Zej                  d        Zd Z ed      d        Z ed	      d
        Z ed      d        Z ed      d        Z ed      d        Z ed      d        Z ed      d        Z e       d        Z e       d        Zd Zd Zd Zd Zd Zd Zd Zd2dZ  ee!      d3d       Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd% Z(d& Z)d' Z*d( Z+d) Z,d* Z-d+ Z.d, Z/d- Z0d2d.Z1d/ Z2d0 Z3d1 Z4 xZ5S )4OutlineExplorerTreeWidgetoutline_explorerc                 
   t        |d      r|j                  | _        | j                  d      | _        | j                  d      | _        | j                  d      | _        | j                  d      | _        | j                  d      | _        | j                  d      | _        | j                  d      | _	        t        | -  |       d	| _        i | _        i | _        i | _        i | _        i | _        i | _        g | _        d | _        g | _        d	| _        | j.                  j1                  | j2                         | j4                  j1                  | j6                         | j8                  j1                  | j:                         y )
NCONTEXT_NAMEshow_fullpathshow_all_filesgroup_cellsshow_commentssort_files_alphabeticallyfollow_cursordisplay_variablesF)rG   r   get_confr   r   r   r   r   r   r   superrA   freezeeditor_itemseditor_tree_cache
editor_idsupdate_timersstartingeditors_to_updateordered_editor_ids_current_editor
_languages
is_visiblecurrentItemChangedconnectselection_switcheditemExpandedtree_item_expandeditemCollapsedtree_item_collapsed)r?   r>   	__class__s     r@   rA   z"OutlineExplorerTreeWidget.__init__   sE   6>* & 3 3D!]]?;"mm,<===7!]]?;)-'*)&!]]?;!%/B!C !#!#"$#''(?(?@!!$"9"9:""4#;#;<rB   c                     | j                   S )zGet current editor.)r   rb   s    r@   current_editorz(OutlineExplorerTreeWidget.current_editor  s     ###rB   c                 v    | j                   |k(  ry| j                  d       || _         | j                  d       y)z5Set current editor and connect the necessary signals.NFT)r   connect_current_editor)r?   values     r@   r   z(OutlineExplorerTreeWidget.current_editor  s9     5(##E*$##D)rB   c                 r    | j                         D ]$  }|j                  ||uxr | j                          & y)z
        show_all_files option is disabled: hide all root items except *item*
        show_all_files option is enabled: do nothing
        N)get_top_level_items	setHiddenr   )r?   item_its      r@   __hide_or_show_root_itemsz3OutlineExplorerTreeWidget.__hide_or_show_root_items$  s<    
 ++- 	GCMM#T/E$2E2E.EF	GrB   r   )optionc                    || _         | j                  |rt        j                  nt        j                         t        | j                               D ]-  }| j                  |      j                  | j                          / y )Nr   )	r   setTextElideModer   ElideMiddle
ElideRightrangetopLevelItemCounttopLevelItemr   )r?   stater:   s      r@   toggle_fullpath_modez.OutlineExplorerTreeWidget.toggle_fullpath_mode,  se    "bnn2==I41134 	KEe$--t7I7I-J	KrB   r   c                 T   || _         | j                  }|| j                  |   }| j                  |   j                  }| j                  |       | j                          | j                   du r+| j                  | j                  | j                  |             | j                          y y r0   )	r   r   r   r   r4   3_OutlineExplorerTreeWidget__hide_or_show_root_items/_OutlineExplorerTreeWidget__sort_toplevel_itemsroot_item_selecteddo_follow_cursor)r?   r   r   	editor_idr   s        r@   toggle_show_all_filesz/OutlineExplorerTreeWidget.toggle_show_all_files3  s    #,,%7I$$Y/44D**40&&(""e+''%%doon&EFH!!# &rB   r   c                 j    || _         | j                  j                          | j                  d       y Nr   )language)r   sig_update_configurationemitupdate_editorsr?   r   s     r@   toggle_show_commentsz.OutlineExplorerTreeWidget.toggle_show_commentsA  s-    "%%**,X.rB   r   c                 j    || _         | j                  j                          | j                  d       y r   )r   r   r   r   r   s     r@   toggle_group_cellsz,OutlineExplorerTreeWidget.toggle_group_cellsG  s-     %%**,X.rB   r   c                     || _         | j                  j                         D ]  }| j                  |j                  |         y re   )r   r   keysupdate_editorinfo)r?   r   editors      r@   toggle_variablesz*OutlineExplorerTreeWidget.toggle_variablesM  s:    !&oo**, 	4Fv{{F3	4rB   r   c                 2    || _         | j                          y re   )r   r   r   s     r@    toggle_sort_files_alphabeticallyz:OutlineExplorerTreeWidget.toggle_sort_files_alphabeticallyS  s    ).&""$rB   r   c                 2    || _         | j                          y)zFollow the cursor.N)r   r   r   s     r@   toggle_follow_cursorz.OutlineExplorerTreeWidget.toggle_follow_cursorX  s     #rB   c                 >    | j                   r| j                          yy)zGo to cursor position.N)r   go_to_cursor_positionrb   s    r@   r   z*OutlineExplorerTreeWidget.do_follow_cursor^  s     &&( rB   c                    | j                   | j                  | j                      }| j                   j                         }| j                  |   }| j                  |   }||dz
     }t        |      dk(  r@|j                  }| j                  |       | j                  |       | j                  |       y t        |      }d}| j                  ||       y y )NrL   r   )r   r   get_cursor_line_numberr   r   lenr4   setCurrentItemscrollToItem
expandItemsortedswitch_to_node)	r?   r   linetreerootoverlapr   sorted_nodesrX   s	            r@   r   z/OutlineExplorerTreeWidget.go_to_cursor_positiond  s    *(;(;<I&&==?D)))4D$$Y/D4!8nG7|q yy##D)!!$'%%g ##L#6# +rB   c                     ||   }|j                   }|j                  }| j                  |       | j                  |       | j	                  |       y)z=Given a set of tree nodes, highlight the node on index `idx`.N)datar4   r   r   r   )r?   r  rX   item_intervalitem_refr   s         r@   r   z(OutlineExplorerTreeWidget.switch_to_nodey  sH    $S) %%}}D!$rB   c                    | j                   }|y|j                  }|j                  }|j                  }|rb|j	                  | j
                         |j	                  | j                         |j	                  | j                         | j                          y	 |j                  | j
                         |j                  | j                         |j                  | j                         y# t        $ r Y yw xY w)z.Connect or disconnect the editor from signals.N)
r   !sig_outline_explorer_data_changedsig_cursor_position_changedsig_start_outline_spinnerr   r   r   sig_display_spinner
disconnect	TypeError)r?   r   r   
sig_updatesig_mover  s         r@   r   z0OutlineExplorerTreeWidget.connect_current_editor  s    $$> ==
55$>>t112T223''(@(@A!!#%%d&8&89##D$9$9:#..t/G/GH  s   AC+ +	C76C7c                 P    | j                  d       t        j                  |        y)zReimplemented Qt methodr   N)	set_titler   r|   rb   s    r@   r|   zOutlineExplorerTreeWidget.clear  s    rD!rB   c                     |j                         }	 | j                  |   j                  }| j                  s3| j                  |       | j                  |       | j                  |       t        j                  d|j                          || _        | j                  ra|j                         j                         | j                  v r6|j                   s)|j"                  | j%                  |j"                         yyyyy# t        $ r Y yw xY w)zBind editor instanceNzSet current editor to file )get_idr   r4   KeyErrorr   r   r   r   loggerdebugfnamer   r   get_languagelowerr   is_tree_updatedr   r   )r?   r   updater   r   s        r@   set_current_editorz,OutlineExplorerTreeWidget.set_current_editor  s    MMO		$$Y/44D {{d###D)**4026<<.AB$ OO$$&,,.$//A**{{&""6;;/ ' + B   		s   D 	DDc                    |j                         }|| j                  |<   | j                  j                  |       t	        |j
                  dd|j
                        }|| j                  |<   t        |j
                  || |j                               }||_	        |j                  | j                         | j                  d       | j                  s|j                  d       t               }|| j                   |<   | j#                          y)z_
        Register editor attributes and create basic objects associated
        to it.
        Nr   r   T)r  r   r   appendr.   r  r   r   r   r4   r   r   resizeColumnToContentsr   r   r   r   r   )r?   r   r   	this_root	root_itemeditor_trees         r@   register_editorz)OutlineExplorerTreeWidget.register_editor  s    
 MMO	"+&&y1 tT6<<H	'0)$ y!%v'7'7'9;	"	D$6$67##A&""%"n,7y)""$rB   c                 h   |y|j                         }|t        | j                  j                               v rz| j                  |   }|j                  |       |j                  }|j                  || j                         |j                          |j                          | j                          yy)z0File was renamed, updating outline explorer treeNr   )r  listr   valuesr   rl   r4   r   rI   request_symbolsr   )r?   r   new_filenamer   itemsr$  s         r@   file_renamedz&OutlineExplorerTreeWidget.file_renamed  s    > MMO	T__33566%%i0E NN<( 

I|d6H6HI LLN""$ &&(! 7rB   c                    | j                   j                  |      rw| j                   |   d   }|j                  ;	 | j                  |j                  |       | j                   |   j                  |       | j                  |   j                          y| j                  j                  |      r%t        j                  d       d| j                  |<   yy# t        $ r Y w xY w)z
        Update all editors for a given language sequentially.

        This is done through a timer to avoid lags in the interface.
        r   Nz Finish updating files at startupF)r   r   r   r   r  remover   startr   r  r  r?   r   r   s      r@   r   z(OutlineExplorerTreeWidget.update_editors  s     !!%%h/++H5a8F{{&&&v{{F; &&x077?x(..0}}  *?@*/h' +   s   C 	C C c                     | j                   D ]2  }| j                  ||       | j                  |   j                          4 y)z$Update all editors with LSP support.)
reset_infoN)r   set_editors_to_updater   r0  )r?   r3  r   s      r@   update_all_editorsz,OutlineExplorerTreeWidget.update_all_editors  s?     	1H&&xJ&Gx(..0	1rB   c                 D   |y|| j                   }| j                  s>t        j                  d|j                   d       | j
                  j                          y| j                  ||      }|r1| j                          | j                          | j                          yy)z]
        Update the outline explorer for `editor` preserving the tree
        state.
        NzDon't update tree of file z because plugin is not visible)r   r   r  r  r  sig_hide_spinnerr   update_treesave_expanded_staterestore_expanded_stater   )r?   r,  r   r  s       r@   r   z'OutlineExplorerTreeWidget.update_editor  s     =>((F LL,V\\N ;  !!&&(!!%0$$&'')!!# rB   c                    d}|j                   \  }}|j                  4|s2|j                   \  }}||k  r|j                  }nd}|j                  |s2|j                  g|j                  j                  |       d|_        |j                  j                  /|j                  j                  j	                  |j                         |j                  |       |j                          |S )z)Add node into an existing tree structure.FNT)r2   r>   rF   r4   rD   rM   rc   )r?   r>   r4   matchr0  endparent_start
parent_ends           r@   merge_intervalz(OutlineExplorerTreeWidget.merge_interval'  s    ]]
smm''-$L*U" mm' ;;"KK##D)DKyy+		  00;rB   c                    |j                         }|j                         }| j                  |   }| j                  |   }g }|D ]  }|d   }	|d   }
|j	                         dk(  rT|
t
        j                  k(  r4|
t
        j                  k(  r| j                  sT|
t
        j                  k(  r| j                  st|d   d   }|d   d   }|d   d   }t        |	|
||fd	      }|j                  ||d
z   |f        t        j                  |      }|j                  j                         dk(  xr t!        |      dkD  }|sJ||k(  rEt"        j%                  d|j&                   d       d|_        | j*                  j-                          yt"        j%                  d|j&                          t/        |      D ]  }|j0                  j3                           | j                  |   j5                          t        |      }|j7                  | j8                  |       || j                  |<   d|_        | j:                  j-                          | j*                  j-                          y)z2Update tree with new items that come from the LSP.r1   r3   r   locationr   r0  r  r=  NrL   r   zCurrent and new trees for file z( are the same, so no update is necessaryTFzUpdating tree for file )data_reducerdata_initializer)r  r  r   r   r  r   MODULEVARIABLEr   FIELDr.   r!  r   from_tuplesr4   
childCountr   r  r  r  r  r7  r   r   r  ri   rI   merge_overlapsr@  sig_tree_updated)r?   r,  r   r   r   current_treer  	tree_infosymbolsymbol_namesymbol_kindsymbol_rangesymbol_start
symbol_endsymbol_reprr  must_updateentry	tree_copys                      r@   r8  z%OutlineExplorerTreeWidget.update_tree<  sd   MMO	&&(--i8  +	  	JF .K .K~~8+*"3"33:#6#66 22:#3#33 22 "*-g6L'08L%e,V4J&{K(4j'A4IKlJNKHI'	J* ''	2 ii**,1Kc,6G!6K |#5fll^ D6 7 *.&%%**,.v||n=> D\ 	%EJJ""$	% 	)$++- !&	  ,,! 	! 	
 -1y)!%""$""$rB   c                    || j                   v r^| j                  |u rd | _        t        j                  d|j                          | j                   j                  |      }|j                         j                         }|| j                  v r| j                  j                  |       || j                  v r/|| j                  |   v r| j                  |   j                  |       |t        | j                   j                               vrb| j                  j                  |      }| j                  j                  |       	 | j!                  | j#                  |j$                               y y y # t&        $ r Y y w xY w)NzRemoving tree of file )r   r   r  r  r  r[   r  r  r   r/  r   r   r(  r)  r   r   takeTopLevelItemindexOfTopLevelItemr4   RuntimeError)r?   r   r   r   r$  s        r@   remove_editorz'OutlineExplorerTreeWidget.remove_editor  sK   T__$""f,&*#LL1&,,@A++F3I**,224HD333''..y9
 DOO+d44X>>&&x077?T__%;%;%= >> --11)<	&&**95))00@B	 ?) %4 $ s   *E/ /	E;:E;c                 p    | j                   |k7  r'|| _         | j                  du r| j                          yyy)zv
        Order the root file items in the Outline Explorer following the
        provided list of editor ids.
        FN)r   r   r   )r?   r   s     r@   set_editor_ids_orderz.OutlineExplorerTreeWidget.set_editor_ids_order  s?    
 ""&88&8D#--6**, 7 9rB   c                    | j                   du ryt        | j                               D cg c]  }| j                  |       }}|D ci c]  }|j                  j                         | }}| j                  rt        |j                         d       }nW| j                  D cg c]B  }| j                  j                  |      %| j                  j                  |      j                  D }}t        xr t        t              t        d      k  xs ||k7  }|r| j!                         }| j#                          t        | j                               D ]  }| j%                  d        t'        |      D ]  \  }}| j)                  ||        | j+                          | j-                          |r|d   j/                  d       yyyc c}w c c}w c c}w )	z
        Sort the root file items in alphabetical order if
        'sort_files_alphabetically' is True, else order the items as
        specified in the 'self.ordered_editor_ids' list.
        FNc                 \    t        j                  | j                  j                               S re   )r   r   r5   r  )r   s    r@   <lambda>zAOutlineExplorerTreeWidget.__sort_toplevel_items.<locals>.<lambda>  s    diioo.?!@ rB   )keyz5.15.0r   r   T)r   r   r   r   r5   r  r   r   r)  r   r   r   r4   r   r   r   selectedItemsr9  rY  	enumerateinsertTopLevelItemr:  clearSelectionr   )	r?   r:   current_ordered_itemsr   current_ordered_items_dictnew_ordered_itemse_idr  selected_itemss	            r@   __sort_toplevel_itemsz/OutlineExplorerTreeWidget.__sort_toplevel_items  s    %' "'t'='='?!@!Be!2!25!9 !B !B 1F&G(,DIIOOt#&G" &G )) &*113@!B ''!959!!%%d+7 !!%%d+00!9 !9 A~.%/A <%):: 	 !//1N$$&t5578 )%%a()():; 5t''t45'')!r"..t4  9!B&G!9s   G	"G$AGc                     | j                   ry| j                         D ])  }||u r| j                  |       | j                  |       + y)z?Root item has been selected: expanding it and collapsing othersN)r   r   r   collapseItemr?   r   r$  s      r@   r   z,OutlineExplorerTreeWidget.root_item_selected  sH    113 	-ID 	*!!),		-rB   c                     | j                   R| j                          | j                  | j                      }| j                  | j                  |   j
                         yy)z"Reimplemented OneColumnTree methodN)r   collapseAllr   r   r   r4   )r?   r   s     r@   restorez!OutlineExplorerTreeWidget.restore  sR    *(;(;<I##D$5$5i$@$E$EF +rB   c                     |}t        |j                         t              r/|j                         }t        |j                         t              r/|S )z+Return the root item of the specified item.)
isinstancer>   r   ro  s      r@   get_root_itemz'OutlineExplorerTreeWidget.get_root_item  sC    	))+_=!((*I ))+_=rB   c                 N   g }t        |       }|j                         r|j                         }|j                         sQ|j                         r0|j                         j	                         r#|j                  |       n|j                  |       |dz  }|j                         r|S )z5Return a list of all visible items in the treewidget.rL   )r   r   isHiddenr>   
isExpandedr!  )r?   r,  iteratorr   s       r@   get_visible_itemsz+OutlineExplorerTreeWidget.get_visible_items  s    *40nn>>#D==?;;={{}//1T*LL&MH nn rB   c                 ,   | j                   j                  | j                  j                  | j                              }|j                  }d}t        |t              rd}t        |      t        |      k7  r5|}n2|j                  j                  d   dz   }|j                  j                  }|j                  j                  }d| _        |r,| j                         j                  j                  |||       n)| j                         j                   j                  |       d| _        t#        | j                   j%                               D ]I  \  }}|j                  |k(  r4t#        | j                  j%                               D ]  \  }	}
|	| _          y  y y)zDouble-click eventr   Nr   rL   TF)r   r   r   r   r4   rt  r   r9   r^   r2   r1   r5   r   r>   	edit_gotor   editr(  r,  )r?   r   editor_rootr$  textr  r5   r   i_itemr   _ids              r@   	activatedz#OutlineExplorerTreeWidget.activated  sL   ''++OO 3 346$$	dL)D)}4( 	88$$Q'!+D88==Dxx}}KKM##((tT:KKM##D)!%d&7&7&=&=&?!@ 	Iv{{d"#'(=(=(?#@ KFC*0D' 	rB   c                 h    t        |t              r| j                  |       | j                  |       y)zClick eventN)rt  r   r   r  )r?   r   s     r@   clickedz!OutlineExplorerTreeWidget.clicked#  s&    dL)##D)trB   c                 Z    ||j                   }d|_        ||j                   }d|_        y y )NTF)r^   r=   )r?   current_itemprevious_itemcurrent_refprevious_refs        r@   r   z,OutlineExplorerTreeWidget.selection_switched)  s9    #&**K#'K $(,,L$)L! %rB   c                 *    |j                   }d|_        y r0   r^   r<   r?   r   r^   s      r@   r   z-OutlineExplorerTreeWidget.tree_item_collapsed1  s    hh
rB   c                 *    |j                   }d|_        y )NTr  r  s      r@   r   z,OutlineExplorerTreeWidget.tree_item_expanded5  s    hh
rB   c                     g }| j                   j                         D ]?  }|j                         j                         |k(  s%|j	                  |       |s9d|_        A || j                  |<   y)z#Set editors to update per language.N)r   r   r  r  r!  r   r   )r?   r   r3  	to_updater   s        r@   r4  z/OutlineExplorerTreeWidget.set_editors_to_update9  sg    	oo**, 	'F""$**,8  ("&FK		'
 ,5x(rB   c                     t         j                  d         j                  j                         t	               }|j                  d       |j                  d       |j                  j                   fd       | j                  <   d j                  <    j                         |j                          y)z&Show symbols for all `language` files.z#Start symbol services for language T   c                  &    j                         S re   )r   )r   r?   s   r@   ra  zAOutlineExplorerTreeWidget.start_symbol_services.<locals>.<lambda>P  s    d&9&9(&C rB   N)r  r  r   r!  r   setSingleShotsetIntervaltimeoutr   r   r   r4  r0  )r?   r   timers   `` r@   start_symbol_servicesz/OutlineExplorerTreeWidget.start_symbol_servicesC  s    :8*EF 	x(
 tD!#CD',8$"&h 	""8, 	rB   c                    t         j                  d|        	 | j                  j                  |       | j
                  j                         D ]+  }|j                         j                         |k(  s%d|_	        - y# t        $ r Y Tw xY w)z"Disable LSP symbols functionality.z"Stop symbol services for language N)
r  r  r   r/  
ValueErrorr   r   r  r  r   r1  s      r@   stop_symbol_servicesz.OutlineExplorerTreeWidget.stop_symbol_servicesZ  s    9(DE	OO""8, oo**, 	#F""$**,8"	#  		s   A> >	B
	B
c                 V   || _         |r| j                  D ]  }| j                  |   r| j                  j	                         D ]a  }|j                         j                         |k(  s%|j                  r2|| j                  |   vsD| j                  |   j                  |       c | j                  |   st        j                  d| d       | j                  |        | j                  }|r7|j                  r*|j                  s| j                  |j                  |       yyyyy)z7Actions to take when the widget visibility has changed.zUpdating outdated trees for z, files because the plugin has become visibleN)r   r   r   r   r   r  r  r  r   r!  r  r  r   r   r   r   )r?   r   r   r   ces        r@   change_visibilityz+OutlineExplorerTreeWidget.change_visibilityf  s   $ OO 6 }}X."&//"6"6"8 L"//1779XE$*$:$: &d.D.DX.N N 228<CCFKL --h7:8* ED E ++H5'6, $$Bbggb&8&8""277B/ '9gr3 rB   )Fre   )6ru   rv   rw   r	   rK  r  r7  r   CONF_SECTIONrA   propertyr   setterr   r   r   r   r   r   r   r   r   r
   r   r   r   r   r|   r  r&  r-  r   r5  r(  r   r@  r8  r\  r^  r   r   rr  ru  rz  r  r  r   r   r   r4  r  r  r  __classcell__)r   s   @r@   r   r      s   x (x%x%L=B $ $ * *G ?+K ,K +,$ -$ ?+/ ,/
 =)/ */
 ./4 04
 67% 8% ?+  , 
 
V) )
 
V7 7(2"
06%2)60,1 
$Z$ $6*GR>-/5b-G:*5.
#0rB   r   )Hr   rN   loggingos.pathr5   r   r7   intervaltreer   packaging.versionr   qtpyr   r   qtpy.QtCorer   r   r	   r
   qtpy.QtWidgetsr   r   spyder.api.config.decoratorsr   spyder.config.baser   spyder.utils.icon_managerr   spyder.plugins.completion.apir   r   spyder.utils.qthelpersr   spyder.widgets.onecolumntreer   	getLoggerru   r  FILErE  	NAMESPACEPACKAGECLASSMETHODPROPERTYrG  CONSTRUCTORENUM	INTERFACEFUNCTIONrF  CONSTANTSTRINGNUMBERBOOLEANARRAYOBJECTKEYNULLENUM_MEMBERSTRUCTEVENTOPERATORTYPE_PARAMETERCELLBLOCK_COMMENTr   r.   rz   r   rh   r   rx   rB   r@   <module>r     s         & # ( 0 0 C 8   ) F 5 6 
		8	$
OOQvYq{ !K. )	
 aj q{ : an Am, OOQvY !K. : : : q{  q{!" )#$ ajq{NNAeHOOQvYAm,q{aj:q!12OOQvYa09Dh
 h
Z
? 
L< L$# #.Z
0 Z
0rB   