
    G@d_~                        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j#        e$          Z%i ej&         ed          ej'         ed          ej(         ed          ej)         ed          ej*         ed          ej+         ed          ej,         ed          ej-         ed          ej.         ed          ej/         ed          ej0         ed          ej1         ed          ej2         ed          ej3         ed          ej4         ed          ej5         ed          ej6         ed          ej7         ed          ej8         ed           ej9         ed!          ej:         ed"          ej;         ed#          ej<         ed$          ej=         ed%          ej>         ed&          ej?         ed'          ej@         ed(          ejA         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"          ZGdS )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                   X    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dS )SymbolStatusNc                     || _         || _        || _        || _        || _        t          t          j                              | _        d | _	        g | _
        d| _        d| _        d | _        d S NF)namepositionkindnodepathstruuiduuid4idindexchildrenstatusselectedparent)selfr1   r3   r2   r5   r4   s         Flib/python3.11/site-packages/spyder/plugins/outlineexplorer/widgets.py__init__zSymbolStatus.__init__H   sa    	 			djll##
    c                 T   | j         D ]	}d |_        
g | _         | j                                         | j        !| j                            |            d | _        | j        j        @t          | j        j        d          r(| j        j                            | j                   d S d S d S )Nremove_children)r;   r>   r4   takeChildrenremove_nodehasattrrD   )r?   childs     r@   deletezSymbolStatus.deleteU   s    ] 	  	 EELL	   ;"K##D)))DK I(	(*;<< ) I,,TY77777 )(((rB   c                 *   |j         | j         k    r| j                            |           d S | |_        | j        |_        | j        }d | j        D             }|j         d         }t          j        ||          }||_        | j        |d          D ]}|xj        dz  c_        |	                    ||j                   | j        
                    ||           t          | j        | j        dd                    D ]\  }}|j        |j        k     sJ d S )Nc                 (    g | ]}|j         d          S )r   )r2   ).0cs     r@   
<listcomp>z)SymbolStatus.add_node.<locals>.<listcomp>n   s    DDDqz!}DDDrB   r      )r2   r>   add_noder5   r4   r;   bisectbisect_leftr:   append_childreninsertzip)	r?   r4   	this_nodechildren_ranges
node_range	new_indexrH   idxnext_idxs	            r@   rP   zSymbolStatus.add_nodef   s&   =DM))K  &&&&&DK	DI	IDDdmDDDOq)J*?JGGI"DJyzz2 ! !q %%i;;;M  D111!$T]DM!""4E!F!F 2 2Xy8>111112 2rB   c                    | j         |j        dz   d          D ]}|xj        dz  c_        | j                             |j                   t          | j         | j         dd                    D ]\  }}|j        |j        k     sJ d S )NrO   )r;   r:   poprU   )r?   r4   rH   rZ   r[   s        r@   rF   zSymbolStatus.remove_nodey   s    ]4:>??3 	 	EKK1KKK$*%%% abb0ABB 	. 	.MC9x~-----	. 	.rB   c                    |j         | _         |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _        | j                            | j	        | j
        | j        d         dz   | j        | j                   | | j        _        | j        D ]	}| |_        
| j        "| j                            | j        |            d S d S Nr   rO   )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    'Z
I	kI	k	diDM!4Dq4H"k4=	: 	: 	:	] 	  	 EELL;"K$$TZ66666 #"rB   c                     | j                             | j        | j        | j        d         dz   | j        | j                   d S r_   )r4   r`   r1   r3   r2   r<   r=   r?   s    r@   refreshzSymbolStatus.refresh   sE    	diDM!4Dq4H"k4=	: 	: 	: 	: 	:rB   c                     || j         |<   d S N)r;   r?   r:   r4   s      r@   rb   zSymbolStatus.replace_node   s    #erB   c           	      ~    t          d | | j        | j        | j        d         dz   | j        | j                  | _        d S r_   )
SymbolItemr1   r3   r2   r<   r=   r4   re   s    r@   create_nodezSymbolStatus.create_node   s;    tT49di#}Q/!3T[#}. .			rB   c                 "    || _         || _        d S rh   )r1   r5   )r?   new_paths     r@   set_pathzSymbolStatus.set_path   s    				rB   c                      t          |           S rh   )r6   re   s    r@   __repr__zSymbolStatus.__repr__   s    4yyrB   c                 Z    d                     | j        | j        | j        | j                  S )Nz({0}, {1}, {2}, {3}))formatr2   r1   r9   r<   re   s    r@   __str__zSymbolStatus.__str__   s+    %,,M49dgt{< < 	<rB   c                 b    | j         |j         k    o| j        |j        k    o| j        |j        k    S rh   )r1   r3   r2   )r?   others     r@   __eq__zSymbolStatus.__eq__   s5    I# 0	UZ'0/	
rB   rh   )__name__
__module____qualname__rA   rI   rP   rF   rc   rf   rb   rl   ro   rq   rt   rw    rB   r@   r.   r.   G   s           8 8 8"2 2 2&. . .7 7 7&: : :$ $ $. . .
    < < <
 
 
 
 
