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

earlydecoder/schema: Infer schema for local modules #126

Merged
merged 2 commits into from
Jul 12, 2022

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Jul 11, 2022

Depends on #125


Collecting reference origins in the context of a module block expects the underlying module files to be parsed and metadata to be also available, such that we can use it to construct the dependent schema for inputs.

When walking through the hierarchy we practically cannot guarantee that one module will be indexed before another and re-indexing modules seems wasteful to provide such a guarantee. Prior to hashicorp/terraform-ls#997 we were just mostly lucky this didn't come up.

Therefore this PR proposes adding a "fallback" blind schema for any dependent module, where we don't try to be accurate with types, but essentially infer the schema from the raw configuration. Given that we always re-build the schema prior to completion/hover/etc., we can still provide more accurate schema if it's available.

The only downside is slightly less detailed origins after the collection which won't be re-collected unless something else triggers the re-collection. We could theoretically gather the type for each input as well, but I'm not entirely sure it's worth the effort/CPU given that we'll gather that later (again) anyway.

@radeksimko radeksimko added the enhancement New feature or request label Jul 11, 2022
@radeksimko radeksimko force-pushed the f-local-inferred-mod-schema branch 2 times, most recently from e5f3ea7 to cde0aa8 Compare July 11, 2022 14:07
@radeksimko radeksimko changed the title WIP: Local inferred module schema earlydecoder/schema: Infer schema for local modules Jul 11, 2022
@radeksimko radeksimko marked this pull request as ready for review July 11, 2022 14:13
Copy link
Member

@dbanck dbanck left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@radeksimko radeksimko merged commit 08c17f0 into main Jul 12, 2022
@radeksimko radeksimko deleted the f-local-inferred-mod-schema branch July 12, 2022 13:59
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