Skip to content

Commit

Permalink
fix(api): explicitly mark source_text optional ∵ File.text is optional (
Browse files Browse the repository at this point in the history
  • Loading branch information
schroederc committed May 30, 2023
1 parent 4b56b7b commit c1a4536
Show file tree
Hide file tree
Showing 4 changed files with 432 additions and 429 deletions.
2 changes: 1 addition & 1 deletion kythe/go/serving/xrefs/xrefs.go
Expand Up @@ -388,7 +388,7 @@ func (t *Table) Decorations(ctx context.Context, req *xpb.DecorationsRequest) (*
})
}

if req.SourceText {
if req.SourceText && text != nil {
reply.Encoding = decor.File.Encoding
if loc.Kind == xpb.Location_FILE {
reply.SourceText = text
Expand Down
4 changes: 2 additions & 2 deletions kythe/go/serving/xrefs/xrefs_test.go
Expand Up @@ -725,7 +725,7 @@ func TestDecorationsRefs(t *testing.T) {
})
testutil.Fatalf(t, "DecorationsRequest error: %v", err)

if len(reply.SourceText) != 0 {
if reply.SourceText != nil {
t.Errorf("Unexpected source text: %q", string(reply.SourceText))
}
if reply.Encoding != "" {
Expand Down Expand Up @@ -912,7 +912,7 @@ func TestDecorationsDirtyBuffer(t *testing.T) {
})
testutil.Fatalf(t, "DecorationsRequest error: %v", err)

if len(reply.SourceText) != 0 {
if reply.SourceText != nil {
t.Errorf("Unexpected source text: %q", string(reply.SourceText))
}
if reply.Encoding != "" {
Expand Down
2 changes: 1 addition & 1 deletion kythe/proto/xref.proto
Expand Up @@ -187,7 +187,7 @@ message DecorationsReply {
string revision = 18;

// The encoded source text for the selected window.
bytes source_text = 2;
optional bytes source_text = 2;
string encoding = 3;

// Represents a reference edge source ---KIND---> target. Each source is an
Expand Down

0 comments on commit c1a4536

Please sign in to comment.