Repository navigation
Index all paths components - #13848
Conversation
Now that we have locations for all longident components, we can add these to the index for tools to be able to provide project-wide occurrences and renaming of these modules.
636bbb0 to
82f255c
Compare
| Approximated: Index_aliases.22 : | ||
| X.F (File "index_aliases.ml", line 48, characters 14-17) | ||
| Alias: Index_aliases.24 -> Alias: Index_aliases.23 -> Approximated: Index_aliases.22 | ||
| : |
There was a problem hiding this comment.
That looks like a flaw in the printer.
| | Longident.Lapply (lid', lid''), Path.Papply (path', path'') -> | ||
| index_components module_ lid'' path''; | ||
| index_components module_ lid' path' | ||
| | _, _ -> |
There was a problem hiding this comment.
I would propose to keep the Lident _ case explicit to make the cases commutative.
There was a problem hiding this comment.
Not exactly, but I agree that expanding the non-diagonal case might be a mouthful, so I am fine with either this version or the previous one.
Octachron
left a comment
There was a problem hiding this comment.
I agree that extending the occurrence table to track all components of Longindent.t is reasonable. Moreover, since this is only enabled with the -bin-annot-occurences flag, the quick benchmark in the PR is enough as a performance sanity check.
| | Longident.Lapply (lid', lid''), Path.Papply (path', path'') -> | ||
| index_components module_ lid'' path''; | ||
| index_components module_ lid' path' | ||
| | _, _ -> |
There was a problem hiding this comment.
Not exactly, but I agree that expanding the non-diagonal case might be a mouthful, so I am fine with either this version or the previous one.
Now that we have comprehensive locations stored in longidents, we can add all occurences of modules appearing in paths to the cmt's index.
This will enable external tools to provide full support for modules in project-wide features such as listing occurrences and renaming. Right now, these are restricted to direct module usages.
This PR simply adds a loop during the indexing that iterats on longidents to reduce all associated sub-path's shapes. This process is not as expensive as it appears due to the global memoization of shape reduction in the compiler. In fact, I found no meaningful difference when timing the build of the compiler:
Edit: I just realised that my benchmarks are actually meaningless since the feature is not activated in the compiler builds, I will do new ones.
Edit2: Again, in the new benches, no remarkable performance impact:
make world.opt --jobs 16 && (cd testsuite && make all-shape-index)make world.opt --jobs 16 && (cd testsuite && make all-shape-index)Cmt sizes increase from 51004 (bytes?) to 51272.