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

Implement for_each and each.* completion, hover info, and semantic tokens #145

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

jpogran
Copy link
Contributor

@jpogran jpogran commented Oct 25, 2022

This provides completion hints inside blocks for for_each and each.* references within resource, data and module blocks anywhere the for_each meta-argument is supported. It detects if for_each is used already and does not suggest duplicates and detects when it is necessary to provide each.* completions. This does not complete the values for each.key and each.value, e.g. each.value.something.

This also provides hover support for for_each and each.* references using the documentation as source.

This also provides semantic token support for for_each and each.* references.

Closes hashicorp/terraform-ls#861

decoder/decoder.go Outdated Show resolved Hide resolved
@jpogran jpogran marked this pull request as ready for review October 25, 2022 16:48
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking pretty good. Aside from my in-line comments we're also missing hover tests.

On the note of testing - in general, when I'm unsure what needs testing, I'd use the coverage report which is built into Go:

go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

https://go.dev/blog/cover

That's not to say I'd expect you to cover 100%, but I think it can provide a good guidance.

decoder/body_candidates.go Outdated Show resolved Hide resolved
decoder/candidates.go Outdated Show resolved Hide resolved
decoder/decoder.go Outdated Show resolved Hide resolved
decoder/decoder.go Outdated Show resolved Hide resolved
decoder/decoder.go Outdated Show resolved Hide resolved
decoder/semantic_tokens.go Show resolved Hide resolved
decoder/semantic_tokens.go Outdated Show resolved Hide resolved
decoder/semantic_tokens.go Outdated Show resolved Hide resolved
decoder/body_extensions_test.go Outdated Show resolved Hide resolved
decoder/body_extensions_test.go Outdated Show resolved Hide resolved
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question left about the test, otherwise LGTM.

If you could also squash the commits before merging, that would be great.

decoder/hover_test.go Outdated Show resolved Hide resolved
decoder/body_extensions_test.go Show resolved Hide resolved
This provides completion hints inside blocks for `for_each` and `each.*` references within `resource`, `data` and `module` blocks anywhere the `for_each` meta-argument is supported. It detects if `for_each` is used already and does not suggest duplicates and detects when it is necessary to provide `each.*` completions. This does not complete the values for `each.key` and `each.value`, e.g. `each.value.something`.

This also provides hover support for `for_each` and `each.*` references using the documentation as source.

This also provides semantic token support for `for_each` and `each.*` references.

Closes hashicorp/terraform-ls#861
@jpogran jpogran merged commit b8c8114 into main Oct 28, 2022
@jpogran jpogran deleted the foreach_each_extensions branch October 28, 2022 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support each.* references in blocks w/ for_each
2 participants