robocorp / robotframework-lsp

Robocorp extensions for VS Code: Robocorp Code and RFW LSP
https://robocorp.com/docs/developer-tools/visual-studio-code
Apache License 2.0
206 stars 94 forks source link

Automatic refresh of libdoc from Remote libraries #518

Open DanielPenning opened 2 years ago

DanielPenning commented 2 years ago

Describe the bug Remote Libraries are well supported within Robot Framework Language / VSCode. Keywords are discovered and their documentation is available. However this information is not updated when the remote library changes.

To Reproduce Steps to reproduce the behavior:

  1. Create a minimal remote library with Keyword A and start a server for it
  2. Create a new .robot file that uses this remote library with Library Remote 127.0.0.1:8270
  3. Keyword completion for Keyword A is available.
  4. Shut down the server and add a second Keyword B to the library. Start the remotserver again.

Expected behavior Keyword completion for Keyword A and Keyword B should be available. However Keyword B is not found. When removing the Library-setting in the .robot file, both keywords are not found - which is correct. However after re-adding the Library-setting, again only Keyword A is found.

It appears that the libdoc is somewhere cached and not re-generated. It would be great if either

Note that for local libraries, the keyword completion already automatically discovers the change.

Versions:

fabioz commented 2 years ago

The problem with remote libraries is that it's indeed hard to know when to refresh it (because the libspec is generated without a reference to the actual sources, even if it's locally installed).

For clearing the cache, there's already an issue to handle that: https://github.com/robocorp/robotframework-lsp/issues/498 (it's already high-priority, so, it should be handled soonish).

In the meanwhile, you can erase the .libspec files manually to have them regenerated.

i.e.:

Open the folder below and erase all the RemoteXXXX.libspec files from it.

~/.robotframework-ls/specs/v2/<python_hash>/user/

Note: you don't want to delete the spec files under /builtins, only under /user (unless you plan to restart the language server -- if that's the case than you can erase all the contents from ~/.robotframework-ls/specs/v2).

Note: <python_hash> is a hash which identifies the python installation (so, you may have multiple in your local machine).

As for having the libdoc refreshed automatically after a given timeout, I'm not sure, I'll leave the issue open to think about it (the problem with that is that unless you have a really small timeout, you'll always see the libspec missing some info for some time and I suspect that in general the manual clear would be better -- implementation-wise having that automatically done would work, but I'm not sure it'd be great performance-wise).

DanielPenning commented 2 years ago

@fabioz I just had a chance to test v0.35. The new command robot.clearCachesAndRestartProcesses works exactly as desired. This solves my problem. Thanks!