From d313441f8d0bae5e122b72a52b194535b8b212fa Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Tue, 4 Jun 2024 18:38:49 +0800 Subject: [PATCH] chore(codeintel): usagesForSymbol - make start/end non-optional for now (#63059) We can add support for optional start/end later in a backwards-compatible way. Making these non-optional helps simplify the initial implementation. --- .../graphqlbackend/codeintel.codenav.graphql | 8 +++++--- internal/codeintel/resolvers/codenav.go | 16 ++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cmd/frontend/graphqlbackend/codeintel.codenav.graphql b/cmd/frontend/graphqlbackend/codeintel.codenav.graphql index fcf4c9391395a..eb3e8a070407d 100644 --- a/cmd/frontend/graphqlbackend/codeintel.codenav.graphql +++ b/cmd/frontend/graphqlbackend/codeintel.codenav.graphql @@ -539,12 +539,14 @@ input RangeInput { """ Start position of the range (inclusive) """ - start: PositionInput + # TODO(id: usagesForSymbol-v2) Make this input optional + start: PositionInput! """ End position of the range (exclusive) """ - end: PositionInput + # TODO(id: usagesForSymbol-v2) Make this input optional + end: PositionInput! } """ @@ -602,7 +604,7 @@ input UsagesFilter { an empty value will find results across the Sourcegraph instance. """ repository: RepositoryFilter - # TODO(id: usagesForSymbols-v2) + # TODO(id: usagesForSymbol-v2) # and: [UsagesFilter!] # or: [UsagesFilter!] # path: PathFilter diff --git a/internal/codeintel/resolvers/codenav.go b/internal/codeintel/resolvers/codenav.go index d08ed9cc9b667..9605ed9cc73d2 100644 --- a/internal/codeintel/resolvers/codenav.go +++ b/internal/codeintel/resolvers/codenav.go @@ -352,8 +352,8 @@ type RangeInput struct { Repository string Revision *string Path string - Start *PositionInput - End *PositionInput + Start PositionInput + End PositionInput } func (r *RangeInput) Attrs() (out []attribute.KeyValue) { @@ -362,14 +362,10 @@ func (r *RangeInput) Attrs() (out []attribute.KeyValue) { out = append(out, attribute.String("range.revision", *r.Revision)) } out = append(out, attribute.String("range.path", r.Path)) - if r.Start != nil { - out = append(out, attribute.Int("range.start.line", int(r.Start.Line))) - out = append(out, attribute.Int("range.start.character", int(r.Start.Character))) - } - if r.End != nil { - out = append(out, attribute.Int("range.end.line", int(r.End.Line))) - out = append(out, attribute.Int("range.end.character", int(r.End.Character))) - } + out = append(out, attribute.Int("range.start.line", int(r.Start.Line))) + out = append(out, attribute.Int("range.start.character", int(r.Start.Character))) + out = append(out, attribute.Int("range.end.line", int(r.End.Line))) + out = append(out, attribute.Int("range.end.character", int(r.End.Character))) return out }