Closed DanielPenning closed 10 months ago
In RobotFramework, it is possible to create dynamic libraries and parameterize them, as you are doing. Occasionally, libraries may have different keywords depending on the parameters, but this is not very common. That's why the first version of a library is always cached, regardless of the parameters.
To disable caching for a specific library, you can use the setting robotcode.analysis.cache.ignoredLibraries
. The libraries specified here, as the name suggests, will not be cached, and the system will attempt to initialize the library based on the parameters, similar to how Robot Framework does it. However, depending on the library, this process may take a bit longer.
To still cache this dynamic library, what I like to do is create a wrapper library that inherits from the actual library and passes any necessary arguments when needed. This approach is based on the consideration that if a test object (which is essentially what a library is) provides different methods depending on the parameters, then the various parameter combinations represent multiple functional test objects that can be better represented in separate libraries. Hope you understand?
Many thanks for the very prompt feedback.
I did not know about robotcode.analysis.cache.ignoredLibraries
. This is exactly what we need to solve the problem, the time it to (re)load the info is not critical. 👍
Describe the bug When libraries are instantiated with different arguments, RF treats them as separate libraries. Robotcode seems to not differentiate and uses the libdoc cache created for the last library instance. In our library, we provide keywords that are dependent on the arguments the library was initiated with. Syntax highlighting does not work propely for these dependent keywords.
To Reproduce Steps to reproduce the behavior:
KeywordLib.py
: A library that provides keywords dependent on its argument.When I use this library in
TestFirst.robot
, theKeywordLib First
keyword documentation is shown:TestFirst.robot
When I use the libary again in
TestSecond.robot
with a different parameter, robotcode shows the keywordKeywordLib Second
as missing. When I runrobotcode.clearCacheRestartLanguageServers
, the keyword is shown. But switching back toTestFirst.robot
, theKeywordLib First
keyword is shown as missing there.TestSecond.robot
:Expected behavior The libdoc of the specific library instance in the current file should be taken as source for syntax highlighting.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.