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

Support splat expressions (*) #526

Open
radeksimko opened this issue May 20, 2021 · 0 comments
Open

Support splat expressions (*) #526

radeksimko opened this issue May 20, 2021 · 0 comments
Assignees

Comments

@radeksimko
Copy link
Member

radeksimko commented May 20, 2021

Depends on #492

This should most likely be implemented after #527


Background

Terraform supports splat expressions. For example:

  • var.list[*].id
  • var.list[*].interfaces[0].name
  • var.website[*]

Language server currently doesn't support these, which means that e.g.

  • we don't provide completion within a splat expression
  • we don't display any details (such as type or description) on hover over splat expressions
  • valid splat expressions are not highlighted via semantic tokens

Proposal

Completion

Relevant suggestions are provided via completion after . or when explicitly requested within a splat expression.

For example, given a variable

variable "list" {
  type = list(object({
    id = string
    name = string
  }))
}

user can type

var.list[*].

at which point two suggestions would come up:

  • id string
  • name string

Hover

Details (type, description) about a splat expression are displayed on hover.

For example, given this config

variable "list" {
  type = list(object({
    id = string
    name = string
  }))
}

output "example" {
  value = var.list[*].id
}

we display var.list[*] list of string.

Semantic Tokens

The splat operator * is recognized as such and reported as a semantic token to be highlighted accordingly.

For example in this config

output "example" {
  value = var.list[*].id
}

(the value part is already reported as attribute),var, list and id will be reported as traversal steps, and * as splat operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants