38
38
from ...common .lsp_types import DocumentUri , FileChangeType , FileEvent
39
39
from ...common .parts .workspace import FileWatcherEntry , Workspace
40
40
from ...common .text_document import TextDocument
41
- from ..configuration import RobotConfig
41
+ from ..configuration import CacheSaveLocation , RobotCodeConfig
42
42
from ..utils .ast_utils import HasError , HasErrors , Token
43
43
from ..utils .async_ast import walk
44
44
from ..utils .robot_path import find_file_ex
@@ -486,17 +486,21 @@ def filepath_base(self) -> Path:
486
486
class ImportsManager :
487
487
_logger = LoggingDescriptor ()
488
488
489
- def __init__ (self , parent_protocol : RobotLanguageServerProtocol , folder : Uri , config : RobotConfig ) -> None :
489
+ def __init__ (self , parent_protocol : RobotLanguageServerProtocol , folder : Uri , config : RobotCodeConfig ) -> None :
490
490
super ().__init__ ()
491
491
self .parent_protocol = parent_protocol
492
492
493
493
self .folder = folder
494
494
get_robot_version ()
495
495
496
496
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
+
500
504
self ._logger .trace (lambda : f"use { cache_base_path } as base for caching" )
501
505
502
506
self .lib_doc_cache_path = (
@@ -506,8 +510,7 @@ def __init__(self, parent_protocol: RobotLanguageServerProtocol, folder: Uri, co
506
510
/ get_robot_version_str ()
507
511
/ "libdoc"
508
512
)
509
-
510
- self .config : RobotConfig = config
513
+ self .config = config
511
514
self ._libaries_lock = Lock ()
512
515
self ._libaries : OrderedDict [_LibrariesEntryKey , _LibrariesEntry ] = OrderedDict ()
513
516
self ._resources_lock = Lock ()
@@ -521,7 +524,7 @@ def __init__(self, parent_protocol: RobotLanguageServerProtocol, folder: Uri, co
521
524
self ._command_line_variables_lock = Lock ()
522
525
523
526
self ._environment = dict (os .environ )
524
- self ._environment .update (self .config .env )
527
+ self ._environment .update (self .config .robot . env )
525
528
526
529
self ._library_files_cache = AsyncSimpleLRUCache ()
527
530
self ._resource_files_cache = AsyncSimpleLRUCache ()
@@ -540,14 +543,14 @@ async def get_command_line_variables(self) -> List[VariableDefinition]:
540
543
if self ._command_line_variables is None :
541
544
command_line_vars : List [VariableDefinition ] = []
542
545
543
- if self .config is None :
546
+ if self .config . robot is None :
544
547
self ._command_line_variables = []
545
548
else :
546
549
command_line_vars = [
547
550
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 ()
549
552
]
550
- for variable_file in self .config .variable_files :
553
+ for variable_file in self .config .robot . variable_files :
551
554
name , args = split_args_from_name_or_path (variable_file )
552
555
try :
553
556
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
806
809
name ,
807
810
str (self .folder .to_path ()),
808
811
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 ,
810
813
variables ,
811
814
)
812
815
@@ -836,7 +839,7 @@ async def __find_resource(
836
839
name ,
837
840
str (self .folder .to_path ()),
838
841
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 ,
840
843
variables ,
841
844
file_type ,
842
845
)
@@ -855,7 +858,7 @@ async def __find_variables(self, name: str, base_dir: str, variables: Optional[D
855
858
name ,
856
859
str (self .folder .to_path ()),
857
860
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 ,
859
862
variables ,
860
863
)
861
864
@@ -918,7 +921,7 @@ async def _get_libdoc() -> LibraryDoc:
918
921
args ,
919
922
str (self .folder .to_path ()),
920
923
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 ,
922
925
variables ,
923
926
),
924
927
LOAD_LIBRARY_TIME_OUT ,
@@ -1111,7 +1114,7 @@ async def _get_libdoc() -> VariablesDoc:
1111
1114
args ,
1112
1115
str (self .folder .to_path ()),
1113
1116
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 ,
1115
1118
variables ,
1116
1119
),
1117
1120
LOAD_LIBRARY_TIME_OUT ,
@@ -1207,7 +1210,7 @@ async def complete_library_import(
1207
1210
name ,
1208
1211
str (self .folder .to_path ()),
1209
1212
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 ,
1211
1214
variables ,
1212
1215
)
1213
1216
@@ -1218,7 +1221,7 @@ async def complete_resource_import(
1218
1221
name ,
1219
1222
str (self .folder .to_path ()),
1220
1223
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 ,
1222
1225
variables ,
1223
1226
)
1224
1227
@@ -1230,7 +1233,7 @@ async def complete_variables_import(
1230
1233
name ,
1231
1234
str (self .folder .to_path ()),
1232
1235
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 ,
1234
1237
variables ,
1235
1238
)
1236
1239
@@ -1239,6 +1242,6 @@ def resolve_variable(self, name: str, base_dir: str = ".", variables: Optional[D
1239
1242
name ,
1240
1243
str (self .folder .to_path ()),
1241
1244
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 ,
1243
1246
variables ,
1244
1247
)
0 commit comments