rB   r.   c                        e Zd Zd Zd Zd ZdS )BaseTreeItemc                 .    |                                   d S rh   )rE   re   s    r@   clearzBaseTreeItem.clear   s    rB   c                 @    |                      ||           | |_        d S rh   )insertChildr>   ri   s      r@   rS   zBaseTreeItem.append_children   s#    %%%rB   c                 >    |                      |           d |_        d S rh   )removeChildr>   )r?   r4   s     r@   rD   zBaseTreeItem.remove_children   s!    rB   N)rx   ry   rz   r   rS   rD   r{   rB   r@   r}   r}      sA                rB   r}   c                   "    e Zd ZddZd Zd ZdS )FileRootItemTc                 *   t          j        | |t           j                   || _        || _        |                     d|rt          j        d          nt          j        d                     |                     d|           t          | |           d S )Nr   pythonTextFileIcon)
r   rA   Typer5   ra   setIconr   icon
setToolTipr   )r?   r5   ra   
treewidget	is_pythons        r@   rA   zFileRootItem.__init__   s     z?3GHHH	YLsx!!!CH^4L4L	N 	N 	N4   4&&&&&rB   c                 >    || _         |                     |           d S rh   )r5   set_text)r?   r5   fullpaths      r@   ro   zFileRootItem.set_path   s!    	hrB   c                 r    |                      d|r| j        nt          j        | j                             d S Nr   )setTextr5   ospbasename)r?   r   s     r@   r   zFileRootItem.set_text   s3    QXJ		3<	3J3JKKKKKrB   N)T)rx   ry   rz   rA   ro   r   r{   rB   r@   r   r      sK        ' ' ' '     L L L L LrB   r   c                       e Zd ZdZd Zd ZdS )rk   zGeneric symbol tree item.c                     t          j        | |t           j                   || _        || _        d| _        |                     |||||           d S r   )r   rA   r   r>   ra   num_childrenr`   )r?   r>   ra   r1   r3   r2   r<   r=   s           r@   rA   zSymbolItem.__init__   sR     v/CDDDtXvx@@@@@rB   c                    |                      dt          j        t          j        |d                               t
                              |d          }|                    dd                                          }|                     dd	                    |||t          d                               t          | |           |                     d|           |                     |           |                     |           d S )Nr   no_match r    z{3} {2}: {0} {1}Line)r   r   r   r   getSYMBOL_NAME_MAPreplace
capitalizer   rs   r   r   r   setExpandedsetSelected)r?   r1   r3   r2   r<   r=   
identifiers          r@   r`   zSymbolItem.update_info   s    Q!1!5dJ!G!GHHIII$((r22
''S11<<>>
-44h&		3 3 	4 	4 	44&&&Q   """""rB   N)rx   ry   rz   __doc__rA   r`   r{   rB   r@   rk   rk      s;        ##A A A	# 	# 	# 	# 	#rB   rk   c                       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d4dZ  ee!          d5d!            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/ Z0d4d0Z1d1 Z2d2 Z3d3 Z4 xZ5S )6OutlineExplorerTreeWidgetoutline_explorerc                 B   t          |d          r|j        | _        |                     d          | _        |                     d          | _        |                     d          | _        |                     d          | _        |                     d          | _        |                     d          | _        |                     d          | _	        t                                          |           d	| _        i | _        i | _        i | _        i | _        i | _        i | _        g | _        d | _        g | _        d	| _        | j                            | j                   | j                            | j                   | j                            | j                   d S )
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__   sr   6>** 	4 & 3D!]]?;;"mm,<====77!]]?;;)-'*) *)&!]]?;;!%/B!C!C   !#!#"$#''(?@@@!!$"9:::""4#;<<<<<rB   c                     | j         S )zGet current editor.)r   re   s    r@   current_editorz(OutlineExplorerTreeWidget.current_editor  s     ##rB   c                     | j         |k    rdS |                     d           || _         |                     d           dS )z5Set current editor and connect the necessary signals.NFT)r   connect_current_editor)r?   values     r@   r   z(OutlineExplorerTreeWidget.current_editor  sM     5((F##E***$##D)))))rB   c                 r    |                                  D ]!}|                    ||uo| j                    "dS )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$  sQ    
 ++-- 	G 	GCMM#T/E$2E.EFFFF	G 	GrB   r   )optionc                    || _         |                     |rt          j        nt          j                   t          |                                           D ]0}|                     |                              | j                    1d S )Nr   )	r   setTextElideModer   ElideMiddle
ElideRightrangetopLevelItemCounttopLevelItemr   )r?   stater:   s      r@   toggle_fullpath_modez.OutlineExplorerTreeWidget.toggle_fullpath_mode,  s    "Hbnn2=III4113344 	K 	KEe$$--t7I-JJJJ	K 	KrB   r   c                 J   || _         | j        }|| j        |         }| j        |         j        }|                     |           |                                  | j         du r+|                     | j        | j        |                             |                                  d S d S 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/4D**4000&&((("e++''%don&EFH H H!!##### &%rB   r   c                 r    || _         | j                                         |                     d           d S 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                 r    || _         | j                                         |                     d           d S r   )r   r   r   r   r   s     r@   toggle_group_cellsz,OutlineExplorerTreeWidget.toggle_group_cellsG  s<     %**,,,X.....rB   r   c                     || _         | j                                        D ]}|                     |j        |           d S rh   )r   r   keysupdate_editorinfo)r?   r   editors      r@   toggle_variablesz*OutlineExplorerTreeWidget.toggle_variablesM  sL    !&o**,, 	4 	4Fv{F3333	4 	4rB   r   c                 <    || _         |                                  d S rh   )r   r   r   s     r@    toggle_sort_files_alphabeticallyz:OutlineExplorerTreeWidget.toggle_sort_files_alphabeticallyS  s"    ).&""$$$$$rB   r   c                 <    || _         |                                  dS )zFollow the cursor.N)r   r   r   s     r@   toggle_follow_cursorz.OutlineExplorerTreeWidget.toggle_follow_cursorX  s$     #rB   c                 @    | j         r|                                  dS dS )zGo to cursor position.N)r   go_to_cursor_positionre   s    r@   r   z*OutlineExplorerTreeWidget.do_follow_cursor^  s1      	)&&(((((	) 	)rB   c                    | j         | j        | j                  }| j                                         }| j        |         }| j        |         }||dz
           }t          |          dk    rH|j        }|                     |           |                     |           | 	                    |           d S t          |          }d}|                     ||           d S d S )NrO   r   )r   r   get_cursor_line_numberr   r   lenr4   setCurrentItemscrollToItem
expandItemsortedswitch_to_node)	r?   r   linetreerootoverlapr   sorted_nodesrZ   s	            r@   r   z/OutlineExplorerTreeWidget.go_to_cursor_positiond  s    *(;<I&==??D))4D$Y/D4!8nG7||q  y##D)))!!$'''%%%%%%g ##L#66666# +*rB   c                     ||         }|j         }|j        }|                     |           |                     |           |                     |           dS )z=Given a set of tree nodes, highlight the node on index `idx`.N)datar4   r   r   r  )r?   r  rZ   item_intervalitem_refr   s         r@   r  z(OutlineExplorerTreeWidget.switch_to_nodey  s[    $S) %}D!!!$rB   c                    | j         }|dS |j        }|j        }|j        }|rd|                    | j                   |                    | j                   |                    | j                   |                                  dS 	 |                    | j                   |                    | j                   |                    | j                   dS # t          $ r Y dS 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   $>F =
5$> 	t1222T2333''(@AAA!!#####%%d&8999##D$9:::#..t/GHHHHH    s   AC 
C&%C&c                 X    |                      d           t          j        |            dS )zReimplemented Qt methodr   N)	set_titler   r   re   s    r@   r   zOutlineExplorerTreeWidget.clear  s+    rD!!!!!rB   c                    |                                 }	 | j        |         j        }n# t          $ r Y dS w xY w| j        s?|                     |           |                     |           |                     |           t          	                    d|j
                    || _        | j        rW|                                                                | j        v r,|j        s'|j        "|                     |j                   dS dS dS dS dS )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  s6   MMOO		$Y/4DD 	 	 	FF	 { 	1d#####D)))**4000A6<AABBB$ O	0$$&&,,..$/AA* B {&""6;/////	0 	0AAAA '&s   ) 
77c                    |                                 }|| j        |<   | j                            |           t	          |j        dd|j                  }|| j        |<   t          |j        || |                                          }||_	        |
                    | j                   |                     d           | j        s|                    d           t                      }|| j        |<   |                                  dS )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    
 MMOO	"+&&y111 tT6<HH	'0)$ y!%v'7'7'9'9; ;	"	D$6777##A&&&" 	&%%%"nn,7y)""$$$$$rB   c                    |dS |                                 }|t          | j                                                  v r| j        |         }|                    |           |j        }|                    || j                   |                                 |	                                 | 
                                 dS dS )z0File was renamed, updating outline explorer treeNr   )r  listr   valuesr   ro   r4   r   rI   request_symbolsr   )r?   r   new_filenamer   itemsr'  s         r@   file_renamedz&OutlineExplorerTreeWidget.file_renamed  s    > FMMOO	T_33556666%i0E NN<((( 
I|d6HIII LLNNN""$$$ &&(((((! 76rB   c                    | j                             |          r| j         |         d         }|j        M	 |                     |j        |           n# t          $ r Y nw xY w| j         |                             |           | j        |                                          dS | j                            |          r&t          
                    d           d| j        |<   dS dS )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// 	0+H5a8F{&&&v{F;;;;   D&x077???x(..00000}  ** 0?@@@*/h'''0 0s   A 
AAFc                     | j         D ]8}|                     ||           | j        |                                          9dS )z$Update all editors with LSP support.)
reset_infoN)r   set_editors_to_updater   r3  )r?   r6  r   s      r@   update_all_editorsz,OutlineExplorerTreeWidget.update_all_editors  sS     	1 	1H&&xJ&GGGx(..0000	1 	1rB   Nc                 V   |dS || j         }| j        s>t                              d|j         d           | j                                         dS |                     ||          }|r>|                                  | 	                                 | 
                                 dS dS )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>(F  	LLV\      !&&(((F!!%00 	$$$&&&'')))!!#####	$ 	$rB   c                 x   d}|j         \  }}|j        %|s#|j         \  }}||k    r|j        }nd}|j        |#|j        Q|j                            |           d|_        |j        j        $|j        j                            |j                   |                    |           |                                 |S )z)Add node into an existing tree structure.FNT)r2   r>   rF   r4   rD   rP   rf   )r?   r>   r4   matchr3  endparent_start
parent_ends           r@   merge_intervalz(OutlineExplorerTreeWidget.merge_interval'  s    ]
sm'''-$L*U"" m'' ;"K##D)))DKy+	 00;;;rB   c                    |                                 }|                                }| j        |         }| j        |         }g }|D ]}|d         }	|d         }
|                                dk    rA|
t
          j        k    r;|
t
          j        k    r| j        sS|
t
          j	        k    r| j        sk|d         d         }|d         d         }|d         d         }t          |	|
||fd	          }|                    ||d
z   |f           t          j        |          }|j                                        dk    ot!          |          dk    }|s_||z
  }|rXt!          |          dk    rEt"                              d|j         d           d|_        | j                                         dS t"                              d|j                    t/          |          D ]}|j                                         | j        |                                          t          |          }|                    | j        |           || j        |<   d|_        | j                                         | j                                         dS )z2Update tree with new items that come from the LSP.r1   r3   r   locationr   r3  r  r@  NrO   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   r:  r   r  r
  rl   rI   merge_overlapsrC  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changesentry	tree_copys                       r@   r;  z%OutlineExplorerTreeWidget.update_tree<  s   MMOO	&&((-i8 +	  	J 	JF .K .K~~8++*"333:#666 2 7:#333 2 4 "*-g6L'08L%e,V4J&{K(4j'A4I IKlJNKHIIII'	22 i**,,1Kc,6G6G!6K 	 \)G G))7fl 7 7 7   *.&%**,,,u=v|==>>> D\\ 	% 	%EJ""$$$$
 	)$++--- !&&	  ,! 	! 	
 	
 	
 -1y)!%""$$$""$$$trB   c                    || j         v rj| j        |u rd | _        t                              d|j                    | j                             |          }|                                                                }|| j        v r| j        	                    |           || j
        v r/|| j        |         v r | j        |         	                    |           |t          | j                                                   vrw| j                            |          }| j                            |           	 |                     |                     |j                             d S # t&          $ r Y d S w xY wd S d S )NzRemoving tree of file )r   r   r  r  r  r]   r  r  r   r2  r   r   r+  r,  r   r   takeTopLevelItemindexOfTopLevelItemr4   RuntimeError)r?   r   r   r   r'  s        r@   remove_editorz'OutlineExplorerTreeWidget.remove_editor  s   T_$$"f,,&*#LL@&,@@AAA++F33I**,,2244HD333'..y999
 DO++d4X>>>&x077???T_%;%;%=%= > >>> -11)<<	&**9555))00@@B B B B B#   DD5 %$( ?>s   5-E$ $
E21E2c                 l    | j         |k    r&|| _         | j        du r|                                  dS dS dS )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  sO    
 "&888&8D#-66**,,,,, 9866rB   c                       j         du rdS  fdt                                                     D             }d |D             } j        r%t	          |                                d           }n fd j        D             }t          r%t          t                    t          d          k    p||k    }|rӉ 
                                }                                  t                                                     D ]}                     d	           t          |          D ]\  }}                     ||                                                                               |r|d
                             d           dS dS dS )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                 :    g | ]}                     |          S r{   )r   )rL   r:   r?   s     r@   rN   zCOutlineExplorerTreeWidget.__sort_toplevel_items.<locals>.<listcomp>  s9     !B !B !Be!2!25!9!9 !B !B !BrB   c                 B    i | ]}|j                                         |S r{   )r5   r  )rL   r   s     r@   
<dictcomp>zCOutlineExplorerTreeWidget.__sort_toplevel_items.<locals>.<dictcomp>  s9     &G &G &G(,DIOOt&G &G &GrB   c                 X    t          j        | j                                                  S rh   )r   r   r5   r  )r   s    r@   <lambda>zAOutlineExplorerTreeWidget.__sort_toplevel_items.<locals>.<lambda>  s    dioo.?.?!@!@ rB   )keyc                     g | ];}j                             |          j                             |          j        <S rh   )r   r   r4   )rL   e_idr?   s     r@   rN   zCOutlineExplorerTreeWidget.__sort_toplevel_items.<locals>.<listcomp>  sN     !9 !9 !959!%%d++7 !%%d++0777rB   z5.15.0r   r   T)r   r   r   r   r  r,  r   r   r   r   selectedItemsr<  r]  	enumerateinsertTopLevelItemr=  clearSelectionr   )r?   current_ordered_itemscurrent_ordered_items_dictnew_ordered_itemsr!  selected_itemsr:   r   s   `       r@   __sort_toplevel_itemsz/OutlineExplorerTreeWidget.__sort_toplevel_items  s    %''F!B !B !B !B!&t'='='?'?!@!@!B !B !B&G &G0E&G &G &G" ) 	9 &*1133@@!B !B !B!9 !9 !9 !9'!9 !9 !9 A~..%//A <%):: 	  
	5!//11N$$&&&t557788 ) )%%a((((():;; 5 5t''t4444'')))!!! 5r"..t44444
	5 
	55 5rB   c                     | j         rdS |                                 D ]1}||u r|                     |           |                     |           2dS )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  sn     	F1133 	- 	-ID  	****!!),,,,		- 	-rB   c                     | j         M|                                  | j        | j                  }|                     | j        |         j                   dS dS )z"Reimplemented OneColumnTree methodN)r   collapseAllr   r   r   r4   )r?   r   s     r@   restorez!OutlineExplorerTreeWidget.restore  sY    *(;<I##D$5i$@$EFFFFF +*rB   c                     |}t          |                                t                    r;|                                }t          |                                t                    ;|S )z+Return the root item of the specified item.)
isinstancer>   r   rw  s      r@   get_root_itemz'OutlineExplorerTreeWidget.get_root_item  s\    	))++_== 	+!((**I ))++_== 	+rB   c                    g }t          |           }|                                r|                                }|                                se|                                r<|                                                                r|                    |           n|                    |           |dz  }|                                |S )z5Return a list of all visible items in the treewidget.rO   )r   r   isHiddenr>   
isExpandedr$  )r?   r/  iteratorr   s       r@   get_visible_itemsz+OutlineExplorerTreeWidget.get_visible_items  s    *400nn 	>>##D==?? ';;== '{{}}//11 +T***LL&&&MH nn 	 rB   c                    | j                             | j                            | j                            }|j        }d}t          |t                    r%d}t          |          t          |          k    r|}n!|j        j	        d         dz   }|j        j
        }|j        j        }d| _        |r/|                                 j                            |||           n,|                                 j                            |           d| _        t#          | j                                                   D ]E\  }}|j        |k    r3t#          | j                                                  D ]\  }	}
|	| _          dS dS )zDouble-click eventr   Nr   rO   TF)r   r   r   r   r4   r|  r   r9   ra   r2   r1   r5   r   r>   	edit_gotor   editr+  r/  )r?   r   editor_rootr'  textr  r5   r   i_itemr   _ids              r@   	activatedz#OutlineExplorerTreeWidget.activated  so   '++O 3446 6$	dL)) 	!D)}}4(( 	8$Q'!+D8=Dx} 	*KKMM#((tT::::KKMM##D)))!%d&7&=&=&?&?!@!@ 	 	Iv{d""#'(=(=(?(?#@#@  KFC*0D'EE	 	rB   c                     t          |t                    r|                     |           |                     |           dS )zClick eventN)r|  r   r   r  )r?   r   s     r@   clickedz!OutlineExplorerTreeWidget.clicked$  s@    dL)) 	*##D)))trB   c                 J    ||j         }d|_        ||j         }d|_        d S d S )NTF)ra   r=   )r?   current_itemprevious_itemcurrent_refprevious_refs        r@   r   z,OutlineExplorerTreeWidget.selection_switched*  s<    #&*K#'K $(,L$)L!!! %$rB   c                 "    |j         }d|_        d S r0   ra   r<   r?   r   ra   s      r@   r   z-OutlineExplorerTreeWidget.tree_item_collapsed2  s    h


rB   c                 "    |j         }d|_        d S )NTr  r  s      r@   r   z,OutlineExplorerTreeWidget.tree_item_expanded6  s    h


rB   c                     g }| j                                         D ]J}|                                                                |k    r|                    |           |rd|_        K|| j        |<   dS )z#Set editors to update per language.N)r   r   r  r  r$  r   r   )r?   r   r6  	to_updater   s        r@   r7  z/OutlineExplorerTreeWidget.set_editors_to_update:  s~    	o**,, 	' 	'F""$$**,,88  ((( '"&FK+4x(((rB   c                     t                               d             j                                       t	                     }|                    d           |                    d           |j                             fd           | j	        <   d j
        <                                   |                                 dS )z&Show symbols for all `language` files.z#Start symbol services for language T   c                  .                                    S rh   )r   )r   r?   s   r@   rh  zAOutlineExplorerTreeWidget.start_symbol_services.<locals>.<lambda>Q  s    d&9&9(&C&C rB   N)r  r  r   r$  r   setSingleShotsetIntervaltimeoutr   r   r   r7  r3  )r?   r   timers   `` r@   start_symbol_servicesz/OutlineExplorerTreeWidget.start_symbol_servicesD  s    E8EEFFF 	x(((
 tD!!!#CCCCCDDD',8$"&h 	""8,,, 	rB   c                 2   t                               d|            	 | j                            |           n# t          $ r Y nw xY w| j                                        D ]3}|                                                                |k    rd|_	        4dS )z"Disable LSP symbols functionality.z"Stop symbol services for language N)
r  r  r   r2  
ValueErrorr   r   r  r  r   r4  s      r@   stop_symbol_servicesz.OutlineExplorerTreeWidget.stop_symbol_services[  s    D(DDEEE	O""8,,,, 	 	 	D	 o**,, 	# 	#F""$$**,,88"	# 	#s   : 
AAc                 4   || _         |r| j        D ]}| j        |         s| j                                        D ]b}|                                                                |k    r6|j        s/|| j        |         vr | j        |         	                    |           c| j        |         r3t                              d| d           |                     |           | j        }|r-|j        r(|j        s#|                     |j        |           dS dS dS dS dS )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_visibilityg  su   $ 	0 O 6 6 }X. 6"&/"6"6"8"8 L L"//117799XEE$*$: F &d.DX.N N N 28<CCFKKK -h7 6E8 E E E   ++H555 $B 0bg 0b&8 0""27B/////5	0 	020 0 0 0 0 0rB   )Frh   )6rx   ry   rz   r	   rN  r  r:  r   CONF_SECTIONrA   propertyr   setterr   r   r   r   r   r   r   r   r   r
   r   r   r  r   r   r"  r)  r0  r   r8  r+  r   rC  r;  r`  rb  r   r   rz  r}  r  r  r  r   r   r   r7  r  r  r  __classcell__)r   s   @r@   r   r      s       vxx &((vxx%vxx%L= = = = =B $ $ X$ * * *G G G ^?+++K K ,+K ^+,,,$ $ -,$ ^?+++/ / ,+/
 ^=)))/ / *)/
 ^.///4 4 0/4
 ^6777% % 87% ^?+++    ,+ 
 
TVV) ) V)
 
TVV7 7 V7(    2" " "
0 0 06% % %2) ) )60 0 0,1 1 1 1 
T$ZZ$ $ $ Z$6  *H H HT  >- - -/5 /5 /5b- - -G G G      :  * * *    5 5 5 5  .
# 
# 
#0 0 0 0 0 0 0rB   r   )Hr   rQ   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   	getLoggerrx   r  FILErH  	NAMESPACEPACKAGECLASSMETHODPROPERTYrJ  CONSTRUCTORENUM	INTERFACEFUNCTIONrI  CONSTANTSTRINGNUMBERBOOLEANARRAYOBJECTKEYNULLENUM_MEMBERSTRUCTEVENTOPERATORTYPE_PARAMETERCELLBLOCK_COMMENTr   r.   r}   r   rk   r   r{   rB   r@   <module>r     s~               & % % % % % # # # # # # ( ( ( ( ( ( ( ( 0 0 0 0 0 0 0 0 0 0 0 0 C C C C C C C C 8 7 7 7 7 7             ) ) ) ) ) ) F F F F F F F F 5 5 5 5 5 5 6 6 6 6 6 6 
	8	$	$
OQQvYYqq{{ !!K.. )	
 aajj qq{{ : aann AAm,, OQQvYY !!K.. : : : qq{{  qq{{!" )#$ aajjqq{{NAAeHHOQQvYYAAm,,qq{{aajj:qq!122OQQvYYaa009 Dh
 h
 h
 h
 h
 h
 h
 h
Z
 
 
 
 
? 
 
 
L L L L L< L L L$# # # # # # # #.[
0 [
0 [
0 [
0 [
0 [
0 [
0 [
0 [
0 [
0rB   