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

Provide workspace-wide symbols for variables in tfvars files #658

Closed
radeksimko opened this issue Sep 30, 2021 · 1 comment · Fixed by #689
Closed

Provide workspace-wide symbols for variables in tfvars files #658

radeksimko opened this issue Sep 30, 2021 · 1 comment · Fixed by #689
Labels
enhancement New feature or request workspace/symbol

Comments

@radeksimko
Copy link
Member

radeksimko commented Sep 30, 2021

Use-cases

When navigating through the whole module (represented as "workspace" in LSP) we currently provide navigation through any symbols representing blocks and/or attributes in *.tf files - such as providers, resources and data sources.

Users would benefit from being able to quickly navigate to variables defined in *.tfvars and *.tfvars.json (see also #519)

Proposal

The WorkspaceSymbol (representing workspace/symbol RPC method) will need to be updated, specifically this part

d, err := decoder.DecoderForModule(ctx, mod)
if err != nil {
return symbols, err
}
modSymbols, err := d.Symbols(params.Query)
if err != nil {
continue
}
symbols = append(symbols, ilsp.SymbolInformation(mod.Path, modSymbols,
cc.Workspace.Symbol)...)

We can reuse this function

func DecoderForVariables(varsFiles ast.VarsFiles) (*decoder.Decoder, error) {
d := decoder.NewDecoder()
for name, f := range varsFiles {
err := d.LoadFile(name.String(), f)
if err != nil {
// skip unreadable files
continue
}
}
return d, nil
}
and call the same Symbols method on the decoder and append found symbols to the slice.

@github-actions
Copy link

github-actions bot commented Dec 2, 2021

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 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request workspace/symbol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant