Skip to content

Commit 7000dd2

Browse files
authored
update to work with latest v0.8.0 release of bufbuild/protocompile (#593)
1 parent 058e6ca commit 7000dd2

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

desc/protoparse/ast.go

-8
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,6 @@ func convertASTValue(f *ast.FileNode, v ast.ValueNode) ast2.ValueNode {
515515
return convertASTCompoundStringLiteral(f, v)
516516
case *ast.UintLiteralNode:
517517
return convertASTUintLiteral(f, v)
518-
case *ast.PositiveUintLiteralNode:
519-
return convertASTPositiveUintLiteral(f, v)
520518
case *ast.NegativeIntLiteralNode:
521519
return convertASTNegativeIntLiteral(f, v)
522520
case *ast.FloatLiteralNode:
@@ -593,8 +591,6 @@ func convertASTInt(f *ast.FileNode, n ast.IntValueNode) ast2.IntValueNode {
593591
switch n := n.(type) {
594592
case *ast.UintLiteralNode:
595593
return convertASTUintLiteral(f, n)
596-
case *ast.PositiveUintLiteralNode:
597-
return convertASTPositiveUintLiteral(f, n)
598594
case *ast.NegativeIntLiteralNode:
599595
return convertASTNegativeIntLiteral(f, n)
600596
default:
@@ -606,10 +602,6 @@ func convertASTUintLiteral(f *ast.FileNode, n *ast.UintLiteralNode) *ast2.UintLi
606602
return ast2.NewUintLiteralNode(n.Val, convertASTTokenInfo(f, n.Token()))
607603
}
608604

609-
func convertASTPositiveUintLiteral(f *ast.FileNode, n *ast.PositiveUintLiteralNode) *ast2.PositiveUintLiteralNode {
610-
return ast2.NewPositiveUintLiteralNode(convertASTRune(f, n.Plus), convertASTUintLiteral(f, n.Uint))
611-
}
612-
613605
func convertASTNegativeIntLiteral(f *ast.FileNode, n *ast.NegativeIntLiteralNode) *ast2.NegativeIntLiteralNode {
614606
return ast2.NewNegativeIntLiteralNode(convertASTRune(f, n.Minus), convertASTUintLiteral(f, n.Uint))
615607
}

desc/protoparse/ast/file.go

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ type FileNode struct {
1919
Syntax *SyntaxNode // nil if file has no syntax declaration
2020
Decls []FileElement
2121

22+
// TODO: add Edition *EditionNode
23+
2224
// Any comments that follow the last token in the file.
2325
FinalComments []Comment
2426
// Any whitespace at the end of the file (after the last token or

desc/protoparse/ast/values.go

+6
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ func (n *UintLiteralNode) AsFloat() float64 {
175175
}
176176

177177
// PositiveUintLiteralNode represents an integer literal with a positive (+) sign.
178+
//
179+
// Deprecated: A valid AST will not contain a node of this type. The Protobuf
180+
// language does not actually allow a numeric literal to have a leading "+"
181+
// positive sign.
178182
type PositiveUintLiteralNode struct {
179183
compositeNode
180184
Plus *RuneNode
@@ -184,6 +188,8 @@ type PositiveUintLiteralNode struct {
184188

185189
// NewPositiveUintLiteralNode creates a new *PositiveUintLiteralNode. Both
186190
// arguments must be non-nil.
191+
//
192+
// Deprecated: The ast.PositiveUintLiteralNode node type should not be used.
187193
func NewPositiveUintLiteralNode(sign *RuneNode, i *UintLiteralNode) *PositiveUintLiteralNode {
188194
if sign == nil {
189195
panic("sign is nil")

desc/protoparse/ast/walk.go

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ type Visitor struct {
5959
VisitFileNode func(*FileNode) (bool, *Visitor)
6060
// VisitSyntaxNode is invoked when visiting a *SyntaxNode in the AST.
6161
VisitSyntaxNode func(*SyntaxNode) (bool, *Visitor)
62+
63+
// TODO: add VisitEditionNode
64+
6265
// VisitPackageNode is invoked when visiting a *PackageNode in the AST.
6366
VisitPackageNode func(*PackageNode) (bool, *Visitor)
6467
// VisitImportNode is invoked when visiting an *ImportNode in the AST.
@@ -112,6 +115,8 @@ type Visitor struct {
112115
// VisitUintLiteralNode is invoked when visiting a *UintLiteralNode in the AST.
113116
VisitUintLiteralNode func(*UintLiteralNode) (bool, *Visitor)
114117
// VisitPositiveUintLiteralNode is invoked when visiting a *PositiveUintLiteralNode in the AST.
118+
//
119+
// Deprecated: this node type will not actually be present in an AST.
115120
VisitPositiveUintLiteralNode func(*PositiveUintLiteralNode) (bool, *Visitor)
116121
// VisitNegativeIntLiteralNode is invoked when visiting a *NegativeIntLiteralNode in the AST.
117122
VisitNegativeIntLiteralNode func(*NegativeIntLiteralNode) (bool, *Visitor)

desc/protoparse/reporting_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestErrorReporting(t *testing.T) {
5757
`,
5858
},
5959
expectedErrs: []string{
60-
"test.proto:5:41: expected ';'",
60+
"test.proto:5:41: syntax error: expecting ';'",
6161
"test.proto:5:69: syntax error: unexpected ';', expecting '='",
6262
"test.proto:7:53: syntax error: unexpected '='",
6363
},

desc/protoparse/validate_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func TestBasicValidation(t *testing.T) {
291291
},
292292
{
293293
contents: `syntax = "proto3"; enum reserved { unset = 0; } message Foo { reserved bar = 1; }`,
294-
errMsg: `test.proto:1:76: expected ';'`,
294+
errMsg: `test.proto:1:76: syntax error: expecting ';'`,
295295
},
296296
{
297297
contents: `syntax = "proto3"; enum extend { unset = 0; } message Foo { extend bar = 1; }`,

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/jhump/protoreflect
33
go 1.18
44

55
require (
6-
github.com/bufbuild/protocompile v0.7.1
6+
github.com/bufbuild/protocompile v0.8.0
77
github.com/golang/protobuf v1.5.3
88
github.com/jhump/gopoet v0.1.0
99
github.com/jhump/goprotoc v0.5.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
22
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3-
github.com/bufbuild/protocompile v0.7.1 h1:Kd8fb6EshOHXNNRtYAmLAwy/PotlyFoN0iMbuwGNh0M=
4-
github.com/bufbuild/protocompile v0.7.1/go.mod h1:+Etjg4guZoAqzVk2czwEQP12yaxLJ8DxuqCJ9qHdH94=
3+
github.com/bufbuild/protocompile v0.8.0 h1:9Kp1q6OkS9L4nM3FYbr8vlJnEwtbpDPQlQOVXfR+78s=
4+
github.com/bufbuild/protocompile v0.8.0/go.mod h1:+Etjg4guZoAqzVk2czwEQP12yaxLJ8DxuqCJ9qHdH94=
55
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
66
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
77
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=

0 commit comments

Comments
 (0)