Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Marks search-based usages as definitions or references#63576

Merged
kritzcreek merged 2 commits intomainfrom
christoph/search-based-symbol-kind
Jul 2, 2024
Merged

Marks search-based usages as definitions or references#63576
kritzcreek merged 2 commits intomainfrom
christoph/search-based-symbol-kind

Conversation

@kritzcreek
Copy link
Contributor

@kritzcreek kritzcreek commented Jul 1, 2024

Closes https://linear.app/sourcegraph/issue/GRAPH-712/determine-usage-kind-for-search-based-usages-by-running-symbol-search

We do this by running a type:symbol search and marking all overlapping results as definitions

Test plan

Here's an example query to run in the API console

@cla-bot cla-bot bot added the cla-signed label Jul 1, 2024
@github-actions github-actions bot added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform labels Jul 1, 2024
@kritzcreek
Copy link
Contributor Author

I might've out-gitted myself and needed to reflog my way out :D

Copy link
Contributor

@varungandhi-src varungandhi-src left a comment

Choose a reason for hiding this comment

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

Looks OK but let's reduce the code duplication

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be taking in a commit parameter similar to the function above or is that deliberately omitted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Before this call, it might be useful to do something like:

trace = trace.With(log.String("language", language), log.String("symbolName", symbolName), log.Int("syntacticUploadID", syntacticUploadID))

This will create a new TraceLogger which auto-attaches the supplied values to subsequent messages (such as the Warn call)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be taking in a commit parameter similar to the function above or is that deliberately omitted?

It's delibarately omitted. Specifying a rev parameter on a symbol seemingly makes it return nothing, but now that I think about it that would mean we should only do definition detection for current HEAD. I'll take another look at what the webapp does.

Copy link
Contributor

Choose a reason for hiding this comment

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

Specifying a rev parameter on a symbol seemingly makes it return nothing

That shouldn't be happening 🤔 For example:

https://sourcegraph.sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/sourcegraph/conc%24+rev:v0.3.0+type:symbol+Pool&patternType=keyword&sm=0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm very confused still, but you're right in all my current testing it's fine to filter by rev for symbol search. I've unified the query generation and search arguments.

Copy link
Contributor

Choose a reason for hiding this comment

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

Normally I'd suggest following a rule of 3, but given that the implementation is largely the same as that for findCandidateOccurrencesViaSearch (and AFAICT we don't expect it to change much in the future), thoughts on combining the implementation for the two?

We do this by running a type:symbol search and marking all overlapping
results as definitions
@kritzcreek kritzcreek force-pushed the christoph/search-based-symbol-kind branch from 0961577 to db58003 Compare July 2, 2024 04:37
Also adds back commit filtering for symbol search
@kritzcreek kritzcreek enabled auto-merge (squash) July 2, 2024 07:54
@kritzcreek kritzcreek merged commit 2f609e2 into main Jul 2, 2024
@kritzcreek kritzcreek deleted the christoph/search-based-symbol-kind branch July 2, 2024 08:05
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