3838from ...common .lsp_types import DocumentUri , FileChangeType , FileEvent
3939from ...common .parts .workspace import FileWatcherEntry , Workspace
4040from ...common .text_document import TextDocument
41- from ..configuration import RobotConfig
41+ from ..configuration import CacheSaveLocation , RobotCodeConfig
4242from ..utils .ast_utils import HasError , HasErrors , Token
4343from ..utils .async_ast import walk
4444from ..utils .robot_path import find_file_ex
@@ -486,17 +486,21 @@ def filepath_base(self) -> Path:
486486class ImportsManager :
487487 _logger = LoggingDescriptor ()
488488
489- def __init__ (self , parent_protocol : RobotLanguageServerProtocol , folder : Uri , config : RobotConfig ) -> None :
489+ def __init__ (self , parent_protocol : RobotLanguageServerProtocol , folder : Uri , config : RobotCodeConfig ) -> None :
490490 super ().__init__ ()
491491 self .parent_protocol = parent_protocol
492492
493493 self .folder = folder
494494 get_robot_version ()
495495
496496 cache_base_path = self .folder .to_path ()
497- if isinstance (self .parent_protocol .initialization_options , dict ):
498- if "storageUri" in self .parent_protocol .initialization_options :
499- cache_base_path = Uri (self .parent_protocol .initialization_options ["storageUri" ]).to_path ()
497+ if (
498+ config .analysis .cache .save_location == CacheSaveLocation .WORKSPACE_STORAGE
499+ and isinstance (self .parent_protocol .initialization_options , dict )
500+ and "storageUri" in self .parent_protocol .initialization_options
501+ ):
502+ cache_base_path = Uri (self .parent_protocol .initialization_options ["storageUri" ]).to_path ()
503+
500504 self ._logger .trace (lambda : f"use { cache_base_path } as base for caching" )
501505
502506 self .lib_doc_cache_path = (
@@ -506,8 +510,7 @@ def __init__(self, parent_protocol: RobotLanguageServerProtocol, folder: Uri, co
506510 / get_robot_version_str ()
507511 / "libdoc"
508512 )
509-
510- self .config : RobotConfig = config
513+ self .config = config
511514 self ._libaries_lock = Lock ()
512515 self ._libaries : OrderedDict [_LibrariesEntryKey , _LibrariesEntry ] = OrderedDict ()
513516 self ._resources_lock = Lock ()
@@ -521,7 +524,7 @@ def __init__(self, parent_protocol: RobotLanguageServerProtocol, folder: Uri, co
521524 self ._command_line_variables_lock = Lock ()
522525
523526 self ._environment = dict (os .environ )
524- self ._environment .update (self .config .env )
527+ self ._environment .update (self .config .robot . env )
525528
526529 self ._library_files_cache = AsyncSimpleLRUCache ()
527530 self ._resource_files_cache = AsyncSimpleLRUCache ()
@@ -540,14 +543,14 @@ async def get_command_line_variables(self) -> List[VariableDefinition]:
540543 if self ._command_line_variables is None :
541544 command_line_vars : List [VariableDefinition ] = []
542545
543- if self .config is None :
546+ if self .config . robot is None :
544547 self ._command_line_variables = []
545548 else :
546549 command_line_vars = [
547550 CommandLineVariableDefinition (0 , 0 , 0 , 0 , "" , f"${{{ k } }}" , None , has_value = True , value = (v ,))
548- for k , v in self .config .variables .items ()
551+ for k , v in self .config .robot . variables .items ()
549552 ]
550- for variable_file in self .config .variable_files :
553+ for variable_file in self .config .robot . variable_files :
551554 name , args = split_args_from_name_or_path (variable_file )
552555 try :
553556 lib_doc = await self .get_libdoc_for_variables_import (
@@ -806,7 +809,7 @@ async def _find_library(self, name: str, base_dir: str, variables: Optional[Dict
806809 name ,
807810 str (self .folder .to_path ()),
808811 base_dir ,
809- self .config .variables if self .config is not None else None ,
812+ self .config .robot . variables if self .config . robot is not None else None ,
810813 variables ,
811814 )
812815
@@ -836,7 +839,7 @@ async def __find_resource(
836839 name ,
837840 str (self .folder .to_path ()),
838841 base_dir ,
839- self .config .variables if self .config is not None else None ,
842+ self .config .robot . variables if self .config . robot is not None else None ,
840843 variables ,
841844 file_type ,
842845 )
@@ -855,7 +858,7 @@ async def __find_variables(self, name: str, base_dir: str, variables: Optional[D
855858 name ,
856859 str (self .folder .to_path ()),
857860 base_dir ,
858- self .config .variables if self .config is not None else None ,
861+ self .config .robot . variables if self .config . robot is not None else None ,
859862 variables ,
860863 )
861864
@@ -918,7 +921,7 @@ async def _get_libdoc() -> LibraryDoc:
918921 args ,
919922 str (self .folder .to_path ()),
920923 base_dir ,
921- self .config .variables if self .config is not None else None ,
924+ self .config .robot . variables if self .config . robot is not None else None ,
922925 variables ,
923926 ),
924927 LOAD_LIBRARY_TIME_OUT ,
@@ -1111,7 +1114,7 @@ async def _get_libdoc() -> VariablesDoc:
11111114 args ,
11121115 str (self .folder .to_path ()),
11131116 base_dir ,
1114- self .config .variables if self .config is not None else None ,
1117+ self .config .robot . variables if self .config . robot is not None else None ,
11151118 variables ,
11161119 ),
11171120 LOAD_LIBRARY_TIME_OUT ,
@@ -1207,7 +1210,7 @@ async def complete_library_import(
12071210 name ,
12081211 str (self .folder .to_path ()),
12091212 base_dir ,
1210- self .config .variables if self .config is not None else None ,
1213+ self .config .robot . variables if self .config . robot is not None else None ,
12111214 variables ,
12121215 )
12131216
@@ -1218,7 +1221,7 @@ async def complete_resource_import(
12181221 name ,
12191222 str (self .folder .to_path ()),
12201223 base_dir ,
1221- self .config .variables if self .config is not None else None ,
1224+ self .config .robot . variables if self .config . robot is not None else None ,
12221225 variables ,
12231226 )
12241227
@@ -1230,7 +1233,7 @@ async def complete_variables_import(
12301233 name ,
12311234 str (self .folder .to_path ()),
12321235 base_dir ,
1233- self .config .variables if self .config is not None else None ,
1236+ self .config .robot . variables if self .config . robot is not None else None ,
12341237 variables ,
12351238 )
12361239
@@ -1239,6 +1242,6 @@ def resolve_variable(self, name: str, base_dir: str = ".", variables: Optional[D
12391242 name ,
12401243 str (self .folder .to_path ()),
12411244 base_dir ,
1242- self .config .variables if self .config is not None else None ,
1245+ self .config .robot . variables if self .config . robot is not None else None ,
12431246 variables ,
12441247 )
0 commit comments