Skip to content
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

Go to variable definition (from local module arg) #670

Closed
radeksimko opened this issue Jun 18, 2021 · 1 comment · Fixed by hashicorp/terraform-ls#700
Closed

Go to variable definition (from local module arg) #670

radeksimko opened this issue Jun 18, 2021 · 1 comment · Fixed by hashicorp/terraform-ls#700
Labels
enhancement New feature or request modules Functionality related to the module block and modules generally terraform-ls Features/bugs which will be implemented/fixed purely on the LS side

Comments

@radeksimko
Copy link
Member

radeksimko commented Jun 18, 2021

Problem Statement

Users which call modules with any arguments may benefit from being able to jump quickly to the definition of the variable from the module call.

User Impact

Any users which use modules with any variables would likely benefit.

Expected User Experience

Cmd/Ctrl+click

For example by clicking to myvar in the following snippet

module "example" {
  source = "./foo-submodule"

  myvar = "test"
}

they would get to the relevant variable block within the ./foo-submodule module:

variable "myvar" {
  type = string
}

See also https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition

ctrlhover

Context menu

Screenshot 2021-06-18 at 15 40 28

AND/OR

Screenshot 2021-06-18 at 15 40 09

(see below)

Blocking Questions

LSP recognizes two concepts that are relevant here - definition and declaration:

For variables in other languages declaration ~= data type and definition ~= value.

Strictly speaking this should therefore probably be implemented as "Go to declaration" unless the variable also has a default, but it's unclear how either of these two methods are surfaced in the VS Code UI, especially when both are in use.

Proposal

  • Introduce lang.ExtReference{ DirPath string, Addr []lang.AddrStep } to hcl-lang
  • Add NameRefersTo *lang.ExtReference to hcl-lang/schema.AttributeSchema
  • Populate NameRefersTo of attributes within DependentBody of module blocks within terraform-schema
@radeksimko radeksimko added enhancement New feature or request terraform-ls Features/bugs which will be implemented/fixed purely on the LS side labels Jun 18, 2021
@danieldreier danieldreier added the modules Functionality related to the module block and modules generally label Jul 23, 2021
@radeksimko radeksimko changed the title Go to variable declaration (from local module arg) Go to variable definition (from local module arg) Aug 5, 2021
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request modules Functionality related to the module block and modules generally terraform-ls Features/bugs which will be implemented/fixed purely on the LS side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants