-
Notifications
You must be signed in to change notification settings - Fork 126
Stop filtering ghost locations from cmt/cms files #3137
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
Conversation
1d754ba to
0568366
Compare
0568366 to
02cae45
Compare
Parser Change ChecklistThis PR modifies the parser. Please check that the following tests are updated:
This test should have examples of every new bit of syntax you are adding. Feel free to just check the box if your PR does not actually change the syntax (because it is refactoring the parser, say). |
|
I'd be roughly in favor of continuing to filter |
|
@ncik-roberts I think you're right. I've talked myself out of thinking that it is important for Merlin to do the filtering. |
|
After discussion, we agreed that @liam923 would check build artifact sizes before merging. |
7be216c to
dc76be7
Compare
|
I've completed the benchmarking, and we've decided that the artifact size increase is relatively minimal. |
This PR changes cmt and cms files to include the locations of all identifier occurrences. This is different from before, where locations with
loc_ghost = trueare filtered out. The onus would then fall on Merlin to filter out occurrences of identifiers that shouldn't be displayed to users.The immediate motivation for this change is to make project-wide occurrences work with punned let expressions. Currently, since the expression side of lets are marked ghost, they are filtered out from occurrences. One solution would be to continue filtering ghost locations, but add some sort of logic that special-cases the expression of a punned let. However, the solution that @ncik-roberts and I came up with is to instead filter locations that are not
Location.none. Our reasoning is that user probably do actually want to see occurrences that are marked as ghost (for example, in ppx generated code) if there is a reasonable location in the source code to point to.Regardless, I think filtering of locations should ultimately be handled by Merlin. If we want to iterate on what locations we choose to filter, it is much easier to change only Merlin rather than both Merlin and the compiler. This comes at a slight cost - cms/cmt files may be bloated with locations that we don't really care about, and the filtering will slow Merlin down slightly since that filtering is no longer done in a preprocessing step. But I think both of these costs are fairly small. With no evidence to back up my claim, I believe the number of ghost locations is likely small relative to non-ghost locations. And that Merlin slowdown it probably negligible compared to, say, serializing the locations after filtering.
This PR necessitates a corresponding change in Merlin because Merlin currently unconditionally includes all occurrences reported by the compiler via cms/cmt files. Thus, Merlin now needs to filter locations read from cms/cmt files. This is done in: oxcaml/merlin#110