Use module hierarchy proximity in finding relevant schema #179
Labels
enhancement
New feature or request
modules
Functionality related to the module block and modules generally
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:both the
./main.tf
and./module-two/main.tf
referencemodule-three
, and both areinit
d.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 wheremodule-three
isinit
d 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
The text was updated successfully, but these errors were encountered: