Skip to content

[Enhancement] New keywords not found until cache is manually cleared #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AndersHogqvist opened this issue Mar 6, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@AndersHogqvist
Copy link

Describe the bug
If I write a new keyword in an existing test library and use it in a .robot/resource file, RobotCode doesn't recognize it until I do a "Clear Cache And Restart Language Servers".

Steps To Reproduce
Steps to reproduce the behavior:

  1. Add a new keyword in an existing test library
  2. Add a call to that keyword in a .robot/resource file where the test library is used

Expected behavior
When I save the test library file after adding the new keyword, RobotCode should recognize that a test library that it's already aware of has changed and update the cache automatically. This should also be the case when a keyword is removed.

Desktop (please complete the following information):

  • VS Code Version 1.98.0
  • RobotCode Version 1.0.0
  • OS: Windows
  • Python Version 3.11.9
  • RobotFramework Version 7.2.2
@AndersHogqvist AndersHogqvist added the bug Something isn't working label Mar 6, 2025
@d-biehl
Copy link
Member

d-biehl commented Mar 6, 2025

How did you add the new keyword? There are so many ways to do this.

And where is your repository located and your libraries located, directly on the hard drive?

Sometimes this can happen, because RobotCode listens to file changes from vscode, but vscode is not able to send this everytime because of the location of the repository.

@AndersHogqvist
Copy link
Author

Ok, this might be an edge case maybe. I have a test library that I import like this:

.robot file:

*** Settings ***
Documentation       Test suite for the SwRS tests
Metadata            SemVer    ${SEMVER}

Library             ../../python/SwRSRAE3.py

If I add a keyword in the SwRSRAE3 class it gets picked up by RobotCode without the need to manually clear the cache. However, the keywords I've been adding lately have been added to AgvHelper, a parent class to SwRSRAE3:

SwRSRAE3.py:

"""Module containing the keywords for the SwRS RAE 3 test suite"""

import random
import time

import AgvHelper
from robot.api.deco import keyword, library, not_keyword
from robot.api.exceptions import Failure

@library
class SwRSRAE3(AgvHelper.AgvHelper):

@d-biehl
Copy link
Member

d-biehl commented Mar 10, 2025

Currently, RobotCode only has access to information provided by Libdoc, which includes the file or module where the keyword class is defined. It does not, however, have insight into the internal structure of a class, such as parent classes and their respective file locations.

If you import a library as a file (as shown in the example above), RobotCode can only track changes in that specific file. Consequently, if you modify keywords within a parent class located in a separate file, RobotCode won't be able to detect those changes.

On the other hand, if you import your library as a Python module—which is the recommended approach—RobotCode attempts to track all files belonging to that module and monitors changes across all related files.

For details on different ways to import libraries in Robot Framework, see the official documentation.

I'm currently unable to confirm whether this approach fully addresses your issue due to limited investigation time. Given this uncertainty, the issue cannot be immediately resolved, but I will reclassify it from a bug to an enhancement. We might revisit this once the planned rewrite of Robot Framework's import functionality is complete.

@d-biehl d-biehl changed the title [BUG] New keywords not found until cache is manually cleared [Enhancement] New keywords not found until cache is manually cleared Mar 10, 2025
@d-biehl d-biehl added enhancement New feature or request and removed bug Something isn't working labels Mar 10, 2025
@AndersHogqvist
Copy link
Author

I've added the path to the Python Path:

"robotcode.robot.pythonPath": [
"HIL-rig/python"
]

Then I changed the import to

Library        SwRSRAE3

A newly created keyword in the parent class of SwRSRAE3 was immediately picked up by RobotCode, but any subsequent changes or keyword additions in the file where not.

However, it's not a show stopper by any means so I completely understand if this goes to the bottom part of your priority list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants