Skip to content

Commit 8c0517d

Browse files
committed
fix(robotlangserver): resolving imports with arguments in diffent files and folders but with same string representation ie. ${curdir}/blah.py now works correctly
1 parent 8210bd9 commit 8c0517d

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

Diff for: robotcode/language_server/robotframework/diagnostics/imports_manager.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
is_embedded_keyword,
7474
is_library_by_path,
7575
is_variables_by_path,
76+
resolve_args,
7677
resolve_variable,
7778
)
7879

@@ -1056,7 +1057,14 @@ async def _get_libdoc(name: str, args: Tuple[Any, ...], working_dir: str, base_d
10561057

10571058
return result
10581059

1059-
entry_key = _LibrariesEntryKey(source, args)
1060+
resolved_args = resolve_args(
1061+
args,
1062+
str(self.folder.to_path()),
1063+
base_dir,
1064+
self.config.robot.variables if self.config.robot is not None else None,
1065+
variables,
1066+
)
1067+
entry_key = _LibrariesEntryKey(source, resolved_args)
10601068

10611069
async with self._libaries_lock:
10621070
if entry_key not in self._libaries:
@@ -1293,7 +1301,14 @@ async def _get_libdoc() -> VariablesDoc:
12931301
self._logger.exception(e)
12941302
return result
12951303

1296-
entry_key = _VariablesEntryKey(source, args)
1304+
resolved_args = resolve_args(
1305+
args,
1306+
str(self.folder.to_path()),
1307+
base_dir,
1308+
self.config.robot.variables if self.config.robot is not None else None,
1309+
variables,
1310+
)
1311+
entry_key = _VariablesEntryKey(source, resolved_args)
12971312

12981313
async with self._variables_lock:
12991314
if entry_key not in self._variables:

Diff for: robotcode/language_server/robotframework/diagnostics/library_doc.py

+19
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,25 @@ def _find_variables_internal(
14681468
return (result, robot_variables)
14691469

14701470

1471+
def resolve_args(
1472+
args: Tuple[Any, ...],
1473+
working_dir: str = ".",
1474+
base_dir: str = ".",
1475+
command_line_variables: Optional[Dict[str, Optional[Any]]] = None,
1476+
variables: Optional[Dict[str, Optional[Any]]] = None,
1477+
) -> Tuple[Any, ...]:
1478+
robot_variables = resolve_robot_variables(working_dir, base_dir, command_line_variables, variables)
1479+
1480+
result = []
1481+
for arg in args:
1482+
if isinstance(arg, str):
1483+
result.append(robot_variables.replace_string(arg, ignore_errors=True))
1484+
else:
1485+
result.append(arg)
1486+
1487+
return tuple(result)
1488+
1489+
14711490
def find_variables(
14721491
name: str,
14731492
working_dir: str = ".",

0 commit comments

Comments
 (0)