-
Notifications
You must be signed in to change notification settings - Fork 313
wit-parser: Add validation hooks for custom linting
#2419
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
base: main
Are you sure you want to change the base?
wit-parser: Add validation hooks for custom linting
#2419
Conversation
wit-parser: Add validation hooks for custom linting
|
Redirecting review because I'm not familiar with |
wit-parser: Add validation hooks for custom lintingwit-parser: Add validation hooks for custom linting
|
Apologies for the delay in reviewing this, it's been a busy week! This is a conceptually large enough change that the design in this PR isn't a slam-dunk to me just yet, and it might still be worth considering some of the other options that you laid out. Could you describe your end goal with this a bit more to help shape the thinking there? For example what are you looking to do with spans after a |
|
No problem! Thanks for the response. I totally understand wanting to consider other options that's why I tried to explore and present a few. Not sure if you clicked the links but they lead to diffs with all the changes made for that strategy. The So the first strategy is about making The second strategy, the PR, is allowing consuming code to hook into the resolution process to add additional validation rules at a point in the lifecycle where the |
#2418
There are two strategies I've explored for giving consumers access to source locations:
Make spans available on resolved items so consumers can inspect them after resolution. There are two ways I found to do this
span: Option<Span>directly toTypeDef,Function,Interface,WorldHashMap<Id, Span>fields onResolveResolvederivesDefaultso not likely to break consumers)Hook into internal validation (this PR)
Keep spans private but let consumers hook into the resolution process via a
Validatortrait with callbacks.push_*calls, not after-the-fact inspectionThis PR implements Strategy 2 because it avoids breaking changes and has zero cost for existing. However, I'm happy to go with one of the other strategies or something totally new that I haven't considered.
Here's an example of how a consumer would use this new features: