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

Introduce support for self.* references #163

Merged
merged 10 commits into from
Nov 24, 2022
Merged

Introduce support for self.* references #163

merged 10 commits into from
Nov 24, 2022

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Nov 23, 2022

Architecture Background

One vs Two schema flags (targets vs origins)

Originally the hope/plan was to have just a single "flag" in the schema under the Extensions - SelfRef: true, just like we have for Count and ForEach and will have for dynamic blocks. However, it turns out that isn't most practical. This is because we collect reference targets with the appropriate addresses separately from origins and because we would have to traverse through the rest of a potentially deeply nested and long block, to find out whether a particular target needs a local self address or not.

So we instead introduce the additional DependentBodySelfRef: true which implies that any attributes and blocks within the body will be collected as a target with an additional self.* local address. This will then be enabled for Terraform within the resource and data blocks and allows us to do the target collection without knowing whether that address is needed or not in the rest of the block.

Contextual Address

Since reference targets can now have both local (LocalAddr) and "absolute" (Addr) address, this needs to be considered when rendering the address in completion, hover and elsewhere. In Terraform, self.* addresses are relevant under provisioner, connection and some other blocks, and the assumption is that these refer to the outermost block/body, i.e. resource block.

UX Impact

Completion

2022-11-24 12 45 19

Hover

Screenshot 2022-11-24 at 12 45 54

Go-to-*

2022-11-24 12 47 20

Semantic Token Highlighting

Screenshot 2022-11-24 at 12 48 22

@radeksimko radeksimko added the enhancement New feature or request label Nov 23, 2022
@radeksimko radeksimko mentioned this pull request Nov 23, 2022
12 tasks
@radeksimko radeksimko marked this pull request as ready for review November 24, 2022 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants