
    Je                     f    d Z ddlmZmZ ddlmZmZ ddlmZ ddl	m
Z
mZ ddlmZ  G d de
      Zy	)
zOutline Explorer Plugin.    )QtSlot)on_plugin_availableon_plugin_teardown_)SpyderDockablePluginPlugins)OutlineExplorerWidgetc                      e Zd ZdZdZej                  ej                  gZg Z	dZ
eZedefd       ZdefdZd Zd Z eej                        d	        Z eej                        d
        Z eej                        d        Z eej                        d        Z ee      d        Zd Z eee      d        Zd Zd Z d Z!y)OutlineExploreroutline_explorerFreturnc                      t        d      S )zReturn widget title.zOutline Explorerr        G/usr/lib/python3/dist-packages/spyder/plugins/outlineexplorer/plugin.pyget_namezOutlineExplorer.get_name   s     #$$r   c                     t        d      S )z6Return the description of the outline explorer widget.z/Explore a file's functions, classes and methodsr   selfs    r   get_descriptionzOutlineExplorer.get_description$   s    BCCr   c                 $    | j                  d      S )z!Return the outline explorer icon.r   )create_iconr   s    r   get_iconzOutlineExplorer.get_icon(   s     233r   c                     | j                   r/| j                   j                  j                  | j                         | j                  j                  | j
                         y N)mainrestore_scrollbar_positionconnect_restore_scrollbar_positionsig_mainwindow_state_changed_on_mainwindow_state_changedr   s    r   on_initializezOutlineExplorer.on_initialize,   sG    99II0088002))11--	/r   )pluginc                     | j                  t        j                        }|j                  j	                  | j
                         |j                  j	                  | j                         y r   )
get_pluginr
   Completions"sig_language_completions_availabler    start_symbol_servicessig_stop_completionsstop_symbol_servicesr   completionss     r   on_completions_availablez(OutlineExplorer.on_completions_available3   sP    oog&9&9:66>>&&	(((00%%	'r   c                     | j                  t        j                        }|j                  j	                  | j
                         y r   )r'   r
   Editorsig_open_files_finishedr    update_all_editorsr   editors     r   on_editor_availablez#OutlineExplorer.on_editor_available<   s1    0&&..##	%r   c                     | j                  t        j                        }|j                  j	                  | j
                         |j                  j	                  | j                         y r   )r'   r
   r(   r)   
disconnectr*   r+   r,   r-   s     r   on_completions_teardownz'OutlineExplorer.on_completions_teardownC   sP    oog&9&9:66AA&&	(((33%%	'r   c                     | j                  t        j                        }|j                  j	                  | j
                         y r   )r'   r
   r1   r2   r8   r3   r4   s     r   on_editor_teardownz"OutlineExplorer.on_editor_teardownL   s1    0&&11##	%r   c                     |t         j                  k(  r | j                         j                  d       y| j                         j                  d       y)z;Actions to take when the main window has changed its state.FTN)r   WindowMinimized
get_widgetchange_tree_visibility)r   window_states     r   r#   z,OutlineExplorer._on_mainwindow_state_changedU   s>     2--- OO44U;OO44T:r   c                     | j                  dd      }| j                         }||j                  j                  |       yy)z9Restoring scrollbar position after main window is visiblescrollbar_positionN)get_confr>   
treewidgetset_scrollbar_position)r   scrollbar_posexplorers      r   r!   z+OutlineExplorer._restore_scrollbar_position_   s>    &:DA??$$66}E %r   c                 p    | j                         }|j                  dd      }|r|j                  |       yy)z!Enable LSP symbols functionality.documentSymbolProviderFN)r>   getr*   )r   capabilitieslanguagerG   symbol_providers        r   r*   z%OutlineExplorer.start_symbol_servicesh   s9     ??$&**+CUK**84 r   c                 F    | j                         }|j                  |       y)z"Disable LSP symbols functionality.N)r>   r,   )r   rL   rG   s      r   r,   z$OutlineExplorer.stop_symbol_servicesp   s    ??$%%h/r   c                 D    | j                         }|j                          y)z1Update all editors with an associated LSP server.N)r>   r3   )r   rG   s     r   r3   z"OutlineExplorer.update_all_editorsu   s    ??$##%r   c                 >    | j                         j                         S )z'List of languages with symbols support.)r>   get_supported_languagesr   s    r   rQ   z'OutlineExplorer.get_supported_languagesz   s     88::r   N)"__name__
__module____qualname__NAMECONF_SECTIONr
   r(   r1   REQUIRESOPTIONAL	CONF_FILEr   WIDGET_CLASSstaticmethodstrr   r   r   r$   r   r/   r6   r   r9   r;   r   objectr#   r!   dictr*   r,   r3   rQ   r   r   r   r   r      s!   D%L##W^^4HHI(L %c % %D D4/  3 34' 5' /% 0% w223' 4' w~~.% /% 
&\; ;F 
$_5 50
&
;r   r   N)__doc__qtpy.QtCorer   r   )spyder.api.plugin_registration.decoratorsr   r   spyder.api.translationsr   spyder.api.pluginsr	   r
   *spyder.plugins.outlineexplorer.main_widgetr   r   r   r   r   <module>re      s,     !- % < Lh;* h;r   