This repository was archived by the owner on Sep 30, 2024. It is now read-only.
chore: Update main occurrence extraction code to allow for symbol-based matching#64082
Merged
Conversation
varungandhi-src
commented
Jul 25, 2024
varungandhi-src
commented
Jul 25, 2024
ad687f7 to
9ac2306
Compare
varungandhi-src
commented
Jul 25, 2024
Comment on lines
210
to
221
Contributor
Author
There was a problem hiding this comment.
This constructor is not currently used anywhere, but I've kept it in for clarity.
varungandhi-src
commented
Jul 25, 2024
9ac2306 to
51e0d16
Compare
kritzcreek
suggested changes
Jul 26, 2024
kritzcreek
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the clear documentation and factoring. I added a few comments.
kritzcreek
approved these changes
Jul 26, 2024
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
At the heart of the loop for extracting usages across a Sourcegraph instance
is the
extractLocationsFromPositionfunction, which extracts related symbolsand source ranges from a single SCIP Document. (Source ranges for returning
to the user directly, and related symbols to do further lookups, e.g. in the case
of inheritance.)
Since we want to perform matching based on symbol names in the upcoming
precise usagesForSymbol API, and also return symbol names for each associated
source range, this function needs to be updated to:
FindUsagesKeytype which allows two cases - position-based and symbol-based.done by creating a new
UsageBuildertype which somewhat subsumesthe
Locationtype. We avoid copying the same 'UploadID' and 'Path' fieldseagerly for clarity; that will be handled by callers in the future when they
mix
UsageBuildervalues across different Documents (by first callingbuild).For the above, I've introduced a new func
extractRelatedUsagesAndSymbolNames,and
extractLocationsFromPositiondelegates to that. In the future,extractLocationsFromPositionwill be removed.Stepping stone for GRAPH-573
Test plan
Covered by existing tests. I will add more tests once we can pass in a
FindUsagesKeywith a symbol-based
Matcherfrom some other functions higher up in the call chain.