@@ -191,6 +191,7 @@ def serve_initialize(self, request: dict):
191191 self .source_dirs .add (self .root_path )
192192
193193 self ._load_config_file ()
194+ self ._resolve_globs_in_paths ()
194195 self ._config_logger (request )
195196 self ._load_intrinsics ()
196197 self ._add_source_dirs ()
@@ -1529,26 +1530,12 @@ def _load_config_file(self) -> None:
15291530 self .post_message (msg )
15301531
15311532 def _load_config_file_dirs (self , config_dict : dict ) -> None :
1532- # Exclude paths (directories & files)
1533- # with glob resolution
1534- for path in config_dict .get ("excl_paths" , []):
1535- self .excl_paths .update (set (resolve_globs (path , self .root_path )))
1536-
1537- # Source directory paths (directories)
1538- # with glob resolution
1539- source_dirs = config_dict .get ("source_dirs" , [])
1540- for path in source_dirs :
1541- # resolve_globs filters any nonexisting directories so FileNotFoundError
1542- # found inside only_dirs can never be raised
1543- dirs = only_dirs (resolve_globs (path , self .root_path ))
1544- self .source_dirs .update (set (dirs ))
1545-
1546- # Keep all directories present in source_dirs but not excl_paths
1547- self .source_dirs = {i for i in self .source_dirs if i not in self .excl_paths }
1548- self .incl_suffixes = config_dict .get ("incl_suffixes" , [])
1533+ self .excl_paths = set (config_dict .get ("excl_paths" , self .excl_paths ))
1534+ self .source_dirs = set (config_dict .get ("source_dirs" , self .source_dirs ))
1535+ self .incl_suffixes = set (config_dict .get ("incl_suffixes" , self .incl_suffixes ))
15491536 # Update the source file REGEX
15501537 self .FORTRAN_SRC_EXT_REGEX = src_file_exts (self .incl_suffixes )
1551- self .excl_suffixes = set (config_dict .get ("excl_suffixes" , [] ))
1538+ self .excl_suffixes = set (config_dict .get ("excl_suffixes" , self . excl_suffixes ))
15521539
15531540 def _load_config_file_general (self , config_dict : dict ) -> None :
15541541 # General options ------------------------------------------------------
@@ -1607,11 +1594,36 @@ def _load_config_file_preproc(self, config_dict: dict) -> None:
16071594 if isinstance (self .pp_defs , list ):
16081595 self .pp_defs = {key : "" for key in self .pp_defs }
16091596
1610- for path in config_dict .get ("include_dirs" , set ()):
1597+ self .include_dirs = set (config_dict .get ("include_dirs" , self .include_dirs ))
1598+
1599+ def _resolve_globs_in_paths (self ) -> None :
1600+ """Resolves glob patterns in `excl_paths`, `source_dirs` and `include_dirs`.
1601+ Also performs the exclusion of `excl_paths` from `source_dirs`.
1602+ """
1603+ # Exclude paths (directories & files) with glob resolution
1604+ excl_paths = set ()
1605+ for path in self .excl_paths :
1606+ excl_paths .update (set (resolve_globs (path , self .root_path )))
1607+ self .excl_paths = excl_paths .copy ()
1608+
1609+ # Source directory paths (directories) with glob resolution
1610+ source_dirs = set ()
1611+ for path in self .source_dirs :
1612+ # resolve_globs filters any nonexisting directories so FileNotFoundError
1613+ # found inside only_dirs can never be raised
1614+ source_dirs .update (set (only_dirs (resolve_globs (path , self .root_path ))))
1615+ self .source_dirs = source_dirs .copy ()
1616+
1617+ # Keep all directories present in source_dirs but not excl_paths
1618+ self .source_dirs = {i for i in self .source_dirs if i not in self .excl_paths }
1619+
1620+ # Preprocessor includes
1621+ include_dirs = set ()
1622+ for path in self .include_dirs :
16111623 # resolve_globs filters any nonexisting directories so FileNotFoundError
16121624 # found inside only_dirs can never be raised
1613- dirs = only_dirs (resolve_globs (path , self .root_path ))
1614- self .include_dirs . update ( set ( dirs ) )
1625+ include_dirs . update ( set ( only_dirs (resolve_globs (path , self .root_path )) ))
1626+ self .include_dirs = include_dirs . copy ( )
16151627
16161628 def _add_source_dirs (self ) -> None :
16171629 """Will recursively add all subdirectories that contain Fortran
0 commit comments