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
205 stars 93 forks source link

Multiple libraries with same or similar keywords don't include preamble on selection #709

Open Alan-Carr opened 2 years ago

Alan-Carr commented 2 years ago

I have a number of libraries which contain same or similair keywords and I use these depending on the requirement.

I have "Click" for Sikuli and RPA.Windows and RPA.Desktop Whilst the autocomplete popup shows the different versions and I can select which one I require the argument is shown correctly however the different keywords do not show the preamble to the correct library eg RPA.Windows.Click or RPA.Desktop.Click

fabioz commented 2 years ago

@Alan-Carr I'm sorry, I didn't really understand what do you mean about preamble in this context... Can you show a screenshot showing what should be different here?

Alan-Carr commented 2 years ago

I am using Click in my robot scripts from different libraries as they have different functionality. Click from Sikulix requires an Image argument and Click from RPA.Windows requires an id

After selecting the correct Click from the popup
2022-07-21_11h34_45

The correct argument is shown within the editor 2022-07-21_11h45_18

In other editors the keyword would show as RPA.Windows.Click or Sikulix.Click image

the ls framework executes the correct library / click however when looking at the script the user doesn't know which library is being used however they can tell by the argument. Furthermore when hovering over either of the two keywords in my example the pop up always shows Sikulix however one is using Silulix and the other RPA.Windows.

One last question is there anyway to show all keywords and there required arguments within VSC / ls such that I can pick what keyword I require.

fabioz commented 2 years ago

I was thinking about this... this would probably require a setting.

The way that it works now is that after you select Click in the example it'll add the library:

*** Settings ***
Library    RPA.Desktop

and it'll then complete regularly as Click.

What you'd like is that it added the library and completed as RPA.Desktop.Click.

I think there are users which would like the current behavior more and users which would like the completion to be full (I guess it's mostly a matter of taste).

Completing with the full name does have the advantage of not having any conflicts though -- because if you have 2 libraries imported which implement a keyword with the same name, the full name is needed to avoid something as:

Multiple keywords with name 'Method As Keyword' found. Give the full name of the keyword you want to use:
    mylib.Method As Keyword
    mylib2.Method As Keyword
Alan-Carr commented 2 years ago

Currently I have the 3 libraries which have Click as keyword, from the popup I can select the RPA.Windows version this then shows in VSC with the correct Argument.
image

However when the script executes it errors

image

Thus I have to manually enter my keyword as

image

Furthermore If I select the RPA.Desktop version this then shows without its argument. If I select the Sikuli version this then shows the correct argument.

Hovering over the RPA.Windows Click, the popup shows the format of the Sikuli Click. image

Kaflak commented 1 year ago

Hello @fabioz,

For me such feature will be also valid to have possibility to add Library name to Keyword, especially that SSHLibrary and Telnet library has same Keywords and many times when I use robotframework-lsp then I faced similar issues like Alan. eg:

Telnet.Read Until Prompt
SSHLibrary.Read Until Prompt 

If I use only Read Until Prompt there will be error in execution that robot don't have information which keyword should be used.

It will be nice if there will be possibility to enable option that automatically library will be added to Keyword definition. It will be good if such settings will have 3 options: never(default), only when conflicts discovered, always If this will be hard to implement then option Always add library or resource name to keyword will be enough for me.

BR Marek