-
Notifications
You must be signed in to change notification settings - Fork 180
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 references #651
Comments
The "Go To References" part (where you can bring up a list of references via context menu) was implemented in language server 0.19.0 (released today) as part of hashicorp/terraform-ls#572 and hashicorp/terraform-ls#580 Code lens is currently being worked on. |
This was implemented as part of #686 which was shipped in extension version There are further planned improvements in this area - feel free to subscribe to any of these issues
or open a new one if the problem/feature isn't described in any of them. |
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. |
Problem Statement
Terraform allows referencing other pieces of config, or the data the config is referring to.
For example a variable can be referenced via
var.name
:Users would benefit from:
variable "test"
block to anyvar.test
occurrences.Technical Details
Code Lens (annotation w/ number of references)
This should be achievable via Code Lens which are part of the LSP:
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeLens
This allows us to associate an "annotation" with a range of code and a command to be executed when the user clicks on the "annotation". In this case the code range may include the block header (block type + any labels).
Go To References
This is also part of LSP:
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
User Impact
Referencing is an essential part of Terraform language that many users use, and so most users would likely benefit from this feature.
This feature was also part of the VS Code extension v1 version.
Users reported this via GitHub:
Expected User Experience
Code Lens
User will see
N references
annotation above any block that is referenced at least once anywhere else in the module.For more than 1 reference, user will be able to pick which reference to navigate to.
Go To References
User will be able to right-click to a block header and pick "Go to references", which will bring the IDE-native dialog for references.
Proposal
CollectReferenceOrigins(filename string) (ReferenceOrigins, error)
tohcl-lang
decoderlang.Reference
tolang.ReferenceTarget
ReferenceTargetAtPos(filename string, pos hcl.Pos) lang.ReferenceTarget
ReferenceOrigins.MatchingAddress(addr lang.Address) lang.ReferenceOrigins
textDocument/references
which will callReferenceTargetAtPos
and use the obtainedReferenceTarget.Address
to filter out persisted reference origins in module state viaReferenceOrigins.MatchingAddress
Blocking Questions
The text was updated successfully, but these errors were encountered: