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

codeintel: make usage-range non-optional#64236

Merged
kritzcreek merged 4 commits into
mainfrom
christoph/usage-range-non-optional
Aug 2, 2024
Merged

codeintel: make usage-range non-optional#64236
kritzcreek merged 4 commits into
mainfrom
christoph/usage-range-non-optional

Conversation

@kritzcreek

@kritzcreek kritzcreek commented Aug 2, 2024

Copy link
Copy Markdown
Contributor

Closes https://linear.app/sourcegraph/issue/GRAPH-727/make-range-for-usagerange-non-optional

@camdencheek I'm not sure what changes the client requires after merging this PR. Would you prefer I merge here and you make a separate one, or would you rather push the changes onto this branch and merge in one go?

Test plan

Tests continue to pass

@github-actions

github-actions Bot commented Aug 2, 2024

Copy link
Copy Markdown
Contributor

✅ Cloud Controller GraphQL Compatability Test Result

sourcegraph/controller uses the GraphQL API to perform automation. The compatibility test has passed.

Learn more from workflow logs.

@github-actions github-actions Bot added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform labels Aug 2, 2024
@varungandhi-src

Copy link
Copy Markdown
Contributor

Changing usageRange! -> usageRange in ExplorePanel*.svelte should be enough

# Invariant: `range.path` == `blob.path`. The path is made available
# as part of this type for convenience.
# """
usageRange: UsageRange

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.

I think this signature will need to change:

UsageRange(context.Context) (UsageRangeResolver, error)

It needs to return a UsageRangeResolver now, similar to the other non-optional fields.

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.

On second glance, it seems a bit weird that we're allowed to have:

Provenance(context.Context) (codenav.CodeGraphDataProvenance, error)

even thought that field is non-optional. Maybe the point is that returning an error will keep bubbling it up until the first optional field? 🤔

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.

Thanks

const repoGroups: RepoGroup[] = []

for (const usage of usages) {
const repo = usage.usageRange!.repository

@varungandhi-src varungandhi-src Aug 2, 2024

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.

There are also similar usageRange! accesses in ExplorePanelFileUsages.svelte

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.

I think I'd need to find the place the type for usageRange is defined, and then I'd get lint warnings for unnecessary !s everywhere.

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.

If you regenerate graphql-operations.ts, then you should get that.

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.

I ran all of the sg gen commands and none seem to have worked. I'll back out the .svelte changes and wait for someone from the search team to take a look.

@camdencheek

camdencheek commented Aug 2, 2024

Copy link
Copy Markdown
Member

@kritzcreek I'm happy to follow up with the changes in a second PR. It doesn't look like this PR will actually change how the client needs to call the API, it just lets me get rid of a bunch of non-null assertions

Thanks for the update!

@kritzcreek kritzcreek enabled auto-merge (squash) August 2, 2024 14:26
@kritzcreek kritzcreek disabled auto-merge August 2, 2024 14:26
@kritzcreek kritzcreek enabled auto-merge (squash) August 2, 2024 14:27
@kritzcreek kritzcreek merged commit 7fc92a5 into main Aug 2, 2024
@kritzcreek kritzcreek deleted the christoph/usage-range-non-optional branch August 2, 2024 14:51
camdencheek added a commit that referenced this pull request Aug 2, 2024
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.

3 participants