
    8@d                         d dl Z d dlmZ d dlmZmZmZmZ d dlZd dl	Z	d dl
mZ d dlmZmZmZmZ  e j        e          ZdgZ G d de	j                  Z G d	 d
          ZdS )    N)	lru_cache)ListMappingSequenceUnion)HookImpl)_utils	hookspecsurisPYLSPpycodestylec                   b    e Zd Zdedee         deeef         dede	ee
e         f         f
dZdS )PluginManager	hook_namemethodskwargsfirstresultreturnc                     	 |                      ||||          S # t          $ r.}t                              d| d| d           g cY d }~S d }~ww xY w)NzFailed to load hook z: T)exc_info)_inner_hookexec	Exceptionlogwarning)selfr   r   r   r   es         3lib/python3.11/site-packages/pylsp/config/config.py	_hookexeczPluginManager._hookexec   sv    	''	7FKPPP 	 	 	KK?y??A??$KOOOIIIIII	s    
A#AAAN)__name__
__module____qualname__strr   r   r   objectboolr   r   r        r   r   r      st         (# V$	
  
vtF|#	$     r&   r   c                       e Zd Zd Zed             Zed             Zed             Zed             Zed             Z	ed             Z
 ed	          dd            Zd ZddZd Zd Zd
S )Configc                    t          j        |          | _        || _        || _        || _        || _        i | _        i | _        i | _	        	 ddl
m}  || j                  | j	        d<   n# t          $ r Y nw xY w	 ddlm}  || j                  | j	        d<   n# t          $ r Y nw xY wt          t                     | _        | j        j        j                            t*          j                   | j                                         | j                            t2                     t5          j        t                     D ]t}	 |                                 # t:          $ rP}t*                              dt           |j        |           | j                             |j                   Y d }~md }~ww xY w| j        !                    t                      | j        "                                D ]#\  }	}
|
t*                              d|	|
           $| j        j#        $                    |           D ]!}tK          j&        | j        |          | _        "| '                                 d S )	N   )Flake8Configflake8)PyCodeStyleConfigr   z&Failed to load %s entry point '%s': %szLoaded pylsp plugin %s from %s)config)(r   
to_fs_path
_root_path	_root_uri
_init_opts_process_id_capabilities	_settings_plugin_settings_config_sourcesflake8_confr+   ImportErrorpycodestyle_confr-   r   r   _pmtraceroot	setwriterr   debugenable_tracingadd_hookspecsr
   pkg_resourcesiter_entry_pointsloadr   infonameset_blockedload_setuptools_entrypointslist_name_pluginhookpylsp_settingsr	   merge_dicts_update_disabled_plugins)r   root_uri	init_opts
process_idcapabilitiesr+   r-   entry_pointr   rF   pluginplugin_confs               r   __init__zConfig.__init__(   s   /(33!#%) "!	111111-9\$/-J-JD ** 	 	 	D		;;;;;;2C2CDO2T2TD // 	 	 	D	 !''%%ci000!!!y)))
 ):5AA 	7 	7K7  """" 7 7 7A5+JZ\]^^^$$[%5666666667
 	,,U333 H5577 	I 	ILD&!94HHH8=77t7DD 	[ 	[K$*$6t7Lk$Z$ZD!!%%'''''s=   A+ +
A87A8<B 
B('B(E
F5%AF00F5c                     | j         S N)_disabled_pluginsr   s    r   disabled_pluginszConfig.disabled_pluginsY   s    %%r&   c                     | j         S rW   )r;   rY   s    r   plugin_managerzConfig.plugin_manager]   s	    xr&   c                     | j         S rW   )r2   rY   s    r   rO   zConfig.init_optsa   s
    r&   c                     | j         S rW   )r1   rY   s    r   rN   zConfig.root_urie   s
    ~r&   c                     | j         S rW   )r3   rY   s    r   rP   zConfig.process_idi   s    r&   c                     | j         S rW   )r4   rY   s    r   rQ   zConfig.capabilitiesm   s    !!r&       )maxsizeNc                    i }| j                             dt                    }t          j        || j                  }t          j        || j                   }t          |          D ]n}| j                            |          }|s|                                }t          
                    d|j        j        |           t          j        ||          }ot          |          D ]v}| j                            |          }|s|                    |p| j                  }t          
                    d|j        j        |           t          j        ||          }wt          
                    d|           |S )a  Settings are constructed from a few sources:

            1. User settings, found in user's home directory
            2. Plugin settings, reported by PyLS plugins
            3. LSP settings, given to us from didChangeConfiguration
            4. Project settings, found in config files in the current project.

        Since this function is nondeterministic, it is important to call
        settings.cache_clear() when the config is updated
        configurationSourceszGot user config from %s: %szGot project config from %s: %szWith configuration: %s)r5   getDEFAULT_CONFIG_SOURCESr	   rL   r6   reversedr7   user_configr   r?   	__class__r   project_configr0   )r   document_pathsettingssourcessource_namesourcesource_confs          r   rl   zConfig.settingsq   sp    .$$%;=STT %h0EFF %h?? $G,, 	A 	AK)--k::F  ,,..KII3V5E5NP[\\\)(K@@HH $G,, 	A 	AK)--k::F  //0PQQKII68H8QS^___)(K@@HH		*H555r&   c                 `    t          j        | j                  }t          j        |||          S rW   )r   r/   r1   r	   find_parents)r   pathnames	root_paths       r   rr   zConfig.find_parents   s(    ODN33	"9dE:::r&   c                 ~    |                      |                              di                               |i           S )N)rk   pluginsrl   re   )r   rS   rk   s      r   plugin_settingszConfig.plugin_settings   s8    }}=}99==iLLPPQWY[\\\r&   c                     | j                                          || _        t                              d| j                   |                                  dS )z?Recursively merge the given settings into the current settings.zUpdated settings to %sN)rl   cache_clearr5   r   rE   rM   )r   rl   s     r   updatezConfig.update   sL    !!###!)4>:::%%'''''r&   c                       fd j                                         D              _        t                              d j                   d S )Nc                     g | ]W\  }}                                                     d i                               |i                               dd          U|XS )rw   enabledTrx   ).0rF   rS   r   s      r   
<listcomp>z3Config._update_disabled_plugins.<locals>.<listcomp>   sl     "
 "
 "
#tV==??&&y"5599$CCGG	SWXX"
"
 "
 "
r&   zDisabled plugins: %s)r\   rI   rX   r   rE   rY   s   `r   rM   zConfig._update_disabled_plugins   s]    "
 "
 "
 "
'+':'K'K'M'M"
 "
 "
 	')?@@@@@r&   rW   )r   r    r!   rU   propertyrZ   r\   rO   rN   rP   rQ   r   rl   rr   ry   r|   rM   r%   r&   r   r(   r(   '   s?       /( /( /(b & & X&   X   X   X     X  " " X" Yr( ( ( (T; ; ;] ] ] ]( ( (A A A A Ar&   r(   )logging	functoolsr   typingr   r   r   r   rB   pluggypluggy._hooksr   pylspr	   r
   r   r   	getLoggerr   r   rf   r   r(   r%   r&   r   <module>r      s   
        1 1 1 1 1 1 1 1 1 1 1 1      " " " " " " 0 0 0 0 0 0 0 0 0 0 0 0g!! (     F(   $IA IA IA IA IA IA IA IA IA IAr&   