feat: use compiler tracers for project indexing#705
Draft
doorgan wants to merge 1 commit into
Draft
Conversation
2b073da to
da72261
Compare
da72261 to
a83aeef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Very early WIP
The main idea of this PR is that we can use Compiler Tracers for all compiled files like NextLS does. This allows us to index definitions and references as the project compiles rather than as a separate step. As a consequence, the indexer no longer goes over .ex files, as those are compilable, and indexes all .beam files instead if a compiler tracer missed them.
Compiler tracers seem to provide all the information we need: aliases, alias references, remote/imported functions/macros, local functions/macros, struct expansion, and definitions(via the module's compiled bytecode), which in principle should allow us to skip indexing from source code, or in the worst case scenario reduce the source analysis to range refinement, which is faster than full AST analysis.
For non-compiled files like .exs scripts and tests, we still run the source code based indexer so we don't lose support for those.
Roughly speaking this works as follows:
Later on for 0.4 we will want to investigate using the compiler locks to share the expert build with the user builds and save repeated work. That would be partially incompatible with compiler tracers because a user triggered build will not send the compiler tracer events to expert. In that case we want to also have the ability to index what's missing after compilation, and this PR should set the foundations for that.
There are a lot of rough edges I'm still figuring out, but the bare minimum is working.