Skip to content

Commit

Permalink
fix(analyzer): fixed find variables as modules for RF > 5
Browse files Browse the repository at this point in the history
  • Loading branch information
d-biehl committed Oct 25, 2024
1 parent 0851d4f commit ce787b2
Showing 1 changed file with 28 additions and 48 deletions.
76 changes: 28 additions & 48 deletions packages/robot/src/robotcode/robot/diagnostics/imports_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,25 +1021,13 @@ def _find_library(
base_dir: str,
variables: Optional[Dict[str, Any]] = None,
) -> str:

if contains_variable(name, "$@&%"):
return find_library(
name,
str(self.root_folder),
base_dir,
self.get_resolvable_command_line_variables(),
variables,
)

if name in STDLIBS:
result = ROBOT_LIBRARY_PACKAGE + "." + name
else:
result = name

if is_library_by_path(result):
return find_file_ex(result, base_dir, "Library")

return result
return find_library(
name,
str(self.root_folder),
base_dir,
self.get_resolvable_command_line_variables(),
variables,
)

def _find_library_simple(
self,
Expand Down Expand Up @@ -1077,17 +1065,14 @@ def __find_resource(
file_type: str = "Resource",
variables: Optional[Dict[str, Any]] = None,
) -> str:
if contains_variable(name, "$@&%"):
return find_file(
name,
str(self.root_folder),
base_dir,
self.get_resolvable_command_line_variables(),
variables,
file_type,
)

return find_file_ex(name, base_dir, file_type)
return find_file(
name,
str(self.root_folder),
base_dir,
self.get_resolvable_command_line_variables(),
variables,
file_type,
)

def __find_resource_simple(
self,
Expand All @@ -1111,7 +1096,6 @@ def find_variables(
name,
base_dir,
variables,
resolve_variables,
resolve_command_line_vars,
)
return self._variables_files_cache.get(self.__find_variables_simple, name, base_dir)
Expand All @@ -1122,25 +1106,15 @@ def __find_variables(
name: str,
base_dir: str,
variables: Optional[Dict[str, Any]] = None,
resolve_variables: bool = True,
resolve_command_line_vars: bool = True,
) -> str:
if resolve_variables and contains_variable(name, "$@&%"):
return find_variables(
name,
str(self.root_folder),
base_dir,
self.get_resolvable_command_line_variables() if resolve_command_line_vars else None,
variables,
)

if get_robot_version() >= (5, 0):
if is_variables_by_path(name):
return find_file_ex(name, base_dir, "Variables")

return name

return find_file_ex(name, base_dir, "Variables")
return find_variables(
name,
str(self.root_folder),
base_dir,
self.get_resolvable_command_line_variables() if resolve_command_line_vars else None,
variables,
)

@_logger.call
def __find_variables_simple(
Expand All @@ -1149,6 +1123,12 @@ def __find_variables_simple(
base_dir: str,
) -> str:

if get_robot_version() >= (5, 0):
if is_variables_by_path(name):
return find_file_ex(name, base_dir, "Variables")

return name

return find_file_ex(name, base_dir, "Variables")

@property
Expand Down

0 comments on commit ce787b2

Please sign in to comment.