Skip to content
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
varungandhi-src merged 3 commits into
mainfrom
vg/update-extraction
Jul 26, 2024
Merged

chore: Update main occurrence extraction code to allow for symbol-based matching#64082
varungandhi-src merged 3 commits into
mainfrom
vg/update-extraction

Conversation

@varungandhi-src

@varungandhi-src varungandhi-src commented Jul 25, 2024

Copy link
Copy Markdown
Contributor

At the heart of the loop for extracting usages across a Sourcegraph instance
is the extractLocationsFromPosition function, which extracts related symbols
and 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:

  1. Be able to take a symbol name for doing lookups. This is done using the new
    FindUsagesKey type which allows two cases - position-based and symbol-based.
  2. Be able to return symbol names associated with every source range. This is
    done by creating a new UsageBuilder type which somewhat subsumes
    the Location type. We avoid copying the same 'UploadID' and 'Path' fields
    eagerly for clarity; that will be handled by callers in the future when they
    mix UsageBuilder values across different Documents (by first calling build).

For the above, I've introduced a new func extractRelatedUsagesAndSymbolNames,
and extractLocationsFromPosition delegates to that. In the future,
extractLocationsFromPosition will be removed.

Stepping stone for GRAPH-573

Test plan

Covered by existing tests. I will add more tests once we can pass in a FindUsagesKey
with a symbol-based Matcher from some other functions higher up in the call chain.

@cla-bot cla-bot Bot added the cla-signed label Jul 25, 2024
@github-actions github-actions Bot added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform labels Jul 25, 2024
Comment thread internal/codeintel/codenav/shared/types.go Outdated
Comment thread internal/codeintel/codenav/shared/types.go Outdated
Comment on lines 210 to 221

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructor is not currently used anywhere, but I've kept it in for clarity.

Comment thread internal/codeintel/codenav/internal/lsifstore/store.go Outdated

@kritzcreek kritzcreek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clear documentation and factoring. I added a few comments.

Comment thread internal/codeintel/codenav/internal/lsifstore/store.go Outdated
Comment thread internal/codeintel/codenav/internal/lsifstore/store.go
Comment thread internal/codeintel/codenav/shared/types.go Outdated
@varungandhi-src varungandhi-src merged commit 6d981c6 into main Jul 26, 2024
@varungandhi-src varungandhi-src deleted the vg/update-extraction branch July 26, 2024 10:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants