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

New Code Action: Generate local value declaration for an orphaned local.* reference #1564

Open
1 task
radeksimko opened this issue Jan 5, 2024 · 0 comments
Labels

Comments

@radeksimko
Copy link
Member

Background

The existing validation logic currently aids users by reporting references to undeclared variables, such as below.

Screenshot 2024-01-05 at 17 06 43

There can be different reasons behind an "orphaned" reference (reference without corresponding declaration). It could be a result of an intentional removal. But it can also be because the user started using variable reference before declaring it.

The server could help in the latter case by generating the local value declaration for the user.

For example, user may start with:

output "example" {
  value = local.foo
}

and want to end up with:

locals {
  foo = "value"
}

output "example" {
  value = local.foo
}

Proposal

  • Provide quickfix code action for any undeclared local.* references which will generate locals entry with the empty value based on constraints surrounding the reference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant