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

Use module hierarchy proximity in finding relevant schema #179

Open
radeksimko opened this issue Jun 24, 2020 · 0 comments
Open

Use module hierarchy proximity in finding relevant schema #179

radeksimko opened this issue Jun 24, 2020 · 0 comments
Labels
enhancement New feature or request modules Functionality related to the module block and modules generally

Comments

@radeksimko
Copy link
Member

Because detection of the relevant root module for a file/dir is not a trivial task, #176 introduces new functionality which reports all potential candidates for root modules in the context of a directory being initialized/opened, matches the first one and displays warning when there is more than 1.

Picking the right root module from a list of candidates is something that #176 does not solve yet, because there is a number of different factors which may play role in picking.

Use-cases

Assuming the root (.) below is the root being opened in the IDE:

.
|-- .terraform
|-- module-one
|   `-- main.tf
|-- main.tf
`-- module-two
    |-- .terraform
    |-- main.tf
    `-- module-three
        `-- main.tf

both the ./main.tf and ./module-two/main.tf reference module-three, and both are initd.

The user will in this case receive a warning, module-two was found as an alternative root module and LS picked the root (.), which in most cases is probably wrong choice.

Proposal

We can assume that the reference in the above example in ./module-two/main.tf is more relevant, because it's just 1 level away. In case where module-three is initd itself, then that becomes the best (and only) candidate for "itself".

Generally the fewer directories in the hierarchy away from the file being opened, more relevant the root module should be.

This still probably leaves room for some unsolvable situations, where 2+ directories are on the same level, but that ambiguity can be solved by further sorting candidates using different techniques.

References

#32
#176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request modules Functionality related to the module block and modules generally
Projects
None yet
Development

No branches or pull requests

1 participant