-
Notifications
You must be signed in to change notification settings - Fork 132
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
Walk hierarchy to add root modules #176
Conversation
This comment has been minimized.
This comment has been minimized.
@FernandoMiguel Just to be clear the example I mentioned above isn't assuming any particular filenames. It's just an example. I will lock this thread temporarily until we iron out the implementation details as it's not quite ready yet for wider public consumption. Generally though feedback related to different hierarchies is welcomed in #32 Thanks. |
66db19e
to
a40c1c9
Compare
Because detection of the relevant root module for a file/dir is a non trivial task, we also introduce candidate finder which can report all potential candidates for root modules in the context of a directory being initialized/opened.
a40c1c9
to
6c152a3
Compare
This turns lookups from O(1) to O(n), but the n is in most cases so low that it likely doesn't matter anyway.
This should provide some details about what kind of hierarchies will be supported when this PR is merged: |
Co-authored-by: Paul Tyng <ptyng@hashicorp.com>
} | ||
|
||
func renderCandidate(rootDir, path string) string { | ||
return strings.TrimPrefix( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there is a better filepath
func to do this to get the relative path? String manipulation feels wrong but maybe its fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it does not feel quite right, but I couldn't find filepath.TrimPrefix
or anything similar.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
This aims to solve some scenarios outlined in #32
Because detection of the relevant root module for a file/dir is a non trivial task, I also introduce candidate finder which can report all potential candidates for root modules in the context of a directory being initialized/opened.
The following factors may play role in deciding about the right root module:
Whether the root module was initialized at all (REQUIREMENT)
This is a hard requirement, at least for now. i.e. Root module has to be
init
d before it's even considered as a candidate (i.e. it has to have.terraform
). The module cache provides enough details about module hierarchy in a very efficient and simple way.Plugin Version Proximity (NOT IMPLEMENTED)
#180
Hierarchy Proximity (NOT IMPLEMENTED)
#179
Before the above detection is implemented we just return the first positive match (in whatever order
filepath.Walk
finds it) and display a warning in case there is more than 1 match.The only awkward thing is that every IDE implements
windows/showMessage
differently. I assume they just work within the constraints of the client API 🤷VSCode
Sublime Text
NeoVim