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

Code reference for variables from .yml and .yaml files does not work (scalar and collections) #403

Open trybuskrzysztof opened 3 years ago

trybuskrzysztof commented 3 years ago

Describe the bug When importing a yml/yaml file and using variables from this file, there's no option to jump to the source file when ctrl+left clicking on a variable.

To Reproduce

  1. Create a yaml/yml file with a variable, e.g.: "variables_yml.yml" file with:
    variable_yml: 'yml_value'
    list_yml:
    - 'list value 1'
    - 'list value 2'
    - 'list value 3'
    dictionary_yml:
    key1: 'dict value 1'
    key2: 'dict value 2'
    key3: 'dict value 3'
  2. Create a test case file with using variable from yml file, e.g.: "testing_variable_import.robot" with content:
    
    *** Settings ***
    Variables  variables_yml.yml

Test Cases Getting Variables Log To Console ${variable_yml} Log To Console ${list_yml}[1] Log To Console ${dictionary_yml.key2}


3. Try to Ctr+left click on ${variable_yml}, ${list_yml}[1] and ${dictionary_yml.key2} -> "Cannot find declaration to go to" error appears

**Expected behavior**
When ctrl+left clicking on ${variable_yml}, ${list_yml}[1] and ${dictionary_yml.key2} variables, "variables_yml.yml" file should be opened and variable references should be displayed.

**Versions:**
 - OS: Windows 10
 - Robot Framework Version [4.0.1]
 - Robot Framework Language Server Version [0.19.0]
 - Client Version [PyCharm 2021.1.3]

**Screenshots**
![yaml_reference_bug](https://user-images.githubusercontent.com/27352125/127154719-d5c9092a-fedf-4f3c-9686-4f95181b1027.png)
fabioz commented 2 years ago

Note: https://github.com/robocorp/robotframework-lsp/commit/e87d49760c98cd881f7961b948af30825bc87203 has a fix to support yml.

The first 2 cases now seem to work, but the third (${dictionary_yml.key2}) still doesn't because it doesn't understand that the . is meant to access an internal variable of dictionary_yml (so, still leaving issue open).