From 131c88c4352999cab50d0e8a6e8223a8e107ff52 Mon Sep 17 00:00:00 2001 From: Nedyalko Andreev Date: Mon, 27 Feb 2023 13:27:37 +0200 Subject: [PATCH 1/6] Update dependencies and go.mod version of xk6 tests --- .../workflows/xk6-tests/xk6-js-test/go.mod | 15 +- .../workflows/xk6-tests/xk6-js-test/go.sum | 643 +----------------- .../xk6-tests/xk6-output-test/go.mod | 21 +- .../xk6-tests/xk6-output-test/go.sum | 374 +++------- 4 files changed, 123 insertions(+), 930 deletions(-) diff --git a/.github/workflows/xk6-tests/xk6-js-test/go.mod b/.github/workflows/xk6-tests/xk6-js-test/go.mod index 9014152f513..4d879fa58ca 100644 --- a/.github/workflows/xk6-tests/xk6-js-test/go.mod +++ b/.github/workflows/xk6-tests/xk6-js-test/go.mod @@ -1,28 +1,27 @@ module github.com/grafana/xk6-js-test -go 1.17 +go 1.19 -require go.k6.io/k6 v0.43.0 +require go.k6.io/k6 v0.43.1-0.20230225140832-4463298b0718 require ( github.com/dlclark/regexp2 v1.7.0 // indirect - github.com/dop251/goja v0.0.0-20230128084908-78b980256d04 // indirect - github.com/fatih/color v1.13.0 // indirect + github.com/dop251/goja v0.0.0-20230216180835-5937a312edda // indirect + github.com/fatih/color v1.14.1 // indirect github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect - github.com/mstoykov/atlas v0.0.0-20220808085829-90340e9998bd // indirect + github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/gomega v1.27.1 // indirect github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/afero v1.1.2 // indirect - golang.org/x/crypto v0.1.0 // indirect golang.org/x/sys v0.5.0 // indirect golang.org/x/text v0.7.0 // indirect - golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect + golang.org/x/time v0.3.0 // indirect gopkg.in/guregu/null.v3 v3.3.0 // indirect ) diff --git a/.github/workflows/xk6-tests/xk6-js-test/go.sum b/.github/workflows/xk6-tests/xk6-js-test/go.sum index b846aa64b41..f3df6f5c4d5 100644 --- a/.github/workflows/xk6-tests/xk6-js-test/go.sum +++ b/.github/workflows/xk6-tests/xk6-js-test/go.sum @@ -1,221 +1,42 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= -github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v0.0.0-20180330214955-e67964b4021a/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI= -github.com/Soontao/goHttpDigestClient v0.0.0-20170320082612-6d28bb1415c5/go.mod h1:5Q4+CyR7+Q3VMG8f78ou+QSX/BNUNUx5W48eFRat8DQ= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chromedp/cdproto v0.0.0-20221023212508-67ada9507fb2/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= -github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20221003171542-5ea1285e6c91/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= -github.com/dop251/goja v0.0.0-20221106173738-3b8a68ca89b4/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= -github.com/dop251/goja v0.0.0-20230128084908-78b980256d04 h1:iQQgQ1wBsFmpu6OjINCY2ekdknKNNpxO/GOzzww2Amk= -github.com/dop251/goja v0.0.0-20230128084908-78b980256d04/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= +github.com/dop251/goja v0.0.0-20230216180835-5937a312edda h1:yWEvdMtib3RbPysHDTNf/c3gerF5r+iMcmhlAeE6hEk= +github.com/dop251/goja v0.0.0-20230216180835-5937a312edda/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= +github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible h1:bopx7t9jyUNX1ebhr0G4gtQWmUOgwQRI0QsYhdYLgkU= github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grafana/xk6-browser v0.8.1-0.20230207135343-cfd6a83dfc42/go.mod h1:elvssKBUHI8rLShlWb+lOUhkaGcn0RcipKE6MRcezVw= -github.com/grafana/xk6-output-prometheus-remote v0.1.0/go.mod h1:R4o0VbIfbQNNPSGkeeiCBLzwNfG+DEdfKYNsV1oww1Y= -github.com/grafana/xk6-redis v0.1.1/go.mod h1:z7el1Tz8advY+ex419KfLbENzSQYgaA2lQYwMlt9yMM= -github.com/grafana/xk6-timers v0.1.2/go.mod h1:XHmDIXAKe30NJMXrxKIKMFXx98etsCl0jBYktjsSURc= -github.com/grafana/xk6-websockets v0.1.5/go.mod h1:+vlArhLMFFvNFgs5GUsw3RtzlDxli1G5SFMdC/QEUxU= -github.com/grafana/xk6-websockets v0.1.6/go.mod h1:rqb9U/KERxR3CUL1k8bSAJLn1eHjNHQXvIhxXaAFKpI= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= -github.com/jhump/gopoet v0.1.0/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= -github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7UvLHRQ= -github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= -github.com/jhump/protoreflect v1.12.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= -github.com/jhump/protoreflect v1.13.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= -github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= @@ -224,510 +45,98 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa h1:lx8ZnNPwjkXSzOROz0cg69RlErRXs+L3eDkggASWKLo= -github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa/go.mod h1:fhpOYavp5g2K74XDl/ao2y4KvhqVtKlkg1e+0UaQv7I= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mstoykov/atlas v0.0.0-20220808085829-90340e9998bd h1:x/wQ8/umYu2x0icx5wNNTSK1NlkYVmsgzQ+U6v4ijv0= -github.com/mstoykov/atlas v0.0.0-20220808085829-90340e9998bd/go.mod h1:9vRHVuLCjoFfE3GT06X0spdOAO+Zzo4AMjdIwUHBvAk= +github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd h1:AC3N94irbx2kWGA8f/2Ks7EQl2LxKIRQYuT9IJDwgiI= +github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd/go.mod h1:9vRHVuLCjoFfE3GT06X0spdOAO+Zzo4AMjdIwUHBvAk= github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 h1:94EkGmhXrVUEal+uLwFUf4fMXPhZpM5tYxuIsxrCCbI= -github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1/go.mod h1:vk/d9jpexY2Z9Bb0uB4Ndesss1Sr0Z9ZiGUrg5o9VGk= -github.com/mstoykov/k6-taskqueue-lib v0.1.0/go.mod h1:PXdINulapvmzF545Auw++SCD69942FeNvUztaa9dVe4= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= -github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= -github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0= -github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= -github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw= -github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= -github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJjy+csc= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= -github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= -github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= -github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= -github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= -github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM= -github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754= github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.14.1-0.20221122130035-8b6e68085b10/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e h1:zWKUYT07mGmVBH+9UgnHXd/ekCK99C8EbDSAt5qsjXE= github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.buf.build/grpc/go/gogo/protobuf v1.4.9/go.mod h1:2rkC/lMWRLTLC2Bmn8BUP3ED9Kxx7FN3OHk+u7KCHDU= -go.buf.build/grpc/go/prometheus/prometheus v1.4.4/go.mod h1:QjrcwuvXQEp/Z0H21rmFvy4QTTnyWvfT5sffq/BlEJU= -go.k6.io/k6 v0.37.1-0.20220426072701-d105f5474bc3/go.mod h1:1bTdDsXTT2V3in3ZgdR15MDW6SQQh5nWni59tirqNB8= -go.k6.io/k6 v0.38.2/go.mod h1:1bTdDsXTT2V3in3ZgdR15MDW6SQQh5nWni59tirqNB8= -go.k6.io/k6 v0.40.1-0.20221017105932-3c97ec7d1231/go.mod h1:vaSQ1A2rnC+wrKRJ4ExZCT6kKLfAEYoaIY9UR0uAjjk= -go.k6.io/k6 v0.41.0/go.mod h1:ZrgrR06UZbzZt9u+so/yQhlkJFH5gkJ3qCp1hwq1mEU= -go.k6.io/k6 v0.41.1-0.20221116104224-5fa71b761185/go.mod h1:JHBf2FpDMqdDvcHMPmSzE2YBBI9HPHn86ndgp5gYWQM= -go.k6.io/k6 v0.42.1-0.20230130080633-582ec4d3940c/go.mod h1:0ThS9XqUtlglwwsZ7IxXs+QJTkjkMUZgQ/N1r6Wajm8= -go.k6.io/k6 v0.43.0 h1:61cS5WZKakkox3r0+ZKS1w1qSiSG9z7BQ5tBURSyuKw= -go.k6.io/k6 v0.43.0/go.mod h1:eViUvOYYvW9ckMoQDv4qvOVhwrYFqhUm1i+PK/VFBmI= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +go.k6.io/k6 v0.43.1-0.20230225140832-4463298b0718 h1:gNgNbQaXCsgIeJtZolEn40wRBrTXzl/Fz4fKrEx4q2o= +go.k6.io/k6 v0.43.1-0.20230225140832-4463298b0718/go.mod h1:QnhCQQcYv3yuf+1Vmj29zFGWDbW18iNZ5zQ6dW0Sy7s= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20220919170432-7a66f970e087/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= -golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= -golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200903010400-9bfcb5116336/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 h1:hrbNEivu7Zn1pxvHk6MBrq9iE22woVILTHqexqBxe6I= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= +google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -735,26 +144,10 @@ gopkg.in/guregu/null.v3 v3.3.0 h1:8j3ggqq+NgKt/O7mbFVUFKUMWN+l1AmT5jQmJ6nPh2c= gopkg.in/guregu/null.v3 v3.3.0/go.mod h1:E4tX2Qe3h7QdL+uZ3a0vqvYwKQsRSQKM5V4YltdgH9Y= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/.github/workflows/xk6-tests/xk6-output-test/go.mod b/.github/workflows/xk6-tests/xk6-output-test/go.mod index ea7de71cb37..4405be4af23 100644 --- a/.github/workflows/xk6-tests/xk6-output-test/go.mod +++ b/.github/workflows/xk6-tests/xk6-output-test/go.mod @@ -1,8 +1,23 @@ module github.com/grafana/xk6-output-test -go 1.15 +go 1.19 require ( - github.com/spf13/afero v1.1.2 - go.k6.io/k6 v0.43.0 + github.com/spf13/afero v1.9.2 + go.k6.io/k6 v0.43.1-0.20230225140832-4463298b0718 +) + +require ( + github.com/fatih/color v1.14.1 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect + github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect + github.com/sirupsen/logrus v1.9.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect + golang.org/x/time v0.3.0 // indirect + gopkg.in/guregu/null.v3 v3.3.0 // indirect ) diff --git a/.github/workflows/xk6-tests/xk6-output-test/go.sum b/.github/workflows/xk6-tests/xk6-output-test/go.sum index cc672c1a537..a35b64f671e 100644 --- a/.github/workflows/xk6-tests/xk6-output-test/go.sum +++ b/.github/workflows/xk6-tests/xk6-output-test/go.sum @@ -3,6 +3,7 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= @@ -13,6 +14,9 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -30,88 +34,33 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= -github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v0.0.0-20180330214955-e67964b4021a/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI= -github.com/Soontao/goHttpDigestClient v0.0.0-20170320082612-6d28bb1415c5/go.mod h1:5Q4+CyR7+Q3VMG8f78ou+QSX/BNUNUx5W48eFRat8DQ= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chromedp/cdproto v0.0.0-20221023212508-67ada9507fb2/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= -github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= -github.com/dop251/goja v0.0.0-20221003171542-5ea1285e6c91/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= -github.com/dop251/goja v0.0.0-20221106173738-3b8a68ca89b4/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= -github.com/dop251/goja v0.0.0-20230128084908-78b980256d04/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= -github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= -github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= +github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= -github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= -github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -137,10 +86,7 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -150,14 +96,11 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -165,190 +108,78 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grafana/xk6-browser v0.8.1-0.20230207135343-cfd6a83dfc42/go.mod h1:elvssKBUHI8rLShlWb+lOUhkaGcn0RcipKE6MRcezVw= -github.com/grafana/xk6-output-prometheus-remote v0.1.0/go.mod h1:R4o0VbIfbQNNPSGkeeiCBLzwNfG+DEdfKYNsV1oww1Y= -github.com/grafana/xk6-redis v0.1.1/go.mod h1:z7el1Tz8advY+ex419KfLbENzSQYgaA2lQYwMlt9yMM= -github.com/grafana/xk6-timers v0.1.2/go.mod h1:XHmDIXAKe30NJMXrxKIKMFXx98etsCl0jBYktjsSURc= -github.com/grafana/xk6-websockets v0.1.5/go.mod h1:+vlArhLMFFvNFgs5GUsw3RtzlDxli1G5SFMdC/QEUxU= -github.com/grafana/xk6-websockets v0.1.6/go.mod h1:rqb9U/KERxR3CUL1k8bSAJLn1eHjNHQXvIhxXaAFKpI= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= -github.com/jhump/gopoet v0.1.0/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= -github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7UvLHRQ= -github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= -github.com/jhump/protoreflect v1.12.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= -github.com/jhump/protoreflect v1.13.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= -github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa h1:lx8ZnNPwjkXSzOROz0cg69RlErRXs+L3eDkggASWKLo= -github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa/go.mod h1:fhpOYavp5g2K74XDl/ao2y4KvhqVtKlkg1e+0UaQv7I= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mstoykov/atlas v0.0.0-20220808085829-90340e9998bd h1:x/wQ8/umYu2x0icx5wNNTSK1NlkYVmsgzQ+U6v4ijv0= -github.com/mstoykov/atlas v0.0.0-20220808085829-90340e9998bd/go.mod h1:9vRHVuLCjoFfE3GT06X0spdOAO+Zzo4AMjdIwUHBvAk= +github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd h1:AC3N94irbx2kWGA8f/2Ks7EQl2LxKIRQYuT9IJDwgiI= +github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd/go.mod h1:9vRHVuLCjoFfE3GT06X0spdOAO+Zzo4AMjdIwUHBvAk= github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 h1:94EkGmhXrVUEal+uLwFUf4fMXPhZpM5tYxuIsxrCCbI= -github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1/go.mod h1:vk/d9jpexY2Z9Bb0uB4Ndesss1Sr0Z9ZiGUrg5o9VGk= -github.com/mstoykov/k6-taskqueue-lib v0.1.0/go.mod h1:PXdINulapvmzF545Auw++SCD69942FeNvUztaa9dVe4= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.14.1-0.20221122130035-8b6e68085b10/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw= +github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.buf.build/grpc/go/gogo/protobuf v1.4.9/go.mod h1:2rkC/lMWRLTLC2Bmn8BUP3ED9Kxx7FN3OHk+u7KCHDU= -go.buf.build/grpc/go/prometheus/prometheus v1.4.4/go.mod h1:QjrcwuvXQEp/Z0H21rmFvy4QTTnyWvfT5sffq/BlEJU= -go.k6.io/k6 v0.37.1-0.20220426072701-d105f5474bc3/go.mod h1:1bTdDsXTT2V3in3ZgdR15MDW6SQQh5nWni59tirqNB8= -go.k6.io/k6 v0.38.2/go.mod h1:1bTdDsXTT2V3in3ZgdR15MDW6SQQh5nWni59tirqNB8= -go.k6.io/k6 v0.40.1-0.20221017105932-3c97ec7d1231/go.mod h1:vaSQ1A2rnC+wrKRJ4ExZCT6kKLfAEYoaIY9UR0uAjjk= -go.k6.io/k6 v0.41.0/go.mod h1:ZrgrR06UZbzZt9u+so/yQhlkJFH5gkJ3qCp1hwq1mEU= -go.k6.io/k6 v0.41.1-0.20221116104224-5fa71b761185/go.mod h1:JHBf2FpDMqdDvcHMPmSzE2YBBI9HPHn86ndgp5gYWQM= -go.k6.io/k6 v0.42.1-0.20230130080633-582ec4d3940c/go.mod h1:0ThS9XqUtlglwwsZ7IxXs+QJTkjkMUZgQ/N1r6Wajm8= -go.k6.io/k6 v0.43.0 h1:61cS5WZKakkox3r0+ZKS1w1qSiSG9z7BQ5tBURSyuKw= -go.k6.io/k6 v0.43.0/go.mod h1:eViUvOYYvW9ckMoQDv4qvOVhwrYFqhUm1i+PK/VFBmI= +go.k6.io/k6 v0.43.1-0.20230225140832-4463298b0718 h1:gNgNbQaXCsgIeJtZolEn40wRBrTXzl/Fz4fKrEx4q2o= +go.k6.io/k6 v0.43.1-0.20230225140832-4463298b0718/go.mod h1:QnhCQQcYv3yuf+1Vmj29zFGWDbW18iNZ5zQ6dW0Sy7s= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be h1:fmw3UbQh+nxngCAHrDCCztao/kbYFnWjoqop8dHx05A= -golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -371,7 +202,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -380,11 +211,10 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -392,7 +222,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -406,28 +235,25 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20221002022538-bcab6841153b h1:6e93nYa3hNqAvLr0pD4PN1fFS+gKzp2zAXqrnTCstqU= -golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -438,32 +264,19 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -474,50 +287,35 @@ golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20220919170432-7a66f970e087/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -558,9 +356,13 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -581,12 +383,16 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -610,17 +416,20 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200903010400-9bfcb5116336/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 h1:hrbNEivu7Zn1pxvHk6MBrq9iE22woVILTHqexqBxe6I= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -633,14 +442,11 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -651,35 +457,15 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/guregu/null.v3 v3.3.0 h1:8j3ggqq+NgKt/O7mbFVUFKUMWN+l1AmT5jQmJ6nPh2c= gopkg.in/guregu/null.v3 v3.3.0/go.mod h1:E4tX2Qe3h7QdL+uZ3a0vqvYwKQsRSQKM5V4YltdgH9Y= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 2d7787d8f76c1d30c537e6beff9ac9e4c32e5ebf Mon Sep 17 00:00:00 2001 From: Nedyalko Andreev Date: Mon, 27 Feb 2023 13:31:55 +0200 Subject: [PATCH 2/6] Update github.com/klauspost/compress from v1.15.15 to v1.16.0 --- go.mod | 2 +- go.sum | 4 +- .../github.com/klauspost/compress/README.md | 6 +++ .../klauspost/compress/huff0/decompress.go | 2 +- .../compress/internal/snapref/encode_other.go | 22 ++++++++++ .../klauspost/compress/zstd/dict.go | 43 +++++++++++++++++-- .../klauspost/compress/zstd/enc_base.go | 2 +- vendor/modules.txt | 4 +- 8 files changed, 75 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 0baac1e79c1..31168dede7b 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/grafana/xk6-websockets v0.1.6 github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc github.com/jhump/protoreflect v1.14.1 - github.com/klauspost/compress v1.15.15 + github.com/klauspost/compress v1.16.0 github.com/mailru/easyjson v0.7.7 github.com/mattn/go-colorable v0.1.13 github.com/mattn/go-isatty v0.0.17 diff --git a/go.sum b/go.sum index a3c91cd23ce..98c583abd5b 100644 --- a/go.sum +++ b/go.sum @@ -204,8 +204,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= -github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= diff --git a/vendor/github.com/klauspost/compress/README.md b/vendor/github.com/klauspost/compress/README.md index 63f2cd5b25f..958666ed891 100644 --- a/vendor/github.com/klauspost/compress/README.md +++ b/vendor/github.com/klauspost/compress/README.md @@ -16,6 +16,12 @@ This package provides various compression algorithms. # changelog +* Jan 21st, 2023 (v1.15.15) + * deflate: Improve level 7-9 by @klauspost in https://github.com/klauspost/compress/pull/739 + * zstd: Add delta encoding support by @greatroar in https://github.com/klauspost/compress/pull/728 + * zstd: Various speed improvements by @greatroar https://github.com/klauspost/compress/pull/741 https://github.com/klauspost/compress/pull/734 https://github.com/klauspost/compress/pull/736 https://github.com/klauspost/compress/pull/744 https://github.com/klauspost/compress/pull/743 https://github.com/klauspost/compress/pull/745 + * gzhttp: Add SuffixETag() and DropETag() options to prevent ETag collisions on compressed responses by @willbicks in https://github.com/klauspost/compress/pull/740 + * Jan 3rd, 2023 (v1.15.14) * flate: Improve speed in big stateless blocks https://github.com/klauspost/compress/pull/718 diff --git a/vendor/github.com/klauspost/compress/huff0/decompress.go b/vendor/github.com/klauspost/compress/huff0/decompress.go index 42a237eac4a..3c0b398c72e 100644 --- a/vendor/github.com/klauspost/compress/huff0/decompress.go +++ b/vendor/github.com/klauspost/compress/huff0/decompress.go @@ -61,7 +61,7 @@ func ReadTable(in []byte, s *Scratch) (s2 *Scratch, remain []byte, err error) { b, err := fse.Decompress(in[:iSize], s.fse) s.fse.Out = nil if err != nil { - return s, nil, err + return s, nil, fmt.Errorf("fse decompress returned: %w", err) } if len(b) > 255 { return s, nil, errors.New("corrupt input: output table too large") diff --git a/vendor/github.com/klauspost/compress/internal/snapref/encode_other.go b/vendor/github.com/klauspost/compress/internal/snapref/encode_other.go index 298c4f8e97d..05db94d39a4 100644 --- a/vendor/github.com/klauspost/compress/internal/snapref/encode_other.go +++ b/vendor/github.com/klauspost/compress/internal/snapref/encode_other.go @@ -103,6 +103,28 @@ func hash(u, shift uint32) uint32 { return (u * 0x1e35a7bd) >> shift } +// EncodeBlockInto exposes encodeBlock but checks dst size. +func EncodeBlockInto(dst, src []byte) (d int) { + if MaxEncodedLen(len(src)) > len(dst) { + return 0 + } + + // encodeBlock breaks on too big blocks, so split. + for len(src) > 0 { + p := src + src = nil + if len(p) > maxBlockSize { + p, src = p[:maxBlockSize], p[maxBlockSize:] + } + if len(p) < minNonLiteralBlockSize { + d += emitLiteral(dst[d:], p) + } else { + d += encodeBlock(dst[d:], p) + } + } + return d +} + // encodeBlock encodes a non-empty src to a guaranteed-large-enough dst. It // assumes that the varint-encoded length of the decompressed bytes has already // been written. diff --git a/vendor/github.com/klauspost/compress/zstd/dict.go b/vendor/github.com/klauspost/compress/zstd/dict.go index 66a95c18ef3..ca0951452e6 100644 --- a/vendor/github.com/klauspost/compress/zstd/dict.go +++ b/vendor/github.com/klauspost/compress/zstd/dict.go @@ -32,14 +32,38 @@ func (d *dict) ID() uint32 { return d.id } -// DictContentSize returns the dictionary content size or 0 if d is nil. -func (d *dict) DictContentSize() int { +// ContentSize returns the dictionary content size or 0 if d is nil. +func (d *dict) ContentSize() int { if d == nil { return 0 } return len(d.content) } +// Content returns the dictionary content. +func (d *dict) Content() []byte { + if d == nil { + return nil + } + return d.content +} + +// Offsets returns the initial offsets. +func (d *dict) Offsets() [3]int { + if d == nil { + return [3]int{} + } + return d.offsets +} + +// LitEncoder returns the literal encoder. +func (d *dict) LitEncoder() *huff0.Scratch { + if d == nil { + return nil + } + return d.litEnc +} + // Load a dictionary as described in // https://github.com/facebook/zstd/blob/master/doc/zstd_compression_format.md#dictionary-format func loadDict(b []byte) (*dict, error) { @@ -64,7 +88,7 @@ func loadDict(b []byte) (*dict, error) { var err error d.litEnc, b, err = huff0.ReadTable(b[8:], nil) if err != nil { - return nil, err + return nil, fmt.Errorf("loading literal table: %w", err) } d.litEnc.Reuse = huff0.ReusePolicyMust @@ -122,3 +146,16 @@ func loadDict(b []byte) (*dict, error) { return &d, nil } + +// InspectDictionary loads a zstd dictionary and provides functions to inspect the content. +func InspectDictionary(b []byte) (interface { + ID() uint32 + ContentSize() int + Content() []byte + Offsets() [3]int + LitEncoder() *huff0.Scratch +}, error) { + initPredefined() + d, err := loadDict(b) + return d, err +} diff --git a/vendor/github.com/klauspost/compress/zstd/enc_base.go b/vendor/github.com/klauspost/compress/zstd/enc_base.go index bfb2e146c33..e008b99298a 100644 --- a/vendor/github.com/klauspost/compress/zstd/enc_base.go +++ b/vendor/github.com/klauspost/compress/zstd/enc_base.go @@ -149,7 +149,7 @@ func (e *fastBase) resetBase(d *dict, singleBlock bool) { if singleBlock { e.lowMem = true } - e.ensureHist(d.DictContentSize() + maxCompressedBlockSize) + e.ensureHist(d.ContentSize() + maxCompressedBlockSize) e.lowMem = low } diff --git a/vendor/modules.txt b/vendor/modules.txt index eb289957aa7..e3e2bbebac2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -179,8 +179,8 @@ github.com/jhump/protoreflect/internal/codec # github.com/josharian/intern v1.0.0 ## explicit; go 1.5 github.com/josharian/intern -# github.com/klauspost/compress v1.15.15 -## explicit; go 1.17 +# github.com/klauspost/compress v1.16.0 +## explicit; go 1.18 github.com/klauspost/compress github.com/klauspost/compress/flate github.com/klauspost/compress/fse From 4eee0e09d373e086d210b5455c37ccee21a3df07 Mon Sep 17 00:00:00 2001 From: Nedyalko Andreev Date: Mon, 27 Feb 2023 13:34:51 +0200 Subject: [PATCH 3/6] Update github.com/jhump/protoreflect from v1.14.1 to v1.15.0 --- go.mod | 6 +- go.sum | 21 +- .../bufbuild/protocompile/.gitignore | 3 + .../github.com/bufbuild/protocompile/LICENSE | 201 ++ .../bufbuild/protocompile/README.md | 91 + .../bufbuild/protocompile/ast/doc.go | 75 + .../bufbuild/protocompile/ast/enum.go | 165 + .../bufbuild/protocompile/ast/field.go | 672 ++++ .../bufbuild/protocompile/ast/file.go | 277 ++ .../bufbuild/protocompile/ast/file_info.go | 676 ++++ .../bufbuild/protocompile/ast/identifiers.go | 148 + .../bufbuild/protocompile/ast/message.go | 213 ++ .../bufbuild/protocompile/ast/no_source.go | 119 + .../bufbuild/protocompile/ast/node.go | 139 + .../bufbuild/protocompile/ast/options.go | 373 +++ .../bufbuild/protocompile/ast/ranges.go | 319 ++ .../bufbuild/protocompile/ast/service.go | 286 ++ .../bufbuild/protocompile/ast/values.go | 558 ++++ .../bufbuild/protocompile/ast/walk.go | 921 ++++++ .../bufbuild/protocompile/compiler.go | 567 ++++ .../github.com/bufbuild/protocompile/doc.go | 82 + .../github.com/bufbuild/protocompile/go.work | 7 + .../bufbuild/protocompile/go.work.sum | 412 +++ .../protocompile/internal/message_context.go | 98 + .../bufbuild/protocompile/internal/options.go | 59 + .../bufbuild/protocompile/internal/tags.go | 243 ++ .../bufbuild/protocompile/internal/types.go | 35 + .../bufbuild/protocompile/internal/util.go | 119 + .../protocompile/linker/descriptors.go | 1880 +++++++++++ .../bufbuild/protocompile/linker/doc.go | 48 + .../bufbuild/protocompile/linker/files.go | 368 +++ .../bufbuild/protocompile/linker/linker.go | 177 ++ .../protocompile/linker/pathkey_no_unsafe.go | 35 + .../protocompile/linker/pathkey_unsafe.go | 36 + .../bufbuild/protocompile/linker/resolve.go | 787 +++++ .../bufbuild/protocompile/linker/symbols.go | 557 ++++ .../bufbuild/protocompile/linker/validate.go | 283 ++ .../bufbuild/protocompile/options/options.go | 1525 +++++++++ .../protocompile/parser}/.gitignore | 0 .../bufbuild/protocompile/parser/ast.go | 216 ++ .../bufbuild/protocompile/parser/doc.go | 25 + .../bufbuild/protocompile/parser/errors.go} | 17 +- .../protocompile/parser}/lexer.go | 603 ++-- .../bufbuild/protocompile/parser/parser.go | 180 ++ .../protocompile/parser}/proto.y | 96 +- .../protocompile/parser}/proto.y.go | 1636 +++++----- .../bufbuild/protocompile/parser/result.go | 920 ++++++ .../bufbuild/protocompile/parser/validate.go | 477 +++ .../bufbuild/protocompile/protoutil/protos.go | 261 ++ .../bufbuild/protocompile/reporter/errors.go | 68 + .../protocompile/reporter/reporter.go | 232 ++ .../bufbuild/protocompile/resolver.go | 192 ++ .../sourceinfo/source_code_info.go | 820 +++++ .../bufbuild/protocompile/std_imports.go | 62 + .../bufbuild/protocompile/walk/walk.go | 445 +++ .../protoc-gen-go/descriptor/descriptor.pb.go | 200 -- .../protoc-gen-go/plugin/plugin.pb.go | 75 - .../golang/protobuf/ptypes/empty/empty.pb.go | 62 - .../protobuf/ptypes/struct/struct.pb.go | 78 - .../protobuf/ptypes/wrappers/wrappers.pb.go | 71 - .../jhump/protoreflect/codec/codec.go | 217 -- .../jhump/protoreflect/codec/decode_fields.go | 318 -- .../jhump/protoreflect/codec/doc.go | 7 - .../jhump/protoreflect/codec/encode_fields.go | 288 -- .../jhump/protoreflect/desc/cache.go | 57 + .../jhump/protoreflect/desc/convert.go | 175 +- .../jhump/protoreflect/desc/descriptor.go | 669 ++-- .../jhump/protoreflect/desc/imports.go | 69 +- .../desc/internal/proto3_optional.go | 9 +- .../protoreflect/desc/internal/registry.go | 48 + .../protoreflect/desc/internal/source_info.go | 18 +- .../jhump/protoreflect/desc/load.go | 275 +- .../jhump/protoreflect/desc/protoparse/ast.go | 801 ++++- .../protoreflect/desc/protoparse/ast/file.go | 2 +- .../desc/protoparse/ast/source_pos.go | 17 +- .../desc/protoparse/descriptor_protos.go | 588 ---- .../protoreflect/desc/protoparse/errors.go | 124 +- .../protoreflect/desc/protoparse/linker.go | 1326 -------- .../protoreflect/desc/protoparse/options.go | 1581 ---------- .../protoreflect/desc/protoparse/parser.go | 782 ++--- .../desc/protoparse/source_code_info.go | 544 ---- .../desc/protoparse/std_imports.go | 50 - .../protoreflect/desc/protoparse/validate.go | 383 --- .../protoreflect/desc/sourceinfo/registry.go | 67 +- .../protoreflect/desc/sourceinfo/wrappers.go | 121 + .../jhump/protoreflect/desc/wrap.go | 208 ++ .../jhump/protoreflect/dynamic/binary.go | 185 -- .../jhump/protoreflect/dynamic/doc.go | 159 - .../protoreflect/dynamic/dynamic_message.go | 2774 ----------------- .../jhump/protoreflect/dynamic/equal.go | 157 - .../jhump/protoreflect/dynamic/extension.go | 46 - .../dynamic/extension_registry.go | 241 -- .../jhump/protoreflect/dynamic/indent.go | 76 - .../jhump/protoreflect/dynamic/json.go | 1256 -------- .../jhump/protoreflect/dynamic/maps_1.11.go | 130 - .../jhump/protoreflect/dynamic/maps_1.12.go | 138 - .../jhump/protoreflect/dynamic/merge.go | 100 - .../protoreflect/dynamic/message_factory.go | 207 -- .../jhump/protoreflect/dynamic/text.go | 1177 ------- .../protoreflect/internal/codec/buffer.go | 118 - .../protoreflect/internal/codec/decode.go | 346 -- .../protoreflect/internal/codec/encode.go | 147 - .../protoreflect/internal/standard_files.go | 8 +- .../protoreflect/internal/unrecognized.go | 27 +- vendor/golang.org/x/sync/LICENSE | 27 + vendor/golang.org/x/sync/PATENTS | 22 + .../golang.org/x/sync/semaphore/semaphore.go | 136 + .../protobuf/field_mask/field_mask.go | 23 - .../genproto/protobuf/ptype/type.go | 82 - .../protobuf/source_context/source_context.go | 23 - .../encoding/protojson/well_known_types.go | 12 +- .../protobuf/internal/genid/descriptor_gen.go | 3 + .../protobuf/internal/version/version.go | 2 +- .../reflect/protoreflect/source_gen.go | 2 + .../types/descriptorpb/descriptor.pb.go | 375 +-- .../protobuf/types/known/anypb/any.pb.go | 6 +- .../protobuf/types/known/emptypb/empty.pb.go | 1 - .../types/known/structpb/struct.pb.go | 4 +- vendor/modules.txt | 33 +- 119 files changed, 20061 insertions(+), 16043 deletions(-) create mode 100644 vendor/github.com/bufbuild/protocompile/.gitignore create mode 100644 vendor/github.com/bufbuild/protocompile/LICENSE create mode 100644 vendor/github.com/bufbuild/protocompile/README.md create mode 100644 vendor/github.com/bufbuild/protocompile/ast/doc.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/enum.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/field.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/file.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/file_info.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/identifiers.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/message.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/no_source.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/node.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/options.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/ranges.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/service.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/values.go create mode 100644 vendor/github.com/bufbuild/protocompile/ast/walk.go create mode 100644 vendor/github.com/bufbuild/protocompile/compiler.go create mode 100644 vendor/github.com/bufbuild/protocompile/doc.go create mode 100644 vendor/github.com/bufbuild/protocompile/go.work create mode 100644 vendor/github.com/bufbuild/protocompile/go.work.sum create mode 100644 vendor/github.com/bufbuild/protocompile/internal/message_context.go create mode 100644 vendor/github.com/bufbuild/protocompile/internal/options.go create mode 100644 vendor/github.com/bufbuild/protocompile/internal/tags.go create mode 100644 vendor/github.com/bufbuild/protocompile/internal/types.go create mode 100644 vendor/github.com/bufbuild/protocompile/internal/util.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/descriptors.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/doc.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/files.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/linker.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/pathkey_no_unsafe.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/pathkey_unsafe.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/resolve.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/symbols.go create mode 100644 vendor/github.com/bufbuild/protocompile/linker/validate.go create mode 100644 vendor/github.com/bufbuild/protocompile/options/options.go rename vendor/github.com/{jhump/protoreflect/desc/protoparse => bufbuild/protocompile/parser}/.gitignore (100%) create mode 100644 vendor/github.com/bufbuild/protocompile/parser/ast.go create mode 100644 vendor/github.com/bufbuild/protocompile/parser/doc.go rename vendor/{google.golang.org/genproto/protobuf/api/api.go => github.com/bufbuild/protocompile/parser/errors.go} (60%) rename vendor/github.com/{jhump/protoreflect/desc/protoparse => bufbuild/protocompile/parser}/lexer.go (50%) create mode 100644 vendor/github.com/bufbuild/protocompile/parser/parser.go rename vendor/github.com/{jhump/protoreflect/desc/protoparse => bufbuild/protocompile/parser}/proto.y (95%) rename vendor/github.com/{jhump/protoreflect/desc/protoparse => bufbuild/protocompile/parser}/proto.y.go (66%) create mode 100644 vendor/github.com/bufbuild/protocompile/parser/result.go create mode 100644 vendor/github.com/bufbuild/protocompile/parser/validate.go create mode 100644 vendor/github.com/bufbuild/protocompile/protoutil/protos.go create mode 100644 vendor/github.com/bufbuild/protocompile/reporter/errors.go create mode 100644 vendor/github.com/bufbuild/protocompile/reporter/reporter.go create mode 100644 vendor/github.com/bufbuild/protocompile/resolver.go create mode 100644 vendor/github.com/bufbuild/protocompile/sourceinfo/source_code_info.go create mode 100644 vendor/github.com/bufbuild/protocompile/std_imports.go create mode 100644 vendor/github.com/bufbuild/protocompile/walk/walk.go delete mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go delete mode 100644 vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go delete mode 100644 vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go delete mode 100644 vendor/github.com/jhump/protoreflect/codec/codec.go delete mode 100644 vendor/github.com/jhump/protoreflect/codec/decode_fields.go delete mode 100644 vendor/github.com/jhump/protoreflect/codec/doc.go delete mode 100644 vendor/github.com/jhump/protoreflect/codec/encode_fields.go create mode 100644 vendor/github.com/jhump/protoreflect/desc/cache.go create mode 100644 vendor/github.com/jhump/protoreflect/desc/internal/registry.go delete mode 100644 vendor/github.com/jhump/protoreflect/desc/protoparse/descriptor_protos.go delete mode 100644 vendor/github.com/jhump/protoreflect/desc/protoparse/linker.go delete mode 100644 vendor/github.com/jhump/protoreflect/desc/protoparse/options.go delete mode 100644 vendor/github.com/jhump/protoreflect/desc/protoparse/source_code_info.go delete mode 100644 vendor/github.com/jhump/protoreflect/desc/protoparse/std_imports.go delete mode 100644 vendor/github.com/jhump/protoreflect/desc/protoparse/validate.go create mode 100644 vendor/github.com/jhump/protoreflect/desc/wrap.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/binary.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/doc.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/dynamic_message.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/equal.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/extension.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/extension_registry.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/indent.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/json.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/maps_1.11.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/maps_1.12.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/merge.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/message_factory.go delete mode 100644 vendor/github.com/jhump/protoreflect/dynamic/text.go delete mode 100644 vendor/github.com/jhump/protoreflect/internal/codec/buffer.go delete mode 100644 vendor/github.com/jhump/protoreflect/internal/codec/decode.go delete mode 100644 vendor/github.com/jhump/protoreflect/internal/codec/encode.go create mode 100644 vendor/golang.org/x/sync/LICENSE create mode 100644 vendor/golang.org/x/sync/PATENTS create mode 100644 vendor/golang.org/x/sync/semaphore/semaphore.go delete mode 100644 vendor/google.golang.org/genproto/protobuf/field_mask/field_mask.go delete mode 100644 vendor/google.golang.org/genproto/protobuf/ptype/type.go delete mode 100644 vendor/google.golang.org/genproto/protobuf/source_context/source_context.go diff --git a/go.mod b/go.mod index 31168dede7b..1046ca7ce00 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/grafana/xk6-timers v0.1.2 github.com/grafana/xk6-websockets v0.1.6 github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc - github.com/jhump/protoreflect v1.14.1 + github.com/jhump/protoreflect v1.15.0 github.com/klauspost/compress v1.16.0 github.com/mailru/easyjson v0.7.7 github.com/mattn/go-colorable v0.1.13 @@ -44,7 +44,7 @@ require ( golang.org/x/term v0.5.0 golang.org/x/time v0.3.0 google.golang.org/grpc v1.53.0 - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 gopkg.in/guregu/null.v3 v3.3.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -52,6 +52,7 @@ require ( require ( github.com/andybalholm/cascadia v1.3.1 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bufbuild/protocompile v0.2.1-0.20230123224550-da57cd758c2f // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chromedp/cdproto v0.0.0-20221023212508-67ada9507fb2 // indirect github.com/chromedp/sysutil v1.0.0 // indirect @@ -72,6 +73,7 @@ require ( github.com/tidwall/match v1.1.1 // indirect go.buf.build/grpc/go/gogo/protobuf v1.4.9 // indirect go.buf.build/grpc/go/prometheus/prometheus v1.4.4 // indirect + golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect golang.org/x/sys v0.5.0 // indirect golang.org/x/text v0.7.0 // indirect google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect diff --git a/go.sum b/go.sum index 98c583abd5b..925984793ed 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bufbuild/protocompile v0.2.1-0.20230123224550-da57cd758c2f h1:IXSA5gow10s7zIOJfPOpXDtNBWCTA0715BDAhoJBXEs= +github.com/bufbuild/protocompile v0.2.1-0.20230123224550-da57cd758c2f/go.mod h1:tleDrpPTlLUVmgnEoN6qBliKWqJaZFJXqZdFjTd+ocU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -68,7 +70,6 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -87,7 +88,6 @@ github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= @@ -164,7 +164,6 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= @@ -186,12 +185,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc h1:KpMgaYJRieDkHZJWY3LMafvtqS/U8xX6+lUN+OKpl/Y= github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= -github.com/jhump/gopoet v0.1.0/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI= -github.com/jhump/goprotoc v0.5.0/go.mod h1:VrbvcYrQOrTi3i0Vf+m+oqQWk9l72mjkJCYo7UvLHRQ= -github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= -github.com/jhump/protoreflect v1.14.1 h1:N88q7JkxTHWFEqReuTsYH1dPIwXxA0ITNQp7avLY10s= -github.com/jhump/protoreflect v1.14.1/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= +github.com/jhump/protoreflect v1.15.0 h1:U5T5/2LF0AZQFP9T4W5GfBjBaTruomrKobiR4E+oA/Q= +github.com/jhump/protoreflect v1.15.0/go.mod h1:qww51KYjD2hoCl/ohxw5cK2LSssFczrbO1t8Ld2TENs= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -304,7 +299,6 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -425,6 +419,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc= +golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -599,7 +595,6 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -614,8 +609,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= +google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -630,7 +626,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/vendor/github.com/bufbuild/protocompile/.gitignore b/vendor/github.com/bufbuild/protocompile/.gitignore new file mode 100644 index 00000000000..65b3b16c3c1 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/.gitignore @@ -0,0 +1,3 @@ +*.iml +.idea/ +/.tmp/ diff --git a/vendor/github.com/bufbuild/protocompile/LICENSE b/vendor/github.com/bufbuild/protocompile/LICENSE new file mode 100644 index 00000000000..04cf1e316a6 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2020-2022 Buf Technologies, Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/bufbuild/protocompile/README.md b/vendor/github.com/bufbuild/protocompile/README.md new file mode 100644 index 00000000000..9d873330011 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/README.md @@ -0,0 +1,91 @@ +![The Buf logo](./.github/buf-logo.svg) + +# Protocompile + +[![Build](https://github.com/bufbuild/protocompile/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/bufbuild/protocompile/actions/workflows/ci.yaml) +[![Report Card](https://goreportcard.com/badge/github.com/bufbuild/protocompile)](https://goreportcard.com/report/github.com/bufbuild/protocompile) +[![GoDoc](https://pkg.go.dev/badge/github.com/bufbuild/protocompile.svg)](https://pkg.go.dev/github.com/bufbuild/protocompile) + +This repo contains a parsing/linking engine for Protocol Buffers, written in pure Go. It is suitable as an alternative +to `protoc` (Google's official reference compiler for Protocol Buffers). This is the compiler that powers [Buf](https://buf.build) +and its bevy of tools. + +This repo is also the spiritual successor to the [`github.com/jhump/protoreflect/desc/protoparse`](https://godoc.org/github.com/jhump/protoreflect/desc/protoparse) +package. If you are looking for a newer version of `protoparse` that natively works with the newer Protobuf runtime +API for Go (`google.golang.org/protobuf`), you have found it! + +## Protocol Buffers + +If you've come across this repo but don't know what Protocol Buffers are, you might acquaint yourself with the [official +documentation](https://developers.google.com/protocol-buffers). Protocol Buffers, or Protobuf for short, is an IDL for +describing APIs and data structures and also a binary encoding format for efficiently transmitting and storing that +data. + +If you want to know more about the language itself, which is what this repo implements, take a look at Buf's +[Protobuf Guide](https://protobuf.com), which includes a very detailed language specification. + +### Descriptors + +Descriptors are the "lingua franca" for describing Protobuf data schemas. They are the basis of runtime features like +reflection and dynamic messages. They are also the output of a Protobuf compiler: a compiler can produce them and write +them to a file (whose contents are the binary-encoded form of a [`FileDescriptorSet`](https://github.com/protocolbuffers/protobuf/blob/v21.7/src/google/protobuf/descriptor.proto#L55-L59)) +or send them to a [plugin](https://docs.buf.build/reference/images#plugins) to generate code for a particular +programming language. + +Descriptors are similar to nodes in a syntax tree: the contents of a file descriptor correspond closely to the elements +in the source file from which it was generated. Also, the descriptor model's data structures are themselves defined in +[Protobuf](https://github.com/protocolbuffers/protobuf/blob/v21.7/src/google/protobuf/descriptor.proto). + +## Using This Repo + +The primary API of this repo is in this root package: `github.com/bufbuild/protocompile`. This is the suggested entry +point and provides a type named `Compiler`, for compiling Protobuf source files into descriptors. There are also +numerous sub-packages, most of which implement various stages of the compiler. Here's an overview (_not_ in alphabetical +order): + + * [`protocompile`](https://pkg.go.dev/github.com/bufbuild/protocompile): + This is the entry point, used to configure and initiate a compilation operation. + * [`parser`](https://pkg.go.dev/github.com/bufbuild/protocompile/parser): + This is the first stage of the compiler. It parses Protobuf source code and produces an AST. This package can also + generate a file descriptor proto from an AST. + * [`ast`](https://pkg.go.dev/github.com/bufbuild/protocompile/ast): + This package models an Abstract Syntax Tree (AST) for the Protobuf language. + * [`linker`](https://pkg.go.dev/github.com/bufbuild/protocompile/linker): + This is the second stage of the compiler. The descriptor proto (generated from an AST) is linked, producing a more + useful data structure than simple descriptor protos. This step also performs numerous validations on the source, + like making sure that all type references are correct and that sources don't try to define two elements with the same + name. + * [`options`](https://pkg.go.dev/github.com/bufbuild/protocompile/options): + This is the next stage of the compiler: interpreting options. The linked data structures that come from the previous + stage are used to validate and interpret all options. + * [`sourceinfo`](https://pkg.go.dev/github.com/bufbuild/protocompile/sourceinfo): + This is the last stage of the compiler: generating source code info. Source code info contains metadata that maps + elements in the descriptor to the location in the original source file from which it came. This includes access to + comments. In order to provide correct source info for options, it must happen last, after options have been + interpreted. + * [`reporter`](https://pkg.go.dev/github.com/bufbuild/protocompile/reporter): This package provides error types + generated by the compiler and interfaces used by the compiler to report errors and warnings to the calling code. + * [`walk`](https://pkg.go.dev/github.com/bufbuild/protocompile/walk): + This package provides functions for walking through all of the elements in a descriptor (or descriptor proto) + hierarchy. + * [`protoutil`](https://pkg.go.dev/github.com/bufbuild/protocompile/protoutil): + This package contains some other useful functions for interacting with Protobuf descriptors. + +### Migrating from `protoparse` + +There are a few differences between this repo and its predecessor, `github.com/jhump/protoreflect/desc/protoparse`. + +* If you want to include "standard imports", for the well-known files that are included with `protoc`, you have to do + so explicitly. To do this, wrap your resolver using `protocompile.WithStandardImports`. +* If you used `protoparse.FileContentsFromMap`, in this new repo you'll use a `protocompile.SourceResolver` and then use + `protocompile.SourceAccessorFromMap` as its accessor function. +* If you used `Parser.ParseToAST`, you won't use the `protocompile` package but instead directly use `parser.Parse` in + this repo's `parser` sub-package. This returns an AST for the given file contents. +* If you used `Parser.ParseFilesButDoNotLink`, that is still possible in this repo, but not provided directly via a + single function. Instead, you need to take a few steps: + 1. Parse the source using `parser.Parse`. Then use `parser.ResultFromAST` to construct a result that contains a file + descriptor proto. + 2. Interpret whatever options can be interpreted without linking using `options.InterpretUnlinkedOptions`. This may + leave some options in the descriptor proto uninterpreted (including all custom options). + 3. If you want source code info for the file, finally call `sourceinfo.GenerateSourceInfo` using the index returned + from the previous step and store that in the file descriptor proto. diff --git a/vendor/github.com/bufbuild/protocompile/ast/doc.go b/vendor/github.com/bufbuild/protocompile/ast/doc.go new file mode 100644 index 00000000000..fac65c420f4 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/doc.go @@ -0,0 +1,75 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package ast defines types for modeling the AST (Abstract Syntax +// Tree) for the Protocol Buffers interface definition language. +// +// # Nodes +// +// All nodes of the tree implement the [Node] interface. Leaf nodes in the +// tree implement [TerminalNode], and all others implement [CompositeNode]. +// The root of the tree for a proto source file is a *[FileNode]. +// +// A [TerminalNode] represents a single lexical element, or [Token]. A +// [CompositeNode] represents a sub-tree of the AST and range of tokens. +// +// Position information is tracked using a *[FileInfo]. The lexer invokes its +// various Add* methods to add details as the file is tokenized. Storing +// the position information in the *[FileInfo], instead of in each AST node, +// allows the AST to have a much more compact representation. To extract +// detailed position information, you must use the NodeInfo method, available +// on either the *[FileInfo] which produced the node's items or the *[FileNode] +// root of the tree that contains the node. +// +// # Items, Tokens, and Comments +// +// An [Item] represents a lexical item, excluding whitespace. This can be +// either a [Token] or a [Comment]. +// +// Comments are not represented as nodes in the tree. Instead, they are +// attributed to terminal nodes in the tree. So, when lexing, comments +// are accumulated until the next non-comment token is found. The AST +// model in this package thus provides access to all comments in the +// file, regardless of location (unlike the SourceCodeInfo present in +// descriptor protos, which is lossy). The comments associated with a +// non-leaf/non-token node (i.e. a CompositeNode) come from the first +// and last nodes in its sub-tree, for leading and trailing comments +// respectively. +// +// A [Comment] value corresponds to a line ("//") or block ("/*") style +// comment in the source. These have no bearing on the grammar and are +// effectively ignored as the parser is determining the shape of the +// syntax tree. +// +// A [Token] value corresponds to a component of the grammar, that is +// used to produce an AST. They correspond to leaves in the AST (i.e. +// [TerminalNode]). +// +// The *[FileInfo] and *[FileNode] types provide methods for querying +// and iterating through all the items or tokens in the file. They also +// include a method for resolving an [Item] into a [Token] or [Comment]. +// +// # Factory Functions +// +// Creation of AST nodes should use the factory functions in this +// package instead of struct literals. Some factory functions accept +// optional arguments, which means the arguments can be nil. If nil +// values are provided for other (non-optional) arguments, the resulting +// node may be invalid and cause panics later in the program. +// +// This package defines numerous interfaces. However, user code should +// not attempt to implement any of them. Most consumers of an AST will +// not work correctly if they encounter concrete implementations other +// than the ones defined in this package. +package ast diff --git a/vendor/github.com/bufbuild/protocompile/ast/enum.go b/vendor/github.com/bufbuild/protocompile/ast/enum.go new file mode 100644 index 00000000000..93edbcbdce9 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/enum.go @@ -0,0 +1,165 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import "fmt" + +// EnumNode represents an enum declaration. Example: +// +// enum Foo { BAR = 0; BAZ = 1 } +type EnumNode struct { + compositeNode + Keyword *KeywordNode + Name *IdentNode + OpenBrace *RuneNode + Decls []EnumElement + CloseBrace *RuneNode +} + +func (*EnumNode) fileElement() {} +func (*EnumNode) msgElement() {} + +// NewEnumNode creates a new *EnumNode. All arguments must be non-nil. While +// it is technically allowed for decls to be nil or empty, the resulting node +// will not be a valid enum, which must have at least one value. +// - keyword: The token corresponding to the "enum" keyword. +// - name: The token corresponding to the enum's name. +// - openBrace: The token corresponding to the "{" rune that starts the body. +// - decls: All declarations inside the enum body. +// - closeBrace: The token corresponding to the "}" rune that ends the body. +func NewEnumNode(keyword *KeywordNode, name *IdentNode, openBrace *RuneNode, decls []EnumElement, closeBrace *RuneNode) *EnumNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if openBrace == nil { + panic("openBrace is nil") + } + if closeBrace == nil { + panic("closeBrace is nil") + } + children := make([]Node, 0, 4+len(decls)) + children = append(children, keyword, name, openBrace) + for _, decl := range decls { + switch decl.(type) { + case *OptionNode, *EnumValueNode, *ReservedNode, *EmptyDeclNode: + default: + panic(fmt.Sprintf("invalid EnumElement type: %T", decl)) + } + children = append(children, decl) + } + children = append(children, closeBrace) + + return &EnumNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Name: name, + OpenBrace: openBrace, + CloseBrace: closeBrace, + Decls: decls, + } +} + +// EnumElement is an interface implemented by all AST nodes that can +// appear in the body of an enum declaration. +type EnumElement interface { + Node + enumElement() +} + +var _ EnumElement = (*OptionNode)(nil) +var _ EnumElement = (*EnumValueNode)(nil) +var _ EnumElement = (*ReservedNode)(nil) +var _ EnumElement = (*EmptyDeclNode)(nil) + +// EnumValueDeclNode is a placeholder interface for AST nodes that represent +// enum values. This allows NoSourceNode to be used in place of *EnumValueNode +// for some usages. +type EnumValueDeclNode interface { + Node + GetName() Node + GetNumber() Node +} + +var _ EnumValueDeclNode = (*EnumValueNode)(nil) +var _ EnumValueDeclNode = NoSourceNode{} + +// EnumNode represents an enum declaration. Example: +// +// UNSET = 0 [deprecated = true]; +type EnumValueNode struct { + compositeNode + Name *IdentNode + Equals *RuneNode + Number IntValueNode + Options *CompactOptionsNode + Semicolon *RuneNode +} + +func (*EnumValueNode) enumElement() {} + +// NewEnumValueNode creates a new *EnumValueNode. All arguments must be non-nil +// except opts which is only non-nil if the declaration included options. +// - name: The token corresponding to the enum value's name. +// - equals: The token corresponding to the '=' rune after the name. +// - number: The token corresponding to the enum value's number. +// - opts: Optional set of enum value options. +// - semicolon: The token corresponding to the ";" rune that ends the declaration. +func NewEnumValueNode(name *IdentNode, equals *RuneNode, number IntValueNode, opts *CompactOptionsNode, semicolon *RuneNode) *EnumValueNode { + if name == nil { + panic("name is nil") + } + if equals == nil { + panic("equals is nil") + } + if number == nil { + panic("number is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + numChildren := 4 + if opts != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + children = append(children, name, equals, number) + if opts != nil { + children = append(children, opts) + } + children = append(children, semicolon) + return &EnumValueNode{ + compositeNode: compositeNode{ + children: children, + }, + Name: name, + Equals: equals, + Number: number, + Options: opts, + Semicolon: semicolon, + } +} + +func (e *EnumValueNode) GetName() Node { + return e.Name +} + +func (e *EnumValueNode) GetNumber() Node { + return e.Number +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/field.go b/vendor/github.com/bufbuild/protocompile/ast/field.go new file mode 100644 index 00000000000..d4d3e3924ca --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/field.go @@ -0,0 +1,672 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import "fmt" + +// FieldDeclNode is a node in the AST that defines a field. This includes +// normal message fields as well as extensions. There are multiple types +// of AST nodes that declare fields: +// - *FieldNode +// - *GroupNode +// - *MapFieldNode +// - *SyntheticMapField +// +// This also allows NoSourceNode and SyntheticMapField to be used in place of +// one of the above for some usages. +type FieldDeclNode interface { + Node + FieldLabel() Node + FieldName() Node + FieldType() Node + FieldTag() Node + FieldExtendee() Node + GetGroupKeyword() Node + GetOptions() *CompactOptionsNode +} + +var _ FieldDeclNode = (*FieldNode)(nil) +var _ FieldDeclNode = (*GroupNode)(nil) +var _ FieldDeclNode = (*MapFieldNode)(nil) +var _ FieldDeclNode = (*SyntheticMapField)(nil) +var _ FieldDeclNode = NoSourceNode{} + +// FieldNode represents a normal field declaration (not groups or maps). It +// can represent extension fields as well as non-extension fields (both inside +// of messages and inside of one-ofs). Example: +// +// optional string foo = 1; +type FieldNode struct { + compositeNode + Label FieldLabel + FldType IdentValueNode + Name *IdentNode + Equals *RuneNode + Tag *UintLiteralNode + Options *CompactOptionsNode + Semicolon *RuneNode + + // This is an up-link to the containing *ExtendNode for fields + // that are defined inside of "extend" blocks. + Extendee *ExtendNode +} + +func (*FieldNode) msgElement() {} +func (*FieldNode) oneOfElement() {} +func (*FieldNode) extendElement() {} + +// NewFieldNode creates a new *FieldNode. The label and options arguments may be +// nil but the others must be non-nil. +// - label: The token corresponding to the label keyword if present ("optional", +// "required", or "repeated"). +// - fieldType: The token corresponding to the field's type. +// - name: The token corresponding to the field's name. +// - equals: The token corresponding to the '=' rune after the name. +// - tag: The token corresponding to the field's tag number. +// - opts: Optional set of field options. +// - semicolon: The token corresponding to the ";" rune that ends the declaration. +func NewFieldNode(label *KeywordNode, fieldType IdentValueNode, name *IdentNode, equals *RuneNode, tag *UintLiteralNode, opts *CompactOptionsNode, semicolon *RuneNode) *FieldNode { + if fieldType == nil { + panic("fieldType is nil") + } + if name == nil { + panic("name is nil") + } + if equals == nil { + panic("equals is nil") + } + if tag == nil { + panic("tag is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + numChildren := 5 + if label != nil { + numChildren++ + } + if opts != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + if label != nil { + children = append(children, label) + } + children = append(children, fieldType, name, equals, tag) + if opts != nil { + children = append(children, opts) + } + children = append(children, semicolon) + + return &FieldNode{ + compositeNode: compositeNode{ + children: children, + }, + Label: newFieldLabel(label), + FldType: fieldType, + Name: name, + Equals: equals, + Tag: tag, + Options: opts, + Semicolon: semicolon, + } +} + +func (n *FieldNode) FieldLabel() Node { + // proto3 fields and fields inside one-ofs will not have a label and we need + // this check in order to return a nil node -- otherwise we'd return a + // non-nil node that has a nil pointer value in it :/ + if n.Label.KeywordNode == nil { + return nil + } + return n.Label.KeywordNode +} + +func (n *FieldNode) FieldName() Node { + return n.Name +} + +func (n *FieldNode) FieldType() Node { + return n.FldType +} + +func (n *FieldNode) FieldTag() Node { + return n.Tag +} + +func (n *FieldNode) FieldExtendee() Node { + if n.Extendee != nil { + return n.Extendee.Extendee + } + return nil +} + +func (n *FieldNode) GetGroupKeyword() Node { + return nil +} + +func (n *FieldNode) GetOptions() *CompactOptionsNode { + return n.Options +} + +// FieldLabel represents the label of a field, which indicates its cardinality +// (i.e. whether it is optional, required, or repeated). +type FieldLabel struct { + *KeywordNode + Repeated bool + Required bool +} + +func newFieldLabel(lbl *KeywordNode) FieldLabel { + repeated, required := false, false + if lbl != nil { + repeated = lbl.Val == "repeated" + required = lbl.Val == "required" + } + return FieldLabel{ + KeywordNode: lbl, + Repeated: repeated, + Required: required, + } +} + +// IsPresent returns true if a label keyword was present in the declaration +// and false if it was absent. +func (f *FieldLabel) IsPresent() bool { + return f.KeywordNode != nil +} + +// GroupNode represents a group declaration, which doubles as a field and inline +// message declaration. It can represent extension fields as well as +// non-extension fields (both inside of messages and inside of one-ofs). +// Example: +// +// optional group Key = 4 { +// optional uint64 id = 1; +// optional string name = 2; +// } +type GroupNode struct { + compositeNode + Label FieldLabel + Keyword *KeywordNode + Name *IdentNode + Equals *RuneNode + Tag *UintLiteralNode + Options *CompactOptionsNode + MessageBody + + // This is an up-link to the containing *ExtendNode for groups + // that are defined inside of "extend" blocks. + Extendee *ExtendNode +} + +func (*GroupNode) msgElement() {} +func (*GroupNode) oneOfElement() {} +func (*GroupNode) extendElement() {} + +// NewGroupNode creates a new *GroupNode. The label and options arguments may be +// nil but the others must be non-nil. +// - label: The token corresponding to the label keyword if present ("optional", +// "required", or "repeated"). +// - keyword: The token corresponding to the "group" keyword. +// - name: The token corresponding to the field's name. +// - equals: The token corresponding to the '=' rune after the name. +// - tag: The token corresponding to the field's tag number. +// - opts: Optional set of field options. +// - openBrace: The token corresponding to the "{" rune that starts the body. +// - decls: All declarations inside the group body. +// - closeBrace: The token corresponding to the "}" rune that ends the body. +func NewGroupNode(label *KeywordNode, keyword *KeywordNode, name *IdentNode, equals *RuneNode, tag *UintLiteralNode, opts *CompactOptionsNode, openBrace *RuneNode, decls []MessageElement, closeBrace *RuneNode) *GroupNode { + if keyword == nil { + panic("fieldType is nil") + } + if name == nil { + panic("name is nil") + } + if equals == nil { + panic("equals is nil") + } + if tag == nil { + panic("tag is nil") + } + if openBrace == nil { + panic("openBrace is nil") + } + if closeBrace == nil { + panic("closeBrace is nil") + } + numChildren := 6 + len(decls) + if label != nil { + numChildren++ + } + if opts != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + if label != nil { + children = append(children, label) + } + children = append(children, keyword, name, equals, tag) + if opts != nil { + children = append(children, opts) + } + children = append(children, openBrace) + for _, decl := range decls { + children = append(children, decl) + } + children = append(children, closeBrace) + + ret := &GroupNode{ + compositeNode: compositeNode{ + children: children, + }, + Label: newFieldLabel(label), + Keyword: keyword, + Name: name, + Equals: equals, + Tag: tag, + Options: opts, + } + populateMessageBody(&ret.MessageBody, openBrace, decls, closeBrace) + return ret +} + +func (n *GroupNode) FieldLabel() Node { + if n.Label.KeywordNode == nil { + // return nil interface to indicate absence, not a typed nil + return nil + } + return n.Label.KeywordNode +} + +func (n *GroupNode) FieldName() Node { + return n.Name +} + +func (n *GroupNode) FieldType() Node { + return n.Keyword +} + +func (n *GroupNode) FieldTag() Node { + return n.Tag +} + +func (n *GroupNode) FieldExtendee() Node { + if n.Extendee != nil { + return n.Extendee.Extendee + } + return nil +} + +func (n *GroupNode) GetGroupKeyword() Node { + return n.Keyword +} + +func (n *GroupNode) GetOptions() *CompactOptionsNode { + return n.Options +} + +func (n *GroupNode) MessageName() Node { + return n.Name +} + +// OneOfDeclNode is a node in the AST that defines a oneof. There are +// multiple types of AST nodes that declare oneofs: +// - *OneOfNode +// - *SyntheticOneOf +// +// This also allows NoSourceNode to be used in place of one of the above +// for some usages. +type OneOfDeclNode interface { + Node + OneOfName() Node +} + +// OneOfNode represents a one-of declaration. Example: +// +// oneof query { +// string by_name = 2; +// Type by_type = 3; +// Address by_address = 4; +// Labels by_label = 5; +// } +type OneOfNode struct { + compositeNode + Keyword *KeywordNode + Name *IdentNode + OpenBrace *RuneNode + Decls []OneOfElement + CloseBrace *RuneNode +} + +func (*OneOfNode) msgElement() {} + +// NewOneOfNode creates a new *OneOfNode. All arguments must be non-nil. While +// it is technically allowed for decls to be nil or empty, the resulting node +// will not be a valid oneof, which must have at least one field. +// - keyword: The token corresponding to the "oneof" keyword. +// - name: The token corresponding to the oneof's name. +// - openBrace: The token corresponding to the "{" rune that starts the body. +// - decls: All declarations inside the oneof body. +// - closeBrace: The token corresponding to the "}" rune that ends the body. +func NewOneOfNode(keyword *KeywordNode, name *IdentNode, openBrace *RuneNode, decls []OneOfElement, closeBrace *RuneNode) *OneOfNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if openBrace == nil { + panic("openBrace is nil") + } + if closeBrace == nil { + panic("closeBrace is nil") + } + children := make([]Node, 0, 4+len(decls)) + children = append(children, keyword, name, openBrace) + for _, decl := range decls { + children = append(children, decl) + } + children = append(children, closeBrace) + + for _, decl := range decls { + switch decl := decl.(type) { + case *OptionNode, *FieldNode, *GroupNode, *EmptyDeclNode: + default: + panic(fmt.Sprintf("invalid OneOfElement type: %T", decl)) + } + } + + return &OneOfNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Name: name, + OpenBrace: openBrace, + Decls: decls, + CloseBrace: closeBrace, + } +} + +func (n *OneOfNode) OneOfName() Node { + return n.Name +} + +// OneOfElement is an interface implemented by all AST nodes that can +// appear in the body of a oneof declaration. +type OneOfElement interface { + Node + oneOfElement() +} + +var _ OneOfElement = (*OptionNode)(nil) +var _ OneOfElement = (*FieldNode)(nil) +var _ OneOfElement = (*GroupNode)(nil) +var _ OneOfElement = (*EmptyDeclNode)(nil) + +// SyntheticOneOf is not an actual node in the AST but a synthetic node +// that represents the oneof implied by a proto3 optional field. +type SyntheticOneOf struct { + Field *FieldNode +} + +var _ Node = (*SyntheticOneOf)(nil) + +// NewSyntheticOneOf creates a new *SyntheticOneOf that corresponds to the +// given proto3 optional field. +func NewSyntheticOneOf(field *FieldNode) *SyntheticOneOf { + return &SyntheticOneOf{Field: field} +} + +func (n *SyntheticOneOf) Start() Token { + return n.Field.Start() +} + +func (n *SyntheticOneOf) End() Token { + return n.Field.End() +} + +func (n *SyntheticOneOf) LeadingComments() []Comment { + return nil +} + +func (n *SyntheticOneOf) TrailingComments() []Comment { + return nil +} + +func (n *SyntheticOneOf) OneOfName() Node { + return n.Field.FieldName() +} + +// MapTypeNode represents the type declaration for a map field. It defines +// both the key and value types for the map. Example: +// +// map +type MapTypeNode struct { + compositeNode + Keyword *KeywordNode + OpenAngle *RuneNode + KeyType *IdentNode + Comma *RuneNode + ValueType IdentValueNode + CloseAngle *RuneNode +} + +// NewMapTypeNode creates a new *MapTypeNode. All arguments must be non-nil. +// - keyword: The token corresponding to the "map" keyword. +// - openAngle: The token corresponding to the "<" rune after the keyword. +// - keyType: The token corresponding to the key type for the map. +// - comma: The token corresponding to the "," rune between key and value types. +// - valType: The token corresponding to the value type for the map. +// - closeAngle: The token corresponding to the ">" rune that ends the declaration. +func NewMapTypeNode(keyword *KeywordNode, openAngle *RuneNode, keyType *IdentNode, comma *RuneNode, valType IdentValueNode, closeAngle *RuneNode) *MapTypeNode { + if keyword == nil { + panic("keyword is nil") + } + if openAngle == nil { + panic("openAngle is nil") + } + if keyType == nil { + panic("keyType is nil") + } + if comma == nil { + panic("comma is nil") + } + if valType == nil { + panic("valType is nil") + } + if closeAngle == nil { + panic("closeAngle is nil") + } + children := []Node{keyword, openAngle, keyType, comma, valType, closeAngle} + return &MapTypeNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + OpenAngle: openAngle, + KeyType: keyType, + Comma: comma, + ValueType: valType, + CloseAngle: closeAngle, + } +} + +// MapFieldNode represents a map field declaration. Example: +// +// map replacements = 3 [deprecated = true]; +type MapFieldNode struct { + compositeNode + MapType *MapTypeNode + Name *IdentNode + Equals *RuneNode + Tag *UintLiteralNode + Options *CompactOptionsNode + Semicolon *RuneNode +} + +func (*MapFieldNode) msgElement() {} + +// NewMapFieldNode creates a new *MapFieldNode. All arguments must be non-nil +// except opts, which may be nil. +// - mapType: The token corresponding to the map type. +// - name: The token corresponding to the field's name. +// - equals: The token corresponding to the '=' rune after the name. +// - tag: The token corresponding to the field's tag number. +// - opts: Optional set of field options. +// - semicolon: The token corresponding to the ";" rune that ends the declaration. +func NewMapFieldNode(mapType *MapTypeNode, name *IdentNode, equals *RuneNode, tag *UintLiteralNode, opts *CompactOptionsNode, semicolon *RuneNode) *MapFieldNode { + if mapType == nil { + panic("mapType is nil") + } + if name == nil { + panic("name is nil") + } + if equals == nil { + panic("equals is nil") + } + if tag == nil { + panic("tag is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + numChildren := 5 + if opts != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + children = append(children, mapType, name, equals, tag) + if opts != nil { + children = append(children, opts) + } + children = append(children, semicolon) + + return &MapFieldNode{ + compositeNode: compositeNode{ + children: children, + }, + MapType: mapType, + Name: name, + Equals: equals, + Tag: tag, + Options: opts, + Semicolon: semicolon, + } +} + +func (n *MapFieldNode) FieldLabel() Node { + return nil +} + +func (n *MapFieldNode) FieldName() Node { + return n.Name +} + +func (n *MapFieldNode) FieldType() Node { + return n.MapType +} + +func (n *MapFieldNode) FieldTag() Node { + return n.Tag +} + +func (n *MapFieldNode) FieldExtendee() Node { + return nil +} + +func (n *MapFieldNode) GetGroupKeyword() Node { + return nil +} + +func (n *MapFieldNode) GetOptions() *CompactOptionsNode { + return n.Options +} + +func (n *MapFieldNode) MessageName() Node { + return n.Name +} + +func (n *MapFieldNode) KeyField() *SyntheticMapField { + return NewSyntheticMapField(n.MapType.KeyType, 1) +} + +func (n *MapFieldNode) ValueField() *SyntheticMapField { + return NewSyntheticMapField(n.MapType.ValueType, 2) +} + +// SyntheticMapField is not an actual node in the AST but a synthetic node +// that implements FieldDeclNode. These are used to represent the implicit +// field declarations of the "key" and "value" fields in a map entry. +type SyntheticMapField struct { + Ident IdentValueNode + Tag *UintLiteralNode +} + +// NewSyntheticMapField creates a new *SyntheticMapField for the given +// identifier (either a key or value type in a map declaration) and tag +// number (1 for key, 2 for value). +func NewSyntheticMapField(ident IdentValueNode, tagNum uint64) *SyntheticMapField { + tag := &UintLiteralNode{ + terminalNode: ident.Start().asTerminalNode(), + Val: tagNum, + } + return &SyntheticMapField{Ident: ident, Tag: tag} +} + +func (n *SyntheticMapField) Start() Token { + return n.Ident.Start() +} + +func (n *SyntheticMapField) End() Token { + return n.Ident.End() +} + +func (n *SyntheticMapField) LeadingComments() []Comment { + return nil +} + +func (n *SyntheticMapField) TrailingComments() []Comment { + return nil +} + +func (n *SyntheticMapField) FieldLabel() Node { + return n.Ident +} + +func (n *SyntheticMapField) FieldName() Node { + return n.Ident +} + +func (n *SyntheticMapField) FieldType() Node { + return n.Ident +} + +func (n *SyntheticMapField) FieldTag() Node { + return n.Tag +} + +func (n *SyntheticMapField) FieldExtendee() Node { + return nil +} + +func (n *SyntheticMapField) GetGroupKeyword() Node { + return nil +} + +func (n *SyntheticMapField) GetOptions() *CompactOptionsNode { + return nil +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/file.go b/vendor/github.com/bufbuild/protocompile/ast/file.go new file mode 100644 index 00000000000..f12cca09e2a --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/file.go @@ -0,0 +1,277 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import "fmt" + +// FileDeclNode is a placeholder interface for AST nodes that represent files. +// This allows NoSourceNode to be used in place of *FileNode for some usages. +type FileDeclNode interface { + Node + Name() string + GetSyntax() Node + NodeInfo(n Node) NodeInfo +} + +var _ FileDeclNode = (*FileNode)(nil) +var _ FileDeclNode = NoSourceNode{} + +// FileNode is the root of the AST hierarchy. It represents an entire +// protobuf source file. +type FileNode struct { + compositeNode + fileInfo *FileInfo + + Syntax *SyntaxNode // nil if file has no syntax declaration + Decls []FileElement + + // This synthetic node allows access to final comments and whitespace + EOF *RuneNode +} + +// NewFileNode creates a new *FileNode. The syntax parameter is optional. If it +// is absent, it means the file had no syntax declaration. +// +// This function panics if the concrete type of any element of decls is not +// from this package. +func NewFileNode(info *FileInfo, syntax *SyntaxNode, decls []FileElement, eof Token) *FileNode { + numChildren := len(decls) + 1 + if syntax != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + if syntax != nil { + children = append(children, syntax) + } + for _, decl := range decls { + switch decl := decl.(type) { + case *PackageNode, *ImportNode, *OptionNode, *MessageNode, + *EnumNode, *ExtendNode, *ServiceNode, *EmptyDeclNode: + default: + panic(fmt.Sprintf("invalid FileElement type: %T", decl)) + } + children = append(children, decl) + } + + eofNode := NewRuneNode(0, eof) + children = append(children, eofNode) + + return &FileNode{ + compositeNode: compositeNode{ + children: children, + }, + fileInfo: info, + Syntax: syntax, + Decls: decls, + EOF: eofNode, + } +} + +// NewEmptyFileNode returns an empty AST for a file with the given name. +func NewEmptyFileNode(filename string) *FileNode { + fileInfo := NewFileInfo(filename, []byte{}) + return NewFileNode(fileInfo, nil, nil, fileInfo.AddToken(0, 0)) +} + +func (f *FileNode) GetSyntax() Node { + return f.Syntax +} + +func (f *FileNode) Name() string { + return f.fileInfo.Name() +} + +func (f *FileNode) NodeInfo(n Node) NodeInfo { + return f.fileInfo.NodeInfo(n) +} + +func (f *FileNode) TokenInfo(t Token) NodeInfo { + return f.fileInfo.TokenInfo(t) +} + +func (f *FileNode) ItemInfo(i Item) ItemInfo { + return f.fileInfo.ItemInfo(i) +} + +func (f *FileNode) GetItem(i Item) (Token, Comment) { + return f.fileInfo.GetItem(i) +} + +func (f *FileNode) Items() Sequence[Item] { + return f.fileInfo.Items() +} + +func (f *FileNode) Tokens() Sequence[Token] { + return f.fileInfo.Tokens() +} + +// FileElement is an interface implemented by all AST nodes that are +// allowed as top-level declarations in the file. +type FileElement interface { + Node + fileElement() +} + +var _ FileElement = (*ImportNode)(nil) +var _ FileElement = (*PackageNode)(nil) +var _ FileElement = (*OptionNode)(nil) +var _ FileElement = (*MessageNode)(nil) +var _ FileElement = (*EnumNode)(nil) +var _ FileElement = (*ExtendNode)(nil) +var _ FileElement = (*ServiceNode)(nil) +var _ FileElement = (*EmptyDeclNode)(nil) + +// SyntaxNode represents a syntax declaration, which if present must be +// the first non-comment content. Example: +// +// syntax = "proto2"; +// +// Files that don't have a syntax node are assumed to use proto2 syntax. +type SyntaxNode struct { + compositeNode + Keyword *KeywordNode + Equals *RuneNode + Syntax StringValueNode + Semicolon *RuneNode +} + +// NewSyntaxNode creates a new *SyntaxNode. All four arguments must be non-nil: +// - keyword: The token corresponding to the "syntax" keyword. +// - equals: The token corresponding to the "=" rune. +// - syntax: The actual syntax value, e.g. "proto2" or "proto3". +// - semicolon: The token corresponding to the ";" rune that ends the declaration. +func NewSyntaxNode(keyword *KeywordNode, equals *RuneNode, syntax StringValueNode, semicolon *RuneNode) *SyntaxNode { + if keyword == nil { + panic("keyword is nil") + } + if equals == nil { + panic("equals is nil") + } + if syntax == nil { + panic("syntax is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + children := []Node{keyword, equals, syntax, semicolon} + return &SyntaxNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Equals: equals, + Syntax: syntax, + Semicolon: semicolon, + } +} + +// ImportNode represents an import statement. Example: +// +// import "google/protobuf/empty.proto"; +type ImportNode struct { + compositeNode + Keyword *KeywordNode + // Optional; if present indicates this is a public import + Public *KeywordNode + // Optional; if present indicates this is a weak import + Weak *KeywordNode + Name StringValueNode + Semicolon *RuneNode +} + +// NewImportNode creates a new *ImportNode. The public and weak arguments are optional +// and only one or the other (or neither) may be specified, not both. When public is +// non-nil, it indicates the "public" keyword in the import statement and means this is +// a public import. When weak is non-nil, it indicates the "weak" keyword in the import +// statement and means this is a weak import. When both are nil, this is a normal import. +// The other arguments must be non-nil: +// - keyword: The token corresponding to the "import" keyword. +// - public: The token corresponding to the optional "public" keyword. +// - weak: The token corresponding to the optional "weak" keyword. +// - name: The actual imported file name. +// - semicolon: The token corresponding to the ";" rune that ends the declaration. +func NewImportNode(keyword *KeywordNode, public *KeywordNode, weak *KeywordNode, name StringValueNode, semicolon *RuneNode) *ImportNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + numChildren := 3 + if public != nil || weak != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + children = append(children, keyword) + if public != nil { + children = append(children, public) + } else if weak != nil { + children = append(children, weak) + } + children = append(children, name, semicolon) + + return &ImportNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Public: public, + Weak: weak, + Name: name, + Semicolon: semicolon, + } +} + +func (*ImportNode) fileElement() {} + +// PackageNode represents a package declaration. Example: +// +// package foobar.com; +type PackageNode struct { + compositeNode + Keyword *KeywordNode + Name IdentValueNode + Semicolon *RuneNode +} + +func (*PackageNode) fileElement() {} + +// NewPackageNode creates a new *PackageNode. All three arguments must be non-nil: +// - keyword: The token corresponding to the "package" keyword. +// - name: The package name declared for the file. +// - semicolon: The token corresponding to the ";" rune that ends the declaration. +func NewPackageNode(keyword *KeywordNode, name IdentValueNode, semicolon *RuneNode) *PackageNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + children := []Node{keyword, name, semicolon} + return &PackageNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Name: name, + Semicolon: semicolon, + } +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/file_info.go b/vendor/github.com/bufbuild/protocompile/ast/file_info.go new file mode 100644 index 00000000000..1de9345773e --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/file_info.go @@ -0,0 +1,676 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import ( + "fmt" + "sort" + "unicode/utf8" +) + +// FileInfo contains information about the contents of a source file, including +// details about comments and items. A lexer accumulates these details as it +// scans the file contents. This allows efficient representation of things like +// source positions. +type FileInfo struct { + // The name of the source file. + name string + // The raw contents of the source file. + data []byte + // The offsets for each line in the file. The value is the zero-based byte + // offset for a given line. The line is given by its index. So the value at + // index 0 is the offset for the first line (which is always zero). The + // value at index 1 is the offset at which the second line begins. Etc. + lines []int + // The info for every comment in the file. This is empty if the file has no + // comments. The first entry corresponds to the first comment in the file, + // and so on. + comments []commentInfo + // The info for every lexed item in the file. The last item in the slice + // corresponds to the EOF, so every file (even an empty one) should have at + // least one entry. This includes all terminal symbols (tokens) in the AST + // as well as all comments. + items []itemSpan +} + +type commentInfo struct { + // the index of the item, in the file's items slice, that represents this + // comment + index int + // the index of the token to which this comment is attributed. + attributedToIndex int +} + +type itemSpan struct { + // the offset into the file of the first character of an item. + offset int + // the length of the item + length int +} + +// NewFileInfo creates a new instance for the given file. +func NewFileInfo(filename string, contents []byte) *FileInfo { + return &FileInfo{ + name: filename, + data: contents, + lines: []int{0}, + } +} + +func (f *FileInfo) Name() string { + return f.name +} + +// AddLine adds the offset representing the beginning of the "next" line in the file. +// The first line always starts at offset 0, the second line starts at offset-of-newline-char+1. +func (f *FileInfo) AddLine(offset int) { + if offset < 0 { + panic(fmt.Sprintf("invalid offset: %d must not be negative", offset)) + } + if offset > len(f.data) { + panic(fmt.Sprintf("invalid offset: %d is greater than file size %d", offset, len(f.data))) + } + + if len(f.lines) > 0 { + lastOffset := f.lines[len(f.lines)-1] + if offset <= lastOffset { + panic(fmt.Sprintf("invalid offset: %d is not greater than previously observed line offset %d", offset, lastOffset)) + } + } + + f.lines = append(f.lines, offset) +} + +// AddToken adds info about a token at the given location to this file. It +// returns a value that allows access to all of the token's details. +func (f *FileInfo) AddToken(offset, length int) Token { + if offset < 0 { + panic(fmt.Sprintf("invalid offset: %d must not be negative", offset)) + } + if length < 0 { + panic(fmt.Sprintf("invalid length: %d must not be negative", length)) + } + if offset+length > len(f.data) { + panic(fmt.Sprintf("invalid offset+length: %d is greater than file size %d", offset+length, len(f.data))) + } + + tokenID := len(f.items) + if len(f.items) > 0 { + lastToken := f.items[tokenID-1] + lastEnd := lastToken.offset + lastToken.length - 1 + if offset <= lastEnd { + panic(fmt.Sprintf("invalid offset: %d is not greater than previously observed token end %d", offset, lastEnd)) + } + } + + f.items = append(f.items, itemSpan{offset: offset, length: length}) + return Token(tokenID) +} + +// AddComment adds info about a comment to this file. Comments must first be +// added as items via f.AddToken(). The given comment argument is the Token +// from that step. The given attributedTo argument indicates another token in the +// file with which the comment is associated. If comment's offset is before that +// of attributedTo, then this is a leading comment. Otherwise, it is a trailing +// comment. +func (f *FileInfo) AddComment(comment, attributedTo Token) Comment { + if len(f.comments) > 0 { + lastComment := f.comments[len(f.comments)-1] + if int(comment) <= lastComment.index { + panic(fmt.Sprintf("invalid index: %d is not greater than previously observed comment index %d", comment, lastComment.index)) + } + if int(attributedTo) < lastComment.attributedToIndex { + panic(fmt.Sprintf("invalid attribution: %d is not greater than previously observed comment attribution index %d", attributedTo, lastComment.attributedToIndex)) + } + } + + f.comments = append(f.comments, commentInfo{index: int(comment), attributedToIndex: int(attributedTo)}) + return Comment{ + fileInfo: f, + index: len(f.comments) - 1, + } +} + +// NodeInfo returns details from the original source for the given AST node. +// +// If the given n is out of range, this returns an invalid NodeInfo (i.e. +// nodeInfo.IsValid() returns false). If the given n is not out of range but +// also from a different file than f, then the result is undefined. +func (f *FileInfo) NodeInfo(n Node) NodeInfo { + return f.nodeInfo(int(n.Start()), int(n.End())) +} + +// TokenInfo returns details from the original source for the given token. +// +// If the given t is out of range, this returns an invalid NodeInfo (i.e. +// nodeInfo.IsValid() returns false). If the given t is not out of range but +// also from a different file than f, then the result is undefined. +func (f *FileInfo) TokenInfo(t Token) NodeInfo { + return f.nodeInfo(int(t), int(t)) +} + +func (f *FileInfo) nodeInfo(start, end int) NodeInfo { + if start < 0 || start >= len(f.items) { + return NodeInfo{} + } + if end < 0 || end >= len(f.items) { + return NodeInfo{} + } + return NodeInfo{fileInfo: f, startIndex: start, endIndex: end} +} + +// ItemInfo returns details from the original source for the given item. +// +// If the given i is out of range, this returns nil. If the given i is not +// out of range but also from a different file than f, then the result is +// undefined. +func (f *FileInfo) ItemInfo(i Item) ItemInfo { + tok, cmt := f.GetItem(i) + if tok != TokenError { + return f.TokenInfo(tok) + } + if cmt.IsValid() { + return cmt + } + return nil +} + +// GetItem returns the token or comment represented by the given item. Only one +// of the return values will be valid. If the item is a token then the returned +// comment will be a zero value and thus invalid (i.e. comment.IsValid() returns +// false). If the item is a comment then the returned token will be TokenError. +// +// If the given i is out of range, this returns (TokenError, Comment{}). If the +// given i is not out of range but also from a different file than f, then +// the result is undefined. +func (f *FileInfo) GetItem(i Item) (Token, Comment) { + if i < 0 || int(i) >= len(f.items) { + return TokenError, Comment{} + } + if !f.isComment(i) { + return Token(i), Comment{} + } + // It's a comment, so find its location in f.comments + c := sort.Search(len(f.comments), func(c int) bool { + return f.comments[c].index >= int(i) + }) + if c < len(f.comments) && f.comments[c].index == int(i) { + return TokenError, Comment{fileInfo: f, index: c} + } + // f.isComment(i) returned true, but we couldn't find it + // in f.comments? Uh oh... that shouldn't be possible. + return TokenError, Comment{} +} + +func (f *FileInfo) isDummyFile() bool { + return f == nil || f.lines == nil +} + +// Sequence represents a navigable sequence of elements. +type Sequence[T any] interface { + // First returns the first element in the sequence. The bool return + // is false if this sequence contains no elements. For example, an + // empty file has no items or tokens. + First() (T, bool) + // Next returns the next element in the sequence that comes after + // the given element. The bool returns is false if there is no next + // item (i.e. the given element is the last one). It also returns + // false if the given element is invalid. + Next(T) (T, bool) + // Last returns the last element in the sequence. The bool return + // is false if this sequence contains no elements. For example, an + // empty file has no items or tokens. + Last() (T, bool) + // Previous returns the previous element in the sequence that comes + // before the given element. The bool returns is false if there is no + // previous item (i.e. the given element is the first one). It also + // returns false if the given element is invalid. + Previous(T) (T, bool) +} + +func (f *FileInfo) Items() Sequence[Item] { + return items{fileInfo: f} +} + +func (f *FileInfo) Tokens() Sequence[Token] { + return tokens{fileInfo: f} +} + +type items struct { + fileInfo *FileInfo +} + +func (i items) First() (Item, bool) { + if len(i.fileInfo.items) == 0 { + return 0, false + } + return 0, true +} + +func (i items) Next(item Item) (Item, bool) { + if item < 0 || int(item) >= len(i.fileInfo.items)-1 { + return 0, false + } + return i.fileInfo.itemForward(item+1, true) +} + +func (i items) Last() (Item, bool) { + if len(i.fileInfo.items) == 0 { + return 0, false + } + return Item(len(i.fileInfo.items) - 1), true +} + +func (i items) Previous(item Item) (Item, bool) { + if item <= 0 || int(item) >= len(i.fileInfo.items) { + return 0, false + } + return i.fileInfo.itemBackward(item-1, true) +} + +type tokens struct { + fileInfo *FileInfo +} + +func (t tokens) First() (Token, bool) { + i, ok := t.fileInfo.itemForward(0, false) + return Token(i), ok +} + +func (t tokens) Next(tok Token) (Token, bool) { + if tok < 0 || int(tok) >= len(t.fileInfo.items)-1 { + return 0, false + } + i, ok := t.fileInfo.itemForward(Item(tok+1), false) + return Token(i), ok +} + +func (t tokens) Last() (Token, bool) { + i, ok := t.fileInfo.itemBackward(Item(len(t.fileInfo.items))-1, false) + return Token(i), ok +} + +func (t tokens) Previous(tok Token) (Token, bool) { + if tok <= 0 || int(tok) >= len(t.fileInfo.items) { + return 0, false + } + i, ok := t.fileInfo.itemBackward(Item(tok-1), false) + return Token(i), ok +} + +func (f *FileInfo) itemForward(i Item, allowComment bool) (Item, bool) { + end := Item(len(f.items)) + for i < end { + if allowComment || !f.isComment(i) { + return i, true + } + i++ + } + return 0, false +} + +func (f *FileInfo) itemBackward(i Item, allowComment bool) (Item, bool) { + for i >= 0 { + if allowComment || !f.isComment(i) { + return i, true + } + i-- + } + return 0, false +} + +// isComment is comment returns true if i refers to a comment. +// (If it returns false, i refers to a token.) +func (f *FileInfo) isComment(i Item) bool { + item := f.items[i] + if item.length < 2 { + return false + } + // see if item text starts with "//" or "/*" + if f.data[item.offset] != '/' { + return false + } + c := f.data[item.offset+1] + return c == '/' || c == '*' +} + +func (f *FileInfo) SourcePos(offset int) SourcePos { + lineNumber := sort.Search(len(f.lines), func(n int) bool { + return f.lines[n] > offset + }) + + // If it weren't for tabs and multi-byte unicode characters, we + // could trivially compute the column just based on offset and the + // starting offset of lineNumber :( + // Wish this were more efficient... that would require also storing + // computed line+column information, which would triple the size of + // f's items slice... + col := 0 + for i := f.lines[lineNumber-1]; i < offset; i++ { + if f.data[i] == '\t' { + nextTabStop := 8 - (col % 8) + col += nextTabStop + } else if utf8.RuneStart(f.data[i]) { + col++ + } + } + + return SourcePos{ + Filename: f.name, + Offset: offset, + Line: lineNumber, + // Columns are 1-indexed in this AST + Col: col + 1, + } +} + +// Token represents a single lexed token. +type Token int + +// TokenError indicates an invalid token. It is returned from query +// functions when no valid token satisfies the request. +const TokenError = Token(-1) + +// AsItem returns the Item that corresponds to t. +func (t Token) AsItem() Item { + return Item(t) +} + +func (t Token) asTerminalNode() terminalNode { + return terminalNode(t) +} + +// Item represents an item lexed from source. It represents either +// a Token or a Comment. +type Item int + +// ItemInfo provides details about an item's location in the source file and +// its contents. +type ItemInfo interface { + Start() SourcePos + End() SourcePos + LeadingWhitespace() string + RawText() string +} + +// NodeInfo represents the details for a node or token in the source file's AST. +// It provides access to information about the node's location in the source +// file. It also provides access to the original text in the source file (with +// all the original formatting intact) and also provides access to surrounding +// comments. +type NodeInfo struct { + fileInfo *FileInfo + startIndex, endIndex int +} + +var _ ItemInfo = NodeInfo{} + +// IsValid returns true if this node info is valid. If n is a zero-value struct, +// it is not valid. +func (n NodeInfo) IsValid() bool { + return n.fileInfo != nil +} + +// Start returns the starting position of the element. This is the first +// character of the node or token. +func (n NodeInfo) Start() SourcePos { + if n.fileInfo.isDummyFile() { + return UnknownPos(n.fileInfo.name) + } + + tok := n.fileInfo.items[n.startIndex] + return n.fileInfo.SourcePos(tok.offset) +} + +// End returns the ending position of the element, exclusive. This is the +// location after the last character of the node or token. If n returns +// the same position for Start() and End(), the element in source had a +// length of zero (which should only happen for the special EOF token +// that designates the end of the file). +func (n NodeInfo) End() SourcePos { + if n.fileInfo.isDummyFile() { + return UnknownPos(n.fileInfo.name) + } + + tok := n.fileInfo.items[n.endIndex] + // find offset of last character in the span + offset := tok.offset + if tok.length > 0 { + offset += tok.length - 1 + } + pos := n.fileInfo.SourcePos(offset) + if tok.length > 0 { + // We return "open range", so end is the position *after* the + // last character in the span. So we adjust + pos.Col++ + } + return pos +} + +// LeadingWhitespace returns any whitespace prior to the element. If there +// were comments in between this element and the previous one, this will +// return the whitespace between the last such comment in the element. If +// there were no such comments, this returns the whitespace between the +// previous element and the current one. +func (n NodeInfo) LeadingWhitespace() string { + if n.fileInfo.isDummyFile() { + return "" + } + + tok := n.fileInfo.items[n.startIndex] + var prevEnd int + if n.startIndex > 0 { + prevTok := n.fileInfo.items[n.startIndex-1] + prevEnd = prevTok.offset + prevTok.length + } + return string(n.fileInfo.data[prevEnd:tok.offset]) +} + +// LeadingComments returns all comments in the source that exist between the +// element and the previous element, except for any trailing comment on the +// previous element. +func (n NodeInfo) LeadingComments() Comments { + if n.fileInfo.isDummyFile() { + return EmptyComments + } + + start := sort.Search(len(n.fileInfo.comments), func(i int) bool { + return n.fileInfo.comments[i].attributedToIndex >= n.startIndex + }) + + if start == len(n.fileInfo.comments) || n.fileInfo.comments[start].attributedToIndex != n.startIndex { + // no comments associated with this token + return EmptyComments + } + + numComments := 0 + for i := start; i < len(n.fileInfo.comments); i++ { + comment := n.fileInfo.comments[i] + if comment.attributedToIndex == n.startIndex && + comment.index < n.startIndex { + numComments++ + } else { + break + } + } + + return Comments{ + fileInfo: n.fileInfo, + first: start, + num: numComments, + } +} + +// TrailingComments returns the trailing comment for the element, if any. +// An element will have a trailing comment only if it is the last token +// on a line and is followed by a comment on the same line. Typically, the +// following comment is a line-style comment (starting with "//"). +// +// If the following comment is a block-style comment that spans multiple +// lines, and the next token is on the same line as the end of the comment, +// the comment is NOT considered a trailing comment. +// +// Examples: +// +// foo // this is a trailing comment for foo +// +// bar /* this is a trailing comment for bar */ +// +// baz /* this is a trailing +// comment for baz */ +// +// fizz /* this is NOT a trailing +// comment for fizz because +// its on the same line as the +// following token buzz */ buzz +func (n NodeInfo) TrailingComments() Comments { + if n.fileInfo.isDummyFile() { + return EmptyComments + } + + start := sort.Search(len(n.fileInfo.comments), func(i int) bool { + comment := n.fileInfo.comments[i] + return comment.attributedToIndex >= n.endIndex && + comment.index > n.endIndex + }) + + if start == len(n.fileInfo.comments) || n.fileInfo.comments[start].attributedToIndex != n.endIndex { + // no comments associated with this token + return EmptyComments + } + + numComments := 0 + for i := start; i < len(n.fileInfo.comments); i++ { + comment := n.fileInfo.comments[i] + if comment.attributedToIndex == n.endIndex { + numComments++ + } else { + break + } + } + + return Comments{ + fileInfo: n.fileInfo, + first: start, + num: numComments, + } +} + +// RawText returns the actual text in the source file that corresponds to the +// element. If the element is a node in the AST that encompasses multiple +// items (like an entire declaration), the full text of all items is returned +// including any interior whitespace and comments. +func (n NodeInfo) RawText() string { + startTok := n.fileInfo.items[n.startIndex] + endTok := n.fileInfo.items[n.endIndex] + return string(n.fileInfo.data[startTok.offset : endTok.offset+endTok.length]) +} + +// SourcePos identifies a location in a proto source file. +type SourcePos struct { + Filename string + // The line and column numbers for this position. These are + // one-based, so the first line and column is 1 (not zero). If + // either is zero, then the line and column are unknown and + // only the file name is known. + Line, Col int + // The offset, in bytes, from the beginning of the file. This + // is zero-based: the first character in the file is offset zero. + Offset int +} + +func (pos SourcePos) String() string { + if pos.Line <= 0 || pos.Col <= 0 { + return pos.Filename + } + return fmt.Sprintf("%s:%d:%d", pos.Filename, pos.Line, pos.Col) +} + +// Comments represents a range of sequential comments in a source file +// (e.g. no interleaving items or AST nodes). +type Comments struct { + fileInfo *FileInfo + first, num int +} + +// EmptyComments is an empty set of comments. +var EmptyComments = Comments{} + +// Len returns the number of comments in c. +func (c Comments) Len() int { + return c.num +} + +func (c Comments) Index(i int) Comment { + if i < 0 || i >= c.num { + panic(fmt.Sprintf("index %d out of range (len = %d)", i, c.num)) + } + return Comment{ + fileInfo: c.fileInfo, + index: c.first + i, + } +} + +// Comment represents a single comment in a source file. It indicates +// the position of the comment and its contents. A single comment means +// one line-style comment ("//" to end of line) or one block comment +// ("/*" through "*/"). If a longer comment uses multiple line comments, +// each line is considered to be a separate comment. For example: +// +// // This is a single comment, and +// // this is a separate comment. +type Comment struct { + fileInfo *FileInfo + index int +} + +var _ ItemInfo = Comment{} + +// IsValid returns true if this comment is valid. If this comment is +// a zero-value struct, it is not valid. +func (c Comment) IsValid() bool { + return c.fileInfo != nil && c.index >= 0 +} + +// AsItem returns the Item that corresponds to c. +func (c Comment) AsItem() Item { + return Item(c.fileInfo.comments[c.index].index) +} + +func (c Comment) Start() SourcePos { + span := c.fileInfo.items[c.AsItem()] + return c.fileInfo.SourcePos(span.offset) +} + +func (c Comment) End() SourcePos { + span := c.fileInfo.items[c.AsItem()] + return c.fileInfo.SourcePos(span.offset + span.length - 1) +} + +func (c Comment) LeadingWhitespace() string { + item := c.AsItem() + span := c.fileInfo.items[item] + var prevEnd int + if item > 0 { + prevItem := c.fileInfo.items[item-1] + prevEnd = prevItem.offset + prevItem.length + } + return string(c.fileInfo.data[prevEnd:span.offset]) +} + +func (c Comment) RawText() string { + span := c.fileInfo.items[c.AsItem()] + return string(c.fileInfo.data[span.offset : span.offset+span.length]) +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/identifiers.go b/vendor/github.com/bufbuild/protocompile/ast/identifiers.go new file mode 100644 index 00000000000..275999291ff --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/identifiers.go @@ -0,0 +1,148 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import ( + "fmt" + "strings" +) + +// Identifier is a possibly-qualified name. This is used to distinguish +// ValueNode values that are references/identifiers vs. those that are +// string literals. +type Identifier string + +// IdentValueNode is an AST node that represents an identifier. +type IdentValueNode interface { + ValueNode + AsIdentifier() Identifier +} + +var _ IdentValueNode = (*IdentNode)(nil) +var _ IdentValueNode = (*CompoundIdentNode)(nil) + +// IdentNode represents a simple, unqualified identifier. These are used to name +// elements declared in a protobuf file or to refer to elements. Example: +// +// foobar +type IdentNode struct { + terminalNode + Val string +} + +// NewIdentNode creates a new *IdentNode. The given val is the identifier text. +func NewIdentNode(val string, tok Token) *IdentNode { + return &IdentNode{ + terminalNode: tok.asTerminalNode(), + Val: val, + } +} + +func (n *IdentNode) Value() interface{} { + return n.AsIdentifier() +} + +func (n *IdentNode) AsIdentifier() Identifier { + return Identifier(n.Val) +} + +// ToKeyword is used to convert identifiers to keywords. Since keywords are not +// reserved in the protobuf language, they are initially lexed as identifiers +// and then converted to keywords based on context. +func (n *IdentNode) ToKeyword() *KeywordNode { + return (*KeywordNode)(n) +} + +// CompoundIdentNode represents a qualified identifier. A qualified identifier +// has at least one dot and possibly multiple identifier names (all separated by +// dots). If the identifier has a leading dot, then it is a *fully* qualified +// identifier. Example: +// +// .com.foobar.Baz +type CompoundIdentNode struct { + compositeNode + // Optional leading dot, indicating that the identifier is fully qualified. + LeadingDot *RuneNode + Components []*IdentNode + // Dots[0] is the dot after Components[0]. The length of Dots is always + // one less than the length of Components. + Dots []*RuneNode + // The text value of the identifier, with all components and dots + // concatenated. + Val string +} + +// NewCompoundIdentNode creates a *CompoundIdentNode. The leadingDot may be nil. +// The dots arg must have a length that is one less than the length of +// components. The components arg must not be empty. +func NewCompoundIdentNode(leadingDot *RuneNode, components []*IdentNode, dots []*RuneNode) *CompoundIdentNode { + if len(components) == 0 { + panic("must have at least one component") + } + if len(dots) != len(components)-1 { + panic(fmt.Sprintf("%d components requires %d dots, not %d", len(components), len(components)-1, len(dots))) + } + numChildren := len(components)*2 - 1 + if leadingDot != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + var b strings.Builder + if leadingDot != nil { + children = append(children, leadingDot) + b.WriteRune(leadingDot.Rune) + } + for i, comp := range components { + if i > 0 { + dot := dots[i-1] + children = append(children, dot) + b.WriteRune(dot.Rune) + } + children = append(children, comp) + b.WriteString(comp.Val) + } + return &CompoundIdentNode{ + compositeNode: compositeNode{ + children: children, + }, + LeadingDot: leadingDot, + Components: components, + Dots: dots, + Val: b.String(), + } +} + +func (n *CompoundIdentNode) Value() interface{} { + return n.AsIdentifier() +} + +func (n *CompoundIdentNode) AsIdentifier() Identifier { + return Identifier(n.Val) +} + +// KeywordNode is an AST node that represents a keyword. Keywords are +// like identifiers, but they have special meaning in particular contexts. +// Example: +// +// message +type KeywordNode IdentNode + +// NewKeywordNode creates a new *KeywordNode. The given val is the keyword. +func NewKeywordNode(val string, tok Token) *KeywordNode { + return &KeywordNode{ + terminalNode: tok.asTerminalNode(), + Val: val, + } +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/message.go b/vendor/github.com/bufbuild/protocompile/ast/message.go new file mode 100644 index 00000000000..00dfe45f890 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/message.go @@ -0,0 +1,213 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import "fmt" + +// MessageDeclNode is a node in the AST that defines a message type. This +// includes normal message fields as well as implicit messages: +// - *MessageNode +// - *GroupNode (the group is a field and inline message type) +// - *MapFieldNode (map fields implicitly define a MapEntry message type) +// +// This also allows NoSourceNode to be used in place of one of the above +// for some usages. +type MessageDeclNode interface { + Node + MessageName() Node +} + +var _ MessageDeclNode = (*MessageNode)(nil) +var _ MessageDeclNode = (*GroupNode)(nil) +var _ MessageDeclNode = (*MapFieldNode)(nil) +var _ MessageDeclNode = NoSourceNode{} + +// MessageNode represents a message declaration. Example: +// +// message Foo { +// string name = 1; +// repeated string labels = 2; +// bytes extra = 3; +// } +type MessageNode struct { + compositeNode + Keyword *KeywordNode + Name *IdentNode + MessageBody +} + +func (*MessageNode) fileElement() {} +func (*MessageNode) msgElement() {} + +// NewMessageNode creates a new *MessageNode. All arguments must be non-nil. +// - keyword: The token corresponding to the "message" keyword. +// - name: The token corresponding to the field's name. +// - openBrace: The token corresponding to the "{" rune that starts the body. +// - decls: All declarations inside the message body. +// - closeBrace: The token corresponding to the "}" rune that ends the body. +func NewMessageNode(keyword *KeywordNode, name *IdentNode, openBrace *RuneNode, decls []MessageElement, closeBrace *RuneNode) *MessageNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if openBrace == nil { + panic("openBrace is nil") + } + if closeBrace == nil { + panic("closeBrace is nil") + } + children := make([]Node, 0, 4+len(decls)) + children = append(children, keyword, name, openBrace) + for _, decl := range decls { + children = append(children, decl) + } + children = append(children, closeBrace) + + ret := &MessageNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Name: name, + } + populateMessageBody(&ret.MessageBody, openBrace, decls, closeBrace) + return ret +} + +func (n *MessageNode) MessageName() Node { + return n.Name +} + +// MessageBody represents the body of a message. It is used by both +// MessageNodes and GroupNodes. +type MessageBody struct { + OpenBrace *RuneNode + Decls []MessageElement + CloseBrace *RuneNode +} + +func populateMessageBody(m *MessageBody, openBrace *RuneNode, decls []MessageElement, closeBrace *RuneNode) { + m.OpenBrace = openBrace + m.Decls = decls + for _, decl := range decls { + switch decl.(type) { + case *OptionNode, *FieldNode, *MapFieldNode, *GroupNode, *OneOfNode, + *MessageNode, *EnumNode, *ExtendNode, *ExtensionRangeNode, + *ReservedNode, *EmptyDeclNode: + default: + panic(fmt.Sprintf("invalid MessageElement type: %T", decl)) + } + } + m.CloseBrace = closeBrace +} + +// MessageElement is an interface implemented by all AST nodes that can +// appear in a message body. +type MessageElement interface { + Node + msgElement() +} + +var _ MessageElement = (*OptionNode)(nil) +var _ MessageElement = (*FieldNode)(nil) +var _ MessageElement = (*MapFieldNode)(nil) +var _ MessageElement = (*OneOfNode)(nil) +var _ MessageElement = (*GroupNode)(nil) +var _ MessageElement = (*MessageNode)(nil) +var _ MessageElement = (*EnumNode)(nil) +var _ MessageElement = (*ExtendNode)(nil) +var _ MessageElement = (*ExtensionRangeNode)(nil) +var _ MessageElement = (*ReservedNode)(nil) +var _ MessageElement = (*EmptyDeclNode)(nil) + +// ExtendNode represents a declaration of extension fields. Example: +// +// extend google.protobuf.FieldOptions { +// bool redacted = 33333; +// } +type ExtendNode struct { + compositeNode + Keyword *KeywordNode + Extendee IdentValueNode + OpenBrace *RuneNode + Decls []ExtendElement + CloseBrace *RuneNode +} + +func (*ExtendNode) fileElement() {} +func (*ExtendNode) msgElement() {} + +// NewExtendNode creates a new *ExtendNode. All arguments must be non-nil. +// - keyword: The token corresponding to the "extend" keyword. +// - extendee: The token corresponding to the name of the extended message. +// - openBrace: The token corresponding to the "{" rune that starts the body. +// - decls: All declarations inside the message body. +// - closeBrace: The token corresponding to the "}" rune that ends the body. +func NewExtendNode(keyword *KeywordNode, extendee IdentValueNode, openBrace *RuneNode, decls []ExtendElement, closeBrace *RuneNode) *ExtendNode { + if keyword == nil { + panic("keyword is nil") + } + if extendee == nil { + panic("extendee is nil") + } + if openBrace == nil { + panic("openBrace is nil") + } + if closeBrace == nil { + panic("closeBrace is nil") + } + children := make([]Node, 0, 4+len(decls)) + children = append(children, keyword, extendee, openBrace) + for _, decl := range decls { + children = append(children, decl) + } + children = append(children, closeBrace) + + ret := &ExtendNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Extendee: extendee, + OpenBrace: openBrace, + Decls: decls, + CloseBrace: closeBrace, + } + for _, decl := range decls { + switch decl := decl.(type) { + case *FieldNode: + decl.Extendee = ret + case *GroupNode: + decl.Extendee = ret + case *EmptyDeclNode: + default: + panic(fmt.Sprintf("invalid ExtendElement type: %T", decl)) + } + } + return ret +} + +// ExtendElement is an interface implemented by all AST nodes that can +// appear in the body of an extends declaration. +type ExtendElement interface { + Node + extendElement() +} + +var _ ExtendElement = (*FieldNode)(nil) +var _ ExtendElement = (*GroupNode)(nil) +var _ ExtendElement = (*EmptyDeclNode)(nil) diff --git a/vendor/github.com/bufbuild/protocompile/ast/no_source.go b/vendor/github.com/bufbuild/protocompile/ast/no_source.go new file mode 100644 index 00000000000..d66d9395754 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/no_source.go @@ -0,0 +1,119 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +// UnknownPos is a placeholder position when only the source file +// name is known. +func UnknownPos(filename string) SourcePos { + return SourcePos{Filename: filename} +} + +// NoSourceNode is a placeholder AST node that implements numerous +// interfaces in this package. It can be used to represent an AST +// element for a file whose source is not available. +type NoSourceNode struct { + filename string +} + +// NewNoSourceNode creates a new NoSourceNode for the given filename. +func NewNoSourceNode(filename string) NoSourceNode { + return NoSourceNode{filename: filename} +} + +func (n NoSourceNode) Name() string { + return n.filename +} + +func (n NoSourceNode) Start() Token { + return 0 +} + +func (n NoSourceNode) End() Token { + return 0 +} + +func (n NoSourceNode) NodeInfo(Node) NodeInfo { + return NodeInfo{ + fileInfo: &FileInfo{name: n.filename}, + } +} + +func (n NoSourceNode) GetSyntax() Node { + return n +} + +func (n NoSourceNode) GetName() Node { + return n +} + +func (n NoSourceNode) GetValue() ValueNode { + return n +} + +func (n NoSourceNode) FieldLabel() Node { + return n +} + +func (n NoSourceNode) FieldName() Node { + return n +} + +func (n NoSourceNode) FieldType() Node { + return n +} + +func (n NoSourceNode) FieldTag() Node { + return n +} + +func (n NoSourceNode) FieldExtendee() Node { + return n +} + +func (n NoSourceNode) GetGroupKeyword() Node { + return n +} + +func (n NoSourceNode) GetOptions() *CompactOptionsNode { + return nil +} + +func (n NoSourceNode) RangeStart() Node { + return n +} + +func (n NoSourceNode) RangeEnd() Node { + return n +} + +func (n NoSourceNode) GetNumber() Node { + return n +} + +func (n NoSourceNode) MessageName() Node { + return n +} + +func (n NoSourceNode) GetInputType() Node { + return n +} + +func (n NoSourceNode) GetOutputType() Node { + return n +} + +func (n NoSourceNode) Value() interface{} { + return nil +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/node.go b/vendor/github.com/bufbuild/protocompile/ast/node.go new file mode 100644 index 00000000000..63a76c79883 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/node.go @@ -0,0 +1,139 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +// Node is the interface implemented by all nodes in the AST. It +// provides information about the span of this AST node in terms +// of location in the source file. It also provides information +// about all prior comments (attached as leading comments) and +// optional subsequent comments (attached as trailing comments). +type Node interface { + Start() Token + End() Token +} + +// TerminalNode represents a leaf in the AST. These represent +// the items/lexemes in the protobuf language. Comments and +// whitespace are accumulated by the lexer and associated with +// the following lexed token. +type TerminalNode interface { + Node + Token() Token +} + +var _ TerminalNode = (*StringLiteralNode)(nil) +var _ TerminalNode = (*UintLiteralNode)(nil) +var _ TerminalNode = (*FloatLiteralNode)(nil) +var _ TerminalNode = (*IdentNode)(nil) +var _ TerminalNode = (*SpecialFloatLiteralNode)(nil) +var _ TerminalNode = (*KeywordNode)(nil) +var _ TerminalNode = (*RuneNode)(nil) + +// CompositeNode represents any non-terminal node in the tree. These +// are interior or root nodes and have child nodes. +type CompositeNode interface { + Node + // Children contains all AST nodes that are immediate children of this one. + Children() []Node +} + +// terminalNode contains bookkeeping shared by all TerminalNode +// implementations. It is embedded in all such node types in this +// package. It provides the implementation of the TerminalNode +// interface. +type terminalNode Token + +func (n terminalNode) Start() Token { + return Token(n) +} + +func (n terminalNode) End() Token { + return Token(n) +} + +func (n terminalNode) Token() Token { + return Token(n) +} + +// compositeNode contains bookkeeping shared by all CompositeNode +// implementations. It is embedded in all such node types in this +// package. It provides the implementation of the CompositeNode +// interface. +type compositeNode struct { + children []Node +} + +func (n *compositeNode) Children() []Node { + return n.children +} + +func (n *compositeNode) Start() Token { + return n.children[0].Start() +} + +func (n *compositeNode) End() Token { + return n.children[len(n.children)-1].End() +} + +// RuneNode represents a single rune in protobuf source. Runes +// are typically collected into items, but some runes stand on +// their own, such as punctuation/symbols like commas, semicolons, +// equals signs, open and close symbols (braces, brackets, angles, +// and parentheses), and periods/dots. +// TODO: make this more compact; if runes don't have attributed comments +// then we don't need a Token to represent them and only need an offset +// into the file's contents. +type RuneNode struct { + terminalNode + Rune rune +} + +// NewRuneNode creates a new *RuneNode with the given properties. +func NewRuneNode(r rune, tok Token) *RuneNode { + return &RuneNode{ + terminalNode: tok.asTerminalNode(), + Rune: r, + } +} + +// EmptyDeclNode represents an empty declaration in protobuf source. +// These amount to extra semicolons, with no actual content preceding +// the semicolon. +type EmptyDeclNode struct { + compositeNode + Semicolon *RuneNode +} + +// NewEmptyDeclNode creates a new *EmptyDeclNode. The one argument must +// be non-nil. +func NewEmptyDeclNode(semicolon *RuneNode) *EmptyDeclNode { + if semicolon == nil { + panic("semicolon is nil") + } + return &EmptyDeclNode{ + compositeNode: compositeNode{ + children: []Node{semicolon}, + }, + Semicolon: semicolon, + } +} + +func (e *EmptyDeclNode) fileElement() {} +func (e *EmptyDeclNode) msgElement() {} +func (e *EmptyDeclNode) extendElement() {} +func (e *EmptyDeclNode) oneOfElement() {} +func (e *EmptyDeclNode) enumElement() {} +func (e *EmptyDeclNode) serviceElement() {} +func (e *EmptyDeclNode) methodElement() {} diff --git a/vendor/github.com/bufbuild/protocompile/ast/options.go b/vendor/github.com/bufbuild/protocompile/ast/options.go new file mode 100644 index 00000000000..497ad44b5b1 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/options.go @@ -0,0 +1,373 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import "fmt" + +// OptionDeclNode is a placeholder interface for AST nodes that represent +// options. This allows NoSourceNode to be used in place of *OptionNode +// for some usages. +type OptionDeclNode interface { + Node + GetName() Node + GetValue() ValueNode +} + +var _ OptionDeclNode = (*OptionNode)(nil) +var _ OptionDeclNode = NoSourceNode{} + +// OptionNode represents the declaration of a single option for an element. +// It is used both for normal option declarations (start with "option" keyword +// and end with semicolon) and for compact options found in fields, enum values, +// and extension ranges. Example: +// +// option (custom.option) = "foo"; +type OptionNode struct { + compositeNode + Keyword *KeywordNode // absent for compact options + Name *OptionNameNode + Equals *RuneNode + Val ValueNode + Semicolon *RuneNode // absent for compact options +} + +func (n *OptionNode) fileElement() {} +func (n *OptionNode) msgElement() {} +func (n *OptionNode) oneOfElement() {} +func (n *OptionNode) enumElement() {} +func (n *OptionNode) serviceElement() {} +func (n *OptionNode) methodElement() {} + +// NewOptionNode creates a new *OptionNode for a full option declaration (as +// used in files, messages, oneofs, enums, services, and methods). All arguments +// must be non-nil. (Also see NewCompactOptionNode.) +// - keyword: The token corresponding to the "option" keyword. +// - name: The token corresponding to the name of the option. +// - equals: The token corresponding to the "=" rune after the name. +// - val: The token corresponding to the option value. +// - semicolon: The token corresponding to the ";" rune that ends the declaration. +func NewOptionNode(keyword *KeywordNode, name *OptionNameNode, equals *RuneNode, val ValueNode, semicolon *RuneNode) *OptionNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if equals == nil { + panic("equals is nil") + } + if val == nil { + panic("val is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + children := []Node{keyword, name, equals, val, semicolon} + return &OptionNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Name: name, + Equals: equals, + Val: val, + Semicolon: semicolon, + } +} + +// NewCompactOptionNode creates a new *OptionNode for a full compact declaration +// (as used in fields, enum values, and extension ranges). All arguments must be +// non-nil. +// - name: The token corresponding to the name of the option. +// - equals: The token corresponding to the "=" rune after the name. +// - val: The token corresponding to the option value. +func NewCompactOptionNode(name *OptionNameNode, equals *RuneNode, val ValueNode) *OptionNode { + if name == nil { + panic("name is nil") + } + if equals == nil { + panic("equals is nil") + } + if val == nil { + panic("val is nil") + } + children := []Node{name, equals, val} + return &OptionNode{ + compositeNode: compositeNode{ + children: children, + }, + Name: name, + Equals: equals, + Val: val, + } +} + +func (n *OptionNode) GetName() Node { + return n.Name +} + +func (n *OptionNode) GetValue() ValueNode { + return n.Val +} + +// OptionNameNode represents an option name or even a traversal through message +// types to name a nested option field. Example: +// +// (foo.bar).baz.(bob) +type OptionNameNode struct { + compositeNode + Parts []*FieldReferenceNode + // Dots represent the separating '.' characters between name parts. The + // length of this slice must be exactly len(Parts)-1, each item in Parts + // having a corresponding item in this slice *except the last* (since a + // trailing dot is not allowed). + // + // These do *not* include dots that are inside of an extension name. For + // example: (foo.bar).baz.(bob) has three parts: + // 1. (foo.bar) - an extension name + // 2. baz - a regular field in foo.bar + // 3. (bob) - an extension field in baz + // Note that the dot in foo.bar will thus not be present in Dots but is + // instead in Parts[0]. + Dots []*RuneNode +} + +// NewOptionNameNode creates a new *OptionNameNode. The dots arg must have a +// length that is one less than the length of parts. The parts arg must not be +// empty. +func NewOptionNameNode(parts []*FieldReferenceNode, dots []*RuneNode) *OptionNameNode { + if len(parts) == 0 { + panic("must have at least one part") + } + if len(dots) != len(parts)-1 { + panic(fmt.Sprintf("%d parts requires %d dots, not %d", len(parts), len(parts)-1, len(dots))) + } + children := make([]Node, 0, len(parts)*2-1) + for i, part := range parts { + if part == nil { + panic(fmt.Sprintf("parts[%d] is nil", i)) + } + if i > 0 { + if dots[i-1] == nil { + panic(fmt.Sprintf("dots[%d] is nil", i-1)) + } + children = append(children, dots[i-1]) + } + children = append(children, part) + } + return &OptionNameNode{ + compositeNode: compositeNode{ + children: children, + }, + Parts: parts, + Dots: dots, + } +} + +// FieldReferenceNode is a reference to a field name. It can indicate a regular +// field (simple unqualified name), an extension field (possibly-qualified name +// that is enclosed either in brackets or parentheses), or an "any" type +// reference (a type URL in the form "server.host/fully.qualified.Name" that is +// enclosed in brackets). +// +// Extension names are used in options to refer to custom options (which are +// actually extensions), in which case the name is enclosed in parentheses "(" +// and ")". They can also be used to refer to extension fields of options. +// +// Extension names are also used in message literals to set extension fields, +// in which case the name is enclosed in square brackets "[" and "]". +// +// "Any" type references can only be used in message literals, and are not +// allowed in option names. They are always enclosed in square brackets. An +// "any" type reference is distinguished from an extension name by the presence +// of a slash, which must be present in an "any" type reference and must be +// absent in an extension name. +// +// Examples: +// +// foobar +// (foo.bar) +// [foo.bar] +// [type.googleapis.com/foo.bar] +type FieldReferenceNode struct { + compositeNode + Open *RuneNode // only present for extension names and "any" type references + + // only present for "any" type references + URLPrefix IdentValueNode + Slash *RuneNode + + Name IdentValueNode + + Close *RuneNode // only present for extension names and "any" type references +} + +// NewFieldReferenceNode creates a new *FieldReferenceNode for a regular field. +// The name arg must not be nil. +func NewFieldReferenceNode(name *IdentNode) *FieldReferenceNode { + if name == nil { + panic("name is nil") + } + children := []Node{name} + return &FieldReferenceNode{ + compositeNode: compositeNode{ + children: children, + }, + Name: name, + } +} + +// NewExtensionFieldReferenceNode creates a new *FieldReferenceNode for an +// extension field. All args must be non-nil. The openSym and closeSym runes +// should be "(" and ")" or "[" and "]". +func NewExtensionFieldReferenceNode(openSym *RuneNode, name IdentValueNode, closeSym *RuneNode) *FieldReferenceNode { + if name == nil { + panic("name is nil") + } + if openSym == nil { + panic("openSym is nil") + } + if closeSym == nil { + panic("closeSym is nil") + } + children := []Node{openSym, name, closeSym} + return &FieldReferenceNode{ + compositeNode: compositeNode{ + children: children, + }, + Open: openSym, + Name: name, + Close: closeSym, + } +} + +// NewAnyTypeReferenceNode creates a new *FieldReferenceNode for an "any" +// type reference. All args must be non-nil. The openSym and closeSym runes +// should be "[" and "]". The slashSym run should be "/". +func NewAnyTypeReferenceNode(openSym *RuneNode, urlPrefix IdentValueNode, slashSym *RuneNode, name IdentValueNode, closeSym *RuneNode) *FieldReferenceNode { + if name == nil { + panic("name is nil") + } + if openSym == nil { + panic("openSym is nil") + } + if closeSym == nil { + panic("closeSym is nil") + } + if urlPrefix == nil { + panic("urlPrefix is nil") + } + if slashSym == nil { + panic("slashSym is nil") + } + children := []Node{openSym, urlPrefix, slashSym, name, closeSym} + return &FieldReferenceNode{ + compositeNode: compositeNode{ + children: children, + }, + Open: openSym, + URLPrefix: urlPrefix, + Slash: slashSym, + Name: name, + Close: closeSym, + } +} + +// IsExtension reports if this is an extension name or not (e.g. enclosed in +// punctuation, such as parentheses or brackets). +func (a *FieldReferenceNode) IsExtension() bool { + return a.Open != nil && a.Slash == nil +} + +// IsAnyTypeReference reports if this is an Any type reference. +func (a *FieldReferenceNode) IsAnyTypeReference() bool { + return a.Slash != nil +} + +func (a *FieldReferenceNode) Value() string { + if a.Open != nil { + if a.Slash != nil { + return string(a.Open.Rune) + string(a.URLPrefix.AsIdentifier()) + string(a.Slash.Rune) + string(a.Name.AsIdentifier()) + string(a.Close.Rune) + } + return string(a.Open.Rune) + string(a.Name.AsIdentifier()) + string(a.Close.Rune) + } + return string(a.Name.AsIdentifier()) +} + +// CompactOptionsNode represents a compact options declaration, as used with +// fields, enum values, and extension ranges. Example: +// +// [deprecated = true, json_name = "foo_bar"] +type CompactOptionsNode struct { + compositeNode + OpenBracket *RuneNode + Options []*OptionNode + // Commas represent the separating ',' characters between options. The + // length of this slice must be exactly len(Options)-1, with each item + // in Options having a corresponding item in this slice *except the last* + // (since a trailing comma is not allowed). + Commas []*RuneNode + CloseBracket *RuneNode +} + +// NewCompactOptionsNode creates a *CompactOptionsNode. All args must be +// non-nil. The commas arg must have a length that is one less than the +// length of opts. The opts arg must not be empty. +func NewCompactOptionsNode(openBracket *RuneNode, opts []*OptionNode, commas []*RuneNode, closeBracket *RuneNode) *CompactOptionsNode { + if openBracket == nil { + panic("openBracket is nil") + } + if closeBracket == nil { + panic("closeBracket is nil") + } + if len(opts) == 0 { + panic("must have at least one part") + } + if len(commas) != len(opts)-1 { + panic(fmt.Sprintf("%d opts requires %d commas, not %d", len(opts), len(opts)-1, len(commas))) + } + children := make([]Node, 0, len(opts)*2+1) + children = append(children, openBracket) + for i, opt := range opts { + if i > 0 { + if commas[i-1] == nil { + panic(fmt.Sprintf("commas[%d] is nil", i-1)) + } + children = append(children, commas[i-1]) + } + if opt == nil { + panic(fmt.Sprintf("opts[%d] is nil", i)) + } + children = append(children, opt) + } + children = append(children, closeBracket) + + return &CompactOptionsNode{ + compositeNode: compositeNode{ + children: children, + }, + OpenBracket: openBracket, + Options: opts, + Commas: commas, + CloseBracket: closeBracket, + } +} + +func (e *CompactOptionsNode) GetElements() []*OptionNode { + if e == nil { + return nil + } + return e.Options +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/ranges.go b/vendor/github.com/bufbuild/protocompile/ast/ranges.go new file mode 100644 index 00000000000..453e5a06960 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/ranges.go @@ -0,0 +1,319 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import "fmt" + +// ExtensionRangeNode represents an extension range declaration in an extendable +// message. Example: +// +// extensions 100 to max; +type ExtensionRangeNode struct { + compositeNode + Keyword *KeywordNode + Ranges []*RangeNode + // Commas represent the separating ',' characters between ranges. The + // length of this slice must be exactly len(Ranges)-1, each item in Ranges + // having a corresponding item in this slice *except the last* (since a + // trailing comma is not allowed). + Commas []*RuneNode + Options *CompactOptionsNode + Semicolon *RuneNode +} + +func (e *ExtensionRangeNode) msgElement() {} + +// NewExtensionRangeNode creates a new *ExtensionRangeNode. All args must be +// non-nil except opts, which may be nil. +// - keyword: The token corresponding to the "extends" keyword. +// - ranges: One or more range expressions. +// - commas: Tokens that represent the "," runes that delimit the range expressions. +// The length of commas must be one less than the length of ranges. +// - opts: The node corresponding to options that apply to each of the ranges. +// - semicolon The token corresponding to the ";" rune that ends the declaration. +func NewExtensionRangeNode(keyword *KeywordNode, ranges []*RangeNode, commas []*RuneNode, opts *CompactOptionsNode, semicolon *RuneNode) *ExtensionRangeNode { + if keyword == nil { + panic("keyword is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + if len(ranges) == 0 { + panic("must have at least one range") + } + if len(commas) != len(ranges)-1 { + panic(fmt.Sprintf("%d ranges requires %d commas, not %d", len(ranges), len(ranges)-1, len(commas))) + } + numChildren := len(ranges)*2 + 1 + if opts != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + children = append(children, keyword) + for i, rng := range ranges { + if i > 0 { + if commas[i-1] == nil { + panic(fmt.Sprintf("commas[%d] is nil", i-1)) + } + children = append(children, commas[i-1]) + } + if rng == nil { + panic(fmt.Sprintf("ranges[%d] is nil", i)) + } + children = append(children, rng) + } + if opts != nil { + children = append(children, opts) + } + children = append(children, semicolon) + return &ExtensionRangeNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Ranges: ranges, + Commas: commas, + Options: opts, + Semicolon: semicolon, + } +} + +// RangeDeclNode is a placeholder interface for AST nodes that represent +// numeric values. This allows NoSourceNode to be used in place of *RangeNode +// for some usages. +type RangeDeclNode interface { + Node + RangeStart() Node + RangeEnd() Node +} + +var _ RangeDeclNode = (*RangeNode)(nil) +var _ RangeDeclNode = NoSourceNode{} + +// RangeNode represents a range expression, used in both extension ranges and +// reserved ranges. Example: +// +// 1000 to max +type RangeNode struct { + compositeNode + StartVal IntValueNode + // if To is non-nil, then exactly one of EndVal or Max must also be non-nil + To *KeywordNode + // EndVal and Max are mutually exclusive + EndVal IntValueNode + Max *KeywordNode +} + +// NewRangeNode creates a new *RangeNode. The start argument must be non-nil. +// The to argument represents the "to" keyword. If present (i.e. if it is non-nil), +// then so must be exactly one of end or max. If max is non-nil, it indicates a +// "100 to max" style range. But if end is non-nil, the end of the range is a +// literal, such as "100 to 200". +func NewRangeNode(start IntValueNode, to *KeywordNode, end IntValueNode, max *KeywordNode) *RangeNode { + if start == nil { + panic("start is nil") + } + numChildren := 1 + if to != nil { + if end == nil && max == nil { + panic("to is not nil, but end and max both are") + } + if end != nil && max != nil { + panic("end and max cannot be both non-nil") + } + numChildren = 3 + } else { + if end != nil { + panic("to is nil, but end is not") + } + if max != nil { + panic("to is nil, but max is not") + } + } + children := make([]Node, 0, numChildren) + children = append(children, start) + if to != nil { + children = append(children, to) + if end != nil { + children = append(children, end) + } else { + children = append(children, max) + } + } + return &RangeNode{ + compositeNode: compositeNode{ + children: children, + }, + StartVal: start, + To: to, + EndVal: end, + Max: max, + } +} + +func (n *RangeNode) RangeStart() Node { + return n.StartVal +} + +func (n *RangeNode) RangeEnd() Node { + if n.Max != nil { + return n.Max + } + if n.EndVal != nil { + return n.EndVal + } + return n.StartVal +} + +func (n *RangeNode) StartValue() interface{} { + return n.StartVal.Value() +} + +func (n *RangeNode) StartValueAsInt32(min, max int32) (int32, bool) { + return AsInt32(n.StartVal, min, max) +} + +func (n *RangeNode) EndValue() interface{} { + if n.EndVal == nil { + return nil + } + return n.EndVal.Value() +} + +func (n *RangeNode) EndValueAsInt32(min, max int32) (int32, bool) { + if n.Max != nil { + return max, true + } + if n.EndVal == nil { + return n.StartValueAsInt32(min, max) + } + return AsInt32(n.EndVal, min, max) +} + +// ReservedNode represents reserved declaration, which can be used to reserve +// either names or numbers. Examples: +// +// reserved 1, 10-12, 15; +// reserved "foo", "bar", "baz"; +type ReservedNode struct { + compositeNode + Keyword *KeywordNode + // If non-empty, this node represents reserved ranges and Names will be empty. + Ranges []*RangeNode + // If non-empty, this node represents reserved names and Ranges will be empty. + Names []StringValueNode + // Commas represent the separating ',' characters between options. The + // length of this slice must be exactly len(Ranges)-1 or len(Names)-1, depending + // on whether this node represents reserved ranges or reserved names. Each item + // in Ranges or Names has a corresponding item in this slice *except the last* + // (since a trailing comma is not allowed). + Commas []*RuneNode + Semicolon *RuneNode +} + +func (*ReservedNode) msgElement() {} +func (*ReservedNode) enumElement() {} + +// NewReservedRangesNode creates a new *ReservedNode that represents reserved +// numeric ranges. All args must be non-nil. +// - keyword: The token corresponding to the "reserved" keyword. +// - ranges: One or more range expressions. +// - commas: Tokens that represent the "," runes that delimit the range expressions. +// The length of commas must be one less than the length of ranges. +// - semicolon The token corresponding to the ";" rune that ends the declaration. +func NewReservedRangesNode(keyword *KeywordNode, ranges []*RangeNode, commas []*RuneNode, semicolon *RuneNode) *ReservedNode { + if keyword == nil { + panic("keyword is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + if len(ranges) == 0 { + panic("must have at least one range") + } + if len(commas) != len(ranges)-1 { + panic(fmt.Sprintf("%d ranges requires %d commas, not %d", len(ranges), len(ranges)-1, len(commas))) + } + children := make([]Node, 0, len(ranges)*2+1) + children = append(children, keyword) + for i, rng := range ranges { + if i > 0 { + if commas[i-1] == nil { + panic(fmt.Sprintf("commas[%d] is nil", i-1)) + } + children = append(children, commas[i-1]) + } + if rng == nil { + panic(fmt.Sprintf("ranges[%d] is nil", i)) + } + children = append(children, rng) + } + children = append(children, semicolon) + return &ReservedNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Ranges: ranges, + Commas: commas, + Semicolon: semicolon, + } +} + +// NewReservedNamesNode creates a new *ReservedNode that represents reserved +// names. All args must be non-nil. +// - keyword: The token corresponding to the "reserved" keyword. +// - names: One or more names. +// - commas: Tokens that represent the "," runes that delimit the names. +// The length of commas must be one less than the length of names. +// - semicolon The token corresponding to the ";" rune that ends the declaration. +func NewReservedNamesNode(keyword *KeywordNode, names []StringValueNode, commas []*RuneNode, semicolon *RuneNode) *ReservedNode { + if keyword == nil { + panic("keyword is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + if len(names) == 0 { + panic("must have at least one name") + } + if len(commas) != len(names)-1 { + panic(fmt.Sprintf("%d names requires %d commas, not %d", len(names), len(names)-1, len(commas))) + } + children := make([]Node, 0, len(names)*2+1) + children = append(children, keyword) + for i, name := range names { + if i > 0 { + if commas[i-1] == nil { + panic(fmt.Sprintf("commas[%d] is nil", i-1)) + } + children = append(children, commas[i-1]) + } + if name == nil { + panic(fmt.Sprintf("names[%d] is nil", i)) + } + children = append(children, name) + } + children = append(children, semicolon) + return &ReservedNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Names: names, + Commas: commas, + Semicolon: semicolon, + } +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/service.go b/vendor/github.com/bufbuild/protocompile/ast/service.go new file mode 100644 index 00000000000..c1807488c00 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/service.go @@ -0,0 +1,286 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import "fmt" + +// ServiceNode represents a service declaration. Example: +// +// service Foo { +// rpc Bar (Baz) returns (Bob); +// rpc Frobnitz (stream Parts) returns (Gyzmeaux); +// } +type ServiceNode struct { + compositeNode + Keyword *KeywordNode + Name *IdentNode + OpenBrace *RuneNode + Decls []ServiceElement + CloseBrace *RuneNode +} + +func (*ServiceNode) fileElement() {} + +// NewServiceNode creates a new *ServiceNode. All arguments must be non-nil. +// - keyword: The token corresponding to the "service" keyword. +// - name: The token corresponding to the service's name. +// - openBrace: The token corresponding to the "{" rune that starts the body. +// - decls: All declarations inside the service body. +// - closeBrace: The token corresponding to the "}" rune that ends the body. +func NewServiceNode(keyword *KeywordNode, name *IdentNode, openBrace *RuneNode, decls []ServiceElement, closeBrace *RuneNode) *ServiceNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if openBrace == nil { + panic("openBrace is nil") + } + if closeBrace == nil { + panic("closeBrace is nil") + } + children := make([]Node, 0, 4+len(decls)) + children = append(children, keyword, name, openBrace) + for _, decl := range decls { + switch decl := decl.(type) { + case *OptionNode, *RPCNode, *EmptyDeclNode: + default: + panic(fmt.Sprintf("invalid ServiceElement type: %T", decl)) + } + children = append(children, decl) + } + children = append(children, closeBrace) + + return &ServiceNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Name: name, + OpenBrace: openBrace, + Decls: decls, + CloseBrace: closeBrace, + } +} + +// ServiceElement is an interface implemented by all AST nodes that can +// appear in the body of a service declaration. +type ServiceElement interface { + Node + serviceElement() +} + +var _ ServiceElement = (*OptionNode)(nil) +var _ ServiceElement = (*RPCNode)(nil) +var _ ServiceElement = (*EmptyDeclNode)(nil) + +// RPCDeclNode is a placeholder interface for AST nodes that represent RPC +// declarations. This allows NoSourceNode to be used in place of *RPCNode +// for some usages. +type RPCDeclNode interface { + Node + GetName() Node + GetInputType() Node + GetOutputType() Node +} + +var _ RPCDeclNode = (*RPCNode)(nil) +var _ RPCDeclNode = NoSourceNode{} + +// RPCNode represents an RPC declaration. Example: +// +// rpc Foo (Bar) returns (Baz); +type RPCNode struct { + compositeNode + Keyword *KeywordNode + Name *IdentNode + Input *RPCTypeNode + Returns *KeywordNode + Output *RPCTypeNode + Semicolon *RuneNode + OpenBrace *RuneNode + Decls []RPCElement + CloseBrace *RuneNode +} + +func (n *RPCNode) serviceElement() {} + +// NewRPCNode creates a new *RPCNode with no body. All arguments must be non-nil. +// - keyword: The token corresponding to the "rpc" keyword. +// - name: The token corresponding to the RPC's name. +// - input: The token corresponding to the RPC input message type. +// - returns: The token corresponding to the "returns" keyword that precedes the output type. +// - output: The token corresponding to the RPC output message type. +// - semicolon: The token corresponding to the ";" rune that ends the declaration. +func NewRPCNode(keyword *KeywordNode, name *IdentNode, input *RPCTypeNode, returns *KeywordNode, output *RPCTypeNode, semicolon *RuneNode) *RPCNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if input == nil { + panic("input is nil") + } + if returns == nil { + panic("returns is nil") + } + if output == nil { + panic("output is nil") + } + if semicolon == nil { + panic("semicolon is nil") + } + children := []Node{keyword, name, input, returns, output, semicolon} + return &RPCNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Name: name, + Input: input, + Returns: returns, + Output: output, + Semicolon: semicolon, + } +} + +// NewRPCNodeWithBody creates a new *RPCNode that includes a body (and possibly +// options). All arguments must be non-nil. +// - keyword: The token corresponding to the "rpc" keyword. +// - name: The token corresponding to the RPC's name. +// - input: The token corresponding to the RPC input message type. +// - returns: The token corresponding to the "returns" keyword that precedes the output type. +// - output: The token corresponding to the RPC output message type. +// - openBrace: The token corresponding to the "{" rune that starts the body. +// - decls: All declarations inside the RPC body. +// - closeBrace: The token corresponding to the "}" rune that ends the body. +func NewRPCNodeWithBody(keyword *KeywordNode, name *IdentNode, input *RPCTypeNode, returns *KeywordNode, output *RPCTypeNode, openBrace *RuneNode, decls []RPCElement, closeBrace *RuneNode) *RPCNode { + if keyword == nil { + panic("keyword is nil") + } + if name == nil { + panic("name is nil") + } + if input == nil { + panic("input is nil") + } + if returns == nil { + panic("returns is nil") + } + if output == nil { + panic("output is nil") + } + if openBrace == nil { + panic("openBrace is nil") + } + if closeBrace == nil { + panic("closeBrace is nil") + } + children := make([]Node, 0, 7+len(decls)) + children = append(children, keyword, name, input, returns, output, openBrace) + for _, decl := range decls { + switch decl := decl.(type) { + case *OptionNode, *EmptyDeclNode: + default: + panic(fmt.Sprintf("invalid RPCElement type: %T", decl)) + } + children = append(children, decl) + } + children = append(children, closeBrace) + + return &RPCNode{ + compositeNode: compositeNode{ + children: children, + }, + Keyword: keyword, + Name: name, + Input: input, + Returns: returns, + Output: output, + OpenBrace: openBrace, + Decls: decls, + CloseBrace: closeBrace, + } +} + +func (n *RPCNode) GetName() Node { + return n.Name +} + +func (n *RPCNode) GetInputType() Node { + return n.Input.MessageType +} + +func (n *RPCNode) GetOutputType() Node { + return n.Output.MessageType +} + +// RPCElement is an interface implemented by all AST nodes that can +// appear in the body of an rpc declaration (aka method). +type RPCElement interface { + Node + methodElement() +} + +var _ RPCElement = (*OptionNode)(nil) +var _ RPCElement = (*EmptyDeclNode)(nil) + +// RPCTypeNode represents the declaration of a request or response type for an +// RPC. Example: +// +// (stream foo.Bar) +type RPCTypeNode struct { + compositeNode + OpenParen *RuneNode + Stream *KeywordNode + MessageType IdentValueNode + CloseParen *RuneNode +} + +// NewRPCTypeNode creates a new *RPCTypeNode. All arguments must be non-nil +// except stream, which may be nil. +// - openParen: The token corresponding to the "(" rune that starts the declaration. +// - stream: The token corresponding to the "stream" keyword or nil if not present. +// - msgType: The token corresponding to the message type's name. +// - closeParen: The token corresponding to the ")" rune that ends the declaration. +func NewRPCTypeNode(openParen *RuneNode, stream *KeywordNode, msgType IdentValueNode, closeParen *RuneNode) *RPCTypeNode { + if openParen == nil { + panic("openParen is nil") + } + if msgType == nil { + panic("msgType is nil") + } + if closeParen == nil { + panic("closeParen is nil") + } + var children []Node + if stream != nil { + children = []Node{openParen, stream, msgType, closeParen} + } else { + children = []Node{openParen, msgType, closeParen} + } + + return &RPCTypeNode{ + compositeNode: compositeNode{ + children: children, + }, + OpenParen: openParen, + Stream: stream, + MessageType: msgType, + CloseParen: closeParen, + } +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/values.go b/vendor/github.com/bufbuild/protocompile/ast/values.go new file mode 100644 index 00000000000..b9f050aa5d6 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/values.go @@ -0,0 +1,558 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import ( + "fmt" + "math" + "strings" +) + +// ValueNode is an AST node that represents a literal value. +// +// It also includes references (e.g. IdentifierValueNode), which can be +// used as values in some contexts, such as describing the default value +// for a field, which can refer to an enum value. +// +// This also allows NoSourceNode to be used in place of a real value node +// for some usages. +type ValueNode interface { + Node + // Value returns a Go representation of the value. For scalars, this + // will be a string, int64, uint64, float64, or bool. This could also + // be an Identifier (e.g. IdentValueNodes). It can also be a composite + // literal: + // * For array literals, the type returned will be []ValueNode + // * For message literals, the type returned will be []*MessageFieldNode + Value() interface{} +} + +var _ ValueNode = (*IdentNode)(nil) +var _ ValueNode = (*CompoundIdentNode)(nil) +var _ ValueNode = (*StringLiteralNode)(nil) +var _ ValueNode = (*CompoundStringLiteralNode)(nil) +var _ ValueNode = (*UintLiteralNode)(nil) +var _ ValueNode = (*PositiveUintLiteralNode)(nil) +var _ ValueNode = (*NegativeIntLiteralNode)(nil) +var _ ValueNode = (*FloatLiteralNode)(nil) +var _ ValueNode = (*SpecialFloatLiteralNode)(nil) +var _ ValueNode = (*SignedFloatLiteralNode)(nil) +var _ ValueNode = (*ArrayLiteralNode)(nil) +var _ ValueNode = (*MessageLiteralNode)(nil) +var _ ValueNode = NoSourceNode{} + +// StringValueNode is an AST node that represents a string literal. +// Such a node can be a single literal (*StringLiteralNode) or a +// concatenation of multiple literals (*CompoundStringLiteralNode). +type StringValueNode interface { + ValueNode + AsString() string +} + +var _ StringValueNode = (*StringLiteralNode)(nil) +var _ StringValueNode = (*CompoundStringLiteralNode)(nil) + +// StringLiteralNode represents a simple string literal. Example: +// +// "proto2" +type StringLiteralNode struct { + terminalNode + // Val is the actual string value that the literal indicates. + Val string +} + +// NewStringLiteralNode creates a new *StringLiteralNode with the given val. +func NewStringLiteralNode(val string, tok Token) *StringLiteralNode { + return &StringLiteralNode{ + terminalNode: tok.asTerminalNode(), + Val: val, + } +} + +func (n *StringLiteralNode) Value() interface{} { + return n.AsString() +} + +func (n *StringLiteralNode) AsString() string { + return n.Val +} + +// CompoundStringLiteralNode represents a compound string literal, which is +// the concatenaton of adjacent string literals. Example: +// +// "this " "is" " all one " "string" +type CompoundStringLiteralNode struct { + compositeNode + Val string +} + +// NewCompoundLiteralStringNode creates a new *CompoundStringLiteralNode that +// consists of the given string components. The components argument may not be +// empty. +func NewCompoundLiteralStringNode(components ...*StringLiteralNode) *CompoundStringLiteralNode { + if len(components) == 0 { + panic("must have at least one component") + } + children := make([]Node, len(components)) + var b strings.Builder + for i, comp := range components { + children[i] = comp + b.WriteString(comp.Val) + } + return &CompoundStringLiteralNode{ + compositeNode: compositeNode{ + children: children, + }, + Val: b.String(), + } +} + +func (n *CompoundStringLiteralNode) Value() interface{} { + return n.AsString() +} + +func (n *CompoundStringLiteralNode) AsString() string { + return n.Val +} + +// IntValueNode is an AST node that represents an integer literal. If +// an integer literal is too large for an int64 (or uint64 for +// positive literals), it is represented instead by a FloatValueNode. +type IntValueNode interface { + ValueNode + AsInt64() (int64, bool) + AsUint64() (uint64, bool) +} + +// AsInt32 range checks the given int value and returns its value is +// in the range or 0, false if it is outside the range. +func AsInt32(n IntValueNode, min, max int32) (int32, bool) { + i, ok := n.AsInt64() + if !ok { + return 0, false + } + if i < int64(min) || i > int64(max) { + return 0, false + } + return int32(i), true +} + +var _ IntValueNode = (*UintLiteralNode)(nil) +var _ IntValueNode = (*PositiveUintLiteralNode)(nil) +var _ IntValueNode = (*NegativeIntLiteralNode)(nil) + +// UintLiteralNode represents a simple integer literal with no sign character. +type UintLiteralNode struct { + terminalNode + // Val is the numeric value indicated by the literal + Val uint64 +} + +// NewUintLiteralNode creates a new *UintLiteralNode with the given val. +func NewUintLiteralNode(val uint64, tok Token) *UintLiteralNode { + return &UintLiteralNode{ + terminalNode: tok.asTerminalNode(), + Val: val, + } +} + +func (n *UintLiteralNode) Value() interface{} { + return n.Val +} + +func (n *UintLiteralNode) AsInt64() (int64, bool) { + if n.Val > math.MaxInt64 { + return 0, false + } + return int64(n.Val), true +} + +func (n *UintLiteralNode) AsUint64() (uint64, bool) { + return n.Val, true +} + +func (n *UintLiteralNode) AsFloat() float64 { + return float64(n.Val) +} + +// PositiveUintLiteralNode represents an integer literal with a positive (+) sign. +type PositiveUintLiteralNode struct { + compositeNode + Plus *RuneNode + Uint *UintLiteralNode + Val uint64 +} + +// NewPositiveUintLiteralNode creates a new *PositiveUintLiteralNode. Both +// arguments must be non-nil. +func NewPositiveUintLiteralNode(sign *RuneNode, i *UintLiteralNode) *PositiveUintLiteralNode { + if sign == nil { + panic("sign is nil") + } + if i == nil { + panic("i is nil") + } + children := []Node{sign, i} + return &PositiveUintLiteralNode{ + compositeNode: compositeNode{ + children: children, + }, + Plus: sign, + Uint: i, + Val: i.Val, + } +} + +func (n *PositiveUintLiteralNode) Value() interface{} { + return n.Val +} + +func (n *PositiveUintLiteralNode) AsInt64() (int64, bool) { + if n.Val > math.MaxInt64 { + return 0, false + } + return int64(n.Val), true +} + +func (n *PositiveUintLiteralNode) AsUint64() (uint64, bool) { + return n.Val, true +} + +// NegativeIntLiteralNode represents an integer literal with a negative (-) sign. +type NegativeIntLiteralNode struct { + compositeNode + Minus *RuneNode + Uint *UintLiteralNode + Val int64 +} + +// NewNegativeIntLiteralNode creates a new *NegativeIntLiteralNode. Both +// arguments must be non-nil. +func NewNegativeIntLiteralNode(sign *RuneNode, i *UintLiteralNode) *NegativeIntLiteralNode { + if sign == nil { + panic("sign is nil") + } + if i == nil { + panic("i is nil") + } + children := []Node{sign, i} + return &NegativeIntLiteralNode{ + compositeNode: compositeNode{ + children: children, + }, + Minus: sign, + Uint: i, + Val: -int64(i.Val), + } +} + +func (n *NegativeIntLiteralNode) Value() interface{} { + return n.Val +} + +func (n *NegativeIntLiteralNode) AsInt64() (int64, bool) { + return n.Val, true +} + +func (n *NegativeIntLiteralNode) AsUint64() (uint64, bool) { + if n.Val < 0 { + return 0, false + } + return uint64(n.Val), true +} + +// FloatValueNode is an AST node that represents a numeric literal with +// a floating point, in scientific notation, or too large to fit in an +// int64 or uint64. +type FloatValueNode interface { + ValueNode + AsFloat() float64 +} + +var _ FloatValueNode = (*FloatLiteralNode)(nil) +var _ FloatValueNode = (*SpecialFloatLiteralNode)(nil) +var _ FloatValueNode = (*UintLiteralNode)(nil) + +// FloatLiteralNode represents a floating point numeric literal. +type FloatLiteralNode struct { + terminalNode + // Val is the numeric value indicated by the literal + Val float64 +} + +// NewFloatLiteralNode creates a new *FloatLiteralNode with the given val. +func NewFloatLiteralNode(val float64, tok Token) *FloatLiteralNode { + return &FloatLiteralNode{ + terminalNode: tok.asTerminalNode(), + Val: val, + } +} + +func (n *FloatLiteralNode) Value() interface{} { + return n.AsFloat() +} + +func (n *FloatLiteralNode) AsFloat() float64 { + return n.Val +} + +// SpecialFloatLiteralNode represents a special floating point numeric literal +// for "inf" and "nan" values. +type SpecialFloatLiteralNode struct { + *KeywordNode + Val float64 +} + +// NewSpecialFloatLiteralNode returns a new *SpecialFloatLiteralNode for the +// given keyword, which must be "inf" or "nan". +func NewSpecialFloatLiteralNode(name *KeywordNode) *SpecialFloatLiteralNode { + var f float64 + if name.Val == "inf" { + f = math.Inf(1) + } else { + f = math.NaN() + } + return &SpecialFloatLiteralNode{ + KeywordNode: name, + Val: f, + } +} + +func (n *SpecialFloatLiteralNode) Value() interface{} { + return n.AsFloat() +} + +func (n *SpecialFloatLiteralNode) AsFloat() float64 { + return n.Val +} + +// SignedFloatLiteralNode represents a signed floating point number. +type SignedFloatLiteralNode struct { + compositeNode + Sign *RuneNode + Float FloatValueNode + Val float64 +} + +// NewSignedFloatLiteralNode creates a new *SignedFloatLiteralNode. Both +// arguments must be non-nil. +func NewSignedFloatLiteralNode(sign *RuneNode, f FloatValueNode) *SignedFloatLiteralNode { + if sign == nil { + panic("sign is nil") + } + if f == nil { + panic("f is nil") + } + children := []Node{sign, f} + val := f.AsFloat() + if sign.Rune == '-' { + val = -val + } + return &SignedFloatLiteralNode{ + compositeNode: compositeNode{ + children: children, + }, + Sign: sign, + Float: f, + Val: val, + } +} + +func (n *SignedFloatLiteralNode) Value() interface{} { + return n.Val +} + +func (n *SignedFloatLiteralNode) AsFloat() float64 { + return n.Val +} + +// ArrayLiteralNode represents an array literal, which is only allowed inside of +// a MessageLiteralNode, to indicate values for a repeated field. Example: +// +// ["foo", "bar", "baz"] +type ArrayLiteralNode struct { + compositeNode + OpenBracket *RuneNode + Elements []ValueNode + // Commas represent the separating ',' characters between elements. The + // length of this slice must be exactly len(Elements)-1, with each item + // in Elements having a corresponding item in this slice *except the last* + // (since a trailing comma is not allowed). + Commas []*RuneNode + CloseBracket *RuneNode +} + +// NewArrayLiteralNode creates a new *ArrayLiteralNode. The openBracket and +// closeBracket args must be non-nil and represent the "[" and "]" runes that +// surround the array values. The given commas arg must have a length that is +// one less than the length of the vals arg. However, vals may be empty, in +// which case commas must also be empty. +func NewArrayLiteralNode(openBracket *RuneNode, vals []ValueNode, commas []*RuneNode, closeBracket *RuneNode) *ArrayLiteralNode { + if openBracket == nil { + panic("openBracket is nil") + } + if closeBracket == nil { + panic("closeBracket is nil") + } + if len(vals) == 0 && len(commas) != 0 { + panic("vals is empty but commas is not") + } + if len(vals) > 0 && len(commas) != len(vals)-1 { + panic(fmt.Sprintf("%d vals requires %d commas, not %d", len(vals), len(vals)-1, len(commas))) + } + children := make([]Node, 0, len(vals)*2+1) + children = append(children, openBracket) + for i, val := range vals { + if i > 0 { + if commas[i-1] == nil { + panic(fmt.Sprintf("commas[%d] is nil", i-1)) + } + children = append(children, commas[i-1]) + } + if val == nil { + panic(fmt.Sprintf("vals[%d] is nil", i)) + } + children = append(children, val) + } + children = append(children, closeBracket) + + return &ArrayLiteralNode{ + compositeNode: compositeNode{ + children: children, + }, + OpenBracket: openBracket, + Elements: vals, + Commas: commas, + CloseBracket: closeBracket, + } +} + +func (n *ArrayLiteralNode) Value() interface{} { + return n.Elements +} + +// MessageLiteralNode represents a message literal, which is compatible with the +// protobuf text format and can be used for custom options with message types. +// Example: +// +// { foo:1 foo:2 foo:3 bar: } +type MessageLiteralNode struct { + compositeNode + Open *RuneNode // should be '{' or '<' + Elements []*MessageFieldNode + // Separator characters between elements, which can be either ',' + // or ';' if present. This slice must be exactly len(Elements) in + // length, with each item in Elements having one corresponding item + // in Seps. Separators in message literals are optional, so a given + // item in this slice may be nil to indicate absence of a separator. + Seps []*RuneNode + Close *RuneNode // should be '}' or '>', depending on Open +} + +// NewMessageLiteralNode creates a new *MessageLiteralNode. The openSym and +// closeSym runes must not be nil and should be "{" and "}" or "<" and ">". +// +// Unlike separators (dots and commas) used for other AST nodes that represent +// a list of elements, the seps arg must be the SAME length as vals, and it may +// contain nil values to indicate absence of a separator (in fact, it could be +// all nils). +func NewMessageLiteralNode(openSym *RuneNode, vals []*MessageFieldNode, seps []*RuneNode, closeSym *RuneNode) *MessageLiteralNode { + if openSym == nil { + panic("openSym is nil") + } + if closeSym == nil { + panic("closeSym is nil") + } + if len(seps) != len(vals) { + panic(fmt.Sprintf("%d vals requires %d commas, not %d", len(vals), len(vals), len(seps))) + } + numChildren := len(vals) + 2 + for _, sep := range seps { + if sep != nil { + numChildren++ + } + } + children := make([]Node, 0, numChildren) + children = append(children, openSym) + for i, val := range vals { + if val == nil { + panic(fmt.Sprintf("vals[%d] is nil", i)) + } + children = append(children, val) + if seps[i] != nil { + children = append(children, seps[i]) + } + } + children = append(children, closeSym) + + return &MessageLiteralNode{ + compositeNode: compositeNode{ + children: children, + }, + Open: openSym, + Elements: vals, + Seps: seps, + Close: closeSym, + } +} + +func (n *MessageLiteralNode) Value() interface{} { + return n.Elements +} + +// MessageFieldNode represents a single field (name and value) inside of a +// message literal. Example: +// +// foo:"bar" +type MessageFieldNode struct { + compositeNode + Name *FieldReferenceNode + // Sep represents the ':' separator between the name and value. If + // the value is a message or list literal (and thus starts with '<', + // '{', or '['), then the separator may be omitted and this field may + // be nil. + Sep *RuneNode + Val ValueNode +} + +// NewMessageFieldNode creates a new *MessageFieldNode. All args except sep +// must be non-nil. +func NewMessageFieldNode(name *FieldReferenceNode, sep *RuneNode, val ValueNode) *MessageFieldNode { + if name == nil { + panic("name is nil") + } + if val == nil { + panic("val is nil") + } + numChildren := 2 + if sep != nil { + numChildren++ + } + children := make([]Node, 0, numChildren) + children = append(children, name) + if sep != nil { + children = append(children, sep) + } + children = append(children, val) + + return &MessageFieldNode{ + compositeNode: compositeNode{ + children: children, + }, + Name: name, + Sep: sep, + Val: val, + } +} diff --git a/vendor/github.com/bufbuild/protocompile/ast/walk.go b/vendor/github.com/bufbuild/protocompile/ast/walk.go new file mode 100644 index 00000000000..c5311b8152e --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/ast/walk.go @@ -0,0 +1,921 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ast + +import "fmt" + +// Walk conducts a walk of the AST rooted at the given root using the +// given visitor. It performs a "pre-order traversal", visiting a +// given AST node before it visits that node's descendants. +// +// If a visitor returns an error while walking the tree, the entire +// operation is aborted and that error is returned. +func Walk(root Node, v Visitor, opts ...WalkOption) error { + var wOpts walkOptions + for _, opt := range opts { + opt(&wOpts) + } + return walk(root, v, wOpts) +} + +// WalkOption represents an option used with the Walk function. These +// allow optional before and after hooks to be invoked as each node in +// the tree is visited. +type WalkOption func(*walkOptions) + +type walkOptions struct { + before, after func(Node) error +} + +// WithBefore returns a WalkOption that will cause the given function to be +// invoked before a node is visited during a walk operation. If this hook +// returns an error, the node is not visited and the walk operation is aborted. +func WithBefore(fn func(Node) error) WalkOption { + return func(options *walkOptions) { + options.before = fn + } +} + +// WithAfter returns a WalkOption that will cause the given function to be +// invoked after a node (as well as any descendants) is visited during a walk +// operation. If this hook returns an error, the node is not visited and the +// walk operation is aborted. +// +// If the walk is aborted due to some other visitor or before hook returning an +// error, the after hook is still called for all nodes that have been visited. +// However, the walk operation fails with the first error it encountered, so any +// error returned from an after hook is effectively ignored. +func WithAfter(fn func(Node) error) WalkOption { + return func(options *walkOptions) { + options.after = fn + } +} + +func walk(root Node, v Visitor, opts walkOptions) (err error) { + if opts.before != nil { + if err := opts.before(root); err != nil { + return err + } + } + if opts.after != nil { + defer func() { + if afterErr := opts.after(root); afterErr != nil { + // if another call already returned an error then we + // have to ignore the error from the after hook + if err == nil { + err = afterErr + } + } + }() + } + + if err := Visit(root, v); err != nil { + return err + } + + if comp, ok := root.(CompositeNode); ok { + for _, child := range comp.Children() { + if err := walk(child, v, opts); err != nil { + return err + } + } + } + return nil +} + +// Visit implements the double-dispatch idiom and visits the given node by +// calling the appropriate method of the given visitor. +func Visit(n Node, v Visitor) error { + switch n := n.(type) { + case *FileNode: + return v.VisitFileNode(n) + case *SyntaxNode: + return v.VisitSyntaxNode(n) + case *PackageNode: + return v.VisitPackageNode(n) + case *ImportNode: + return v.VisitImportNode(n) + case *OptionNode: + return v.VisitOptionNode(n) + case *OptionNameNode: + return v.VisitOptionNameNode(n) + case *FieldReferenceNode: + return v.VisitFieldReferenceNode(n) + case *CompactOptionsNode: + return v.VisitCompactOptionsNode(n) + case *MessageNode: + return v.VisitMessageNode(n) + case *ExtendNode: + return v.VisitExtendNode(n) + case *ExtensionRangeNode: + return v.VisitExtensionRangeNode(n) + case *ReservedNode: + return v.VisitReservedNode(n) + case *RangeNode: + return v.VisitRangeNode(n) + case *FieldNode: + return v.VisitFieldNode(n) + case *GroupNode: + return v.VisitGroupNode(n) + case *MapFieldNode: + return v.VisitMapFieldNode(n) + case *MapTypeNode: + return v.VisitMapTypeNode(n) + case *OneOfNode: + return v.VisitOneOfNode(n) + case *EnumNode: + return v.VisitEnumNode(n) + case *EnumValueNode: + return v.VisitEnumValueNode(n) + case *ServiceNode: + return v.VisitServiceNode(n) + case *RPCNode: + return v.VisitRPCNode(n) + case *RPCTypeNode: + return v.VisitRPCTypeNode(n) + case *IdentNode: + return v.VisitIdentNode(n) + case *CompoundIdentNode: + return v.VisitCompoundIdentNode(n) + case *StringLiteralNode: + return v.VisitStringLiteralNode(n) + case *CompoundStringLiteralNode: + return v.VisitCompoundStringLiteralNode(n) + case *UintLiteralNode: + return v.VisitUintLiteralNode(n) + case *PositiveUintLiteralNode: + return v.VisitPositiveUintLiteralNode(n) + case *NegativeIntLiteralNode: + return v.VisitNegativeIntLiteralNode(n) + case *FloatLiteralNode: + return v.VisitFloatLiteralNode(n) + case *SpecialFloatLiteralNode: + return v.VisitSpecialFloatLiteralNode(n) + case *SignedFloatLiteralNode: + return v.VisitSignedFloatLiteralNode(n) + case *ArrayLiteralNode: + return v.VisitArrayLiteralNode(n) + case *MessageLiteralNode: + return v.VisitMessageLiteralNode(n) + case *MessageFieldNode: + return v.VisitMessageFieldNode(n) + case *KeywordNode: + return v.VisitKeywordNode(n) + case *RuneNode: + return v.VisitRuneNode(n) + case *EmptyDeclNode: + return v.VisitEmptyDeclNode(n) + default: + panic(fmt.Sprintf("unexpected type of node: %T", n)) + } +} + +// AncestorTracker is used to track the path of nodes during a walk operation. +// By passing AsWalkOptions to a call to Walk, a visitor can inspect the path to +// the node being visited using this tracker. +type AncestorTracker struct { + ancestors []Node +} + +// AsWalkOptions returns WalkOption values that will cause this ancestor tracker +// to track the path through the AST during the walk operation. +func (t *AncestorTracker) AsWalkOptions() []WalkOption { + return []WalkOption{ + WithBefore(func(n Node) error { + t.ancestors = append(t.ancestors, n) + return nil + }), + WithAfter(func(n Node) error { + t.ancestors = t.ancestors[:len(t.ancestors)-1] + return nil + }), + } +} + +// Path returns a slice of nodes that represents the path from the root of the +// walk operaiton to the currently visited node. The first element in the path +// is the root supplied to Walk. The last element in the path is the currently +// visited node. +// +// The returned slice is not a defensive copy; so callers should NOT mutate it. +func (t *AncestorTracker) Path() []Node { + return t.ancestors +} + +// Parent returns the parent node of the currently visited node. If the node +// currently being visited is the root supplied to Walk then nil is returned. +func (t *AncestorTracker) Parent() Node { + if len(t.ancestors) <= 1 { + return nil + } + return t.ancestors[len(t.ancestors)-2] +} + +// VisitChildren visits all direct children of the given node using the given +// visitor. If visiting a child returns an error, that error is immediately +// returned, and other children will not be visited. +func VisitChildren(n CompositeNode, v Visitor) error { + for _, ch := range n.Children() { + if err := Visit(ch, v); err != nil { + return err + } + } + return nil +} + +// Visitor provides a technique for walking the AST that allows for +// dynamic dispatch, where a particular function is invoked based on +// the runtime type of the argument. +// +// It consists of a number of functions, each of which matches a +// concrete Node type. It also includes functions for sub-interfaces +// of Node and the Node interface itself, to be used as broader +// "catch all" functions. +// +// To use a visitor, provide a function for the node types of +// interest and pass visitor.Visit as the function to a Walk operation. +// When a node is traversed, the corresponding function field of +// the visitor is invoked, if not nil. If the function for a node's +// concrete type is nil/absent but the function for an interface it +// implements is present, that interface visit function will be used +// instead. If no matching function is present, the traversal will +// continue. If a matching function is present, it will be invoked +// and its response determines how the traversal proceeds. +// +// Every visit function returns (bool, *Visitor). If the bool returned +// is false, the visited node's descendants are skipped. Otherwise, +// traversal will continue into the node's children. If the returned +// visitor is nil, the current visitor will continue to be used. But +// if a non-nil visitor is returned, it will be used to visit the +// node's children. +type Visitor interface { + // VisitFileNode is invoked when visiting a *FileNode in the AST. + VisitFileNode(*FileNode) error + // VisitSyntaxNode is invoked when visiting a *SyntaxNode in the AST. + VisitSyntaxNode(*SyntaxNode) error + // VisitPackageNode is invoked when visiting a *PackageNode in the AST. + VisitPackageNode(*PackageNode) error + // VisitImportNode is invoked when visiting an *ImportNode in the AST. + VisitImportNode(*ImportNode) error + // VisitOptionNode is invoked when visiting an *OptionNode in the AST. + VisitOptionNode(*OptionNode) error + // VisitOptionNameNode is invoked when visiting an *OptionNameNode in the AST. + VisitOptionNameNode(*OptionNameNode) error + // VisitFieldReferenceNode is invoked when visiting a *FieldReferenceNode in the AST. + VisitFieldReferenceNode(*FieldReferenceNode) error + // VisitCompactOptionsNode is invoked when visiting a *CompactOptionsNode in the AST. + VisitCompactOptionsNode(*CompactOptionsNode) error + // VisitMessageNode is invoked when visiting a *MessageNode in the AST. + VisitMessageNode(*MessageNode) error + // VisitExtendNode is invoked when visiting an *ExtendNode in the AST. + VisitExtendNode(*ExtendNode) error + // VisitExtensionRangeNode is invoked when visiting an *ExtensionRangeNode in the AST. + VisitExtensionRangeNode(*ExtensionRangeNode) error + // VisitReservedNode is invoked when visiting a *ReservedNode in the AST. + VisitReservedNode(*ReservedNode) error + // VisitRangeNode is invoked when visiting a *RangeNode in the AST. + VisitRangeNode(*RangeNode) error + // VisitFieldNode is invoked when visiting a *FieldNode in the AST. + VisitFieldNode(*FieldNode) error + // VisitGroupNode is invoked when visiting a *GroupNode in the AST. + VisitGroupNode(*GroupNode) error + // VisitMapFieldNode is invoked when visiting a *MapFieldNode in the AST. + VisitMapFieldNode(*MapFieldNode) error + // VisitMapTypeNode is invoked when visiting a *MapTypeNode in the AST. + VisitMapTypeNode(*MapTypeNode) error + // VisitOneOfNode is invoked when visiting a *OneOfNode in the AST. + VisitOneOfNode(*OneOfNode) error + // VisitEnumNode is invoked when visiting an *EnumNode in the AST. + VisitEnumNode(*EnumNode) error + // VisitEnumValueNode is invoked when visiting an *EnumValueNode in the AST. + VisitEnumValueNode(*EnumValueNode) error + // VisitServiceNode is invoked when visiting a *ServiceNode in the AST. + VisitServiceNode(*ServiceNode) error + // VisitRPCNode is invoked when visiting an *RPCNode in the AST. + VisitRPCNode(*RPCNode) error + // VisitRPCTypeNode is invoked when visiting an *RPCTypeNode in the AST. + VisitRPCTypeNode(*RPCTypeNode) error + // VisitIdentNode is invoked when visiting an *IdentNode in the AST. + VisitIdentNode(*IdentNode) error + // VisitCompoundIdentNode is invoked when visiting a *CompoundIdentNode in the AST. + VisitCompoundIdentNode(*CompoundIdentNode) error + // VisitStringLiteralNode is invoked when visiting a *StringLiteralNode in the AST. + VisitStringLiteralNode(*StringLiteralNode) error + // VisitCompoundStringLiteralNode is invoked when visiting a *CompoundStringLiteralNode in the AST. + VisitCompoundStringLiteralNode(*CompoundStringLiteralNode) error + // VisitUintLiteralNode is invoked when visiting a *UintLiteralNode in the AST. + VisitUintLiteralNode(*UintLiteralNode) error + // VisitPositiveUintLiteralNode is invoked when visiting a *PositiveUintLiteralNode in the AST. + VisitPositiveUintLiteralNode(*PositiveUintLiteralNode) error + // VisitNegativeIntLiteralNode is invoked when visiting a *NegativeIntLiteralNode in the AST. + VisitNegativeIntLiteralNode(*NegativeIntLiteralNode) error + // VisitFloatLiteralNode is invoked when visiting a *FloatLiteralNode in the AST. + VisitFloatLiteralNode(*FloatLiteralNode) error + // VisitSpecialFloatLiteralNode is invoked when visiting a *SpecialFloatLiteralNode in the AST. + VisitSpecialFloatLiteralNode(*SpecialFloatLiteralNode) error + // VisitSignedFloatLiteralNode is invoked when visiting a *SignedFloatLiteralNode in the AST. + VisitSignedFloatLiteralNode(*SignedFloatLiteralNode) error + // VisitArrayLiteralNode is invoked when visiting an *ArrayLiteralNode in the AST. + VisitArrayLiteralNode(*ArrayLiteralNode) error + // VisitMessageLiteralNode is invoked when visiting a *MessageLiteralNode in the AST. + VisitMessageLiteralNode(*MessageLiteralNode) error + // VisitMessageFieldNode is invoked when visiting a *MessageFieldNode in the AST. + VisitMessageFieldNode(*MessageFieldNode) error + // VisitKeywordNode is invoked when visiting a *KeywordNode in the AST. + VisitKeywordNode(*KeywordNode) error + // VisitRuneNode is invoked when visiting a *RuneNode in the AST. + VisitRuneNode(*RuneNode) error + // VisitEmptyDeclNode is invoked when visiting a *EmptyDeclNode in the AST. + VisitEmptyDeclNode(*EmptyDeclNode) error +} + +// NoOpVisitor is a visitor implementation that does nothing. All methods +// unconditionally return nil. This can be embedded into a struct to make that +// struct implement the Visitor interface, and only the relevant visit methods +// then need to be implemented on the struct. +type NoOpVisitor struct{} + +var _ Visitor = NoOpVisitor{} + +func (n NoOpVisitor) VisitFileNode(_ *FileNode) error { + return nil +} + +func (n NoOpVisitor) VisitSyntaxNode(_ *SyntaxNode) error { + return nil +} + +func (n NoOpVisitor) VisitPackageNode(_ *PackageNode) error { + return nil +} + +func (n NoOpVisitor) VisitImportNode(_ *ImportNode) error { + return nil +} + +func (n NoOpVisitor) VisitOptionNode(_ *OptionNode) error { + return nil +} + +func (n NoOpVisitor) VisitOptionNameNode(_ *OptionNameNode) error { + return nil +} + +func (n NoOpVisitor) VisitFieldReferenceNode(_ *FieldReferenceNode) error { + return nil +} + +func (n NoOpVisitor) VisitCompactOptionsNode(_ *CompactOptionsNode) error { + return nil +} + +func (n NoOpVisitor) VisitMessageNode(_ *MessageNode) error { + return nil +} + +func (n NoOpVisitor) VisitExtendNode(_ *ExtendNode) error { + return nil +} + +func (n NoOpVisitor) VisitExtensionRangeNode(_ *ExtensionRangeNode) error { + return nil +} + +func (n NoOpVisitor) VisitReservedNode(_ *ReservedNode) error { + return nil +} + +func (n NoOpVisitor) VisitRangeNode(_ *RangeNode) error { + return nil +} + +func (n NoOpVisitor) VisitFieldNode(_ *FieldNode) error { + return nil +} + +func (n NoOpVisitor) VisitGroupNode(_ *GroupNode) error { + return nil +} + +func (n NoOpVisitor) VisitMapFieldNode(_ *MapFieldNode) error { + return nil +} + +func (n NoOpVisitor) VisitMapTypeNode(_ *MapTypeNode) error { + return nil +} + +func (n NoOpVisitor) VisitOneOfNode(_ *OneOfNode) error { + return nil +} + +func (n NoOpVisitor) VisitEnumNode(_ *EnumNode) error { + return nil +} + +func (n NoOpVisitor) VisitEnumValueNode(_ *EnumValueNode) error { + return nil +} + +func (n NoOpVisitor) VisitServiceNode(_ *ServiceNode) error { + return nil +} + +func (n NoOpVisitor) VisitRPCNode(_ *RPCNode) error { + return nil +} + +func (n NoOpVisitor) VisitRPCTypeNode(_ *RPCTypeNode) error { + return nil +} + +func (n NoOpVisitor) VisitIdentNode(_ *IdentNode) error { + return nil +} + +func (n NoOpVisitor) VisitCompoundIdentNode(_ *CompoundIdentNode) error { + return nil +} + +func (n NoOpVisitor) VisitStringLiteralNode(_ *StringLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitCompoundStringLiteralNode(_ *CompoundStringLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitUintLiteralNode(_ *UintLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitPositiveUintLiteralNode(_ *PositiveUintLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitNegativeIntLiteralNode(_ *NegativeIntLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitFloatLiteralNode(_ *FloatLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitSpecialFloatLiteralNode(_ *SpecialFloatLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitSignedFloatLiteralNode(_ *SignedFloatLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitArrayLiteralNode(_ *ArrayLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitMessageLiteralNode(_ *MessageLiteralNode) error { + return nil +} + +func (n NoOpVisitor) VisitMessageFieldNode(_ *MessageFieldNode) error { + return nil +} + +func (n NoOpVisitor) VisitKeywordNode(_ *KeywordNode) error { + return nil +} + +func (n NoOpVisitor) VisitRuneNode(_ *RuneNode) error { + return nil +} + +func (n NoOpVisitor) VisitEmptyDeclNode(_ *EmptyDeclNode) error { + return nil +} + +// SimpleVisitor is a visitor implementation that uses numerous function fields. +// If a relevant function field is not nil, then it will be invoked when a node +// is visited. +// +// In addition to a function for each concrete node type (and thus for each +// Visit* method of the Visitor interface), it also has function fields that +// accept interface types. So a visitor can, for example, easily treat all +// ValueNodes uniformly by providing a non-nil value for DoVisitValueNode +// instead of having to supply values for the various Do*Node methods +// corresponding to all types that implement ValueNode. +// +// The most specific function provided that matches a given node is the one that +// will be invoked. For example, DoVisitStringValueNode will be called if +// present and applicable before DoVisitValueNode. Similarly, DoVisitValueNode +// would be called before DoVisitTerminalNode or DoVisitCompositeNode. The +// DoVisitNode is the most generic function and is called only if no more +// specific function is present for a given node type. +// +// The *UintLiteralNode type implements both IntValueNode and FloatValueNode. +// In this case, the DoVisitIntValueNode function is considered more specific +// than DoVisitFloatValueNode, so will be preferred if present. +// +// Similarly, *MapFieldNode implements both FieldDeclNode and MessageDeclNode. +// In this case, the DoVisitFieldDeclNode function is considered more specific +// than DoVisitMessageDeclNode, so will be preferred if present. +type SimpleVisitor struct { + DoVisitFileNode func(*FileNode) error + DoVisitSyntaxNode func(*SyntaxNode) error + DoVisitPackageNode func(*PackageNode) error + DoVisitImportNode func(*ImportNode) error + DoVisitOptionNode func(*OptionNode) error + DoVisitOptionNameNode func(*OptionNameNode) error + DoVisitFieldReferenceNode func(*FieldReferenceNode) error + DoVisitCompactOptionsNode func(*CompactOptionsNode) error + DoVisitMessageNode func(*MessageNode) error + DoVisitExtendNode func(*ExtendNode) error + DoVisitExtensionRangeNode func(*ExtensionRangeNode) error + DoVisitReservedNode func(*ReservedNode) error + DoVisitRangeNode func(*RangeNode) error + DoVisitFieldNode func(*FieldNode) error + DoVisitGroupNode func(*GroupNode) error + DoVisitMapFieldNode func(*MapFieldNode) error + DoVisitMapTypeNode func(*MapTypeNode) error + DoVisitOneOfNode func(*OneOfNode) error + DoVisitEnumNode func(*EnumNode) error + DoVisitEnumValueNode func(*EnumValueNode) error + DoVisitServiceNode func(*ServiceNode) error + DoVisitRPCNode func(*RPCNode) error + DoVisitRPCTypeNode func(*RPCTypeNode) error + DoVisitIdentNode func(*IdentNode) error + DoVisitCompoundIdentNode func(*CompoundIdentNode) error + DoVisitStringLiteralNode func(*StringLiteralNode) error + DoVisitCompoundStringLiteralNode func(*CompoundStringLiteralNode) error + DoVisitUintLiteralNode func(*UintLiteralNode) error + DoVisitPositiveUintLiteralNode func(*PositiveUintLiteralNode) error + DoVisitNegativeIntLiteralNode func(*NegativeIntLiteralNode) error + DoVisitFloatLiteralNode func(*FloatLiteralNode) error + DoVisitSpecialFloatLiteralNode func(*SpecialFloatLiteralNode) error + DoVisitSignedFloatLiteralNode func(*SignedFloatLiteralNode) error + DoVisitArrayLiteralNode func(*ArrayLiteralNode) error + DoVisitMessageLiteralNode func(*MessageLiteralNode) error + DoVisitMessageFieldNode func(*MessageFieldNode) error + DoVisitKeywordNode func(*KeywordNode) error + DoVisitRuneNode func(*RuneNode) error + DoVisitEmptyDeclNode func(*EmptyDeclNode) error + + DoVisitFieldDeclNode func(FieldDeclNode) error + DoVisitMessageDeclNode func(MessageDeclNode) error + + DoVisitIdentValueNode func(IdentValueNode) error + DoVisitStringValueNode func(StringValueNode) error + DoVisitIntValueNode func(IntValueNode) error + DoVisitFloatValueNode func(FloatValueNode) error + DoVisitValueNode func(ValueNode) error + + DoVisitTerminalNode func(TerminalNode) error + DoVisitCompositeNode func(CompositeNode) error + DoVisitNode func(Node) error +} + +var _ Visitor = (*SimpleVisitor)(nil) + +func (b *SimpleVisitor) visitInterface(node Node) error { + switch n := node.(type) { + case FieldDeclNode: + if b.DoVisitFieldDeclNode != nil { + return b.DoVisitFieldDeclNode(n) + } + // *MapFieldNode implements both FieldDeclNode and MessageDeclNode, + // so handle other case here + if fn, ok := n.(MessageDeclNode); ok && b.DoVisitMessageDeclNode != nil { + return b.DoVisitMessageDeclNode(fn) + } + case MessageDeclNode: + if b.DoVisitMessageDeclNode != nil { + return b.DoVisitMessageDeclNode(n) + } + case IdentValueNode: + if b.DoVisitIdentValueNode != nil { + return b.DoVisitIdentValueNode(n) + } + case StringValueNode: + if b.DoVisitStringValueNode != nil { + return b.DoVisitStringValueNode(n) + } + case IntValueNode: + if b.DoVisitIntValueNode != nil { + return b.DoVisitIntValueNode(n) + } + // *UintLiteralNode implements both IntValueNode and FloatValueNode, + // so handle other case here + if fn, ok := n.(FloatValueNode); ok && b.DoVisitFloatValueNode != nil { + return b.DoVisitFloatValueNode(fn) + } + case FloatValueNode: + if b.DoVisitFloatValueNode != nil { + return b.DoVisitFloatValueNode(n) + } + } + + if n, ok := node.(ValueNode); ok && b.DoVisitValueNode != nil { + return b.DoVisitValueNode(n) + } + + switch n := node.(type) { + case TerminalNode: + if b.DoVisitTerminalNode != nil { + return b.DoVisitTerminalNode(n) + } + case CompositeNode: + if b.DoVisitCompositeNode != nil { + return b.DoVisitCompositeNode(n) + } + } + + if b.DoVisitNode != nil { + return b.DoVisitNode(node) + } + + return nil +} + +func (b *SimpleVisitor) VisitFileNode(node *FileNode) error { + if b.DoVisitFileNode != nil { + return b.DoVisitFileNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitSyntaxNode(node *SyntaxNode) error { + if b.DoVisitSyntaxNode != nil { + return b.DoVisitSyntaxNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitPackageNode(node *PackageNode) error { + if b.DoVisitPackageNode != nil { + return b.DoVisitPackageNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitImportNode(node *ImportNode) error { + if b.DoVisitImportNode != nil { + return b.DoVisitImportNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitOptionNode(node *OptionNode) error { + if b.DoVisitOptionNode != nil { + return b.DoVisitOptionNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitOptionNameNode(node *OptionNameNode) error { + if b.DoVisitOptionNameNode != nil { + return b.DoVisitOptionNameNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitFieldReferenceNode(node *FieldReferenceNode) error { + if b.DoVisitFieldReferenceNode != nil { + return b.DoVisitFieldReferenceNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitCompactOptionsNode(node *CompactOptionsNode) error { + if b.DoVisitCompactOptionsNode != nil { + return b.DoVisitCompactOptionsNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitMessageNode(node *MessageNode) error { + if b.DoVisitMessageNode != nil { + return b.DoVisitMessageNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitExtendNode(node *ExtendNode) error { + if b.DoVisitExtendNode != nil { + return b.DoVisitExtendNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitExtensionRangeNode(node *ExtensionRangeNode) error { + if b.DoVisitExtensionRangeNode != nil { + return b.DoVisitExtensionRangeNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitReservedNode(node *ReservedNode) error { + if b.DoVisitReservedNode != nil { + return b.DoVisitReservedNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitRangeNode(node *RangeNode) error { + if b.DoVisitRangeNode != nil { + return b.DoVisitRangeNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitFieldNode(node *FieldNode) error { + if b.DoVisitFieldNode != nil { + return b.DoVisitFieldNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitGroupNode(node *GroupNode) error { + if b.DoVisitGroupNode != nil { + return b.DoVisitGroupNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitMapFieldNode(node *MapFieldNode) error { + if b.DoVisitMapFieldNode != nil { + return b.DoVisitMapFieldNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitMapTypeNode(node *MapTypeNode) error { + if b.DoVisitMapTypeNode != nil { + return b.DoVisitMapTypeNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitOneOfNode(node *OneOfNode) error { + if b.DoVisitOneOfNode != nil { + return b.DoVisitOneOfNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitEnumNode(node *EnumNode) error { + if b.DoVisitEnumNode != nil { + return b.DoVisitEnumNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitEnumValueNode(node *EnumValueNode) error { + if b.DoVisitEnumValueNode != nil { + return b.DoVisitEnumValueNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitServiceNode(node *ServiceNode) error { + if b.DoVisitServiceNode != nil { + return b.DoVisitServiceNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitRPCNode(node *RPCNode) error { + if b.DoVisitRPCNode != nil { + return b.DoVisitRPCNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitRPCTypeNode(node *RPCTypeNode) error { + if b.DoVisitRPCTypeNode != nil { + return b.DoVisitRPCTypeNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitIdentNode(node *IdentNode) error { + if b.DoVisitIdentNode != nil { + return b.DoVisitIdentNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitCompoundIdentNode(node *CompoundIdentNode) error { + if b.DoVisitCompoundIdentNode != nil { + return b.DoVisitCompoundIdentNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitStringLiteralNode(node *StringLiteralNode) error { + if b.DoVisitStringLiteralNode != nil { + return b.DoVisitStringLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitCompoundStringLiteralNode(node *CompoundStringLiteralNode) error { + if b.DoVisitCompoundStringLiteralNode != nil { + return b.DoVisitCompoundStringLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitUintLiteralNode(node *UintLiteralNode) error { + if b.DoVisitUintLiteralNode != nil { + return b.DoVisitUintLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitPositiveUintLiteralNode(node *PositiveUintLiteralNode) error { + if b.DoVisitPositiveUintLiteralNode != nil { + return b.DoVisitPositiveUintLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitNegativeIntLiteralNode(node *NegativeIntLiteralNode) error { + if b.DoVisitNegativeIntLiteralNode != nil { + return b.DoVisitNegativeIntLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitFloatLiteralNode(node *FloatLiteralNode) error { + if b.DoVisitFloatLiteralNode != nil { + return b.DoVisitFloatLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitSpecialFloatLiteralNode(node *SpecialFloatLiteralNode) error { + if b.DoVisitSpecialFloatLiteralNode != nil { + return b.DoVisitSpecialFloatLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitSignedFloatLiteralNode(node *SignedFloatLiteralNode) error { + if b.DoVisitSignedFloatLiteralNode != nil { + return b.DoVisitSignedFloatLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitArrayLiteralNode(node *ArrayLiteralNode) error { + if b.DoVisitArrayLiteralNode != nil { + return b.DoVisitArrayLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitMessageLiteralNode(node *MessageLiteralNode) error { + if b.DoVisitMessageLiteralNode != nil { + return b.DoVisitMessageLiteralNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitMessageFieldNode(node *MessageFieldNode) error { + if b.DoVisitMessageFieldNode != nil { + return b.DoVisitMessageFieldNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitKeywordNode(node *KeywordNode) error { + if b.DoVisitKeywordNode != nil { + return b.DoVisitKeywordNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitRuneNode(node *RuneNode) error { + if b.DoVisitRuneNode != nil { + return b.DoVisitRuneNode(node) + } + return b.visitInterface(node) +} + +func (b *SimpleVisitor) VisitEmptyDeclNode(node *EmptyDeclNode) error { + if b.DoVisitEmptyDeclNode != nil { + return b.DoVisitEmptyDeclNode(node) + } + return b.visitInterface(node) +} diff --git a/vendor/github.com/bufbuild/protocompile/compiler.go b/vendor/github.com/bufbuild/protocompile/compiler.go new file mode 100644 index 00000000000..b219621c81e --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/compiler.go @@ -0,0 +1,567 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protocompile + +import ( + "bytes" + "context" + "fmt" + "io" + "runtime" + "runtime/debug" + "strings" + "sync" + + "golang.org/x/sync/semaphore" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/linker" + "github.com/bufbuild/protocompile/options" + "github.com/bufbuild/protocompile/parser" + "github.com/bufbuild/protocompile/reporter" + "github.com/bufbuild/protocompile/sourceinfo" +) + +// Compiler handles compilation tasks, to turn protobuf source files, or other +// intermediate representations, into fully linked descriptors. +// +// The compilation process involves five steps for each protobuf source file: +// 1. Parsing the source into an AST (abstract syntax tree). +// 2. Converting the AST into descriptor protos. +// 3. Linking descriptor protos into fully linked descriptors. +// 4. Interpreting options. +// 5. Computing source code information. +// +// With fully linked descriptors, code generators and protoc plugins could be +// invoked (though that step is not implemented by this package and not a +// responsibility of this type). +type Compiler struct { + // Resolves path/file names into source code or intermediate representations + // for protobuf source files. This is how the compiler loads the files to + // be compiled as well as all dependencies. This field is the only required + // field. + Resolver Resolver + // The maximum parallelism to use when compiling. If unspecified or set to + // a non-positive value, then min(runtime.NumCPU(), runtime.GOMAXPROCS(-1)) + // will be used. + MaxParallelism int + // A custom error and warning reporter. If unspecified a default reporter + // is used. A default reporter fails the compilation after encountering any + // errors and ignores all warnings. + Reporter reporter.Reporter + + // If unspecified or set to SourceInfoNone, source code information will not + // be included in the resulting descriptors. Source code information is + // metadata in the file descriptor that provides position information (i.e. + // the line and column where file elements were defined) as well as comments. + // + // If set to SourceInfoStandard, normal source code information will be + // included in the resulting descriptors. This matches the output of protoc + // (the reference compiler for Protocol Buffers). If set to + // SourceInfoMoreComments, the resulting descriptor will attempt to preserve + // as many comments as possible, for all elements in the file, not just for + // complete declarations. + // + // If Resolver returns descriptors or descriptor protos for a file, then + // those descriptors will not be modified. If they do not already include + // source code info, they will be left that way when the compile operation + // concludes. Similarly, if they already have source code info but this flag + // is false, existing info will be left in place. + SourceInfoMode SourceInfoMode + + // If true, ASTs are retained in compilation results for which an AST was + // constructed. So any linker.Result value in the resulting compiled files + // will have an AST, in addition to descriptors. If left false, the AST + // will be removed as soon as it's no longer needed. This can help reduce + // total memory usage for operations involving a large number of files. + RetainASTs bool +} + +// SourceInfoMode indicates how source code info is generated by a Compiler. +type SourceInfoMode int + +const ( + // SourceInfoNone indicates that no source code info is generated. + SourceInfoNone = SourceInfoMode(iota) + // SourceInfoStandard indicates that the standard source code info is + // generated, which includes comments only for complete declarations. + SourceInfoStandard + // SourceInfoExtraComments indicates that source code info is generated + // and will include comments for all elements (more comments than would + // be found in a descriptor produced by protoc). + SourceInfoExtraComments +) + +// Compile compiles the given file names into fully-linked descriptors. The +// compiler's resolver is used to locate source code (or intermediate artifacts +// such as parsed ASTs or descriptor protos) and then do what is necessary to +// transform that into descriptors (parsing, linking, etc). +// +// Elements in the given returned files will implement [linker.Result] if the +// compiler had to link it (i.e. the resolver provided either a descriptor proto +// or source code). That result will contain a full AST for the file if the +// compiler had to parse it (i.e. the resolver provided source code for that +// file). +func (c *Compiler) Compile(ctx context.Context, files ...string) (linker.Files, error) { + if len(files) == 0 { + return nil, nil + } + + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + par := c.MaxParallelism + if par <= 0 { + par = runtime.GOMAXPROCS(-1) + cpus := runtime.NumCPU() + if par > cpus { + par = cpus + } + } + + h := reporter.NewHandler(c.Reporter) + + e := executor{ + c: c, + h: h, + s: semaphore.NewWeighted(int64(par)), + cancel: cancel, + sym: &linker.Symbols{}, + results: map[string]*result{}, + } + + // We lock now and create all tasks under lock to make sure that no + // async task can create a duplicate result. For example, if files + // contains both "foo.proto" and "bar.proto", then there is a race + // after we start compiling "foo.proto" between this loop and the + // async compilation task to create the result for "bar.proto". But + // we need to know if the file is directly requested for compilation, + // so we need this loop to define the result. So this loop holds the + // lock the whole time so async tasks can't create a result first. + results := make([]*result, len(files)) + func() { + e.mu.Lock() + defer e.mu.Unlock() + for i, f := range files { + results[i] = e.compileLocked(ctx, f, true) + } + }() + + descs := make([]linker.File, len(files)) + var firstError error + for i, r := range results { + select { + case <-r.ready: + case <-ctx.Done(): + return nil, ctx.Err() + } + if r.err != nil { + if firstError == nil { + firstError = r.err + } + } + descs[i] = r.res + } + + if err := h.Error(); err != nil { + return descs, err + } + // this should probably never happen; if any task returned an + // error, h.Error() should be non-nil + return descs, firstError +} + +type result struct { + name string + ready chan struct{} + + // true if this file was explicitly provided to the compiler; otherwise + // this file is an import that is implicitly included + explicitFile bool + + // produces a linker.File or error, only available when ready is closed + res linker.File + err error + + mu sync.Mutex + // the results that are dependencies of this result; this result is + // blocked, waiting on these dependencies to complete + blockedOn []string +} + +func (r *result) fail(err error) { + r.err = err + close(r.ready) +} + +func (r *result) complete(f linker.File) { + r.res = f + close(r.ready) +} + +func (r *result) setBlockedOn(deps []string) { + r.mu.Lock() + defer r.mu.Unlock() + r.blockedOn = deps +} + +func (r *result) getBlockedOn() []string { + r.mu.Lock() + defer r.mu.Unlock() + return r.blockedOn +} + +type executor struct { + c *Compiler + h *reporter.Handler + s *semaphore.Weighted + cancel context.CancelFunc + sym *linker.Symbols + + mu sync.Mutex + results map[string]*result +} + +func (e *executor) compile(ctx context.Context, file string) *result { + e.mu.Lock() + defer e.mu.Unlock() + + return e.compileLocked(ctx, file, false) +} + +func (e *executor) compileLocked(ctx context.Context, file string, explicitFile bool) *result { + r := e.results[file] + if r != nil { + return r + } + + r = &result{ + name: file, + ready: make(chan struct{}), + explicitFile: explicitFile, + } + e.results[file] = r + go func() { + defer func() { + if p := recover(); p != nil { + if r.err == nil { + // TODO: strip top frames from stack trace so that the panic is + // the top of the trace? + panicErr := PanicError{File: file, Value: p, Stack: string(debug.Stack())} + r.fail(panicErr) + } + // TODO: if r.err != nil, then this task has already + // failed and there's nothing we can really do to + // communicate this panic to parent goroutine. This + // means the panic must have happened *after* the + // failure was already recorded (or during?) + // It would be nice to do something else here, like + // send the compiler an out-of-band error? Or log? + } + }() + e.doCompile(ctx, file, r) + }() + return r +} + +// PanicError is an error value that represents a recovered panic. It includes +// the value returned by recover() as well as the stack trace. +// +// This should generally only be seen if a Resolver implementation panics. +// +// An error returned by a Compiler may wrap a PanicError, so you may need to +// use errors.As(...) to access panic details. +type PanicError struct { + // The file that was being processed when the panic occurred + File string + // The value returned by recover() + Value interface{} + // A formatted stack trace + Stack string +} + +// Error implements the error interface. It does NOT include the stack trace. +// Use a type assertion and query the Stack field directly to access that. +func (p PanicError) Error() string { + return fmt.Sprintf("panic handling %q: %v", p.File, p.Value) +} + +type errFailedToResolve struct { + err error + path string +} + +func (e errFailedToResolve) Error() string { + errMsg := e.err.Error() + if strings.Contains(errMsg, e.path) { + // underlying error already refers to path in question, so we don't need to add more context + return errMsg + } + return fmt.Sprintf("could not resolve path %q: %s", e.path, e.err.Error()) +} + +func (e errFailedToResolve) Unwrap() error { + return e.err +} + +func (e *executor) doCompile(ctx context.Context, file string, r *result) { + t := task{e: e, h: e.h.SubHandler(), r: r} + if err := e.s.Acquire(ctx, 1); err != nil { + r.fail(err) + return + } + defer t.release() + + sr, err := e.c.Resolver.FindFileByPath(file) + if err != nil { + r.fail(errFailedToResolve{err, file}) + return + } + + defer func() { + // if results included a result, don't leave it open if it can be closed + if sr.Source == nil { + return + } + if c, ok := sr.Source.(io.Closer); ok { + _ = c.Close() + } + }() + + desc, err := t.asFile(ctx, file, sr) + if err != nil { + r.fail(err) + return + } + r.complete(desc) +} + +// A compilation task. The executor has a semaphore that limits the number +// of concurrent, running tasks. +type task struct { + e *executor + + // handler for this task + h *reporter.Handler + + // If true, this task needs to acquire a semaphore permit before running. + // If false, this task needs to release its semaphore permit on completion. + released bool + + // the result that is populated by this task + r *result +} + +func (t *task) release() { + if !t.released { + t.e.s.Release(1) + t.released = true + } +} + +func (t *task) asFile(ctx context.Context, name string, r SearchResult) (linker.File, error) { + if r.Desc != nil { + if r.Desc.Path() != name { + return nil, fmt.Errorf("search result for %q returned descriptor for %q", name, r.Desc.Path()) + } + return linker.NewFileRecursive(r.Desc) + } + + parseRes, err := t.asParseResult(name, r) + if err != nil { + return nil, err + } + + var deps []linker.File + if len(parseRes.FileDescriptorProto().Dependency) > 0 { + t.r.setBlockedOn(parseRes.FileDescriptorProto().Dependency) + + results := make([]*result, len(parseRes.FileDescriptorProto().Dependency)) + checked := map[string]struct{}{} + for i, dep := range parseRes.FileDescriptorProto().Dependency { + pos := findImportPos(parseRes, dep) + if name == dep { + // doh! file imports itself + handleImportCycle(t.h, pos, []string{name}, dep) + return nil, t.h.Error() + } + + res := t.e.compile(ctx, dep) + // check for dependency cycle to prevent deadlock + if err := t.e.checkForDependencyCycle(res, []string{name, dep}, pos, checked); err != nil { + return nil, err + } + results[i] = res + } + deps = make([]linker.File, len(results)) + + // release our semaphore so dependencies can be processed w/out risk of deadlock + t.e.s.Release(1) + t.released = true + + // now we wait for them all to be computed + for i, res := range results { + select { + case <-res.ready: + if res.err != nil { + if rerr, ok := res.err.(errFailedToResolve); ok { + // We don't report errors to get file from resolver to handler since + // it's usually considered immediately fatal. However, if the reason + // we were resolving is due to an import, turn this into an error with + // source position that pinpoints the import statement and report it. + return nil, reporter.Error(findImportPos(parseRes, res.name), rerr) + } + return nil, res.err + } + deps[i] = res.res + case <-ctx.Done(): + return nil, ctx.Err() + } + } + + // all deps resolved + t.r.setBlockedOn(nil) + // reacquire semaphore so we can proceed + if err := t.e.s.Acquire(ctx, 1); err != nil { + return nil, err + } + t.released = false + } + + return t.link(parseRes, deps) +} + +func (e *executor) checkForDependencyCycle(res *result, sequence []string, pos ast.SourcePos, checked map[string]struct{}) error { + if _, ok := checked[res.name]; ok { + // already checked this one + return nil + } + checked[res.name] = struct{}{} + deps := res.getBlockedOn() + for _, dep := range deps { + // is this a cycle? + for _, file := range sequence { + if file == dep { + handleImportCycle(e.h, pos, sequence, dep) + return e.h.Error() + } + } + + e.mu.Lock() + depRes := e.results[dep] + e.mu.Unlock() + if depRes == nil { + continue + } + if err := e.checkForDependencyCycle(depRes, append(sequence, dep), pos, checked); err != nil { + return err + } + } + return nil +} + +func handleImportCycle(h *reporter.Handler, pos ast.SourcePos, importSequence []string, dep string) { + var buf bytes.Buffer + buf.WriteString("cycle found in imports: ") + for _, imp := range importSequence { + fmt.Fprintf(&buf, "%q -> ", imp) + } + fmt.Fprintf(&buf, "%q", dep) + // error is saved and returned in caller + h.HandleErrorf(pos, buf.String()) //nolint:errcheck +} + +func findImportPos(res parser.Result, dep string) ast.SourcePos { + root := res.AST() + if root == nil { + return ast.UnknownPos(res.FileNode().Name()) + } + for _, decl := range root.Decls { + if imp, ok := decl.(*ast.ImportNode); ok { + if imp.Name.AsString() == dep { + return root.NodeInfo(imp.Name).Start() + } + } + } + // this should never happen... + return ast.UnknownPos(res.FileNode().Name()) +} + +func (t *task) link(parseRes parser.Result, deps linker.Files) (linker.File, error) { + file, err := linker.Link(parseRes, deps, t.e.sym, t.h) + if err != nil { + return nil, err + } + optsIndex, err := options.InterpretOptions(file, t.h) + if err != nil { + return nil, err + } + // now that options are interpreted, we can do some additional checks + if err := file.ValidateOptions(t.h); err != nil { + return nil, err + } + if t.r.explicitFile { + file.CheckForUnusedImports(t.h) + } + + if t.e.c.SourceInfoMode != SourceInfoNone && parseRes.AST() != nil { + switch t.e.c.SourceInfoMode { + case SourceInfoStandard: + parseRes.FileDescriptorProto().SourceCodeInfo = sourceinfo.GenerateSourceInfo(parseRes.AST(), optsIndex) + case SourceInfoExtraComments: + parseRes.FileDescriptorProto().SourceCodeInfo = sourceinfo.GenerateSourceInfoWithExtraComments(parseRes.AST(), optsIndex) + } + file.PopulateSourceCodeInfo() + } + + if !t.e.c.RetainASTs { + file.RemoveAST() + } + return file, nil +} + +func (t *task) asParseResult(name string, r SearchResult) (parser.Result, error) { + if r.ParseResult != nil { + if r.ParseResult.FileDescriptorProto().GetName() != name { + return nil, fmt.Errorf("search result for %q returned descriptor for %q", name, r.ParseResult.FileDescriptorProto().GetName()) + } + return r.ParseResult, nil + } + + if r.Proto != nil { + if r.Proto.GetName() != name { + return nil, fmt.Errorf("search result for %q returned descriptor for %q", name, r.Proto.GetName()) + } + return parser.ResultWithoutAST(r.Proto), nil + } + + file, err := t.asAST(name, r) + if err != nil { + return nil, err + } + + return parser.ResultFromAST(file, true, t.h) +} + +func (t *task) asAST(name string, r SearchResult) (*ast.FileNode, error) { + if r.AST != nil { + if r.AST.Name() != name { + return nil, fmt.Errorf("search result for %q returned descriptor for %q", name, r.AST.Name()) + } + return r.AST, nil + } + + return parser.Parse(name, r.Source, t.h) +} diff --git a/vendor/github.com/bufbuild/protocompile/doc.go b/vendor/github.com/bufbuild/protocompile/doc.go new file mode 100644 index 00000000000..661ccc45fee --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/doc.go @@ -0,0 +1,82 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package protocompile provides the entry point for a high performance +// native Go protobuf compiler. "Compile" in this case just means parsing +// and validating source and generating fully-linked descriptors in the end. +// Unlike the protoc command-line tool, this package does not try to use the +// descriptors to perform code generation. +// +// The various sub-packages represent the various compile phases and contain +// models for the intermediate results. Those phases follow: +// 1. Parse into AST. +// Also see: parser.Parse +// 2. Convert AST to unlinked descriptor protos. +// Also see: parser.ResultFromAST +// 3. Link descriptor protos into "rich" descriptors. +// Also see: linker.Link +// 4. Interpret custom options. +// Also see: options.InterpretOptions +// 5. Generate source code info. +// Also see: sourceinfo.GenerateSourceInfo +// +// This package provides an easy-to-use interface that does all the relevant +// phases, based on the inputs given. If an input is provided as source, all +// phases apply. If an input is provided as a descriptor proto, only phases +// 3 to 5 apply. Nothing is necessary if provided a linked descriptor (which +// is usually only the case for select system dependencies). +// +// This package is also capable of taking advantage of multiple CPU cores, so +// a compilation involving thousands of files can be done very quickly by +// compiling things in parallel. +// +// # Resolvers +// +// A Resolver is how the compiler locates artifacts that are inputs to the +// compilation. For example, it can load protobuf source code that must be +// processed. A Resolver could also supply some already-compiled dependencies +// as fully-linked descriptors, alleviating the need to re-compile them. +// +// A Resolver can provide any of the following in response to a query for an +// input. +// - Source code: If a resolver answers a query with protobuf source, the +// compiler will parse and compile it. +// - AST: If a resolver answers a query with an AST, the parsing step can be +// skipped, and the rest of the compilation steps will be applied. +// - Descriptor proto: If a resolver answers a query with an unlinked proto, +// only the other compilation steps, including linking, need to be applied. +// - Descriptor: If a resolver answers a query with a fully-linked descriptor, +// nothing further needs to be done. The descriptor is used as-is. +// +// Compilation will use the Resolver to load the files that are to be compiled +// and also to load all dependencies (i.e. other files imported by those being +// compiled). +// +// # Compiler +// +// A Compiler accepts a list of file names and produces the list of descriptors. +// A Compiler has several fields that control how it works but only the Resolver +// field is required. A minimal Compiler, that resolves files by loading them +// from the file system based on the current working directory, can be had with +// the following simple snippet: +// +// compiler := protocompile.Compiler{ +// Resolver: &protocompile.SourceResolver{}, +// } +// +// This minimal Compiler will use default parallelism, equal to the number of +// CPU cores detected; it will not generate source code info in the resulting +// descriptors; and it will fail fast at the first sign of any error. All of +// these aspects can be customized by setting other fields. +package protocompile diff --git a/vendor/github.com/bufbuild/protocompile/go.work b/vendor/github.com/bufbuild/protocompile/go.work new file mode 100644 index 00000000000..de1c41a8fa4 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/go.work @@ -0,0 +1,7 @@ +go 1.19 + +use ( + . + ./internal/benchmarks + ./internal/tools +) diff --git a/vendor/github.com/bufbuild/protocompile/go.work.sum b/vendor/github.com/bufbuild/protocompile/go.work.sum new file mode 100644 index 00000000000..0b7ae97bff9 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/go.work.sum @@ -0,0 +1,412 @@ +cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= +cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= +cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= +cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= +cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= +cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= +cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= +cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= +cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4= +cloud.google.com/go/accesscontextmanager v1.3.0/go.mod h1:TgCBehyr5gNMz7ZaH9xubp+CE8dkrszb4oK9CWyvD4o= +cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= +cloud.google.com/go/analytics v0.12.0/go.mod h1:gkfj9h6XRf9+TS4bmuhPEShsh3hH8PAZzm/41OOhQd4= +cloud.google.com/go/apigateway v1.3.0/go.mod h1:89Z8Bhpmxu6AmUxuVRg/ECRGReEdiP3vQtk4Z1J9rJk= +cloud.google.com/go/apigeeconnect v1.3.0/go.mod h1:G/AwXFAKo0gIXkPTVfZDd2qA1TxBXJ3MgMRBQkIi9jc= +cloud.google.com/go/appengine v1.4.0/go.mod h1:CS2NhuBuDXM9f+qscZ6V86m1MIIqPj3WC/UoEuR1Sno= +cloud.google.com/go/area120 v0.6.0/go.mod h1:39yFJqWVgm0UZqWTOdqkLhjoC7uFfgXRC8g/ZegeAh0= +cloud.google.com/go/artifactregistry v1.7.0/go.mod h1:mqTOFOnGZx8EtSqK/ZWcsm/4U8B77rbcLP6ruDU2Ixk= +cloud.google.com/go/artifactregistry v1.8.0/go.mod h1:w3GQXkJX8hiKN0v+at4b0qotwijQbYUqF2GWkZzAhC0= +cloud.google.com/go/asset v1.7.0/go.mod h1:YbENsRK4+xTiL+Ofoj5Ckf+O17kJtgp3Y3nn4uzZz5s= +cloud.google.com/go/asset v1.9.0/go.mod h1:83MOE6jEJBMqFKadM9NLRcs80Gdw76qGuHn8m3h8oHQ= +cloud.google.com/go/assuredworkloads v1.6.0/go.mod h1:yo2YOk37Yc89Rsd5QMVECvjaMKymF9OP+QXWlKXUkXw= +cloud.google.com/go/assuredworkloads v1.8.0/go.mod h1:AsX2cqyNCOvEQC8RMPnoc0yEarXQk6WEKkxYfL6kGIo= +cloud.google.com/go/automl v1.6.0/go.mod h1:ugf8a6Fx+zP0D59WLhqgTDsQI9w07o64uf/Is3Nh5p8= +cloud.google.com/go/automl v1.7.0/go.mod h1:RL9MYCCsJEOmt0Wf3z9uzG0a7adTT1fe+aObgSpkCt8= +cloud.google.com/go/baremetalsolution v0.3.0/go.mod h1:XOrocE+pvK1xFfleEnShBlNAXf+j5blPPxrhjKgnIFc= +cloud.google.com/go/batch v0.3.0/go.mod h1:TR18ZoAekj1GuirsUsR1ZTKN3FC/4UDnScjT8NXImFE= +cloud.google.com/go/beyondcorp v0.2.0/go.mod h1:TB7Bd+EEtcw9PCPQhCJtJGjk/7TC6ckmnSFS+xwTfm4= +cloud.google.com/go/bigquery v1.42.0/go.mod h1:8dRTJxhtG+vwBKzE5OseQn/hiydoQN3EedCaOdYmxRA= +cloud.google.com/go/billing v1.5.0/go.mod h1:mztb1tBc3QekhjSgmpf/CV4LzWXLzCArwpLmP2Gm88s= +cloud.google.com/go/billing v1.6.0/go.mod h1:WoXzguj+BeHXPbKfNWkqVtDdzORazmCjraY+vrxcyvI= +cloud.google.com/go/binaryauthorization v1.2.0/go.mod h1:86WKkJHtRcv5ViNABtYMhhNWRrD1Vpi//uKEy7aYEfI= +cloud.google.com/go/binaryauthorization v1.3.0/go.mod h1:lRZbKgjDIIQvzYQS1p99A7/U1JqvqeZg0wiI5tp6tg0= +cloud.google.com/go/certificatemanager v1.3.0/go.mod h1:n6twGDvcUBFu9uBgt4eYvvf3sQ6My8jADcOVwHmzadg= +cloud.google.com/go/channel v1.8.0/go.mod h1:W5SwCXDJsq/rg3tn3oG0LOxpAo6IMxNa09ngphpSlnk= +cloud.google.com/go/cloudbuild v1.3.0/go.mod h1:WequR4ULxlqvMsjDEEEFnOG5ZSRSgWOywXYDb1vPE6U= +cloud.google.com/go/clouddms v1.3.0/go.mod h1:oK6XsCDdW4Ib3jCCBugx+gVjevp2TMXFtgxvPSee3OM= +cloud.google.com/go/cloudtasks v1.6.0/go.mod h1:C6Io+sxuke9/KNRkbQpihnW93SWDU3uXt92nu85HkYI= +cloud.google.com/go/cloudtasks v1.7.0/go.mod h1:ImsfdYWwlWNJbdgPIIGJWC+gemEGTBK/SunNQQNCAb4= +cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= +cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= +cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= +cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= +cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= +cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= +cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= +cloud.google.com/go/contactcenterinsights v1.3.0/go.mod h1:Eu2oemoePuEFc/xKFPjbTuPSj0fYJcPls9TFlPNnHHY= +cloud.google.com/go/container v1.6.0/go.mod h1:Xazp7GjJSeUYo688S+6J5V+n/t+G5sKBTFkKNudGRxg= +cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= +cloud.google.com/go/datacatalog v1.6.0/go.mod h1:+aEyF8JKg+uXcIdAmmaMUmZ3q1b/lKLtXCmXdnc0lbc= +cloud.google.com/go/datacatalog v1.7.0/go.mod h1:9mEl4AuDYWw81UGc41HonIHH7/sn52H0/tc8f8ZbZIE= +cloud.google.com/go/dataflow v0.7.0/go.mod h1:PX526vb4ijFMesO1o202EaUmouZKBpjHsTlCtB4parQ= +cloud.google.com/go/dataform v0.4.0/go.mod h1:fwV6Y4Ty2yIFL89huYlEkwUPtS7YZinZbzzj5S9FzCE= +cloud.google.com/go/datafusion v1.4.0/go.mod h1:1Zb6VN+W6ALo85cXnM1IKiPw+yQMKMhB9TsTSRDo/38= +cloud.google.com/go/datalabeling v0.6.0/go.mod h1:WqdISuk/+WIGeMkpw/1q7bK/tFEZxsrFJOJdY2bXvTQ= +cloud.google.com/go/dataplex v1.3.0/go.mod h1:hQuRtDg+fCiFgC8j0zV222HvzFQdRd+SVX8gdmFcZzA= +cloud.google.com/go/dataproc v1.7.0/go.mod h1:CKAlMjII9H90RXaMpSxQ8EU6dQx6iAYNPcYPOkSbi8s= +cloud.google.com/go/dataqna v0.6.0/go.mod h1:1lqNpM7rqNLVgWBJyk5NF6Uen2PHym0jtVJonplVsDA= +cloud.google.com/go/datastream v1.3.0/go.mod h1:cqlOX8xlyYF/uxhiKn6Hbv6WjwPPuI9W2M9SAXwaLLQ= +cloud.google.com/go/datastream v1.4.0/go.mod h1:h9dpzScPhDTs5noEMQVWP8Wx8AFBRyS0s8KWPx/9r0g= +cloud.google.com/go/deploy v1.4.0/go.mod h1:5Xghikd4VrmMLNaF6FiRFDlHb59VM59YoDQnOUdsH/c= +cloud.google.com/go/dialogflow v1.16.1/go.mod h1:po6LlzGfK+smoSmTBnbkIZY2w8ffjz/RcGSS+sh1el0= +cloud.google.com/go/dialogflow v1.18.0/go.mod h1:trO7Zu5YdyEuR+BhSNOqJezyFQ3aUzz0njv7sMx/iek= +cloud.google.com/go/dlp v1.6.0/go.mod h1:9eyB2xIhpU0sVwUixfBubDoRwP+GjeUoxxeueZmqvmM= +cloud.google.com/go/documentai v1.8.0/go.mod h1:xGHNEB7CtsnySCNrCFdCyyMz44RhFEEX2Q7UD0c5IhU= +cloud.google.com/go/documentai v1.9.0/go.mod h1:FS5485S8R00U10GhgBC0aNGrJxBP8ZVpEeJ7PQDZd6k= +cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg= +cloud.google.com/go/edgecontainer v0.1.0/go.mod h1:WgkZ9tp10bFxqO8BLPqv2LlfmQF1X8lZqwW4r1BTajk= +cloud.google.com/go/edgecontainer v0.2.0/go.mod h1:RTmLijy+lGpQ7BXuTDa4C4ssxyXT34NIuHIgKuP4s5w= +cloud.google.com/go/essentialcontacts v1.3.0/go.mod h1:r+OnHa5jfj90qIfZDO/VztSFqbQan7HV75p8sA+mdGI= +cloud.google.com/go/eventarc v1.7.0/go.mod h1:6ctpF3zTnaQCxUjHUdcfgcA1A2T309+omHZth7gDfmc= +cloud.google.com/go/filestore v1.3.0/go.mod h1:+qbvHGvXU1HaKX2nD0WEPo92TP/8AQuCVEBXNY9z0+w= +cloud.google.com/go/functions v1.7.0/go.mod h1:+d+QBcWM+RsrgZfV9xo6KfA1GlzJfxcfZcRPEhDDfzg= +cloud.google.com/go/functions v1.8.0/go.mod h1:RTZ4/HsQjIqIYP9a9YPbU+QFoQsAlYgrwOXJWHn1POY= +cloud.google.com/go/gaming v1.6.0/go.mod h1:YMU1GEvA39Qt3zWGyAVA9bpYz/yAhTvaQ1t2sK4KPUA= +cloud.google.com/go/gaming v1.7.0/go.mod h1:LrB8U7MHdGgFG851iHAfqUdLcKBdQ55hzXy9xBJz0+w= +cloud.google.com/go/gkebackup v0.2.0/go.mod h1:XKvv/4LfG829/B8B7xRkk8zRrOEbKtEam6yNfuQNH60= +cloud.google.com/go/gkeconnect v0.6.0/go.mod h1:Mln67KyU/sHJEBY8kFZ0xTeyPtzbq9StAVvEULYK16A= +cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y977wO+hBH0= +cloud.google.com/go/gkemulticloud v0.3.0/go.mod h1:7orzy7O0S+5kq95e4Hpn7RysVA7dPs8W/GgfUtsPbrA= +cloud.google.com/go/gsuiteaddons v1.3.0/go.mod h1:EUNK/J1lZEZO8yPtykKxLXI6JSVN2rg9bN8SXOa0bgM= +cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= +cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHDMFMc= +cloud.google.com/go/iap v1.4.0/go.mod h1:RGFwRJdihTINIe4wZ2iCP0zF/qu18ZwyKxrhMhygBEc= +cloud.google.com/go/ids v1.1.0/go.mod h1:WIuwCaYVOzHIj2OhN9HAwvW+DBdmUAdcWlFxRl+KubM= +cloud.google.com/go/iot v1.3.0/go.mod h1:r7RGh2B61+B8oz0AGE+J72AhA0G7tdXItODWsaA2oLs= +cloud.google.com/go/kms v1.5.0/go.mod h1:QJS2YY0eJGBg3mnDfuaCyLauWwBJiHRboYxJ++1xJNg= +cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= +cloud.google.com/go/language v1.7.0/go.mod h1:DJ6dYN/W+SQOjF8e1hLQXMF21AkH2w9wiPzPCJa2MIE= +cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= +cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE= +cloud.google.com/go/managedidentities v1.3.0/go.mod h1:UzlW3cBOiPrzucO5qWkNkh0w33KFtBJU281hacNvsdE= +cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= +cloud.google.com/go/memcache v1.5.0/go.mod h1:dk3fCK7dVo0cUU2c36jKb4VqKPS22BTkf81Xq617aWM= +cloud.google.com/go/memcache v1.6.0/go.mod h1:XS5xB0eQZdHtTuTF9Hf8eJkKtR3pVRCcvJwtm68T3rA= +cloud.google.com/go/metastore v1.6.0/go.mod h1:6cyQTls8CWXzk45G55x57DVQ9gWg7RiH65+YgPsNh9s= +cloud.google.com/go/metastore v1.7.0/go.mod h1:s45D0B4IlsINu87/AsWiEVYbLaIMeUSoxlKKDqBGFS8= +cloud.google.com/go/monitoring v1.7.0/go.mod h1:HpYse6kkGo//7p6sT0wsIC6IBDET0RhIsnmlA53dvEk= +cloud.google.com/go/networkconnectivity v1.5.0/go.mod h1:3GzqJx7uhtlM3kln0+x5wyFvuVH1pIBJjhCpjzSt75o= +cloud.google.com/go/networkconnectivity v1.6.0/go.mod h1:OJOoEXW+0LAxHh89nXd64uGG+FbQoeH8DtxCHVOMlaM= +cloud.google.com/go/networkmanagement v1.4.0/go.mod h1:Q9mdLLRn60AsOrPc8rs8iNV6OHXaGcDdsIQe1ohekq8= +cloud.google.com/go/networksecurity v0.6.0/go.mod h1:Q5fjhTr9WMI5mbpRYEbiexTzROf7ZbDzvzCrNl14nyU= +cloud.google.com/go/notebooks v1.3.0/go.mod h1:bFR5lj07DtCPC7YAAJ//vHskFBxA5JzYlH68kXVdk34= +cloud.google.com/go/notebooks v1.4.0/go.mod h1:4QPMngcwmgb6uw7Po99B2xv5ufVoIQ7nOGDyL4P8AgA= +cloud.google.com/go/optimization v1.1.0/go.mod h1:5po+wfvX5AQlPznyVEZjGJTMr4+CAkJf2XSTQOOl9l4= +cloud.google.com/go/orchestration v1.3.0/go.mod h1:Sj5tq/JpWiB//X/q3Ngwdl5K7B7Y0KZ7bfv0wL6fqVA= +cloud.google.com/go/orgpolicy v1.4.0/go.mod h1:xrSLIV4RePWmP9P3tBl8S93lTmlAxjm06NSm2UTmKvE= +cloud.google.com/go/osconfig v1.8.0/go.mod h1:EQqZLu5w5XA7eKizepumcvWx+m8mJUhEwiPqWiZeEdg= +cloud.google.com/go/osconfig v1.9.0/go.mod h1:Yx+IeIZJ3bdWmzbQU4fxNl8xsZ4amB+dygAwFPlvnNo= +cloud.google.com/go/oslogin v1.5.0/go.mod h1:D260Qj11W2qx/HVF29zBg+0fd6YCSjSqLUkY/qEenQU= +cloud.google.com/go/oslogin v1.6.0/go.mod h1:zOJ1O3+dTU8WPlGEkFSh7qeHPPSoxrcMbbK1Nm2iX70= +cloud.google.com/go/phishingprotection v0.6.0/go.mod h1:9Y3LBLgy0kDTcYET8ZH3bq/7qni15yVUoAxiFxnlSUA= +cloud.google.com/go/policytroubleshooter v1.3.0/go.mod h1:qy0+VwANja+kKrjlQuOzmlvscn4RNsAc0e15GGqfMxg= +cloud.google.com/go/privatecatalog v0.6.0/go.mod h1:i/fbkZR0hLN29eEWiiwue8Pb+GforiEIBnV9yrRUOKI= +cloud.google.com/go/recaptchaenterprise/v2 v2.2.0/go.mod h1:/Zu5jisWGeERrd5HnlS3EUGb/D335f9k51B/FVil0jk= +cloud.google.com/go/recaptchaenterprise/v2 v2.4.0/go.mod h1:Am3LHfOuBstrLrNCBrlI5sbwx9LBg3te2N6hGvHn2mE= +cloud.google.com/go/recommendationengine v0.6.0/go.mod h1:08mq2umu9oIqc7tDy8sx+MNJdLG0fUi3vaSVbztHgJ4= +cloud.google.com/go/recommender v1.6.0/go.mod h1:+yETpm25mcoiECKh9DEScGzIRyDKpZ0cEhWGo+8bo+c= +cloud.google.com/go/recommender v1.7.0/go.mod h1:XLHs/W+T8olwlGOgfQenXBTbIseGclClff6lhFVe9Bs= +cloud.google.com/go/redis v1.8.0/go.mod h1:Fm2szCDavWzBk2cDKxrkmWBqoCiL1+Ctwq7EyqBCA/A= +cloud.google.com/go/redis v1.9.0/go.mod h1:HMYQuajvb2D0LvMgZmLDZW8V5aOC/WxstZHiy4g8OiA= +cloud.google.com/go/resourcemanager v1.3.0/go.mod h1:bAtrTjZQFJkiWTPDb1WBjzvc6/kifjj4QBYuKCCoqKA= +cloud.google.com/go/resourcesettings v1.3.0/go.mod h1:lzew8VfESA5DQ8gdlHwMrqZs1S9V87v3oCnKCWoOuQU= +cloud.google.com/go/retail v1.9.0/go.mod h1:g6jb6mKuCS1QKnH/dpu7isX253absFl6iE92nHwlBUY= +cloud.google.com/go/retail v1.10.0/go.mod h1:2gDk9HsL4HMS4oZwz6daui2/jmKvqShXKQuB2RZ+cCc= +cloud.google.com/go/run v0.2.0/go.mod h1:CNtKsTA1sDcnqqIFR3Pb5Tq0usWxJJvsWOCPldRU3Do= +cloud.google.com/go/scheduler v1.5.0/go.mod h1:ri073ym49NW3AfT6DZi21vLZrG07GXr5p3H1KxN5QlI= +cloud.google.com/go/scheduler v1.6.0/go.mod h1:SgeKVM7MIwPn3BqtcBntpLyrIJftQISRrYB5ZtT+KOk= +cloud.google.com/go/secretmanager v1.6.0/go.mod h1:awVa/OXF6IiyaU1wQ34inzQNc4ISIDIrId8qE5QGgKA= +cloud.google.com/go/secretmanager v1.8.0/go.mod h1:hnVgi/bN5MYHd3Gt0SPuTPPp5ENina1/LxM+2W9U9J4= +cloud.google.com/go/security v1.8.0/go.mod h1:hAQOwgmaHhztFhiQ41CjDODdWP0+AE1B3sX4OFlq+GU= +cloud.google.com/go/security v1.9.0/go.mod h1:6Ta1bO8LXI89nZnmnsZGp9lVoVWXqsVbIq/t9dzI+2Q= +cloud.google.com/go/securitycenter v1.14.0/go.mod h1:gZLAhtyKv85n52XYWt6RmeBdydyxfPeTrpToDPw4Auc= +cloud.google.com/go/securitycenter v1.15.0/go.mod h1:PeKJ0t8MoFmmXLXWm41JidyzI3PJjd8sXWaVqg43WWk= +cloud.google.com/go/servicecontrol v1.4.0/go.mod h1:o0hUSJ1TXJAmi/7fLJAedOovnujSEvjKCAFNXPQ1RaU= +cloud.google.com/go/servicedirectory v1.5.0/go.mod h1:QMKFL0NUySbpZJ1UZs3oFAmdvVxhhxB6eJ/Vlp73dfg= +cloud.google.com/go/servicedirectory v1.6.0/go.mod h1:pUlbnWsLH9c13yGkxCmfumWEPjsRs1RlmJ4pqiNjVL4= +cloud.google.com/go/servicemanagement v1.4.0/go.mod h1:d8t8MDbezI7Z2R1O/wu8oTggo3BI2GKYbdG4y/SJTco= +cloud.google.com/go/serviceusage v1.3.0/go.mod h1:Hya1cozXM4SeSKTAgGXgj97GlqUvF5JaoXacR1JTP/E= +cloud.google.com/go/shell v1.3.0/go.mod h1:VZ9HmRjZBsjLGXusm7K5Q5lzzByZmJHf1d0IWHEN5X4= +cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ= +cloud.google.com/go/speech v1.8.0/go.mod h1:9bYIl1/tjsAnMgKGHKmBZzXKEkGgtU+MpdDPTE9f7y0= +cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= +cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= +cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= +cloud.google.com/go/storagetransfer v1.5.0/go.mod h1:dxNzUopWy7RQevYFHewchb29POFv3/AaBgnhqzqiK0w= +cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= +cloud.google.com/go/talent v1.3.0/go.mod h1:CmcxwJ/PKfRgd1pBjQgU6W3YBwiewmUzQYH5HHmSCmM= +cloud.google.com/go/texttospeech v1.4.0/go.mod h1:FX8HQHA6sEpJ7rCMSfXuzBcysDAuWusNNNvN9FELDd8= +cloud.google.com/go/tpu v1.3.0/go.mod h1:aJIManG0o20tfDQlRIej44FcwGGl/cD0oiRyMKG19IQ= +cloud.google.com/go/trace v1.3.0/go.mod h1:FFUE83d9Ca57C+K8rDl/Ih8LwOzWIV1krKgxg6N0G28= +cloud.google.com/go/translate v1.3.0/go.mod h1:gzMUwRjvOqj5i69y/LYLd8RrNQk+hOmIXTi9+nb3Djs= +cloud.google.com/go/video v1.8.0/go.mod h1:sTzKFc0bUSByE8Yoh8X0mn8bMymItVGPfTuUBUyRgxk= +cloud.google.com/go/videointelligence v1.7.0/go.mod h1:k8pI/1wAhjznARtVT9U1llUaFNPh7muw8QyOUpavru4= +cloud.google.com/go/videointelligence v1.8.0/go.mod h1:dIcCn4gVDdS7yte/w+koiXn5dWVplOZkE+xwG9FgK+M= +cloud.google.com/go/vision/v2 v2.3.0/go.mod h1:UO61abBx9QRMFkNBbf1D8B1LXdS2cGiiCRx0vSpZoUo= +cloud.google.com/go/vision/v2 v2.4.0/go.mod h1:VtI579ll9RpVTrdKdkMzckdnwMyX2JILb+MhPqRbPsY= +cloud.google.com/go/vmmigration v1.2.0/go.mod h1:IRf0o7myyWFSmVR1ItrBSFLFD/rJkfDCUTO4vLlJvsE= +cloud.google.com/go/vpcaccess v1.4.0/go.mod h1:aQHVbTWDYUR1EbTApSVvMq1EnT57ppDmQzZ3imqIk4w= +cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= +cloud.google.com/go/webrisk v1.6.0/go.mod h1:65sW9V9rOosnc9ZY7A7jsy1zoHS5W9IAXv6dGqhMQMc= +cloud.google.com/go/websecurityscanner v1.3.0/go.mod h1:uImdKm2wyeXQevQJXeh8Uun/Ym1VqworNDlBXQevGMo= +cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= +github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= +github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= +github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= +github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= +github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= +github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= +github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= +github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= +github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/jhump/protoreflect v1.13.1-0.20220928232736-101791cb1b4c h1:XImQJfpJLmGEEd8ll5yPVyL/aEvmgGHW4WYTyNseLOM= +github.com/jhump/protoreflect v1.13.1-0.20220928232736-101791cb1b4c/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= +github.com/jhump/protoreflect v1.14.0 h1:MBbQK392K3u8NTLbKOCIi3XdI+y+c6yt5oMq0X3xviw= +github.com/jhump/protoreflect v1.14.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= +golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= +golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= +google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= +google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= +google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= +google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= +google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= +google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= +google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= +google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= +google.golang.org/api v0.81.0/go.mod h1:FA6Mb/bZxj706H2j+j2d6mHEEaHBmbbWnkfvmorOCko= +google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= +google.golang.org/api v0.85.0/go.mod h1:AqZf8Ep9uZ2pyTvgL+x0D3Zt0eoT9b5E8fmzfu6FO2g= +google.golang.org/api v0.90.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= +google.golang.org/api v0.93.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= +google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= +google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= +google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= +google.golang.org/api v0.99.0/go.mod h1:1YOf74vkVndF7pG6hIHuINsM7eWwpVTAfNMNiL91A08= +google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= +google.golang.org/genproto v0.0.0-20220722212130-b98a9ff5e252/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE= +google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= +google.golang.org/genproto v0.0.0-20220915135415-7fd63a7952de/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= +google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqwhZAwq4wsRUaVG555sVgsNmIjRtO7t/JH29U= +google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a h1:GH6UPn3ixhWcKDhpnEC55S75cerLPdpp3hrhfKYjZgw= +google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= +google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= +google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c h1:QgY/XxIAIeccR+Ca/rDdKubLIU9rcJ3xfy1DC/Wd2Oo= +google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/bufbuild/protocompile/internal/message_context.go b/vendor/github.com/bufbuild/protocompile/internal/message_context.go new file mode 100644 index 00000000000..134a05d0024 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/internal/message_context.go @@ -0,0 +1,98 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import ( + "bytes" + "fmt" + + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" +) + +// ParsedFile wraps an optional AST and required FileDescriptorProto. +// This is used so types like parser.Result can be passed to this internal package avoiding circular imports. +// Additionally, it makes it less likely that users might specify one or the other. +type ParsedFile interface { + // AST returns the parsed abstract syntax tree. This returns nil if the + // Result was created without an AST. + AST() *ast.FileNode + // FileDescriptorProto returns the file descriptor proto. + FileDescriptorProto() *descriptorpb.FileDescriptorProto +} + +// MessageContext provides information about the location in a descriptor +// hierarchy, for adding context to warnings and error messages. +type MessageContext struct { + // The relevant file + File ParsedFile + + // The type and fully-qualified name of the element within the file. + ElementType string + ElementName string + + // If the element being processed is an option (or *in* an option) + // on the named element above, this will be non-nil. + Option *descriptorpb.UninterpretedOption + // If the element being processed is inside a message literal in an + // option value, this will be non-empty and represent a traversal + // to the element in question. + OptAggPath string +} + +func (c *MessageContext) String() string { + var ctx bytes.Buffer + if c.ElementType != "file" { + _, _ = fmt.Fprintf(&ctx, "%s %s: ", c.ElementType, c.ElementName) + } + if c.Option != nil && c.Option.Name != nil { + ctx.WriteString("option ") + writeOptionName(&ctx, c.Option.Name) + if c.File.AST() == nil { + // if we have no source position info, try to provide as much context + // as possible (if nodes != nil, we don't need this because any errors + // will actually have file and line numbers) + if c.OptAggPath != "" { + _, _ = fmt.Fprintf(&ctx, " at %s", c.OptAggPath) + } + } + ctx.WriteString(": ") + } + return ctx.String() +} + +func writeOptionName(buf *bytes.Buffer, parts []*descriptorpb.UninterpretedOption_NamePart) { + first := true + for _, p := range parts { + if first { + first = false + } else { + buf.WriteByte('.') + } + nm := p.GetNamePart() + if nm[0] == '.' { + // skip leading dot + nm = nm[1:] + } + if p.GetIsExtension() { + buf.WriteByte('(') + buf.WriteString(nm) + buf.WriteByte(')') + } else { + buf.WriteString(nm) + } + } +} diff --git a/vendor/github.com/bufbuild/protocompile/internal/options.go b/vendor/github.com/bufbuild/protocompile/internal/options.go new file mode 100644 index 00000000000..5586802b247 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/internal/options.go @@ -0,0 +1,59 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import ( + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/reporter" +) + +type hasOptionNode interface { + OptionNode(part *descriptorpb.UninterpretedOption) ast.OptionDeclNode + FileNode() ast.FileDeclNode // needed in order to query for NodeInfo +} + +func FindOption(res hasOptionNode, handler *reporter.Handler, scope string, opts []*descriptorpb.UninterpretedOption, name string) (int, error) { + found := -1 + for i, opt := range opts { + if len(opt.Name) != 1 { + continue + } + if opt.Name[0].GetIsExtension() || opt.Name[0].GetNamePart() != name { + continue + } + if found >= 0 { + optNode := res.OptionNode(opt) + fn := res.FileNode() + node := optNode.GetName() + nodeInfo := fn.NodeInfo(node) + return -1, handler.HandleErrorf(nodeInfo.Start(), "%s: option %s cannot be defined more than once", scope, name) + } + found = i + } + return found, nil +} + +func RemoveOption(uo []*descriptorpb.UninterpretedOption, indexToRemove int) []*descriptorpb.UninterpretedOption { + switch { + case indexToRemove == 0: + return uo[1:] + case indexToRemove == len(uo)-1: + return uo[:len(uo)-1] + default: + return append(uo[:indexToRemove], uo[indexToRemove+1:]...) + } +} diff --git a/vendor/github.com/bufbuild/protocompile/internal/tags.go b/vendor/github.com/bufbuild/protocompile/internal/tags.go new file mode 100644 index 00000000000..7e674c176ce --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/internal/tags.go @@ -0,0 +1,243 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import "math" + +const ( + // MaxNormalTag is the maximum allowed tag number for a field in a normal message. + MaxNormalTag = 536870911 // 2^29 - 1 + + // MaxMessageSetTag is the maximum allowed tag number of a field in a message that + // uses the message set wire format. + MaxMessageSetTag = math.MaxInt32 - 1 + + // MaxTag is the maximum allowed tag number. (It is the same as MaxMessageSetTag + // since that is the absolute highest allowed.) + MaxTag = MaxMessageSetTag + + // SpecialReservedStart is the first tag in a range that is reserved and not + // allowed for use in message definitions. + SpecialReservedStart = 19000 + // SpecialReservedEnd is the last tag in a range that is reserved and not + // allowed for use in message definitions. + SpecialReservedEnd = 19999 + + // NB: It would be nice to use constants from generated code instead of + // hard-coding these here. But code-gen does not emit these as constants + // anywhere. The only places they appear in generated code are struct tags + // on fields of the generated descriptor protos. + + // FilePackageTag is the tag number of the package element in a file + // descriptor proto. + FilePackageTag = 2 + // FileDependencyTag is the tag number of the dependencies element in a + // file descriptor proto. + FileDependencyTag = 3 + // FileMessagesTag is the tag number of the messages element in a file + // descriptor proto. + FileMessagesTag = 4 + // FileEnumsTag is the tag number of the enums element in a file descriptor + // proto. + FileEnumsTag = 5 + // FileServicesTag is the tag number of the services element in a file + // descriptor proto. + FileServicesTag = 6 + // FileExtensionsTag is the tag number of the extensions element in a file + // descriptor proto. + FileExtensionsTag = 7 + // FileOptionsTag is the tag number of the options element in a file + // descriptor proto. + FileOptionsTag = 8 + // FileSourceCodeInfoTag is the tag number of the source code info element + // in a file descriptor proto. + FileSourceCodeInfoTag = 9 + // FilePublicDependencyTag is the tag number of the public dependency element + // in a file descriptor proto. + FilePublicDependencyTag = 10 + // FileWeakDependencyTag is the tag number of the weak dependency element + // in a file descriptor proto. + FileWeakDependencyTag = 11 + // FileSyntaxTag is the tag number of the syntax element in a file + // descriptor proto. + FileSyntaxTag = 12 + // MessageNameTag is the tag number of the name element in a message + // descriptor proto. + MessageNameTag = 1 + // MessageFieldsTag is the tag number of the fields element in a message + // descriptor proto. + MessageFieldsTag = 2 + // MessageNestedMessagesTag is the tag number of the nested messages + // element in a message descriptor proto. + MessageNestedMessagesTag = 3 + // MessageEnumsTag is the tag number of the enums element in a message + // descriptor proto. + MessageEnumsTag = 4 + // MessageExtensionRangesTag is the tag number of the extension ranges + // element in a message descriptor proto. + MessageExtensionRangesTag = 5 + // MessageExtensionsTag is the tag number of the extensions element in a + // message descriptor proto. + MessageExtensionsTag = 6 + // MessageOptionsTag is the tag number of the options element in a message + // descriptor proto. + MessageOptionsTag = 7 + // MessageOneOfsTag is the tag number of the one-ofs element in a message + // descriptor proto. + MessageOneOfsTag = 8 + // MessageReservedRangesTag is the tag number of the reserved ranges element + // in a message descriptor proto. + MessageReservedRangesTag = 9 + // MessageReservedNamesTag is the tag number of the reserved names element + // in a message descriptor proto. + MessageReservedNamesTag = 10 + // ExtensionRangeStartTag is the tag number of the start index in an + // extension range proto. + ExtensionRangeStartTag = 1 + // ExtensionRangeEndTag is the tag number of the end index in an + // extension range proto. + ExtensionRangeEndTag = 2 + // ExtensionRangeOptionsTag is the tag number of the options element in an + // extension range proto. + ExtensionRangeOptionsTag = 3 + // ReservedRangeStartTag is the tag number of the start index in a reserved + // range proto. This field number is the same for both "flavors" of reserved + // ranges: DescriptorProto.ReservedRange and EnumDescriptorProto.EnumReservedRange. + ReservedRangeStartTag = 1 + // ReservedRangeEndTag is the tag number of the end index in a reserved + // range proto. This field number is the same for both "flavors" of reserved + // ranges: DescriptorProto.ReservedRange and EnumDescriptorProto.EnumReservedRange. + ReservedRangeEndTag = 2 + // FieldNameTag is the tag number of the name element in a field descriptor + // proto. + FieldNameTag = 1 + // FieldExtendeeTag is the tag number of the extendee element in a field + // descriptor proto. + FieldExtendeeTag = 2 + // FieldNumberTag is the tag number of the number element in a field + // descriptor proto. + FieldNumberTag = 3 + // FieldLabelTag is the tag number of the label element in a field + // descriptor proto. + FieldLabelTag = 4 + // FieldTypeTag is the tag number of the type element in a field descriptor + // proto. + FieldTypeTag = 5 + // FieldTypeNameTag is the tag number of the type name element in a field + // descriptor proto. + FieldTypeNameTag = 6 + // FieldDefaultTag is the tag number of the default value element in a + // field descriptor proto. + FieldDefaultTag = 7 + // FieldOptionsTag is the tag number of the options element in a field + // descriptor proto. + FieldOptionsTag = 8 + // FieldOneofIndexTag is the tag number of the oneof index element in a + // field descriptor proto. + FieldOneofIndexTag = 9 + // FieldJSONNameTag is the tag number of the JSON name element in a field + // descriptor proto. + FieldJSONNameTag = 10 + // FieldProto3OptionalTag is the tag number of the proto3_optional element + // in a descriptor proto. + FieldProto3OptionalTag = 17 + // OneOfNameTag is the tag number of the name element in a one-of + // descriptor proto. + OneOfNameTag = 1 + // OneOfOptionsTag is the tag number of the options element in a one-of + // descriptor proto. + OneOfOptionsTag = 2 + // EnumNameTag is the tag number of the name element in an enum descriptor + // proto. + EnumNameTag = 1 + // EnumValuesTag is the tag number of the values element in an enum + // descriptor proto. + EnumValuesTag = 2 + // EnumOptionsTag is the tag number of the options element in an enum + // descriptor proto. + EnumOptionsTag = 3 + // EnumReservedRangesTag is the tag number of the reserved ranges element in + // an enum descriptor proto. + EnumReservedRangesTag = 4 + // EnumReservedNamesTag is the tag number of the reserved names element in + // an enum descriptor proto. + EnumReservedNamesTag = 5 + // EnumValNameTag is the tag number of the name element in an enum value + // descriptor proto. + EnumValNameTag = 1 + // EnumValNumberTag is the tag number of the number element in an enum + // value descriptor proto. + EnumValNumberTag = 2 + // EnumValOptionsTag is the tag number of the options element in an enum + // value descriptor proto. + EnumValOptionsTag = 3 + // ServiceNameTag is the tag number of the name element in a service + // descriptor proto. + ServiceNameTag = 1 + // ServiceMethodsTag is the tag number of the methods element in a service + // descriptor proto. + ServiceMethodsTag = 2 + // ServiceOptionsTag is the tag number of the options element in a service + // descriptor proto. + ServiceOptionsTag = 3 + // MethodNameTag is the tag number of the name element in a method + // descriptor proto. + MethodNameTag = 1 + // MethodInputTag is the tag number of the input type element in a method + // descriptor proto. + MethodInputTag = 2 + // MethodOutputTag is the tag number of the output type element in a method + // descriptor proto. + MethodOutputTag = 3 + // MethodOptionsTag is the tag number of the options element in a method + // descriptor proto. + MethodOptionsTag = 4 + // MethodInputStreamTag is the tag number of the input stream flag in a + // method descriptor proto. + MethodInputStreamTag = 5 + // MethodOutputStreamTag is the tag number of the output stream flag in a + // method descriptor proto. + MethodOutputStreamTag = 6 + + // UninterpretedOptionsTag is the tag number of the uninterpreted options + // element. All *Options messages use the same tag for the field that stores + // uninterpreted options. + UninterpretedOptionsTag = 999 + + // UninterpretedNameTag is the tag number of the name element in an + // uninterpreted options proto. + UninterpretedNameTag = 2 + // UninterpretedIdentTag is the tag number of the identifier value in an + // uninterpreted options proto. + UninterpretedIdentTag = 3 + // UninterpretedPosIntTag is the tag number of the positive int value in an + // uninterpreted options proto. + UninterpretedPosIntTag = 4 + // UninterpretedNegIntTag is the tag number of the negative int value in an + // uninterpreted options proto. + UninterpretedNegIntTag = 5 + // UninterpretedDoubleTag is the tag number of the double value in an + // uninterpreted options proto. + UninterpretedDoubleTag = 6 + // UninterpretedStringTag is the tag number of the string value in an + // uninterpreted options proto. + UninterpretedStringTag = 7 + // UninterpretedAggregateTag is the tag number of the aggregate value in an + // uninterpreted options proto. + UninterpretedAggregateTag = 8 + // UninterpretedNameNameTag is the tag number of the name element in an + // uninterpreted option name proto. + UninterpretedNameNameTag = 1 +) diff --git a/vendor/github.com/bufbuild/protocompile/internal/types.go b/vendor/github.com/bufbuild/protocompile/internal/types.go new file mode 100644 index 00000000000..5e54e4af540 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/internal/types.go @@ -0,0 +1,35 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import "google.golang.org/protobuf/types/descriptorpb" + +var FieldTypes = map[string]descriptorpb.FieldDescriptorProto_Type{ + "double": descriptorpb.FieldDescriptorProto_TYPE_DOUBLE, + "float": descriptorpb.FieldDescriptorProto_TYPE_FLOAT, + "int32": descriptorpb.FieldDescriptorProto_TYPE_INT32, + "int64": descriptorpb.FieldDescriptorProto_TYPE_INT64, + "uint32": descriptorpb.FieldDescriptorProto_TYPE_UINT32, + "uint64": descriptorpb.FieldDescriptorProto_TYPE_UINT64, + "sint32": descriptorpb.FieldDescriptorProto_TYPE_SINT32, + "sint64": descriptorpb.FieldDescriptorProto_TYPE_SINT64, + "fixed32": descriptorpb.FieldDescriptorProto_TYPE_FIXED32, + "fixed64": descriptorpb.FieldDescriptorProto_TYPE_FIXED64, + "sfixed32": descriptorpb.FieldDescriptorProto_TYPE_SFIXED32, + "sfixed64": descriptorpb.FieldDescriptorProto_TYPE_SFIXED64, + "bool": descriptorpb.FieldDescriptorProto_TYPE_BOOL, + "string": descriptorpb.FieldDescriptorProto_TYPE_STRING, + "bytes": descriptorpb.FieldDescriptorProto_TYPE_BYTES, +} diff --git a/vendor/github.com/bufbuild/protocompile/internal/util.go b/vendor/github.com/bufbuild/protocompile/internal/util.go new file mode 100644 index 00000000000..f01513ea08d --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/internal/util.go @@ -0,0 +1,119 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import ( + "bytes" + "unicode" + "unicode/utf8" +) + +// JSONName returns the default JSON name for a field with the given name. +// This mirrors the algorithm in protoc: +// +// https://github.com/protocolbuffers/protobuf/blob/v21.3/src/google/protobuf/descriptor.cc#L95 +func JSONName(name string) string { + var js []rune + nextUpper := false + for _, r := range name { + if r == '_' { + nextUpper = true + continue + } + if nextUpper { + nextUpper = false + js = append(js, unicode.ToUpper(r)) + } else { + js = append(js, r) + } + } + return string(js) +} + +// InitCap returns the given field name, but with the first letter capitalized. +func InitCap(name string) string { + r, sz := utf8.DecodeRuneInString(name) + return string(unicode.ToUpper(r)) + name[sz:] +} + +// CreatePrefixList returns a list of package prefixes to search when resolving +// a symbol name. If the given package is blank, it returns only the empty +// string. If the given package contains only one token, e.g. "foo", it returns +// that token and the empty string, e.g. ["foo", ""]. Otherwise, it returns +// successively shorter prefixes of the package and then the empty string. For +// example, for a package named "foo.bar.baz" it will return the following list: +// +// ["foo.bar.baz", "foo.bar", "foo", ""] +func CreatePrefixList(pkg string) []string { + if pkg == "" { + return []string{""} + } + + numDots := 0 + // one pass to pre-allocate the returned slice + for i := 0; i < len(pkg); i++ { + if pkg[i] == '.' { + numDots++ + } + } + if numDots == 0 { + return []string{pkg, ""} + } + + prefixes := make([]string, numDots+2) + // second pass to fill in returned slice + for i := 0; i < len(pkg); i++ { + if pkg[i] == '.' { + prefixes[numDots] = pkg[:i] + numDots-- + } + } + prefixes[0] = pkg + + return prefixes +} + +func WriteEscapedBytes(buf *bytes.Buffer, b []byte) { + // This uses the same algorithm as the protoc C++ code for escaping strings. + // The protoc C++ code in turn uses the abseil C++ library's CEscape function: + // https://github.com/abseil/abseil-cpp/blob/934f613818ffcb26c942dff4a80be9a4031c662c/absl/strings/escaping.cc#L406 + for _, c := range b { + switch c { + case '\n': + buf.WriteString("\\n") + case '\r': + buf.WriteString("\\r") + case '\t': + buf.WriteString("\\t") + case '"': + buf.WriteString("\\\"") + case '\'': + buf.WriteString("\\'") + case '\\': + buf.WriteString("\\\\") + default: + if c >= 0x20 && c < 0x7f { + // simple printable characters + buf.WriteByte(c) + } else { + // use octal escape for all other values + buf.WriteRune('\\') + buf.WriteByte('0' + ((c >> 6) & 0x7)) + buf.WriteByte('0' + ((c >> 3) & 0x7)) + buf.WriteByte('0' + (c & 0x7)) + } + } + } +} diff --git a/vendor/github.com/bufbuild/protocompile/linker/descriptors.go b/vendor/github.com/bufbuild/protocompile/linker/descriptors.go new file mode 100644 index 00000000000..20968936f3c --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/descriptors.go @@ -0,0 +1,1880 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linker + +import ( + "bytes" + "fmt" + "strconv" + "strings" + "unicode/utf8" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + "google.golang.org/protobuf/types/dynamicpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/parser" + "github.com/bufbuild/protocompile/protoutil" +) + +// This file contains implementations of protoreflect.Descriptor. Note that +// this is a hack since those interfaces have a "doNotImplement" tag +// interface therein. We do just enough to make dynamicpb happy; constructing +// a regular descriptor would fail because we haven't yet interpreted options +// at the point we need these, and some validations will fail if the options +// aren't present. + +type result struct { + protoreflect.FileDescriptor + parser.Result + prefix string + deps Files + + // A map of all descriptors keyed by their fully-qualified name (without + // any leading dot). + descriptors map[string]protoreflect.Descriptor + + // A set of imports that have been used in the course of linking and + // interpreting options. + usedImports map[string]struct{} + + // A map of descriptor options messages to their pre-serialized bytes (using + // a canonical serialization format based on how protoc renders options to + // bytes). + optionBytes map[proto.Message][]byte + + // A map of AST nodes that represent identifiers in ast.FieldReferenceNodes + // to their fully-qualified name. The identifiers are for field names in + // message literals (in option values) that are extension fields. These names + // are resolved during linking and stored here, to be used to interpret options. + optionQualifiedNames map[ast.IdentValueNode]string + + imports fileImports + messages msgDescriptors + enums enumDescriptors + extensions extDescriptors + services svcDescriptors + srcLocations srcLocs +} + +var _ protoreflect.FileDescriptor = (*result)(nil) +var _ Result = (*result)(nil) +var _ protoutil.DescriptorProtoWrapper = (*result)(nil) + +func (r *result) RemoveAST() { + r.Result = parser.ResultWithoutAST(r.FileDescriptorProto()) + r.optionQualifiedNames = nil +} + +func (r *result) AsProto() proto.Message { + return r.FileDescriptorProto() +} + +func (r *result) ParentFile() protoreflect.FileDescriptor { + return r +} + +func (r *result) Parent() protoreflect.Descriptor { + return nil +} + +func (r *result) Index() int { + return 0 +} + +func (r *result) Syntax() protoreflect.Syntax { + switch r.FileDescriptorProto().GetSyntax() { + case "proto2", "": + return protoreflect.Proto2 + case "proto3": + return protoreflect.Proto3 + default: + return 0 // ??? + } +} + +func (r *result) Name() protoreflect.Name { + return "" +} + +func (r *result) FullName() protoreflect.FullName { + return r.Package() +} + +func (r *result) IsPlaceholder() bool { + return false +} + +func (r *result) Options() protoreflect.ProtoMessage { + return r.FileDescriptorProto().Options +} + +func (r *result) Path() string { + return r.FileDescriptorProto().GetName() +} + +func (r *result) Package() protoreflect.FullName { + return protoreflect.FullName(r.FileDescriptorProto().GetPackage()) +} + +func (r *result) Imports() protoreflect.FileImports { + return &r.imports +} + +func (r *result) Enums() protoreflect.EnumDescriptors { + return &r.enums +} + +func (r *result) Messages() protoreflect.MessageDescriptors { + return &r.messages +} + +func (r *result) Extensions() protoreflect.ExtensionDescriptors { + return &r.extensions +} + +func (r *result) Services() protoreflect.ServiceDescriptors { + return &r.services +} + +func (r *result) PopulateSourceCodeInfo() { + srcLocProtos := asSourceLocations(r.FileDescriptorProto().GetSourceCodeInfo().GetLocation()) + srcLocIndex := computeSourceLocIndex(srcLocProtos) + r.srcLocations = srcLocs{file: r, locs: srcLocProtos, index: srcLocIndex} +} + +func (r *result) SourceLocations() protoreflect.SourceLocations { + return &r.srcLocations +} + +func computeSourceLocIndex(locs []protoreflect.SourceLocation) map[interface{}]int { + index := map[interface{}]int{} + for i, loc := range locs { + if loc.Next == 0 { + index[pathKey(loc.Path)] = i + } + } + return index +} + +func asSourceLocations(srcInfoProtos []*descriptorpb.SourceCodeInfo_Location) []protoreflect.SourceLocation { + locs := make([]protoreflect.SourceLocation, len(srcInfoProtos)) + prev := map[string]*protoreflect.SourceLocation{} + for i, loc := range srcInfoProtos { + var stLin, stCol, enLin, enCol int + if len(loc.Span) == 3 { + stLin, stCol, enCol = int(loc.Span[0]), int(loc.Span[1]), int(loc.Span[2]) + enLin = stLin + } else { + stLin, stCol, enLin, enCol = int(loc.Span[0]), int(loc.Span[1]), int(loc.Span[2]), int(loc.Span[3]) + } + locs[i] = protoreflect.SourceLocation{ + Path: loc.Path, + LeadingComments: loc.GetLeadingComments(), + LeadingDetachedComments: loc.GetLeadingDetachedComments(), + TrailingComments: loc.GetTrailingComments(), + StartLine: stLin, + StartColumn: stCol, + EndLine: enLin, + EndColumn: enCol, + } + str := pathStr(loc.Path) + pr := prev[str] + if pr != nil { + pr.Next = i + } + prev[str] = &locs[i] + } + return locs +} + +func pathStr(p protoreflect.SourcePath) string { + var buf bytes.Buffer + for _, v := range p { + fmt.Fprintf(&buf, "%x:", v) + } + return buf.String() +} + +// AddOptionBytes associates the given opts (an options message encoded in the +// binary format) with the given options protobuf message. The protobuf message +// should exist in the hierarchy of this result's FileDescriptorProto. This +// allows the FileDescriptorProto to be marshaled to bytes in a way that +// preserves the way options are defined in source (just as is done by protoc, +// but not possible when only using the generated Go types and standard +// marshaling APIs in the protobuf runtime). +func (r *result) AddOptionBytes(pm proto.Message, opts []byte) { + if r.optionBytes == nil { + r.optionBytes = map[proto.Message][]byte{} + } + r.optionBytes[pm] = append(r.optionBytes[pm], opts...) +} + +func (r *result) CanonicalProto() *descriptorpb.FileDescriptorProto { + origFd := r.FileDescriptorProto() + // make a copy that we can mutate + fd := proto.Clone(origFd).(*descriptorpb.FileDescriptorProto) //nolint:errcheck + + r.storeOptionBytesInFile(fd, origFd) + + return fd +} + +func (r *result) storeOptionBytesInFile(fd, origFd *descriptorpb.FileDescriptorProto) { + if fd.Options != nil { + fd.Options.Reset() + fd.Options.ProtoReflect().SetUnknown(r.optionBytes[origFd.Options]) + } + + for i, md := range fd.MessageType { + origMd := origFd.MessageType[i] + r.storeOptionBytesInMessage(md, origMd) + } + + for i, ed := range fd.EnumType { + origEd := origFd.EnumType[i] + r.storeOptionBytesInEnum(ed, origEd) + } + + for i, exd := range fd.Extension { + origExd := origFd.Extension[i] + r.storeOptionBytesInField(exd, origExd) + } + + for i, sd := range fd.Service { + origSd := origFd.Service[i] + if sd.Options != nil { + sd.Options.Reset() + sd.Options.ProtoReflect().SetUnknown(r.optionBytes[origSd.Options]) + } + + for j, mtd := range sd.Method { + origMtd := origSd.Method[j] + if mtd.Options != nil { + mtd.Options.Reset() + mtd.Options.ProtoReflect().SetUnknown(r.optionBytes[origMtd.Options]) + } + } + } +} + +func (r *result) storeOptionBytesInMessage(md, origMd *descriptorpb.DescriptorProto) { + if md.GetOptions().GetMapEntry() { + // Map entry messages are synthesized. They won't have any option bytes + // since they don't actually appear in the source and thus have any option + // declarations in the source. + return + } + + if md.Options != nil { + md.Options.Reset() + md.Options.ProtoReflect().SetUnknown(r.optionBytes[origMd.Options]) + } + + for i, fld := range md.Field { + origFld := origMd.Field[i] + r.storeOptionBytesInField(fld, origFld) + } + + for i, ood := range md.OneofDecl { + origOod := origMd.OneofDecl[i] + if ood.Options != nil { + ood.Options.Reset() + ood.Options.ProtoReflect().SetUnknown(r.optionBytes[origOod.Options]) + } + } + + for i, exr := range md.ExtensionRange { + origExr := origMd.ExtensionRange[i] + if exr.Options != nil { + exr.Options.Reset() + exr.Options.ProtoReflect().SetUnknown(r.optionBytes[origExr.Options]) + } + } + + for i, nmd := range md.NestedType { + origNmd := origMd.NestedType[i] + r.storeOptionBytesInMessage(nmd, origNmd) + } + + for i, ed := range md.EnumType { + origEd := origMd.EnumType[i] + r.storeOptionBytesInEnum(ed, origEd) + } + + for i, exd := range md.Extension { + origExd := origMd.Extension[i] + r.storeOptionBytesInField(exd, origExd) + } +} + +func (r *result) storeOptionBytesInEnum(ed, origEd *descriptorpb.EnumDescriptorProto) { + if ed.Options != nil { + ed.Options.Reset() + ed.Options.ProtoReflect().SetUnknown(r.optionBytes[origEd.Options]) + } + + for i, evd := range ed.Value { + origEvd := origEd.Value[i] + if evd.Options != nil { + evd.Options.Reset() + evd.Options.ProtoReflect().SetUnknown(r.optionBytes[origEvd.Options]) + } + } +} + +func (r *result) storeOptionBytesInField(fld, origFld *descriptorpb.FieldDescriptorProto) { + if fld.Options != nil { + fld.Options.Reset() + fld.Options.ProtoReflect().SetUnknown(r.optionBytes[origFld.Options]) + } +} + +type fileImports struct { + protoreflect.FileImports + files []protoreflect.FileImport +} + +func (r *result) createImports() fileImports { + fd := r.FileDescriptorProto() + imps := make([]protoreflect.FileImport, len(fd.Dependency)) + for i, dep := range fd.Dependency { + desc := r.deps.FindFileByPath(dep) + imps[i] = protoreflect.FileImport{FileDescriptor: desc} + } + for _, publicIndex := range fd.PublicDependency { + imps[int(publicIndex)].IsPublic = true + } + for _, weakIndex := range fd.WeakDependency { + imps[int(weakIndex)].IsWeak = true + } + return fileImports{files: imps} +} + +func (f *fileImports) Len() int { + return len(f.files) +} + +func (f *fileImports) Get(i int) protoreflect.FileImport { + return f.files[i] +} + +type srcLocs struct { + protoreflect.SourceLocations + file *result + locs []protoreflect.SourceLocation + index map[interface{}]int +} + +func (s *srcLocs) Len() int { + return len(s.locs) +} + +func (s *srcLocs) Get(i int) protoreflect.SourceLocation { + return s.locs[i] +} + +func (s *srcLocs) ByPath(p protoreflect.SourcePath) protoreflect.SourceLocation { + index, ok := s.index[pathKey(p)] + if !ok { + return protoreflect.SourceLocation{} + } + return s.locs[index] +} + +func (s *srcLocs) ByDescriptor(d protoreflect.Descriptor) protoreflect.SourceLocation { + if d.ParentFile() != s.file { + return protoreflect.SourceLocation{} + } + path, ok := computePath(d) + if !ok { + return protoreflect.SourceLocation{} + } + return s.ByPath(path) +} + +func computePath(d protoreflect.Descriptor) (protoreflect.SourcePath, bool) { + _, ok := d.(protoreflect.FileDescriptor) + if ok { + return nil, true + } + var path protoreflect.SourcePath + for { + p := d.Parent() + switch d := d.(type) { + case protoreflect.FileDescriptor: + return reverse(path), true + case protoreflect.MessageDescriptor: + path = append(path, int32(d.Index())) + switch p.(type) { + case protoreflect.FileDescriptor: + path = append(path, internal.FileMessagesTag) + case protoreflect.MessageDescriptor: + path = append(path, internal.MessageNestedMessagesTag) + default: + return nil, false + } + case protoreflect.FieldDescriptor: + path = append(path, int32(d.Index())) + switch p.(type) { + case protoreflect.FileDescriptor: + if d.IsExtension() { + path = append(path, internal.FileExtensionsTag) + } else { + return nil, false + } + case protoreflect.MessageDescriptor: + if d.IsExtension() { + path = append(path, internal.MessageExtensionsTag) + } else { + path = append(path, internal.MessageFieldsTag) + } + default: + return nil, false + } + case protoreflect.OneofDescriptor: + path = append(path, int32(d.Index())) + if _, ok := p.(protoreflect.MessageDescriptor); ok { + path = append(path, internal.MessageOneOfsTag) + } else { + return nil, false + } + case protoreflect.EnumDescriptor: + path = append(path, int32(d.Index())) + switch p.(type) { + case protoreflect.FileDescriptor: + path = append(path, internal.FileEnumsTag) + case protoreflect.MessageDescriptor: + path = append(path, internal.MessageEnumsTag) + default: + return nil, false + } + case protoreflect.EnumValueDescriptor: + path = append(path, int32(d.Index())) + if _, ok := p.(protoreflect.EnumDescriptor); ok { + path = append(path, internal.EnumValuesTag) + } else { + return nil, false + } + case protoreflect.ServiceDescriptor: + path = append(path, int32(d.Index())) + if _, ok := p.(protoreflect.FileDescriptor); ok { + path = append(path, internal.FileServicesTag) + } else { + return nil, false + } + case protoreflect.MethodDescriptor: + path = append(path, int32(d.Index())) + if _, ok := p.(protoreflect.ServiceDescriptor); ok { + path = append(path, internal.ServiceMethodsTag) + } else { + return nil, false + } + } + d = p + } +} + +func reverse(p protoreflect.SourcePath) protoreflect.SourcePath { + for i, j := 0, len(p)-1; i < j; i, j = i+1, j-1 { + p[i], p[j] = p[j], p[i] + } + return p +} + +type msgDescriptors struct { + protoreflect.MessageDescriptors + msgs []*msgDescriptor +} + +func (r *result) createMessages(prefix string, parent protoreflect.Descriptor, msgProtos []*descriptorpb.DescriptorProto) msgDescriptors { + msgs := make([]*msgDescriptor, len(msgProtos)) + for i, msgProto := range msgProtos { + msgs[i] = r.createMessageDescriptor(msgProto, parent, i, prefix+msgProto.GetName()) + } + return msgDescriptors{msgs: msgs} +} + +func (m *msgDescriptors) Len() int { + return len(m.msgs) +} + +func (m *msgDescriptors) Get(i int) protoreflect.MessageDescriptor { + return m.msgs[i] +} + +func (m *msgDescriptors) ByName(s protoreflect.Name) protoreflect.MessageDescriptor { + for _, msg := range m.msgs { + if msg.Name() == s { + return msg + } + } + return nil +} + +type msgDescriptor struct { + protoreflect.MessageDescriptor + file *result + parent protoreflect.Descriptor + index int + proto *descriptorpb.DescriptorProto + fqn string + + fields fldDescriptors + oneofs oneofDescriptors + nestedMessages msgDescriptors + nestedEnums enumDescriptors + nestedExtensions extDescriptors + + extRanges fieldRanges + rsvdRanges fieldRanges + rsvdNames names +} + +var _ protoreflect.MessageDescriptor = (*msgDescriptor)(nil) +var _ protoutil.DescriptorProtoWrapper = (*msgDescriptor)(nil) + +func (r *result) createMessageDescriptor(md *descriptorpb.DescriptorProto, parent protoreflect.Descriptor, index int, fqn string) *msgDescriptor { + ret := &msgDescriptor{file: r, parent: parent, index: index, proto: md, fqn: fqn} + r.descriptors[fqn] = ret + + prefix := fqn + "." + // NB: We MUST create fields before oneofs so that we can populate the + // set of fields that belong to the oneof + ret.fields = r.createFields(prefix, ret, md.Field) + ret.oneofs = r.createOneOfs(prefix, ret, md.OneofDecl) + ret.nestedMessages = r.createMessages(prefix, ret, md.NestedType) + ret.nestedEnums = r.createEnums(prefix, ret, md.EnumType) + ret.nestedExtensions = r.createExtensions(prefix, ret, md.Extension) + ret.extRanges = createFieldRanges(md.ExtensionRange) + ret.rsvdRanges = createFieldRanges(md.ReservedRange) + ret.rsvdNames = names{s: md.ReservedName} + + return ret +} + +func (m *msgDescriptor) MessageDescriptorProto() *descriptorpb.DescriptorProto { + return m.proto +} + +func (m *msgDescriptor) AsProto() proto.Message { + return m.proto +} + +func (m *msgDescriptor) ParentFile() protoreflect.FileDescriptor { + return m.file +} + +func (m *msgDescriptor) Parent() protoreflect.Descriptor { + return m.parent +} + +func (m *msgDescriptor) Index() int { + return m.index +} + +func (m *msgDescriptor) Syntax() protoreflect.Syntax { + return m.file.Syntax() +} + +func (m *msgDescriptor) Name() protoreflect.Name { + return protoreflect.Name(m.proto.GetName()) +} + +func (m *msgDescriptor) FullName() protoreflect.FullName { + return protoreflect.FullName(m.fqn) +} + +func (m *msgDescriptor) IsPlaceholder() bool { + return false +} + +func (m *msgDescriptor) Options() protoreflect.ProtoMessage { + return m.proto.Options +} + +func (m *msgDescriptor) IsMapEntry() bool { + return m.proto.Options.GetMapEntry() +} + +func (m *msgDescriptor) Fields() protoreflect.FieldDescriptors { + return &m.fields +} + +func (m *msgDescriptor) Oneofs() protoreflect.OneofDescriptors { + return &m.oneofs +} + +func (m *msgDescriptor) ReservedNames() protoreflect.Names { + return m.rsvdNames +} + +func (m *msgDescriptor) ReservedRanges() protoreflect.FieldRanges { + return m.rsvdRanges +} + +func (m *msgDescriptor) RequiredNumbers() protoreflect.FieldNumbers { + var indexes fieldNums + for _, fld := range m.proto.Field { + if fld.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REQUIRED { + indexes.s = append(indexes.s, fld.GetNumber()) + } + } + return indexes +} + +func (m *msgDescriptor) ExtensionRanges() protoreflect.FieldRanges { + return m.extRanges +} + +func (m *msgDescriptor) ExtensionRangeOptions(i int) protoreflect.ProtoMessage { + return m.proto.ExtensionRange[i].Options +} + +func (m *msgDescriptor) Enums() protoreflect.EnumDescriptors { + return &m.nestedEnums +} + +func (m *msgDescriptor) Messages() protoreflect.MessageDescriptors { + return &m.nestedMessages +} + +func (m *msgDescriptor) Extensions() protoreflect.ExtensionDescriptors { + return &m.nestedExtensions +} + +type names struct { + protoreflect.Names + s []string +} + +func (n names) Len() int { + return len(n.s) +} + +func (n names) Get(i int) protoreflect.Name { + return protoreflect.Name(n.s[i]) +} + +func (n names) Has(s protoreflect.Name) bool { + for _, name := range n.s { + if name == string(s) { + return true + } + } + return false +} + +type fieldNums struct { + protoreflect.FieldNumbers + s []int32 +} + +func (n fieldNums) Len() int { + return len(n.s) +} + +func (n fieldNums) Get(i int) protoreflect.FieldNumber { + return protoreflect.FieldNumber(n.s[i]) +} + +func (n fieldNums) Has(s protoreflect.FieldNumber) bool { + for _, num := range n.s { + if num == int32(s) { + return true + } + } + return false +} + +type fieldRanges struct { + protoreflect.FieldRanges + ranges [][2]protoreflect.FieldNumber +} + +type fieldRange interface { + GetStart() int32 + GetEnd() int32 +} + +func createFieldRanges[T fieldRange](rangeProtos []T) fieldRanges { + ranges := make([][2]protoreflect.FieldNumber, len(rangeProtos)) + for i, r := range rangeProtos { + ranges[i] = [2]protoreflect.FieldNumber{ + protoreflect.FieldNumber(r.GetStart()), + protoreflect.FieldNumber(r.GetEnd()), + } + } + return fieldRanges{ranges: ranges} +} + +func (f fieldRanges) Len() int { + return len(f.ranges) +} + +func (f fieldRanges) Get(i int) [2]protoreflect.FieldNumber { + return f.ranges[i] +} + +func (f fieldRanges) Has(n protoreflect.FieldNumber) bool { + for _, r := range f.ranges { + if r[0] <= n && r[1] > n { + return true + } + } + return false +} + +type enumDescriptors struct { + protoreflect.EnumDescriptors + enums []*enumDescriptor +} + +func (r *result) createEnums(prefix string, parent protoreflect.Descriptor, enumProtos []*descriptorpb.EnumDescriptorProto) enumDescriptors { + enums := make([]*enumDescriptor, len(enumProtos)) + for i, enumProto := range enumProtos { + enums[i] = r.createEnumDescriptor(enumProto, parent, i, prefix+enumProto.GetName()) + } + return enumDescriptors{enums: enums} +} + +func (e *enumDescriptors) Len() int { + return len(e.enums) +} + +func (e *enumDescriptors) Get(i int) protoreflect.EnumDescriptor { + return e.enums[i] +} + +func (e *enumDescriptors) ByName(s protoreflect.Name) protoreflect.EnumDescriptor { + for _, en := range e.enums { + if en.Name() == s { + return en + } + } + return nil +} + +type enumDescriptor struct { + protoreflect.EnumDescriptor + file *result + parent protoreflect.Descriptor + index int + proto *descriptorpb.EnumDescriptorProto + fqn string + + values enValDescriptors + + rsvdRanges enumRanges + rsvdNames names +} + +var _ protoreflect.EnumDescriptor = (*enumDescriptor)(nil) +var _ protoutil.DescriptorProtoWrapper = (*enumDescriptor)(nil) + +func (r *result) createEnumDescriptor(ed *descriptorpb.EnumDescriptorProto, parent protoreflect.Descriptor, index int, fqn string) *enumDescriptor { + ret := &enumDescriptor{file: r, parent: parent, index: index, proto: ed, fqn: fqn} + r.descriptors[fqn] = ret + + // Unlike all other elements, the fully-qualified name of enum values + // is NOT scoped to their parent element (the enum), but rather to + // the enum's parent element. This follows C++ scoping rules for + // enum values. + prefix := strings.TrimSuffix(fqn, ed.GetName()) + ret.values = r.createEnumValues(prefix, ret, ed.Value) + ret.rsvdRanges = createEnumRanges(ed.ReservedRange) + ret.rsvdNames = names{s: ed.ReservedName} + return ret +} + +func (e *enumDescriptor) EnumDescriptorProto() *descriptorpb.EnumDescriptorProto { + return e.proto +} + +func (e *enumDescriptor) AsProto() proto.Message { + return e.proto +} + +func (e *enumDescriptor) ParentFile() protoreflect.FileDescriptor { + return e.file +} + +func (e *enumDescriptor) Parent() protoreflect.Descriptor { + return e.parent +} + +func (e *enumDescriptor) Index() int { + return e.index +} + +func (e *enumDescriptor) Syntax() protoreflect.Syntax { + return e.file.Syntax() +} + +func (e *enumDescriptor) Name() protoreflect.Name { + return protoreflect.Name(e.proto.GetName()) +} + +func (e *enumDescriptor) FullName() protoreflect.FullName { + return protoreflect.FullName(e.fqn) +} + +func (e *enumDescriptor) IsPlaceholder() bool { + return false +} + +func (e *enumDescriptor) Options() protoreflect.ProtoMessage { + return e.proto.Options +} + +func (e *enumDescriptor) Values() protoreflect.EnumValueDescriptors { + return &e.values +} + +func (e *enumDescriptor) ReservedNames() protoreflect.Names { + return e.rsvdNames +} + +func (e *enumDescriptor) ReservedRanges() protoreflect.EnumRanges { + return e.rsvdRanges +} + +type enumRanges struct { + protoreflect.EnumRanges + ranges [][2]protoreflect.EnumNumber +} + +func createEnumRanges(rangeProtos []*descriptorpb.EnumDescriptorProto_EnumReservedRange) enumRanges { + ranges := make([][2]protoreflect.EnumNumber, len(rangeProtos)) + for i, r := range rangeProtos { + ranges[i] = [2]protoreflect.EnumNumber{ + protoreflect.EnumNumber(r.GetStart()), + protoreflect.EnumNumber(r.GetEnd()), + } + } + return enumRanges{ranges: ranges} +} + +func (e enumRanges) Len() int { + return len(e.ranges) +} + +func (e enumRanges) Get(i int) [2]protoreflect.EnumNumber { + return e.ranges[i] +} + +func (e enumRanges) Has(n protoreflect.EnumNumber) bool { + for _, r := range e.ranges { + if r[0] <= n && r[1] >= n { + return true + } + } + return false +} + +type enValDescriptors struct { + protoreflect.EnumValueDescriptors + vals []*enValDescriptor +} + +func (r *result) createEnumValues(prefix string, parent *enumDescriptor, enValProtos []*descriptorpb.EnumValueDescriptorProto) enValDescriptors { + vals := make([]*enValDescriptor, len(enValProtos)) + for i, enValProto := range enValProtos { + vals[i] = r.createEnumValueDescriptor(enValProto, parent, i, prefix+enValProto.GetName()) + } + return enValDescriptors{vals: vals} +} + +func (e *enValDescriptors) Len() int { + return len(e.vals) +} + +func (e *enValDescriptors) Get(i int) protoreflect.EnumValueDescriptor { + return e.vals[i] +} + +func (e *enValDescriptors) ByName(s protoreflect.Name) protoreflect.EnumValueDescriptor { + for _, val := range e.vals { + if val.Name() == s { + return val + } + } + return nil +} + +func (e *enValDescriptors) ByNumber(n protoreflect.EnumNumber) protoreflect.EnumValueDescriptor { + for _, val := range e.vals { + if val.Number() == n { + return val + } + } + return nil +} + +type enValDescriptor struct { + protoreflect.EnumValueDescriptor + file *result + parent *enumDescriptor + index int + proto *descriptorpb.EnumValueDescriptorProto + fqn string +} + +var _ protoreflect.EnumValueDescriptor = (*enValDescriptor)(nil) +var _ protoutil.DescriptorProtoWrapper = (*enValDescriptor)(nil) + +func (r *result) createEnumValueDescriptor(ed *descriptorpb.EnumValueDescriptorProto, parent *enumDescriptor, index int, fqn string) *enValDescriptor { + ret := &enValDescriptor{file: r, parent: parent, index: index, proto: ed, fqn: fqn} + r.descriptors[fqn] = ret + return ret +} + +func (e *enValDescriptor) EnumValueDescriptorProto() *descriptorpb.EnumValueDescriptorProto { + return e.proto +} + +func (e *enValDescriptor) AsProto() proto.Message { + return e.proto +} + +func (e *enValDescriptor) ParentFile() protoreflect.FileDescriptor { + return e.file +} + +func (e *enValDescriptor) Parent() protoreflect.Descriptor { + return e.parent +} + +func (e *enValDescriptor) Index() int { + return e.index +} + +func (e *enValDescriptor) Syntax() protoreflect.Syntax { + return e.file.Syntax() +} + +func (e *enValDescriptor) Name() protoreflect.Name { + return protoreflect.Name(e.proto.GetName()) +} + +func (e *enValDescriptor) FullName() protoreflect.FullName { + return protoreflect.FullName(e.fqn) +} + +func (e *enValDescriptor) IsPlaceholder() bool { + return false +} + +func (e *enValDescriptor) Options() protoreflect.ProtoMessage { + return e.proto.Options +} + +func (e *enValDescriptor) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(e.proto.GetNumber()) +} + +type extDescriptors struct { + protoreflect.ExtensionDescriptors + exts []*extTypeDescriptor +} + +func (r *result) createExtensions(prefix string, parent protoreflect.Descriptor, extProtos []*descriptorpb.FieldDescriptorProto) extDescriptors { + exts := make([]*extTypeDescriptor, len(extProtos)) + for i, extProto := range extProtos { + exts[i] = r.createExtTypeDescriptor(extProto, parent, i, prefix+extProto.GetName()) + } + return extDescriptors{exts: exts} +} + +func (e *extDescriptors) Len() int { + return len(e.exts) +} + +func (e *extDescriptors) Get(i int) protoreflect.ExtensionDescriptor { + return e.exts[i] +} + +func (e *extDescriptors) ByName(s protoreflect.Name) protoreflect.ExtensionDescriptor { + for _, ext := range e.exts { + if ext.Name() == s { + return ext + } + } + return nil +} + +type extTypeDescriptor struct { + protoreflect.ExtensionTypeDescriptor + field *fldDescriptor +} + +var _ protoutil.DescriptorProtoWrapper = &extTypeDescriptor{} + +func (r *result) createExtTypeDescriptor(fd *descriptorpb.FieldDescriptorProto, parent protoreflect.Descriptor, index int, fqn string) *extTypeDescriptor { + ret := &fldDescriptor{file: r, parent: parent, index: index, proto: fd, fqn: fqn} + r.descriptors[fqn] = ret + return &extTypeDescriptor{ExtensionTypeDescriptor: dynamicpb.NewExtensionType(ret).TypeDescriptor(), field: ret} +} + +func (e *extTypeDescriptor) FieldDescriptorProto() *descriptorpb.FieldDescriptorProto { + return e.field.proto +} + +func (e *extTypeDescriptor) AsProto() proto.Message { + return e.field.proto +} + +type fldDescriptors struct { + protoreflect.FieldDescriptors + fields []*fldDescriptor +} + +func (r *result) createFields(prefix string, parent *msgDescriptor, fldProtos []*descriptorpb.FieldDescriptorProto) fldDescriptors { + fields := make([]*fldDescriptor, len(fldProtos)) + for i, fldProto := range fldProtos { + fields[i] = r.createFieldDescriptor(fldProto, parent, i, prefix+fldProto.GetName()) + } + return fldDescriptors{fields: fields} +} + +func (f *fldDescriptors) Len() int { + return len(f.fields) +} + +func (f *fldDescriptors) Get(i int) protoreflect.FieldDescriptor { + return f.fields[i] +} + +func (f *fldDescriptors) ByName(s protoreflect.Name) protoreflect.FieldDescriptor { + for _, fld := range f.fields { + if fld.Name() == s { + return fld + } + } + return nil +} + +func (f *fldDescriptors) ByJSONName(s string) protoreflect.FieldDescriptor { + for _, fld := range f.fields { + if fld.JSONName() == s { + return fld + } + } + return nil +} + +func (f *fldDescriptors) ByTextName(s string) protoreflect.FieldDescriptor { + return f.ByName(protoreflect.Name(s)) +} + +func (f *fldDescriptors) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor { + for _, fld := range f.fields { + if fld.Number() == n { + return fld + } + } + return nil +} + +type fldDescriptor struct { + protoreflect.FieldDescriptor + file *result + parent protoreflect.Descriptor + index int + proto *descriptorpb.FieldDescriptorProto + fqn string + + msgType protoreflect.MessageDescriptor + extendee protoreflect.MessageDescriptor + enumType protoreflect.EnumDescriptor + oneof protoreflect.OneofDescriptor +} + +var _ protoreflect.FieldDescriptor = (*fldDescriptor)(nil) +var _ protoutil.DescriptorProtoWrapper = (*fldDescriptor)(nil) + +func (r *result) createFieldDescriptor(fd *descriptorpb.FieldDescriptorProto, parent *msgDescriptor, index int, fqn string) *fldDescriptor { + ret := &fldDescriptor{file: r, parent: parent, index: index, proto: fd, fqn: fqn} + r.descriptors[fqn] = ret + return ret +} + +func (f *fldDescriptor) FieldDescriptorProto() *descriptorpb.FieldDescriptorProto { + return f.proto +} + +func (f *fldDescriptor) AsProto() proto.Message { + return f.proto +} + +func (f *fldDescriptor) ParentFile() protoreflect.FileDescriptor { + return f.file +} + +func (f *fldDescriptor) Parent() protoreflect.Descriptor { + return f.parent +} + +func (f *fldDescriptor) Index() int { + return f.index +} + +func (f *fldDescriptor) Syntax() protoreflect.Syntax { + return f.file.Syntax() +} + +func (f *fldDescriptor) Name() protoreflect.Name { + return protoreflect.Name(f.proto.GetName()) +} + +func (f *fldDescriptor) FullName() protoreflect.FullName { + return protoreflect.FullName(f.fqn) +} + +func (f *fldDescriptor) IsPlaceholder() bool { + return false +} + +func (f *fldDescriptor) Options() protoreflect.ProtoMessage { + return f.proto.Options +} + +func (f *fldDescriptor) Number() protoreflect.FieldNumber { + return protoreflect.FieldNumber(f.proto.GetNumber()) +} + +func (f *fldDescriptor) Cardinality() protoreflect.Cardinality { + switch f.proto.GetLabel() { + case descriptorpb.FieldDescriptorProto_LABEL_REPEATED: + return protoreflect.Repeated + case descriptorpb.FieldDescriptorProto_LABEL_REQUIRED: + return protoreflect.Required + case descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL: + return protoreflect.Optional + default: + return 0 + } +} + +func (f *fldDescriptor) Kind() protoreflect.Kind { + return protoreflect.Kind(f.proto.GetType()) +} + +func (f *fldDescriptor) HasJSONName() bool { + return f.proto.JsonName != nil +} + +func (f *fldDescriptor) JSONName() string { + if f.IsExtension() { + return f.TextName() + } + return f.proto.GetJsonName() +} + +func (f *fldDescriptor) TextName() string { + if f.IsExtension() { + return fmt.Sprintf("[%s]", f.FullName()) + } + return string(f.Name()) +} + +func (f *fldDescriptor) HasPresence() bool { + if f.proto.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED { + return false + } + return f.IsExtension() || + f.Syntax() == protoreflect.Proto2 || + f.Kind() == protoreflect.MessageKind || f.Kind() == protoreflect.GroupKind || + f.proto.OneofIndex != nil +} + +func (f *fldDescriptor) IsExtension() bool { + return f.proto.GetExtendee() != "" +} + +func (f *fldDescriptor) HasOptionalKeyword() bool { + if f.proto.GetLabel() != descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL { + return false + } + if f.proto.GetProto3Optional() { + // NB: This smells weird to return false here. If the proto3_optional field + // is set, it's because the keyword WAS present. However, the Go runtime + // returns false for this case, so we mirror that behavior. + return !f.IsExtension() + } + // If it's optional, but not a proto3 optional, then the keyword is only + // present for proto2 files, for fields that are not part of a oneof. + return f.file.Syntax() == protoreflect.Proto2 && f.proto.OneofIndex == nil +} + +func (f *fldDescriptor) IsWeak() bool { + return f.proto.Options.GetWeak() +} + +func (f *fldDescriptor) IsPacked() bool { + opts := f.proto.GetOptions() + if opts.GetPacked() { + return true + } + if opts != nil && opts.Packed != nil { + // explicitly not packed + return false + } + + // proto3 defaults to packed for repeated scalar numeric fields + if f.file.Syntax() != protoreflect.Proto3 { + return false + } + if f.proto.GetLabel() != descriptorpb.FieldDescriptorProto_LABEL_REPEATED { + return false + } + switch f.proto.GetType() { + case descriptorpb.FieldDescriptorProto_TYPE_GROUP, descriptorpb.FieldDescriptorProto_TYPE_MESSAGE, + descriptorpb.FieldDescriptorProto_TYPE_BYTES, descriptorpb.FieldDescriptorProto_TYPE_STRING: + return false + default: + // all others can be packed + return true + } +} + +func (f *fldDescriptor) IsList() bool { + if f.proto.GetLabel() != descriptorpb.FieldDescriptorProto_LABEL_REPEATED { + return false + } + return !f.isMapEntry() +} + +func (f *fldDescriptor) IsMap() bool { + if f.proto.GetLabel() != descriptorpb.FieldDescriptorProto_LABEL_REPEATED { + return false + } + if f.IsExtension() { + return false + } + return f.isMapEntry() +} + +func (f *fldDescriptor) isMapEntry() bool { + if f.proto.GetType() != descriptorpb.FieldDescriptorProto_TYPE_MESSAGE { + return false + } + return f.Message().IsMapEntry() +} + +func (f *fldDescriptor) MapKey() protoreflect.FieldDescriptor { + if !f.IsMap() { + return nil + } + return f.Message().Fields().ByNumber(1) +} + +func (f *fldDescriptor) MapValue() protoreflect.FieldDescriptor { + if !f.IsMap() { + return nil + } + return f.Message().Fields().ByNumber(2) +} + +func (f *fldDescriptor) HasDefault() bool { + return f.proto.DefaultValue != nil +} + +func (f *fldDescriptor) Default() protoreflect.Value { + // We only return a valid value for scalar fields + if f.proto.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED || + f.Kind() == protoreflect.GroupKind || f.Kind() == protoreflect.MessageKind { + return protoreflect.Value{} + } + + if f.proto.DefaultValue != nil { + defVal := f.parseDefaultValue(f.proto.GetDefaultValue()) + if defVal.IsValid() { + return defVal + } + // if we cannot parse a valid value, fall back to zero value below + } + + // No custom default value, so return the zero value for the type + switch f.Kind() { + case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: + return protoreflect.ValueOfInt32(0) + case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: + return protoreflect.ValueOfInt64(0) + case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: + return protoreflect.ValueOfUint32(0) + case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: + return protoreflect.ValueOfUint64(0) + case protoreflect.FloatKind: + return protoreflect.ValueOfFloat32(0) + case protoreflect.DoubleKind: + return protoreflect.ValueOfFloat64(0) + case protoreflect.BoolKind: + return protoreflect.ValueOfBool(false) + case protoreflect.BytesKind: + return protoreflect.ValueOfBytes(nil) + case protoreflect.StringKind: + return protoreflect.ValueOfString("") + case protoreflect.EnumKind: + return protoreflect.ValueOfEnum(f.Enum().Values().Get(0).Number()) + case protoreflect.GroupKind, protoreflect.MessageKind: + return protoreflect.ValueOfMessage(dynamicpb.NewMessage(f.Message())) + default: + panic(fmt.Sprintf("unknown kind: %v", f.Kind())) + } +} + +func (f *fldDescriptor) parseDefaultValue(val string) protoreflect.Value { + switch f.Kind() { + case protoreflect.EnumKind: + vd := f.Enum().Values().ByName(protoreflect.Name(val)) + if vd != nil { + return protoreflect.ValueOfEnum(vd.Number()) + } + return protoreflect.Value{} + case protoreflect.BoolKind: + switch val { + case "true": + return protoreflect.ValueOfBool(true) + case "false": + return protoreflect.ValueOfBool(false) + default: + return protoreflect.Value{} + } + case protoreflect.BytesKind: + return protoreflect.ValueOfBytes([]byte(unescape(val))) + case protoreflect.StringKind: + return protoreflect.ValueOfString(val) + case protoreflect.FloatKind: + if f, err := strconv.ParseFloat(val, 32); err == nil { + return protoreflect.ValueOfFloat32(float32(f)) + } + return protoreflect.Value{} + case protoreflect.DoubleKind: + if f, err := strconv.ParseFloat(val, 64); err == nil { + return protoreflect.ValueOfFloat64(f) + } + return protoreflect.Value{} + case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: + if i, err := strconv.ParseInt(val, 10, 32); err == nil { + return protoreflect.ValueOfInt32(int32(i)) + } + return protoreflect.Value{} + case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: + if i, err := strconv.ParseUint(val, 10, 32); err == nil { + return protoreflect.ValueOfUint32(uint32(i)) + } + return protoreflect.Value{} + case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: + if i, err := strconv.ParseInt(val, 10, 64); err == nil { + return protoreflect.ValueOfInt64(i) + } + return protoreflect.Value{} + case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: + if i, err := strconv.ParseUint(val, 10, 64); err == nil { + return protoreflect.ValueOfUint64(i) + } + return protoreflect.Value{} + default: + return protoreflect.Value{} + } +} + +func unescape(s string) string { + // protoc encodes default values for 'bytes' fields using C escaping, + // so this function reverses that escaping + out := make([]byte, 0, len(s)) + var buf [4]byte + for len(s) > 0 { + if s[0] != '\\' || len(s) < 2 { + // not escape sequence, or too short to be well-formed escape + out = append(out, s[0]) + s = s[1:] + continue + } + nextIndex := 2 // by default, skip '\' + escaped character + switch s[1] { + case 'x', 'X': + n := matchPrefix(s[2:], 2, isHex) + if n == 0 { + // bad escape + out = append(out, s[:2]...) + } else { + c, err := strconv.ParseUint(s[2:2+n], 16, 8) + if err != nil { + // shouldn't really happen... + out = append(out, s[:2+n]...) + } else { + out = append(out, byte(c)) + } + nextIndex = 2 + n + } + case '0', '1', '2', '3', '4', '5', '6', '7': + n := 1 + matchPrefix(s[2:], 2, isOctal) + c, err := strconv.ParseUint(s[1:1+n], 8, 8) + if err != nil || c > 0xff { + out = append(out, s[:1+n]...) + } else { + out = append(out, byte(c)) + } + nextIndex = 1 + n + case 'u': + if len(s) < 6 { + // bad escape + out = append(out, s...) + nextIndex = len(s) + } else { + c, err := strconv.ParseUint(s[2:6], 16, 16) + if err != nil { + // bad escape + out = append(out, s[:6]...) + } else { + w := utf8.EncodeRune(buf[:], rune(c)) + out = append(out, buf[:w]...) + } + nextIndex = 6 + } + case 'U': + if len(s) < 10 { + // bad escape + out = append(out, s...) + nextIndex = len(s) + } else { + c, err := strconv.ParseUint(s[2:10], 16, 32) + if err != nil || c > 0x10ffff { + // bad escape + out = append(out, s[:10]...) + } else { + w := utf8.EncodeRune(buf[:], rune(c)) + out = append(out, buf[:w]...) + } + nextIndex = 10 + } + case 'a': + out = append(out, '\a') + case 'b': + out = append(out, '\b') + case 'f': + out = append(out, '\f') + case 'n': + out = append(out, '\n') + case 'r': + out = append(out, '\r') + case 't': + out = append(out, '\t') + case 'v': + out = append(out, '\v') + case '\\', '\'', '"', '?': + out = append(out, s[1]) + default: + // invalid escape, just copy it as-is + out = append(out, s[:2]...) + } + s = s[nextIndex:] + } + return string(out) +} + +func isOctal(b byte) bool { return b >= '0' && b <= '7' } +func isHex(b byte) bool { + return (b >= '0' && b <= '9') || (b >= 'a' && b <= 'f') || (b >= 'A' && b <= 'F') +} +func matchPrefix(s string, limit int, fn func(byte) bool) int { + l := len(s) + if l > limit { + l = limit + } + i := 0 + for ; i < l; i++ { + if !fn(s[i]) { + return i + } + } + return i +} + +func (f *fldDescriptor) DefaultEnumValue() protoreflect.EnumValueDescriptor { + ed := f.Enum() + if ed == nil { + return nil + } + if f.proto.DefaultValue != nil { + if val := ed.Values().ByName(protoreflect.Name(f.proto.GetDefaultValue())); val != nil { + return val + } + } + // if no default specified in source, return nil + return nil +} + +func (f *fldDescriptor) ContainingOneof() protoreflect.OneofDescriptor { + return f.oneof +} + +func (f *fldDescriptor) ContainingMessage() protoreflect.MessageDescriptor { + if f.extendee != nil { + return f.extendee + } + return f.parent.(protoreflect.MessageDescriptor) +} + +func (f *fldDescriptor) Enum() protoreflect.EnumDescriptor { + return f.enumType +} + +func (f *fldDescriptor) Message() protoreflect.MessageDescriptor { + return f.msgType +} + +type oneofDescriptors struct { + protoreflect.OneofDescriptors + oneofs []*oneofDescriptor +} + +func (r *result) createOneOfs(prefix string, parent *msgDescriptor, ooProtos []*descriptorpb.OneofDescriptorProto) oneofDescriptors { + oos := make([]*oneofDescriptor, len(ooProtos)) + for i, fldProto := range ooProtos { + oos[i] = r.createOneOfDescriptor(fldProto, parent, i, prefix+fldProto.GetName()) + } + return oneofDescriptors{oneofs: oos} +} + +func (o *oneofDescriptors) Len() int { + return len(o.oneofs) +} + +func (o *oneofDescriptors) Get(i int) protoreflect.OneofDescriptor { + return o.oneofs[i] +} + +func (o *oneofDescriptors) ByName(s protoreflect.Name) protoreflect.OneofDescriptor { + for _, oo := range o.oneofs { + if oo.Name() == s { + return oo + } + } + return nil +} + +type oneofDescriptor struct { + protoreflect.OneofDescriptor + file *result + parent *msgDescriptor + index int + proto *descriptorpb.OneofDescriptorProto + fqn string + + fields fldDescriptors +} + +var _ protoreflect.OneofDescriptor = (*oneofDescriptor)(nil) +var _ protoutil.DescriptorProtoWrapper = (*oneofDescriptor)(nil) + +func (r *result) createOneOfDescriptor(ood *descriptorpb.OneofDescriptorProto, parent *msgDescriptor, index int, fqn string) *oneofDescriptor { + ret := &oneofDescriptor{file: r, parent: parent, index: index, proto: ood, fqn: fqn} + r.descriptors[fqn] = ret + + var fields []*fldDescriptor + for _, fld := range parent.fields.fields { + if fld.proto.OneofIndex != nil && int(fld.proto.GetOneofIndex()) == index { + fields = append(fields, fld) + } + } + ret.fields = fldDescriptors{fields: fields} + + return ret +} + +func (o *oneofDescriptor) OneOfDescriptorProto() *descriptorpb.OneofDescriptorProto { + return o.proto +} + +func (o *oneofDescriptor) AsProto() proto.Message { + return o.proto +} + +func (o *oneofDescriptor) ParentFile() protoreflect.FileDescriptor { + return o.file +} + +func (o *oneofDescriptor) Parent() protoreflect.Descriptor { + return o.parent +} + +func (o *oneofDescriptor) Index() int { + return o.index +} + +func (o *oneofDescriptor) Syntax() protoreflect.Syntax { + return o.file.Syntax() +} + +func (o *oneofDescriptor) Name() protoreflect.Name { + return protoreflect.Name(o.proto.GetName()) +} + +func (o *oneofDescriptor) FullName() protoreflect.FullName { + return protoreflect.FullName(o.fqn) +} + +func (o *oneofDescriptor) IsPlaceholder() bool { + return false +} + +func (o *oneofDescriptor) Options() protoreflect.ProtoMessage { + return o.proto.Options +} + +func (o *oneofDescriptor) IsSynthetic() bool { + for _, fld := range o.parent.proto.GetField() { + if fld.OneofIndex != nil && int(fld.GetOneofIndex()) == o.index { + return fld.GetProto3Optional() + } + } + return false // NB: we should never get here +} + +func (o *oneofDescriptor) Fields() protoreflect.FieldDescriptors { + return &o.fields +} + +type svcDescriptors struct { + protoreflect.ServiceDescriptors + svcs []*svcDescriptor +} + +func (r *result) createServices(prefix string, svcProtos []*descriptorpb.ServiceDescriptorProto) svcDescriptors { + svcs := make([]*svcDescriptor, len(svcProtos)) + for i, svcProto := range svcProtos { + svcs[i] = r.createServiceDescriptor(svcProto, i, prefix+svcProto.GetName()) + } + return svcDescriptors{svcs: svcs} +} + +func (s *svcDescriptors) Len() int { + return len(s.svcs) +} + +func (s *svcDescriptors) Get(i int) protoreflect.ServiceDescriptor { + return s.svcs[i] +} + +func (s *svcDescriptors) ByName(n protoreflect.Name) protoreflect.ServiceDescriptor { + for _, svc := range s.svcs { + if svc.Name() == n { + return svc + } + } + return nil +} + +type svcDescriptor struct { + protoreflect.ServiceDescriptor + file *result + index int + proto *descriptorpb.ServiceDescriptorProto + fqn string + + methods mtdDescriptors +} + +var _ protoreflect.ServiceDescriptor = (*svcDescriptor)(nil) +var _ protoutil.DescriptorProtoWrapper = (*svcDescriptor)(nil) + +func (r *result) createServiceDescriptor(sd *descriptorpb.ServiceDescriptorProto, index int, fqn string) *svcDescriptor { + ret := &svcDescriptor{file: r, index: index, proto: sd, fqn: fqn} + r.descriptors[fqn] = ret + + prefix := fqn + "." + ret.methods = r.createMethods(prefix, ret, sd.Method) + + return ret +} + +func (s *svcDescriptor) ServiceDescriptorProto() *descriptorpb.ServiceDescriptorProto { + return s.proto +} + +func (s *svcDescriptor) AsProto() proto.Message { + return s.proto +} + +func (s *svcDescriptor) ParentFile() protoreflect.FileDescriptor { + return s.file +} + +func (s *svcDescriptor) Parent() protoreflect.Descriptor { + return s.file +} + +func (s *svcDescriptor) Index() int { + return s.index +} + +func (s *svcDescriptor) Syntax() protoreflect.Syntax { + return s.file.Syntax() +} + +func (s *svcDescriptor) Name() protoreflect.Name { + return protoreflect.Name(s.proto.GetName()) +} + +func (s *svcDescriptor) FullName() protoreflect.FullName { + return protoreflect.FullName(s.fqn) +} + +func (s *svcDescriptor) IsPlaceholder() bool { + return false +} + +func (s *svcDescriptor) Options() protoreflect.ProtoMessage { + return s.proto.Options +} + +func (s *svcDescriptor) Methods() protoreflect.MethodDescriptors { + return &s.methods +} + +type mtdDescriptors struct { + protoreflect.MethodDescriptors + mtds []*mtdDescriptor +} + +func (r *result) createMethods(prefix string, parent *svcDescriptor, mtdProtos []*descriptorpb.MethodDescriptorProto) mtdDescriptors { + mtds := make([]*mtdDescriptor, len(mtdProtos)) + for i, mtdProto := range mtdProtos { + mtds[i] = r.createMethodDescriptor(mtdProto, parent, i, prefix+mtdProto.GetName()) + } + return mtdDescriptors{mtds: mtds} +} + +func (m *mtdDescriptors) Len() int { + return len(m.mtds) +} + +func (m *mtdDescriptors) Get(i int) protoreflect.MethodDescriptor { + return m.mtds[i] +} + +func (m *mtdDescriptors) ByName(n protoreflect.Name) protoreflect.MethodDescriptor { + for _, mtd := range m.mtds { + if mtd.Name() == n { + return mtd + } + } + return nil +} + +type mtdDescriptor struct { + protoreflect.MethodDescriptor + file *result + parent *svcDescriptor + index int + proto *descriptorpb.MethodDescriptorProto + fqn string + + inputType, outputType protoreflect.MessageDescriptor +} + +var _ protoreflect.MethodDescriptor = (*mtdDescriptor)(nil) +var _ protoutil.DescriptorProtoWrapper = (*mtdDescriptor)(nil) + +func (r *result) createMethodDescriptor(mtd *descriptorpb.MethodDescriptorProto, parent *svcDescriptor, index int, fqn string) *mtdDescriptor { + ret := &mtdDescriptor{file: r, parent: parent, index: index, proto: mtd, fqn: fqn} + r.descriptors[fqn] = ret + return ret +} + +func (m *mtdDescriptor) MethodDescriptorProto() *descriptorpb.MethodDescriptorProto { + return m.proto +} + +func (m *mtdDescriptor) AsProto() proto.Message { + return m.proto +} + +func (m *mtdDescriptor) ParentFile() protoreflect.FileDescriptor { + return m.file +} + +func (m *mtdDescriptor) Parent() protoreflect.Descriptor { + return m.parent +} + +func (m *mtdDescriptor) Index() int { + return m.index +} + +func (m *mtdDescriptor) Syntax() protoreflect.Syntax { + return m.file.Syntax() +} + +func (m *mtdDescriptor) Name() protoreflect.Name { + return protoreflect.Name(m.proto.GetName()) +} + +func (m *mtdDescriptor) FullName() protoreflect.FullName { + return protoreflect.FullName(m.fqn) +} + +func (m *mtdDescriptor) IsPlaceholder() bool { + return false +} + +func (m *mtdDescriptor) Options() protoreflect.ProtoMessage { + return m.proto.Options +} + +func (m *mtdDescriptor) Input() protoreflect.MessageDescriptor { + return m.inputType +} + +func (m *mtdDescriptor) Output() protoreflect.MessageDescriptor { + return m.outputType +} + +func (m *mtdDescriptor) IsStreamingClient() bool { + return m.proto.GetClientStreaming() +} + +func (m *mtdDescriptor) IsStreamingServer() bool { + return m.proto.GetServerStreaming() +} + +func (r *result) FindImportByPath(path string) File { + return r.deps.FindFileByPath(path) +} + +func (r *result) FindExtensionByNumber(msg protoreflect.FullName, tag protoreflect.FieldNumber) protoreflect.ExtensionTypeDescriptor { + return findExtension(r, msg, tag) +} + +func (r *result) FindDescriptorByName(name protoreflect.FullName) protoreflect.Descriptor { + fqn := strings.TrimPrefix(string(name), ".") + return r.descriptors[fqn] +} + +func (r *result) importsAsFiles() Files { + return r.deps +} + +func (r *result) hasSource() bool { + n := r.FileNode() + _, ok := n.(*ast.FileNode) + return ok +} diff --git a/vendor/github.com/bufbuild/protocompile/linker/doc.go b/vendor/github.com/bufbuild/protocompile/linker/doc.go new file mode 100644 index 00000000000..455c2ef6895 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/doc.go @@ -0,0 +1,48 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package linker contains logic and APIs related to linking a protobuf file. +// The process of linking involves resolving all symbol references to the +// referenced descriptor. The result of linking is a "rich" descriptor that +// is more useful than just a descriptor proto since the links allow easy +// traversal of a protobuf type schema and the relationships between elements. +// +// # Files +// +// This package uses an augmentation to protoreflect.FileDescriptor instances +// in the form of the File interface. There are also factory functions for +// promoting a FileDescriptor into a linker.File. This new interface provides +// additional methods for resolving symbols in the file. +// +// This interface is both the result of linking but also an input to the linking +// process, as all dependencies of a file to be linked must be provided in this +// form. The actual result of the Link function, a Result, is an even broader +// interface than File: The linker.Result interface provides even more functions, +// which are needed for subsequent compilation steps: interpreting options and +// generating source code info. +// +// # Symbols +// +// This package has a type named Symbols which represents a symbol table. This +// is usually an internal detail when linking, but callers can provide an +// instance so that symbols across multiple compile/link operations all have +// access to the same table. This allows for detection of cases where multiple +// files try to declare elements with conflicting fully-qualified names or +// declare extensions for a particular extendable message that have conflicting +// tag numbers. +// +// The calling code simply uses the same Symbols instance across all compile +// operations and if any files processed have such conflicts, they can be +// reported. +package linker diff --git a/vendor/github.com/bufbuild/protocompile/linker/files.go b/vendor/github.com/bufbuild/protocompile/linker/files.go new file mode 100644 index 00000000000..aad534756bb --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/files.go @@ -0,0 +1,368 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linker + +import ( + "fmt" + "strings" + + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/dynamicpb" + + "github.com/bufbuild/protocompile/walk" +) + +// File is like a super-powered protoreflect.FileDescriptor. It includes helpful +// methods for looking up elements in the descriptor and can be used to create a +// resolver for all in the file's transitive closure of dependencies. (See +// ResolverFromFile.) +type File interface { + protoreflect.FileDescriptor + // FindDescriptorByName returns the given named element that is defined in + // this file. If no such element exists, nil is returned. + FindDescriptorByName(name protoreflect.FullName) protoreflect.Descriptor + // FindImportByPath returns the File corresponding to the given import path. + // If this file does not import the given path, nil is returned. + FindImportByPath(path string) File + // FindExtensionByNumber returns the extension descriptor for the given tag + // that extends the given message name. If no such extension is defined in this + // file, nil is returned. + FindExtensionByNumber(message protoreflect.FullName, tag protoreflect.FieldNumber) protoreflect.ExtensionTypeDescriptor + // Imports returns this file's imports. These are only the files directly + // imported by the file. Indirect transitive dependencies will not be in + // the returned slice. + importsAsFiles() Files +} + +// NewFile converts a protoreflect.FileDescriptor to a File. The given deps must +// contain all dependencies/imports of f. Also see NewFileRecursive. +func NewFile(f protoreflect.FileDescriptor, deps Files) (File, error) { + if asFile, ok := f.(File); ok { + return asFile, nil + } + checkedDeps := make(Files, f.Imports().Len()) + for i := 0; i < f.Imports().Len(); i++ { + imprt := f.Imports().Get(i) + dep := deps.FindFileByPath(imprt.Path()) + if dep == nil { + return nil, fmt.Errorf("cannot create File for %q: missing dependency for %q", f.Path(), imprt.Path()) + } + checkedDeps[i] = dep + } + return newFile(f, checkedDeps) +} + +func newFile(f protoreflect.FileDescriptor, deps Files) (File, error) { + descs := map[protoreflect.FullName]protoreflect.Descriptor{} + err := walk.Descriptors(f, func(d protoreflect.Descriptor) error { + if _, ok := descs[d.FullName()]; ok { + return fmt.Errorf("file %q contains multiple elements with the name %s", f.Path(), d.FullName()) + } + descs[d.FullName()] = d + return nil + }) + if err != nil { + return nil, err + } + return &file{ + FileDescriptor: f, + descs: descs, + deps: deps, + }, nil +} + +// NewFileRecursive recursively converts a protoreflect.FileDescriptor to a File. +// If f has any dependencies/imports, they are converted, too, including any and +// all transitive dependencies. +func NewFileRecursive(f protoreflect.FileDescriptor) (File, error) { + if asFile, ok := f.(File); ok { + return asFile, nil + } + return newFileRecursive(f, map[protoreflect.FileDescriptor]File{}) +} + +func newFileRecursive(fd protoreflect.FileDescriptor, seen map[protoreflect.FileDescriptor]File) (File, error) { + if res, ok := seen[fd]; ok { + if res == nil { + return nil, fmt.Errorf("import cycle encountered: file %s transitively imports itself", fd.Path()) + } + return res, nil + } + + if f, ok := fd.(File); ok { + seen[fd] = f + return f, nil + } + + seen[fd] = nil + deps := make([]File, fd.Imports().Len()) + for i := 0; i < fd.Imports().Len(); i++ { + imprt := fd.Imports().Get(i) + dep, err := newFileRecursive(imprt, seen) + if err != nil { + return nil, err + } + deps[i] = dep + } + + f, err := newFile(fd, deps) + if err != nil { + return nil, err + } + seen[fd] = f + return f, nil +} + +type file struct { + protoreflect.FileDescriptor + descs map[protoreflect.FullName]protoreflect.Descriptor + deps Files +} + +func (f *file) FindDescriptorByName(name protoreflect.FullName) protoreflect.Descriptor { + return f.descs[name] +} + +func (f *file) FindImportByPath(path string) File { + return f.deps.FindFileByPath(path) +} + +func (f *file) FindExtensionByNumber(msg protoreflect.FullName, tag protoreflect.FieldNumber) protoreflect.ExtensionTypeDescriptor { + return findExtension(f, msg, tag) +} + +func (f *file) importsAsFiles() Files { + return f.deps +} + +var _ File = (*file)(nil) + +// Files represents a set of protobuf files. It is a slice of File values, but +// also provides a method for easily looking up files by path and name. +type Files []File + +// FindFileByPath finds a file in f that has the given path and name. If f +// contains no such file, nil is returned. +func (f Files) FindFileByPath(path string) File { + for _, file := range f { + if file.Path() == path { + return file + } + } + return nil +} + +// AsResolver returns a Resolver that uses f as the source of descriptors. If +// a given query cannot be answered with the files in f, the query will fail +// with a protoregistry.NotFound error. The implementation just delegates calls +// to each file until a result is found. +// +// Also see ResolverFromFile. +func (f Files) AsResolver() Resolver { + return filesResolver(f) +} + +// Resolver is an interface that can resolve various kinds of queries about +// descriptors. It satisfies the resolver interfaces defined in protodesc +// and protoregistry packages. +type Resolver interface { + protodesc.Resolver + protoregistry.MessageTypeResolver + protoregistry.ExtensionTypeResolver +} + +// ResolverFromFile returns a Resolver that uses the given file plus its full +// set of transitive dependencies as the source of descriptors. If a given query +// cannot be answered with these files, the query will fail with a +// protoregistry.NotFound error. +// +// Note that this function does not compute any additional indexes for efficient +// search, so queries generally take linear time, O(n) where n is the number of +// files in the transitive closure of the given file. Queries for an extension +// by number are linear with the number of messages and extensions defined across +// all the files. +func ResolverFromFile(f File) Resolver { + return fileResolver{ + f: f, + deps: f.importsAsFiles().AsResolver(), + } +} + +type fileResolver struct { + f File + deps Resolver +} + +func (r fileResolver) FindFileByPath(path string) (protoreflect.FileDescriptor, error) { + if r.f.Path() == path { + return r.f, nil + } + return r.deps.FindFileByPath(path) +} + +func (r fileResolver) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error) { + d := r.f.FindDescriptorByName(name) + if d != nil { + return d, nil + } + return r.deps.FindDescriptorByName(name) +} + +func (r fileResolver) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) { + d := r.f.FindDescriptorByName(message) + if d != nil { + if md, ok := d.(protoreflect.MessageDescriptor); ok { + return dynamicpb.NewMessageType(md), nil + } + return nil, protoregistry.NotFound + } + return r.deps.FindMessageByName(message) +} + +func (r fileResolver) FindMessageByURL(url string) (protoreflect.MessageType, error) { + fullName := messageNameFromURL(url) + return r.FindMessageByName(protoreflect.FullName(fullName)) +} + +func messageNameFromURL(url string) string { + lastSlash := strings.LastIndexByte(url, '/') + var fullName string + if lastSlash >= 0 { + fullName = url[lastSlash+1:] + } else { + fullName = url + } + return fullName +} + +func (r fileResolver) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error) { + d := r.f.FindDescriptorByName(field) + if d != nil { + if extd, ok := d.(protoreflect.ExtensionTypeDescriptor); ok { + return extd.Type(), nil + } + if fld, ok := d.(protoreflect.FieldDescriptor); ok && fld.IsExtension() { + return dynamicpb.NewExtensionType(fld), nil + } + return nil, protoregistry.NotFound + } + return r.deps.FindExtensionByName(field) +} + +func (r fileResolver) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error) { + ext := findExtension(r.f, message, field) + if ext != nil { + return ext.Type(), nil + } + return r.deps.FindExtensionByNumber(message, field) +} + +type filesResolver []File + +func (r filesResolver) FindFileByPath(path string) (protoreflect.FileDescriptor, error) { + for _, f := range r { + if f.Path() == path { + return f, nil + } + } + return nil, protoregistry.NotFound +} + +func (r filesResolver) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error) { + for _, f := range r { + result := f.FindDescriptorByName(name) + if result != nil { + return result, nil + } + } + return nil, protoregistry.NotFound +} + +func (r filesResolver) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) { + for _, f := range r { + d := f.FindDescriptorByName(message) + if d != nil { + if md, ok := d.(protoreflect.MessageDescriptor); ok { + return dynamicpb.NewMessageType(md), nil + } + return nil, protoregistry.NotFound + } + } + return nil, protoregistry.NotFound +} + +func (r filesResolver) FindMessageByURL(url string) (protoreflect.MessageType, error) { + name := messageNameFromURL(url) + return r.FindMessageByName(protoreflect.FullName(name)) +} + +func (r filesResolver) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error) { + for _, f := range r { + d := f.FindDescriptorByName(field) + if d != nil { + if extd, ok := d.(protoreflect.ExtensionTypeDescriptor); ok { + return extd.Type(), nil + } + if fld, ok := d.(protoreflect.FieldDescriptor); ok && fld.IsExtension() { + return dynamicpb.NewExtensionType(fld), nil + } + return nil, protoregistry.NotFound + } + } + return nil, protoregistry.NotFound +} + +func (r filesResolver) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error) { + for _, f := range r { + ext := findExtension(f, message, field) + if ext != nil { + return ext.Type(), nil + } + } + return nil, protoregistry.NotFound +} + +type hasExtensionsAndMessages interface { + Messages() protoreflect.MessageDescriptors + Extensions() protoreflect.ExtensionDescriptors +} + +func findExtension(d hasExtensionsAndMessages, message protoreflect.FullName, field protoreflect.FieldNumber) protoreflect.ExtensionTypeDescriptor { + for i := 0; i < d.Extensions().Len(); i++ { + if extType := isExtensionMatch(d.Extensions().Get(i), message, field); extType != nil { + return extType + } + } + + for i := 0; i < d.Messages().Len(); i++ { + if extType := findExtension(d.Messages().Get(i), message, field); extType != nil { + return extType + } + } + + return nil // could not be found +} + +func isExtensionMatch(ext protoreflect.ExtensionDescriptor, message protoreflect.FullName, field protoreflect.FieldNumber) protoreflect.ExtensionTypeDescriptor { + if ext.Number() != field || ext.ContainingMessage().FullName() != message { + return nil + } + if extType, ok := ext.(protoreflect.ExtensionTypeDescriptor); ok { + return extType + } + return dynamicpb.NewExtensionType(ext).TypeDescriptor() +} diff --git a/vendor/github.com/bufbuild/protocompile/linker/linker.go b/vendor/github.com/bufbuild/protocompile/linker/linker.go new file mode 100644 index 00000000000..c9e6e84e2d3 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/linker.go @@ -0,0 +1,177 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linker + +import ( + "fmt" + + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/parser" + "github.com/bufbuild/protocompile/reporter" +) + +// Link handles linking a parsed descriptor proto into a fully-linked descriptor. +// If the given parser.Result has imports, they must all be present in the given +// dependencies. +// +// The symbols value is optional and may be nil. If it is not nil, it must be the +// same instance used to create and link all of the given result's dependencies +// (or otherwise already have all dependencies imported). Otherwise, linking may +// fail with spurious errors resolving symbols. +// +// The handler value is used to report any link errors. If any such errors are +// reported, this function returns a non-nil error. The Result value returned +// also implements protoreflect.FileDescriptor. +// +// Note that linking does NOT interpret options. So options messages in the +// returned value have all values stored in UninterpretedOptions fields. +func Link(parsed parser.Result, dependencies Files, symbols *Symbols, handler *reporter.Handler) (Result, error) { + if symbols == nil { + symbols = &Symbols{} + } + prefix := parsed.FileDescriptorProto().GetPackage() + if prefix != "" { + prefix += "." + } + + for _, imp := range parsed.FileDescriptorProto().Dependency { + dep := dependencies.FindFileByPath(imp) + if dep == nil { + return nil, fmt.Errorf("dependencies is missing import %q", imp) + } + if err := symbols.Import(dep, handler); err != nil { + return nil, err + } + } + + r := &result{ + Result: parsed, + deps: dependencies, + descriptors: map[string]protoreflect.Descriptor{}, + usedImports: map[string]struct{}{}, + prefix: prefix, + optionQualifiedNames: map[ast.IdentValueNode]string{}, + } + + // First, we put all symbols into a single pool, which lets us ensure there + // are no duplicate symbols and will also let us resolve and revise all type + // references in next step. + if err := symbols.importResult(r, handler); err != nil { + return nil, err + } + + // After we've populated the pool, we can now try to resolve all type + // references. All references must be checked for correct type, any fields + // with enum types must be corrected (since we parse them as if they are + // message references since we don't actually know message or enum until + // link time), and references will be re-written to be fully-qualified + // references (e.g. start with a dot "."). + if err := r.resolveReferences(handler, symbols); err != nil { + return nil, err + } + + return r, handler.Error() +} + +// Result is the result of linking. This is a protoreflect.FileDescriptor, but +// with some additional methods for exposing additional information, such as the +// for accessing the input AST or file descriptor. +// +// It also provides Resolve* methods, for looking up enums, messages, and +// extensions that are available to the protobuf source file this result +// represents. An element is "available" if it meets any of the following +// criteria: +// 1. The element is defined in this file itself. +// 2. The element is defined in a file that is directly imported by this file. +// 3. The element is "available" to a file that is directly imported by this +// file as a public import. +// +// Other elements, even if in the transitive closure of this file, are not +// available and thus won't be returned by these methods. +type Result interface { + File + parser.Result + // ResolveEnumType returns an enum descriptor for the given named enum that + // is available in this file. If no such element is available or if the + // named element is not an enum, nil is returned. + ResolveEnumType(protoreflect.FullName) protoreflect.EnumDescriptor + // ResolveMessageType returns a message descriptor for the given named + // message that is available in this file. If no such element is available + // or if the named element is not a message, nil is returned. + ResolveMessageType(protoreflect.FullName) protoreflect.MessageDescriptor + // ResolveExtension returns an extension descriptor for the given named + // extension that is available in this file. If no such element is available + // or if the named element is not an extension, nil is returned. + ResolveExtension(protoreflect.FullName) protoreflect.ExtensionTypeDescriptor + // ResolveMessageLiteralExtensionName returns the fully qualified name for + // an identifier for extension field names in message literals. + ResolveMessageLiteralExtensionName(ast.IdentValueNode) string + // ValidateOptions runs some validation checks on the descriptor that can only + // be done after options are interpreted. Any errors or warnings encountered + // will be reported via the given handler. If any error is reported, this + // function returns a non-nil error. + ValidateOptions(handler *reporter.Handler) error + // CheckForUnusedImports is used to report warnings for unused imports. This + // should be called after options have been interpreted. Otherwise, the logic + // could incorrectly report imports as unused if the only symbol used were a + // custom option. + CheckForUnusedImports(handler *reporter.Handler) + // PopulateSourceCodeInfo is used to populate source code info for the file + // descriptor. This step requires that the underlying descriptor proto have + // its `source_code_info` field populated. This is typically a post-process + // step separate from linking, because computing source code info requires + // interpreting options (which is done after linking). + PopulateSourceCodeInfo() + + // CanonicalProto returns the file descriptor proto in a form that + // will be serialized in a canonical way. The "canonical" way matches + // the way that "protoc" emits option values, which is a way that + // mostly matches the way options are defined in source, including + // ordering and de-structuring. Unlike the FileDescriptorProto() method, this + // method is more expensive and results in a new descriptor proto + // being constructed with each call. + // + // The returned value will have all options (fields of the various + // descriptorpb.*Options message types) represented via unrecognized + // fields. So the returned value will serialize as desired, but it + // is otherwise not useful since all option values are treated as + // unknown. + CanonicalProto() *descriptorpb.FileDescriptorProto + + // RemoveAST drops the AST information from this result. + RemoveAST() +} + +// ErrorUnusedImport may be passed to a warning reporter when an unused +// import is detected. The error the reporter receives will be wrapped +// with source position that indicates the file and line where the import +// statement appeared. +type ErrorUnusedImport interface { + error + UnusedImport() string +} + +type errUnusedImport string + +func (e errUnusedImport) Error() string { + return fmt.Sprintf("import %q not used", string(e)) +} + +func (e errUnusedImport) UnusedImport() string { + return string(e) +} diff --git a/vendor/github.com/bufbuild/protocompile/linker/pathkey_no_unsafe.go b/vendor/github.com/bufbuild/protocompile/linker/pathkey_no_unsafe.go new file mode 100644 index 00000000000..89475e6931f --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/pathkey_no_unsafe.go @@ -0,0 +1,35 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build appengine || gopherjs || purego +// +build appengine gopherjs purego + +// NB: other environments where unsafe is inappropriate should use "purego" build tag +// https://github.com/golang/go/issues/23172 + +package linker + +import ( + "reflect" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +func pathKey(p protoreflect.SourcePath) interface{} { + rv := reflect.ValueOf(p) + arrayType := reflect.ArrayOf(rv.Len(), rv.Type().Elem()) + array := reflect.New(arrayType).Elem() + reflect.Copy(array, rv) + return array.Interface() +} diff --git a/vendor/github.com/bufbuild/protocompile/linker/pathkey_unsafe.go b/vendor/github.com/bufbuild/protocompile/linker/pathkey_unsafe.go new file mode 100644 index 00000000000..cf0d0c26620 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/pathkey_unsafe.go @@ -0,0 +1,36 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !appengine && !gopherjs && !purego +// +build !appengine,!gopherjs,!purego + +// NB: other environments where unsafe is inappropriate should use "purego" build tag +// https://github.com/golang/go/issues/23172 + +package linker + +import ( + "reflect" + "unsafe" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +var pathElementType = reflect.TypeOf(protoreflect.SourcePath{}).Elem() + +func pathKey(p protoreflect.SourcePath) interface{} { + hdr := (*reflect.SliceHeader)(unsafe.Pointer(reflect.ValueOf(&p).Pointer())) + array := reflect.NewAt(reflect.ArrayOf(hdr.Len, pathElementType), unsafe.Pointer(hdr.Data)) + return array.Elem().Interface() +} diff --git a/vendor/github.com/bufbuild/protocompile/linker/resolve.go b/vendor/github.com/bufbuild/protocompile/linker/resolve.go new file mode 100644 index 00000000000..50a78fc07f7 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/resolve.go @@ -0,0 +1,787 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linker + +import ( + "fmt" + "strings" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + "google.golang.org/protobuf/types/dynamicpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/reporter" + "github.com/bufbuild/protocompile/walk" +) + +func (r *result) ResolveMessageType(name protoreflect.FullName) protoreflect.MessageDescriptor { + d := r.resolveElement(name) + if md, ok := d.(protoreflect.MessageDescriptor); ok { + return md + } + return nil +} + +func (r *result) ResolveEnumType(name protoreflect.FullName) protoreflect.EnumDescriptor { + d := r.resolveElement(name) + if ed, ok := d.(protoreflect.EnumDescriptor); ok { + return ed + } + return nil +} + +func (r *result) ResolveExtension(name protoreflect.FullName) protoreflect.ExtensionTypeDescriptor { + d := r.resolveElement(name) + if ed, ok := d.(protoreflect.ExtensionDescriptor); ok { + if !ed.IsExtension() { + return nil + } + if td, ok := ed.(protoreflect.ExtensionTypeDescriptor); ok { + return td + } + return dynamicpb.NewExtensionType(ed).TypeDescriptor() + } + return nil +} + +func (r *result) ResolveMessageLiteralExtensionName(node ast.IdentValueNode) string { + return r.optionQualifiedNames[node] +} + +func (r *result) resolveElement(name protoreflect.FullName) protoreflect.Descriptor { + if len(name) > 0 && name[0] == '.' { + name = name[1:] + } + importedFd, res := resolveElement(r, name, false, nil) + if importedFd != nil { + r.markUsed(importedFd.Path()) + } + return res +} + +func (r *result) markUsed(importPath string) { + r.usedImports[importPath] = struct{}{} +} + +func (r *result) CheckForUnusedImports(handler *reporter.Handler) { + fd := r.FileDescriptorProto() + file, _ := r.FileNode().(*ast.FileNode) + for i, dep := range fd.Dependency { + if _, ok := r.usedImports[dep]; !ok { + isPublic := false + // it's fine if it's a public import + for _, j := range fd.PublicDependency { + if i == int(j) { + isPublic = true + break + } + } + if isPublic { + continue + } + pos := ast.UnknownPos(fd.GetName()) + if file != nil { + for _, decl := range file.Decls { + imp, ok := decl.(*ast.ImportNode) + if ok && imp.Name.AsString() == dep { + pos = file.NodeInfo(imp).Start() + } + } + } + handler.HandleWarningWithPos(pos, errUnusedImport(dep)) + } + } +} + +func resolveElement(f File, fqn protoreflect.FullName, publicImportsOnly bool, checked []string) (imported File, d protoreflect.Descriptor) { + path := f.Path() + for _, str := range checked { + if str == path { + // already checked + return nil, nil + } + } + checked = append(checked, path) + + r := resolveElementInFile(fqn, f) + if r != nil { + // not imported, but present in f + return nil, r + } + + // When publicImportsOnly = false, we are searching only directly imported symbols. But + // we also need to search transitive public imports due to semantics of public imports. + for i := 0; i < f.Imports().Len(); i++ { + dep := f.Imports().Get(i) + if dep.IsPublic || !publicImportsOnly { + depFile := f.FindImportByPath(dep.Path()) + _, d := resolveElement(depFile, fqn, true, checked) + if d != nil { + return depFile, d + } + } + } + + return nil, nil +} + +func descriptorTypeWithArticle(d protoreflect.Descriptor) string { + switch d := d.(type) { + case protoreflect.MessageDescriptor: + return "a message" + case protoreflect.FieldDescriptor: + if d.IsExtension() { + return "an extension" + } + return "a field" + case protoreflect.OneofDescriptor: + return "a oneof" + case protoreflect.EnumDescriptor: + return "an enum" + case protoreflect.EnumValueDescriptor: + return "an enum value" + case protoreflect.ServiceDescriptor: + return "a service" + case protoreflect.MethodDescriptor: + return "a method" + case protoreflect.FileDescriptor: + return "a file" + default: + // shouldn't be possible + return fmt.Sprintf("a %T", d) + } +} + +func (r *result) resolveReferences(handler *reporter.Handler, s *Symbols) error { + // first create the full descriptor hierarchy + fd := r.FileDescriptorProto() + prefix := "" + if fd.GetPackage() != "" { + prefix = fd.GetPackage() + "." + } + r.imports = r.createImports() + r.messages = r.createMessages(prefix, r, fd.MessageType) + r.enums = r.createEnums(prefix, r, fd.EnumType) + r.extensions = r.createExtensions(prefix, r, fd.Extension) + r.services = r.createServices(prefix, fd.Service) + + // then resolve symbol references + scopes := []scope{fileScope(r)} + if fd.Options != nil { + if err := r.resolveOptions(handler, "file", protoreflect.FullName(fd.GetName()), fd.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + + return walk.DescriptorsEnterAndExit(r, + func(d protoreflect.Descriptor) error { + fqn := d.FullName() + switch d := d.(type) { + case *msgDescriptor: + // Strangely, when protoc resolves extension names, it uses the *enclosing* scope + // instead of the message's scope. So if the message contains an extension named "i", + // an option cannot refer to it as simply "i" but must qualify it (at a minimum "Msg.i"). + // So we don't add this messages scope to our scopes slice until *after* we do options. + if d.proto.Options != nil { + if err := r.resolveOptions(handler, "message", fqn, d.proto.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + scopes = append(scopes, messageScope(r, fqn)) // push new scope on entry + // walk only visits descriptors, so we need to loop over extension ranges ourselves + for _, er := range d.proto.ExtensionRange { + if er.Options != nil { + erName := protoreflect.FullName(fmt.Sprintf("%s:%d-%d", fqn, er.GetStart(), er.GetEnd()-1)) + if err := r.resolveOptions(handler, "extension range", erName, er.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + } + case *extTypeDescriptor: + if d.field.proto.Options != nil { + if err := r.resolveOptions(handler, "extension", fqn, d.field.proto.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + if err := resolveFieldTypes(d.field, handler, s, scopes); err != nil { + return err + } + if r.Syntax() == protoreflect.Proto3 && !allowedProto3Extendee(d.field.proto.GetExtendee()) { + file := r.FileNode() + node := r.FieldNode(d.field.proto).FieldExtendee() + if err := handler.HandleErrorf(file.NodeInfo(node).Start(), "extend blocks in proto3 can only be used to define custom options"); err != nil { + return err + } + } + case *fldDescriptor: + if d.proto.Options != nil { + if err := r.resolveOptions(handler, "field", fqn, d.proto.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + if err := resolveFieldTypes(d, handler, s, scopes); err != nil { + return err + } + case *oneofDescriptor: + if d.proto.Options != nil { + if err := r.resolveOptions(handler, "oneof", fqn, d.proto.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + case *enumDescriptor: + if d.proto.Options != nil { + if err := r.resolveOptions(handler, "enum", fqn, d.proto.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + case *enValDescriptor: + if d.proto.Options != nil { + if err := r.resolveOptions(handler, "enum value", fqn, d.proto.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + case *svcDescriptor: + if d.proto.Options != nil { + if err := r.resolveOptions(handler, "service", fqn, d.proto.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + // not a message, but same scoping rules for nested elements as if it were + scopes = append(scopes, messageScope(r, fqn)) // push new scope on entry + case *mtdDescriptor: + if d.proto.Options != nil { + if err := r.resolveOptions(handler, "method", fqn, d.proto.Options.UninterpretedOption, scopes); err != nil { + return err + } + } + if err := resolveMethodTypes(d, handler, scopes); err != nil { + return err + } + } + return nil + }, + func(d protoreflect.Descriptor) error { + switch d.(type) { + case protoreflect.MessageDescriptor, protoreflect.ServiceDescriptor: + // pop message scope on exit + scopes = scopes[:len(scopes)-1] + } + return nil + }) +} + +var allowedProto3Extendees = map[string]struct{}{ + ".google.protobuf.FileOptions": {}, + ".google.protobuf.MessageOptions": {}, + ".google.protobuf.FieldOptions": {}, + ".google.protobuf.OneofOptions": {}, + ".google.protobuf.ExtensionRangeOptions": {}, + ".google.protobuf.EnumOptions": {}, + ".google.protobuf.EnumValueOptions": {}, + ".google.protobuf.ServiceOptions": {}, + ".google.protobuf.MethodOptions": {}, +} + +func allowedProto3Extendee(n string) bool { + if n == "" { + // not an extension, allowed + return true + } + _, ok := allowedProto3Extendees[n] + return ok +} + +func resolveFieldTypes(f *fldDescriptor, handler *reporter.Handler, s *Symbols, scopes []scope) error { + r := f.file + fld := f.proto + file := r.FileNode() + node := r.FieldNode(fld) + scope := fmt.Sprintf("field %s", f.fqn) + if fld.GetExtendee() != "" { + scope := fmt.Sprintf("extension %s", f.fqn) + dsc := r.resolve(fld.GetExtendee(), false, scopes) + if dsc == nil { + return handler.HandleErrorf(file.NodeInfo(node.FieldExtendee()).Start(), "unknown extendee type %s", fld.GetExtendee()) + } + if isSentinelDescriptor(dsc) { + return handler.HandleErrorf(file.NodeInfo(node.FieldExtendee()).Start(), "unknown extendee type %s; resolved to %s which is not defined; consider using a leading dot", fld.GetExtendee(), dsc.FullName()) + } + extd, ok := dsc.(protoreflect.MessageDescriptor) + if !ok { + return handler.HandleErrorf(file.NodeInfo(node.FieldExtendee()).Start(), "extendee is invalid: %s is %s, not a message", dsc.FullName(), descriptorTypeWithArticle(dsc)) + } + f.extendee = extd + fld.Extendee = proto.String("." + string(dsc.FullName())) + // make sure the tag number is in range + found := false + tag := protoreflect.FieldNumber(fld.GetNumber()) + for i := 0; i < extd.ExtensionRanges().Len(); i++ { + rng := extd.ExtensionRanges().Get(i) + if tag >= rng[0] && tag < rng[1] { + found = true + break + } + } + if !found { + if err := handler.HandleErrorf(file.NodeInfo(node.FieldTag()).Start(), "%s: tag %d is not in valid range for extended type %s", scope, tag, dsc.FullName()); err != nil { + return err + } + } else { + // make sure tag is not a duplicate + if err := s.AddExtension(dsc.ParentFile().Package(), dsc.FullName(), tag, file.NodeInfo(node.FieldTag()).Start(), handler); err != nil { + return err + } + } + } else if f.proto.OneofIndex != nil { + parent := f.parent.(protoreflect.MessageDescriptor) //nolint:errcheck + index := int(f.proto.GetOneofIndex()) + f.oneof = parent.Oneofs().Get(index) + } + + if fld.GetTypeName() == "" { + // scalar type; no further resolution required + return nil + } + + dsc := r.resolve(fld.GetTypeName(), true, scopes) + if dsc == nil { + return handler.HandleErrorf(file.NodeInfo(node.FieldType()).Start(), "%s: unknown type %s", scope, fld.GetTypeName()) + } + if isSentinelDescriptor(dsc) { + return handler.HandleErrorf(file.NodeInfo(node.FieldType()).Start(), "%s: unknown type %s; resolved to %s which is not defined; consider using a leading dot", scope, fld.GetTypeName(), dsc.FullName()) + } + switch dsc := dsc.(type) { + case protoreflect.MessageDescriptor: + if dsc.IsMapEntry() { + isValid := false + switch node.(type) { + case *ast.MapFieldNode: + // We have an AST for this file and can see this field is from a map declaration + isValid = true + case ast.NoSourceNode: + // We don't have an AST for the file (it came from a provided descriptor). So we + // need to validate that it's not an illegal reference. To be valid, the field + // must be repeated and the entry type must be nested in the same enclosing + // message as the field. + isValid = isValidMap(f, dsc) + if isValid && f.index > 0 { + // also make sure there are no earlier fields that are valid for this map entry + flds := f.Parent().(protoreflect.MessageDescriptor).Fields() + for i := 0; i < f.index; i++ { + if isValidMap(flds.Get(i), dsc) { + isValid = false + break + } + } + } + } + if !isValid { + return handler.HandleErrorf(file.NodeInfo(node.FieldType()).Start(), "%s: %s is a synthetic map entry and may not be referenced explicitly", scope, dsc.FullName()) + } + } + fld.TypeName = proto.String("." + string(dsc.FullName())) + // if type was tentatively unset, we now know it's actually a message + if fld.Type == nil { + fld.Type = descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum() + } + f.msgType = dsc + case protoreflect.EnumDescriptor: + proto3 := r.Syntax() == protoreflect.Proto3 + enumIsProto3 := dsc.ParentFile().Syntax() == protoreflect.Proto3 + if fld.GetExtendee() == "" && proto3 && !enumIsProto3 { + // fields in a proto3 message cannot refer to proto2 enums + return handler.HandleErrorf(file.NodeInfo(node.FieldType()).Start(), "%s: cannot use proto2 enum %s in a proto3 message", scope, fld.GetTypeName()) + } + fld.TypeName = proto.String("." + string(dsc.FullName())) + // the type was tentatively unset, but now we know it's actually an enum + fld.Type = descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum() + f.enumType = dsc + default: + return handler.HandleErrorf(file.NodeInfo(node.FieldType()).Start(), "%s: invalid type: %s is %s, not a message or enum", scope, dsc.FullName(), descriptorTypeWithArticle(dsc)) + } + return nil +} + +func isValidMap(mapField protoreflect.FieldDescriptor, mapEntry protoreflect.MessageDescriptor) bool { + return !mapField.IsExtension() && + mapEntry.Parent() == mapField.ContainingMessage() && + mapField.Cardinality() == protoreflect.Repeated && + string(mapEntry.Name()) == internal.InitCap(internal.JSONName(string(mapField.Name())))+"Entry" +} + +func resolveMethodTypes(m *mtdDescriptor, handler *reporter.Handler, scopes []scope) error { + scope := fmt.Sprintf("method %s", m.fqn) + r := m.file + mtd := m.proto + file := r.FileNode() + node := r.MethodNode(mtd) + dsc := r.resolve(mtd.GetInputType(), false, scopes) + if dsc == nil { + if err := handler.HandleErrorf(file.NodeInfo(node.GetInputType()).Start(), "%s: unknown request type %s", scope, mtd.GetInputType()); err != nil { + return err + } + } else if isSentinelDescriptor(dsc) { + if err := handler.HandleErrorf(file.NodeInfo(node.GetInputType()).Start(), "%s: unknown request type %s; resolved to %s which is not defined; consider using a leading dot", scope, mtd.GetInputType(), dsc.FullName()); err != nil { + return err + } + } else if msg, ok := dsc.(protoreflect.MessageDescriptor); !ok { + if err := handler.HandleErrorf(file.NodeInfo(node.GetInputType()).Start(), "%s: invalid request type: %s is %s, not a message", scope, dsc.FullName(), descriptorTypeWithArticle(dsc)); err != nil { + return err + } + } else { + mtd.InputType = proto.String("." + string(dsc.FullName())) + m.inputType = msg + } + + // TODO: make input and output type resolution more DRY + dsc = r.resolve(mtd.GetOutputType(), false, scopes) + if dsc == nil { + if err := handler.HandleErrorf(file.NodeInfo(node.GetOutputType()).Start(), "%s: unknown response type %s", scope, mtd.GetOutputType()); err != nil { + return err + } + } else if isSentinelDescriptor(dsc) { + if err := handler.HandleErrorf(file.NodeInfo(node.GetOutputType()).Start(), "%s: unknown response type %s; resolved to %s which is not defined; consider using a leading dot", scope, mtd.GetOutputType(), dsc.FullName()); err != nil { + return err + } + } else if msg, ok := dsc.(protoreflect.MessageDescriptor); !ok { + if err := handler.HandleErrorf(file.NodeInfo(node.GetOutputType()).Start(), "%s: invalid response type: %s is %s, not a message", scope, dsc.FullName(), descriptorTypeWithArticle(dsc)); err != nil { + return err + } + } else { + mtd.OutputType = proto.String("." + string(dsc.FullName())) + m.outputType = msg + } + + return nil +} + +func (r *result) resolveOptions(handler *reporter.Handler, elemType string, elemName protoreflect.FullName, opts []*descriptorpb.UninterpretedOption, scopes []scope) error { + mc := &internal.MessageContext{ + File: r, + ElementName: string(elemName), + ElementType: elemType, + } + file := r.FileNode() +opts: + for _, opt := range opts { + // resolve any extension names found in option names + for _, nm := range opt.Name { + if nm.GetIsExtension() { + node := r.OptionNamePartNode(nm) + fqn, err := r.resolveExtensionName(nm.GetNamePart(), scopes) + if err != nil { + if err := handler.HandleErrorf(file.NodeInfo(node).Start(), "%v%v", mc, err); err != nil { + return err + } + continue opts + } + nm.NamePart = proto.String(fqn) + } + } + // also resolve any extension names found inside message literals in option values + mc.Option = opt + optVal := r.OptionNode(opt).GetValue() + if err := r.resolveOptionValue(handler, mc, optVal, scopes); err != nil { + return err + } + mc.Option = nil + } + return nil +} + +func (r *result) resolveOptionValue(handler *reporter.Handler, mc *internal.MessageContext, val ast.ValueNode, scopes []scope) error { + optVal := val.Value() + switch optVal := optVal.(type) { + case []ast.ValueNode: + origPath := mc.OptAggPath + defer func() { + mc.OptAggPath = origPath + }() + for i, v := range optVal { + mc.OptAggPath = fmt.Sprintf("%s[%d]", origPath, i) + if err := r.resolveOptionValue(handler, mc, v, scopes); err != nil { + return err + } + } + case []*ast.MessageFieldNode: + origPath := mc.OptAggPath + defer func() { + mc.OptAggPath = origPath + }() + for _, fld := range optVal { + // check for extension name + if fld.Name.IsExtension() { + // Confusingly, an extension reference inside a message literal cannot refer to + // elements in the same enclosing message without a qualifier. Basically, we + // treat this as if there were no message scopes, so only the package name is + // used for resolving relative references. (Inconsistent protoc behavior, but + // likely due to how it re-uses C++ text format implementation, and normal text + // format doesn't expect that kind of relative reference.) + scopes := scopes[:1] // first scope is file, the rest are enclosing messages + fqn, err := r.resolveExtensionName(string(fld.Name.Name.AsIdentifier()), scopes) + if err != nil { + if err := handler.HandleErrorf(r.FileNode().NodeInfo(fld.Name.Name).Start(), "%v%v", mc, err); err != nil { + return err + } + } else { + r.optionQualifiedNames[fld.Name.Name] = fqn + } + } + + // recurse into value + mc.OptAggPath = origPath + if origPath != "" { + mc.OptAggPath += "." + } + if fld.Name.IsExtension() { + mc.OptAggPath = fmt.Sprintf("%s[%s]", mc.OptAggPath, string(fld.Name.Name.AsIdentifier())) + } else { + mc.OptAggPath = fmt.Sprintf("%s%s", mc.OptAggPath, string(fld.Name.Name.AsIdentifier())) + } + + if err := r.resolveOptionValue(handler, mc, fld.Val, scopes); err != nil { + return err + } + } + } + return nil +} + +func (r *result) resolveExtensionName(name string, scopes []scope) (string, error) { + dsc := r.resolve(name, false, scopes) + if dsc == nil { + return "", fmt.Errorf("unknown extension %s", name) + } + if isSentinelDescriptor(dsc) { + return "", fmt.Errorf("unknown extension %s; resolved to %s which is not defined; consider using a leading dot", name, dsc.FullName()) + } + if ext, ok := dsc.(protoreflect.FieldDescriptor); !ok { + return "", fmt.Errorf("invalid extension: %s is %s, not an extension", name, descriptorTypeWithArticle(dsc)) + } else if !ext.IsExtension() { + return "", fmt.Errorf("invalid extension: %s is a field but not an extension", name) + } + return string("." + dsc.FullName()), nil +} + +func (r *result) resolve(name string, onlyTypes bool, scopes []scope) protoreflect.Descriptor { + if strings.HasPrefix(name, ".") { + // already fully-qualified + return r.resolveElement(protoreflect.FullName(name[1:])) + } + // unqualified, so we look in the enclosing (last) scope first and move + // towards outermost (first) scope, trying to resolve the symbol + pos := strings.IndexByte(name, '.') + firstName := name + if pos > 0 { + firstName = name[:pos] + } + var bestGuess protoreflect.Descriptor + for i := len(scopes) - 1; i >= 0; i-- { + d := scopes[i](firstName, name) + if d != nil { + // In `protoc`, it will skip a match of the wrong type and move on + // to the next scope, but only if the reference is unqualified. So + // we mirror that behavior here. When we skip and move on, we go + // ahead and save the match of the wrong type so we can at least use + // it to construct a better error in the event that we don't find + // any match of the right type. + if !onlyTypes || isType(d) || firstName != name { + return d + } + if bestGuess == nil { + bestGuess = d + } + } + } + // we return best guess, even though it was not an allowed kind of + // descriptor, so caller can print a better error message (e.g. + // indicating that the name was found but that it's the wrong type) + return bestGuess +} + +func isType(d protoreflect.Descriptor) bool { + switch d.(type) { + case protoreflect.MessageDescriptor, protoreflect.EnumDescriptor: + return true + } + return false +} + +// scope represents a lexical scope in a proto file in which messages and enums +// can be declared. +type scope func(firstName, fullName string) protoreflect.Descriptor + +func fileScope(r *result) scope { + // we search symbols in this file, but also symbols in other files that have + // the same package as this file or a "parent" package (in protobuf, + // packages are a hierarchy like C++ namespaces) + prefixes := internal.CreatePrefixList(r.FileDescriptorProto().GetPackage()) + querySymbol := func(n string) protoreflect.Descriptor { + return r.resolveElement(protoreflect.FullName(n)) + } + return func(firstName, fullName string) protoreflect.Descriptor { + for _, prefix := range prefixes { + var n1, n string + if prefix == "" { + // exhausted all prefixes, so it must be in this one + n1, n = fullName, fullName + } else { + n = prefix + "." + fullName + n1 = prefix + "." + firstName + } + d := resolveElementRelative(n1, n, querySymbol) + if d != nil { + return d + } + } + return nil + } +} + +func messageScope(r *result, messageName protoreflect.FullName) scope { + querySymbol := func(n string) protoreflect.Descriptor { + return resolveElementInFile(protoreflect.FullName(n), r) + } + return func(firstName, fullName string) protoreflect.Descriptor { + n1 := string(messageName) + "." + firstName + n := string(messageName) + "." + fullName + return resolveElementRelative(n1, n, querySymbol) + } +} + +func resolveElementRelative(firstName, fullName string, query func(name string) protoreflect.Descriptor) protoreflect.Descriptor { + d := query(firstName) + if d == nil { + return nil + } + if firstName == fullName { + return d + } + if !isAggregateDescriptor(d) { + // can't possibly find the rest of full name if + // the first name indicated a leaf descriptor + return nil + } + d = query(fullName) + if d == nil { + return newSentinelDescriptor(fullName) + } + return d +} + +func resolveElementInFile(name protoreflect.FullName, f File) protoreflect.Descriptor { + d := f.FindDescriptorByName(name) + if d != nil { + return d + } + + if matchesPkgNamespace(name, f.Package()) { + // this sentinel means the name is a valid namespace but + // does not refer to a descriptor + return newSentinelDescriptor(string(name)) + } + return nil +} + +func matchesPkgNamespace(fqn, pkg protoreflect.FullName) bool { + if pkg == "" { + return false + } + if fqn == pkg { + return true + } + if len(pkg) > len(fqn) && strings.HasPrefix(string(pkg), string(fqn)) { + // if char after fqn is a dot, then fqn is a namespace + if pkg[len(fqn)] == '.' { + return true + } + } + return false +} + +func isAggregateDescriptor(d protoreflect.Descriptor) bool { + if isSentinelDescriptor(d) { + // this indicates the name matched a package, not a + // descriptor, but a package is an aggregate, so + // we return true + return true + } + switch d.(type) { + case protoreflect.MessageDescriptor, protoreflect.EnumDescriptor, protoreflect.ServiceDescriptor: + return true + default: + return false + } +} + +func isSentinelDescriptor(d protoreflect.Descriptor) bool { + _, ok := d.(*sentinelDescriptor) + return ok +} + +func newSentinelDescriptor(name string) protoreflect.Descriptor { + return &sentinelDescriptor{name: name} +} + +// sentinelDescriptor is a placeholder descriptor. It is used instead of nil to +// distinguish between two situations: +// 1. The given name could not be found. +// 2. The given name *cannot* be a valid result so stop searching. +// +// In these cases, attempts to resolve an element name will return nil for the +// first case and will return a sentinelDescriptor in the second. The sentinel +// contains the fully-qualified name which caused the search to stop (which may +// be a prefix of the actual name being resolved). +type sentinelDescriptor struct { + protoreflect.Descriptor + name string +} + +func (p *sentinelDescriptor) ParentFile() protoreflect.FileDescriptor { + return nil +} + +func (p *sentinelDescriptor) Parent() protoreflect.Descriptor { + return nil +} + +func (p *sentinelDescriptor) Index() int { + return 0 +} + +func (p *sentinelDescriptor) Syntax() protoreflect.Syntax { + return 0 +} + +func (p *sentinelDescriptor) Name() protoreflect.Name { + return protoreflect.Name(p.name) +} + +func (p *sentinelDescriptor) FullName() protoreflect.FullName { + return protoreflect.FullName(p.name) +} + +func (p *sentinelDescriptor) IsPlaceholder() bool { + return false +} + +func (p *sentinelDescriptor) Options() protoreflect.ProtoMessage { + return nil +} + +var _ protoreflect.Descriptor = (*sentinelDescriptor)(nil) diff --git a/vendor/github.com/bufbuild/protocompile/linker/symbols.go b/vendor/github.com/bufbuild/protocompile/linker/symbols.go new file mode 100644 index 00000000000..ca2ffe478a1 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/symbols.go @@ -0,0 +1,557 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linker + +import ( + "strings" + "sync" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/reporter" + "github.com/bufbuild/protocompile/walk" +) + +// Symbols is a symbol table that maps names for all program elements to their +// location in source. It also tracks extension tag numbers. This can be used +// to enforce uniqueness for symbol names and tag numbers across many files and +// many link operations. +// +// This type is thread-safe. +type Symbols struct { + pkgTrie packageSymbols +} + +type packageSymbols struct { + mu sync.RWMutex + children map[protoreflect.FullName]*packageSymbols + files map[protoreflect.FileDescriptor]struct{} + symbols map[protoreflect.FullName]symbolEntry + exts map[extNumber]ast.SourcePos +} + +type extNumber struct { + extendee protoreflect.FullName + tag protoreflect.FieldNumber +} + +type symbolEntry struct { + pos ast.SourcePos + isEnumValue bool + isPackage bool +} + +// Import populates the symbol table with all symbols/elements and extension +// tags present in the given file descriptor. If s is nil or if fd has already +// been imported into s, this returns immediately without doing anything. If any +// collisions in symbol names or extension tags are identified, an error will be +// returned and the symbol table will not be updated. +func (s *Symbols) Import(fd protoreflect.FileDescriptor, handler *reporter.Handler) error { + if s == nil { + return nil + } + + if f, ok := fd.(*file); ok { + // unwrap any file instance + fd = f.FileDescriptor + } + + var pkgPos ast.SourcePos + if res, ok := fd.(*result); ok { + pkgPos = packageNameStart(res) + } else { + pkgPos = sourcePositionForPackage(fd) + } + pkg, err := s.importPackages(pkgPos, fd.Package(), handler) + if err != nil || pkg == nil { + return err + } + + pkg.mu.RLock() + _, alreadyImported := pkg.files[fd] + pkg.mu.RUnlock() + + if alreadyImported { + return nil + } + + for i := 0; i < fd.Imports().Len(); i++ { + if err := s.Import(fd.Imports().Get(i).FileDescriptor, handler); err != nil { + return err + } + } + + if res, ok := fd.(*result); ok && res.hasSource() { + return s.importResultWithExtensions(pkg, res, handler) + } + + return s.importFileWithExtensions(pkg, fd, handler) +} + +func (s *Symbols) importFileWithExtensions(pkg *packageSymbols, fd protoreflect.FileDescriptor, handler *reporter.Handler) error { + imported, err := pkg.importFile(fd, handler) + if err != nil { + return err + } + if !imported { + // nothing else to do + return nil + } + + return walk.Descriptors(fd, func(d protoreflect.Descriptor) error { + fld, ok := d.(protoreflect.FieldDescriptor) + if !ok || !fld.IsExtension() { + return nil + } + pos := sourcePositionForNumber(fld) + extendee := fld.ContainingMessage() + if err := s.AddExtension(extendee.ParentFile().Package(), extendee.FullName(), fld.Number(), pos, handler); err != nil { + return err + } + return nil + }) +} + +func (s *packageSymbols) importFile(fd protoreflect.FileDescriptor, handler *reporter.Handler) (bool, error) { + s.mu.Lock() + defer s.mu.Unlock() + + if _, ok := s.files[fd]; ok { + // have to double-check if it's already imported, in case + // it was added after above read-locked check + return false, nil + } + + // first pass: check for conflicts + if err := s.checkFileLocked(fd, handler); err != nil { + return false, err + } + if err := handler.Error(); err != nil { + return false, err + } + + // second pass: commit all symbols + s.commitFileLocked(fd) + + return true, nil +} + +func (s *Symbols) importPackages(pkgPos ast.SourcePos, pkg protoreflect.FullName, handler *reporter.Handler) (*packageSymbols, error) { + if pkg == "" { + return &s.pkgTrie, nil + } + + parts := strings.Split(string(pkg), ".") + for i := 1; i < len(parts); i++ { + parts[i] = parts[i-1] + "." + parts[i] + } + + cur := &s.pkgTrie + for _, p := range parts { + var err error + cur, err = cur.importPackage(pkgPos, protoreflect.FullName(p), handler) + if err != nil { + return nil, err + } + if cur == nil { + return nil, nil + } + } + + return cur, nil +} + +func (s *packageSymbols) importPackage(pkgPos ast.SourcePos, pkg protoreflect.FullName, handler *reporter.Handler) (*packageSymbols, error) { + s.mu.RLock() + existing, ok := s.symbols[pkg] + var child *packageSymbols + if ok && existing.isPackage { + child = s.children[pkg] + } + s.mu.RUnlock() + + if ok && existing.isPackage { + // package already exists + return child, nil + } else if ok { + return nil, reportSymbolCollision(pkgPos, pkg, false, existing, handler) + } + + s.mu.Lock() + defer s.mu.Unlock() + // have to double-check in case it was added while upgrading to write lock + existing, ok = s.symbols[pkg] + if ok && existing.isPackage { + // package already exists + return s.children[pkg], nil + } else if ok { + return nil, reportSymbolCollision(pkgPos, pkg, false, existing, handler) + } + if s.symbols == nil { + s.symbols = map[protoreflect.FullName]symbolEntry{} + } + s.symbols[pkg] = symbolEntry{pos: pkgPos, isPackage: true} + child = &packageSymbols{} + if s.children == nil { + s.children = map[protoreflect.FullName]*packageSymbols{} + } + s.children[pkg] = child + return child, nil +} + +func (s *Symbols) getPackage(pkg protoreflect.FullName) *packageSymbols { + if pkg == "" { + return &s.pkgTrie + } + + parts := strings.Split(string(pkg), ".") + for i := 1; i < len(parts); i++ { + parts[i] = parts[i-1] + "." + parts[i] + } + + cur := &s.pkgTrie + for _, p := range parts { + cur.mu.RLock() + next := cur.children[protoreflect.FullName(p)] + cur.mu.RUnlock() + + if next == nil { + return nil + } + cur = next + } + + return cur +} + +func reportSymbolCollision(pos ast.SourcePos, fqn protoreflect.FullName, additionIsEnumVal bool, existing symbolEntry, handler *reporter.Handler) error { + // because of weird scoping for enum values, provide more context in error message + // if this conflict is with an enum value + var isPkg, suffix string + if additionIsEnumVal || existing.isEnumValue { + suffix = "; protobuf uses C++ scoping rules for enum values, so they exist in the scope enclosing the enum" + } + if existing.isPackage { + isPkg = " as a package" + } + orig := existing.pos + conflict := pos + if posLess(conflict, orig) { + orig, conflict = conflict, orig + } + return handler.HandleErrorf(conflict, "symbol %q already defined%s at %v%s", fqn, isPkg, orig, suffix) +} + +func posLess(a, b ast.SourcePos) bool { + if a.Filename == b.Filename { + if a.Line == b.Line { + return a.Col < b.Col + } + return a.Line < b.Line + } + return false +} + +func (s *packageSymbols) checkFileLocked(f protoreflect.FileDescriptor, handler *reporter.Handler) error { + return walk.Descriptors(f, func(d protoreflect.Descriptor) error { + pos := sourcePositionFor(d) + if existing, ok := s.symbols[d.FullName()]; ok { + _, isEnumVal := d.(protoreflect.EnumValueDescriptor) + if err := reportSymbolCollision(pos, d.FullName(), isEnumVal, existing, handler); err != nil { + return err + } + } + return nil + }) +} + +func sourcePositionForPackage(fd protoreflect.FileDescriptor) ast.SourcePos { + loc := fd.SourceLocations().ByPath([]int32{internal.FilePackageTag}) + if isZeroLoc(loc) { + return ast.UnknownPos(fd.Path()) + } + return ast.SourcePos{ + Filename: fd.Path(), + Line: loc.StartLine, + Col: loc.StartColumn, + } +} + +func sourcePositionFor(d protoreflect.Descriptor) ast.SourcePos { + path, ok := computePath(d) + if !ok { + return ast.UnknownPos(d.ParentFile().Path()) + } + namePath := path + switch d.(type) { + case protoreflect.FieldDescriptor: + namePath = append(namePath, internal.FieldNameTag) + case protoreflect.MessageDescriptor: + namePath = append(namePath, internal.MessageNameTag) + case protoreflect.OneofDescriptor: + namePath = append(namePath, internal.OneOfNameTag) + case protoreflect.EnumDescriptor: + namePath = append(namePath, internal.EnumNameTag) + case protoreflect.EnumValueDescriptor: + namePath = append(namePath, internal.EnumValNameTag) + case protoreflect.ServiceDescriptor: + namePath = append(namePath, internal.ServiceNameTag) + case protoreflect.MethodDescriptor: + namePath = append(namePath, internal.MethodNameTag) + default: + // NB: shouldn't really happen, but just in case fall back to path to + // descriptor, sans name field + } + loc := d.ParentFile().SourceLocations().ByPath(namePath) + if isZeroLoc(loc) { + loc = d.ParentFile().SourceLocations().ByPath(path) + if isZeroLoc(loc) { + return ast.UnknownPos(d.ParentFile().Path()) + } + } + return ast.SourcePos{ + Filename: d.ParentFile().Path(), + Line: loc.StartLine, + Col: loc.StartColumn, + } +} + +func sourcePositionForNumber(fd protoreflect.FieldDescriptor) ast.SourcePos { + path, ok := computePath(fd) + if !ok { + return ast.UnknownPos(fd.ParentFile().Path()) + } + numberPath := path + numberPath = append(numberPath, internal.FieldNumberTag) + loc := fd.ParentFile().SourceLocations().ByPath(numberPath) + if isZeroLoc(loc) { + loc = fd.ParentFile().SourceLocations().ByPath(path) + if isZeroLoc(loc) { + return ast.UnknownPos(fd.ParentFile().Path()) + } + } + return ast.SourcePos{ + Filename: fd.ParentFile().Path(), + Line: loc.StartLine, + Col: loc.StartColumn, + } +} + +func isZeroLoc(loc protoreflect.SourceLocation) bool { + return loc.Path == nil && + loc.StartLine == 0 && + loc.StartColumn == 0 && + loc.EndLine == 0 && + loc.EndColumn == 0 +} + +func (s *packageSymbols) commitFileLocked(f protoreflect.FileDescriptor) { + if s.symbols == nil { + s.symbols = map[protoreflect.FullName]symbolEntry{} + } + if s.exts == nil { + s.exts = map[extNumber]ast.SourcePos{} + } + _ = walk.Descriptors(f, func(d protoreflect.Descriptor) error { + pos := sourcePositionFor(d) + name := d.FullName() + _, isEnumValue := d.(protoreflect.EnumValueDescriptor) + s.symbols[name] = symbolEntry{pos: pos, isEnumValue: isEnumValue} + return nil + }) + + if s.files == nil { + s.files = map[protoreflect.FileDescriptor]struct{}{} + } + s.files[f] = struct{}{} +} + +func (s *Symbols) importResultWithExtensions(pkg *packageSymbols, r *result, handler *reporter.Handler) error { + imported, err := pkg.importResult(r, handler) + if err != nil { + return err + } + if !imported { + // nothing else to do + return nil + } + + return walk.Descriptors(r, func(d protoreflect.Descriptor) error { + fd, ok := d.(*extTypeDescriptor) + if !ok { + return nil + } + file := r.FileNode() + node := r.FieldNode(fd.FieldDescriptorProto()) + pos := file.NodeInfo(node.FieldTag()).Start() + extendee := fd.ContainingMessage() + if err := s.AddExtension(extendee.ParentFile().Package(), extendee.FullName(), fd.Number(), pos, handler); err != nil { + return err + } + + return nil + }) +} + +func (s *Symbols) importResult(r *result, handler *reporter.Handler) error { + pkg, err := s.importPackages(packageNameStart(r), r.Package(), handler) + if err != nil || pkg == nil { + return err + } + _, err = pkg.importResult(r, handler) + return err +} + +func (s *packageSymbols) importResult(r *result, handler *reporter.Handler) (bool, error) { + s.mu.Lock() + defer s.mu.Unlock() + + if _, ok := s.files[r]; ok { + // already imported + return false, nil + } + + // first pass: check for conflicts + if err := s.checkResultLocked(r, handler); err != nil { + return false, err + } + if err := handler.Error(); err != nil { + return false, err + } + + // second pass: commit all symbols + s.commitResultLocked(r) + + return true, nil +} + +func (s *packageSymbols) checkResultLocked(r *result, handler *reporter.Handler) error { + resultSyms := map[protoreflect.FullName]symbolEntry{} + return walk.DescriptorProtos(r.FileDescriptorProto(), func(fqn protoreflect.FullName, d proto.Message) error { + _, isEnumVal := d.(*descriptorpb.EnumValueDescriptorProto) + file := r.FileNode() + node := r.Node(d) + pos := nameStart(file, node) + // check symbols already in this symbol table + if existing, ok := s.symbols[fqn]; ok { + if err := reportSymbolCollision(pos, fqn, isEnumVal, existing, handler); err != nil { + return err + } + } + + // also check symbols from this result (that are not yet in symbol table) + if existing, ok := resultSyms[fqn]; ok { + if err := reportSymbolCollision(pos, fqn, isEnumVal, existing, handler); err != nil { + return err + } + } + resultSyms[fqn] = symbolEntry{ + pos: pos, + isEnumValue: isEnumVal, + } + + return nil + }) +} + +func packageNameStart(r *result) ast.SourcePos { + if node, ok := r.FileNode().(*ast.FileNode); ok { + for _, decl := range node.Decls { + if pkgNode, ok := decl.(*ast.PackageNode); ok { + return r.FileNode().NodeInfo(pkgNode.Name).Start() + } + } + } + return ast.UnknownPos(r.Path()) +} + +func nameStart(file ast.FileDeclNode, n ast.Node) ast.SourcePos { + // TODO: maybe ast package needs a NamedNode interface to simplify this? + switch n := n.(type) { + case ast.FieldDeclNode: + return file.NodeInfo(n.FieldName()).Start() + case ast.MessageDeclNode: + return file.NodeInfo(n.MessageName()).Start() + case ast.OneOfDeclNode: + return file.NodeInfo(n.OneOfName()).Start() + case ast.EnumValueDeclNode: + return file.NodeInfo(n.GetName()).Start() + case *ast.EnumNode: + return file.NodeInfo(n.Name).Start() + case *ast.ServiceNode: + return file.NodeInfo(n.Name).Start() + case ast.RPCDeclNode: + return file.NodeInfo(n.GetName()).Start() + default: + return file.NodeInfo(n).Start() + } +} + +func (s *packageSymbols) commitResultLocked(r *result) { + if s.symbols == nil { + s.symbols = map[protoreflect.FullName]symbolEntry{} + } + if s.exts == nil { + s.exts = map[extNumber]ast.SourcePos{} + } + _ = walk.DescriptorProtos(r.FileDescriptorProto(), func(fqn protoreflect.FullName, d proto.Message) error { + pos := nameStart(r.FileNode(), r.Node(d)) + _, isEnumValue := d.(protoreflect.EnumValueDescriptor) + s.symbols[fqn] = symbolEntry{pos: pos, isEnumValue: isEnumValue} + return nil + }) + + if s.files == nil { + s.files = map[protoreflect.FileDescriptor]struct{}{} + } + s.files[r] = struct{}{} +} + +func (s *Symbols) AddExtension(pkg, extendee protoreflect.FullName, tag protoreflect.FieldNumber, pos ast.SourcePos, handler *reporter.Handler) error { + if pkg != "" { + if !strings.HasPrefix(string(extendee), string(pkg)+".") { + return handler.HandleErrorf(pos, "could not register extension: extendee %q does not match package %q", extendee, pkg) + } + } + pkgSyms := s.getPackage(pkg) + if pkgSyms == nil { + // should never happen + return handler.HandleErrorf(pos, "could not register extension: missing package symbols for %q", pkg) + } + return pkgSyms.addExtension(extendee, tag, pos, handler) +} + +func (s *packageSymbols) addExtension(extendee protoreflect.FullName, tag protoreflect.FieldNumber, pos ast.SourcePos, handler *reporter.Handler) error { + s.mu.Lock() + defer s.mu.Unlock() + + if s.exts == nil { + s.exts = map[extNumber]ast.SourcePos{} + } + + extNum := extNumber{extendee: extendee, tag: tag} + if existing, ok := s.exts[extNum]; ok { + if err := handler.HandleErrorf(pos, "extension with tag %d for message %s already defined at %v", tag, extendee, existing); err != nil { + return err + } + } else { + s.exts[extNum] = pos + } + return nil +} diff --git a/vendor/github.com/bufbuild/protocompile/linker/validate.go b/vendor/github.com/bufbuild/protocompile/linker/validate.go new file mode 100644 index 00000000000..f30c5718656 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/linker/validate.go @@ -0,0 +1,283 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linker + +import ( + "fmt" + "strings" + "unicode" + "unicode/utf8" + + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/reporter" +) + +// ValidateOptions runs some validation checks on the result that can only +// be done after options are interpreted. +func (r *result) ValidateOptions(handler *reporter.Handler) error { + if err := r.validateExtensions(r, handler); err != nil { + return err + } + return r.validateJSONNamesInFile(handler) +} + +func (r *result) validateExtensions(d hasExtensionsAndMessages, handler *reporter.Handler) error { + for i := 0; i < d.Extensions().Len(); i++ { + if err := r.validateExtension(d.Extensions().Get(i), handler); err != nil { + return err + } + } + for i := 0; i < d.Messages().Len(); i++ { + if err := r.validateExtensions(d.Messages().Get(i), handler); err != nil { + return err + } + } + return nil +} + +func (r *result) validateExtension(fld protoreflect.FieldDescriptor, handler *reporter.Handler) error { + // NB: It's a little gross that we don't enforce these in validateBasic(). + // But it requires linking to resolve the extendee, so we can interrogate + // its descriptor. + if xtd, ok := fld.(protoreflect.ExtensionTypeDescriptor); ok { + fld = xtd.Descriptor() + } + fd := fld.(*fldDescriptor) //nolint:errcheck + if fld.ContainingMessage().Options().(*descriptorpb.MessageOptions).GetMessageSetWireFormat() { + // Message set wire format requires that all extensions be messages + // themselves (no scalar extensions) + if fld.Kind() != protoreflect.MessageKind { + file := r.FileNode() + pos := file.NodeInfo(r.FieldNode(fd.proto).FieldType()).Start() + return handler.HandleErrorf(pos, "messages with message-set wire format cannot contain scalar extensions, only messages") + } + if fld.Cardinality() == protoreflect.Repeated { + file := r.FileNode() + pos := file.NodeInfo(r.FieldNode(fd.proto).FieldLabel()).Start() + return handler.HandleErrorf(pos, "messages with message-set wire format cannot contain repeated extensions, only optional") + } + } else if fld.Number() > internal.MaxNormalTag { + // In validateBasic() we just made sure these were within bounds for any message. But + // now that things are linked, we can check if the extendee is messageset wire format + // and, if not, enforce tighter limit. + file := r.FileNode() + pos := file.NodeInfo(r.FieldNode(fd.proto).FieldTag()).Start() + return handler.HandleErrorf(pos, "tag number %d is higher than max allowed tag number (%d)", fld.Number(), internal.MaxNormalTag) + } + + return nil +} + +func (r *result) validateJSONNamesInFile(handler *reporter.Handler) error { + for _, md := range r.FileDescriptorProto().GetMessageType() { + if err := r.validateJSONNamesInMessage(md, handler); err != nil { + return err + } + } + for _, ed := range r.FileDescriptorProto().GetEnumType() { + if err := r.validateJSONNamesInEnum(ed, handler); err != nil { + return err + } + } + return nil +} + +func (r *result) validateJSONNamesInMessage(md *descriptorpb.DescriptorProto, handler *reporter.Handler) error { + if err := r.validateFieldJSONNames(md, false, handler); err != nil { + return err + } + if err := r.validateFieldJSONNames(md, true, handler); err != nil { + return err + } + + for _, nmd := range md.GetNestedType() { + if err := r.validateJSONNamesInMessage(nmd, handler); err != nil { + return err + } + } + for _, ed := range md.GetEnumType() { + if err := r.validateJSONNamesInEnum(ed, handler); err != nil { + return err + } + } + return nil +} + +func (r *result) validateJSONNamesInEnum(ed *descriptorpb.EnumDescriptorProto, handler *reporter.Handler) error { + seen := map[string]*descriptorpb.EnumValueDescriptorProto{} + for _, evd := range ed.GetValue() { + scope := "enum value " + ed.GetName() + "." + evd.GetName() + + name := canonicalEnumValueName(evd.GetName(), ed.GetName()) + if existing, ok := seen[name]; ok && evd.GetNumber() != existing.GetNumber() { + fldNode := r.EnumValueNode(evd) + existingNode := r.EnumValueNode(existing) + conflictErr := fmt.Errorf("%s: camel-case name (with optional enum name prefix removed) %q conflicts with camel-case name of enum value %s, defined at %v", + scope, name, existing.GetName(), r.FileNode().NodeInfo(existingNode).Start()) + + // Since proto2 did not originally have a JSON format, we report conflicts as just warnings + if r.Syntax() != protoreflect.Proto3 { + handler.HandleWarningWithPos(r.FileNode().NodeInfo(fldNode).Start(), conflictErr) + } else if err := handler.HandleErrorf(r.FileNode().NodeInfo(fldNode).Start(), conflictErr.Error()); err != nil { + return err + } + } else { + seen[name] = evd + } + } + return nil +} + +func (r *result) validateFieldJSONNames(md *descriptorpb.DescriptorProto, useCustom bool, handler *reporter.Handler) error { + type jsonName struct { + source *descriptorpb.FieldDescriptorProto + // true if orig is a custom JSON name (vs. the field's default JSON name) + custom bool + } + seen := map[string]jsonName{} + + for _, fd := range md.GetField() { + scope := "field " + md.GetName() + "." + fd.GetName() + defaultName := internal.JSONName(fd.GetName()) + name := defaultName + custom := false + if useCustom { + n := fd.GetJsonName() + if n != defaultName || r.hasCustomJSONName(fd) { + name = n + custom = true + } + } + if existing, ok := seen[name]; ok { + // When useCustom is true, we'll only report an issue when a conflict is + // due to a custom name. That way, we don't double report conflicts on + // non-custom names. + if !useCustom || custom || existing.custom { + fldNode := r.FieldNode(fd) + customStr, srcCustomStr := "custom", "custom" + if !custom { + customStr = "default" + } + if !existing.custom { + srcCustomStr = "default" + } + pos := r.FileNode().NodeInfo(fldNode).Start() + conflictErr := reporter.Errorf(pos, "%s: %s JSON name %q conflicts with %s JSON name of field %s, defined at %v", + scope, customStr, name, srcCustomStr, existing.source.GetName(), r.FileNode().NodeInfo(r.FieldNode(existing.source)).Start()) + + // Since proto2 did not originally have default JSON names, we report conflicts + // between default names (neither is a custom name) as just warnings. + if r.Syntax() != protoreflect.Proto3 && !custom && !existing.custom { + handler.HandleWarning(conflictErr) + } else if err := handler.HandleError(conflictErr); err != nil { + return err + } + } + } else { + seen[name] = jsonName{source: fd, custom: custom} + } + } + return nil +} + +func (r *result) hasCustomJSONName(fdProto *descriptorpb.FieldDescriptorProto) bool { + // if we have the AST, we can more precisely determine if there was a custom + // JSON named defined, even if it is explicitly configured to tbe the same + // as the default JSON name for the field. + opts := r.FieldNode(fdProto).GetOptions() + if opts == nil { + return false + } + for _, opt := range opts.Options { + if len(opt.Name.Parts) == 1 && + opt.Name.Parts[0].Name.AsIdentifier() == "json_name" && + !opt.Name.Parts[0].IsExtension() { + return true + } + } + return false +} + +func canonicalEnumValueName(enumValueName, enumName string) string { + return enumValCamelCase(removePrefix(enumValueName, enumName)) +} + +// removePrefix is used to remove the given prefix from the given str. It does not require +// an exact match and ignores case and underscores. If the all non-underscore characters +// would be removed from str, str is returned unchanged. If str does not have the given +// prefix (even with the very lenient matching, in regard to case and underscores), then +// str is returned unchanged. +// +// The algorithm is adapted from the protoc source: +// +// https://github.com/protocolbuffers/protobuf/blob/v21.3/src/google/protobuf/descriptor.cc#L922 +func removePrefix(str, prefix string) string { + j := 0 + for i, r := range str { + if r == '_' { + // skip underscores in the input + continue + } + + p, sz := utf8.DecodeRuneInString(prefix[j:]) + for p == '_' { + j += sz // consume/skip underscore + p, sz = utf8.DecodeRuneInString(prefix[j:]) + } + + if j == len(prefix) { + // matched entire prefix; return rest of str + // but skipping any leading underscores + result := strings.TrimLeft(str[i:], "_") + if len(result) == 0 { + // result can't be empty string + return str + } + return result + } + if unicode.ToLower(r) != unicode.ToLower(p) { + // does not match prefix + return str + } + j += sz // consume matched rune of prefix + } + return str +} + +// enumValCamelCase converts the given string to upper-camel-case. +// +// The algorithm is adapted from the protoc source: +// +// https://github.com/protocolbuffers/protobuf/blob/v21.3/src/google/protobuf/descriptor.cc#L887 +func enumValCamelCase(name string) string { + var js []rune + nextUpper := true + for _, r := range name { + if r == '_' { + nextUpper = true + continue + } + if nextUpper { + nextUpper = false + js = append(js, unicode.ToUpper(r)) + } else { + js = append(js, unicode.ToLower(r)) + } + } + return string(js) +} diff --git a/vendor/github.com/bufbuild/protocompile/options/options.go b/vendor/github.com/bufbuild/protocompile/options/options.go new file mode 100644 index 00000000000..634a9013e70 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/options/options.go @@ -0,0 +1,1525 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package options contains the logic for interpreting options. The parse step +// of compilation stores the options in uninterpreted form, which contains raw +// identifiers and literal values. +// +// The process of interpreting an option is to resolve identifiers, by examining +// descriptors for the google.protobuf.*Options types and their available +// extensions (custom options). As field names are resolved, the values can be +// type-checked against the types indicated in field descriptors. +// +// On success, the various fields and extensions of the options message are +// populated and the field holding the uninterpreted form is cleared. +package options + +import ( + "bytes" + "fmt" + "math" + "sort" + "strings" + + "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + "google.golang.org/protobuf/types/dynamicpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/linker" + "github.com/bufbuild/protocompile/parser" + "github.com/bufbuild/protocompile/reporter" +) + +// Index is a mapping of AST nodes that define options to a corresponding path +// into the containing file descriptor. The path is a sequence of field tags +// and indexes that define a traversal path from the root (the file descriptor) +// to the resolved option field. +type Index map[*ast.OptionNode][]int32 + +type interpreter struct { + file file + resolver linker.Resolver + container optionsContainer + lenient bool + reporter *reporter.Handler + index Index +} + +type file interface { + parser.Result + ResolveEnumType(protoreflect.FullName) protoreflect.EnumDescriptor + ResolveMessageType(protoreflect.FullName) protoreflect.MessageDescriptor + ResolveExtension(protoreflect.FullName) protoreflect.ExtensionTypeDescriptor + ResolveMessageLiteralExtensionName(ast.IdentValueNode) string +} + +type noResolveFile struct { + parser.Result +} + +func (n noResolveFile) ResolveEnumType(name protoreflect.FullName) protoreflect.EnumDescriptor { + return nil +} + +func (n noResolveFile) ResolveMessageType(name protoreflect.FullName) protoreflect.MessageDescriptor { + return nil +} + +func (n noResolveFile) ResolveExtension(name protoreflect.FullName) protoreflect.ExtensionTypeDescriptor { + return nil +} + +func (n noResolveFile) ResolveMessageLiteralExtensionName(ast.IdentValueNode) string { + return "" +} + +// InterpretOptions interprets options in the given linked result, returning +// an index that can be used to generate source code info. This step mutates +// the linked result's underlying proto to move option elements out of the +// "uninterpreted_option" fields and into proper option fields and extensions. +// +// The given handler is used to report errors and warnings. If any errors are +// reported, this function returns a non-nil error. +func InterpretOptions(linked linker.Result, handler *reporter.Handler) (Index, error) { + return interpretOptions(false, linked, handler) +} + +// InterpretOptionsLenient interprets options in a lenient/best-effort way in +// the given linked result, returning an index that can be used to generate +// source code info. This step mutates the linked result's underlying proto to +// move option elements out of the "uninterpreted_option" fields and into proper +// option fields and extensions. +// +// In lenient more, errors resolving option names and type errors are ignored. +// Any options that are uninterpretable (due to such errors) will remain in the +// "uninterpreted_option" fields. +func InterpretOptionsLenient(linked linker.Result) (Index, error) { + return interpretOptions(true, linked, reporter.NewHandler(nil)) +} + +// InterpretUnlinkedOptions does a best-effort attempt to interpret options in +// the given parsed result, returning an index that can be used to generate +// source code info. This step mutates the parsed result's underlying proto to +// move option elements out of the "uninterpreted_option" fields and into proper +// option fields and extensions. +// +// This is the same as InterpretOptionsLenient except that it accepts an +// unlinked result. Because the file is unlinked, custom options cannot be +// interpreted. Other errors resolving option names or type errors will be +// effectively ignored. Any options that are uninterpretable (due to such +// errors) will remain in the "uninterpreted_option" fields. +func InterpretUnlinkedOptions(parsed parser.Result) (Index, error) { + return interpretOptions(true, noResolveFile{parsed}, reporter.NewHandler(nil)) +} + +func interpretOptions(lenient bool, file file, handler *reporter.Handler) (Index, error) { + interp := interpreter{ + file: file, + lenient: lenient, + reporter: handler, + index: Index{}, + } + interp.container, _ = file.(optionsContainer) + if f, ok := file.(linker.File); ok { + interp.resolver = linker.ResolverFromFile(f) + } + + fd := file.FileDescriptorProto() + prefix := fd.GetPackage() + if prefix != "" { + prefix += "." + } + opts := fd.GetOptions() + if opts != nil { + if len(opts.UninterpretedOption) > 0 { + remain, err := interp.interpretOptions(fd.GetName(), fd, opts, opts.UninterpretedOption) + if err != nil { + return nil, err + } + opts.UninterpretedOption = remain + } + } + for _, md := range fd.GetMessageType() { + fqn := prefix + md.GetName() + if err := interp.interpretMessageOptions(fqn, md); err != nil { + return nil, err + } + } + for _, fld := range fd.GetExtension() { + fqn := prefix + fld.GetName() + if err := interp.interpretFieldOptions(fqn, fld); err != nil { + return nil, err + } + } + for _, ed := range fd.GetEnumType() { + fqn := prefix + ed.GetName() + if err := interp.interpretEnumOptions(fqn, ed); err != nil { + return nil, err + } + } + for _, sd := range fd.GetService() { + fqn := prefix + sd.GetName() + opts := sd.GetOptions() + if len(opts.GetUninterpretedOption()) > 0 { + remain, err := interp.interpretOptions(fqn, sd, opts, opts.UninterpretedOption) + if err != nil { + return nil, err + } + opts.UninterpretedOption = remain + } + for _, mtd := range sd.GetMethod() { + mtdFqn := fqn + "." + mtd.GetName() + opts := mtd.GetOptions() + if len(opts.GetUninterpretedOption()) > 0 { + remain, err := interp.interpretOptions(mtdFqn, mtd, opts, opts.UninterpretedOption) + if err != nil { + return nil, err + } + opts.UninterpretedOption = remain + } + } + } + return interp.index, nil +} + +func (interp *interpreter) nodeInfo(n ast.Node) ast.NodeInfo { + return interp.file.FileNode().NodeInfo(n) +} + +func (interp *interpreter) interpretMessageOptions(fqn string, md *descriptorpb.DescriptorProto) error { + opts := md.GetOptions() + if opts != nil { + if len(opts.UninterpretedOption) > 0 { + remain, err := interp.interpretOptions(fqn, md, opts, opts.UninterpretedOption) + if err != nil { + return err + } + opts.UninterpretedOption = remain + } + } + for _, fld := range md.GetField() { + fldFqn := fqn + "." + fld.GetName() + if err := interp.interpretFieldOptions(fldFqn, fld); err != nil { + return err + } + } + for _, ood := range md.GetOneofDecl() { + oodFqn := fqn + "." + ood.GetName() + opts := ood.GetOptions() + if len(opts.GetUninterpretedOption()) > 0 { + remain, err := interp.interpretOptions(oodFqn, ood, opts, opts.UninterpretedOption) + if err != nil { + return err + } + opts.UninterpretedOption = remain + } + } + for _, fld := range md.GetExtension() { + fldFqn := fqn + "." + fld.GetName() + if err := interp.interpretFieldOptions(fldFqn, fld); err != nil { + return err + } + } + for _, er := range md.GetExtensionRange() { + erFqn := fmt.Sprintf("%s.%d-%d", fqn, er.GetStart(), er.GetEnd()) + opts := er.GetOptions() + if len(opts.GetUninterpretedOption()) > 0 { + remain, err := interp.interpretOptions(erFqn, er, opts, opts.UninterpretedOption) + if err != nil { + return err + } + opts.UninterpretedOption = remain + } + } + for _, nmd := range md.GetNestedType() { + nmdFqn := fqn + "." + nmd.GetName() + if err := interp.interpretMessageOptions(nmdFqn, nmd); err != nil { + return err + } + } + for _, ed := range md.GetEnumType() { + edFqn := fqn + "." + ed.GetName() + if err := interp.interpretEnumOptions(edFqn, ed); err != nil { + return err + } + } + return nil +} + +func (interp *interpreter) interpretFieldOptions(fqn string, fld *descriptorpb.FieldDescriptorProto) error { + opts := fld.GetOptions() + if len(opts.GetUninterpretedOption()) == 0 { + return nil + } + uo := opts.UninterpretedOption + scope := fmt.Sprintf("field %s", fqn) + + // process json_name pseudo-option + index, err := internal.FindOption(interp.file, interp.reporter, scope, uo, "json_name") + if err != nil && !interp.lenient { + return err + } + if index >= 0 { + opt := uo[index] + optNode := interp.file.OptionNode(opt) + if fld.GetExtendee() != "" { + return interp.reporter.HandleErrorf(interp.nodeInfo(optNode.GetName()).Start(), "%s: option json_name is not allowed on extensions", scope) + } + // attribute source code info + if on, ok := optNode.(*ast.OptionNode); ok { + interp.index[on] = []int32{-1, internal.FieldJSONNameTag} + } + uo = internal.RemoveOption(uo, index) + if opt.StringValue == nil { + return interp.reporter.HandleErrorf(interp.nodeInfo(optNode.GetValue()).Start(), "%s: expecting string value for json_name option", scope) + } + name := string(opt.StringValue) + if strings.HasPrefix(name, "[") && strings.HasSuffix(name, "]") { + return interp.reporter.HandleErrorf(interp.nodeInfo(optNode.GetValue()).Start(), "%s: option json_name value cannot start with '[' and end with ']'; that is reserved for representing extensions", scope) + } + fld.JsonName = proto.String(name) + } + + // and process default pseudo-option + if index, err := interp.processDefaultOption(scope, fqn, fld, uo); err != nil && !interp.lenient { + return err + } else if index >= 0 { + // attribute source code info + optNode := interp.file.OptionNode(uo[index]) + if on, ok := optNode.(*ast.OptionNode); ok { + interp.index[on] = []int32{-1, internal.FieldDefaultTag} + } + uo = internal.RemoveOption(uo, index) + } + + if len(uo) == 0 { + // no real options, only pseudo-options above? clear out options + fld.Options = nil + } else if remain, err := interp.interpretOptions(fqn, fld, opts, uo); err != nil { + return err + } else { + opts.UninterpretedOption = remain + } + return nil +} + +func (interp *interpreter) processDefaultOption(scope string, fqn string, fld *descriptorpb.FieldDescriptorProto, uos []*descriptorpb.UninterpretedOption) (defaultIndex int, err error) { + found, err := internal.FindOption(interp.file, interp.reporter, scope, uos, "default") + if err != nil || found == -1 { + return -1, err + } + opt := uos[found] + optNode := interp.file.OptionNode(opt) + if fld.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED { + return -1, interp.reporter.HandleErrorf(interp.nodeInfo(optNode.GetName()).Start(), "%s: default value cannot be set because field is repeated", scope) + } + if fld.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP || fld.GetType() == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE { + return -1, interp.reporter.HandleErrorf(interp.nodeInfo(optNode.GetName()).Start(), "%s: default value cannot be set because field is a message", scope) + } + val := optNode.GetValue() + if _, ok := val.(*ast.MessageLiteralNode); ok { + return -1, interp.reporter.HandleErrorf(interp.nodeInfo(val).Start(), "%s: default value cannot be a message", scope) + } + mc := &internal.MessageContext{ + File: interp.file, + ElementName: fqn, + ElementType: descriptorType(fld), + Option: opt, + } + var v interface{} + if fld.GetType() == descriptorpb.FieldDescriptorProto_TYPE_ENUM { + ed := interp.file.ResolveEnumType(protoreflect.FullName(fld.GetTypeName())) + ev, err := interp.enumFieldValue(mc, ed, val) + if err != nil { + return -1, interp.reporter.HandleError(err) + } + v = string(ev.Name()) + } else { + v, err = interp.scalarFieldValue(mc, fld.GetType(), val, false) + if err != nil { + return -1, interp.reporter.HandleError(err) + } + } + if str, ok := v.(string); ok { + fld.DefaultValue = proto.String(str) + } else if b, ok := v.([]byte); ok { + fld.DefaultValue = proto.String(encodeDefaultBytes(b)) + } else { + var flt float64 + var ok bool + if flt, ok = v.(float64); !ok { + var flt32 float32 + if flt32, ok = v.(float32); ok { + flt = float64(flt32) + } + } + if ok { + switch { + case math.IsInf(flt, 1): + fld.DefaultValue = proto.String("inf") + case math.IsInf(flt, -1): + fld.DefaultValue = proto.String("-inf") + case math.IsNaN(flt): + fld.DefaultValue = proto.String("nan") + default: + fld.DefaultValue = proto.String(fmt.Sprintf("%v", v)) + } + } else { + fld.DefaultValue = proto.String(fmt.Sprintf("%v", v)) + } + } + return found, nil +} + +func encodeDefaultBytes(b []byte) string { + var buf bytes.Buffer + internal.WriteEscapedBytes(&buf, b) + return buf.String() +} + +func (interp *interpreter) interpretEnumOptions(fqn string, ed *descriptorpb.EnumDescriptorProto) error { + opts := ed.GetOptions() + if opts != nil { + if len(opts.UninterpretedOption) > 0 { + remain, err := interp.interpretOptions(fqn, ed, opts, opts.UninterpretedOption) + if err != nil { + return err + } + opts.UninterpretedOption = remain + } + } + for _, evd := range ed.GetValue() { + evdFqn := fqn + "." + evd.GetName() + opts := evd.GetOptions() + if len(opts.GetUninterpretedOption()) > 0 { + remain, err := interp.interpretOptions(evdFqn, evd, opts, opts.UninterpretedOption) + if err != nil { + return err + } + opts.UninterpretedOption = remain + } + } + return nil +} + +// interpretedOption represents the result of interpreting an option. +// This includes metadata that allows the option to be serialized to +// bytes in a way that is deterministic and can preserve the structure +// of the source (the way the options are de-structured and the order in +// which options appear). +type interpretedOption struct { + unknown bool + pathPrefix []int32 + interpretedField +} + +func (o *interpretedOption) path() []int32 { + path := o.pathPrefix + path = append(path, o.number) + if o.repeated { + path = append(path, o.index) + } + return path +} + +func (o *interpretedOption) appendOptionBytes(b []byte) ([]byte, error) { + return o.appendOptionBytesWithPath(b, o.pathPrefix) +} + +func (o *interpretedOption) appendOptionBytesWithPath(b []byte, path []int32) ([]byte, error) { + if len(path) == 0 { + return appendOptionBytesSingle(b, &o.interpretedField) + } + // NB: if we add functions to compute sizes of the options first, we could + // allocate precisely sized slice up front, which would be more efficient than + // repeated creation/growing/concatenation. + enclosed, err := o.appendOptionBytesWithPath(nil, path[1:]) + if err != nil { + return nil, err + } + b = protowire.AppendTag(b, protowire.Number(path[0]), protowire.BytesType) + return protowire.AppendBytes(b, enclosed), nil +} + +// interpretedField represents a field in an options message that is the +// result of interpreting an option. This is used for the option value +// itself as well as for subfields when an option value is a message +// literal. +type interpretedField struct { + // field number + number int32 + // index of this element inside a repeated field; only set if repeated == true + index int32 + // true if this is a repeated field + repeated bool + // true if this is a repeated field that stores scalar values in packed form + packed bool + // the field's kind + kind protoreflect.Kind + + value interpretedFieldValue +} + +// interpretedFieldValue is a wrapper around protoreflect.Value that +// includes extra metadata. +type interpretedFieldValue struct { + // the field value + val protoreflect.Value + // if true, this value is a list of values, not a singular value + isList bool + // non-nil for singular message values + msgVal []*interpretedField + // non-nil for non-empty lists of message values + msgListVal [][]*interpretedField +} + +func appendOptionBytes(b []byte, flds []*interpretedField) ([]byte, error) { + // protoc emits messages sorted by field number + if len(flds) > 1 { + sort.SliceStable(flds, func(i, j int) bool { + return flds[i].number < flds[j].number + }) + } + + for i := 0; i < len(flds); i++ { + f := flds[i] + switch { + case f.packed && canPack(f.kind): + // for packed repeated numeric fields, all runs of values are merged into one packed list + num := f.number + j := i + for j < len(flds) && flds[j].number == num { + j++ + } + // now flds[i:j] is the range of contiguous fields for the same field number + enclosed, err := appendOptionBytesPacked(nil, f.kind, flds[i:j]) + if err != nil { + return nil, err + } + b = protowire.AppendTag(b, protowire.Number(f.number), protowire.BytesType) + b = protowire.AppendBytes(b, enclosed) + // skip over the other subsequent fields we just serialized + i = j - 1 + case f.value.isList: + // if not packed, then emit one value at a time + single := *f + single.value.isList = false + single.value.msgListVal = nil + l := f.value.val.List() + for i := 0; i < l.Len(); i++ { + single.value.val = l.Get(i) + if f.kind == protoreflect.MessageKind || f.kind == protoreflect.GroupKind { + single.value.msgVal = f.value.msgListVal[i] + } + var err error + b, err = appendOptionBytesSingle(b, &single) + if err != nil { + return nil, err + } + } + default: + // simple singular value + var err error + b, err = appendOptionBytesSingle(b, f) + if err != nil { + return nil, err + } + } + } + + return b, nil +} + +func canPack(k protoreflect.Kind) bool { + switch k { + case protoreflect.MessageKind, protoreflect.GroupKind, protoreflect.StringKind, protoreflect.BytesKind: + return false + default: + return true + } +} + +func appendOptionBytesPacked(b []byte, k protoreflect.Kind, flds []*interpretedField) ([]byte, error) { + for i := range flds { + val := flds[i].value + if val.isList { + l := val.val.List() + var err error + b, err = appendNumericValueBytesPacked(b, k, l) + if err != nil { + return nil, err + } + } else { + var err error + b, err = appendNumericValueBytes(b, k, val.val) + if err != nil { + return nil, err + } + } + } + return b, nil +} + +func appendOptionBytesSingle(b []byte, f *interpretedField) ([]byte, error) { + num := protowire.Number(f.number) + switch f.kind { + case protoreflect.MessageKind: + enclosed, err := appendOptionBytes(nil, f.value.msgVal) + if err != nil { + return nil, err + } + b = protowire.AppendTag(b, num, protowire.BytesType) + return protowire.AppendBytes(b, enclosed), nil + + case protoreflect.GroupKind: + b = protowire.AppendTag(b, num, protowire.StartGroupType) + var err error + b, err = appendOptionBytes(b, f.value.msgVal) + if err != nil { + return nil, err + } + return protowire.AppendTag(b, num, protowire.EndGroupType), nil + + case protoreflect.StringKind: + b = protowire.AppendTag(b, num, protowire.BytesType) + return protowire.AppendString(b, f.value.val.String()), nil + + case protoreflect.BytesKind: + b = protowire.AppendTag(b, num, protowire.BytesType) + return protowire.AppendBytes(b, f.value.val.Bytes()), nil + + case protoreflect.Int32Kind, protoreflect.Int64Kind, protoreflect.Uint32Kind, protoreflect.Uint64Kind, + protoreflect.Sint32Kind, protoreflect.Sint64Kind, protoreflect.EnumKind, protoreflect.BoolKind: + b = protowire.AppendTag(b, num, protowire.VarintType) + return appendNumericValueBytes(b, f.kind, f.value.val) + + case protoreflect.Fixed32Kind, protoreflect.Sfixed32Kind, protoreflect.FloatKind: + b = protowire.AppendTag(b, num, protowire.Fixed32Type) + return appendNumericValueBytes(b, f.kind, f.value.val) + + case protoreflect.Fixed64Kind, protoreflect.Sfixed64Kind, protoreflect.DoubleKind: + b = protowire.AppendTag(b, num, protowire.Fixed64Type) + return appendNumericValueBytes(b, f.kind, f.value.val) + + default: + return nil, fmt.Errorf("unknown field kind: %v", f.kind) + } +} + +func appendNumericValueBytesPacked(b []byte, k protoreflect.Kind, l protoreflect.List) ([]byte, error) { + for i := 0; i < l.Len(); i++ { + var err error + b, err = appendNumericValueBytes(b, k, l.Get(i)) + if err != nil { + return nil, err + } + } + return b, nil +} + +func appendNumericValueBytes(b []byte, k protoreflect.Kind, v protoreflect.Value) ([]byte, error) { + switch k { + case protoreflect.Int32Kind, protoreflect.Int64Kind: + return protowire.AppendVarint(b, uint64(v.Int())), nil + case protoreflect.Uint32Kind, protoreflect.Uint64Kind: + return protowire.AppendVarint(b, v.Uint()), nil + case protoreflect.Sint32Kind, protoreflect.Sint64Kind: + return protowire.AppendVarint(b, protowire.EncodeZigZag(v.Int())), nil + case protoreflect.Fixed32Kind: + return protowire.AppendFixed32(b, uint32(v.Uint())), nil + case protoreflect.Fixed64Kind: + return protowire.AppendFixed64(b, v.Uint()), nil + case protoreflect.Sfixed32Kind: + return protowire.AppendFixed32(b, uint32(v.Int())), nil + case protoreflect.Sfixed64Kind: + return protowire.AppendFixed64(b, uint64(v.Int())), nil + case protoreflect.FloatKind: + return protowire.AppendFixed32(b, math.Float32bits(float32(v.Float()))), nil + case protoreflect.DoubleKind: + return protowire.AppendFixed64(b, math.Float64bits(v.Float())), nil + case protoreflect.BoolKind: + return protowire.AppendVarint(b, protowire.EncodeBool(v.Bool())), nil + case protoreflect.EnumKind: + return protowire.AppendVarint(b, uint64(v.Enum())), nil + default: + return nil, fmt.Errorf("unknown field kind: %v", k) + } +} + +// optionsContainer may be optionally implemented by a linker.Result. It is +// not part of the linker.Result interface as it is meant only for internal use. +// This allows the option interpreter step to store extra metadata about the +// serialized structure of options. +type optionsContainer interface { + // AddOptionBytes adds the given pre-serialized option bytes to a file, + // associated with the given options message. The type of the given message + // should be an options message, for example *descriptorpb.MessageOptions. + // This value should be part of the message hierarchy whose root is the + // *descriptorpb.FileDescriptorProto that corresponds to this result. + AddOptionBytes(pm proto.Message, opts []byte) +} + +// interpretOptions processes the options in uninterpreted, which are interpreted as fields +// of the given opts message. On success, it will usually return nil, nil. But if the current +// operation is lenient, it may return a non-nil slice of uninterpreted options on success. +// In such a case, the returned value is the remaining slice of options which could not be +// interpreted. +func (interp *interpreter) interpretOptions(fqn string, element, opts proto.Message, uninterpreted []*descriptorpb.UninterpretedOption) ([]*descriptorpb.UninterpretedOption, error) { + optsDesc := opts.ProtoReflect().Descriptor() + optsFqn := string(optsDesc.FullName()) + var msg protoreflect.Message + // see if the parse included an override copy for these options + if md := interp.file.ResolveMessageType(protoreflect.FullName(optsFqn)); md != nil { + dm := dynamicpb.NewMessage(md) + if err := cloneInto(dm, opts, nil); err != nil { + node := interp.file.Node(element) + return nil, interp.reporter.HandleError(reporter.Error(interp.nodeInfo(node).Start(), err)) + } + msg = dm + } else { + msg = proto.Clone(opts).ProtoReflect() + } + + mc := &internal.MessageContext{ + File: interp.file, + ElementName: fqn, + ElementType: descriptorType(element), + } + var remain []*descriptorpb.UninterpretedOption + results := make([]*interpretedOption, 0, len(uninterpreted)) + for _, uo := range uninterpreted { + node := interp.file.OptionNode(uo) + if !uo.Name[0].GetIsExtension() && uo.Name[0].GetNamePart() == "uninterpreted_option" { + if interp.lenient { + remain = append(remain, uo) + continue + } + // uninterpreted_option might be found reflectively, but is not actually valid for use + if err := interp.reporter.HandleErrorf(interp.nodeInfo(node.GetName()).Start(), "%vinvalid option 'uninterpreted_option'", mc); err != nil { + return nil, err + } + } + mc.Option = uo + res, err := interp.interpretField(mc, msg, uo, 0, nil) + if err != nil { + if interp.lenient { + remain = append(remain, uo) + continue + } + return nil, err + } + res.unknown = !isKnownField(optsDesc, res) + results = append(results, res) + if optn, ok := node.(*ast.OptionNode); ok { + interp.index[optn] = res.path() + } + } + + if interp.lenient { + // If we're lenient, then we don't want to clobber the passed in message + // and leave it partially populated. So we convert into a copy first + optsClone := opts.ProtoReflect().New().Interface() + if err := cloneInto(optsClone, msg.Interface(), interp.resolver); err != nil { + // TODO: do this in a more granular way, so we can convert individual + // fields and leave bad ones uninterpreted instead of skipping all of + // the work we've done so far. + return uninterpreted, nil + } + // conversion from dynamic message above worked, so now + // it is safe to overwrite the passed in message + proto.Reset(opts) + proto.Merge(opts, optsClone) + + if interp.container != nil { + b, err := interp.toOptionBytes(mc, results) + if err != nil { + return nil, err + } + interp.container.AddOptionBytes(opts, b) + } + + return remain, nil + } + + if err := validateRecursive(msg, ""); err != nil { + node := interp.file.Node(element) + if err := interp.reporter.HandleErrorf(interp.nodeInfo(node).Start(), "error in %s options: %v", descriptorType(element), err); err != nil { + return nil, err + } + } + + // now try to convert into the passed in message and fail if not successful + if err := cloneInto(opts, msg.Interface(), interp.resolver); err != nil { + node := interp.file.Node(element) + return nil, interp.reporter.HandleError(reporter.Error(interp.nodeInfo(node).Start(), err)) + } + if interp.container != nil { + b, err := interp.toOptionBytes(mc, results) + if err != nil { + return nil, err + } + interp.container.AddOptionBytes(opts, b) + } + + return nil, nil +} + +func isKnownField(desc protoreflect.MessageDescriptor, opt *interpretedOption) bool { + var num int32 + if len(opt.pathPrefix) > 0 { + num = opt.pathPrefix[0] + } else { + num = opt.number + } + return desc.Fields().ByNumber(protoreflect.FieldNumber(num)) != nil +} + +func cloneInto(dest proto.Message, src proto.Message, res linker.Resolver) error { + if dest.ProtoReflect().Descriptor() == src.ProtoReflect().Descriptor() { + proto.Reset(dest) + proto.Merge(dest, src) + if err := proto.CheckInitialized(dest); err != nil { + return err + } + return nil + } + + // If descriptors are not the same, we could have field descriptors in src that + // don't match the ones in dest. There's no easy/sane way to handle that. So we + // just marshal to bytes and back to do this + data, err := proto.Marshal(src) + if err != nil { + return err + } + return proto.UnmarshalOptions{Resolver: res}.Unmarshal(data, dest) +} + +func (interp *interpreter) toOptionBytes(mc *internal.MessageContext, results []*interpretedOption) ([]byte, error) { + // protoc emits non-custom options in tag order and then + // the rest are emitted in the order they are defined in source + sort.SliceStable(results, func(i, j int) bool { + if !results[i].unknown && results[j].unknown { + return true + } + if !results[i].unknown && !results[j].unknown { + return results[i].number < results[j].number + } + return false + }) + var b []byte + for _, res := range results { + var err error + b, err = res.appendOptionBytes(b) + if err != nil { + if _, ok := err.(reporter.ErrorWithPos); !ok { + pos := ast.SourcePos{Filename: interp.file.AST().Name()} + err = reporter.Errorf(pos, "%sfailed to encode options: %w", mc, err) + } + if err := interp.reporter.HandleError(err); err != nil { + return nil, err + } + } + } + return b, nil +} + +func validateRecursive(msg protoreflect.Message, prefix string) error { + flds := msg.Descriptor().Fields() + var missingFields []string + for i := 0; i < flds.Len(); i++ { + fld := flds.Get(i) + if fld.Cardinality() == protoreflect.Required && !msg.Has(fld) { + missingFields = append(missingFields, fmt.Sprintf("%s%s", prefix, fld.Name())) + } + } + if len(missingFields) > 0 { + return fmt.Errorf("some required fields missing: %v", strings.Join(missingFields, ", ")) + } + + var err error + msg.Range(func(fld protoreflect.FieldDescriptor, val protoreflect.Value) bool { + if fld.IsMap() { + md := fld.MapValue().Message() + if md != nil { + val.Map().Range(func(k protoreflect.MapKey, v protoreflect.Value) bool { + chprefix := fmt.Sprintf("%s%s[%v].", prefix, fieldName(fld), k) + err = validateRecursive(v.Message(), chprefix) + return err == nil + }) + if err != nil { + return false + } + } + } else { + md := fld.Message() + if md != nil { + if fld.IsList() { + sl := val.List() + for i := 0; i < sl.Len(); i++ { + v := sl.Get(i) + chprefix := fmt.Sprintf("%s%s[%d].", prefix, fieldName(fld), i) + err = validateRecursive(v.Message(), chprefix) + if err != nil { + return false + } + } + } else { + chprefix := fmt.Sprintf("%s%s.", prefix, fieldName(fld)) + err = validateRecursive(val.Message(), chprefix) + if err != nil { + return false + } + } + } + } + return true + }) + return err +} + +// interpretField interprets the option described by opt, as a field inside the given msg. This +// interprets components of the option name starting at nameIndex. When nameIndex == 0, then +// msg must be an options message. For nameIndex > 0, msg is a nested message inside of the +// options message. The given pathPrefix is the path (sequence of field numbers and indices +// with a FileDescriptorProto as the start) up to but not including the given nameIndex. +func (interp *interpreter) interpretField(mc *internal.MessageContext, msg protoreflect.Message, opt *descriptorpb.UninterpretedOption, nameIndex int, pathPrefix []int32) (*interpretedOption, error) { + var fld protoreflect.FieldDescriptor + nm := opt.GetName()[nameIndex] + node := interp.file.OptionNamePartNode(nm) + if nm.GetIsExtension() { + extName := nm.GetNamePart() + if extName[0] == '.' { + extName = extName[1:] /* skip leading dot */ + } + fld = interp.file.ResolveExtension(protoreflect.FullName(extName)) + if fld == nil { + return nil, interp.reporter.HandleErrorf(interp.nodeInfo(node).Start(), + "%vunrecognized extension %s of %s", + mc, extName, msg.Descriptor().FullName()) + } + if fld.ContainingMessage().FullName() != msg.Descriptor().FullName() { + return nil, interp.reporter.HandleErrorf(interp.nodeInfo(node).Start(), + "%vextension %s should extend %s but instead extends %s", + mc, extName, msg.Descriptor().FullName(), fld.ContainingMessage().FullName()) + } + } else { + fld = msg.Descriptor().Fields().ByName(protoreflect.Name(nm.GetNamePart())) + if fld == nil { + return nil, interp.reporter.HandleErrorf(interp.nodeInfo(node).Start(), + "%vfield %s of %s does not exist", + mc, nm.GetNamePart(), msg.Descriptor().FullName()) + } + } + + if len(opt.GetName()) > nameIndex+1 { + nextnm := opt.GetName()[nameIndex+1] + nextnode := interp.file.OptionNamePartNode(nextnm) + k := fld.Kind() + if k != protoreflect.MessageKind && k != protoreflect.GroupKind { + return nil, interp.reporter.HandleErrorf(interp.nodeInfo(nextnode).Start(), + "%vcannot set field %s because %s is not a message", + mc, nextnm.GetNamePart(), nm.GetNamePart()) + } + if fld.Cardinality() == protoreflect.Repeated { + return nil, interp.reporter.HandleErrorf(interp.nodeInfo(nextnode).Start(), + "%vcannot set field %s because %s is repeated (must use an aggregate)", + mc, nextnm.GetNamePart(), nm.GetNamePart()) + } + var fdm protoreflect.Message + if msg.Has(fld) { + v := msg.Mutable(fld) + fdm = v.Message() + } else { + if ood := fld.ContainingOneof(); ood != nil { + existingFld := msg.WhichOneof(ood) + if existingFld != nil && existingFld.Number() != fld.Number() { + return nil, interp.reporter.HandleErrorf(interp.nodeInfo(node).Start(), + "%voneof %q already has field %q set", + mc, ood.Name(), fieldName(existingFld)) + } + } + fdm = dynamicpb.NewMessage(fld.Message()) + msg.Set(fld, protoreflect.ValueOfMessage(fdm)) + } + // recurse to set next part of name + return interp.interpretField(mc, fdm, opt, nameIndex+1, append(pathPrefix, int32(fld.Number()))) + } + + optNode := interp.file.OptionNode(opt) + val, err := interp.setOptionField(mc, msg, fld, node, optNode.GetValue(), false) + if err != nil { + return nil, interp.reporter.HandleError(err) + } + var index int32 + if fld.IsMap() { + index = int32(msg.Get(fld).Map().Len()) - 1 + } else if fld.IsList() { + index = int32(msg.Get(fld).List().Len()) - 1 + } + return &interpretedOption{ + pathPrefix: pathPrefix, + interpretedField: interpretedField{ + number: int32(fld.Number()), + index: index, + kind: fld.Kind(), + repeated: fld.Cardinality() == protoreflect.Repeated, + value: val, + // NB: don't set packed here in a top-level option + // (only values in message literals will be serialized + // in packed format) + }, + }, nil +} + +// setOptionField sets the value for field fld in the given message msg to the value represented +// by val. The given name is the AST node that corresponds to the name of fld. On success, it +// returns additional metadata about the field that was set. +func (interp *interpreter) setOptionField(mc *internal.MessageContext, msg protoreflect.Message, fld protoreflect.FieldDescriptor, name ast.Node, val ast.ValueNode, insideMsgLiteral bool) (interpretedFieldValue, error) { + v := val.Value() + if sl, ok := v.([]ast.ValueNode); ok { + // handle slices a little differently than the others + if fld.Cardinality() != protoreflect.Repeated { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(val).Start(), "%vvalue is an array but field is not repeated", mc) + } + origPath := mc.OptAggPath + defer func() { + mc.OptAggPath = origPath + }() + var resVal listValue + var resMsgVals [][]*interpretedField + for index, item := range sl { + mc.OptAggPath = fmt.Sprintf("%s[%d]", origPath, index) + value, err := interp.fieldValue(mc, fld, item, insideMsgLiteral) + if err != nil { + return interpretedFieldValue{}, err + } + if fld.IsMap() { + setMapEntry(msg, fld, &value) + } else { + msg.Mutable(fld).List().Append(value.val) + } + resVal = append(resVal, value.val) + if value.msgVal != nil { + resMsgVals = append(resMsgVals, value.msgVal) + } + } + return interpretedFieldValue{ + isList: true, + val: protoreflect.ValueOfList(&resVal), + msgListVal: resMsgVals, + }, nil + } + + value, err := interp.fieldValue(mc, fld, val, insideMsgLiteral) + if err != nil { + return interpretedFieldValue{}, err + } + + if ood := fld.ContainingOneof(); ood != nil { + existingFld := msg.WhichOneof(ood) + if existingFld != nil && existingFld.Number() != fld.Number() { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(name).Start(), "%voneof %q already has field %q set", mc, ood.Name(), fieldName(existingFld)) + } + } + + switch { + case fld.IsMap(): + setMapEntry(msg, fld, &value) + case fld.IsList(): + msg.Mutable(fld).List().Append(value.val) + default: + if msg.Has(fld) { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(name).Start(), "%vnon-repeated option field %s already set", mc, fieldName(fld)) + } + msg.Set(fld, value.val) + } + return value, nil +} + +func setMapEntry(msg protoreflect.Message, fld protoreflect.FieldDescriptor, value *interpretedFieldValue) { + entry := value.val.Message() + keyFld, valFld := fld.MapKey(), fld.MapValue() + // if an entry is missing a key or value, we add in an explicit + // zero value to msgVals to match protoc (which also odds these + // in even if not present in source) + if !entry.Has(keyFld) { + // put key before value + value.msgVal = append(append(([]*interpretedField)(nil), zeroValue(keyFld)), value.msgVal...) + } + if !entry.Has(valFld) { + value.msgVal = append(value.msgVal, zeroValue(valFld)) + } + key := entry.Get(keyFld) + val := entry.Get(valFld) + if dm, ok := val.Interface().(*dynamicpb.Message); ok && (dm == nil || !dm.IsValid()) { + val = protoreflect.ValueOfMessage(dynamicpb.NewMessage(valFld.Message())) + } + m := msg.Mutable(fld).Map() + // TODO: error if key is already present + m.Set(key.MapKey(), val) +} + +// zeroValue returns the zero value for the field types as a *interpretedField. +// The given fld must NOT be a repeated field. +func zeroValue(fld protoreflect.FieldDescriptor) *interpretedField { + var val protoreflect.Value + var msgVal []*interpretedField + switch fld.Kind() { + case protoreflect.MessageKind, protoreflect.GroupKind: + // needs to be non-nil, but empty + msgVal = []*interpretedField{} + msg := dynamicpb.NewMessage(fld.Message()) + val = protoreflect.ValueOfMessage(msg) + case protoreflect.EnumKind: + val = protoreflect.ValueOfEnum(0) + case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: + val = protoreflect.ValueOfInt32(0) + case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: + val = protoreflect.ValueOfUint32(0) + case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: + val = protoreflect.ValueOfInt64(0) + case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: + val = protoreflect.ValueOfUint64(0) + case protoreflect.BoolKind: + val = protoreflect.ValueOfBool(false) + case protoreflect.FloatKind: + val = protoreflect.ValueOfFloat32(0) + case protoreflect.DoubleKind: + val = protoreflect.ValueOfFloat64(0) + case protoreflect.BytesKind: + val = protoreflect.ValueOfBytes(nil) + case protoreflect.StringKind: + val = protoreflect.ValueOfString("") + } + return &interpretedField{ + number: int32(fld.Number()), + kind: fld.Kind(), + value: interpretedFieldValue{ + val: val, + msgVal: msgVal, + }, + } +} + +type listValue []protoreflect.Value + +var _ protoreflect.List = (*listValue)(nil) + +func (l listValue) Len() int { + return len(l) +} + +func (l listValue) Get(i int) protoreflect.Value { + return l[i] +} + +func (l listValue) Set(i int, value protoreflect.Value) { + l[i] = value +} + +func (l *listValue) Append(value protoreflect.Value) { + *l = append(*l, value) +} + +func (l listValue) AppendMutable() protoreflect.Value { + panic("AppendMutable not supported") +} + +func (l *listValue) Truncate(i int) { + *l = (*l)[:i] +} + +func (l listValue) NewElement() protoreflect.Value { + panic("NewElement not supported") +} + +func (l listValue) IsValid() bool { + return true +} + +func fieldName(fld protoreflect.FieldDescriptor) string { + if fld.IsExtension() { + return fmt.Sprintf("(%s)", fld.FullName()) + } + return string(fld.Name()) +} + +func valueKind(val interface{}) string { + switch val := val.(type) { + case ast.Identifier: + return "identifier" + case bool: + return "bool" + case int64: + if val < 0 { + return "negative integer" + } + return "integer" + case uint64: + return "integer" + case float64: + return "double" + case string, []byte: + return "string" + case []*ast.MessageFieldNode: + return "message" + case []ast.ValueNode: + return "array" + default: + return fmt.Sprintf("%T", val) + } +} + +// fieldValue computes a compile-time value (constant or list or message literal) for the given +// AST node val. The value in val must be assignable to the field fld. +func (interp *interpreter) fieldValue(mc *internal.MessageContext, fld protoreflect.FieldDescriptor, val ast.ValueNode, insideMsgLiteral bool) (interpretedFieldValue, error) { + k := fld.Kind() + switch k { + case protoreflect.EnumKind: + evd, err := interp.enumFieldValue(mc, fld.Enum(), val) + if err != nil { + return interpretedFieldValue{}, err + } + return interpretedFieldValue{val: protoreflect.ValueOfEnum(evd.Number())}, nil + + case protoreflect.MessageKind, protoreflect.GroupKind: + v := val.Value() + if aggs, ok := v.([]*ast.MessageFieldNode); ok { + fmd := fld.Message() + return interp.messageLiteralValue(mc, aggs, fmd) + } + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting message, got %s", mc, valueKind(v)) + + default: + v, err := interp.scalarFieldValue(mc, descriptorpb.FieldDescriptorProto_Type(k), val, insideMsgLiteral) + if err != nil { + return interpretedFieldValue{}, err + } + return interpretedFieldValue{val: protoreflect.ValueOf(v)}, nil + } +} + +// enumFieldValue resolves the given AST node val as an enum value descriptor. If the given +// value is not a valid identifier, an error is returned instead. +func (interp *interpreter) enumFieldValue(mc *internal.MessageContext, ed protoreflect.EnumDescriptor, val ast.ValueNode) (protoreflect.EnumValueDescriptor, error) { + v := val.Value() + if id, ok := v.(ast.Identifier); ok { + ev := ed.Values().ByName(protoreflect.Name(id)) + if ev == nil { + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%venum %s has no value named %s", mc, ed.FullName(), id) + } + return ev, nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting enum, got %s", mc, valueKind(v)) +} + +// scalarFieldValue resolves the given AST node val as a value whose type is assignable to a +// field with the given fldType. +func (interp *interpreter) scalarFieldValue(mc *internal.MessageContext, fldType descriptorpb.FieldDescriptorProto_Type, val ast.ValueNode, insideMsgLiteral bool) (interface{}, error) { + v := val.Value() + switch fldType { + case descriptorpb.FieldDescriptorProto_TYPE_BOOL: + if b, ok := v.(bool); ok { + return b, nil + } + if id, ok := v.(ast.Identifier); ok { + if insideMsgLiteral { + // inside a message literal, values use the protobuf text format, + // which is lenient in that it accepts "t" and "f" or "True" and "False" + switch id { + case "t", "true", "True": + return true, nil + case "f", "false", "False": + return false, nil + } + } else { + // options with simple scalar values (no message literal) are stricter + switch id { + case "true": + return true, nil + case "false": + return false, nil + } + } + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting bool, got %s", mc, valueKind(v)) + case descriptorpb.FieldDescriptorProto_TYPE_BYTES: + if str, ok := v.(string); ok { + return []byte(str), nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting bytes, got %s", mc, valueKind(v)) + case descriptorpb.FieldDescriptorProto_TYPE_STRING: + if str, ok := v.(string); ok { + return str, nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting string, got %s", mc, valueKind(v)) + case descriptorpb.FieldDescriptorProto_TYPE_INT32, descriptorpb.FieldDescriptorProto_TYPE_SINT32, descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: + if i, ok := v.(int64); ok { + if i > math.MaxInt32 || i < math.MinInt32 { + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vvalue %d is out of range for int32", mc, i) + } + return int32(i), nil + } + if ui, ok := v.(uint64); ok { + if ui > math.MaxInt32 { + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vvalue %d is out of range for int32", mc, ui) + } + return int32(ui), nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting int32, got %s", mc, valueKind(v)) + case descriptorpb.FieldDescriptorProto_TYPE_UINT32, descriptorpb.FieldDescriptorProto_TYPE_FIXED32: + if i, ok := v.(int64); ok { + if i > math.MaxUint32 || i < 0 { + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vvalue %d is out of range for uint32", mc, i) + } + return uint32(i), nil + } + if ui, ok := v.(uint64); ok { + if ui > math.MaxUint32 { + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vvalue %d is out of range for uint32", mc, ui) + } + return uint32(ui), nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting uint32, got %s", mc, valueKind(v)) + case descriptorpb.FieldDescriptorProto_TYPE_INT64, descriptorpb.FieldDescriptorProto_TYPE_SINT64, descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: + if i, ok := v.(int64); ok { + return i, nil + } + if ui, ok := v.(uint64); ok { + if ui > math.MaxInt64 { + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vvalue %d is out of range for int64", mc, ui) + } + return int64(ui), nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting int64, got %s", mc, valueKind(v)) + case descriptorpb.FieldDescriptorProto_TYPE_UINT64, descriptorpb.FieldDescriptorProto_TYPE_FIXED64: + if i, ok := v.(int64); ok { + if i < 0 { + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vvalue %d is out of range for uint64", mc, i) + } + return uint64(i), nil + } + if ui, ok := v.(uint64); ok { + return ui, nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting uint64, got %s", mc, valueKind(v)) + case descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: + if id, ok := v.(ast.Identifier); ok { + switch id { + case "inf": + return math.Inf(1), nil + case "nan": + return math.NaN(), nil + } + } + if d, ok := v.(float64); ok { + return d, nil + } + if i, ok := v.(int64); ok { + return float64(i), nil + } + if u, ok := v.(uint64); ok { + return float64(u), nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting double, got %s", mc, valueKind(v)) + case descriptorpb.FieldDescriptorProto_TYPE_FLOAT: + if id, ok := v.(ast.Identifier); ok { + switch id { + case "inf": + return float32(math.Inf(1)), nil + case "nan": + return float32(math.NaN()), nil + } + } + if d, ok := v.(float64); ok { + return float32(d), nil + } + if i, ok := v.(int64); ok { + return float32(i), nil + } + if u, ok := v.(uint64); ok { + return float32(u), nil + } + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vexpecting float, got %s", mc, valueKind(v)) + default: + return nil, reporter.Errorf(interp.nodeInfo(val).Start(), "%vunrecognized field type: %s", mc, fldType) + } +} + +func descriptorType(m proto.Message) string { + switch m := m.(type) { + case *descriptorpb.DescriptorProto: + return "message" + case *descriptorpb.DescriptorProto_ExtensionRange: + return "extension range" + case *descriptorpb.FieldDescriptorProto: + if m.GetExtendee() == "" { + return "field" + } + return "extension" + case *descriptorpb.EnumDescriptorProto: + return "enum" + case *descriptorpb.EnumValueDescriptorProto: + return "enum value" + case *descriptorpb.ServiceDescriptorProto: + return "service" + case *descriptorpb.MethodDescriptorProto: + return "method" + case *descriptorpb.FileDescriptorProto: + return "file" + default: + // shouldn't be possible + return fmt.Sprintf("%T", m) + } +} + +func (interp *interpreter) messageLiteralValue(mc *internal.MessageContext, fieldNodes []*ast.MessageFieldNode, fmd protoreflect.MessageDescriptor) (interpretedFieldValue, error) { + fdm := dynamicpb.NewMessage(fmd) + origPath := mc.OptAggPath + defer func() { + mc.OptAggPath = origPath + }() + // NB: we don't want to leave this nil, even if the + // message is empty, because that indicates to + // caller that the result is not a message + flds := make([]*interpretedField, 0, len(fieldNodes)) + var foundAnyNode bool + for _, fieldNode := range fieldNodes { + if origPath == "" { + mc.OptAggPath = fieldNode.Name.Value() + } else { + mc.OptAggPath = origPath + "." + fieldNode.Name.Value() + } + if fieldNode.Name.IsAnyTypeReference() { + if fmd.FullName() != "google.protobuf.Any" { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix).Start(), "%vtype references are only allowed for google.protobuf.Any, but this type is %s", mc, fmd.FullName()) + } + if foundAnyNode { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix).Start(), "%vmultiple any type references are not allowed", mc) + } + foundAnyNode = true + urlPrefix := fieldNode.Name.URLPrefix.AsIdentifier() + msgName := fieldNode.Name.Name.AsIdentifier() + fullURL := fmt.Sprintf("%s/%s", urlPrefix, msgName) + // TODO: Support other URLs dynamically -- the caller of protoparse + // should be able to provide a fldNode custom resolver that can resolve type + // URLs into message descriptors. The default resolver would be + // implemented as below, only accepting "type.googleapis.com" and + // "type.googleprod.com" as hosts/prefixes and using the compiled + // file's transitive closure to find the named message. + if urlPrefix != "type.googleapis.com" && urlPrefix != "type.googleprod.com" { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix).Start(), "%vcould not resolve type reference %s", mc, fullURL) + } + anyFields, ok := fieldNode.Val.Value().([]*ast.MessageFieldNode) + if !ok { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Val).Start(), "%vtype references for google.protobuf.Any must have message literal value", mc) + } + anyMd := interp.file.ResolveMessageType(protoreflect.FullName(msgName)) + if anyMd == nil { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name.URLPrefix).Start(), "%vcould not resolve type reference %s", mc, fullURL) + } + // parse the message value + msgVal, err := interp.messageLiteralValue(mc, anyFields, anyMd) + if err != nil { + return interpretedFieldValue{}, err + } + + // Any is defined with two fields: + // string type_url = 1 + // bytes value = 2 + typeURLDescriptor := fmd.Fields().ByNumber(1) + if typeURLDescriptor == nil || typeURLDescriptor.Kind() != protoreflect.StringKind { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name).Start(), "%vfailed to set type_url string field on Any: %w", mc, err) + } + fdm.Set(typeURLDescriptor, protoreflect.ValueOfString(fullURL)) + valueDescriptor := fmd.Fields().ByNumber(2) + if valueDescriptor == nil || valueDescriptor.Kind() != protoreflect.BytesKind { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name).Start(), "%vfailed to set value bytes field on Any: %w", mc, err) + } + b, err := proto.MarshalOptions{Deterministic: true}.Marshal(msgVal.val.Message().Interface()) + if err != nil { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Val).Start(), "%vfailed to serialize message value: %w", mc, err) + } + fdm.Set(valueDescriptor, protoreflect.ValueOfBytes(b)) + } else { + var ffld protoreflect.FieldDescriptor + if fieldNode.Name.IsExtension() { + n := interp.file.ResolveMessageLiteralExtensionName(fieldNode.Name.Name) + if n == "" { + // this should not be possible! + n = string(fieldNode.Name.Name.AsIdentifier()) + } + ffld = interp.file.ResolveExtension(protoreflect.FullName(n)) + if ffld == nil { + // may need to qualify with package name + // (this should not be necessary!) + pkg := mc.File.FileDescriptorProto().GetPackage() + if pkg != "" { + ffld = interp.file.ResolveExtension(protoreflect.FullName(pkg + "." + n)) + } + } + } else { + ffld = fmd.Fields().ByName(protoreflect.Name(fieldNode.Name.Value())) + // Groups are indicated in the text format by the group name (which is + // camel-case), NOT the field name (which is lower-case). + // ...but only regular fields, not extensions that are groups... + if ffld != nil && ffld.Kind() == protoreflect.GroupKind && ffld.Message().Name() != protoreflect.Name(fieldNode.Name.Value()) { + // this is kind of silly to fail here, but this mimics protoc behavior + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name).Start(), "%vfield %s not found (did you mean the group named %s?)", mc, fieldNode.Name.Value(), ffld.Message().Name()) + } + if ffld == nil { + // could be a group name + for i := 0; i < fmd.Fields().Len(); i++ { + fd := fmd.Fields().Get(i) + if fd.Kind() == protoreflect.GroupKind && fd.Message().Name() == protoreflect.Name(fieldNode.Name.Value()) { + // found it! + ffld = fd + break + } + } + } + } + if ffld == nil { + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Name).Start(), "%vfield %s not found", mc, string(fieldNode.Name.Name.AsIdentifier())) + } + if fieldNode.Sep == nil && ffld.Message() == nil { + // If there is no separator, the field type should be a message. + // Otherwise it is an error in the text format. + return interpretedFieldValue{}, reporter.Errorf(interp.nodeInfo(fieldNode.Val).Start(), "syntax error: unexpected value, expecting ':'") + } + res, err := interp.setOptionField(mc, fdm, ffld, fieldNode.Name, fieldNode.Val, true) + if err != nil { + return interpretedFieldValue{}, err + } + flds = append(flds, &interpretedField{ + number: int32(ffld.Number()), + kind: ffld.Kind(), + repeated: ffld.Cardinality() == protoreflect.Repeated, + packed: ffld.IsPacked(), + value: res, + // NB: no need to set index here, inside message literal + // (it is only used for top-level options, for emitting + // source code info) + }) + } + } + return interpretedFieldValue{ + val: protoreflect.ValueOfMessage(fdm), + msgVal: flds, + }, nil +} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/.gitignore b/vendor/github.com/bufbuild/protocompile/parser/.gitignore similarity index 100% rename from vendor/github.com/jhump/protoreflect/desc/protoparse/.gitignore rename to vendor/github.com/bufbuild/protocompile/parser/.gitignore diff --git a/vendor/github.com/bufbuild/protocompile/parser/ast.go b/vendor/github.com/bufbuild/protocompile/parser/ast.go new file mode 100644 index 00000000000..105502d4067 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/parser/ast.go @@ -0,0 +1,216 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import "github.com/bufbuild/protocompile/ast" + +// the types below are accumulator types: linked lists that are +// constructed during parsing and then converted to slices of AST nodes +// once the whole list has been parsed +// TODO: change grammar to use slices of nodes instead of these constructions + +type compactOptionList struct { + option *ast.OptionNode + comma *ast.RuneNode + next *compactOptionList +} + +func (list *compactOptionList) toNodes() ([]*ast.OptionNode, []*ast.RuneNode) { + l := 0 + for cur := list; cur != nil; cur = cur.next { + l++ + } + opts := make([]*ast.OptionNode, l) + commas := make([]*ast.RuneNode, l-1) + for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { + opts[i] = cur.option + if cur.comma != nil { + commas[i] = cur.comma + } + } + return opts, commas +} + +type stringList struct { + str *ast.StringLiteralNode + next *stringList +} + +func (list *stringList) toStringValueNode() ast.StringValueNode { + if list.next == nil { + // single name + return list.str + } + + l := 0 + for cur := list; cur != nil; cur = cur.next { + l++ + } + strs := make([]*ast.StringLiteralNode, l) + for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { + strs[i] = cur.str + } + return ast.NewCompoundLiteralStringNode(strs...) +} + +type nameList struct { + name ast.StringValueNode + comma *ast.RuneNode + next *nameList +} + +func (list *nameList) toNodes() ([]ast.StringValueNode, []*ast.RuneNode) { + l := 0 + for cur := list; cur != nil; cur = cur.next { + l++ + } + names := make([]ast.StringValueNode, l) + commas := make([]*ast.RuneNode, l-1) + for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { + names[i] = cur.name + if cur.comma != nil { + commas[i] = cur.comma + } + } + return names, commas +} + +type rangeList struct { + rng *ast.RangeNode + comma *ast.RuneNode + next *rangeList +} + +func (list *rangeList) toNodes() ([]*ast.RangeNode, []*ast.RuneNode) { + l := 0 + for cur := list; cur != nil; cur = cur.next { + l++ + } + ranges := make([]*ast.RangeNode, l) + commas := make([]*ast.RuneNode, l-1) + for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { + ranges[i] = cur.rng + if cur.comma != nil { + commas[i] = cur.comma + } + } + return ranges, commas +} + +type valueList struct { + val ast.ValueNode + comma *ast.RuneNode + next *valueList +} + +func (list *valueList) toNodes() ([]ast.ValueNode, []*ast.RuneNode) { + if list == nil { + return nil, nil + } + l := 0 + for cur := list; cur != nil; cur = cur.next { + l++ + } + vals := make([]ast.ValueNode, l) + commas := make([]*ast.RuneNode, l-1) + for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { + vals[i] = cur.val + if cur.comma != nil { + commas[i] = cur.comma + } + } + return vals, commas +} + +type fieldRefList struct { + ref *ast.FieldReferenceNode + dot *ast.RuneNode + next *fieldRefList +} + +func (list *fieldRefList) toNodes() ([]*ast.FieldReferenceNode, []*ast.RuneNode) { + l := 0 + for cur := list; cur != nil; cur = cur.next { + l++ + } + refs := make([]*ast.FieldReferenceNode, l) + dots := make([]*ast.RuneNode, l-1) + for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { + refs[i] = cur.ref + if cur.dot != nil { + dots[i] = cur.dot + } + } + + return refs, dots +} + +type identList struct { + ident *ast.IdentNode + dot *ast.RuneNode + next *identList +} + +func (list *identList) toIdentValueNode(leadingDot *ast.RuneNode) ast.IdentValueNode { + if list.next == nil && leadingDot == nil { + // single name + return list.ident + } + + l := 0 + for cur := list; cur != nil; cur = cur.next { + l++ + } + idents := make([]*ast.IdentNode, l) + dots := make([]*ast.RuneNode, l-1) + for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { + idents[i] = cur.ident + if cur.dot != nil { + dots[i] = cur.dot + } + } + + return ast.NewCompoundIdentNode(leadingDot, idents, dots) +} + +type messageFieldEntry struct { + field *ast.MessageFieldNode + delimiter *ast.RuneNode +} + +type messageFieldList struct { + field *messageFieldEntry + next *messageFieldList +} + +func (list *messageFieldList) toNodes() ([]*ast.MessageFieldNode, []*ast.RuneNode) { + if list == nil { + return nil, nil + } + l := 0 + for cur := list; cur != nil; cur = cur.next { + l++ + } + fields := make([]*ast.MessageFieldNode, l) + delimiters := make([]*ast.RuneNode, l) + for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { + fields[i] = cur.field.field + if cur.field.delimiter != nil { + delimiters[i] = cur.field.delimiter + } + } + + return fields, delimiters +} diff --git a/vendor/github.com/bufbuild/protocompile/parser/doc.go b/vendor/github.com/bufbuild/protocompile/parser/doc.go new file mode 100644 index 00000000000..d4e2c75aa1b --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/parser/doc.go @@ -0,0 +1,25 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package parser contains the logic for parsing protobuf source code into an +// AST (abstract syntax tree) and also for converting an AST into a descriptor +// proto. +// +// A FileDescriptorProto is very similar to an AST, but the AST this package +// uses is more useful because it contains more information about the source +// code, including details about whitespace and comments, that cannot be +// represented by a descriptor proto. This makes it ideal for things like +// code formatters, which may want to preserve things like whitespace and +// comment format. +package parser diff --git a/vendor/google.golang.org/genproto/protobuf/api/api.go b/vendor/github.com/bufbuild/protocompile/parser/errors.go similarity index 60% rename from vendor/google.golang.org/genproto/protobuf/api/api.go rename to vendor/github.com/bufbuild/protocompile/parser/errors.go index 67697b2c5f1..6e34bb8cff1 100644 --- a/vendor/google.golang.org/genproto/protobuf/api/api.go +++ b/vendor/github.com/bufbuild/protocompile/parser/errors.go @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2020-2022 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package api aliases all exported identifiers in -// package "google.golang.org/protobuf/types/known/apipb". -package api +package parser -import "google.golang.org/protobuf/types/known/apipb" +import "errors" -type Api = apipb.Api -type Method = apipb.Method -type Mixin = apipb.Mixin - -var File_google_protobuf_api_proto = apipb.File_google_protobuf_api_proto +// ErrNoSyntax is a sentinel error that may be passed to a warning reporter. +// The error the reporter receives will be wrapped with source position that +// indicates the file that had no syntax statement. +var ErrNoSyntax = errors.New("no syntax specified; defaulting to proto2 syntax") diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/lexer.go b/vendor/github.com/bufbuild/protocompile/parser/lexer.go similarity index 50% rename from vendor/github.com/jhump/protoreflect/desc/protoparse/lexer.go rename to vendor/github.com/bufbuild/protocompile/parser/lexer.go index ed67f562578..e4701faa4e4 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/lexer.go +++ b/vendor/github.com/bufbuild/protocompile/parser/lexer.go @@ -1,4 +1,18 @@ -package protoparse +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser import ( "bufio" @@ -11,80 +25,73 @@ import ( "strings" "unicode/utf8" - "github.com/jhump/protoreflect/desc/protoparse/ast" + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/reporter" ) type runeReader struct { - rr *bufio.Reader - marked []rune - unread []rune - err error + data []byte + pos int + err error + mark int + // Enable this check to make input required to be valid UTF-8. + // For now, since protoc allows invalid UTF-8, default to false. + utf8Strict bool } func (rr *runeReader) readRune() (r rune, size int, err error) { if rr.err != nil { return 0, 0, rr.err } - if len(rr.unread) > 0 { - r := rr.unread[len(rr.unread)-1] - rr.unread = rr.unread[:len(rr.unread)-1] - if rr.marked != nil { - rr.marked = append(rr.marked, r) - } - return r, utf8.RuneLen(r), nil + if rr.pos == len(rr.data) { + rr.err = io.EOF + return 0, 0, rr.err } - r, sz, err := rr.rr.ReadRune() - if err != nil { - rr.err = err - } else if rr.marked != nil { - rr.marked = append(rr.marked, r) + r, sz := utf8.DecodeRune(rr.data[rr.pos:]) + if rr.utf8Strict && r == utf8.RuneError { + rr.err = fmt.Errorf("invalid UTF8 at offset %d: %x", rr.pos, rr.data[rr.pos]) + return 0, 0, rr.err } - return r, sz, err + rr.pos += sz + return r, sz, nil } -func (rr *runeReader) unreadRune(r rune) { - if rr.marked != nil { - if rr.marked[len(rr.marked)-1] != r { - panic("unread rune is not the same as last marked rune!") - } - rr.marked = rr.marked[:len(rr.marked)-1] +func (rr *runeReader) offset() int { + return rr.pos +} + +func (rr *runeReader) unreadRune(sz int) { + newPos := rr.pos - sz + if newPos < rr.mark { + panic("unread past mark") } - rr.unread = append(rr.unread, r) + rr.pos = newPos } -func (rr *runeReader) startMark(initial rune) { - rr.marked = []rune{initial} +func (rr *runeReader) setMark() { + rr.mark = rr.pos } -func (rr *runeReader) endMark() string { - m := string(rr.marked) - rr.marked = rr.marked[:0] - return m +func (rr *runeReader) getMark() string { + return string(rr.data[rr.mark:rr.pos]) } type protoLex struct { - filename string - input *runeReader - errs *errorHandler - res *ast.FileNode - - lineNo int - colNo int - offset int + input *runeReader + info *ast.FileInfo + handler *reporter.Handler + res *ast.FileNode - prevSym ast.TerminalNode - eof ast.TerminalNode - - prevLineNo int - prevColNo int + prevSym ast.TerminalNode prevOffset int - comments []ast.Comment - ws []rune + eof ast.Token + + comments []ast.Token } var utf8Bom = []byte{0xEF, 0xBB, 0xBF} -func newLexer(in io.Reader, filename string, errs *errorHandler) *protoLex { +func newLexer(in io.Reader, filename string, handler *reporter.Handler) (*protoLex, error) { br := bufio.NewReader(in) // if file has UTF8 byte order marker preface, consume it @@ -93,11 +100,15 @@ func newLexer(in io.Reader, filename string, errs *errorHandler) *protoLex { _, _ = br.Discard(3) } - return &protoLex{ - input: &runeReader{rr: br}, - filename: filename, - errs: errs, + contents, err := io.ReadAll(br) + if err != nil { + return nil, err } + return &protoLex{ + input: &runeReader{data: contents}, + info: ast.NewFileInfo(filename, contents), + handler: handler, + }, nil } var keywords = map[string]int{ @@ -145,99 +156,59 @@ var keywords = map[string]int{ "returns": _RETURNS, } -func (l *protoLex) cur() SourcePos { - return SourcePos{ - Filename: l.filename, - Offset: l.offset, - Line: l.lineNo + 1, - Col: l.colNo + 1, +func (l *protoLex) maybeNewLine(r rune) { + if r == '\n' { + l.info.AddLine(l.input.offset()) } } -func (l *protoLex) adjustPos(consumedChars ...rune) { - for _, c := range consumedChars { - switch c { - case '\n': - // new line, back to first column - l.colNo = 0 - l.lineNo++ - case '\r': - // no adjustment - case '\t': - // advance to next tab stop - mod := l.colNo % 8 - l.colNo += 8 - mod - default: - l.colNo++ - } - } -} - -func (l *protoLex) prev() *SourcePos { - if l.prevSym == nil { - return &SourcePos{ - Filename: l.filename, - Offset: 0, - Line: 1, - Col: 1, - } - } - return l.prevSym.Start() +func (l *protoLex) prev() ast.SourcePos { + return l.info.SourcePos(l.prevOffset) } func (l *protoLex) Lex(lval *protoSymType) int { - if l.errs.err != nil { + if l.handler.ReporterError() != nil { // if error reporter already returned non-nil error, // we can skip the rest of the input return 0 } - l.prevLineNo = l.lineNo - l.prevColNo = l.colNo - l.prevOffset = l.offset l.comments = nil - l.ws = nil - l.input.endMark() // reset, just in case for { - c, n, err := l.input.readRune() + l.input.setMark() + + l.prevOffset = l.input.offset() + c, _, err := l.input.readRune() if err == io.EOF { // we're not actually returning a rune, but this will associate // accumulated comments as a trailing comment on last symbol // (if appropriate) l.setRune(lval, 0) - l.eof = lval.b + l.eof = lval.b.Token() return 0 - } else if err != nil { - // we don't call setError because we don't want it wrapped - // with a source position because it's I/O, not syntax - lval.err = err - _ = l.errs.handleError(err) + } + if err != nil { + l.setError(lval, err) return _ERROR } - l.prevLineNo = l.lineNo - l.prevColNo = l.colNo - l.prevOffset = l.offset - - l.offset += n - l.adjustPos(c) if strings.ContainsRune("\n\r\t\f\v ", c) { - l.ws = append(l.ws, c) + // skip whitespace + l.maybeNewLine(c) continue } - l.input.startMark(c) if c == '.' { // decimal literals could start with a dot - cn, _, err := l.input.readRune() + cn, szn, err := l.input.readRune() if err != nil { l.setRune(lval, c) return int(c) } if cn >= '0' && cn <= '9' { - l.adjustPos(cn) - token := l.readNumber(c, cn) + l.readNumber() + token := l.input.getMark() f, err := parseFloat(token) if err != nil { l.setError(lval, numError(err, "float", token)) @@ -246,16 +217,15 @@ func (l *protoLex) Lex(lval *protoSymType) int { l.setFloat(lval, f) return _FLOAT_LIT } - l.input.unreadRune(cn) + l.input.unreadRune(szn) l.setRune(lval, c) return int(c) } if c == '_' || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') { // identifier - token := []rune{c} - token = l.readIdentifier(token) - str := string(token) + l.readIdentifier() + str := l.input.getMark() if t, ok := keywords[str]; ok { l.setIdent(lval, str) return t @@ -266,7 +236,8 @@ func (l *protoLex) Lex(lval *protoSymType) int { if c >= '0' && c <= '9' { // integer or float literal - token := l.readNumber(c) + l.readNumber() + token := l.input.getMark() if strings.HasPrefix(token, "0x") || strings.HasPrefix(token, "0X") { // hexadecimal ui, err := strconv.ParseUint(token[2:], 16, 64) @@ -277,7 +248,7 @@ func (l *protoLex) Lex(lval *protoSymType) int { l.setInt(lval, ui) return _INT_LIT } - if strings.Contains(token, ".") || strings.Contains(token, "e") || strings.Contains(token, "E") { + if strings.ContainsAny(token, ".eE") { // floating point! f, err := parseFloat(token) if err != nil { @@ -297,8 +268,7 @@ func (l *protoLex) Lex(lval *protoSymType) int { kind := "integer" if base == 8 { kind = "octal integer" - } - if numErr, ok := err.(*strconv.NumError); ok && numErr.Err == strconv.ErrRange { + } else if numErr, ok := err.(*strconv.NumError); ok && numErr.Err == strconv.ErrRange { // if it's too big to be an int, parse it as a float var f float64 kind = "float" @@ -328,30 +298,19 @@ func (l *protoLex) Lex(lval *protoSymType) int { if c == '/' { // comment - cn, _, err := l.input.readRune() + cn, szn, err := l.input.readRune() if err != nil { l.setRune(lval, '/') return int(c) } if cn == '/' { - l.adjustPos(cn) - hitNewline, hasErr := l.skipToEndOfLineComment(lval) - if hasErr { + if hasErr := l.skipToEndOfLineComment(lval); hasErr { return _ERROR } - comment := l.newComment() - comment.PosRange.End.Col++ - if hitNewline { - // we don't do this inside of skipToEndOfLineComment - // because we want to know the length of previous - // line for calculation above - l.adjustPos('\n') - } - l.comments = append(l.comments, comment) + l.comments = append(l.comments, l.newToken()) continue } if cn == '*' { - l.adjustPos(cn) ok, hasErr := l.skipToEndOfBlockComment(lval) if hasErr { return _ERROR @@ -360,10 +319,10 @@ func (l *protoLex) Lex(lval *protoSymType) int { l.setError(lval, errors.New("block comment never terminates, unexpected EOF")) return _ERROR } - l.comments = append(l.comments, l.newComment()) + l.comments = append(l.comments, l.newToken()) continue } - l.input.unreadRune(cn) + l.input.unreadRune(szn) } if c < 32 || c == 127 { @@ -400,155 +359,97 @@ func parseFloat(token string) (float64, error) { return f, err } -func (l *protoLex) posRange() ast.PosRange { - return ast.PosRange{ - Start: SourcePos{ - Filename: l.filename, - Offset: l.prevOffset, - Line: l.prevLineNo + 1, - Col: l.prevColNo + 1, - }, - End: l.cur(), - } +func (l *protoLex) newToken() ast.Token { + offset := l.input.mark + length := l.input.pos - l.input.mark + return l.info.AddToken(offset, length) } -func (l *protoLex) newComment() ast.Comment { - ws := string(l.ws) - l.ws = l.ws[:0] - return ast.Comment{ - PosRange: l.posRange(), - LeadingWhitespace: ws, - Text: l.input.endMark(), - } -} - -func (l *protoLex) newTokenInfo() ast.TokenInfo { - ws := string(l.ws) - l.ws = nil - return ast.TokenInfo{ - PosRange: l.posRange(), - LeadingComments: l.comments, - LeadingWhitespace: ws, - RawText: l.input.endMark(), - } -} - -func (l *protoLex) setPrev(n ast.TerminalNode, isDot bool) { - nStart := n.Start().Line - if _, ok := n.(*ast.RuneNode); ok { - // This is really gross, but there are many cases where we don't want - // to attribute comments to punctuation (like commas, equals, semicolons) - // and would instead prefer to attribute comments to a more meaningful - // element in the AST. - // - // So if it's a simple node OTHER THAN PERIOD (since that is not just - // punctuation but typically part of a qualified identifier), don't - // attribute comments to it. We do that with this TOTAL HACK: adjusting - // the start line makes leading comments appear detached so logic below - // will naturally associated trailing comment to previous symbol - if !isDot { - nStart += 2 +func (l *protoLex) setPrevAndAddComments(n ast.TerminalNode) { + comments := l.comments + l.comments = nil + var prevTrailingComments []ast.Token + if l.prevSym != nil && len(comments) > 0 { + prevEnd := l.info.NodeInfo(l.prevSym).End().Line + info := l.info.NodeInfo(n) + nStart := info.Start().Line + if nStart == prevEnd { + if rn, ok := n.(*ast.RuneNode); ok && rn.Rune == 0 { + // if current token is EOF, pretend its on separate line + // so that the logic below can attribute a final trailing + // comment to the previous token + nStart++ + } } - } - if l.prevSym != nil && len(n.LeadingComments()) > 0 && l.prevSym.End().Line < nStart { - // we may need to re-attribute the first comment to - // instead be previous node's trailing comment - prevEnd := l.prevSym.End().Line - comments := n.LeadingComments() c := comments[0] - commentStart := c.Start.Line - if commentStart == prevEnd { - // comment is on same line as previous symbol - n.PopLeadingComment() - l.prevSym.PushTrailingComment(c) - } else if commentStart == prevEnd+1 { - // comment is right after previous symbol; see if it is detached - // and if so re-attribute - singleLineStyle := strings.HasPrefix(c.Text, "//") - line := c.End.Line - groupEnd := -1 - for i := 1; i < len(comments); i++ { - c := comments[i] - newGroup := false - if !singleLineStyle || c.Start.Line > line+1 { - // we've found a gap between comments, which means the - // previous comments were detached - newGroup = true - } else { - line = c.End.Line - singleLineStyle = strings.HasPrefix(comments[i].Text, "//") - if !singleLineStyle { - // we've found a switch from // comments to /* - // consider that a new group which means the - // previous comments were detached - newGroup = true - } - } - if newGroup { - groupEnd = i - break - } - } - - if groupEnd == -1 { - // just one group of comments; we'll mark it as a trailing - // comment if it immediately follows previous symbol and is - // detached from current symbol - c1 := comments[0] - c2 := comments[len(comments)-1] - if c1.Start.Line <= prevEnd+1 && c2.End.Line < nStart-1 { - groupEnd = len(comments) - } - } - - for i := 0; i < groupEnd; i++ { - l.prevSym.PushTrailingComment(n.PopLeadingComment()) + commentInfo := l.info.TokenInfo(c) + commentStart := commentInfo.Start().Line + if nStart > prevEnd && commentStart == prevEnd { + // Comment starts right after the previous token. If it's a + // line comment, we record that as a trailing comment. + // + // But if it's a block comment, it is only a trailing comment + // if there are multiple comments or if the block comment ends + // on a line before n. + canDonate := strings.HasPrefix(commentInfo.RawText(), "//") || + len(comments) > 1 || commentInfo.End().Line < nStart + + if canDonate { + prevTrailingComments = comments[:1] + comments = comments[1:] } } } + // now we can associate comments + for _, c := range prevTrailingComments { + l.info.AddComment(c, l.prevSym.Token()) + } + for _, c := range comments { + l.info.AddComment(c, n.Token()) + } + l.prevSym = n } func (l *protoLex) setString(lval *protoSymType, val string) { - lval.s = ast.NewStringLiteralNode(val, l.newTokenInfo()) - l.setPrev(lval.s, false) + lval.s = ast.NewStringLiteralNode(val, l.newToken()) + l.setPrevAndAddComments(lval.s) } func (l *protoLex) setIdent(lval *protoSymType, val string) { - lval.id = ast.NewIdentNode(val, l.newTokenInfo()) - l.setPrev(lval.id, false) + lval.id = ast.NewIdentNode(val, l.newToken()) + l.setPrevAndAddComments(lval.id) } func (l *protoLex) setInt(lval *protoSymType, val uint64) { - lval.i = ast.NewUintLiteralNode(val, l.newTokenInfo()) - l.setPrev(lval.i, false) + lval.i = ast.NewUintLiteralNode(val, l.newToken()) + l.setPrevAndAddComments(lval.i) } func (l *protoLex) setFloat(lval *protoSymType, val float64) { - lval.f = ast.NewFloatLiteralNode(val, l.newTokenInfo()) - l.setPrev(lval.f, false) + lval.f = ast.NewFloatLiteralNode(val, l.newToken()) + l.setPrevAndAddComments(lval.f) } func (l *protoLex) setRune(lval *protoSymType, val rune) { - lval.b = ast.NewRuneNode(val, l.newTokenInfo()) - l.setPrev(lval.b, val == '.') + lval.b = ast.NewRuneNode(val, l.newToken()) + l.setPrevAndAddComments(lval.b) } func (l *protoLex) setError(lval *protoSymType, err error) { - lval.err = l.addSourceError(err) + lval.err, _ = l.addSourceError(err) } -func (l *protoLex) readNumber(sofar ...rune) string { - token := sofar +func (l *protoLex) readNumber() { allowExpSign := false for { - c, _, err := l.input.readRune() + c, sz, err := l.input.readRune() if err != nil { break } if (c == '-' || c == '+') && !allowExpSign { - l.input.unreadRune(c) + l.input.unreadRune(sz) break } allowExpSign = false @@ -556,7 +457,7 @@ func (l *protoLex) readNumber(sofar ...rune) string { (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '-' && c != '+' { // no more chars in the number token - l.input.unreadRune(c) + l.input.unreadRune(sz) break } if c == 'e' || c == 'E' { @@ -564,10 +465,7 @@ func (l *protoLex) readNumber(sofar ...rune) string { // an exponent sign allowExpSign = true } - l.adjustPos(c) - token = append(token, c) } - return string(token) } func numError(err error, kind, s string) error { @@ -582,25 +480,44 @@ func numError(err error, kind, s string) error { return fmt.Errorf("invalid syntax in %s value: %s", kind, s) } -func (l *protoLex) readIdentifier(sofar []rune) []rune { - token := sofar +func (l *protoLex) readIdentifier() { for { - c, _, err := l.input.readRune() + c, sz, err := l.input.readRune() if err != nil { break } if c != '_' && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') { - l.input.unreadRune(c) + l.input.unreadRune(sz) break } - l.adjustPos(c) - token = append(token, c) } - return token } func (l *protoLex) readStringLiteral(quote rune) (string, error) { var buf bytes.Buffer + var escapeError reporter.ErrorWithPos + var noMoreErrors bool + reportErr := func(msg, badEscape string) { + if noMoreErrors { + return + } + if escapeError != nil { + // report previous one + _, ok := l.addSourceError(escapeError) + if !ok { + noMoreErrors = true + } + } + var err error + if strings.HasSuffix(msg, "%s") { + err = fmt.Errorf(msg, badEscape) + } else { + err = errors.New(msg) + } + // we've now consumed the bad escape and lexer position is after it, so we need + // to back up to the beginning of the escape to report the correct position + escapeError = l.errWithCurrentPos(err, -len(badEscape)) + } for { c, _, err := l.input.readRune() if err != nil { @@ -612,12 +529,12 @@ func (l *protoLex) readStringLiteral(quote rune) (string, error) { if c == '\n' { return "", errors.New("encountered end-of-line before end of string literal") } - l.adjustPos(c) if c == quote { break } if c == 0 { - return "", errors.New("null character ('\\0') not allowed in string literal") + reportErr("null character ('\\0') not allowed in string literal", string(rune(0))) + continue } if c == '\\' { // escape sequence @@ -625,148 +542,175 @@ func (l *protoLex) readStringLiteral(quote rune) (string, error) { if err != nil { return "", err } - l.adjustPos(c) - if c == 'x' || c == 'X' { + switch { + case c == 'x' || c == 'X': // hex escape - c, _, err := l.input.readRune() + c1, sz1, err := l.input.readRune() if err != nil { return "", err } - l.adjustPos(c) - c2, _, err := l.input.readRune() + if c1 == quote || c1 == '\\' { + l.input.unreadRune(sz1) + reportErr("invalid hex escape: %s", "\\"+string(c)) + continue + } + c2, sz2, err := l.input.readRune() if err != nil { return "", err } var hex string if (c2 < '0' || c2 > '9') && (c2 < 'a' || c2 > 'f') && (c2 < 'A' || c2 > 'F') { - l.input.unreadRune(c2) - hex = string(c) + l.input.unreadRune(sz2) + hex = string(c1) } else { - l.adjustPos(c2) - hex = string([]rune{c, c2}) + hex = string([]rune{c1, c2}) } i, err := strconv.ParseInt(hex, 16, 32) if err != nil { - return "", fmt.Errorf("invalid hex escape: \\x%q", hex) + reportErr("invalid hex escape: %s", "\\"+string(c)+hex) + continue } buf.WriteByte(byte(i)) - - } else if c >= '0' && c <= '7' { + case c >= '0' && c <= '7': // octal escape - c2, _, err := l.input.readRune() + c2, sz2, err := l.input.readRune() if err != nil { return "", err } var octal string if c2 < '0' || c2 > '7' { - l.input.unreadRune(c2) + l.input.unreadRune(sz2) octal = string(c) } else { - l.adjustPos(c2) - c3, _, err := l.input.readRune() + c3, sz3, err := l.input.readRune() if err != nil { return "", err } if c3 < '0' || c3 > '7' { - l.input.unreadRune(c3) + l.input.unreadRune(sz3) octal = string([]rune{c, c2}) } else { - l.adjustPos(c3) octal = string([]rune{c, c2, c3}) } } i, err := strconv.ParseInt(octal, 8, 32) if err != nil { - return "", fmt.Errorf("invalid octal escape: \\%q", octal) + reportErr("invalid octal escape: %s", "\\"+octal) + continue } if i > 0xff { - return "", fmt.Errorf("octal escape is out range, must be between 0 and 377: \\%q", octal) + reportErr("octal escape is out range, must be between 0 and 377: %s", "\\"+octal) + continue } buf.WriteByte(byte(i)) - - } else if c == 'u' { + case c == 'u': // short unicode escape u := make([]rune, 4) for i := range u { - c, _, err := l.input.readRune() + c2, sz2, err := l.input.readRune() if err != nil { return "", err } - l.adjustPos(c) - u[i] = c + if c2 == quote || c2 == '\\' { + l.input.unreadRune(sz2) + u = u[:i] + break + } + u[i] = c2 } - i, err := strconv.ParseInt(string(u), 16, 32) + codepointStr := string(u) + if len(u) < 4 { + reportErr("invalid unicode escape: %s", "\\u"+codepointStr) + continue + } + i, err := strconv.ParseInt(codepointStr, 16, 32) if err != nil { - return "", fmt.Errorf("invalid unicode escape: \\u%q", string(u)) + reportErr("invalid unicode escape: %s", "\\u"+codepointStr) + continue } buf.WriteRune(rune(i)) - - } else if c == 'U' { + case c == 'U': // long unicode escape u := make([]rune, 8) for i := range u { - c, _, err := l.input.readRune() + c2, sz2, err := l.input.readRune() if err != nil { return "", err } - l.adjustPos(c) - u[i] = c + if c2 == quote || c2 == '\\' { + l.input.unreadRune(sz2) + u = u[:i] + break + } + u[i] = c2 + } + codepointStr := string(u) + if len(u) < 8 { + reportErr("invalid unicode escape: %s", "\\U"+codepointStr) + continue } i, err := strconv.ParseInt(string(u), 16, 32) if err != nil { - return "", fmt.Errorf("invalid unicode escape: \\U%q", string(u)) + reportErr("invalid unicode escape: %s", "\\U"+codepointStr) + continue } if i > 0x10ffff || i < 0 { - return "", fmt.Errorf("unicode escape is out of range, must be between 0 and 0x10ffff: \\U%q", string(u)) + reportErr("unicode escape is out of range, must be between 0 and 0x10ffff: %s", "\\U"+codepointStr) + continue } buf.WriteRune(rune(i)) - - } else if c == 'a' { + case c == 'a': buf.WriteByte('\a') - } else if c == 'b' { + case c == 'b': buf.WriteByte('\b') - } else if c == 'f' { + case c == 'f': buf.WriteByte('\f') - } else if c == 'n' { + case c == 'n': buf.WriteByte('\n') - } else if c == 'r' { + case c == 'r': buf.WriteByte('\r') - } else if c == 't' { + case c == 't': buf.WriteByte('\t') - } else if c == 'v' { + case c == 'v': buf.WriteByte('\v') - } else if c == '\\' { + case c == '\\': buf.WriteByte('\\') - } else if c == '\'' { + case c == '\'': buf.WriteByte('\'') - } else if c == '"' { + case c == '"': buf.WriteByte('"') - } else if c == '?' { + case c == '?': buf.WriteByte('?') - } else { - return "", fmt.Errorf("invalid escape sequence: %q", "\\"+string(c)) + default: + reportErr("invalid escape sequence: %s", "\\"+string(c)) + continue } } else { buf.WriteRune(c) } } + if escapeError != nil { + return "", escapeError + } return buf.String(), nil } -func (l *protoLex) skipToEndOfLineComment(lval *protoSymType) (ok, hasErr bool) { +func (l *protoLex) skipToEndOfLineComment(lval *protoSymType) (hasErr bool) { for { - c, _, err := l.input.readRune() + c, sz, err := l.input.readRune() if err != nil { - return false, false + // eof + return false } switch c { case '\n': - return true, false + // don't include newline in the comment + l.input.unreadRune(sz) + return false case 0: l.setError(lval, errors.New("invalid control character")) - return false, true + return true } - l.adjustPos(c) } } @@ -780,30 +724,37 @@ func (l *protoLex) skipToEndOfBlockComment(lval *protoSymType) (ok, hasErr bool) l.setError(lval, errors.New("invalid control character")) return false, true } - l.adjustPos(c) + l.maybeNewLine(c) if c == '*' { - c, _, err := l.input.readRune() + c, sz, err := l.input.readRune() if err != nil { return false, false } if c == '/' { - l.adjustPos(c) return true, false } - l.input.unreadRune(c) + l.input.unreadRune(sz) } } } -func (l *protoLex) addSourceError(err error) ErrorWithPos { - ewp, ok := err.(ErrorWithPos) +func (l *protoLex) addSourceError(err error) (reporter.ErrorWithPos, bool) { + ewp, ok := err.(reporter.ErrorWithPos) if !ok { - ewp = ErrorWithSourcePos{Pos: l.prev(), Underlying: err} + ewp = reporter.Error(l.prev(), err) } - _ = l.errs.handleError(ewp) - return ewp + handlerErr := l.handler.HandleError(ewp) + return ewp, handlerErr == nil } func (l *protoLex) Error(s string) { - _ = l.addSourceError(errors.New(s)) + _, _ = l.addSourceError(errors.New(s)) +} + +func (l *protoLex) errWithCurrentPos(err error, offset int) reporter.ErrorWithPos { + if ewp, ok := err.(reporter.ErrorWithPos); ok { + return ewp + } + pos := l.info.SourcePos(l.input.offset() + offset) + return reporter.Error(pos, err) } diff --git a/vendor/github.com/bufbuild/protocompile/parser/parser.go b/vendor/github.com/bufbuild/protocompile/parser/parser.go new file mode 100644 index 00000000000..c6494ad872e --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/parser/parser.go @@ -0,0 +1,180 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import ( + "fmt" + "io" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/reporter" +) + +//go:generate goyacc -o proto.y.go -l -p proto proto.y + +func init() { + protoErrorVerbose = true + + // fix up the generated "token name" array so that error messages are nicer + setTokenName(_STRING_LIT, "string literal") + setTokenName(_INT_LIT, "int literal") + setTokenName(_FLOAT_LIT, "float literal") + setTokenName(_NAME, "identifier") + setTokenName(_ERROR, "error") + // for keywords, just show the keyword itself wrapped in quotes + for str, i := range keywords { + setTokenName(i, fmt.Sprintf(`"%s"`, str)) + } +} + +func setTokenName(token int, text string) { + // NB: this is based on logic in generated parse code that translates the + // int returned from the lexer into an internal token number. + var intern int8 + if token < len(protoTok1) { + intern = protoTok1[token] + } else { + if token >= protoPrivate { + if token < protoPrivate+len(protoTok2) { + intern = protoTok2[token-protoPrivate] + } + } + if intern == 0 { + for i := 0; i+1 < len(protoTok3); i += 2 { + if int(protoTok3[i]) == token { + intern = protoTok3[i+1] + break + } + } + } + } + + if intern >= 1 && int(intern-1) < len(protoToknames) { + protoToknames[intern-1] = text + return + } + + panic(fmt.Sprintf("Unknown token value: %d", token)) +} + +// Parse parses the given source code info and returns an AST. The given filename +// is used to construct error messages and position information. The given reader +// supplies the source code. The given handler is used to report errors and +// warnings encountered while parsing. If any errors are reported, this function +// returns a non-nil error. +func Parse(filename string, r io.Reader, handler *reporter.Handler) (*ast.FileNode, error) { + lx, err := newLexer(r, filename, handler) + if err != nil { + return nil, err + } + protoParse(lx) + if lx.res == nil { + // nil AST means there was an error that prevented any parsing + // or the file was empty; synthesize empty non-nil AST + lx.res = ast.NewEmptyFileNode(filename) + } + return lx.res, handler.Error() +} + +// Result is the result of constructing a descriptor proto from a parsed AST. +// From this result, the AST and the file descriptor proto can be had. This +// also contains numerous lookup functions, for looking up AST nodes that +// correspond to various elements of the descriptor hierarchy. +// +// Results can be created without AST information, using the ResultWithoutAST() +// function. All functions other than AST() will still return non-nil values, +// allowing compile operations to work with files that have only intermediate +// descriptor protos and no source code. For such results, the function that +// return AST nodes will return placeholder nodes. The position information for +// placeholder nodes contains only the filename. +type Result interface { + // AST returns the parsed abstract syntax tree. This returns nil if the + // Result was created without an AST. + AST() *ast.FileNode + // FileDescriptorProto returns the file descriptor proto. + FileDescriptorProto() *descriptorpb.FileDescriptorProto + + // FileNode returns the root of the AST. If this result has no AST then a + // placeholder node is returned. + FileNode() ast.FileDeclNode + // Node returns the AST node from which the given message was created. This + // can return nil, such as if the given message is not part of the + // FileDescriptorProto hierarchy. If this result has no AST, this returns a + // placeholder node. + Node(proto.Message) ast.Node + // OptionNode returns the AST node corresponding to the given uninterpreted + // option. This can return nil, such as if the given option is not part of + // the FileDescriptorProto hierarchy. If this result has no AST, this + // returns a placeholder node. + OptionNode(*descriptorpb.UninterpretedOption) ast.OptionDeclNode + // OptionNamePartNode returns the AST node corresponding to the given name + // part for an uninterpreted option. This can return nil, such as if the + // given name part is not part of the FileDescriptorProto hierarchy. If this + // result has no AST, this returns a placeholder node. + OptionNamePartNode(*descriptorpb.UninterpretedOption_NamePart) ast.Node + // MessageNode returns the AST node corresponding to the given message. This + // can return nil, such as if the given message is not part of the + // FileDescriptorProto hierarchy. If this result has no AST, this returns a + // placeholder node. + MessageNode(*descriptorpb.DescriptorProto) ast.MessageDeclNode + // FieldNode returns the AST node corresponding to the given field. This can + // return nil, such as if the given field is not part of the + // FileDescriptorProto hierarchy. If this result has no AST, this returns a + // placeholder node. + FieldNode(*descriptorpb.FieldDescriptorProto) ast.FieldDeclNode + // OneOfNode returns the AST node corresponding to the given oneof. This can + // return nil, such as if the given oneof is not part of the + // FileDescriptorProto hierarchy. If this result has no AST, this returns a + // placeholder node. + OneOfNode(*descriptorpb.OneofDescriptorProto) ast.Node + // ExtensionRangeNode returns the AST node corresponding to the given + // extension range. This can return nil, such as if the given range is not + // part of the FileDescriptorProto hierarchy. If this result has no AST, + // this returns a placeholder node. + ExtensionRangeNode(*descriptorpb.DescriptorProto_ExtensionRange) ast.RangeDeclNode + // MessageReservedRangeNode returns the AST node corresponding to the given + // reserved range. This can return nil, such as if the given range is not + // part of the FileDescriptorProto hierarchy. If this result has no AST, + // this returns a placeholder node. + MessageReservedRangeNode(*descriptorpb.DescriptorProto_ReservedRange) ast.RangeDeclNode + // EnumNode returns the AST node corresponding to the given enum. This can + // return nil, such as if the given enum is not part of the + // FileDescriptorProto hierarchy. If this result has no AST, this returns a + // placeholder node. + EnumNode(*descriptorpb.EnumDescriptorProto) ast.Node + // EnumValueNode returns the AST node corresponding to the given enum. This + // can return nil, such as if the given enum value is not part of the + // FileDescriptorProto hierarchy. If this result has no AST, this returns a + // placeholder node. + EnumValueNode(*descriptorpb.EnumValueDescriptorProto) ast.EnumValueDeclNode + // EnumReservedRangeNode returns the AST node corresponding to the given + // reserved range. This can return nil, such as if the given range is not + // part of the FileDescriptorProto hierarchy. If this result has no AST, + // this returns a placeholder node. + EnumReservedRangeNode(*descriptorpb.EnumDescriptorProto_EnumReservedRange) ast.RangeDeclNode + // ServiceNode returns the AST node corresponding to the given service. This + // can return nil, such as if the given service is not part of the + // FileDescriptorProto hierarchy. If this result has no AST, this returns a + // placeholder node. + ServiceNode(*descriptorpb.ServiceDescriptorProto) ast.Node + // MethodNode returns the AST node corresponding to the given method. This + // can return nil, such as if the given method is not part of the + // FileDescriptorProto hierarchy. If this result has no AST, this returns a + // placeholder node. + MethodNode(*descriptorpb.MethodDescriptorProto) ast.RPCDeclNode +} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/proto.y b/vendor/github.com/bufbuild/protocompile/parser/proto.y similarity index 95% rename from vendor/github.com/jhump/protoreflect/desc/protoparse/proto.y rename to vendor/github.com/bufbuild/protocompile/parser/proto.y index 67a52ae496f..78a6c806951 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/proto.y +++ b/vendor/github.com/bufbuild/protocompile/parser/proto.y @@ -1,12 +1,12 @@ %{ -package protoparse +package parser //lint:file-ignore SA4006 generated parser has unused values import ( "math" - "github.com/jhump/protoreflect/desc/protoparse/ast" + "github.com/bufbuild/protocompile/ast" ) %} @@ -86,16 +86,16 @@ import ( %type optionNameComponent aggName %type optionName %type compactOptions -%type constant scalarConstant aggregate numLit +%type constant scalarConstant aggregate msgLit numLit %type intLit %type name keyType msgElementName extElementName oneofElementName enumElementName %type ident msgElementIdent extElementIdent oneofElementIdent %type typeIdent msgElementTypeIdent extElementTypeIdent oneofElementTypeIdent -%type constantList +%type constantList msgList %type aggFieldEntry %type aggField %type aggFields -%type oneofField msgField extField +%type msgField oneofField extField %type oneof %type group oneofGroup %type mapField @@ -141,18 +141,24 @@ import ( %% file : syntax { - $$ = ast.NewFileNode($1, nil) - protolex.(*protoLex).res = $$ + lex := protolex.(*protoLex) + $$ = ast.NewFileNode(lex.info, $1, nil, lex.eof) + lex.res = $$ } | fileDecls { - $$ = ast.NewFileNode(nil, $1) - protolex.(*protoLex).res = $$ + lex := protolex.(*protoLex) + $$ = ast.NewFileNode(lex.info, nil, $1, lex.eof) + lex.res = $$ } | syntax fileDecls { - $$ = ast.NewFileNode($1, $2) - protolex.(*protoLex).res = $$ + lex := protolex.(*protoLex) + $$ = ast.NewFileNode(lex.info, $1, $2, lex.eof) + lex.res = $$ } | { + lex := protolex.(*protoLex) + $$ = ast.NewFileNode(lex.info, nil, nil, lex.eof) + lex.res = $$ } fileDecls : fileDecls fileDecl { @@ -279,7 +285,7 @@ scalarConstant : stringLit { } | numLit | name { - $$ = $1 + $$ = $1 } numLit : _FLOAT_LIT { @@ -325,6 +331,9 @@ aggregate : '{' aggFields '}' { fields, delims := $2.toNodes() $$ = ast.NewMessageLiteralNode($1, fields, delims, $3) } + | '{' error '}' { + $$ = nil + } aggFields : aggField { if $1 != nil { @@ -398,7 +407,7 @@ aggFieldEntry : aggName ':' scalarConstant { $$ = nil } } - | aggName '[' constantList ']' { + | aggName '[' msgList ']' { if $1 != nil { vals, commas := $3.toNodes() val := ast.NewArrayLiteralNode($2, vals, commas, $4) @@ -419,38 +428,23 @@ aggFieldEntry : aggName ':' scalarConstant { | aggName ':' '[' error ']' { $$ = nil } - | aggName ':' aggregate { - if $1 != nil { + | aggName '[' error ']' { + $$ = nil + } + | aggName ':' msgLit { + if $1 != nil && $3 != nil { $$ = ast.NewMessageFieldNode($1, $2, $3) } else { $$ = nil } } - | aggName aggregate { - if $1 != nil { + | aggName msgLit { + if $1 != nil && $2 != nil { $$ = ast.NewMessageFieldNode($1, nil, $2) } else { $$ = nil } } - | aggName ':' '<' aggFields '>' { - if $1 != nil { - fields, delims := $4.toNodes() - msg := ast.NewMessageLiteralNode($3, fields, delims, $5) - $$ = ast.NewMessageFieldNode($1, $2, msg) - } else { - $$ = nil - } - } - | aggName '<' aggFields '>' { - if $1 != nil { - fields, delims := $3.toNodes() - msg := ast.NewMessageLiteralNode($2, fields, delims, $4) - $$ = ast.NewMessageFieldNode($1, nil, msg) - } else { - $$ = nil - } - } | aggName ':' '<' error '>' { $$ = nil } @@ -471,6 +465,32 @@ aggName : name { $$ = nil } +msgList : msgLit { + if $1 == nil { + $$ = nil + } else { + $$ = &valueList{$1, nil, nil} + } + } + | msgLit ',' msgList { + if $1 == nil { + $$ = nil + } else { + $$ = &valueList{$1, $2, $3} + } + } + +msgLit : aggregate { + $$ = $1 + } + | '<' aggFields '>' { + fields, delims := $2.toNodes() + $$ = ast.NewMessageLiteralNode($1, fields, delims, $3) + } + | '<' error '>' { + $$ = nil + } + constantList : constant { $$ = &valueList{$1, nil, nil} } @@ -640,9 +660,6 @@ ooDecl : option { | oneofGroup { $$ = $1 } - | ';' { - $$ = ast.NewEmptyDeclNode($1) - } | error ';' { $$ = nil } @@ -900,9 +917,6 @@ extendDecl : extField { | group { $$ = $1 } - | ';' { - $$ = ast.NewEmptyDeclNode($1) - } | error ';' { $$ = nil } diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/proto.y.go b/vendor/github.com/bufbuild/protocompile/parser/proto.y.go similarity index 66% rename from vendor/github.com/jhump/protoreflect/desc/protoparse/proto.y.go rename to vendor/github.com/bufbuild/protocompile/parser/proto.y.go index 31fdcb1cff5..5a7e953f437 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/proto.y.go +++ b/vendor/github.com/bufbuild/protocompile/parser/proto.y.go @@ -1,21 +1,30 @@ -// Code generated by goyacc -o proto.y.go -p proto proto.y. DO NOT EDIT. - -//line proto.y:2 -package protoparse +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by goyacc -o proto.y.go -l -p proto proto.y. DO NOT EDIT. +package parser import __yyfmt__ "fmt" -//line proto.y:2 - //lint:file-ignore SA4006 generated parser has unused values import ( "math" - "github.com/jhump/protoreflect/desc/protoparse/ast" + "github.com/bufbuild/protocompile/ast" ) -//line proto.y:16 type protoSymType struct { yys int file *ast.FileNode @@ -210,10 +219,7 @@ const protoEofCode = 1 const protoErrCode = 2 const protoInitialStackSize = 16 -//line proto.y:1205 - -//line yacctab:1 -var protoExca = [...]int{ +var protoExca = [...]int16{ -1, 0, 1, 4, -2, 0, @@ -230,461 +236,462 @@ var protoExca = [...]int{ 1, 3, -2, 0, -1, 95, - 55, 181, + 55, 185, -2, 0, -1, 96, - 55, 169, + 55, 173, -2, 0, -1, 97, - 55, 198, + 55, 202, -2, 0, -1, 99, - 55, 207, + 55, 210, -2, 0, -1, 110, - 55, 53, + 55, 54, -2, 0, -1, 289, - 55, 51, - 61, 51, + 55, 52, + 61, 52, -2, 0, - -1, 353, - 61, 53, + -1, 354, + 61, 54, -2, 0, - -1, 368, - 55, 119, + -1, 370, + 55, 124, -2, 0, - -1, 402, - 61, 53, + -1, 404, + 61, 54, -2, 0, - -1, 406, - 61, 53, + -1, 409, + 61, 54, -2, 0, - -1, 543, - 55, 181, + -1, 497, + 61, 54, -2, 0, -1, 547, - 55, 181, + 55, 185, -2, 0, -1, 551, - 55, 181, + 55, 185, + -2, 0, + -1, 555, + 55, 185, -2, 0, - -1, 569, - 55, 219, + -1, 573, + 55, 222, -2, 0, - -1, 575, - 55, 181, + -1, 580, + 55, 185, -2, 0, - -1, 578, - 55, 181, + -1, 583, + 55, 185, -2, 0, - -1, 581, - 55, 181, + -1, 586, + 55, 185, -2, 0, - -1, 602, - 55, 181, + -1, 607, + 55, 185, -2, 0, - -1, 612, - 55, 181, + -1, 619, + 55, 185, -2, 0, } const protoPrivate = 57344 -const protoLast = 2437 - -var protoAct = [...]int{ - 118, 117, 125, 8, 405, 8, 8, 588, 364, 420, - 81, 427, 31, 397, 288, 326, 328, 107, 317, 82, - 311, 404, 106, 105, 281, 8, 124, 228, 139, 177, - 77, 79, 80, 26, 84, 422, 30, 410, 602, 540, - 350, 110, 85, 600, 565, 87, 88, 89, 409, 353, - 563, 365, 561, 75, 351, 551, 549, 547, 365, 365, - 545, 543, 541, 534, 533, 365, 528, 365, 365, 521, - 365, 365, 509, 511, 365, 365, 479, 365, 363, 496, - 411, 365, 570, 398, 365, 532, 329, 365, 116, 94, - 320, 365, 329, 365, 29, 329, 560, 104, 538, 178, - 349, 535, 282, 98, 349, 109, 77, 349, 348, 539, - 500, 103, 348, 536, 572, 348, 501, 571, 302, 349, - 347, 512, 483, 293, 230, 185, 14, 348, 346, 115, - 497, 478, 4, 15, 389, 372, 16, 17, 366, 520, - 344, 339, 304, 306, 308, 330, 612, 310, 321, 314, - 315, 330, 93, 14, 330, 91, 318, 581, 578, 316, - 15, 319, 285, 16, 17, 575, 591, 19, 18, 20, - 21, 591, 568, 17, 569, 285, 13, 17, 283, 178, - 368, 99, 17, 97, 96, 95, 17, 610, 606, 586, - 585, 584, 579, 576, 19, 18, 20, 21, 573, 567, - 559, 553, 318, 13, 524, 185, 323, 286, 516, 419, - 388, 371, 284, 370, 342, 340, 590, 333, 324, 604, - 286, 590, 303, 287, 102, 284, 101, 100, 90, 86, - 25, 557, 556, 513, 486, 485, 484, 417, 416, 415, - 414, 413, 412, 395, 334, 335, 336, 369, 362, 337, - 325, 92, 24, 488, 230, 332, 424, 390, 338, 374, - 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 367, 122, 11, 583, 11, 11, 120, 10, 582, - 10, 10, 527, 282, 121, 9, 5, 9, 9, 526, - 23, 525, 425, 29, 313, 11, 508, 300, 298, 343, - 10, 507, 293, 506, 345, 341, 505, 9, 299, 23, - 504, 503, 297, 295, 354, 352, 487, 356, 357, 358, - 359, 360, 361, 296, 29, 280, 476, 313, 418, 391, - 27, 28, 29, 3, 12, 227, 22, 179, 176, 123, - 327, 386, 387, 312, 180, 128, 426, 392, 393, 394, - 137, 127, 430, 126, 229, 119, 429, 289, 290, 396, - 433, 236, 134, 109, 109, 435, 293, 237, 407, 140, - 183, 428, 437, 401, 399, 239, 143, 373, 77, 108, - 292, 76, 587, 421, 7, 6, 2, 423, 1, 0, - 318, 477, 0, 0, 0, 0, 480, 0, 0, 0, - 0, 0, 0, 0, 0, 481, 0, 482, 0, 490, - 0, 0, 0, 109, 0, 293, 0, 494, 0, 293, - 0, 498, 492, 0, 0, 0, 0, 510, 0, 428, - 502, 0, 0, 0, 0, 0, 0, 0, 515, 0, - 0, 0, 0, 0, 0, 0, 517, 518, 0, 0, - 0, 0, 0, 0, 0, 0, 519, 0, 0, 0, +const protoLast = 2396 + +var protoAct = [...]int16{ + 31, 118, 117, 125, 8, 106, 8, 8, 496, 494, + 593, 423, 366, 406, 399, 430, 81, 325, 77, 79, + 80, 82, 84, 327, 316, 107, 8, 310, 411, 408, + 105, 280, 124, 228, 139, 177, 407, 413, 30, 425, + 544, 26, 351, 110, 605, 607, 569, 567, 412, 565, + 85, 354, 555, 87, 88, 89, 352, 75, 367, 367, + 553, 367, 367, 551, 367, 367, 549, 547, 545, 537, + 536, 531, 524, 514, 512, 367, 367, 481, 500, 499, + 367, 367, 365, 367, 574, 414, 367, 367, 110, 367, + 535, 400, 367, 109, 77, 94, 409, 367, 328, 116, + 178, 104, 405, 281, 110, 98, 328, 346, 319, 346, + 576, 292, 409, 103, 346, 345, 577, 345, 543, 301, + 346, 564, 345, 541, 346, 504, 598, 344, 345, 503, + 230, 185, 345, 115, 485, 309, 346, 313, 314, 287, + 597, 538, 515, 350, 345, 501, 480, 391, 303, 305, + 307, 349, 374, 29, 328, 368, 523, 329, 338, 320, + 343, 93, 434, 318, 317, 329, 315, 440, 441, 442, + 443, 444, 445, 17, 446, 447, 448, 449, 91, 619, + 178, 450, 451, 452, 453, 454, 455, 456, 457, 458, + 459, 460, 461, 462, 463, 464, 436, 465, 466, 467, + 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, + 317, 185, 322, 329, 14, 517, 572, 586, 573, 438, + 4, 15, 284, 583, 16, 17, 580, 14, 596, 284, + 596, 370, 99, 17, 15, 97, 336, 16, 17, 17, + 17, 17, 96, 95, 617, 611, 591, 590, 589, 333, + 334, 335, 584, 581, 578, 19, 18, 20, 21, 337, + 230, 331, 571, 563, 13, 557, 527, 285, 19, 18, + 20, 21, 283, 519, 285, 339, 422, 13, 595, 283, + 595, 609, 390, 281, 373, 372, 342, 341, 332, 323, + 292, 302, 286, 102, 101, 100, 90, 355, 86, 25, + 561, 560, 516, 488, 358, 359, 360, 361, 362, 363, + 487, 340, 486, 420, 419, 356, 418, 417, 347, 416, + 415, 353, 397, 371, 364, 324, 92, 24, 490, 427, + 392, 369, 29, 5, 394, 395, 396, 23, 27, 28, + 122, 11, 388, 11, 11, 588, 120, 10, 389, 10, + 10, 587, 109, 299, 297, 292, 23, 355, 355, 530, + 398, 29, 312, 11, 298, 428, 296, 294, 77, 10, + 529, 528, 121, 9, 431, 9, 9, 295, 511, 510, + 509, 403, 401, 376, 377, 378, 379, 380, 381, 382, + 383, 384, 385, 386, 387, 9, 426, 508, 507, 479, + 317, 506, 482, 109, 489, 292, 478, 312, 421, 483, + 292, 393, 29, 282, 279, 3, 484, 492, 22, 12, + 227, 179, 176, 123, 326, 311, 180, 128, 429, 137, + 127, 433, 126, 431, 513, 505, 520, 521, 229, 432, + 119, 289, 434, 290, 435, 518, 235, 440, 441, 442, + 443, 444, 445, 17, 446, 447, 448, 449, 134, 437, + 522, 450, 451, 452, 453, 454, 455, 456, 457, 458, + 459, 460, 461, 462, 463, 464, 436, 465, 466, 467, + 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, + 236, 525, 140, 183, 439, 238, 143, 526, 292, 438, + 375, 108, 532, 291, 76, 533, 592, 355, 534, 424, + 7, 6, 2, 1, 0, 542, 77, 109, 0, 546, + 548, 550, 552, 554, 556, 559, 539, 558, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, + 0, 566, 568, 570, 0, 562, 0, 0, 575, 0, + 579, 0, 0, 0, 582, 0, 0, 0, 585, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 523, - 0, 0, 0, 0, 0, 0, 529, 0, 0, 0, - 531, 0, 530, 0, 0, 0, 0, 0, 0, 0, - 109, 0, 542, 544, 546, 548, 550, 552, 555, 537, - 0, 0, 554, 0, 0, 77, 109, 0, 0, 0, - 0, 0, 0, 0, 562, 564, 566, 0, 0, 0, - 558, 0, 0, 0, 0, 574, 0, 0, 0, 577, - 0, 0, 0, 580, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 589, 0, 0, 302, 0, 595, 302, 0, - 597, 302, 0, 599, 109, 109, 0, 0, 0, 0, - 589, 601, 603, 592, 593, 605, 302, 0, 302, 0, - 302, 0, 0, 0, 611, 0, 0, 0, 0, 0, - 0, 0, 302, 0, 614, 302, 493, 0, 29, 114, - 111, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 0, 0, 0, 0, 110, 0, - 0, 0, 0, 0, 0, 0, 406, 113, 112, 0, - 0, 0, 491, 29, 114, 111, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, - 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, - 0, 406, 113, 112, 0, 0, 0, 403, 29, 114, - 111, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 0, 0, 0, 0, 110, 0, - 0, 0, 0, 0, 0, 0, 402, 113, 112, 0, - 0, 400, 29, 114, 111, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 0, 0, - 0, 0, 110, 0, 0, 0, 0, 0, 0, 0, - 406, 113, 112, 29, 114, 111, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, - 0, 0, 0, 110, 0, 0, 0, 0, 0, 499, - 0, 0, 113, 112, 32, 33, 34, 35, 36, 37, + 0, 0, 0, 0, 0, 0, 0, 594, 0, 0, + 0, 301, 0, 600, 301, 0, 602, 301, 0, 604, + 0, 0, 0, 0, 0, 0, 594, 0, 109, 109, + 606, 608, 301, 610, 301, 0, 301, 612, 613, 0, + 618, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 301, 0, 621, 301, 495, 0, 29, 114, 111, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 0, 0, 0, 0, 110, 0, 0, 0, + 0, 0, 0, 0, 497, 113, 112, 0, 0, 0, + 493, 29, 114, 111, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 495, 0, 0, 0, 294, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 408, 0, 0, 0, 294, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 291, 0, 0, 0, 294, 32, 33, 34, + 0, 110, 0, 0, 0, 0, 0, 0, 0, 404, + 113, 112, 0, 0, 402, 29, 114, 111, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 0, 0, 0, 0, 110, 0, 0, 0, 0, + 0, 0, 0, 497, 113, 112, 29, 114, 111, 32, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 0, 0, 0, 0, 110, 0, 0, 0, + 0, 0, 540, 0, 0, 113, 112, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 294, 32, 33, + 0, 0, 0, 502, 0, 0, 0, 293, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 130, 0, 0, 0, 78, 144, 145, 146, - 147, 148, 149, 17, 150, 151, 152, 153, 133, 132, - 131, 154, 155, 156, 157, 158, 159, 160, 161, 162, - 163, 164, 165, 166, 167, 168, 169, 136, 142, 135, - 170, 171, 138, 19, 18, 20, 172, 173, 174, 175, - 0, 0, 129, 0, 0, 615, 130, 0, 0, 141, - 0, 144, 145, 146, 147, 148, 149, 17, 150, 151, - 152, 153, 133, 132, 131, 154, 155, 156, 157, 158, - 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, - 169, 136, 142, 135, 170, 171, 138, 19, 18, 20, - 172, 173, 174, 175, 0, 0, 129, 0, 0, 613, - 130, 0, 0, 141, 0, 144, 145, 146, 147, 148, - 149, 17, 150, 151, 152, 153, 133, 132, 131, 154, - 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 136, 142, 135, 170, 171, - 138, 19, 18, 20, 172, 173, 174, 175, 0, 0, - 129, 0, 0, 609, 130, 0, 0, 141, 0, 144, - 145, 146, 147, 148, 149, 17, 150, 151, 152, 153, - 133, 132, 131, 154, 155, 156, 157, 158, 159, 160, - 161, 162, 163, 164, 165, 166, 167, 168, 169, 136, - 142, 135, 170, 171, 138, 19, 18, 20, 172, 173, - 174, 175, 0, 0, 129, 0, 0, 608, 130, 0, - 0, 141, 0, 144, 145, 146, 147, 148, 149, 17, - 150, 151, 152, 153, 133, 132, 131, 154, 155, 156, - 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, - 167, 168, 169, 136, 142, 135, 170, 171, 138, 19, - 18, 20, 172, 173, 174, 175, 0, 0, 129, 0, - 0, 607, 130, 0, 0, 141, 0, 144, 145, 146, - 147, 148, 149, 17, 150, 151, 152, 153, 133, 132, - 131, 154, 155, 156, 157, 158, 159, 160, 161, 162, - 163, 164, 165, 166, 167, 168, 169, 136, 142, 135, - 170, 171, 138, 19, 18, 20, 172, 173, 174, 175, - 0, 0, 129, 0, 0, 598, 130, 0, 0, 141, - 0, 144, 145, 146, 147, 148, 149, 17, 150, 151, - 152, 153, 133, 132, 131, 154, 155, 156, 157, 158, - 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, - 169, 136, 142, 135, 170, 171, 138, 19, 18, 20, - 172, 173, 174, 175, 0, 0, 129, 0, 0, 596, - 130, 0, 0, 141, 0, 144, 145, 146, 147, 148, - 149, 17, 150, 151, 152, 153, 133, 132, 131, 154, - 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 136, 142, 135, 170, 171, - 138, 19, 18, 20, 172, 173, 174, 175, 0, 0, - 129, 0, 0, 594, 232, 0, 0, 141, 0, 240, - 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, - 235, 234, 233, 251, 252, 253, 254, 255, 256, 257, - 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, - 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, - 278, 279, 0, 0, 231, 0, 0, 331, 130, 0, - 0, 238, 0, 144, 145, 146, 147, 148, 149, 17, - 150, 151, 152, 153, 133, 132, 131, 154, 155, 156, - 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, - 167, 168, 169, 136, 142, 135, 170, 171, 138, 19, - 18, 20, 172, 173, 174, 175, 0, 0, 129, 0, - 0, 301, 130, 0, 0, 141, 0, 144, 145, 146, - 147, 148, 149, 17, 150, 151, 152, 153, 133, 132, - 131, 154, 155, 156, 157, 158, 159, 160, 161, 162, - 163, 164, 165, 166, 167, 168, 169, 136, 142, 135, - 170, 171, 138, 19, 18, 20, 172, 173, 174, 175, - 0, 0, 129, 0, 0, 232, 0, 0, 0, 141, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - 250, 235, 234, 233, 251, 252, 253, 254, 255, 256, - 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, - 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, - 277, 278, 279, 0, 0, 231, 0, 0, 0, 0, - 0, 0, 238, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 0, 0, 0, 0, - 0, 432, 0, 0, 0, 83, 438, 439, 440, 441, - 442, 443, 17, 444, 445, 446, 447, 0, 0, 0, - 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, - 458, 459, 460, 461, 462, 434, 463, 464, 465, 466, - 467, 468, 469, 470, 471, 472, 473, 474, 475, 0, - 0, 431, 0, 0, 514, 0, 0, 0, 436, 32, + 0, 0, 0, 0, 498, 0, 0, 0, 293, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, - 489, 74, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 83, 32, 33, 34, 35, 36, 37, 38, 39, + 73, 74, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 410, 0, 0, 0, 293, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 348, 0, 0, 0, + 293, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 288, 0, 0, + 0, 293, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 309, 62, 63, 64, 65, 66, 67, 68, 69, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 83, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 307, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 83, 32, 33, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 293, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 130, 0, 0, + 0, 78, 144, 145, 146, 147, 148, 149, 17, 150, + 151, 152, 153, 133, 132, 131, 154, 155, 156, 157, + 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, + 168, 169, 136, 142, 135, 170, 171, 138, 19, 18, + 20, 172, 173, 174, 175, 0, 0, 129, 0, 0, + 622, 130, 0, 0, 141, 0, 144, 145, 146, 147, + 148, 149, 17, 150, 151, 152, 153, 133, 132, 131, + 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, + 164, 165, 166, 167, 168, 169, 136, 142, 135, 170, + 171, 138, 19, 18, 20, 172, 173, 174, 175, 0, + 0, 129, 0, 0, 620, 130, 0, 0, 141, 0, + 144, 145, 146, 147, 148, 149, 17, 150, 151, 152, + 153, 133, 132, 131, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 136, 142, 135, 170, 171, 138, 19, 18, 20, 172, + 173, 174, 175, 0, 0, 129, 0, 0, 616, 130, + 0, 0, 141, 0, 144, 145, 146, 147, 148, 149, + 17, 150, 151, 152, 153, 133, 132, 131, 154, 155, + 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, + 166, 167, 168, 169, 136, 142, 135, 170, 171, 138, + 19, 18, 20, 172, 173, 174, 175, 0, 0, 129, + 0, 0, 615, 130, 0, 0, 141, 0, 144, 145, + 146, 147, 148, 149, 17, 150, 151, 152, 153, 133, + 132, 131, 154, 155, 156, 157, 158, 159, 160, 161, + 162, 163, 164, 165, 166, 167, 168, 169, 136, 142, + 135, 170, 171, 138, 19, 18, 20, 172, 173, 174, + 175, 0, 0, 129, 0, 0, 614, 130, 0, 0, + 141, 0, 144, 145, 146, 147, 148, 149, 17, 150, + 151, 152, 153, 133, 132, 131, 154, 155, 156, 157, + 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, + 168, 169, 136, 142, 135, 170, 171, 138, 19, 18, + 20, 172, 173, 174, 175, 0, 0, 129, 0, 0, + 603, 130, 0, 0, 141, 0, 144, 145, 146, 147, + 148, 149, 17, 150, 151, 152, 153, 133, 132, 131, + 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, + 164, 165, 166, 167, 168, 169, 136, 142, 135, 170, + 171, 138, 19, 18, 20, 172, 173, 174, 175, 0, + 0, 129, 0, 0, 601, 130, 0, 0, 141, 0, + 144, 145, 146, 147, 148, 149, 17, 150, 151, 152, + 153, 133, 132, 131, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, + 136, 142, 135, 170, 171, 138, 19, 18, 20, 172, + 173, 174, 175, 0, 0, 129, 0, 0, 599, 130, + 0, 0, 141, 0, 144, 145, 146, 147, 148, 149, + 17, 150, 151, 152, 153, 133, 132, 131, 154, 155, + 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, + 166, 167, 168, 169, 136, 142, 135, 170, 171, 138, + 19, 18, 20, 172, 173, 174, 175, 0, 0, 129, + 0, 0, 300, 130, 0, 0, 141, 0, 144, 145, + 146, 147, 148, 149, 17, 150, 151, 152, 153, 133, + 132, 131, 154, 155, 156, 157, 158, 159, 160, 161, + 162, 163, 164, 165, 166, 167, 168, 169, 136, 142, + 135, 170, 171, 138, 19, 18, 20, 172, 173, 174, + 175, 0, 0, 129, 0, 0, 231, 0, 0, 0, + 141, 239, 240, 241, 242, 243, 244, 245, 246, 247, + 248, 249, 234, 233, 232, 250, 251, 252, 253, 254, + 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 0, 0, 0, 0, 0, 330, + 231, 0, 0, 237, 0, 239, 240, 241, 242, 243, + 244, 245, 246, 247, 248, 249, 234, 233, 232, 250, + 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 237, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 305, 62, 63, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, - 74, 0, 0, 0, 0, 0, 432, 0, 0, 0, - 83, 438, 439, 440, 441, 442, 443, 17, 444, 445, - 446, 447, 0, 0, 0, 448, 449, 450, 451, 452, - 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, - 434, 463, 464, 465, 466, 467, 468, 469, 470, 471, - 472, 473, 474, 475, 0, 0, 431, 0, 0, 182, - 0, 0, 0, 436, 186, 187, 188, 189, 190, 191, - 17, 192, 193, 194, 195, 196, 197, 198, 199, 200, - 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, - 211, 212, 213, 214, 215, 216, 217, 218, 219, 184, - 220, 221, 222, 223, 224, 225, 226, 0, 182, 181, - 0, 0, 322, 186, 187, 188, 189, 190, 191, 17, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, - 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, - 212, 213, 214, 215, 216, 217, 218, 219, 184, 220, - 221, 222, 223, 224, 225, 226, 355, 0, 181, 0, - 0, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 74, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 83, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 32, 33, 34, 35, 36, 37, + 71, 72, 491, 74, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 83, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, + 58, 59, 60, 308, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 83, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 306, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 304, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 0, 0, 0, 0, 0, 182, 0, + 0, 0, 83, 186, 187, 188, 189, 190, 191, 17, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + 212, 213, 214, 215, 216, 217, 218, 219, 184, 220, + 221, 222, 223, 224, 225, 226, 0, 182, 181, 0, + 0, 321, 186, 187, 188, 189, 190, 191, 17, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, + 213, 214, 215, 216, 217, 218, 219, 184, 220, 221, + 222, 223, 224, 225, 226, 357, 0, 181, 0, 0, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, } -var protoPact = [...]int{ - 124, -1000, 151, 151, 201, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, 178, 320, 2387, 1171, 2387, 2387, - 1876, 2387, 151, -1000, 328, -1000, 177, 328, 328, 328, - 176, 96, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, +var protoPact = [...]int16{ + 212, -1000, 225, 225, 276, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, 247, 328, 2346, 1236, 2346, 2346, + 1941, 2346, 225, -1000, 408, -1000, 246, 408, 408, 408, + 244, 119, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, 200, 93, -1000, 1876, 131, - 130, 129, -1000, 2387, 127, 175, -1000, 174, 172, -1000, - -1000, 2387, 869, 1171, 22, 1770, 2296, 1823, -1000, 173, - -1000, -1000, -1000, -1000, 171, -1000, -1000, -1000, -1000, -1000, - 1110, -1000, 307, 292, -1000, -1000, -1000, 1716, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, 275, 102, -1000, 1941, 189, + 188, 181, -1000, 2346, 178, 243, -1000, 242, 241, -1000, + -1000, 2346, 812, 1236, 33, 1781, 2255, 1888, -1000, 227, + -1000, -1000, -1000, -1000, 240, -1000, -1000, -1000, -1000, -1000, + 1175, -1000, 361, 348, -1000, -1000, -1000, 1727, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 170, 2141, 2088, 2035, 2387, 322, 2387, 2387, 289, -1000, - -1000, 2387, 28, 89, -1000, -1000, -1000, -1000, -1000, -1000, + 239, 2153, 2100, 2047, 2346, 402, 2346, 2346, 357, -1000, + -1000, 2346, 46, 100, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, 2247, -1000, -1000, -1000, - -1000, -1000, 166, 199, 90, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, 2206, -1000, -1000, -1000, + -1000, -1000, 237, 274, 149, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, 1662, -1000, -1000, - -1000, -1000, 165, 2141, 2088, 2035, 2387, -1000, 2387, 82, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, 1834, -1000, -1000, + -1000, 236, 2153, 2100, 2047, 2346, -1000, 2346, 99, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 220, + -1000, -1000, -1000, -1000, 235, 2346, -1000, 105, 72, 1114, + 91, -11, -1000, 2303, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, 2346, 2346, 2346, 2346, 2346, 2346, 273, + 30, 95, 291, 177, 272, 233, 232, 92, -1000, 360, + 2346, -1000, -1000, -1000, 101, 230, 87, 290, -1000, 406, + -1000, -1000, -1000, 2346, 2346, 2346, 271, -1000, 2346, -1000, + -1000, -1000, 26, -1000, -1000, -1000, -1000, -1000, 84, -1000, + -1000, 687, 34, -1000, 1053, -1000, -20, 17, 269, 268, + 266, 265, 263, 262, 403, -1000, 224, 1236, 402, 324, + 440, 401, -1000, -1000, 408, 86, -1000, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 25, + -1000, 101, 93, -1000, 261, 259, 252, 399, -1000, 279, + 1994, -1000, 622, -1000, 992, -1000, 11, 10, 85, 931, + 68, 64, -1000, 2346, -1000, 396, 393, 392, 375, 374, + 373, 22, -1000, 5, 82, 251, -1000, -1000, -1000, 160, + -1000, -1000, -1000, -1000, 221, 2346, 2346, -1000, 2346, 97, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 160, -1000, -1000, -1000, -1000, 162, 2387, -1000, 85, 1110, - 68, 67, -13, -1000, 2344, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, 2387, 2387, 2387, 2387, 2387, 2387, - 197, 26, 78, 231, 126, 196, 161, 159, 75, -1000, - 236, 2387, -1000, -1000, -1000, 87, 158, 74, 217, -1000, - 324, -1000, -1000, -1000, 2387, 2387, 2387, 192, -1000, 2387, - -1000, -1000, -1000, 18, -1000, -1000, -1000, -1000, -1000, -1000, - 744, 679, -1000, 1049, -20, 12, 191, 190, 189, 188, - 187, 186, 323, -1000, 157, 1171, 322, 251, 2194, 321, - -1000, -1000, 328, 71, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, 24, -1000, 87, - 81, -1000, 185, 184, 183, 311, -1000, 204, 1982, -1000, - 614, -1000, 988, -1000, 11, 70, 927, 49, 55, -1000, - 2387, -1000, 306, 305, 301, 298, 296, 291, 20, -1000, - 5, 61, 182, -1000, -1000, -1000, 1929, -1000, -1000, -1000, - -1000, -1000, 156, 2387, 2387, -1000, 2387, 80, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, -1000, -1000, 17, -1000, 1876, -1000, - 152, -1000, -1000, -1000, 286, 284, 277, 14, 18, 1876, - 19, -1000, -4, -5, 40, 52, -1000, 808, 37, 48, - -1000, -1000, -29, 10, 7, 8, 3, 4, 1, -1000, - 149, -1000, 1171, 869, -1000, -1000, -1000, 181, 180, -1000, - 2387, -1000, 148, 35, -1000, 0, -2, -8, -1000, 147, - 120, 16, -1000, -1000, -1000, -1000, -1000, -1000, 57, 54, - -1000, -1000, 146, 1770, 111, -1000, 141, 1770, 104, -1000, - 140, 1770, 103, -1000, -1000, -1000, 274, 269, -1000, -1000, - -1000, -1000, 139, -1000, 138, -1000, 137, -1000, -1000, 169, - -1000, 808, 808, -1000, 1608, 1770, -1000, 1554, 1770, -1000, - 1500, 1770, -9, -16, -1000, -1000, -1000, 164, -1000, -1000, - -1000, 136, -1000, -1000, -1000, 1446, -1000, 1392, -1000, 1338, - -1000, 135, 1770, 92, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, 1284, 1770, -1000, 1230, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 20, -1000, + 1941, -1000, 214, -1000, -1000, -1000, 366, 365, 354, 19, + 26, 1941, 24, -1000, 2, 1, 81, 870, 62, -1000, + -1000, 50, 57, -1000, -1000, -28, 16, 13, 14, 9, + 8, -2, -1000, 213, -1000, 1236, 812, -1000, -1000, -1000, + 250, 249, -1000, 2346, -1000, 211, 60, -1000, -3, -5, + -6, -1000, 210, 164, 18, -1000, -1000, -1000, 751, 49, + 55, -1000, -1000, -1000, -1000, -1000, 202, 1781, 172, -1000, + 201, 1781, 169, -1000, 200, 1781, 163, -1000, -1000, -1000, + 346, 340, -1000, -1000, -1000, -1000, 196, -1000, 195, -1000, + 194, -1000, -1000, 228, -1000, -1000, 80, 66, -1000, 1673, + 1781, -1000, 1619, 1781, -1000, 1565, 1781, -8, -9, -1000, + -1000, -1000, 226, -1000, -1000, -1000, 193, 751, 751, -1000, + 1511, -1000, 1457, -1000, 1403, -1000, 192, 1781, 125, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 1349, 1781, + -1000, 1295, -1000, } -var protoPgo = [...]int{ - 0, 388, 386, 286, 333, 385, 384, 2, 383, 9, - 7, 382, 381, 380, 35, 8, 4, 23, 22, 379, - 16, 12, 377, 376, 375, 372, 370, 19, 369, 367, - 365, 10, 362, 361, 360, 21, 358, 357, 14, 356, - 355, 354, 353, 26, 352, 351, 350, 284, 0, 1, - 11, 346, 18, 345, 344, 28, 343, 340, 20, 15, - 339, 277, 29, 338, 337, 272, 27, 335, 17, 334, - 24, 325, 178, 13, +var protoPgo = [...]int16{ + 0, 513, 512, 333, 415, 511, 510, 3, 509, 11, + 10, 506, 504, 503, 39, 12, 8, 30, 5, 29, + 501, 23, 0, 500, 496, 495, 494, 493, 21, 492, + 490, 459, 16, 458, 446, 444, 9, 13, 443, 441, + 28, 440, 439, 438, 432, 32, 431, 430, 429, 372, + 1, 2, 15, 428, 24, 427, 426, 34, 425, 424, + 27, 17, 423, 346, 35, 422, 421, 340, 33, 420, + 25, 419, 31, 414, 413, 14, } -var protoR1 = [...]int{ +var protoR1 = [...]int8{ 0, 1, 1, 1, 1, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 5, - 5, 6, 27, 27, 28, 28, 29, 29, 30, 30, + 5, 6, 28, 28, 29, 29, 30, 30, 31, 31, 7, 14, 14, 12, 12, 16, 16, 17, 17, 17, - 19, 19, 19, 19, 19, 19, 19, 19, 68, 68, - 18, 38, 38, 38, 37, 37, 37, 37, 37, 37, - 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 13, 13, 13, 13, 35, 35, 35, 35, - 35, 35, 31, 31, 32, 32, 33, 33, 34, 34, - 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, - 41, 41, 41, 41, 41, 41, 15, 9, 9, 8, - 43, 43, 43, 43, 43, 43, 42, 51, 51, 51, - 50, 50, 50, 50, 50, 50, 39, 39, 44, 44, - 45, 45, 46, 22, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 60, 60, 58, 58, 56, - 56, 56, 59, 59, 57, 57, 57, 20, 20, 53, - 53, 54, 54, 55, 52, 52, 61, 63, 63, 63, - 62, 62, 62, 62, 62, 62, 64, 64, 47, 49, - 49, 49, 48, 48, 48, 48, 48, 48, 48, 48, - 48, 48, 48, 48, 48, 65, 67, 67, 67, 66, - 66, 66, 66, 66, 69, 71, 71, 71, 70, 70, - 70, 70, 70, 72, 72, 73, 73, 11, 11, 11, - 10, 10, 10, 10, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, - 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, + 20, 20, 20, 20, 20, 20, 20, 20, 70, 70, + 18, 18, 40, 40, 40, 39, 39, 39, 39, 39, + 39, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 13, 13, 13, 13, 37, 37, 19, 19, + 19, 36, 36, 36, 36, 36, 36, 32, 32, 33, + 33, 34, 34, 35, 35, 41, 41, 41, 41, 41, + 41, 41, 41, 43, 43, 43, 43, 43, 43, 43, + 43, 15, 9, 9, 8, 45, 45, 45, 45, 45, + 45, 44, 53, 53, 53, 52, 52, 52, 52, 52, + 42, 42, 46, 46, 47, 47, 48, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 62, + 62, 60, 60, 58, 58, 58, 61, 61, 59, 59, + 59, 21, 21, 55, 55, 56, 56, 57, 54, 54, + 63, 65, 65, 65, 64, 64, 64, 64, 64, 64, + 66, 66, 49, 51, 51, 51, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 67, + 69, 69, 69, 68, 68, 68, 68, 71, 73, 73, + 73, 72, 72, 72, 72, 72, 74, 74, 75, 75, + 11, 11, 11, 10, 10, 10, 10, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 24, 24, 24, 24, 24, 24, 24, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 22, } -var protoR2 = [...]int{ +var protoR2 = [...]int8{ 0, 1, 1, 2, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 4, 3, 4, 4, 3, 1, 3, 1, 3, 1, 3, 1, 3, 5, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1, 2, - 3, 1, 2, 0, 1, 2, 2, 2, 2, 1, - 3, 3, 4, 4, 5, 5, 3, 2, 5, 4, - 5, 4, 1, 3, 5, 3, 1, 3, 3, 5, - 3, 5, 1, 2, 1, 2, 1, 2, 1, 2, - 6, 6, 6, 7, 7, 7, 5, 6, 6, 6, - 6, 7, 7, 7, 5, 6, 3, 1, 3, 3, - 8, 8, 8, 9, 9, 9, 5, 2, 1, 0, - 1, 1, 1, 1, 2, 1, 5, 6, 7, 8, - 5, 6, 6, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 3, 4, 1, 3, 1, - 3, 3, 1, 3, 1, 3, 3, 1, 2, 3, - 1, 3, 1, 3, 1, 3, 5, 2, 1, 0, - 1, 1, 1, 1, 2, 1, 4, 5, 5, 2, - 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 1, 5, 2, 1, 0, 1, - 1, 1, 2, 1, 5, 2, 1, 0, 1, 1, - 1, 2, 1, 6, 8, 4, 3, 2, 1, 0, - 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 3, 3, 1, 2, 0, 1, 2, 2, 2, 2, + 1, 3, 3, 4, 4, 5, 5, 4, 3, 2, + 5, 4, 1, 3, 5, 3, 1, 3, 1, 3, + 3, 1, 3, 3, 5, 3, 5, 1, 2, 1, + 2, 1, 2, 1, 2, 6, 6, 6, 7, 7, + 7, 5, 6, 6, 6, 6, 7, 7, 7, 5, + 6, 3, 1, 3, 3, 8, 8, 8, 9, 9, + 9, 5, 2, 1, 0, 1, 1, 1, 2, 1, + 5, 6, 7, 8, 5, 6, 6, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 4, 1, 3, 1, 3, 3, 1, 3, 1, 3, + 3, 1, 2, 3, 1, 3, 1, 3, 1, 3, + 5, 2, 1, 0, 1, 1, 1, 1, 2, 1, + 4, 5, 5, 2, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 1, 5, + 2, 1, 0, 1, 1, 2, 1, 5, 2, 1, + 0, 1, 1, 1, 2, 1, 6, 8, 4, 3, + 2, 1, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -704,139 +711,142 @@ var protoR2 = [...]int{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, } -var protoChk = [...]int{ - -1000, -1, -2, -4, 8, -3, -5, -6, -7, -47, - -61, -65, -69, 52, 2, 9, 12, 13, 44, 43, - 45, 46, -4, -3, 51, 52, -68, 10, 11, 4, - -27, -21, 7, 8, 9, 10, 11, 12, 13, 14, +var protoChk = [...]int16{ + -1000, -1, -2, -4, 8, -3, -5, -6, -7, -49, + -63, -67, -71, 52, 2, 9, 12, 13, 44, 43, + 45, 46, -4, -3, 51, 52, -70, 10, 11, 4, + -28, -22, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, -14, -12, -21, 65, -21, - -21, -31, -27, 59, -21, -68, 52, -68, -68, -68, - 52, 59, 51, 59, -31, 54, 54, 54, -27, 54, - 52, 52, 52, -27, -16, -17, -18, -68, -19, -21, - 54, 6, 64, 63, 5, -14, 66, -49, -48, -40, - -61, -47, -65, -60, -43, -7, -42, -45, -53, 52, - 2, 20, 19, 18, -32, 39, 37, -46, 42, -55, - -28, 59, 38, -23, 7, 8, 9, 10, 11, 12, + 45, 46, 47, 48, 49, -14, -12, -22, 65, -22, + -22, -32, -28, 59, -22, -70, 52, -70, -70, -70, + 52, 59, 51, 59, -32, 54, 54, 54, -28, 54, + 52, 52, 52, -28, -16, -17, -18, -70, -20, -22, + 54, 6, 64, 63, 5, -14, 66, -51, -50, -41, + -63, -49, -67, -62, -45, -7, -44, -47, -55, 52, + 2, 20, 19, 18, -33, 39, 37, -48, 42, -57, + -29, 59, 38, -24, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 40, 41, 46, 47, 48, 49, -63, -62, -7, -64, - -54, 52, 2, -26, 42, -55, 7, 8, 9, 10, + 40, 41, 46, 47, 48, 49, -65, -64, -7, -66, + -56, 52, 2, -27, 42, -57, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 43, 44, 45, 46, 47, 48, 49, -67, -66, -41, - -43, 52, 2, 20, 19, 18, -33, -29, 59, -24, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - -71, -70, -7, -72, 52, 2, 47, 52, -38, -37, - -36, 2, -13, -21, 67, 6, 16, 5, 6, 16, - 5, 55, -48, 52, -31, 36, -31, 36, -31, 36, - -21, -58, -56, 5, -21, -21, -58, -52, -68, -27, - 62, 59, 55, -62, 52, 51, -59, -57, -20, 5, - 64, 55, -66, 52, -31, -31, -31, -21, -27, 59, - 55, -70, 52, -21, 55, -38, 60, 52, 60, 52, - 53, 67, -18, 62, -27, 2, -21, -21, -21, -21, - -21, -21, 51, 52, -15, 67, 60, 40, 54, 51, - 52, 52, 60, -22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, -27, -20, 52, 60, - 40, 5, -21, -21, -21, 51, -27, -73, 65, -17, - 67, -18, 62, 68, -35, -16, 62, -38, 2, 68, - 57, 68, 51, 51, 51, 51, 51, 51, 5, 52, - -9, -8, -14, -58, 5, 41, -51, -50, -7, -39, - -44, 52, 2, -34, 36, -30, 59, -25, 7, 8, - 9, 10, 11, 12, 14, 15, 16, 17, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 49, 5, -52, 60, 52, - -15, -59, -20, 41, 51, 51, 51, 5, 49, 48, - -31, 68, -35, 2, -38, 2, 68, 60, -38, 2, - 61, 61, -27, 5, 5, 5, 5, 5, 5, 52, - -15, 68, 60, 51, 55, -50, 52, -21, -21, -27, - 59, 52, -15, -31, 52, 5, 5, 5, 52, -15, - -73, -31, 66, 68, 68, 61, 61, -35, 61, 61, - 68, 52, -15, 54, -15, 52, -15, 54, -15, 52, - -15, 54, -15, 52, -9, -16, 51, 51, -27, 52, - 61, 52, -15, 52, -15, 52, -15, 52, 52, 54, - 66, 60, 60, 52, -49, 54, 52, -49, 54, 52, - -49, 54, 5, 5, 52, 52, 52, -11, -10, -7, - 52, 2, -35, -35, 55, -49, 55, -49, 55, -49, - 52, -15, 54, -15, 55, -10, 52, 55, 55, 55, - 52, -49, 54, 55, -49, 55, + 43, 44, 45, 46, 47, 48, 49, -69, -68, -43, + -45, 2, 20, 19, 18, -34, -30, 59, -25, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, -73, + -72, -7, -74, 52, 2, 47, 52, -40, 2, -39, + -38, -13, -22, 67, 6, 16, 5, 6, 16, 5, + 55, -50, 52, -32, 36, -32, 36, -32, 36, -22, + -60, -58, 5, -22, -22, -60, -54, -70, -28, 62, + 59, 55, -64, 52, 51, -61, -59, -21, 5, 64, + 55, -68, 52, -32, -32, -32, -22, -28, 59, 55, + -72, 52, -22, 55, 55, 60, 52, -40, 2, 60, + 52, 53, 67, -19, 62, -18, -28, 2, -22, -22, + -22, -22, -22, -22, 51, 52, -15, 67, 60, 40, + 54, 51, 52, 52, 60, -23, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, -28, -21, + 52, 60, 40, 5, -22, -22, -22, 51, -28, -75, + 65, -17, 67, -19, 62, 68, -37, 2, -19, 62, + 2, -40, 68, 57, 68, 51, 51, 51, 51, 51, + 51, 5, 52, -9, -8, -14, -60, 5, 41, -53, + -52, -7, -42, -46, 2, -35, 36, -31, 59, -26, + 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, 49, 5, -54, + 60, 52, -15, -61, -21, 41, 51, 51, 51, 5, + 49, 48, -32, 68, -36, 2, -16, 62, 2, 68, + 68, 60, 2, 61, 61, -28, 5, 5, 5, 5, + 5, 5, 52, -15, 68, 60, 51, 55, -52, 52, + -22, -22, -28, 59, 52, -15, -32, 52, 5, 5, + 5, 52, -15, -75, -32, 66, 68, 68, 60, -40, + 2, 61, -37, 61, 68, 52, -15, 54, -15, 52, + -15, 54, -15, 52, -15, 54, -15, 52, -9, -16, + 51, 51, -28, 52, 61, 52, -15, 52, -15, 52, + -15, 52, 52, 54, 66, -36, 61, 61, 52, -51, + 54, 52, -51, 54, 52, -51, 54, 5, 5, 52, + 52, 52, -11, -10, -7, 52, 2, 60, 60, 55, + -51, 55, -51, 55, -51, 52, -15, 54, -15, 55, + -10, 52, -36, -36, 55, 55, 55, 52, -51, 54, + 55, -51, 55, } -var protoDef = [...]int{ +var protoDef = [...]int16{ -2, -2, -2, -2, 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 0, 0, 0, 0, 0, 0, 0, -2, 5, 0, 15, 0, 0, 0, 48, - 0, 22, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, - 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, - 415, 416, 417, 418, 419, 0, 31, 33, 0, 0, - 0, 0, 82, 0, 0, 0, 18, 0, 0, 49, - 21, 0, 0, 0, 0, -2, -2, -2, 83, -2, + 0, 22, 380, 381, 382, 383, 384, 385, 386, 387, + 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, + 418, 419, 420, 421, 422, 0, 31, 33, 0, 0, + 0, 0, 87, 0, 0, 0, 18, 0, 0, 49, + 21, 0, 0, 0, 0, -2, -2, -2, 88, -2, 17, 19, 20, 23, 0, 35, 36, 37, 38, 39, - -2, 40, 0, 0, 45, 32, 34, 0, 180, 182, - 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, - 194, 0, 0, 0, 0, 0, 0, 0, 0, 160, - 84, 0, 250, 24, 224, 225, 226, 227, 228, 229, - 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - 251, 252, 253, 254, 255, 256, 0, 168, 170, 171, - 172, 173, 175, 0, 0, 162, 297, 298, 299, 300, - 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, - 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, - 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, - 331, 332, 333, 334, 335, 336, 337, 0, 197, 199, - 200, 201, 203, 0, 0, 0, 0, 86, 0, 26, - 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, - 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, - 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, - 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, - 0, 206, 208, 209, 210, 212, 0, 30, 0, -2, - 54, 59, 0, 72, 0, 41, 44, 47, 42, 43, - 46, 178, 179, 193, 0, 406, 0, 406, 0, 406, - 0, 0, 147, 149, 0, 0, 0, 0, 164, 85, - 0, 0, 166, 167, 174, 0, 0, 152, 154, 157, - 0, 195, 196, 202, 0, 0, 0, 0, 87, 0, - 204, 205, 211, 0, 50, 52, 55, 56, 57, 58, - 0, 0, 67, -2, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 145, 0, 0, 0, 0, -2, 0, - 159, 163, 0, 0, 133, 134, 135, 136, 137, 138, - 139, 140, 141, 142, 143, 144, 25, 0, 161, 0, - 0, 158, 0, 0, 0, 0, 27, 0, 0, 60, - 0, 66, -2, 61, 0, 76, -2, 0, 59, 73, - 0, 75, 0, 0, 0, 0, 0, 0, 0, 146, - 0, 107, 0, 148, 150, 151, 0, 118, 120, 121, - 122, 123, 125, 0, 363, 88, 0, 28, 338, 339, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 364, 365, 366, 367, 368, 369, 370, - 371, 372, 373, 374, 375, 376, 0, 165, 0, 176, - 0, 153, 155, 156, 0, 0, 0, 0, 0, 418, - 0, 62, 0, 0, 0, 59, 63, 0, 0, 59, - 69, 71, 0, 0, 0, 0, 0, 0, 0, 96, - 0, 106, 0, 0, 116, 117, 124, 0, 0, 89, - 0, 130, 0, 0, 177, 0, 0, 0, 104, 0, - 0, 0, 216, 64, 65, 68, 70, 77, 78, 80, - 74, 90, 0, -2, 0, 91, 0, -2, 0, 92, - 0, -2, 0, 97, 108, 109, 0, 0, 29, 131, - 132, 98, 0, 99, 0, 100, 0, 105, 213, -2, - 215, 0, 0, 93, 0, -2, 94, 0, -2, 95, - 0, -2, 0, 0, 101, 102, 103, 0, 218, 220, - 221, 223, 79, 81, 110, 0, 111, 0, 112, 0, - 126, 0, -2, 0, 214, 217, 222, 113, 114, 115, - 127, 0, -2, 128, 0, 129, + -2, 40, 0, 0, 45, 32, 34, 0, 184, 186, + 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, + 198, 0, 0, 0, 0, 0, 0, 0, 0, 164, + 89, 0, 253, 24, 227, 228, 229, 230, 231, 232, + 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, + 254, 255, 256, 257, 258, 259, 0, 172, 174, 175, + 176, 177, 179, 0, 0, 166, 300, 301, 302, 303, + 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, + 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, + 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, + 334, 335, 336, 337, 338, 339, 340, 0, 201, 203, + 204, 206, 0, 0, 0, 0, 91, 0, 26, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, + 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, + 291, 292, 293, 294, 295, 296, 297, 298, 299, 0, + 209, 211, 212, 213, 215, 0, 30, 0, 60, -2, + 55, 0, 72, 0, 41, 44, 47, 42, 43, 46, + 182, 183, 197, 0, 409, 0, 409, 0, 409, 0, + 0, 151, 153, 0, 0, 0, 0, 168, 90, 0, + 0, 170, 171, 178, 0, 0, 156, 158, 161, 0, + 199, 200, 205, 0, 0, 0, 0, 92, 0, 207, + 208, 214, 0, 50, 51, 58, 59, 53, 60, 56, + 57, 0, 0, 69, -2, 78, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 149, 0, 0, 0, 0, + -2, 0, 163, 167, 0, 0, 137, 138, 139, 140, + 141, 142, 143, 144, 145, 146, 147, 148, 25, 0, + 165, 0, 0, 162, 0, 0, 0, 0, 27, 0, + 0, 61, 0, 68, -2, 62, 0, 0, 76, -2, + 60, 0, 73, 0, 75, 0, 0, 0, 0, 0, + 0, 0, 150, 0, 112, 0, 152, 154, 155, 0, + 123, 125, 126, 127, 129, 0, 366, 93, 0, 28, + 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, + 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, + 361, 362, 363, 364, 365, 367, 368, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 0, 169, + 0, 180, 0, 157, 159, 160, 0, 0, 0, 0, + 0, 421, 0, 63, 0, 0, 81, -2, 60, 64, + 67, 0, 60, 71, 79, 0, 0, 0, 0, 0, + 0, 0, 101, 0, 111, 0, 0, 121, 122, 128, + 0, 0, 94, 0, 134, 0, 0, 181, 0, 0, + 0, 109, 0, 0, 0, 219, 65, 66, 0, 0, + 60, 70, 77, 80, 74, 95, 0, -2, 0, 96, + 0, -2, 0, 97, 0, -2, 0, 102, 113, 114, + 0, 0, 29, 135, 136, 103, 0, 104, 0, 105, + 0, 110, 216, -2, 218, 82, 83, 85, 98, 0, + -2, 99, 0, -2, 100, 0, -2, 0, 0, 106, + 107, 108, 0, 221, 223, 224, 226, 0, 0, 115, + 0, 116, 0, 117, 0, 130, 0, -2, 0, 217, + 220, 225, 84, 86, 118, 119, 120, 131, 0, -2, + 132, 0, 133, } -var protoTok1 = [...]int{ +var protoTok1 = [...]int8{ 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, @@ -852,7 +862,7 @@ var protoTok1 = [...]int{ 3, 3, 3, 54, 3, 55, 77, } -var protoTok2 = [...]int{ +var protoTok2 = [...]int8{ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, @@ -860,7 +870,7 @@ var protoTok2 = [...]int{ 42, 43, 44, 45, 46, 47, 48, 49, 50, } -var protoTok3 = [...]int{ +var protoTok3 = [...]int8{ 0, } @@ -870,8 +880,6 @@ var protoErrorMessages = [...]struct { msg string }{} -//line yaccpar:1 - /* parser for yacc output */ var ( @@ -942,9 +950,9 @@ func protoErrorMessage(state, lookAhead int) string { expected := make([]int, 0, 4) // Look for shiftable tokens. - base := protoPact[state] + base := int(protoPact[state]) for tok := TOKSTART; tok-1 < len(protoToknames); tok++ { - if n := base + tok; n >= 0 && n < protoLast && protoChk[protoAct[n]] == tok { + if n := base + tok; n >= 0 && n < protoLast && int(protoChk[int(protoAct[n])]) == tok { if len(expected) == cap(expected) { return res } @@ -954,13 +962,13 @@ func protoErrorMessage(state, lookAhead int) string { if protoDef[state] == -2 { i := 0 - for protoExca[i] != -1 || protoExca[i+1] != state { + for protoExca[i] != -1 || int(protoExca[i+1]) != state { i += 2 } // Look for tokens that we accept or reduce. for i += 2; protoExca[i] >= 0; i += 2 { - tok := protoExca[i] + tok := int(protoExca[i]) if tok < TOKSTART || protoExca[i+1] == 0 { continue } @@ -991,30 +999,30 @@ func protolex1(lex protoLexer, lval *protoSymType) (char, token int) { token = 0 char = lex.Lex(lval) if char <= 0 { - token = protoTok1[0] + token = int(protoTok1[0]) goto out } if char < len(protoTok1) { - token = protoTok1[char] + token = int(protoTok1[char]) goto out } if char >= protoPrivate { if char < protoPrivate+len(protoTok2) { - token = protoTok2[char-protoPrivate] + token = int(protoTok2[char-protoPrivate]) goto out } } for i := 0; i < len(protoTok3); i += 2 { - token = protoTok3[i+0] + token = int(protoTok3[i+0]) if token == char { - token = protoTok3[i+1] + token = int(protoTok3[i+1]) goto out } } out: if token == 0 { - token = protoTok2[1] /* unknown char */ + token = int(protoTok2[1]) /* unknown char */ } if protoDebug >= 3 { __yyfmt__.Printf("lex %s(%d)\n", protoTokname(token), uint(char)) @@ -1069,7 +1077,7 @@ protostack: protoS[protop].yys = protostate protonewstate: - proton = protoPact[protostate] + proton = int(protoPact[protostate]) if proton <= protoFlag { goto protodefault /* simple state */ } @@ -1080,8 +1088,8 @@ protonewstate: if proton < 0 || proton >= protoLast { goto protodefault } - proton = protoAct[proton] - if protoChk[proton] == prototoken { /* valid shift */ + proton = int(protoAct[proton]) + if int(protoChk[proton]) == prototoken { /* valid shift */ protorcvr.char = -1 prototoken = -1 protoVAL = protorcvr.lval @@ -1094,7 +1102,7 @@ protonewstate: protodefault: /* default state action */ - proton = protoDef[protostate] + proton = int(protoDef[protostate]) if proton == -2 { if protorcvr.char < 0 { protorcvr.char, prototoken = protolex1(protolex, &protorcvr.lval) @@ -1103,18 +1111,18 @@ protodefault: /* look through exception table */ xi := 0 for { - if protoExca[xi+0] == -1 && protoExca[xi+1] == protostate { + if protoExca[xi+0] == -1 && int(protoExca[xi+1]) == protostate { break } xi += 2 } for xi += 2; ; xi += 2 { - proton = protoExca[xi+0] + proton = int(protoExca[xi+0]) if proton < 0 || proton == prototoken { break } } - proton = protoExca[xi+1] + proton = int(protoExca[xi+1]) if proton < 0 { goto ret0 } @@ -1136,10 +1144,10 @@ protodefault: /* find a state where "error" is a legal shift action */ for protop >= 0 { - proton = protoPact[protoS[protop].yys] + protoErrCode + proton = int(protoPact[protoS[protop].yys]) + protoErrCode if proton >= 0 && proton < protoLast { - protostate = protoAct[proton] /* simulate a shift of "error" */ - if protoChk[protostate] == protoErrCode { + protostate = int(protoAct[proton]) /* simulate a shift of "error" */ + if int(protoChk[protostate]) == protoErrCode { goto protostack } } @@ -1175,7 +1183,7 @@ protodefault: protopt := protop _ = protopt // guard against "declared and not used" - protop -= protoR2[proton] + protop -= int(protoR2[proton]) // protop is now the index of $0. Perform the default action. Iff the // reduced production is ε, $1 is possibly out of range. if protop+1 >= len(protoS) { @@ -1186,16 +1194,16 @@ protodefault: protoVAL = protoS[protop+1] /* consult goto table to find next state */ - proton = protoR1[proton] - protog := protoPgo[proton] + proton = int(protoR1[proton]) + protog := int(protoPgo[proton]) protoj := protog + protoS[protop].yys + 1 if protoj >= protoLast { - protostate = protoAct[protog] + protostate = int(protoAct[protog]) } else { - protostate = protoAct[protoj] - if protoChk[protostate] != -proton { - protostate = protoAct[protog] + protostate = int(protoAct[protoj]) + if int(protoChk[protostate]) != -proton { + protostate = int(protoAct[protog]) } } // dummy call; replaced with literal code @@ -1203,33 +1211,34 @@ protodefault: case 1: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:143 { - protoVAL.file = ast.NewFileNode(protoDollar[1].syn, nil) - protolex.(*protoLex).res = protoVAL.file + lex := protolex.(*protoLex) + protoVAL.file = ast.NewFileNode(lex.info, protoDollar[1].syn, nil, lex.eof) + lex.res = protoVAL.file } case 2: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:147 { - protoVAL.file = ast.NewFileNode(nil, protoDollar[1].fileDecls) - protolex.(*protoLex).res = protoVAL.file + lex := protolex.(*protoLex) + protoVAL.file = ast.NewFileNode(lex.info, nil, protoDollar[1].fileDecls, lex.eof) + lex.res = protoVAL.file } case 3: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:151 { - protoVAL.file = ast.NewFileNode(protoDollar[1].syn, protoDollar[2].fileDecls) - protolex.(*protoLex).res = protoVAL.file + lex := protolex.(*protoLex) + protoVAL.file = ast.NewFileNode(lex.info, protoDollar[1].syn, protoDollar[2].fileDecls, lex.eof) + lex.res = protoVAL.file } case 4: protoDollar = protoS[protopt-0 : protopt+1] -//line proto.y:155 { + lex := protolex.(*protoLex) + protoVAL.file = ast.NewFileNode(lex.info, nil, nil, lex.eof) + lex.res = protoVAL.file } case 5: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:158 { if protoDollar[2].fileDecl != nil { protoVAL.fileDecls = append(protoDollar[1].fileDecls, protoDollar[2].fileDecl) @@ -1239,7 +1248,6 @@ protodefault: } case 6: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:165 { if protoDollar[1].fileDecl != nil { protoVAL.fileDecls = []ast.FileElement{protoDollar[1].fileDecl} @@ -1249,145 +1257,121 @@ protodefault: } case 7: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:173 { protoVAL.fileDecl = protoDollar[1].imprt } case 8: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:176 { protoVAL.fileDecl = protoDollar[1].pkg } case 9: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:179 { protoVAL.fileDecl = protoDollar[1].opt } case 10: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:182 { protoVAL.fileDecl = protoDollar[1].msg } case 11: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:185 { protoVAL.fileDecl = protoDollar[1].en } case 12: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:188 { protoVAL.fileDecl = protoDollar[1].extend } case 13: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:191 { protoVAL.fileDecl = protoDollar[1].svc } case 14: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:194 { protoVAL.fileDecl = ast.NewEmptyDeclNode(protoDollar[1].b) } case 15: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:197 { protoVAL.fileDecl = nil } case 16: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:200 { protoVAL.fileDecl = nil } case 17: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:204 { protoVAL.syn = ast.NewSyntaxNode(protoDollar[1].id.ToKeyword(), protoDollar[2].b, protoDollar[3].str.toStringValueNode(), protoDollar[4].b) } case 18: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:208 { protoVAL.imprt = ast.NewImportNode(protoDollar[1].id.ToKeyword(), nil, nil, protoDollar[2].str.toStringValueNode(), protoDollar[3].b) } case 19: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:211 { protoVAL.imprt = ast.NewImportNode(protoDollar[1].id.ToKeyword(), nil, protoDollar[2].id.ToKeyword(), protoDollar[3].str.toStringValueNode(), protoDollar[4].b) } case 20: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:214 { protoVAL.imprt = ast.NewImportNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), nil, protoDollar[3].str.toStringValueNode(), protoDollar[4].b) } case 21: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:218 { protoVAL.pkg = ast.NewPackageNode(protoDollar[1].id.ToKeyword(), protoDollar[2].cid.toIdentValueNode(nil), protoDollar[3].b) } case 22: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:222 { protoVAL.cid = &identList{protoDollar[1].id, nil, nil} } case 23: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:225 { protoVAL.cid = &identList{protoDollar[1].id, protoDollar[2].b, protoDollar[3].cid} } case 24: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:233 { protoVAL.cid = &identList{protoDollar[1].id, nil, nil} } case 25: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:236 { protoVAL.cid = &identList{protoDollar[1].id, protoDollar[2].b, protoDollar[3].cid} } case 26: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:240 { protoVAL.cid = &identList{protoDollar[1].id, nil, nil} } case 27: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:243 { protoVAL.cid = &identList{protoDollar[1].id, protoDollar[2].b, protoDollar[3].cid} } case 28: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:247 { protoVAL.cid = &identList{protoDollar[1].id, nil, nil} } case 29: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:250 { protoVAL.cid = &identList{protoDollar[1].id, protoDollar[2].b, protoDollar[3].cid} } case 30: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:254 { refs, dots := protoDollar[2].optNms.toNodes() optName := ast.NewOptionNameNode(refs, dots) @@ -1395,87 +1379,73 @@ protodefault: } case 31: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:260 { protoVAL.optNms = &fieldRefList{protoDollar[1].ref, nil, nil} } case 32: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:263 { protoVAL.optNms = &fieldRefList{protoDollar[1].ref, protoDollar[2].b, protoDollar[3].optNms} } case 33: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:267 { protoVAL.ref = ast.NewFieldReferenceNode(protoDollar[1].id) } case 34: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:270 { protoVAL.ref = ast.NewExtensionFieldReferenceNode(protoDollar[1].b, protoDollar[2].tid, protoDollar[3].b) } case 37: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:277 { protoVAL.v = protoDollar[1].str.toStringValueNode() } case 39: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:281 { protoVAL.v = protoDollar[1].id } case 40: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:285 { protoVAL.v = protoDollar[1].f } case 41: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:288 { protoVAL.v = ast.NewSignedFloatLiteralNode(protoDollar[1].b, protoDollar[2].f) } case 42: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:291 { protoVAL.v = ast.NewSignedFloatLiteralNode(protoDollar[1].b, protoDollar[2].f) } case 43: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:294 { f := ast.NewSpecialFloatLiteralNode(protoDollar[2].id.ToKeyword()) protoVAL.v = ast.NewSignedFloatLiteralNode(protoDollar[1].b, f) } case 44: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:298 { f := ast.NewSpecialFloatLiteralNode(protoDollar[2].id.ToKeyword()) protoVAL.v = ast.NewSignedFloatLiteralNode(protoDollar[1].b, f) } case 45: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:302 { protoVAL.v = protoDollar[1].i } case 46: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:305 { protoVAL.v = ast.NewPositiveUintLiteralNode(protoDollar[1].b, protoDollar[2].i) } case 47: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:308 { if protoDollar[2].i.Val > math.MaxInt64+1 { // can't represent as int so treat as float literal @@ -1486,26 +1456,27 @@ protodefault: } case 48: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:317 { protoVAL.str = &stringList{protoDollar[1].s, nil} } case 49: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:320 { protoVAL.str = &stringList{protoDollar[1].s, protoDollar[2].str} } case 50: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:324 { fields, delims := protoDollar[2].msgLit.toNodes() protoVAL.v = ast.NewMessageLiteralNode(protoDollar[1].b, fields, delims, protoDollar[3].b) } case 51: + protoDollar = protoS[protopt-3 : protopt+1] + { + protoVAL.v = nil + } + case 52: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:329 { if protoDollar[1].msgEntry != nil { protoVAL.msgLit = &messageFieldList{protoDollar[1].msgEntry, nil} @@ -1513,9 +1484,8 @@ protodefault: protoVAL.msgLit = nil } } - case 52: + case 53: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:336 { if protoDollar[1].msgEntry != nil { protoVAL.msgLit = &messageFieldList{protoDollar[1].msgEntry, protoDollar[2].msgLit} @@ -1523,15 +1493,13 @@ protodefault: protoVAL.msgLit = protoDollar[2].msgLit } } - case 53: + case 54: protoDollar = protoS[protopt-0 : protopt+1] -//line proto.y:343 { protoVAL.msgLit = nil } - case 54: + case 55: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:347 { if protoDollar[1].msgField != nil { protoVAL.msgEntry = &messageFieldEntry{protoDollar[1].msgField, nil} @@ -1539,9 +1507,8 @@ protodefault: protoVAL.msgEntry = nil } } - case 55: + case 56: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:354 { if protoDollar[1].msgField != nil { protoVAL.msgEntry = &messageFieldEntry{protoDollar[1].msgField, protoDollar[2].b} @@ -1549,9 +1516,8 @@ protodefault: protoVAL.msgEntry = nil } } - case 56: + case 57: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:361 { if protoDollar[1].msgField != nil { protoVAL.msgEntry = &messageFieldEntry{protoDollar[1].msgField, protoDollar[2].b} @@ -1559,27 +1525,23 @@ protodefault: protoVAL.msgEntry = nil } } - case 57: + case 58: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:368 { protoVAL.msgEntry = nil } - case 58: + case 59: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:371 { protoVAL.msgEntry = nil } - case 59: + case 60: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:374 { protoVAL.msgEntry = nil } - case 60: + case 61: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:378 { if protoDollar[1].ref != nil { protoVAL.msgField = ast.NewMessageFieldNode(protoDollar[1].ref, protoDollar[2].b, protoDollar[3].v) @@ -1587,9 +1549,8 @@ protodefault: protoVAL.msgField = nil } } - case 61: + case 62: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:385 { if protoDollar[1].ref != nil { val := ast.NewArrayLiteralNode(protoDollar[2].b, nil, nil, protoDollar[3].b) @@ -1598,9 +1559,8 @@ protodefault: protoVAL.msgField = nil } } - case 62: + case 63: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:393 { if protoDollar[1].ref != nil { val := ast.NewArrayLiteralNode(protoDollar[3].b, nil, nil, protoDollar[4].b) @@ -1609,9 +1569,8 @@ protodefault: protoVAL.msgField = nil } } - case 63: + case 64: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:401 { if protoDollar[1].ref != nil { vals, commas := protoDollar[3].sl.toNodes() @@ -1621,9 +1580,8 @@ protodefault: protoVAL.msgField = nil } } - case 64: + case 65: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:410 { if protoDollar[1].ref != nil { vals, commas := protoDollar[4].sl.toNodes() @@ -1633,348 +1591,312 @@ protodefault: protoVAL.msgField = nil } } - case 65: + case 66: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:419 { protoVAL.msgField = nil } - case 66: - protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:422 - { - if protoDollar[1].ref != nil { - protoVAL.msgField = ast.NewMessageFieldNode(protoDollar[1].ref, protoDollar[2].b, protoDollar[3].v) - } else { - protoVAL.msgField = nil - } - } case 67: - protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:429 + protoDollar = protoS[protopt-4 : protopt+1] { - if protoDollar[1].ref != nil { - protoVAL.msgField = ast.NewMessageFieldNode(protoDollar[1].ref, nil, protoDollar[2].v) - } else { - protoVAL.msgField = nil - } + protoVAL.msgField = nil } case 68: - protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:436 + protoDollar = protoS[protopt-3 : protopt+1] { - if protoDollar[1].ref != nil { - fields, delims := protoDollar[4].msgLit.toNodes() - msg := ast.NewMessageLiteralNode(protoDollar[3].b, fields, delims, protoDollar[5].b) - protoVAL.msgField = ast.NewMessageFieldNode(protoDollar[1].ref, protoDollar[2].b, msg) + if protoDollar[1].ref != nil && protoDollar[3].v != nil { + protoVAL.msgField = ast.NewMessageFieldNode(protoDollar[1].ref, protoDollar[2].b, protoDollar[3].v) } else { protoVAL.msgField = nil } } case 69: - protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:445 + protoDollar = protoS[protopt-2 : protopt+1] { - if protoDollar[1].ref != nil { - fields, delims := protoDollar[3].msgLit.toNodes() - msg := ast.NewMessageLiteralNode(protoDollar[2].b, fields, delims, protoDollar[4].b) - protoVAL.msgField = ast.NewMessageFieldNode(protoDollar[1].ref, nil, msg) + if protoDollar[1].ref != nil && protoDollar[2].v != nil { + protoVAL.msgField = ast.NewMessageFieldNode(protoDollar[1].ref, nil, protoDollar[2].v) } else { protoVAL.msgField = nil } } case 70: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:454 { protoVAL.msgField = nil } case 71: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:457 { protoVAL.msgField = nil } case 72: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:461 { protoVAL.ref = ast.NewFieldReferenceNode(protoDollar[1].id) } case 73: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:464 { protoVAL.ref = ast.NewExtensionFieldReferenceNode(protoDollar[1].b, protoDollar[2].cid.toIdentValueNode(nil), protoDollar[3].b) } case 74: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:467 { protoVAL.ref = ast.NewAnyTypeReferenceNode(protoDollar[1].b, protoDollar[2].cid.toIdentValueNode(nil), protoDollar[3].b, protoDollar[4].cid.toIdentValueNode(nil), protoDollar[5].b) } case 75: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:470 { protoVAL.ref = nil } case 76: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:474 { - protoVAL.sl = &valueList{protoDollar[1].v, nil, nil} + if protoDollar[1].v == nil { + protoVAL.sl = nil + } else { + protoVAL.sl = &valueList{protoDollar[1].v, nil, nil} + } } case 77: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:477 { - protoVAL.sl = &valueList{protoDollar[1].v, protoDollar[2].b, protoDollar[3].sl} + if protoDollar[1].v == nil { + protoVAL.sl = nil + } else { + protoVAL.sl = &valueList{protoDollar[1].v, protoDollar[2].b, protoDollar[3].sl} + } } case 78: + protoDollar = protoS[protopt-1 : protopt+1] + { + protoVAL.v = protoDollar[1].v + } + case 79: + protoDollar = protoS[protopt-3 : protopt+1] + { + fields, delims := protoDollar[2].msgLit.toNodes() + protoVAL.v = ast.NewMessageLiteralNode(protoDollar[1].b, fields, delims, protoDollar[3].b) + } + case 80: + protoDollar = protoS[protopt-3 : protopt+1] + { + protoVAL.v = nil + } + case 81: + protoDollar = protoS[protopt-1 : protopt+1] + { + protoVAL.sl = &valueList{protoDollar[1].v, nil, nil} + } + case 82: + protoDollar = protoS[protopt-3 : protopt+1] + { + protoVAL.sl = &valueList{protoDollar[1].v, protoDollar[2].b, protoDollar[3].sl} + } + case 83: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:480 { fields, delims := protoDollar[2].msgLit.toNodes() msg := ast.NewMessageLiteralNode(protoDollar[1].b, fields, delims, protoDollar[3].b) protoVAL.sl = &valueList{msg, nil, nil} } - case 79: + case 84: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:485 { fields, delims := protoDollar[2].msgLit.toNodes() msg := ast.NewMessageLiteralNode(protoDollar[1].b, fields, delims, protoDollar[3].b) protoVAL.sl = &valueList{msg, protoDollar[4].b, protoDollar[5].sl} } - case 80: + case 85: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:490 { protoVAL.sl = nil } - case 81: + case 86: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:493 { protoVAL.sl = protoDollar[5].sl } - case 82: + case 87: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:497 { protoVAL.tid = protoDollar[1].cid.toIdentValueNode(nil) } - case 83: + case 88: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:500 { protoVAL.tid = protoDollar[2].cid.toIdentValueNode(protoDollar[1].b) } - case 84: + case 89: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:504 { protoVAL.tid = protoDollar[1].cid.toIdentValueNode(nil) } - case 85: + case 90: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:507 { protoVAL.tid = protoDollar[2].cid.toIdentValueNode(protoDollar[1].b) } - case 86: + case 91: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:511 { protoVAL.tid = protoDollar[1].cid.toIdentValueNode(nil) } - case 87: + case 92: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:514 { protoVAL.tid = protoDollar[2].cid.toIdentValueNode(protoDollar[1].b) } - case 88: + case 93: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:518 { protoVAL.tid = protoDollar[1].cid.toIdentValueNode(nil) } - case 89: + case 94: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:521 { protoVAL.tid = protoDollar[2].cid.toIdentValueNode(protoDollar[1].b) } - case 90: + case 95: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:525 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b) } - case 91: + case 96: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:528 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b) } - case 92: + case 97: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:531 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b) } - case 93: + case 98: protoDollar = protoS[protopt-7 : protopt+1] -//line proto.y:534 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b) } - case 94: + case 99: protoDollar = protoS[protopt-7 : protopt+1] -//line proto.y:537 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b) } - case 95: + case 100: protoDollar = protoS[protopt-7 : protopt+1] -//line proto.y:540 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b) } - case 96: + case 101: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:543 { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, protoDollar[5].b) } - case 97: + case 102: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:546 { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, protoDollar[6].b) } - case 98: + case 103: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:550 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b) } - case 99: + case 104: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:553 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b) } - case 100: + case 105: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:556 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b) } - case 101: + case 106: protoDollar = protoS[protopt-7 : protopt+1] -//line proto.y:559 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b) } - case 102: + case 107: protoDollar = protoS[protopt-7 : protopt+1] -//line proto.y:562 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b) } - case 103: + case 108: protoDollar = protoS[protopt-7 : protopt+1] -//line proto.y:565 { protoVAL.fld = ast.NewFieldNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b) } - case 104: + case 109: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:568 { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, protoDollar[5].b) } - case 105: + case 110: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:571 { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, protoDollar[6].b) } - case 106: + case 111: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:575 { opts, commas := protoDollar[2].opts.toNodes() protoVAL.cmpctOpts = ast.NewCompactOptionsNode(protoDollar[1].b, opts, commas, protoDollar[3].b) } - case 107: + case 112: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:580 { protoVAL.opts = &compactOptionList{protoDollar[1].opt, nil, nil} } - case 108: + case 113: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:583 { protoVAL.opts = &compactOptionList{protoDollar[1].opt, protoDollar[2].b, protoDollar[3].opts} } - case 109: + case 114: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:587 { refs, dots := protoDollar[1].optNms.toNodes() optName := ast.NewOptionNameNode(refs, dots) protoVAL.opt = ast.NewCompactOptionNode(optName, protoDollar[2].b, protoDollar[3].v) } - case 110: + case 115: protoDollar = protoS[protopt-8 : protopt+1] -//line proto.y:593 { protoVAL.grp = ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b, protoDollar[7].msgDecls, protoDollar[8].b) } - case 111: + case 116: protoDollar = protoS[protopt-8 : protopt+1] -//line proto.y:596 { protoVAL.grp = ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b, protoDollar[7].msgDecls, protoDollar[8].b) } - case 112: + case 117: protoDollar = protoS[protopt-8 : protopt+1] -//line proto.y:599 { protoVAL.grp = ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, nil, protoDollar[6].b, protoDollar[7].msgDecls, protoDollar[8].b) } - case 113: + case 118: protoDollar = protoS[protopt-9 : protopt+1] -//line proto.y:602 { protoVAL.grp = ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b, protoDollar[8].msgDecls, protoDollar[9].b) } - case 114: + case 119: protoDollar = protoS[protopt-9 : protopt+1] -//line proto.y:605 { protoVAL.grp = ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b, protoDollar[8].msgDecls, protoDollar[9].b) } - case 115: + case 120: protoDollar = protoS[protopt-9 : protopt+1] -//line proto.y:608 { protoVAL.grp = ast.NewGroupNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id.ToKeyword(), protoDollar[3].id, protoDollar[4].b, protoDollar[5].i, protoDollar[6].cmpctOpts, protoDollar[7].b, protoDollar[8].msgDecls, protoDollar[9].b) } - case 116: + case 121: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:612 { protoVAL.oo = ast.NewOneOfNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].ooDecls, protoDollar[5].b) } - case 117: + case 122: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:616 { if protoDollar[2].ooDecl != nil { protoVAL.ooDecls = append(protoDollar[1].ooDecls, protoDollar[2].ooDecl) @@ -1982,9 +1904,8 @@ protodefault: protoVAL.ooDecls = protoDollar[1].ooDecls } } - case 118: + case 123: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:623 { if protoDollar[1].ooDecl != nil { protoVAL.ooDecls = []ast.OneOfElement{protoDollar[1].ooDecl} @@ -1992,218 +1913,178 @@ protodefault: protoVAL.ooDecls = nil } } - case 119: + case 124: protoDollar = protoS[protopt-0 : protopt+1] -//line proto.y:630 { protoVAL.ooDecls = nil } - case 120: + case 125: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:634 { protoVAL.ooDecl = protoDollar[1].opt } - case 121: + case 126: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:637 { protoVAL.ooDecl = protoDollar[1].fld } - case 122: + case 127: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:640 { protoVAL.ooDecl = protoDollar[1].grp } - case 123: - protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:643 - { - protoVAL.ooDecl = ast.NewEmptyDeclNode(protoDollar[1].b) - } - case 124: + case 128: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:646 { protoVAL.ooDecl = nil } - case 125: + case 129: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:649 { protoVAL.ooDecl = nil } - case 126: + case 130: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:653 { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, protoDollar[5].b) } - case 127: + case 131: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:656 { protoVAL.fld = ast.NewFieldNode(nil, protoDollar[1].tid, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, protoDollar[6].b) } - case 128: + case 132: protoDollar = protoS[protopt-7 : protopt+1] -//line proto.y:660 { protoVAL.grp = ast.NewGroupNode(nil, protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, protoDollar[5].b, protoDollar[6].msgDecls, protoDollar[7].b) } - case 129: + case 133: protoDollar = protoS[protopt-8 : protopt+1] -//line proto.y:663 { protoVAL.grp = ast.NewGroupNode(nil, protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, protoDollar[6].b, protoDollar[7].msgDecls, protoDollar[8].b) } - case 130: + case 134: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:667 { protoVAL.mapFld = ast.NewMapFieldNode(protoDollar[1].mapType, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, nil, protoDollar[5].b) } - case 131: + case 135: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:670 { protoVAL.mapFld = ast.NewMapFieldNode(protoDollar[1].mapType, protoDollar[2].id, protoDollar[3].b, protoDollar[4].i, protoDollar[5].cmpctOpts, protoDollar[6].b) } - case 132: + case 136: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:674 { protoVAL.mapType = ast.NewMapTypeNode(protoDollar[1].id.ToKeyword(), protoDollar[2].b, protoDollar[3].id, protoDollar[4].b, protoDollar[5].tid, protoDollar[6].b) } - case 145: + case 149: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:691 { ranges, commas := protoDollar[2].rngs.toNodes() protoVAL.ext = ast.NewExtensionRangeNode(protoDollar[1].id.ToKeyword(), ranges, commas, nil, protoDollar[3].b) } - case 146: + case 150: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:695 { ranges, commas := protoDollar[2].rngs.toNodes() protoVAL.ext = ast.NewExtensionRangeNode(protoDollar[1].id.ToKeyword(), ranges, commas, protoDollar[3].cmpctOpts, protoDollar[4].b) } - case 147: + case 151: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:700 { protoVAL.rngs = &rangeList{protoDollar[1].rng, nil, nil} } - case 148: + case 152: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:703 { protoVAL.rngs = &rangeList{protoDollar[1].rng, protoDollar[2].b, protoDollar[3].rngs} } - case 149: + case 153: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:707 { protoVAL.rng = ast.NewRangeNode(protoDollar[1].i, nil, nil, nil) } - case 150: + case 154: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:710 { protoVAL.rng = ast.NewRangeNode(protoDollar[1].i, protoDollar[2].id.ToKeyword(), protoDollar[3].i, nil) } - case 151: + case 155: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:713 { protoVAL.rng = ast.NewRangeNode(protoDollar[1].i, protoDollar[2].id.ToKeyword(), nil, protoDollar[3].id.ToKeyword()) } - case 152: + case 156: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:717 { protoVAL.rngs = &rangeList{protoDollar[1].rng, nil, nil} } - case 153: + case 157: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:720 { protoVAL.rngs = &rangeList{protoDollar[1].rng, protoDollar[2].b, protoDollar[3].rngs} } - case 154: + case 158: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:724 { protoVAL.rng = ast.NewRangeNode(protoDollar[1].il, nil, nil, nil) } - case 155: + case 159: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:727 { protoVAL.rng = ast.NewRangeNode(protoDollar[1].il, protoDollar[2].id.ToKeyword(), protoDollar[3].il, nil) } - case 156: + case 160: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:730 { protoVAL.rng = ast.NewRangeNode(protoDollar[1].il, protoDollar[2].id.ToKeyword(), nil, protoDollar[3].id.ToKeyword()) } - case 157: + case 161: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:734 { protoVAL.il = protoDollar[1].i } - case 158: + case 162: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:737 { protoVAL.il = ast.NewNegativeIntLiteralNode(protoDollar[1].b, protoDollar[2].i) } - case 159: + case 163: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:741 { ranges, commas := protoDollar[2].rngs.toNodes() protoVAL.resvd = ast.NewReservedRangesNode(protoDollar[1].id.ToKeyword(), ranges, commas, protoDollar[3].b) } - case 161: + case 165: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:747 { ranges, commas := protoDollar[2].rngs.toNodes() protoVAL.resvd = ast.NewReservedRangesNode(protoDollar[1].id.ToKeyword(), ranges, commas, protoDollar[3].b) } - case 163: + case 167: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:753 { names, commas := protoDollar[2].names.toNodes() protoVAL.resvd = ast.NewReservedNamesNode(protoDollar[1].id.ToKeyword(), names, commas, protoDollar[3].b) } - case 164: + case 168: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:758 { protoVAL.names = &nameList{protoDollar[1].str.toStringValueNode(), nil, nil} } - case 165: + case 169: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:761 { protoVAL.names = &nameList{protoDollar[1].str.toStringValueNode(), protoDollar[2].b, protoDollar[3].names} } - case 166: + case 170: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:765 { protoVAL.en = ast.NewEnumNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].enDecls, protoDollar[5].b) } - case 167: + case 171: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:769 { if protoDollar[2].enDecl != nil { protoVAL.enDecls = append(protoDollar[1].enDecls, protoDollar[2].enDecl) @@ -2211,9 +2092,8 @@ protodefault: protoVAL.enDecls = protoDollar[1].enDecls } } - case 168: + case 172: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:776 { if protoDollar[1].enDecl != nil { protoVAL.enDecls = []ast.EnumElement{protoDollar[1].enDecl} @@ -2221,69 +2101,58 @@ protodefault: protoVAL.enDecls = nil } } - case 169: + case 173: protoDollar = protoS[protopt-0 : protopt+1] -//line proto.y:783 { protoVAL.enDecls = nil } - case 170: + case 174: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:787 { protoVAL.enDecl = protoDollar[1].opt } - case 171: + case 175: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:790 { protoVAL.enDecl = protoDollar[1].env } - case 172: + case 176: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:793 { protoVAL.enDecl = protoDollar[1].resvd } - case 173: + case 177: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:796 { protoVAL.enDecl = ast.NewEmptyDeclNode(protoDollar[1].b) } - case 174: + case 178: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:799 { protoVAL.enDecl = nil } - case 175: + case 179: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:802 { protoVAL.enDecl = nil } - case 176: + case 180: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:806 { protoVAL.env = ast.NewEnumValueNode(protoDollar[1].id, protoDollar[2].b, protoDollar[3].il, nil, protoDollar[4].b) } - case 177: + case 181: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:809 { protoVAL.env = ast.NewEnumValueNode(protoDollar[1].id, protoDollar[2].b, protoDollar[3].il, protoDollar[4].cmpctOpts, protoDollar[5].b) } - case 178: + case 182: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:813 { protoVAL.msg = ast.NewMessageNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].msgDecls, protoDollar[5].b) } - case 179: + case 183: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:817 { if protoDollar[2].msgDecl != nil { protoVAL.msgDecls = append(protoDollar[1].msgDecls, protoDollar[2].msgDecl) @@ -2291,9 +2160,8 @@ protodefault: protoVAL.msgDecls = protoDollar[1].msgDecls } } - case 180: + case 184: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:824 { if protoDollar[1].msgDecl != nil { protoVAL.msgDecls = []ast.MessageElement{protoDollar[1].msgDecl} @@ -2301,99 +2169,83 @@ protodefault: protoVAL.msgDecls = nil } } - case 181: + case 185: protoDollar = protoS[protopt-0 : protopt+1] -//line proto.y:831 { protoVAL.msgDecls = nil } - case 182: + case 186: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:835 { protoVAL.msgDecl = protoDollar[1].fld } - case 183: + case 187: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:838 { protoVAL.msgDecl = protoDollar[1].en } - case 184: + case 188: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:841 { protoVAL.msgDecl = protoDollar[1].msg } - case 185: + case 189: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:844 { protoVAL.msgDecl = protoDollar[1].extend } - case 186: + case 190: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:847 { protoVAL.msgDecl = protoDollar[1].ext } - case 187: + case 191: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:850 { protoVAL.msgDecl = protoDollar[1].grp } - case 188: + case 192: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:853 { protoVAL.msgDecl = protoDollar[1].opt } - case 189: + case 193: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:856 { protoVAL.msgDecl = protoDollar[1].oo } - case 190: + case 194: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:859 { protoVAL.msgDecl = protoDollar[1].mapFld } - case 191: + case 195: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:862 { protoVAL.msgDecl = protoDollar[1].resvd } - case 192: + case 196: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:865 { protoVAL.msgDecl = ast.NewEmptyDeclNode(protoDollar[1].b) } - case 193: + case 197: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:868 { protoVAL.msgDecl = nil } - case 194: + case 198: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:871 { protoVAL.msgDecl = nil } - case 195: + case 199: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:875 { protoVAL.extend = ast.NewExtendNode(protoDollar[1].id.ToKeyword(), protoDollar[2].tid, protoDollar[3].b, protoDollar[4].extDecls, protoDollar[5].b) } - case 196: + case 200: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:879 { if protoDollar[2].extDecl != nil { protoVAL.extDecls = append(protoDollar[1].extDecls, protoDollar[2].extDecl) @@ -2401,9 +2253,8 @@ protodefault: protoVAL.extDecls = protoDollar[1].extDecls } } - case 197: + case 201: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:886 { if protoDollar[1].extDecl != nil { protoVAL.extDecls = []ast.ExtendElement{protoDollar[1].extDecl} @@ -2411,51 +2262,38 @@ protodefault: protoVAL.extDecls = nil } } - case 198: + case 202: protoDollar = protoS[protopt-0 : protopt+1] -//line proto.y:893 { protoVAL.extDecls = nil } - case 199: + case 203: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:897 { protoVAL.extDecl = protoDollar[1].fld } - case 200: + case 204: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:900 { protoVAL.extDecl = protoDollar[1].grp } - case 201: - protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:903 - { - protoVAL.extDecl = ast.NewEmptyDeclNode(protoDollar[1].b) - } - case 202: + case 205: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:906 { protoVAL.extDecl = nil } - case 203: + case 206: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:909 { protoVAL.extDecl = nil } - case 204: + case 207: protoDollar = protoS[protopt-5 : protopt+1] -//line proto.y:913 { protoVAL.svc = ast.NewServiceNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].b, protoDollar[4].svcDecls, protoDollar[5].b) } - case 205: + case 208: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:917 { if protoDollar[2].svcDecl != nil { protoVAL.svcDecls = append(protoDollar[1].svcDecls, protoDollar[2].svcDecl) @@ -2463,9 +2301,8 @@ protodefault: protoVAL.svcDecls = protoDollar[1].svcDecls } } - case 206: + case 209: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:924 { if protoDollar[1].svcDecl != nil { protoVAL.svcDecls = []ast.ServiceElement{protoDollar[1].svcDecl} @@ -2473,69 +2310,58 @@ protodefault: protoVAL.svcDecls = nil } } - case 207: + case 210: protoDollar = protoS[protopt-0 : protopt+1] -//line proto.y:931 { protoVAL.svcDecls = nil } - case 208: + case 211: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:938 { protoVAL.svcDecl = protoDollar[1].opt } - case 209: + case 212: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:941 { protoVAL.svcDecl = protoDollar[1].mtd } - case 210: + case 213: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:944 { protoVAL.svcDecl = ast.NewEmptyDeclNode(protoDollar[1].b) } - case 211: + case 214: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:947 { protoVAL.svcDecl = nil } - case 212: + case 215: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:950 { protoVAL.svcDecl = nil } - case 213: + case 216: protoDollar = protoS[protopt-6 : protopt+1] -//line proto.y:954 { protoVAL.mtd = ast.NewRPCNode(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].rpcType, protoDollar[4].id.ToKeyword(), protoDollar[5].rpcType, protoDollar[6].b) } - case 214: + case 217: protoDollar = protoS[protopt-8 : protopt+1] -//line proto.y:957 { protoVAL.mtd = ast.NewRPCNodeWithBody(protoDollar[1].id.ToKeyword(), protoDollar[2].id, protoDollar[3].rpcType, protoDollar[4].id.ToKeyword(), protoDollar[5].rpcType, protoDollar[6].b, protoDollar[7].rpcDecls, protoDollar[8].b) } - case 215: + case 218: protoDollar = protoS[protopt-4 : protopt+1] -//line proto.y:961 { protoVAL.rpcType = ast.NewRPCTypeNode(protoDollar[1].b, protoDollar[2].id.ToKeyword(), protoDollar[3].tid, protoDollar[4].b) } - case 216: + case 219: protoDollar = protoS[protopt-3 : protopt+1] -//line proto.y:964 { protoVAL.rpcType = ast.NewRPCTypeNode(protoDollar[1].b, nil, protoDollar[2].tid, protoDollar[3].b) } - case 217: + case 220: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:968 { if protoDollar[2].rpcDecl != nil { protoVAL.rpcDecls = append(protoDollar[1].rpcDecls, protoDollar[2].rpcDecl) @@ -2543,9 +2369,8 @@ protodefault: protoVAL.rpcDecls = protoDollar[1].rpcDecls } } - case 218: + case 221: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:975 { if protoDollar[1].rpcDecl != nil { protoVAL.rpcDecls = []ast.RPCElement{protoDollar[1].rpcDecl} @@ -2553,33 +2378,28 @@ protodefault: protoVAL.rpcDecls = nil } } - case 219: + case 222: protoDollar = protoS[protopt-0 : protopt+1] -//line proto.y:982 { protoVAL.rpcDecls = nil } - case 220: + case 223: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:986 { protoVAL.rpcDecl = protoDollar[1].opt } - case 221: + case 224: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:989 { protoVAL.rpcDecl = ast.NewEmptyDeclNode(protoDollar[1].b) } - case 222: + case 225: protoDollar = protoS[protopt-2 : protopt+1] -//line proto.y:992 { protoVAL.rpcDecl = nil } - case 223: + case 226: protoDollar = protoS[protopt-1 : protopt+1] -//line proto.y:995 { protoVAL.rpcDecl = nil } diff --git a/vendor/github.com/bufbuild/protocompile/parser/result.go b/vendor/github.com/bufbuild/protocompile/parser/result.go new file mode 100644 index 00000000000..f44a1599ace --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/parser/result.go @@ -0,0 +1,920 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import ( + "bytes" + "math" + "strings" + "unicode" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/reporter" +) + +type result struct { + file *ast.FileNode + proto *descriptorpb.FileDescriptorProto + + nodes map[proto.Message]ast.Node +} + +// ResultWithoutAST returns a parse result that has no AST. All methods for +// looking up AST nodes return a placeholder node that contains only the filename +// in position information. +func ResultWithoutAST(proto *descriptorpb.FileDescriptorProto) Result { + return &result{proto: proto} +} + +// ResultFromAST constructs a descriptor proto from the given AST. The returned +// result includes the descriptor proto and also contains an index that can be +// used to lookup AST node information for elements in the descriptor proto +// hierarchy. +// +// If validate is true, some basic validation is performed, to make sure the +// resulting descriptor proto is valid per protobuf rules and semantics. Only +// some language elements can be validated since some rules and semantics can +// only be checked after all symbols are all resolved, which happens in the +// linking step. +// +// The given handler is used to report any errors or warnings encountered. If any +// errors are reported, this function returns a non-nil error. +func ResultFromAST(file *ast.FileNode, validate bool, handler *reporter.Handler) (Result, error) { + filename := file.Name() + r := &result{file: file, nodes: map[proto.Message]ast.Node{}} + r.createFileDescriptor(filename, file, handler) + if validate { + validateBasic(r, handler) + } + return r, handler.Error() +} + +func (r *result) AST() *ast.FileNode { + return r.file +} + +func (r *result) FileDescriptorProto() *descriptorpb.FileDescriptorProto { + return r.proto +} + +func (r *result) createFileDescriptor(filename string, file *ast.FileNode, handler *reporter.Handler) { + fd := &descriptorpb.FileDescriptorProto{Name: proto.String(filename)} + r.proto = fd + + r.putFileNode(fd, file) + + isProto3 := false + if file.Syntax != nil { + if file.Syntax.Syntax.AsString() == "proto3" { + isProto3 = true + } else if file.Syntax.Syntax.AsString() != "proto2" { + nodeInfo := file.NodeInfo(file.Syntax.Syntax) + if handler.HandleErrorf(nodeInfo.Start(), `syntax value must be "proto2" or "proto3"`) != nil { + return + } + } + + // proto2 is the default, so no need to set unless proto3 + if isProto3 { + fd.Syntax = proto.String(file.Syntax.Syntax.AsString()) + } + } else { + nodeInfo := file.NodeInfo(file) + handler.HandleWarningWithPos(nodeInfo.Start(), ErrNoSyntax) + } + + for _, decl := range file.Decls { + if handler.ReporterError() != nil { + return + } + switch decl := decl.(type) { + case *ast.EnumNode: + fd.EnumType = append(fd.EnumType, r.asEnumDescriptor(decl, handler)) + case *ast.ExtendNode: + r.addExtensions(decl, &fd.Extension, &fd.MessageType, isProto3, handler, 0) + case *ast.ImportNode: + index := len(fd.Dependency) + fd.Dependency = append(fd.Dependency, decl.Name.AsString()) + if decl.Public != nil { + fd.PublicDependency = append(fd.PublicDependency, int32(index)) + } else if decl.Weak != nil { + fd.WeakDependency = append(fd.WeakDependency, int32(index)) + } + case *ast.MessageNode: + fd.MessageType = append(fd.MessageType, r.asMessageDescriptor(decl, isProto3, handler, 1)) + case *ast.OptionNode: + if fd.Options == nil { + fd.Options = &descriptorpb.FileOptions{} + } + fd.Options.UninterpretedOption = append(fd.Options.UninterpretedOption, r.asUninterpretedOption(decl)) + case *ast.ServiceNode: + fd.Service = append(fd.Service, r.asServiceDescriptor(decl)) + case *ast.PackageNode: + if fd.Package != nil { + nodeInfo := file.NodeInfo(decl) + if handler.HandleErrorf(nodeInfo.Start(), "files should have only one package declaration") != nil { + return + } + } + pkgName := string(decl.Name.AsIdentifier()) + if len(pkgName) >= 512 { + nodeInfo := file.NodeInfo(decl.Name) + if handler.HandleErrorf(nodeInfo.Start(), "package name (with whitespace removed) must be less than 512 characters long") != nil { + return + } + } + if strings.Count(pkgName, ".") > 100 { + nodeInfo := file.NodeInfo(decl.Name) + if handler.HandleErrorf(nodeInfo.Start(), "package name may not contain more than 100 periods") != nil { + return + } + } + fd.Package = proto.String(string(decl.Name.AsIdentifier())) + } + } +} + +func (r *result) asUninterpretedOptions(nodes []*ast.OptionNode) []*descriptorpb.UninterpretedOption { + if len(nodes) == 0 { + return nil + } + opts := make([]*descriptorpb.UninterpretedOption, len(nodes)) + for i, n := range nodes { + opts[i] = r.asUninterpretedOption(n) + } + return opts +} + +func (r *result) asUninterpretedOption(node *ast.OptionNode) *descriptorpb.UninterpretedOption { + opt := &descriptorpb.UninterpretedOption{Name: r.asUninterpretedOptionName(node.Name.Parts)} + r.putOptionNode(opt, node) + + switch val := node.Val.Value().(type) { + case bool: + if val { + opt.IdentifierValue = proto.String("true") + } else { + opt.IdentifierValue = proto.String("false") + } + case int64: + opt.NegativeIntValue = proto.Int64(val) + case uint64: + opt.PositiveIntValue = proto.Uint64(val) + case float64: + opt.DoubleValue = proto.Float64(val) + case string: + opt.StringValue = []byte(val) + case ast.Identifier: + opt.IdentifierValue = proto.String(string(val)) + default: + // the grammar does not allow arrays here, so the only possible case + // left should be []*ast.MessageFieldNode, which corresponds to an + // *ast.MessageLiteralNode + if n, ok := node.Val.(*ast.MessageLiteralNode); ok { + var buf bytes.Buffer + for i, el := range n.Elements { + flattenNode(r.file, el, &buf) + if len(n.Seps) > i && n.Seps[i] != nil { + buf.WriteRune(' ') + buf.WriteRune(n.Seps[i].Rune) + } + } + aggStr := buf.String() + opt.AggregateValue = proto.String(aggStr) + } + // TODO: else that reports an error or panics?? + } + return opt +} + +func flattenNode(f *ast.FileNode, n ast.Node, buf *bytes.Buffer) { + if cn, ok := n.(ast.CompositeNode); ok { + for _, ch := range cn.Children() { + flattenNode(f, ch, buf) + } + return + } + + if buf.Len() > 0 { + buf.WriteRune(' ') + } + buf.WriteString(f.NodeInfo(n).RawText()) +} + +func (r *result) asUninterpretedOptionName(parts []*ast.FieldReferenceNode) []*descriptorpb.UninterpretedOption_NamePart { + ret := make([]*descriptorpb.UninterpretedOption_NamePart, len(parts)) + for i, part := range parts { + np := &descriptorpb.UninterpretedOption_NamePart{ + NamePart: proto.String(string(part.Name.AsIdentifier())), + IsExtension: proto.Bool(part.IsExtension()), + } + r.putOptionNamePartNode(np, part) + ret[i] = np + } + return ret +} + +func (r *result) addExtensions(ext *ast.ExtendNode, flds *[]*descriptorpb.FieldDescriptorProto, msgs *[]*descriptorpb.DescriptorProto, isProto3 bool, handler *reporter.Handler, depth int) { + extendee := string(ext.Extendee.AsIdentifier()) + count := 0 + for _, decl := range ext.Decls { + switch decl := decl.(type) { + case *ast.FieldNode: + count++ + // use higher limit since we don't know yet whether extendee is messageset wire format + fd := r.asFieldDescriptor(decl, internal.MaxTag, isProto3, handler) + fd.Extendee = proto.String(extendee) + *flds = append(*flds, fd) + case *ast.GroupNode: + count++ + // ditto: use higher limit right now + fd, md := r.asGroupDescriptors(decl, isProto3, internal.MaxTag, handler, depth+1) + fd.Extendee = proto.String(extendee) + *flds = append(*flds, fd) + *msgs = append(*msgs, md) + } + } + if count == 0 { + nodeInfo := r.file.NodeInfo(ext) + _ = handler.HandleErrorf(nodeInfo.Start(), "extend sections must define at least one extension") + } +} + +func asLabel(lbl *ast.FieldLabel) *descriptorpb.FieldDescriptorProto_Label { + if !lbl.IsPresent() { + return nil + } + switch { + case lbl.Repeated: + return descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum() + case lbl.Required: + return descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum() + default: + return descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum() + } +} + +func (r *result) asFieldDescriptor(node *ast.FieldNode, maxTag int32, isProto3 bool, handler *reporter.Handler) *descriptorpb.FieldDescriptorProto { + tag := node.Tag.Val + if err := r.checkTag(node.Tag, tag, maxTag); err != nil { + _ = handler.HandleError(err) + } + fd := newFieldDescriptor(node.Name.Val, string(node.FldType.AsIdentifier()), int32(tag), asLabel(&node.Label)) + r.putFieldNode(fd, node) + if opts := node.Options.GetElements(); len(opts) > 0 { + fd.Options = &descriptorpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} + } + if isProto3 && fd.Label != nil && fd.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL { + fd.Proto3Optional = proto.Bool(true) + } + return fd +} + +var fieldTypes = map[string]descriptorpb.FieldDescriptorProto_Type{ + "double": descriptorpb.FieldDescriptorProto_TYPE_DOUBLE, + "float": descriptorpb.FieldDescriptorProto_TYPE_FLOAT, + "int32": descriptorpb.FieldDescriptorProto_TYPE_INT32, + "int64": descriptorpb.FieldDescriptorProto_TYPE_INT64, + "uint32": descriptorpb.FieldDescriptorProto_TYPE_UINT32, + "uint64": descriptorpb.FieldDescriptorProto_TYPE_UINT64, + "sint32": descriptorpb.FieldDescriptorProto_TYPE_SINT32, + "sint64": descriptorpb.FieldDescriptorProto_TYPE_SINT64, + "fixed32": descriptorpb.FieldDescriptorProto_TYPE_FIXED32, + "fixed64": descriptorpb.FieldDescriptorProto_TYPE_FIXED64, + "sfixed32": descriptorpb.FieldDescriptorProto_TYPE_SFIXED32, + "sfixed64": descriptorpb.FieldDescriptorProto_TYPE_SFIXED64, + "bool": descriptorpb.FieldDescriptorProto_TYPE_BOOL, + "string": descriptorpb.FieldDescriptorProto_TYPE_STRING, + "bytes": descriptorpb.FieldDescriptorProto_TYPE_BYTES, +} + +func newFieldDescriptor(name string, fieldType string, tag int32, lbl *descriptorpb.FieldDescriptorProto_Label) *descriptorpb.FieldDescriptorProto { + fd := &descriptorpb.FieldDescriptorProto{ + Name: proto.String(name), + JsonName: proto.String(internal.JSONName(name)), + Number: proto.Int32(tag), + Label: lbl, + } + t, ok := fieldTypes[fieldType] + if ok { + fd.Type = t.Enum() + } else { + // NB: we don't have enough info to determine whether this is an enum + // or a message type, so we'll leave Type nil and set it later + // (during linking) + fd.TypeName = proto.String(fieldType) + } + return fd +} + +func (r *result) asGroupDescriptors(group *ast.GroupNode, isProto3 bool, maxTag int32, handler *reporter.Handler, depth int) (*descriptorpb.FieldDescriptorProto, *descriptorpb.DescriptorProto) { + tag := group.Tag.Val + if err := r.checkTag(group.Tag, tag, maxTag); err != nil { + _ = handler.HandleError(err) + } + if !unicode.IsUpper(rune(group.Name.Val[0])) { + nameNodeInfo := r.file.NodeInfo(group.Name) + _ = handler.HandleErrorf(nameNodeInfo.Start(), "group %s should have a name that starts with a capital letter", group.Name.Val) + } + fieldName := strings.ToLower(group.Name.Val) + fd := &descriptorpb.FieldDescriptorProto{ + Name: proto.String(fieldName), + JsonName: proto.String(internal.JSONName(fieldName)), + Number: proto.Int32(int32(tag)), + Label: asLabel(&group.Label), + Type: descriptorpb.FieldDescriptorProto_TYPE_GROUP.Enum(), + TypeName: proto.String(group.Name.Val), + } + r.putFieldNode(fd, group) + if opts := group.Options.GetElements(); len(opts) > 0 { + fd.Options = &descriptorpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} + } + md := &descriptorpb.DescriptorProto{Name: proto.String(group.Name.Val)} + r.putMessageNode(md, group) + // don't bother processing body if we've exceeded depth + if r.checkDepth(depth, group, handler) { + r.addMessageBody(md, &group.MessageBody, isProto3, handler, depth) + } + return fd, md +} + +func (r *result) asMapDescriptors(mapField *ast.MapFieldNode, isProto3 bool, maxTag int32, handler *reporter.Handler, depth int) (*descriptorpb.FieldDescriptorProto, *descriptorpb.DescriptorProto) { + tag := mapField.Tag.Val + if err := r.checkTag(mapField.Tag, tag, maxTag); err != nil { + _ = handler.HandleError(err) + } + r.checkDepth(depth, mapField, handler) + var lbl *descriptorpb.FieldDescriptorProto_Label + if !isProto3 { + lbl = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum() + } + keyFd := newFieldDescriptor("key", mapField.MapType.KeyType.Val, 1, lbl) + r.putFieldNode(keyFd, mapField.KeyField()) + valFd := newFieldDescriptor("value", string(mapField.MapType.ValueType.AsIdentifier()), 2, lbl) + r.putFieldNode(valFd, mapField.ValueField()) + entryName := internal.InitCap(internal.JSONName(mapField.Name.Val)) + "Entry" + fd := newFieldDescriptor(mapField.Name.Val, entryName, int32(tag), descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum()) + if opts := mapField.Options.GetElements(); len(opts) > 0 { + fd.Options = &descriptorpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} + } + r.putFieldNode(fd, mapField) + md := &descriptorpb.DescriptorProto{ + Name: proto.String(entryName), + Options: &descriptorpb.MessageOptions{MapEntry: proto.Bool(true)}, + Field: []*descriptorpb.FieldDescriptorProto{keyFd, valFd}, + } + r.putMessageNode(md, mapField) + return fd, md +} + +func (r *result) asExtensionRanges(node *ast.ExtensionRangeNode, maxTag int32, handler *reporter.Handler) []*descriptorpb.DescriptorProto_ExtensionRange { + opts := r.asUninterpretedOptions(node.Options.GetElements()) + ers := make([]*descriptorpb.DescriptorProto_ExtensionRange, len(node.Ranges)) + for i, rng := range node.Ranges { + start, end := r.getRangeBounds(rng, 1, maxTag, handler) + er := &descriptorpb.DescriptorProto_ExtensionRange{ + Start: proto.Int32(start), + End: proto.Int32(end + 1), + } + if len(opts) > 0 { + er.Options = &descriptorpb.ExtensionRangeOptions{UninterpretedOption: opts} + } + r.putExtensionRangeNode(er, rng) + ers[i] = er + } + return ers +} + +func (r *result) asEnumValue(ev *ast.EnumValueNode, handler *reporter.Handler) *descriptorpb.EnumValueDescriptorProto { + num, ok := ast.AsInt32(ev.Number, math.MinInt32, math.MaxInt32) + if !ok { + numberNodeInfo := r.file.NodeInfo(ev.Number) + _ = handler.HandleErrorf(numberNodeInfo.Start(), "value %d is out of range: should be between %d and %d", ev.Number.Value(), math.MinInt32, math.MaxInt32) + } + evd := &descriptorpb.EnumValueDescriptorProto{Name: proto.String(ev.Name.Val), Number: proto.Int32(num)} + r.putEnumValueNode(evd, ev) + if opts := ev.Options.GetElements(); len(opts) > 0 { + evd.Options = &descriptorpb.EnumValueOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} + } + return evd +} + +func (r *result) asMethodDescriptor(node *ast.RPCNode) *descriptorpb.MethodDescriptorProto { + md := &descriptorpb.MethodDescriptorProto{ + Name: proto.String(node.Name.Val), + InputType: proto.String(string(node.Input.MessageType.AsIdentifier())), + OutputType: proto.String(string(node.Output.MessageType.AsIdentifier())), + } + r.putMethodNode(md, node) + if node.Input.Stream != nil { + md.ClientStreaming = proto.Bool(true) + } + if node.Output.Stream != nil { + md.ServerStreaming = proto.Bool(true) + } + // protoc always adds a MethodOptions if there are brackets + // We do the same to match protoc as closely as possible + // https://github.com/protocolbuffers/protobuf/blob/0c3f43a6190b77f1f68b7425d1b7e1a8257a8d0c/src/google/protobuf/compiler/parser.cc#L2152 + if node.OpenBrace != nil { + md.Options = &descriptorpb.MethodOptions{} + for _, decl := range node.Decls { + if option, ok := decl.(*ast.OptionNode); ok { + md.Options.UninterpretedOption = append(md.Options.UninterpretedOption, r.asUninterpretedOption(option)) + } + } + } + return md +} + +func (r *result) asEnumDescriptor(en *ast.EnumNode, handler *reporter.Handler) *descriptorpb.EnumDescriptorProto { + ed := &descriptorpb.EnumDescriptorProto{Name: proto.String(en.Name.Val)} + r.putEnumNode(ed, en) + for _, decl := range en.Decls { + switch decl := decl.(type) { + case *ast.OptionNode: + if ed.Options == nil { + ed.Options = &descriptorpb.EnumOptions{} + } + ed.Options.UninterpretedOption = append(ed.Options.UninterpretedOption, r.asUninterpretedOption(decl)) + case *ast.EnumValueNode: + ed.Value = append(ed.Value, r.asEnumValue(decl, handler)) + case *ast.ReservedNode: + for _, n := range decl.Names { + ed.ReservedName = append(ed.ReservedName, n.AsString()) + } + for _, rng := range decl.Ranges { + ed.ReservedRange = append(ed.ReservedRange, r.asEnumReservedRange(rng, handler)) + } + } + } + return ed +} + +func (r *result) asEnumReservedRange(rng *ast.RangeNode, handler *reporter.Handler) *descriptorpb.EnumDescriptorProto_EnumReservedRange { + start, end := r.getRangeBounds(rng, math.MinInt32, math.MaxInt32, handler) + rr := &descriptorpb.EnumDescriptorProto_EnumReservedRange{ + Start: proto.Int32(start), + End: proto.Int32(end), + } + r.putEnumReservedRangeNode(rr, rng) + return rr +} + +func (r *result) asMessageDescriptor(node *ast.MessageNode, isProto3 bool, handler *reporter.Handler, depth int) *descriptorpb.DescriptorProto { + msgd := &descriptorpb.DescriptorProto{Name: proto.String(node.Name.Val)} + r.putMessageNode(msgd, node) + // don't bother processing body if we've exceeded depth + if r.checkDepth(depth, node, handler) { + r.addMessageBody(msgd, &node.MessageBody, isProto3, handler, depth) + } + return msgd +} + +func (r *result) checkDepth(depth int, node ast.MessageDeclNode, handler *reporter.Handler) bool { + if depth < 32 { + return true + } + n := ast.Node(node) + if grp, ok := n.(*ast.GroupNode); ok { + // pinpoint the group keyword if the source is a group + n = grp.Keyword + } + _ = handler.HandleErrorf(r.file.NodeInfo(n).Start(), "message nesting depth must be less than 32") + return false +} + +func (r *result) addMessageBody(msgd *descriptorpb.DescriptorProto, body *ast.MessageBody, isProto3 bool, handler *reporter.Handler, depth int) { + // first process any options + for _, decl := range body.Decls { + if opt, ok := decl.(*ast.OptionNode); ok { + if msgd.Options == nil { + msgd.Options = &descriptorpb.MessageOptions{} + } + msgd.Options.UninterpretedOption = append(msgd.Options.UninterpretedOption, r.asUninterpretedOption(opt)) + } + } + + // now that we have options, we can see if this uses messageset wire format, which + // impacts how we validate tag numbers in any fields in the message + maxTag := int32(internal.MaxNormalTag) + messageSetOpt, err := r.isMessageSetWireFormat("message "+msgd.GetName(), msgd, handler) + if err != nil { + return + } else if messageSetOpt != nil { + if isProto3 { + node := r.OptionNode(messageSetOpt) + nodeInfo := r.file.NodeInfo(node) + _ = handler.HandleErrorf(nodeInfo.Start(), "messages with message-set wire format are not allowed with proto3 syntax") + } + maxTag = internal.MaxTag // higher limit for messageset wire format + } + + rsvdNames := map[string]int{} + + // now we can process the rest + for _, decl := range body.Decls { + switch decl := decl.(type) { + case *ast.EnumNode: + msgd.EnumType = append(msgd.EnumType, r.asEnumDescriptor(decl, handler)) + case *ast.ExtendNode: + r.addExtensions(decl, &msgd.Extension, &msgd.NestedType, isProto3, handler, depth) + case *ast.ExtensionRangeNode: + msgd.ExtensionRange = append(msgd.ExtensionRange, r.asExtensionRanges(decl, maxTag, handler)...) + case *ast.FieldNode: + fd := r.asFieldDescriptor(decl, maxTag, isProto3, handler) + msgd.Field = append(msgd.Field, fd) + case *ast.MapFieldNode: + fd, md := r.asMapDescriptors(decl, isProto3, maxTag, handler, depth+1) + msgd.Field = append(msgd.Field, fd) + msgd.NestedType = append(msgd.NestedType, md) + case *ast.GroupNode: + fd, md := r.asGroupDescriptors(decl, isProto3, maxTag, handler, depth+1) + msgd.Field = append(msgd.Field, fd) + msgd.NestedType = append(msgd.NestedType, md) + case *ast.OneOfNode: + oodIndex := len(msgd.OneofDecl) + ood := &descriptorpb.OneofDescriptorProto{Name: proto.String(decl.Name.Val)} + r.putOneOfNode(ood, decl) + msgd.OneofDecl = append(msgd.OneofDecl, ood) + ooFields := 0 + for _, oodecl := range decl.Decls { + switch oodecl := oodecl.(type) { + case *ast.OptionNode: + if ood.Options == nil { + ood.Options = &descriptorpb.OneofOptions{} + } + ood.Options.UninterpretedOption = append(ood.Options.UninterpretedOption, r.asUninterpretedOption(oodecl)) + case *ast.FieldNode: + fd := r.asFieldDescriptor(oodecl, maxTag, isProto3, handler) + fd.OneofIndex = proto.Int32(int32(oodIndex)) + msgd.Field = append(msgd.Field, fd) + ooFields++ + case *ast.GroupNode: + fd, md := r.asGroupDescriptors(oodecl, isProto3, maxTag, handler, depth+1) + fd.OneofIndex = proto.Int32(int32(oodIndex)) + msgd.Field = append(msgd.Field, fd) + msgd.NestedType = append(msgd.NestedType, md) + ooFields++ + } + } + if ooFields == 0 { + declNodeInfo := r.file.NodeInfo(decl) + _ = handler.HandleErrorf(declNodeInfo.Start(), "oneof must contain at least one field") + } + case *ast.MessageNode: + msgd.NestedType = append(msgd.NestedType, r.asMessageDescriptor(decl, isProto3, handler, depth+1)) + case *ast.ReservedNode: + for _, n := range decl.Names { + count := rsvdNames[n.AsString()] + if count == 1 { // already seen + nameNodeInfo := r.file.NodeInfo(n) + _ = handler.HandleErrorf(nameNodeInfo.Start(), "name %q is reserved multiple times", n.AsString()) + } + rsvdNames[n.AsString()] = count + 1 + msgd.ReservedName = append(msgd.ReservedName, n.AsString()) + } + for _, rng := range decl.Ranges { + msgd.ReservedRange = append(msgd.ReservedRange, r.asMessageReservedRange(rng, maxTag, handler)) + } + } + } + + if messageSetOpt != nil { + if len(msgd.Field) > 0 { + node := r.FieldNode(msgd.Field[0]) + nodeInfo := r.file.NodeInfo(node) + _ = handler.HandleErrorf(nodeInfo.Start(), "messages with message-set wire format cannot contain non-extension fields") + } + if len(msgd.ExtensionRange) == 0 { + node := r.OptionNode(messageSetOpt) + nodeInfo := r.file.NodeInfo(node) + _ = handler.HandleErrorf(nodeInfo.Start(), "messages with message-set wire format must contain at least one extension range") + } + } + + // process any proto3_optional fields + if isProto3 { + r.processProto3OptionalFields(msgd) + } +} + +func (r *result) isMessageSetWireFormat(scope string, md *descriptorpb.DescriptorProto, handler *reporter.Handler) (*descriptorpb.UninterpretedOption, error) { + uo := md.GetOptions().GetUninterpretedOption() + index, err := internal.FindOption(r, handler, scope, uo, "message_set_wire_format") + if err != nil { + return nil, err + } + if index == -1 { + // no such option + return nil, nil + } + + opt := uo[index] + + switch opt.GetIdentifierValue() { + case "true": + return opt, nil + case "false": + return nil, nil + default: + optNode := r.OptionNode(opt) + optNodeInfo := r.file.NodeInfo(optNode.GetValue()) + return nil, handler.HandleErrorf(optNodeInfo.Start(), "%s: expecting bool value for message_set_wire_format option", scope) + } +} + +func (r *result) asMessageReservedRange(rng *ast.RangeNode, maxTag int32, handler *reporter.Handler) *descriptorpb.DescriptorProto_ReservedRange { + start, end := r.getRangeBounds(rng, 1, maxTag, handler) + rr := &descriptorpb.DescriptorProto_ReservedRange{ + Start: proto.Int32(start), + End: proto.Int32(end + 1), + } + r.putMessageReservedRangeNode(rr, rng) + return rr +} + +func (r *result) getRangeBounds(rng *ast.RangeNode, minVal, maxVal int32, handler *reporter.Handler) (int32, int32) { + checkOrder := true + start, ok := rng.StartValueAsInt32(minVal, maxVal) + if !ok { + checkOrder = false + startValNodeInfo := r.file.NodeInfo(rng.StartVal) + _ = handler.HandleErrorf(startValNodeInfo.Start(), "range start %d is out of range: should be between %d and %d", rng.StartValue(), minVal, maxVal) + } + + end, ok := rng.EndValueAsInt32(minVal, maxVal) + if !ok { + checkOrder = false + if rng.EndVal != nil { + endValNodeInfo := r.file.NodeInfo(rng.EndVal) + _ = handler.HandleErrorf(endValNodeInfo.Start(), "range end %d is out of range: should be between %d and %d", rng.EndValue(), minVal, maxVal) + } + } + + if checkOrder && start > end { + rangeStartNodeInfo := r.file.NodeInfo(rng.RangeStart()) + _ = handler.HandleErrorf(rangeStartNodeInfo.Start(), "range, %d to %d, is invalid: start must be <= end", start, end) + } + + return start, end +} + +func (r *result) asServiceDescriptor(svc *ast.ServiceNode) *descriptorpb.ServiceDescriptorProto { + sd := &descriptorpb.ServiceDescriptorProto{Name: proto.String(svc.Name.Val)} + r.putServiceNode(sd, svc) + for _, decl := range svc.Decls { + switch decl := decl.(type) { + case *ast.OptionNode: + if sd.Options == nil { + sd.Options = &descriptorpb.ServiceOptions{} + } + sd.Options.UninterpretedOption = append(sd.Options.UninterpretedOption, r.asUninterpretedOption(decl)) + case *ast.RPCNode: + sd.Method = append(sd.Method, r.asMethodDescriptor(decl)) + } + } + return sd +} + +func (r *result) checkTag(n ast.Node, v uint64, maxTag int32) error { + switch { + case v < 1: + return reporter.Errorf(r.file.NodeInfo(n).Start(), "tag number %d must be greater than zero", v) + case v > uint64(maxTag): + return reporter.Errorf(r.file.NodeInfo(n).Start(), "tag number %d is higher than max allowed tag number (%d)", v, maxTag) + case v >= internal.SpecialReservedStart && v <= internal.SpecialReservedEnd: + return reporter.Errorf(r.file.NodeInfo(n).Start(), "tag number %d is in disallowed reserved range %d-%d", v, internal.SpecialReservedStart, internal.SpecialReservedEnd) + default: + return nil + } +} + +// processProto3OptionalFields adds synthetic oneofs to the given message descriptor +// for each proto3 optional field. It also updates the fields to have the correct +// oneof index reference. +func (r *result) processProto3OptionalFields(msgd *descriptorpb.DescriptorProto) { + // add synthetic oneofs to the given message descriptor for each proto3 + // optional field, and update each field to have correct oneof index + var allNames map[string]struct{} + for _, fd := range msgd.Field { + if fd.GetProto3Optional() { + // lazy init the set of all names + if allNames == nil { + allNames = map[string]struct{}{} + for _, fd := range msgd.Field { + allNames[fd.GetName()] = struct{}{} + } + for _, od := range msgd.OneofDecl { + allNames[od.GetName()] = struct{}{} + } + // NB: protoc only considers names of other fields and oneofs + // when computing the synthetic oneof name. But that feels like + // a bug, since it means it could generate a name that conflicts + // with some other symbol defined in the message. If it's decided + // that's NOT a bug and is desirable, then we should remove the + // following four loops to mimic protoc's behavior. + for _, fd := range msgd.Extension { + allNames[fd.GetName()] = struct{}{} + } + for _, ed := range msgd.EnumType { + allNames[ed.GetName()] = struct{}{} + for _, evd := range ed.Value { + allNames[evd.GetName()] = struct{}{} + } + } + for _, fd := range msgd.NestedType { + allNames[fd.GetName()] = struct{}{} + } + } + + // Compute a name for the synthetic oneof. This uses the same + // algorithm as used in protoc: + // https://github.com/protocolbuffers/protobuf/blob/74ad62759e0a9b5a21094f3fb9bb4ebfaa0d1ab8/src/google/protobuf/compiler/parser.cc#L785-L803 + ooName := fd.GetName() + if !strings.HasPrefix(ooName, "_") { + ooName = "_" + ooName + } + for { + _, ok := allNames[ooName] + if !ok { + // found a unique name + allNames[ooName] = struct{}{} + break + } + ooName = "X" + ooName + } + + fd.OneofIndex = proto.Int32(int32(len(msgd.OneofDecl))) + ood := &descriptorpb.OneofDescriptorProto{Name: proto.String(ooName)} + msgd.OneofDecl = append(msgd.OneofDecl, ood) + ooident := r.FieldNode(fd).(*ast.FieldNode) //nolint:errcheck + r.putOneOfNode(ood, ast.NewSyntheticOneOf(ooident)) + } + } +} + +func (r *result) Node(m proto.Message) ast.Node { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[m] +} + +func (r *result) FileNode() ast.FileDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[r.proto].(ast.FileDeclNode) +} + +func (r *result) OptionNode(o *descriptorpb.UninterpretedOption) ast.OptionDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[o].(ast.OptionDeclNode) +} + +func (r *result) OptionNamePartNode(o *descriptorpb.UninterpretedOption_NamePart) ast.Node { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[o] +} + +func (r *result) MessageNode(m *descriptorpb.DescriptorProto) ast.MessageDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[m].(ast.MessageDeclNode) +} + +func (r *result) FieldNode(f *descriptorpb.FieldDescriptorProto) ast.FieldDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[f].(ast.FieldDeclNode) +} + +func (r *result) OneOfNode(o *descriptorpb.OneofDescriptorProto) ast.Node { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[o] +} + +func (r *result) ExtensionRangeNode(e *descriptorpb.DescriptorProto_ExtensionRange) ast.RangeDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[e].(ast.RangeDeclNode) +} + +func (r *result) MessageReservedRangeNode(rr *descriptorpb.DescriptorProto_ReservedRange) ast.RangeDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[rr].(ast.RangeDeclNode) +} + +func (r *result) EnumNode(e *descriptorpb.EnumDescriptorProto) ast.Node { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[e] +} + +func (r *result) EnumValueNode(e *descriptorpb.EnumValueDescriptorProto) ast.EnumValueDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[e].(ast.EnumValueDeclNode) +} + +func (r *result) EnumReservedRangeNode(rr *descriptorpb.EnumDescriptorProto_EnumReservedRange) ast.RangeDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[rr].(ast.RangeDeclNode) +} + +func (r *result) ServiceNode(s *descriptorpb.ServiceDescriptorProto) ast.Node { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[s] +} + +func (r *result) MethodNode(m *descriptorpb.MethodDescriptorProto) ast.RPCDeclNode { + if r.nodes == nil { + return ast.NewNoSourceNode(r.proto.GetName()) + } + return r.nodes[m].(ast.RPCDeclNode) +} + +func (r *result) putFileNode(f *descriptorpb.FileDescriptorProto, n *ast.FileNode) { + r.nodes[f] = n +} + +func (r *result) putOptionNode(o *descriptorpb.UninterpretedOption, n *ast.OptionNode) { + r.nodes[o] = n +} + +func (r *result) putOptionNamePartNode(o *descriptorpb.UninterpretedOption_NamePart, n *ast.FieldReferenceNode) { + r.nodes[o] = n +} + +func (r *result) putMessageNode(m *descriptorpb.DescriptorProto, n ast.MessageDeclNode) { + r.nodes[m] = n +} + +func (r *result) putFieldNode(f *descriptorpb.FieldDescriptorProto, n ast.FieldDeclNode) { + r.nodes[f] = n +} + +func (r *result) putOneOfNode(o *descriptorpb.OneofDescriptorProto, n ast.OneOfDeclNode) { + r.nodes[o] = n +} + +func (r *result) putExtensionRangeNode(e *descriptorpb.DescriptorProto_ExtensionRange, n *ast.RangeNode) { + r.nodes[e] = n +} + +func (r *result) putMessageReservedRangeNode(rr *descriptorpb.DescriptorProto_ReservedRange, n *ast.RangeNode) { + r.nodes[rr] = n +} + +func (r *result) putEnumNode(e *descriptorpb.EnumDescriptorProto, n *ast.EnumNode) { + r.nodes[e] = n +} + +func (r *result) putEnumValueNode(e *descriptorpb.EnumValueDescriptorProto, n *ast.EnumValueNode) { + r.nodes[e] = n +} + +func (r *result) putEnumReservedRangeNode(rr *descriptorpb.EnumDescriptorProto_EnumReservedRange, n *ast.RangeNode) { + r.nodes[rr] = n +} + +func (r *result) putServiceNode(s *descriptorpb.ServiceDescriptorProto, n *ast.ServiceNode) { + r.nodes[s] = n +} + +func (r *result) putMethodNode(m *descriptorpb.MethodDescriptorProto, n *ast.RPCNode) { + r.nodes[m] = n +} diff --git a/vendor/github.com/bufbuild/protocompile/parser/validate.go b/vendor/github.com/bufbuild/protocompile/parser/validate.go new file mode 100644 index 00000000000..f2f6c4fcd7a --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/parser/validate.go @@ -0,0 +1,477 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import ( + "fmt" + "sort" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/reporter" + "github.com/bufbuild/protocompile/walk" +) + +func validateBasic(res *result, handler *reporter.Handler) { + fd := res.proto + isProto3 := fd.GetSyntax() == "proto3" + + if err := validateImports(res, handler); err != nil { + return + } + + _ = walk.DescriptorProtos(fd, + func(name protoreflect.FullName, d proto.Message) error { + switch d := d.(type) { + case *descriptorpb.DescriptorProto: + if err := validateMessage(res, isProto3, name, d, handler); err != nil { + // exit func is not called when enter returns error + return err + } + case *descriptorpb.EnumDescriptorProto: + if err := validateEnum(res, isProto3, name, d, handler); err != nil { + return err + } + case *descriptorpb.FieldDescriptorProto: + if err := validateField(res, isProto3, name, d, handler); err != nil { + return err + } + } + return nil + }) +} + +func validateImports(res *result, handler *reporter.Handler) error { + fileNode := res.file + if fileNode == nil { + return nil + } + imports := make(map[string]ast.SourcePos) + for _, decl := range fileNode.Decls { + imp, ok := decl.(*ast.ImportNode) + if !ok { + continue + } + startPos := fileNode.NodeInfo(decl).Start() + name := imp.Name.AsString() + if prev, ok := imports[name]; ok { + return handler.HandleErrorf(startPos, "%q was already imported at %v", name, prev) + } + imports[name] = startPos + } + return nil +} + +func validateMessage(res *result, isProto3 bool, name protoreflect.FullName, md *descriptorpb.DescriptorProto, handler *reporter.Handler) error { + scope := fmt.Sprintf("message %s", name) + + if isProto3 && len(md.ExtensionRange) > 0 { + n := res.ExtensionRangeNode(md.ExtensionRange[0]) + nInfo := res.file.NodeInfo(n) + if err := handler.HandleErrorf(nInfo.Start(), "%s: extension ranges are not allowed in proto3", scope); err != nil { + return err + } + } + + if index, err := internal.FindOption(res, handler, scope, md.Options.GetUninterpretedOption(), "map_entry"); err != nil { + return err + } else if index >= 0 { + opt := md.Options.UninterpretedOption[index] + optn := res.OptionNode(opt) + md.Options.UninterpretedOption = internal.RemoveOption(md.Options.UninterpretedOption, index) + valid := false + if opt.IdentifierValue != nil { + if opt.GetIdentifierValue() == "true" { + valid = true + optionNodeInfo := res.file.NodeInfo(optn.GetValue()) + if err := handler.HandleErrorf(optionNodeInfo.Start(), "%s: map_entry option should not be set explicitly; use map type instead", scope); err != nil { + return err + } + } else if opt.GetIdentifierValue() == "false" { + valid = true + md.Options.MapEntry = proto.Bool(false) + } + } + if !valid { + optionNodeInfo := res.file.NodeInfo(optn.GetValue()) + if err := handler.HandleErrorf(optionNodeInfo.Start(), "%s: expecting bool value for map_entry option", scope); err != nil { + return err + } + } + } + + // reserved ranges should not overlap + rsvd := make(tagRanges, len(md.ReservedRange)) + for i, r := range md.ReservedRange { + n := res.MessageReservedRangeNode(r) + rsvd[i] = tagRange{start: r.GetStart(), end: r.GetEnd(), node: n} + } + sort.Sort(rsvd) + for i := 1; i < len(rsvd); i++ { + if rsvd[i].start < rsvd[i-1].end { + rangeNodeInfo := res.file.NodeInfo(rsvd[i].node) + if err := handler.HandleErrorf(rangeNodeInfo.Start(), "%s: reserved ranges overlap: %d to %d and %d to %d", scope, rsvd[i-1].start, rsvd[i-1].end-1, rsvd[i].start, rsvd[i].end-1); err != nil { + return err + } + } + } + + // extensions ranges should not overlap + exts := make(tagRanges, len(md.ExtensionRange)) + for i, r := range md.ExtensionRange { + n := res.ExtensionRangeNode(r) + exts[i] = tagRange{start: r.GetStart(), end: r.GetEnd(), node: n} + } + sort.Sort(exts) + for i := 1; i < len(exts); i++ { + if exts[i].start < exts[i-1].end { + rangeNodeInfo := res.file.NodeInfo(exts[i].node) + if err := handler.HandleErrorf(rangeNodeInfo.Start(), "%s: extension ranges overlap: %d to %d and %d to %d", scope, exts[i-1].start, exts[i-1].end-1, exts[i].start, exts[i].end-1); err != nil { + return err + } + } + } + + // see if any extension range overlaps any reserved range + var i, j int // i indexes rsvd; j indexes exts + for i < len(rsvd) && j < len(exts) { + if rsvd[i].start >= exts[j].start && rsvd[i].start < exts[j].end || + exts[j].start >= rsvd[i].start && exts[j].start < rsvd[i].end { + var pos ast.SourcePos + if rsvd[i].start >= exts[j].start && rsvd[i].start < exts[j].end { + rangeNodeInfo := res.file.NodeInfo(rsvd[i].node) + pos = rangeNodeInfo.Start() + } else { + rangeNodeInfo := res.file.NodeInfo(exts[j].node) + pos = rangeNodeInfo.Start() + } + // ranges overlap + if err := handler.HandleErrorf(pos, "%s: extension range %d to %d overlaps reserved range %d to %d", scope, exts[j].start, exts[j].end-1, rsvd[i].start, rsvd[i].end-1); err != nil { + return err + } + } + if rsvd[i].start < exts[j].start { + i++ + } else { + j++ + } + } + + // now, check that fields don't re-use tags and don't try to use extension + // or reserved ranges or reserved names + rsvdNames := map[string]struct{}{} + for _, n := range md.ReservedName { + // validate reserved name while we're here + if !isIdentifier(n) { + node := findMessageReservedNameNode(res.MessageNode(md), n) + nodeInfo := res.file.NodeInfo(node) + if err := handler.HandleErrorf(nodeInfo.Start(), "%s: reserved name %q is not a valid identifier", scope, n); err != nil { + return err + } + } + rsvdNames[n] = struct{}{} + } + fieldTags := map[int32]string{} + for _, fld := range md.Field { + fn := res.FieldNode(fld) + if _, ok := rsvdNames[fld.GetName()]; ok { + fieldNameNodeInfo := res.file.NodeInfo(fn.FieldName()) + if err := handler.HandleErrorf(fieldNameNodeInfo.Start(), "%s: field %s is using a reserved name", scope, fld.GetName()); err != nil { + return err + } + } + if existing := fieldTags[fld.GetNumber()]; existing != "" { + fieldTagNodeInfo := res.file.NodeInfo(fn.FieldTag()) + if err := handler.HandleErrorf(fieldTagNodeInfo.Start(), "%s: fields %s and %s both have the same tag %d", scope, existing, fld.GetName(), fld.GetNumber()); err != nil { + return err + } + } + fieldTags[fld.GetNumber()] = fld.GetName() + // check reserved ranges + r := sort.Search(len(rsvd), func(index int) bool { return rsvd[index].end > fld.GetNumber() }) + if r < len(rsvd) && rsvd[r].start <= fld.GetNumber() { + fieldTagNodeInfo := res.file.NodeInfo(fn.FieldTag()) + if err := handler.HandleErrorf(fieldTagNodeInfo.Start(), "%s: field %s is using tag %d which is in reserved range %d to %d", scope, fld.GetName(), fld.GetNumber(), rsvd[r].start, rsvd[r].end-1); err != nil { + return err + } + } + // and check extension ranges + e := sort.Search(len(exts), func(index int) bool { return exts[index].end > fld.GetNumber() }) + if e < len(exts) && exts[e].start <= fld.GetNumber() { + fieldTagNodeInfo := res.file.NodeInfo(fn.FieldTag()) + if err := handler.HandleErrorf(fieldTagNodeInfo.Start(), "%s: field %s is using tag %d which is in extension range %d to %d", scope, fld.GetName(), fld.GetNumber(), exts[e].start, exts[e].end-1); err != nil { + return err + } + } + } + + return nil +} + +func isIdentifier(s string) bool { + if len(s) == 0 { + return false + } + for i, r := range s { + if i == 0 && r >= '0' && r <= '9' { + // can't start with number + return false + } + // alphanumeric and underscore ok; everything else bad + switch { + case r >= '0' && r <= '9': + case r >= 'a' && r <= 'z': + case r >= 'A' && r <= 'Z': + case r == '_': + default: + return false + } + } + return true +} + +func findMessageReservedNameNode(msgNode ast.MessageDeclNode, name string) ast.Node { + var decls []ast.MessageElement + switch msgNode := msgNode.(type) { + case *ast.MessageNode: + decls = msgNode.Decls + case *ast.GroupNode: + decls = msgNode.Decls + default: + // leave decls empty + } + return findReservedNameNode(msgNode, decls, name) +} + +func findReservedNameNode[T ast.Node](parent ast.Node, decls []T, name string) ast.Node { + for _, decl := range decls { + // NB: We have to convert to empty interface first, before we can do a type + // assertion because type assertions on type parameters aren't allowed. (The + // compiler cannot yet know whether T is an interface type or not.) + rsvd, ok := any(decl).(*ast.ReservedNode) + if !ok { + continue + } + for _, rsvdName := range rsvd.Names { + if rsvdName.AsString() == name { + return rsvdName + } + } + } + // couldn't find it? Instead of puking, report position of the parent. + return parent +} + +func validateEnum(res *result, isProto3 bool, name protoreflect.FullName, ed *descriptorpb.EnumDescriptorProto, handler *reporter.Handler) error { + scope := fmt.Sprintf("enum %s", name) + + if len(ed.Value) == 0 { + enNode := res.EnumNode(ed) + enNodeInfo := res.file.NodeInfo(enNode) + if err := handler.HandleErrorf(enNodeInfo.Start(), "%s: enums must define at least one value", scope); err != nil { + return err + } + } + + allowAlias := false + var allowAliasOpt *descriptorpb.UninterpretedOption + if index, err := internal.FindOption(res, handler, scope, ed.Options.GetUninterpretedOption(), "allow_alias"); err != nil { + return err + } else if index >= 0 { + allowAliasOpt = ed.Options.UninterpretedOption[index] + valid := false + if allowAliasOpt.IdentifierValue != nil { + if allowAliasOpt.GetIdentifierValue() == "true" { + allowAlias = true + valid = true + } else if allowAliasOpt.GetIdentifierValue() == "false" { + valid = true + } + } + if !valid { + optNode := res.OptionNode(allowAliasOpt) + optNodeInfo := res.file.NodeInfo(optNode.GetValue()) + if err := handler.HandleErrorf(optNodeInfo.Start(), "%s: expecting bool value for allow_alias option", scope); err != nil { + return err + } + } + } + + if isProto3 && len(ed.Value) > 0 && ed.Value[0].GetNumber() != 0 { + evNode := res.EnumValueNode(ed.Value[0]) + evNodeInfo := res.file.NodeInfo(evNode.GetNumber()) + if err := handler.HandleErrorf(evNodeInfo.Start(), "%s: proto3 requires that first value in enum have numeric value of 0", scope); err != nil { + return err + } + } + + // check for aliases + vals := map[int32]string{} + hasAlias := false + for _, evd := range ed.Value { + existing := vals[evd.GetNumber()] + if existing != "" { + if allowAlias { + hasAlias = true + } else { + evNode := res.EnumValueNode(evd) + evNodeInfo := res.file.NodeInfo(evNode.GetNumber()) + if err := handler.HandleErrorf(evNodeInfo.Start(), "%s: values %s and %s both have the same numeric value %d; use allow_alias option if intentional", scope, existing, evd.GetName(), evd.GetNumber()); err != nil { + return err + } + } + } + vals[evd.GetNumber()] = evd.GetName() + } + if allowAlias && !hasAlias { + optNode := res.OptionNode(allowAliasOpt) + optNodeInfo := res.file.NodeInfo(optNode.GetValue()) + if err := handler.HandleErrorf(optNodeInfo.Start(), "%s: allow_alias is true but no values are aliases", scope); err != nil { + return err + } + } + + // reserved ranges should not overlap + rsvd := make(tagRanges, len(ed.ReservedRange)) + for i, r := range ed.ReservedRange { + n := res.EnumReservedRangeNode(r) + rsvd[i] = tagRange{start: r.GetStart(), end: r.GetEnd(), node: n} + } + sort.Sort(rsvd) + for i := 1; i < len(rsvd); i++ { + if rsvd[i].start <= rsvd[i-1].end { + rangeNodeInfo := res.file.NodeInfo(rsvd[i].node) + if err := handler.HandleErrorf(rangeNodeInfo.Start(), "%s: reserved ranges overlap: %d to %d and %d to %d", scope, rsvd[i-1].start, rsvd[i-1].end, rsvd[i].start, rsvd[i].end); err != nil { + return err + } + } + } + + // now, check that fields don't re-use tags and don't try to use extension + // or reserved ranges or reserved names + rsvdNames := map[string]struct{}{} + for _, n := range ed.ReservedName { + // validate reserved name while we're here + if !isIdentifier(n) { + node := findEnumReservedNameNode(res.EnumNode(ed), n) + nodeInfo := res.file.NodeInfo(node) + if err := handler.HandleErrorf(nodeInfo.Start(), "%s: reserved name %q is not a valid identifier", scope, n); err != nil { + return err + } + } + rsvdNames[n] = struct{}{} + } + for _, ev := range ed.Value { + evn := res.EnumValueNode(ev) + if _, ok := rsvdNames[ev.GetName()]; ok { + enumValNodeInfo := res.file.NodeInfo(evn.GetName()) + if err := handler.HandleErrorf(enumValNodeInfo.Start(), "%s: value %s is using a reserved name", scope, ev.GetName()); err != nil { + return err + } + } + // check reserved ranges + r := sort.Search(len(rsvd), func(index int) bool { return rsvd[index].end >= ev.GetNumber() }) + if r < len(rsvd) && rsvd[r].start <= ev.GetNumber() { + enumValNodeInfo := res.file.NodeInfo(evn.GetNumber()) + if err := handler.HandleErrorf(enumValNodeInfo.Start(), "%s: value %s is using number %d which is in reserved range %d to %d", scope, ev.GetName(), ev.GetNumber(), rsvd[r].start, rsvd[r].end); err != nil { + return err + } + } + } + + return nil +} + +func findEnumReservedNameNode(enumNode ast.Node, name string) ast.Node { + var decls []ast.EnumElement + if enumNode, ok := enumNode.(*ast.EnumNode); ok { + decls = enumNode.Decls + // if not the right type, we leave decls empty + } + return findReservedNameNode(enumNode, decls, name) +} + +func validateField(res *result, isProto3 bool, name protoreflect.FullName, fld *descriptorpb.FieldDescriptorProto, handler *reporter.Handler) error { + scope := fmt.Sprintf("field %s", name) + + node := res.FieldNode(fld) + if isProto3 { + if fld.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP { + groupNodeInfo := res.file.NodeInfo(node.GetGroupKeyword()) + if err := handler.HandleErrorf(groupNodeInfo.Start(), "%s: groups are not allowed in proto3", scope); err != nil { + return err + } + } else if fld.Label != nil && fld.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REQUIRED { + fieldLabelNodeInfo := res.file.NodeInfo(node.FieldLabel()) + if err := handler.HandleErrorf(fieldLabelNodeInfo.Start(), "%s: label 'required' is not allowed in proto3", scope); err != nil { + return err + } + } + if index, err := internal.FindOption(res, handler, scope, fld.Options.GetUninterpretedOption(), "default"); err != nil { + return err + } else if index >= 0 { + optNode := res.OptionNode(fld.Options.GetUninterpretedOption()[index]) + optNameNodeInfo := res.file.NodeInfo(optNode.GetName()) + if err := handler.HandleErrorf(optNameNodeInfo.Start(), "%s: default values are not allowed in proto3", scope); err != nil { + return err + } + } + } else { + if fld.Label == nil && fld.OneofIndex == nil { + fieldNameNodeInfo := res.file.NodeInfo(node.FieldName()) + if err := handler.HandleErrorf(fieldNameNodeInfo.Start(), "%s: field has no label; proto2 requires explicit 'optional' label", scope); err != nil { + return err + } + } + if fld.GetExtendee() != "" && fld.Label != nil && fld.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REQUIRED { + fieldLabelNodeInfo := res.file.NodeInfo(node.FieldLabel()) + if err := handler.HandleErrorf(fieldLabelNodeInfo.Start(), "%s: extension fields cannot be 'required'", scope); err != nil { + return err + } + } + } + + // finally, set any missing label to optional + if fld.Label == nil { + fld.Label = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum() + } + + return nil +} + +type tagRange struct { + start int32 + end int32 + node ast.RangeDeclNode +} + +type tagRanges []tagRange + +func (r tagRanges) Len() int { + return len(r) +} + +func (r tagRanges) Less(i, j int) bool { + return r[i].start < r[j].start || + (r[i].start == r[j].start && r[i].end < r[j].end) +} + +func (r tagRanges) Swap(i, j int) { + r[i], r[j] = r[j], r[i] +} diff --git a/vendor/github.com/bufbuild/protocompile/protoutil/protos.go b/vendor/github.com/bufbuild/protocompile/protoutil/protos.go new file mode 100644 index 00000000000..ad8044260d5 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/protoutil/protos.go @@ -0,0 +1,261 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package protoutil contains useful functions for interacting with descriptors. +// For now these include only functions for efficiently converting descriptors +// produced by the compiler to descriptor protos. +// +// Despite the fact that descriptor protos are mutable, calling code should NOT +// mutate any of the protos returned from this package. For efficiency, some +// protos returned from this package may be part of internal state of a compiler +// result, and mutating the proto could corrupt or invalidate parts of that +// result. +package protoutil + +import ( + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" +) + +// DescriptorProtoWrapper is a protoreflect.Descriptor that wraps an +// underlying descriptor proto. It provides the same interface as +// Descriptor but with one extra operation, to efficiently query for +// the underlying descriptor proto. +// +// Descriptors that implement this will also implement another method +// whose specified return type is the concrete type returned by the +// AsProto method. The name of this method varies by the type of this +// descriptor: +// +// Descriptor Type Other Method Name +// ---------------------+------------------------------------ +// FileDescriptor | FileDescriptorProto() +// MessageDescriptor | MessageDescriptorProto() +// FieldDescriptor | FieldDescriptorProto() +// OneofDescriptor | OneOfDescriptorProto() +// EnumDescriptor | EnumDescriptorProto() +// EnumValueDescriptor | EnumValueDescriptorProto() +// ServiceDescriptor | ServiceDescriptorProto() +// MethodDescriptor | MethodDescriptorProto() +// +// For example, a DescriptorProtoWrapper that implements FileDescriptor +// returns a *descriptorpb.FileDescriptorProto value from its AsProto +// method and also provides a method with the following signature: +// +// FileDescriptorProto() *descriptorpb.FileDescriptorProto +type DescriptorProtoWrapper interface { + protoreflect.Descriptor + // AsProto returns the underlying descriptor proto. The concrete + // type of the proto message depends on the type of this + // descriptor: + // Descriptor Type Proto Message Type + // ---------------------+------------------------------------ + // FileDescriptor | *descriptorpb.FileDescriptorProto + // MessageDescriptor | *descriptorpb.DescriptorProto + // FieldDescriptor | *descriptorpb.FieldDescriptorProto + // OneofDescriptor | *descriptorpb.OneofDescriptorProto + // EnumDescriptor | *descriptorpb.EnumDescriptorProto + // EnumValueDescriptor | *descriptorpb.EnumValueDescriptorProto + // ServiceDescriptor | *descriptorpb.ServiceDescriptorProto + // MethodDescriptor | *descriptorpb.MethodDescriptorProto + AsProto() proto.Message +} + +// ProtoFromDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. Descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromDescriptor(d protoreflect.Descriptor) proto.Message { + switch d := d.(type) { + case protoreflect.FileDescriptor: + return ProtoFromFileDescriptor(d) + case protoreflect.MessageDescriptor: + return ProtoFromMessageDescriptor(d) + case protoreflect.FieldDescriptor: + return ProtoFromFieldDescriptor(d) + case protoreflect.OneofDescriptor: + return ProtoFromOneofDescriptor(d) + case protoreflect.EnumDescriptor: + return ProtoFromEnumDescriptor(d) + case protoreflect.EnumValueDescriptor: + return ProtoFromEnumValueDescriptor(d) + case protoreflect.ServiceDescriptor: + return ProtoFromServiceDescriptor(d) + case protoreflect.MethodDescriptor: + return ProtoFromMethodDescriptor(d) + default: + // WTF?? + if res, ok := d.(DescriptorProtoWrapper); ok { + return res.AsProto() + } + return nil + } +} + +// ProtoFromFileDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For file descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. File descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromFileDescriptor(d protoreflect.FileDescriptor) *descriptorpb.FileDescriptorProto { + if imp, ok := d.(protoreflect.FileImport); ok { + d = imp.FileDescriptor + } + type canProto interface { + FileDescriptorProto() *descriptorpb.FileDescriptorProto + } + if res, ok := d.(canProto); ok { + return res.FileDescriptorProto() + } + if res, ok := d.(DescriptorProtoWrapper); ok { + if fd, ok := res.AsProto().(*descriptorpb.FileDescriptorProto); ok { + return fd + } + } + return protodesc.ToFileDescriptorProto(d) +} + +// ProtoFromMessageDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For message descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. Message descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromMessageDescriptor(d protoreflect.MessageDescriptor) *descriptorpb.DescriptorProto { + type canProto interface { + MessageDescriptorProto() *descriptorpb.DescriptorProto + } + if res, ok := d.(canProto); ok { + return res.MessageDescriptorProto() + } + if res, ok := d.(DescriptorProtoWrapper); ok { + if md, ok := res.AsProto().(*descriptorpb.DescriptorProto); ok { + return md + } + } + return protodesc.ToDescriptorProto(d) +} + +// ProtoFromFieldDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For field descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. Field descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromFieldDescriptor(d protoreflect.FieldDescriptor) *descriptorpb.FieldDescriptorProto { + type canProto interface { + FieldDescriptorProto() *descriptorpb.FieldDescriptorProto + } + if res, ok := d.(canProto); ok { + return res.FieldDescriptorProto() + } + if res, ok := d.(DescriptorProtoWrapper); ok { + if fd, ok := res.AsProto().(*descriptorpb.FieldDescriptorProto); ok { + return fd + } + } + return protodesc.ToFieldDescriptorProto(d) +} + +// ProtoFromOneofDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For oneof descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. Oneof descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromOneofDescriptor(d protoreflect.OneofDescriptor) *descriptorpb.OneofDescriptorProto { + type canProto interface { + OneofDescriptorProto() *descriptorpb.OneofDescriptorProto + } + if res, ok := d.(canProto); ok { + return res.OneofDescriptorProto() + } + if res, ok := d.(DescriptorProtoWrapper); ok { + if ood, ok := res.AsProto().(*descriptorpb.OneofDescriptorProto); ok { + return ood + } + } + return protodesc.ToOneofDescriptorProto(d) +} + +// ProtoFromEnumDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For enum descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. Enum descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromEnumDescriptor(d protoreflect.EnumDescriptor) *descriptorpb.EnumDescriptorProto { + type canProto interface { + EnumDescriptorProto() *descriptorpb.EnumDescriptorProto + } + if res, ok := d.(canProto); ok { + return res.EnumDescriptorProto() + } + if res, ok := d.(DescriptorProtoWrapper); ok { + if ed, ok := res.AsProto().(*descriptorpb.EnumDescriptorProto); ok { + return ed + } + } + return protodesc.ToEnumDescriptorProto(d) +} + +// ProtoFromEnumValueDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For enum value descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. Enum value descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromEnumValueDescriptor(d protoreflect.EnumValueDescriptor) *descriptorpb.EnumValueDescriptorProto { + type canProto interface { + EnumValueDescriptorProto() *descriptorpb.EnumValueDescriptorProto + } + if res, ok := d.(canProto); ok { + return res.EnumValueDescriptorProto() + } + if res, ok := d.(DescriptorProtoWrapper); ok { + if ed, ok := res.AsProto().(*descriptorpb.EnumValueDescriptorProto); ok { + return ed + } + } + return protodesc.ToEnumValueDescriptorProto(d) +} + +// ProtoFromServiceDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For service descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. Service descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromServiceDescriptor(d protoreflect.ServiceDescriptor) *descriptorpb.ServiceDescriptorProto { + type canProto interface { + ServiceDescriptorProto() *descriptorpb.ServiceDescriptorProto + } + if res, ok := d.(canProto); ok { + return res.ServiceDescriptorProto() + } + if res, ok := d.(DescriptorProtoWrapper); ok { + if sd, ok := res.AsProto().(*descriptorpb.ServiceDescriptorProto); ok { + return sd + } + } + return protodesc.ToServiceDescriptorProto(d) +} + +// ProtoFromMethodDescriptor extracts a descriptor proto from the given "rich" +// descriptor. For method descriptors generated by the compiler, this is an +// inexpensive and non-lossy operation. Method descriptors from other sources +// however may be expensive (to re-create a proto) and even lossy. +func ProtoFromMethodDescriptor(d protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto { + type canProto interface { + MethodDescriptorProto() *descriptorpb.MethodDescriptorProto + } + if res, ok := d.(canProto); ok { + return res.MethodDescriptorProto() + } + if res, ok := d.(DescriptorProtoWrapper); ok { + if md, ok := res.AsProto().(*descriptorpb.MethodDescriptorProto); ok { + return md + } + } + return protodesc.ToMethodDescriptorProto(d) +} diff --git a/vendor/github.com/bufbuild/protocompile/reporter/errors.go b/vendor/github.com/bufbuild/protocompile/reporter/errors.go new file mode 100644 index 00000000000..2932c79fb24 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/reporter/errors.go @@ -0,0 +1,68 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package reporter + +import ( + "errors" + "fmt" + + "github.com/bufbuild/protocompile/ast" +) + +// ErrInvalidSource is a sentinel error that is returned by compilation and +// stand-alone compilation steps (such as parsing, linking) when one or more +// errors is reported but the configured ErrorReporter always returns nil. +var ErrInvalidSource = errors.New("parse failed: invalid proto source") + +// ErrorWithPos is an error about a proto source file that adds information +// about the location in the file that caused the error. +type ErrorWithPos interface { + error + // GetPosition returns the source position that caused the underlying error. + GetPosition() ast.SourcePos + // Unwrap returns the underlying error. + Unwrap() error +} + +// Error creates a new ErrorWithPos from the given error and source position. +func Error(pos ast.SourcePos, err error) ErrorWithPos { + return errorWithSourcePos{pos: pos, underlying: err} +} + +// Errorf creates a new ErrorWithPos whose underlying error is created using the +// given message format and arguments (via fmt.Errorf). +func Errorf(pos ast.SourcePos, format string, args ...interface{}) ErrorWithPos { + return errorWithSourcePos{pos: pos, underlying: fmt.Errorf(format, args...)} +} + +type errorWithSourcePos struct { + underlying error + pos ast.SourcePos +} + +func (e errorWithSourcePos) Error() string { + sourcePos := e.GetPosition() + return fmt.Sprintf("%s: %v", sourcePos, e.underlying) +} + +func (e errorWithSourcePos) GetPosition() ast.SourcePos { + return e.pos +} + +func (e errorWithSourcePos) Unwrap() error { + return e.underlying +} + +var _ ErrorWithPos = errorWithSourcePos{} diff --git a/vendor/github.com/bufbuild/protocompile/reporter/reporter.go b/vendor/github.com/bufbuild/protocompile/reporter/reporter.go new file mode 100644 index 00000000000..d3a31686981 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/reporter/reporter.go @@ -0,0 +1,232 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package reporter contains the types used for reporting errors from +// protocompile operations. It contains error types as well as interfaces +// for reporting and handling errors and warnings. +package reporter + +import ( + "sync" + + "github.com/bufbuild/protocompile/ast" +) + +// ErrorReporter is responsible for reporting the given error. If the reporter +// returns a non-nil error, parsing/linking will abort with that error. If the +// reporter returns nil, parsing will continue, allowing the parser to try to +// report as many syntax and/or link errors as it can find. +type ErrorReporter func(err ErrorWithPos) error + +// WarningReporter is responsible for reporting the given warning. This is used +// for indicating non-error messages to the calling program for things that do +// not cause the parse to fail but are considered bad practice. Though they are +// just warnings, the details are supplied to the reporter via an error type. +type WarningReporter func(ErrorWithPos) + +// Reporter is a type that handles reporting both errors and warnings. +// A reporter does not need to be thread-safe. Safe concurrent access is +// managed by a Handler. +type Reporter interface { + // Error is called when the given error is encountered and needs to be + // reported to the calling program. This signature matches ErrorReporter + // because it has the same semantics. If this function returns non-nil + // then the operation will abort immediately with the given error. But + // if it returns nil, the operation will continue, reporting more errors + // as they are encountered. If the reporter never returns non-nil then + // the operation will eventually fail with ErrInvalidSource. + Error(ErrorWithPos) error + // Warning is called when the given warnings is encountered and needs to be + // reported to the calling program. Despite the argument being an error + // type, a warning will never cause the operation to abort or fail (unless + // the reporter's implementation of this method panics). + Warning(ErrorWithPos) +} + +// NewReporter creates a new reporter that invokes the given functions on error +// or warning. +func NewReporter(errs ErrorReporter, warnings WarningReporter) Reporter { + return reporterFuncs{errs: errs, warnings: warnings} +} + +type reporterFuncs struct { + errs ErrorReporter + warnings WarningReporter +} + +func (r reporterFuncs) Error(err ErrorWithPos) error { + if r.errs == nil { + return err + } + return r.errs(err) +} + +func (r reporterFuncs) Warning(err ErrorWithPos) { + if r.warnings != nil { + r.warnings(err) + } +} + +// Handler is used by protocompile operations for handling errors and warnings. +// This type is thread-safe. It uses a mutex to serialize calls to its reporter +// so that reporter instances do not have to be thread-safe (unless re-used +// across multiple handlers). +type Handler struct { + parent *Handler + mu sync.Mutex + reporter Reporter + errsReported bool + err error +} + +// NewHandler creates a new Handler that reports errors and warnings using the +// given reporter. +func NewHandler(rep Reporter) *Handler { + if rep == nil { + rep = NewReporter(nil, nil) + } + return &Handler{reporter: rep} +} + +// SubHandler returns a "child" of h. Use of a child handler is the same as use +// of the parent, except that the Error() and ReporterError() functions only +// report non-nil for errors that were reported using the child handler. So +// errors reported directly to the parent or to a different child handler won't +// be returned. This is useful for making concurrent access to the handler more +// deterministic: if a child handler is only used from one goroutine, its view +// of reported errors is consistent and unimpacted by concurrent operations. +func (h *Handler) SubHandler() *Handler { + return &Handler{parent: h} +} + +// HandleError handles the given error. If the given err is an ErrorWithPos, it +// is reported, and this function returns the error returned by the reporter. If +// the given err is NOT an ErrorWithPos, the current operation will abort +// immediately. +// +// If the handler has already aborted (by returning a non-nil error from a prior +// call to HandleError or HandleErrorf), that same error is returned and the +// given error is not reported. +func (h *Handler) HandleError(err error) error { + if h.parent != nil { + _, isErrWithPos := err.(ErrorWithPos) + err = h.parent.HandleError(err) + + // update child state + h.mu.Lock() + defer h.mu.Unlock() + if isErrWithPos { + h.errsReported = true + } + h.err = err + return err + } + + h.mu.Lock() + defer h.mu.Unlock() + + if h.err != nil { + return h.err + } + if ewp, ok := err.(ErrorWithPos); ok { + h.errsReported = true + err = h.reporter.Error(ewp) + } + h.err = err + return err +} + +// HandleErrorWithPos handles an error with the given source position. +// +// If the handler has already aborted (by returning a non-nil error from a prior +// call to HandleError or HandleErrorf), that same error is returned and the +// given error is not reported. +func (h *Handler) HandleErrorWithPos(pos ast.SourcePos, err error) error { + if ewp, ok := err.(ErrorWithPos); ok { + // replace existing position with given one + err = errorWithSourcePos{pos: pos, underlying: ewp.Unwrap()} + } else { + err = errorWithSourcePos{pos: pos, underlying: err} + } + return h.HandleError(err) +} + +// HandleErrorf handles an error with the given source position, creating the +// error using the given message format and arguments. +// +// If the handler has already aborted (by returning a non-nil error from a call +// to HandleError or HandleErrorf), that same error is returned and the given +// error is not reported. +func (h *Handler) HandleErrorf(pos ast.SourcePos, format string, args ...interface{}) error { + return h.HandleError(Errorf(pos, format, args...)) +} + +// HandleWarning handles the given warning. This will delegate to the handler's +// configured reporter. +func (h *Handler) HandleWarning(err ErrorWithPos) { + if h.parent != nil { + h.parent.HandleWarning(err) + return + } + + // even though we aren't touching mutable fields, we acquire lock anyway so + // that underlying reporter does not have to be thread-safe + h.mu.Lock() + defer h.mu.Unlock() + + h.reporter.Warning(err) +} + +// HandleWarningWithPos handles a warning with the given source position. This will +// delegate to the handler's configured reporter. +func (h *Handler) HandleWarningWithPos(pos ast.SourcePos, err error) { + ewp, ok := err.(ErrorWithPos) + if ok { + // replace existing position with given one + ewp = errorWithSourcePos{pos: pos, underlying: ewp.Unwrap()} + } else { + ewp = errorWithSourcePos{pos: pos, underlying: err} + } + h.HandleWarning(ewp) +} + +// HandleWarningf handles a warning with the given source position, creating the +// actual error value using the given message format and arguments. +func (h *Handler) HandleWarningf(pos ast.SourcePos, format string, args ...interface{}) { + h.HandleWarning(Errorf(pos, format, args...)) +} + +// Error returns the handler result. If any errors have been reported then this +// returns a non-nil error. If the reporter never returned a non-nil error then +// ErrInvalidSource is returned. Otherwise, this returns the error returned by +// the handler's reporter (the same value returned by ReporterError). +func (h *Handler) Error() error { + h.mu.Lock() + defer h.mu.Unlock() + + if h.errsReported && h.err == nil { + return ErrInvalidSource + } + return h.err +} + +// ReporterError returns the error returned by the handler's reporter. If +// the reporter has either not been invoked (no errors handled) or has not +// returned any non-nil value, then this returns nil. +func (h *Handler) ReporterError() error { + h.mu.Lock() + defer h.mu.Unlock() + + return h.err +} diff --git a/vendor/github.com/bufbuild/protocompile/resolver.go b/vendor/github.com/bufbuild/protocompile/resolver.go new file mode 100644 index 00000000000..706b873bda8 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/resolver.go @@ -0,0 +1,192 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protocompile + +import ( + "errors" + "io" + "io/fs" + "os" + "path/filepath" + "strings" + + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/parser" +) + +// Resolver is used by the compiler to resolve a proto source file name +// into some unit that is usable by the compiler. The result could be source +// for a proto file or it could be an already-parsed AST or descriptor. +// +// Resolver implementations must be thread-safe as a single compilation +// operation could invoke FindFileByPath from multiple goroutines. +type Resolver interface { + // FindFileByPath searches for information for the given file path. If no + // result is available, it should return a non-nil error, such as + // protoregistry.NotFound. + FindFileByPath(path string) (SearchResult, error) +} + +// SearchResult represents information about a proto source file. Only one of +// the various fields must be set, based on what is available for a file. If +// multiple fields are set, the compiler prefers them in opposite order listed: +// so it uses a descriptor if present and only falls back to source if nothing +// else is available. +type SearchResult struct { + // Represents source code for the file. This should be nil if source code + // is not available. If no field below is set, then the compiler will parse + // the source code into an AST. + Source io.Reader + // Represents the abstract syntax tree for the file. If no field below is + // set, then the compiler will convert the AST into a descriptor proto. + AST *ast.FileNode + // A descriptor proto that represents the file. If the field below is not + // set, then the compiler will link this proto with its dependencies to + // produce a linked descriptor. + Proto *descriptorpb.FileDescriptorProto + // A parse result for the file. This packages both an AST and a descriptor + // proto in one. When a parser result is available, it is more efficient + // than using an AST search result, since the descriptor proto need not be + // re-created. And it provides better error messages than a descriptor proto + // search results, since the AST has greater fidelity with regard to source + // positions (even if the descriptor proto includes source code info). + ParseResult parser.Result + // A fully linked descriptor that represents the file. If this field is set, + // then the compiler has no additional work to do for this file as it is + // already compiled. + Desc protoreflect.FileDescriptor +} + +// ResolverFunc is a simple function type that implements Resolver. +type ResolverFunc func(string) (SearchResult, error) + +var _ Resolver = ResolverFunc(nil) + +func (f ResolverFunc) FindFileByPath(path string) (SearchResult, error) { + return f(path) +} + +// CompositeResolver is a slice of resolvers, which are consulted in order +// until one can supply a result. If none of the constituent resolvers can +// supply a result, the error returned by the first resolver is returned. If +// the slice of resolvers is empty, all operations return +// protoregistry.NotFound. +type CompositeResolver []Resolver + +var _ Resolver = CompositeResolver(nil) + +func (f CompositeResolver) FindFileByPath(path string) (SearchResult, error) { + if len(f) == 0 { + return SearchResult{}, protoregistry.NotFound + } + var firstErr error + for _, res := range f { + r, err := res.FindFileByPath(path) + if err == nil { + return r, nil + } + if firstErr == nil { + firstErr = err + } + } + return SearchResult{}, firstErr +} + +// SourceResolver can resolve file names by returning source code. It uses +// an optional list of import paths to search. By default, it searches the +// file system. +type SourceResolver struct { + // Optional list of import paths. If present and not empty, then all + // file paths to find are assumed to be relative to one of these paths. + // If nil or empty, all file paths to find are assumed to be relative to + // the current working directory. + ImportPaths []string + // Optional function for returning a file's contents. If nil, then + // os.Open is used to open files on the file system. + // + // This function must be thread-safe as a single compilation operation + // could result in concurrent invocations of this function from + // multiple goroutines. + Accessor func(path string) (io.ReadCloser, error) +} + +var _ Resolver = (*SourceResolver)(nil) + +func (r *SourceResolver) FindFileByPath(path string) (SearchResult, error) { + if len(r.ImportPaths) == 0 { + reader, err := r.accessFile(path) + if err != nil { + return SearchResult{}, err + } + return SearchResult{Source: reader}, nil + } + + var e error + for _, importPath := range r.ImportPaths { + reader, err := r.accessFile(filepath.Join(importPath, path)) + if err != nil { + if errors.Is(err, fs.ErrNotExist) { + e = err + continue + } + return SearchResult{}, err + } + return SearchResult{Source: reader}, nil + } + return SearchResult{}, e +} + +func (r *SourceResolver) accessFile(path string) (io.ReadCloser, error) { + if r.Accessor != nil { + return r.Accessor(path) + } + return os.Open(path) +} + +// SourceAccessorFromMap returns a function that can be used as the Accessor +// field of a SourceResolver that uses the given map to load source. The map +// keys are file names and the values are the corresponding file contents. +// +// The given map is used directly and not copied. Since accessor functions +// must be thread-safe, this means that the provided map must not be mutated +// once this accessor is provided to a compile operation. +func SourceAccessorFromMap(srcs map[string]string) func(string) (io.ReadCloser, error) { + return func(path string) (io.ReadCloser, error) { + src, ok := srcs[path] + if !ok { + return nil, os.ErrNotExist + } + return io.NopCloser(strings.NewReader(src)), nil + } +} + +// WithStandardImports returns a new resolver that knows about the same standard +// imports that are included with protoc. +func WithStandardImports(r Resolver) Resolver { + return ResolverFunc(func(name string) (SearchResult, error) { + res, err := r.FindFileByPath(name) + if err != nil { + // error from given resolver? see if it's a known standard file + if d, ok := standardImports[name]; ok { + return SearchResult{Desc: d}, nil + } + } + return res, err + }) +} diff --git a/vendor/github.com/bufbuild/protocompile/sourceinfo/source_code_info.go b/vendor/github.com/bufbuild/protocompile/sourceinfo/source_code_info.go new file mode 100644 index 00000000000..02e6a09cd9f --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/sourceinfo/source_code_info.go @@ -0,0 +1,820 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package sourceinfo contains the logic for computing source code info for a +// file descriptor. +// +// The inputs to the computation are an AST for a file as well as the index of +// interpreted options for that file. +package sourceinfo + +import ( + "bytes" + "fmt" + "strings" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/internal" + "github.com/bufbuild/protocompile/options" +) + +// GenerateSourceInfo generates source code info for the given AST. If the given +// opts is present, it can generate source code info for interpreted options. +// Otherwise, any options in the AST will get source code info as uninterpreted +// options. +// +// This includes comments only for locations that represent complete declarations. +// This is the same behavior as protoc, the reference compiler for Protocol Buffers. +func GenerateSourceInfo(file *ast.FileNode, opts options.Index) *descriptorpb.SourceCodeInfo { + return generateSourceInfo(file, opts, false) +} + +// GenerateSourceInfoWithExtraComments generates source code info for the given +// AST. If the given opts is present, it can generate source code info for +// interpreted options. Otherwise, any options in the AST will get source code +// info as uninterpreted options. +// +// This includes comments for all locations. This is still lossy, but less so as +// it preserves far more comments from the source file. +func GenerateSourceInfoWithExtraComments(file *ast.FileNode, opts options.Index) *descriptorpb.SourceCodeInfo { + return generateSourceInfo(file, opts, true) +} + +func generateSourceInfo(file *ast.FileNode, opts options.Index, extraComments bool) *descriptorpb.SourceCodeInfo { + if file == nil { + return nil + } + + sci := sourceCodeInfo{file: file, commentsUsed: map[ast.SourcePos]struct{}{}, extraComments: extraComments} + path := make([]int32, 0, 10) + + sci.newLocWithoutComments(file, nil) + + if file.Syntax != nil { + sci.newLocWithComments(file.Syntax, append(path, internal.FileSyntaxTag)) + } + + var depIndex, pubDepIndex, weakDepIndex, optIndex, msgIndex, enumIndex, extendIndex, svcIndex int32 + + for _, child := range file.Decls { + switch child := child.(type) { + case *ast.ImportNode: + sci.newLocWithComments(child, append(path, internal.FileDependencyTag, depIndex)) + depIndex++ + if child.Public != nil { + sci.newLoc(child.Public, append(path, internal.FilePublicDependencyTag, pubDepIndex)) + pubDepIndex++ + } else if child.Weak != nil { + sci.newLoc(child.Weak, append(path, internal.FileWeakDependencyTag, weakDepIndex)) + weakDepIndex++ + } + case *ast.PackageNode: + sci.newLocWithComments(child, append(path, internal.FilePackageTag)) + case *ast.OptionNode: + generateSourceCodeInfoForOption(opts, &sci, child, false, &optIndex, append(path, internal.FileOptionsTag)) + case *ast.MessageNode: + generateSourceCodeInfoForMessage(opts, &sci, child, nil, append(path, internal.FileMessagesTag, msgIndex)) + msgIndex++ + case *ast.EnumNode: + generateSourceCodeInfoForEnum(opts, &sci, child, append(path, internal.FileEnumsTag, enumIndex)) + enumIndex++ + case *ast.ExtendNode: + generateSourceCodeInfoForExtensions(opts, &sci, child, &extendIndex, &msgIndex, append(path, internal.FileExtensionsTag), append(dup(path), internal.FileMessagesTag)) + case *ast.ServiceNode: + generateSourceCodeInfoForService(opts, &sci, child, append(path, internal.FileServicesTag, svcIndex)) + svcIndex++ + } + } + + return &descriptorpb.SourceCodeInfo{Location: sci.locs} +} + +func generateSourceCodeInfoForOption(opts options.Index, sci *sourceCodeInfo, n *ast.OptionNode, compact bool, uninterpIndex *int32, path []int32) { + if !compact { + sci.newLocWithoutComments(n, path) + } + subPath := opts[n] + if len(subPath) > 0 { + p := make([]int32, len(path), len(path)+len(subPath)) + copy(p, path) + if subPath[0] == -1 { + // used by "default" and "json_name" field pseudo-options + // to attribute path to parent element (since those are + // stored directly on the descriptor, not its options) + subPath = subPath[1:] + p = p[:len(path)-1] + } + p = append(p, subPath...) + if compact { + sci.newLoc(n, p) + } else { + sci.newLocWithComments(n, p) + } + return + } + + // it's an uninterpreted option + optPath := path + optPath = append(optPath, internal.UninterpretedOptionsTag, *uninterpIndex) + *uninterpIndex++ + sci.newLoc(n, optPath) + var valTag int32 + switch n.Val.(type) { + case ast.IdentValueNode: + valTag = internal.UninterpretedIdentTag + case *ast.NegativeIntLiteralNode: + valTag = internal.UninterpretedNegIntTag + case ast.IntValueNode: + valTag = internal.UninterpretedPosIntTag + case ast.FloatValueNode: + valTag = internal.UninterpretedDoubleTag + case ast.StringValueNode: + valTag = internal.UninterpretedStringTag + case *ast.MessageLiteralNode: + valTag = internal.UninterpretedAggregateTag + } + if valTag != 0 { + sci.newLoc(n.Val, append(optPath, valTag)) + } + for j, nn := range n.Name.Parts { + optNmPath := optPath + optNmPath = append(optNmPath, internal.UninterpretedNameTag, int32(j)) + sci.newLoc(nn, optNmPath) + sci.newLoc(nn.Name, append(optNmPath, internal.UninterpretedNameNameTag)) + } +} + +func generateSourceCodeInfoForMessage(opts options.Index, sci *sourceCodeInfo, n ast.MessageDeclNode, fieldPath []int32, path []int32) { + var openBrace ast.Node + + var decls []ast.MessageElement + switch n := n.(type) { + case *ast.MessageNode: + openBrace = n.OpenBrace + decls = n.Decls + case *ast.GroupNode: + openBrace = n.OpenBrace + decls = n.Decls + case *ast.MapFieldNode: + sci.newLoc(n, path) + // map entry so nothing else to do + return + } + sci.newBlockLocWithComments(n, openBrace, path) + + sci.newLoc(n.MessageName(), append(path, internal.MessageNameTag)) + // matching protoc, which emits the corresponding field type name (for group fields) + // right after the source location for the group message name + if fieldPath != nil { + sci.newLoc(n.MessageName(), append(fieldPath, internal.FieldTypeNameTag)) + } + + var optIndex, fieldIndex, oneOfIndex, extendIndex, nestedMsgIndex int32 + var nestedEnumIndex, extRangeIndex, reservedRangeIndex, reservedNameIndex int32 + for _, child := range decls { + switch child := child.(type) { + case *ast.OptionNode: + generateSourceCodeInfoForOption(opts, sci, child, false, &optIndex, append(path, internal.MessageOptionsTag)) + case *ast.FieldNode: + generateSourceCodeInfoForField(opts, sci, child, append(path, internal.MessageFieldsTag, fieldIndex)) + fieldIndex++ + case *ast.GroupNode: + fldPath := path + fldPath = append(fldPath, internal.MessageFieldsTag, fieldIndex) + generateSourceCodeInfoForField(opts, sci, child, fldPath) + fieldIndex++ + generateSourceCodeInfoForMessage(opts, sci, child, fldPath, append(dup(path), internal.MessageNestedMessagesTag, nestedMsgIndex)) + nestedMsgIndex++ + case *ast.MapFieldNode: + generateSourceCodeInfoForField(opts, sci, child, append(path, internal.MessageFieldsTag, fieldIndex)) + fieldIndex++ + nestedMsgIndex++ + case *ast.OneOfNode: + generateSourceCodeInfoForOneOf(opts, sci, child, &fieldIndex, &nestedMsgIndex, append(path, internal.MessageFieldsTag), append(dup(path), internal.MessageNestedMessagesTag), append(dup(path), internal.MessageOneOfsTag, oneOfIndex)) + oneOfIndex++ + case *ast.MessageNode: + generateSourceCodeInfoForMessage(opts, sci, child, nil, append(path, internal.MessageNestedMessagesTag, nestedMsgIndex)) + nestedMsgIndex++ + case *ast.EnumNode: + generateSourceCodeInfoForEnum(opts, sci, child, append(path, internal.MessageEnumsTag, nestedEnumIndex)) + nestedEnumIndex++ + case *ast.ExtendNode: + generateSourceCodeInfoForExtensions(opts, sci, child, &extendIndex, &nestedMsgIndex, append(path, internal.MessageExtensionsTag), append(dup(path), internal.MessageNestedMessagesTag)) + case *ast.ExtensionRangeNode: + generateSourceCodeInfoForExtensionRanges(opts, sci, child, &extRangeIndex, append(path, internal.MessageExtensionRangesTag)) + case *ast.ReservedNode: + if len(child.Names) > 0 { + resPath := path + resPath = append(resPath, internal.MessageReservedNamesTag) + sci.newLocWithComments(child, resPath) + for _, rn := range child.Names { + sci.newLoc(rn, append(resPath, reservedNameIndex)) + reservedNameIndex++ + } + } + if len(child.Ranges) > 0 { + resPath := path + resPath = append(resPath, internal.MessageReservedRangesTag) + sci.newLocWithComments(child, resPath) + for _, rr := range child.Ranges { + generateSourceCodeInfoForReservedRange(sci, rr, append(resPath, reservedRangeIndex)) + reservedRangeIndex++ + } + } + } + } +} + +func generateSourceCodeInfoForEnum(opts options.Index, sci *sourceCodeInfo, n *ast.EnumNode, path []int32) { + sci.newBlockLocWithComments(n, n.OpenBrace, path) + sci.newLoc(n.Name, append(path, internal.EnumNameTag)) + + var optIndex, valIndex, reservedNameIndex, reservedRangeIndex int32 + for _, child := range n.Decls { + switch child := child.(type) { + case *ast.OptionNode: + generateSourceCodeInfoForOption(opts, sci, child, false, &optIndex, append(path, internal.EnumOptionsTag)) + case *ast.EnumValueNode: + generateSourceCodeInfoForEnumValue(opts, sci, child, append(path, internal.EnumValuesTag, valIndex)) + valIndex++ + case *ast.ReservedNode: + if len(child.Names) > 0 { + resPath := path + resPath = append(resPath, internal.EnumReservedNamesTag) + sci.newLocWithComments(child, resPath) + for _, rn := range child.Names { + sci.newLoc(rn, append(resPath, reservedNameIndex)) + reservedNameIndex++ + } + } + if len(child.Ranges) > 0 { + resPath := path + resPath = append(resPath, internal.EnumReservedRangesTag) + sci.newLocWithComments(child, resPath) + for _, rr := range child.Ranges { + generateSourceCodeInfoForReservedRange(sci, rr, append(resPath, reservedRangeIndex)) + reservedRangeIndex++ + } + } + } + } +} + +func generateSourceCodeInfoForEnumValue(opts options.Index, sci *sourceCodeInfo, n *ast.EnumValueNode, path []int32) { + sci.newLocWithComments(n, path) + sci.newLoc(n.Name, append(path, internal.EnumValNameTag)) + sci.newLoc(n.Number, append(path, internal.EnumValNumberTag)) + + // enum value options + if n.Options != nil { + optsPath := path + optsPath = append(optsPath, internal.EnumValOptionsTag) + sci.newLoc(n.Options, optsPath) + var optIndex int32 + for _, opt := range n.Options.GetElements() { + generateSourceCodeInfoForOption(opts, sci, opt, true, &optIndex, optsPath) + } + } +} + +func generateSourceCodeInfoForReservedRange(sci *sourceCodeInfo, n *ast.RangeNode, path []int32) { + sci.newLoc(n, path) + sci.newLoc(n.StartVal, append(path, internal.ReservedRangeStartTag)) + switch { + case n.EndVal != nil: + sci.newLoc(n.EndVal, append(path, internal.ReservedRangeEndTag)) + case n.Max != nil: + sci.newLoc(n.Max, append(path, internal.ReservedRangeEndTag)) + default: + sci.newLoc(n.StartVal, append(path, internal.ReservedRangeEndTag)) + } +} + +func generateSourceCodeInfoForExtensions(opts options.Index, sci *sourceCodeInfo, n *ast.ExtendNode, extendIndex, msgIndex *int32, extendPath, msgPath []int32) { + sci.newBlockLocWithComments(n, n.OpenBrace, extendPath) + for _, decl := range n.Decls { + switch decl := decl.(type) { + case *ast.FieldNode: + generateSourceCodeInfoForField(opts, sci, decl, append(extendPath, *extendIndex)) + *extendIndex++ + case *ast.GroupNode: + fldPath := extendPath + fldPath = append(fldPath, *extendIndex) + generateSourceCodeInfoForField(opts, sci, decl, fldPath) + *extendIndex++ + generateSourceCodeInfoForMessage(opts, sci, decl, fldPath, append(msgPath, *msgIndex)) + *msgIndex++ + } + } +} + +func generateSourceCodeInfoForOneOf(opts options.Index, sci *sourceCodeInfo, n *ast.OneOfNode, fieldIndex, nestedMsgIndex *int32, fieldPath, nestedMsgPath, oneOfPath []int32) { + sci.newBlockLocWithComments(n, n.OpenBrace, oneOfPath) + sci.newLoc(n.Name, append(oneOfPath, internal.OneOfNameTag)) + + var optIndex int32 + for _, child := range n.Decls { + switch child := child.(type) { + case *ast.OptionNode: + generateSourceCodeInfoForOption(opts, sci, child, false, &optIndex, append(oneOfPath, internal.OneOfOptionsTag)) + case *ast.FieldNode: + generateSourceCodeInfoForField(opts, sci, child, append(fieldPath, *fieldIndex)) + *fieldIndex++ + case *ast.GroupNode: + fldPath := fieldPath + fldPath = append(fldPath, *fieldIndex) + generateSourceCodeInfoForField(opts, sci, child, fldPath) + *fieldIndex++ + generateSourceCodeInfoForMessage(opts, sci, child, fldPath, append(nestedMsgPath, *nestedMsgIndex)) + *nestedMsgIndex++ + } + } +} + +func generateSourceCodeInfoForField(opts options.Index, sci *sourceCodeInfo, n ast.FieldDeclNode, path []int32) { + var fieldType string + if f, ok := n.(*ast.FieldNode); ok { + fieldType = string(f.FldType.AsIdentifier()) + } + + if n.GetGroupKeyword() != nil { + // comments will appear on group message + sci.newLocWithoutComments(n, path) + if n.FieldExtendee() != nil { + sci.newLoc(n.FieldExtendee(), append(path, internal.FieldExtendeeTag)) + } + if n.FieldLabel() != nil { + // no comments here either (label is first token for group, so we want + // to leave the comments to be associated with the group message instead) + sci.newLocWithoutComments(n.FieldLabel(), append(path, internal.FieldLabelTag)) + } + sci.newLoc(n.FieldType(), append(path, internal.FieldTypeTag)) + // let the name comments be attributed to the group name + sci.newLocWithoutComments(n.FieldName(), append(path, internal.FieldNameTag)) + } else { + sci.newLocWithComments(n, path) + if n.FieldExtendee() != nil { + sci.newLoc(n.FieldExtendee(), append(path, internal.FieldExtendeeTag)) + } + if n.FieldLabel() != nil { + sci.newLoc(n.FieldLabel(), append(path, internal.FieldLabelTag)) + } + var tag int32 + if _, isScalar := internal.FieldTypes[fieldType]; isScalar { + tag = internal.FieldTypeTag + } else { + // this is a message or an enum, so attribute type location + // to the type name field + tag = internal.FieldTypeNameTag + } + sci.newLoc(n.FieldType(), append(path, tag)) + sci.newLoc(n.FieldName(), append(path, internal.FieldNameTag)) + } + sci.newLoc(n.FieldTag(), append(path, internal.FieldNumberTag)) + + if n.GetOptions() != nil { + optsPath := path + optsPath = append(optsPath, internal.FieldOptionsTag) + sci.newLoc(n.GetOptions(), optsPath) + var optIndex int32 + for _, opt := range n.GetOptions().GetElements() { + generateSourceCodeInfoForOption(opts, sci, opt, true, &optIndex, optsPath) + } + } +} + +func generateSourceCodeInfoForExtensionRanges(opts options.Index, sci *sourceCodeInfo, n *ast.ExtensionRangeNode, extRangeIndex *int32, path []int32) { + sci.newLocWithComments(n, path) + startExtRangeIndex := *extRangeIndex + for _, child := range n.Ranges { + path := append(path, *extRangeIndex) + *extRangeIndex++ + sci.newLoc(child, path) + sci.newLoc(child.StartVal, append(path, internal.ExtensionRangeStartTag)) + switch { + case child.EndVal != nil: + sci.newLoc(child.EndVal, append(path, internal.ExtensionRangeEndTag)) + case child.Max != nil: + sci.newLoc(child.Max, append(path, internal.ExtensionRangeEndTag)) + default: + sci.newLoc(child.StartVal, append(path, internal.ExtensionRangeEndTag)) + } + } + // options for all ranges go after the start+end values + for range n.Ranges { + path := append(path, startExtRangeIndex) + startExtRangeIndex++ + if n.Options != nil { + optsPath := path + optsPath = append(optsPath, internal.ExtensionRangeOptionsTag) + sci.newLoc(n.Options, optsPath) + var optIndex int32 + for _, opt := range n.Options.GetElements() { + generateSourceCodeInfoForOption(opts, sci, opt, true, &optIndex, optsPath) + } + } + } +} + +func generateSourceCodeInfoForService(opts options.Index, sci *sourceCodeInfo, n *ast.ServiceNode, path []int32) { + sci.newBlockLocWithComments(n, n.OpenBrace, path) + sci.newLoc(n.Name, append(path, internal.ServiceNameTag)) + var optIndex, rpcIndex int32 + for _, child := range n.Decls { + switch child := child.(type) { + case *ast.OptionNode: + generateSourceCodeInfoForOption(opts, sci, child, false, &optIndex, append(path, internal.ServiceOptionsTag)) + case *ast.RPCNode: + generateSourceCodeInfoForMethod(opts, sci, child, append(path, internal.ServiceMethodsTag, rpcIndex)) + rpcIndex++ + } + } +} + +func generateSourceCodeInfoForMethod(opts options.Index, sci *sourceCodeInfo, n *ast.RPCNode, path []int32) { + if n.OpenBrace != nil { + sci.newBlockLocWithComments(n, n.OpenBrace, path) + } else { + sci.newLocWithComments(n, path) + } + sci.newLoc(n.Name, append(path, internal.MethodNameTag)) + if n.Input.Stream != nil { + sci.newLoc(n.Input.Stream, append(path, internal.MethodInputStreamTag)) + } + sci.newLoc(n.Input.MessageType, append(path, internal.MethodInputTag)) + if n.Output.Stream != nil { + sci.newLoc(n.Output.Stream, append(path, internal.MethodOutputStreamTag)) + } + sci.newLoc(n.Output.MessageType, append(path, internal.MethodOutputTag)) + + optsPath := path + optsPath = append(optsPath, internal.MethodOptionsTag) + var optIndex int32 + for _, decl := range n.Decls { + if opt, ok := decl.(*ast.OptionNode); ok { + generateSourceCodeInfoForOption(opts, sci, opt, false, &optIndex, optsPath) + } + } +} + +type sourceCodeInfo struct { + file *ast.FileNode + extraComments bool + locs []*descriptorpb.SourceCodeInfo_Location + commentsUsed map[ast.SourcePos]struct{} +} + +func (sci *sourceCodeInfo) newLocWithoutComments(n ast.Node, path []int32) { + dup := make([]int32, len(path)) + copy(dup, path) + var start, end ast.SourcePos + if n == sci.file { + // For files, we don't want to consider trailing EOF token + // as part of the span. We want the span to only include + // actual lexical elements in the file (which also excludes + // whitespace and comments). + children := sci.file.Children() + if len(children) > 0 && isEOF(children[len(children)-1]) { + children = children[:len(children)-1] + } + if len(children) == 0 { + start = ast.SourcePos{Filename: sci.file.Name(), Line: 1, Col: 1} + end = start + } else { + start = sci.file.TokenInfo(n.Start()).Start() + end = sci.file.TokenInfo(children[len(children)-1].End()).End() + } + } else { + info := sci.file.NodeInfo(n) + start, end = info.Start(), info.End() + } + sci.locs = append(sci.locs, &descriptorpb.SourceCodeInfo_Location{ + Path: dup, + Span: makeSpan(start, end), + }) +} + +func (sci *sourceCodeInfo) newLoc(n ast.Node, path []int32) { + info := sci.file.NodeInfo(n) + if !sci.extraComments { + dup := make([]int32, len(path)) + copy(dup, path) + start, end := info.Start(), info.End() + sci.locs = append(sci.locs, &descriptorpb.SourceCodeInfo_Location{ + Path: dup, + Span: makeSpan(start, end), + }) + } else { + detachedComments, leadingComments := sci.getLeadingComments(n) + trailingComments := sci.getTrailingComments(n) + sci.newLocWithGivenComments(info, detachedComments, leadingComments, trailingComments, path) + } +} + +func isEOF(n ast.Node) bool { + r, ok := n.(*ast.RuneNode) + return ok && r.Rune == 0 +} + +func (sci *sourceCodeInfo) newBlockLocWithComments(n, openBrace ast.Node, path []int32) { + // Block definitions use trailing comments after the open brace "{" as the + // element's trailing comments. For example: + // + // message Foo { // this is a trailing comment for a message + // + // } // not this + // + nodeInfo := sci.file.NodeInfo(n) + detachedComments, leadingComments := sci.getLeadingComments(n) + trailingComments := sci.getTrailingComments(openBrace) + sci.newLocWithGivenComments(nodeInfo, detachedComments, leadingComments, trailingComments, path) +} + +func (sci *sourceCodeInfo) newLocWithComments(n ast.Node, path []int32) { + nodeInfo := sci.file.NodeInfo(n) + detachedComments, leadingComments := sci.getLeadingComments(n) + trailingComments := sci.getTrailingComments(n) + sci.newLocWithGivenComments(nodeInfo, detachedComments, leadingComments, trailingComments, path) +} + +func (sci *sourceCodeInfo) newLocWithGivenComments(nodeInfo ast.NodeInfo, detachedComments []comments, leadingComments comments, trailingComments comments, path []int32) { + if (len(detachedComments) > 0 && sci.commentUsed(detachedComments[0])) || + (len(detachedComments) == 0 && sci.commentUsed(leadingComments)) { + detachedComments = nil + leadingComments = ast.EmptyComments + } + if sci.commentUsed(trailingComments) { + trailingComments = ast.EmptyComments + } + + var trail *string + if trailingComments.Len() > 0 { + trail = proto.String(sci.combineComments(trailingComments)) + } + + var lead *string + if leadingComments.Len() > 0 { + lead = proto.String(sci.combineComments(leadingComments)) + } + + detached := make([]string, len(detachedComments)) + for i, cmts := range detachedComments { + detached[i] = sci.combineComments(cmts) + } + + dup := make([]int32, len(path)) + copy(dup, path) + sci.locs = append(sci.locs, &descriptorpb.SourceCodeInfo_Location{ + LeadingDetachedComments: detached, + LeadingComments: lead, + TrailingComments: trail, + Path: dup, + Span: makeSpan(nodeInfo.Start(), nodeInfo.End()), + }) +} + +type comments interface { + Len() int + Index(int) ast.Comment +} + +type subComments struct { + offs, n int + c ast.Comments +} + +func (s subComments) Len() int { + return s.n +} + +func (s subComments) Index(i int) ast.Comment { + if i < 0 || i >= s.n { + panic(fmt.Errorf("runtime error: index out of range [%d] with length %d", i, s.n)) + } + return s.c.Index(i + s.offs) +} + +func (sci *sourceCodeInfo) getLeadingComments(n ast.Node) ([]comments, comments) { + s := n.Start() + info := sci.file.TokenInfo(s) + var prevInfo ast.NodeInfo + if prev, ok := sci.file.Tokens().Previous(s); ok { + prevInfo = sci.file.TokenInfo(prev) + } + _, d, l := sci.attributeComments(prevInfo, info) + return d, l +} + +func (sci *sourceCodeInfo) getTrailingComments(n ast.Node) comments { + e := n.End() + next, ok := sci.file.Tokens().Next(e) + if !ok { + return ast.EmptyComments + } + info := sci.file.TokenInfo(e) + nextInfo := sci.file.TokenInfo(next) + t, _, _ := sci.attributeComments(info, nextInfo) + return t +} + +func (sci *sourceCodeInfo) attributeComments(prevInfo, info ast.NodeInfo) (t comments, d []comments, l comments) { + detached := groupComments(info.LeadingComments()) + var trail comments + if prevInfo.IsValid() { + trail = comments(prevInfo.TrailingComments()) + if trail.Len() == 0 { + trail, detached = sci.maybeDonate(prevInfo, info, detached) + } + } else { + trail = ast.EmptyComments + } + detached, lead := sci.maybeAttach(prevInfo, info, trail.Len() > 0, detached) + return trail, detached, lead +} + +func (sci *sourceCodeInfo) maybeDonate(prevInfo ast.NodeInfo, info ast.NodeInfo, lead []comments) (t comments, l []comments) { + if len(lead) == 0 { + // nothing to donate + return ast.EmptyComments, nil + } + if !sci.extraComments { + // Mirroring protoc for now: if tokens on the same line, attribution + // is ambiguous so drop everything. + // This condition can be dropped (and we can stop dropping comments) + // once this PR is released: + // https://github.com/protocolbuffers/protobuf/pull/10660 + if prevInfo.End().Line == info.Start().Line { + return ast.EmptyComments, nil + } + } + if lead[0].Index(0).Start().Line > prevInfo.End().Line+1 { + // first comment is detached from previous token, so can't be a trailing comment + return ast.EmptyComments, lead + } + if len(lead) > 1 { + // multiple groups? then donate first comment to previous token + return lead[0], lead[1:] + } + // there is only one element in lead + comment := lead[0] + if comment.Index(comment.Len()-1).End().Line < info.Start().Line-1 { + // there is a blank line between the comments and subsequent token, so + // we can donate the comment to previous token + return comment, nil + } + if txt := info.RawText(); len(txt) == 1 && strings.ContainsAny(txt, "}]),;") { + // token is a symbol for the end of a scope, which doesn't need a leading comment + return comment, nil + } + + // cannot donate + return ast.EmptyComments, lead +} + +func (sci *sourceCodeInfo) maybeAttach(prevInfo ast.NodeInfo, info ast.NodeInfo, hasTrail bool, lead []comments) (d []comments, l comments) { + if len(lead) == 0 { + return nil, ast.EmptyComments + } + + if len(lead) == 1 && !hasTrail && prevInfo.IsValid() { + // If the one comment appears attached to both previous and next tokens, + // don't attach to either. + comment := lead[0] + attachedToPrevious := comment.Index(0).Start().Line == prevInfo.End().Line + attachedToNext := comment.Index(comment.Len()-1).End().Line == info.Start().Line + if attachedToPrevious && attachedToNext { + if !sci.extraComments { + // Mirroring protoc for now: if comment starts on line of previous token + // and ends on line of next, attribution is ambiguous so drop everything. + // This condition can be dropped (and we can stop dropping comments) + // once this PR is released: + // https://github.com/protocolbuffers/protobuf/pull/10660 + return nil, ast.EmptyComments + } + // Since attachment is ambiguous, leave it detached. + return lead, ast.EmptyComments + } + } + + lastComment := lead[len(lead)-1] + if lastComment.Index(lastComment.Len()-1).End().Line >= info.Start().Line-1 { + return lead[:len(lead)-1], lastComment + } + + return lead, ast.EmptyComments +} + +func makeSpan(start, end ast.SourcePos) []int32 { + if start.Line == end.Line { + return []int32{int32(start.Line) - 1, int32(start.Col) - 1, int32(end.Col) - 1} + } + return []int32{int32(start.Line) - 1, int32(start.Col) - 1, int32(end.Line) - 1, int32(end.Col) - 1} +} + +func (sci *sourceCodeInfo) commentUsed(c comments) bool { + if c.Len() == 0 { + return false + } + pos := c.Index(0).Start() + if _, ok := sci.commentsUsed[pos]; ok { + return true + } + + sci.commentsUsed[pos] = struct{}{} + return false +} + +func groupComments(cmts ast.Comments) []comments { + if cmts.Len() == 0 { + return nil + } + var groups []comments + singleLineStyle := cmts.Index(0).RawText()[:2] == "//" + line := cmts.Index(0).End().Line + start := 0 + for i := 1; i < cmts.Len(); i++ { + c := cmts.Index(i) + prevSingleLine := singleLineStyle + singleLineStyle = strings.HasPrefix(c.RawText(), "//") + if !singleLineStyle || prevSingleLine != singleLineStyle || c.Start().Line > line+1 { + // new group! + groups = append(groups, subComments{offs: start, n: i - start, c: cmts}) + start = i + } + line = c.End().Line + } + // don't forget last group + groups = append(groups, subComments{offs: start, n: cmts.Len() - start, c: cmts}) + return groups +} + +func (sci *sourceCodeInfo) combineComments(comments comments) string { + if comments.Len() == 0 { + return "" + } + var buf bytes.Buffer + for i, l := 0, comments.Len(); i < l; i++ { + c := comments.Index(i) + txt := c.RawText() + if txt[:2] == "//" { + buf.WriteString(txt[2:]) + // protoc includes trailing newline for line comments, + // but it's not present in the AST comment. So we need + // to add it if present. + if i, ok := sci.file.Items().Next(c.AsItem()); ok { + info := sci.file.ItemInfo(i) + if strings.HasPrefix(info.LeadingWhitespace(), "\n") { + buf.WriteRune('\n') + } + } + } else { + lines := strings.Split(txt[2:len(txt)-2], "\n") + first := true + for _, l := range lines { + if first { + first = false + } else { + buf.WriteByte('\n') + } + + // strip a prefix of whitespace followed by '*' + j := 0 + for j < len(l) { + if l[j] != ' ' && l[j] != '\t' { + break + } + j++ + } + switch { + case j == len(l): + l = "" + case l[j] == '*': + l = l[j+1:] + case j > 0: + l = " " + l[j:] + } + + buf.WriteString(l) + } + } + } + return buf.String() +} + +func dup(p []int32) []int32 { + return append(([]int32)(nil), p...) +} diff --git a/vendor/github.com/bufbuild/protocompile/std_imports.go b/vendor/github.com/bufbuild/protocompile/std_imports.go new file mode 100644 index 00000000000..dcf8553a748 --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/std_imports.go @@ -0,0 +1,62 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protocompile + +import ( + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + _ "google.golang.org/protobuf/types/known/anypb" // link in packages that include the standard protos included with protoc. + _ "google.golang.org/protobuf/types/known/apipb" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/emptypb" + _ "google.golang.org/protobuf/types/known/fieldmaskpb" + _ "google.golang.org/protobuf/types/known/sourcecontextpb" + _ "google.golang.org/protobuf/types/known/structpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + _ "google.golang.org/protobuf/types/known/typepb" + _ "google.golang.org/protobuf/types/known/wrapperspb" + _ "google.golang.org/protobuf/types/pluginpb" +) + +// All files that are included with protoc are also included with this package +// so that clients do not need to explicitly supply a copy of these protos (just +// like callers of protoc do not need to supply them). +var standardImports map[string]protoreflect.FileDescriptor + +func init() { + standardFilenames := []string{ + "google/protobuf/any.proto", + "google/protobuf/api.proto", + "google/protobuf/compiler/plugin.proto", + "google/protobuf/descriptor.proto", + "google/protobuf/duration.proto", + "google/protobuf/empty.proto", + "google/protobuf/field_mask.proto", + "google/protobuf/source_context.proto", + "google/protobuf/struct.proto", + "google/protobuf/timestamp.proto", + "google/protobuf/type.proto", + "google/protobuf/wrappers.proto", + } + + standardImports = map[string]protoreflect.FileDescriptor{} + for _, fn := range standardFilenames { + fd, err := protoregistry.GlobalFiles.FindFileByPath(fn) + if err != nil { + panic(err.Error()) + } + standardImports[fn] = fd + } +} diff --git a/vendor/github.com/bufbuild/protocompile/walk/walk.go b/vendor/github.com/bufbuild/protocompile/walk/walk.go new file mode 100644 index 00000000000..e7a1ab3b1af --- /dev/null +++ b/vendor/github.com/bufbuild/protocompile/walk/walk.go @@ -0,0 +1,445 @@ +// Copyright 2020-2022 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package walk provides helper functions for traversing all elements in a +// protobuf file descriptor. There are versions both for traversing "rich" +// descriptors (protoreflect.Descriptor) and for traversing the underlying +// "raw" descriptor protos. +// +// # Enter And Exit +// +// This package includes variants of the functions that accept two callback +// functions. These variants have names ending with "EnterAndExit". One function +// is called as each element is visited ("enter") and the other is called after +// the element and all of its descendants have been visited ("exit"). This +// can be useful when you need to track state that is scoped to the visitation +// of a single element. +// +// # Source Path +// +// When traversing raw descriptor protos, this package include variants whose +// callback accepts a protoreflect.SourcePath. These variants have names that +// include "WithPath". This path can be used to locate corresponding data in the +// file's source code info (if present). +package walk + +import ( + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" + + "github.com/bufbuild/protocompile/internal" +) + +// Descriptors walks all descriptors in the given file using a depth-first +// traversal, calling the given function for each descriptor in the hierarchy. +// The walk ends when traversal is complete or when the function returns an +// error. If the function returns an error, that is returned as the result of the +// walk operation. +// +// Descriptors are visited using a pre-order traversal, where the function is +// called for a descriptor before it is called for any of its descendants. +func Descriptors(file protoreflect.FileDescriptor, fn func(protoreflect.Descriptor) error) error { + return DescriptorsEnterAndExit(file, fn, nil) +} + +// DescriptorsEnterAndExit walks all descriptors in the given file using a +// depth-first traversal, calling the given functions on entry and on exit +// for each descriptor in the hierarchy. The walk ends when traversal is +// complete or when a function returns an error. If a function returns an error, +// that is returned as the result of the walk operation. +// +// The enter function is called using a pre-order traversal, where the function +// is called for a descriptor before it is called for any of its descendants. +// The exit function is called using a post-order traversal, where the function +// is called for a descriptor only after it is called for any descendants. +func DescriptorsEnterAndExit(file protoreflect.FileDescriptor, enter, exit func(protoreflect.Descriptor) error) error { + for i := 0; i < file.Messages().Len(); i++ { + msg := file.Messages().Get(i) + if err := messageDescriptor(msg, enter, exit); err != nil { + return err + } + } + for i := 0; i < file.Enums().Len(); i++ { + en := file.Enums().Get(i) + if err := enumDescriptor(en, enter, exit); err != nil { + return err + } + } + for i := 0; i < file.Extensions().Len(); i++ { + ext := file.Extensions().Get(i) + if err := enter(ext); err != nil { + return err + } + if exit != nil { + if err := exit(ext); err != nil { + return err + } + } + } + for i := 0; i < file.Services().Len(); i++ { + svc := file.Services().Get(i) + if err := enter(svc); err != nil { + return err + } + for i := 0; i < svc.Methods().Len(); i++ { + mtd := svc.Methods().Get(i) + if err := enter(mtd); err != nil { + return err + } + if exit != nil { + if err := exit(mtd); err != nil { + return err + } + } + } + if exit != nil { + if err := exit(svc); err != nil { + return err + } + } + } + return nil +} + +func messageDescriptor(msg protoreflect.MessageDescriptor, enter, exit func(protoreflect.Descriptor) error) error { + if err := enter(msg); err != nil { + return err + } + for i := 0; i < msg.Fields().Len(); i++ { + fld := msg.Fields().Get(i) + if err := enter(fld); err != nil { + return err + } + if exit != nil { + if err := exit(fld); err != nil { + return err + } + } + } + for i := 0; i < msg.Oneofs().Len(); i++ { + oo := msg.Oneofs().Get(i) + if err := enter(oo); err != nil { + return err + } + if exit != nil { + if err := exit(oo); err != nil { + return err + } + } + } + for i := 0; i < msg.Messages().Len(); i++ { + nested := msg.Messages().Get(i) + if err := messageDescriptor(nested, enter, exit); err != nil { + return err + } + } + for i := 0; i < msg.Enums().Len(); i++ { + en := msg.Enums().Get(i) + if err := enumDescriptor(en, enter, exit); err != nil { + return err + } + } + for i := 0; i < msg.Extensions().Len(); i++ { + ext := msg.Extensions().Get(i) + if err := enter(ext); err != nil { + return err + } + if exit != nil { + if err := exit(ext); err != nil { + return err + } + } + } + if exit != nil { + if err := exit(msg); err != nil { + return err + } + } + return nil +} + +func enumDescriptor(en protoreflect.EnumDescriptor, enter, exit func(protoreflect.Descriptor) error) error { + if err := enter(en); err != nil { + return err + } + for i := 0; i < en.Values().Len(); i++ { + enVal := en.Values().Get(i) + if err := enter(enVal); err != nil { + return err + } + if exit != nil { + if err := exit(enVal); err != nil { + return err + } + } + } + if exit != nil { + if err := exit(en); err != nil { + return err + } + } + return nil +} + +// DescriptorProtosWithPath walks all descriptor protos in the given file using +// a depth-first traversal. This is the same as DescriptorProtos except that the +// callback function, fn, receives a protoreflect.SourcePath, that indicates the +// path for the element in the file's source code info. +func DescriptorProtosWithPath(file *descriptorpb.FileDescriptorProto, fn func(protoreflect.FullName, protoreflect.SourcePath, proto.Message) error) error { + return DescriptorProtosWithPathEnterAndExit(file, fn, nil) +} + +// DescriptorProtosWithPathEnterAndExit walks all descriptor protos in the given +// file using a depth-first traversal. This is the same as +// DescriptorProtosEnterAndExit except that the callback function, fn, receives +// a protoreflect.SourcePath, that indicates the path for the element in the +// file's source code info. +func DescriptorProtosWithPathEnterAndExit(file *descriptorpb.FileDescriptorProto, enter, exit func(protoreflect.FullName, protoreflect.SourcePath, proto.Message) error) error { + w := &protoWalker{usePath: true, enter: enter, exit: exit} + return w.walkDescriptorProtos(file) +} + +// DescriptorProtos walks all descriptor protos in the given file using a +// depth-first traversal, calling the given function for each descriptor proto +// in the hierarchy. The walk ends when traversal is complete or when the +// function returns an error. If the function returns an error, that is +// returned as the result of the walk operation. +// +// Descriptor protos are visited using a pre-order traversal, where the function +// is called for a descriptor before it is called for any of its descendants. +func DescriptorProtos(file *descriptorpb.FileDescriptorProto, fn func(protoreflect.FullName, proto.Message) error) error { + return DescriptorProtosEnterAndExit(file, fn, nil) +} + +// DescriptorProtosEnterAndExit walks all descriptor protos in the given file +// using a depth-first traversal, calling the given functions on entry and on +// exit for each descriptor in the hierarchy. The walk ends when traversal is +// complete or when a function returns an error. If a function returns an error, +// that is returned as the result of the walk operation. +// +// The enter function is called using a pre-order traversal, where the function +// is called for a descriptor proto before it is called for any of its +// descendants. The exit function is called using a post-order traversal, where +// the function is called for a descriptor proto only after it is called for any +// descendants. +func DescriptorProtosEnterAndExit(file *descriptorpb.FileDescriptorProto, enter, exit func(protoreflect.FullName, proto.Message) error) error { + enterWithPath := func(n protoreflect.FullName, p protoreflect.SourcePath, m proto.Message) error { + return enter(n, m) + } + var exitWithPath func(n protoreflect.FullName, p protoreflect.SourcePath, m proto.Message) error + if exit != nil { + exitWithPath = func(n protoreflect.FullName, p protoreflect.SourcePath, m proto.Message) error { + return exit(n, m) + } + } + w := &protoWalker{ + enter: enterWithPath, + exit: exitWithPath, + } + return w.walkDescriptorProtos(file) +} + +type protoWalker struct { + usePath bool + enter, exit func(protoreflect.FullName, protoreflect.SourcePath, proto.Message) error +} + +func (w *protoWalker) walkDescriptorProtos(file *descriptorpb.FileDescriptorProto) error { + prefix := file.GetPackage() + if prefix != "" { + prefix += "." + } + var path protoreflect.SourcePath + for i, msg := range file.MessageType { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.FileMessagesTag, int32(i)) + } + if err := w.walkDescriptorProto(prefix, p, msg); err != nil { + return err + } + } + for i, en := range file.EnumType { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.FileEnumsTag, int32(i)) + } + if err := w.walkEnumDescriptorProto(prefix, p, en); err != nil { + return err + } + } + for i, ext := range file.Extension { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.FileExtensionsTag, int32(i)) + } + fqn := prefix + ext.GetName() + if err := w.enter(protoreflect.FullName(fqn), p, ext); err != nil { + return err + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(fqn), p, ext); err != nil { + return err + } + } + } + for i, svc := range file.Service { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.FileServicesTag, int32(i)) + } + fqn := prefix + svc.GetName() + if err := w.enter(protoreflect.FullName(fqn), p, svc); err != nil { + return err + } + for j, mtd := range svc.Method { + var mp protoreflect.SourcePath + if w.usePath { + mp = p + mp = append(mp, internal.ServiceMethodsTag, int32(j)) + } + mtdFqn := fqn + "." + mtd.GetName() + if err := w.enter(protoreflect.FullName(mtdFqn), mp, mtd); err != nil { + return err + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(mtdFqn), mp, mtd); err != nil { + return err + } + } + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(fqn), p, svc); err != nil { + return err + } + } + } + return nil +} + +func (w *protoWalker) walkDescriptorProto(prefix string, path protoreflect.SourcePath, msg *descriptorpb.DescriptorProto) error { + fqn := prefix + msg.GetName() + if err := w.enter(protoreflect.FullName(fqn), path, msg); err != nil { + return err + } + prefix = fqn + "." + for i, fld := range msg.Field { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.MessageFieldsTag, int32(i)) + } + fqn := prefix + fld.GetName() + if err := w.enter(protoreflect.FullName(fqn), p, fld); err != nil { + return err + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(fqn), p, fld); err != nil { + return err + } + } + } + for i, oo := range msg.OneofDecl { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.MessageOneOfsTag, int32(i)) + } + fqn := prefix + oo.GetName() + if err := w.enter(protoreflect.FullName(fqn), p, oo); err != nil { + return err + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(fqn), p, oo); err != nil { + return err + } + } + } + for i, nested := range msg.NestedType { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.MessageNestedMessagesTag, int32(i)) + } + if err := w.walkDescriptorProto(prefix, p, nested); err != nil { + return err + } + } + for i, en := range msg.EnumType { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.MessageEnumsTag, int32(i)) + } + if err := w.walkEnumDescriptorProto(prefix, p, en); err != nil { + return err + } + } + for i, ext := range msg.Extension { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.MessageExtensionsTag, int32(i)) + } + fqn := prefix + ext.GetName() + if err := w.enter(protoreflect.FullName(fqn), p, ext); err != nil { + return err + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(fqn), p, ext); err != nil { + return err + } + } + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(fqn), path, msg); err != nil { + return err + } + } + return nil +} + +func (w *protoWalker) walkEnumDescriptorProto(prefix string, path protoreflect.SourcePath, en *descriptorpb.EnumDescriptorProto) error { + fqn := prefix + en.GetName() + if err := w.enter(protoreflect.FullName(fqn), path, en); err != nil { + return err + } + for i, val := range en.Value { + var p protoreflect.SourcePath + if w.usePath { + p = path + p = append(p, internal.EnumValuesTag, int32(i)) + } + fqn := prefix + val.GetName() + if err := w.enter(protoreflect.FullName(fqn), p, val); err != nil { + return err + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(fqn), p, val); err != nil { + return err + } + } + } + if w.exit != nil { + if err := w.exit(protoreflect.FullName(fqn), path, en); err != nil { + return err + } + } + return nil +} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go b/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go deleted file mode 100644 index 63dc0578514..00000000000 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.proto - -package descriptor - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - descriptorpb "google.golang.org/protobuf/types/descriptorpb" - reflect "reflect" -) - -// Symbols defined in public import of google/protobuf/descriptor.proto. - -type FieldDescriptorProto_Type = descriptorpb.FieldDescriptorProto_Type - -const FieldDescriptorProto_TYPE_DOUBLE = descriptorpb.FieldDescriptorProto_TYPE_DOUBLE -const FieldDescriptorProto_TYPE_FLOAT = descriptorpb.FieldDescriptorProto_TYPE_FLOAT -const FieldDescriptorProto_TYPE_INT64 = descriptorpb.FieldDescriptorProto_TYPE_INT64 -const FieldDescriptorProto_TYPE_UINT64 = descriptorpb.FieldDescriptorProto_TYPE_UINT64 -const FieldDescriptorProto_TYPE_INT32 = descriptorpb.FieldDescriptorProto_TYPE_INT32 -const FieldDescriptorProto_TYPE_FIXED64 = descriptorpb.FieldDescriptorProto_TYPE_FIXED64 -const FieldDescriptorProto_TYPE_FIXED32 = descriptorpb.FieldDescriptorProto_TYPE_FIXED32 -const FieldDescriptorProto_TYPE_BOOL = descriptorpb.FieldDescriptorProto_TYPE_BOOL -const FieldDescriptorProto_TYPE_STRING = descriptorpb.FieldDescriptorProto_TYPE_STRING -const FieldDescriptorProto_TYPE_GROUP = descriptorpb.FieldDescriptorProto_TYPE_GROUP -const FieldDescriptorProto_TYPE_MESSAGE = descriptorpb.FieldDescriptorProto_TYPE_MESSAGE -const FieldDescriptorProto_TYPE_BYTES = descriptorpb.FieldDescriptorProto_TYPE_BYTES -const FieldDescriptorProto_TYPE_UINT32 = descriptorpb.FieldDescriptorProto_TYPE_UINT32 -const FieldDescriptorProto_TYPE_ENUM = descriptorpb.FieldDescriptorProto_TYPE_ENUM -const FieldDescriptorProto_TYPE_SFIXED32 = descriptorpb.FieldDescriptorProto_TYPE_SFIXED32 -const FieldDescriptorProto_TYPE_SFIXED64 = descriptorpb.FieldDescriptorProto_TYPE_SFIXED64 -const FieldDescriptorProto_TYPE_SINT32 = descriptorpb.FieldDescriptorProto_TYPE_SINT32 -const FieldDescriptorProto_TYPE_SINT64 = descriptorpb.FieldDescriptorProto_TYPE_SINT64 - -var FieldDescriptorProto_Type_name = descriptorpb.FieldDescriptorProto_Type_name -var FieldDescriptorProto_Type_value = descriptorpb.FieldDescriptorProto_Type_value - -type FieldDescriptorProto_Label = descriptorpb.FieldDescriptorProto_Label - -const FieldDescriptorProto_LABEL_OPTIONAL = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL -const FieldDescriptorProto_LABEL_REQUIRED = descriptorpb.FieldDescriptorProto_LABEL_REQUIRED -const FieldDescriptorProto_LABEL_REPEATED = descriptorpb.FieldDescriptorProto_LABEL_REPEATED - -var FieldDescriptorProto_Label_name = descriptorpb.FieldDescriptorProto_Label_name -var FieldDescriptorProto_Label_value = descriptorpb.FieldDescriptorProto_Label_value - -type FileOptions_OptimizeMode = descriptorpb.FileOptions_OptimizeMode - -const FileOptions_SPEED = descriptorpb.FileOptions_SPEED -const FileOptions_CODE_SIZE = descriptorpb.FileOptions_CODE_SIZE -const FileOptions_LITE_RUNTIME = descriptorpb.FileOptions_LITE_RUNTIME - -var FileOptions_OptimizeMode_name = descriptorpb.FileOptions_OptimizeMode_name -var FileOptions_OptimizeMode_value = descriptorpb.FileOptions_OptimizeMode_value - -type FieldOptions_CType = descriptorpb.FieldOptions_CType - -const FieldOptions_STRING = descriptorpb.FieldOptions_STRING -const FieldOptions_CORD = descriptorpb.FieldOptions_CORD -const FieldOptions_STRING_PIECE = descriptorpb.FieldOptions_STRING_PIECE - -var FieldOptions_CType_name = descriptorpb.FieldOptions_CType_name -var FieldOptions_CType_value = descriptorpb.FieldOptions_CType_value - -type FieldOptions_JSType = descriptorpb.FieldOptions_JSType - -const FieldOptions_JS_NORMAL = descriptorpb.FieldOptions_JS_NORMAL -const FieldOptions_JS_STRING = descriptorpb.FieldOptions_JS_STRING -const FieldOptions_JS_NUMBER = descriptorpb.FieldOptions_JS_NUMBER - -var FieldOptions_JSType_name = descriptorpb.FieldOptions_JSType_name -var FieldOptions_JSType_value = descriptorpb.FieldOptions_JSType_value - -type MethodOptions_IdempotencyLevel = descriptorpb.MethodOptions_IdempotencyLevel - -const MethodOptions_IDEMPOTENCY_UNKNOWN = descriptorpb.MethodOptions_IDEMPOTENCY_UNKNOWN -const MethodOptions_NO_SIDE_EFFECTS = descriptorpb.MethodOptions_NO_SIDE_EFFECTS -const MethodOptions_IDEMPOTENT = descriptorpb.MethodOptions_IDEMPOTENT - -var MethodOptions_IdempotencyLevel_name = descriptorpb.MethodOptions_IdempotencyLevel_name -var MethodOptions_IdempotencyLevel_value = descriptorpb.MethodOptions_IdempotencyLevel_value - -type FileDescriptorSet = descriptorpb.FileDescriptorSet -type FileDescriptorProto = descriptorpb.FileDescriptorProto -type DescriptorProto = descriptorpb.DescriptorProto -type ExtensionRangeOptions = descriptorpb.ExtensionRangeOptions -type FieldDescriptorProto = descriptorpb.FieldDescriptorProto -type OneofDescriptorProto = descriptorpb.OneofDescriptorProto -type EnumDescriptorProto = descriptorpb.EnumDescriptorProto -type EnumValueDescriptorProto = descriptorpb.EnumValueDescriptorProto -type ServiceDescriptorProto = descriptorpb.ServiceDescriptorProto -type MethodDescriptorProto = descriptorpb.MethodDescriptorProto - -const Default_MethodDescriptorProto_ClientStreaming = descriptorpb.Default_MethodDescriptorProto_ClientStreaming -const Default_MethodDescriptorProto_ServerStreaming = descriptorpb.Default_MethodDescriptorProto_ServerStreaming - -type FileOptions = descriptorpb.FileOptions - -const Default_FileOptions_JavaMultipleFiles = descriptorpb.Default_FileOptions_JavaMultipleFiles -const Default_FileOptions_JavaStringCheckUtf8 = descriptorpb.Default_FileOptions_JavaStringCheckUtf8 -const Default_FileOptions_OptimizeFor = descriptorpb.Default_FileOptions_OptimizeFor -const Default_FileOptions_CcGenericServices = descriptorpb.Default_FileOptions_CcGenericServices -const Default_FileOptions_JavaGenericServices = descriptorpb.Default_FileOptions_JavaGenericServices -const Default_FileOptions_PyGenericServices = descriptorpb.Default_FileOptions_PyGenericServices -const Default_FileOptions_PhpGenericServices = descriptorpb.Default_FileOptions_PhpGenericServices -const Default_FileOptions_Deprecated = descriptorpb.Default_FileOptions_Deprecated -const Default_FileOptions_CcEnableArenas = descriptorpb.Default_FileOptions_CcEnableArenas - -type MessageOptions = descriptorpb.MessageOptions - -const Default_MessageOptions_MessageSetWireFormat = descriptorpb.Default_MessageOptions_MessageSetWireFormat -const Default_MessageOptions_NoStandardDescriptorAccessor = descriptorpb.Default_MessageOptions_NoStandardDescriptorAccessor -const Default_MessageOptions_Deprecated = descriptorpb.Default_MessageOptions_Deprecated - -type FieldOptions = descriptorpb.FieldOptions - -const Default_FieldOptions_Ctype = descriptorpb.Default_FieldOptions_Ctype -const Default_FieldOptions_Jstype = descriptorpb.Default_FieldOptions_Jstype -const Default_FieldOptions_Lazy = descriptorpb.Default_FieldOptions_Lazy -const Default_FieldOptions_Deprecated = descriptorpb.Default_FieldOptions_Deprecated -const Default_FieldOptions_Weak = descriptorpb.Default_FieldOptions_Weak - -type OneofOptions = descriptorpb.OneofOptions -type EnumOptions = descriptorpb.EnumOptions - -const Default_EnumOptions_Deprecated = descriptorpb.Default_EnumOptions_Deprecated - -type EnumValueOptions = descriptorpb.EnumValueOptions - -const Default_EnumValueOptions_Deprecated = descriptorpb.Default_EnumValueOptions_Deprecated - -type ServiceOptions = descriptorpb.ServiceOptions - -const Default_ServiceOptions_Deprecated = descriptorpb.Default_ServiceOptions_Deprecated - -type MethodOptions = descriptorpb.MethodOptions - -const Default_MethodOptions_Deprecated = descriptorpb.Default_MethodOptions_Deprecated -const Default_MethodOptions_IdempotencyLevel = descriptorpb.Default_MethodOptions_IdempotencyLevel - -type UninterpretedOption = descriptorpb.UninterpretedOption -type SourceCodeInfo = descriptorpb.SourceCodeInfo -type GeneratedCodeInfo = descriptorpb.GeneratedCodeInfo -type DescriptorProto_ExtensionRange = descriptorpb.DescriptorProto_ExtensionRange -type DescriptorProto_ReservedRange = descriptorpb.DescriptorProto_ReservedRange -type EnumDescriptorProto_EnumReservedRange = descriptorpb.EnumDescriptorProto_EnumReservedRange -type UninterpretedOption_NamePart = descriptorpb.UninterpretedOption_NamePart -type SourceCodeInfo_Location = descriptorpb.SourceCodeInfo_Location -type GeneratedCodeInfo_Annotation = descriptorpb.GeneratedCodeInfo_Annotation - -var File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto protoreflect.FileDescriptor - -var file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc = []byte{ - 0x0a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, - 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, - 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x3b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x32, -} - -var file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes = []interface{}{} -var file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_init() } -func file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_init() { - if File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc, - NumEnums: 0, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes, - DependencyIndexes: file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs, - }.Build() - File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto = out.File - file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc = nil - file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes = nil - file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs = nil -} diff --git a/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go b/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go deleted file mode 100644 index b7b4a2f9454..00000000000 --- a/vendor/github.com/golang/protobuf/protoc-gen-go/plugin/plugin.pb.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: github.com/golang/protobuf/protoc-gen-go/plugin/plugin.proto - -package plugin_go - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - pluginpb "google.golang.org/protobuf/types/pluginpb" - reflect "reflect" -) - -// Symbols defined in public import of google/protobuf/compiler/plugin.proto. - -type CodeGeneratorResponse_Feature = pluginpb.CodeGeneratorResponse_Feature - -const CodeGeneratorResponse_FEATURE_NONE = pluginpb.CodeGeneratorResponse_FEATURE_NONE -const CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL = pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL - -var CodeGeneratorResponse_Feature_name = pluginpb.CodeGeneratorResponse_Feature_name -var CodeGeneratorResponse_Feature_value = pluginpb.CodeGeneratorResponse_Feature_value - -type Version = pluginpb.Version -type CodeGeneratorRequest = pluginpb.CodeGeneratorRequest -type CodeGeneratorResponse = pluginpb.CodeGeneratorResponse -type CodeGeneratorResponse_File = pluginpb.CodeGeneratorResponse_File - -var File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto protoreflect.FileDescriptor - -var file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc = []byte{ - 0x0a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, - 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, - 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, - 0x6f, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x3b, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, - 0x67, 0x6f, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, -} - -var file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_goTypes = []interface{}{} -var file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_init() } -func file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_init() { - if File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc, - NumEnums: 0, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_goTypes, - DependencyIndexes: file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_depIdxs, - }.Build() - File_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto = out.File - file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_rawDesc = nil - file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_goTypes = nil - file_github_com_golang_protobuf_protoc_gen_go_plugin_plugin_proto_depIdxs = nil -} diff --git a/vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go b/vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go deleted file mode 100644 index 16686a65523..00000000000 --- a/vendor/github.com/golang/protobuf/ptypes/empty/empty.pb.go +++ /dev/null @@ -1,62 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: github.com/golang/protobuf/ptypes/empty/empty.proto - -package empty - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" - reflect "reflect" -) - -// Symbols defined in public import of google/protobuf/empty.proto. - -type Empty = emptypb.Empty - -var File_github_com_golang_protobuf_ptypes_empty_empty_proto protoreflect.FileDescriptor - -var file_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc = []byte{ - 0x0a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, - 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x3b, 0x65, 0x6d, - 0x70, 0x74, 0x79, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var file_github_com_golang_protobuf_ptypes_empty_empty_proto_goTypes = []interface{}{} -var file_github_com_golang_protobuf_ptypes_empty_empty_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_github_com_golang_protobuf_ptypes_empty_empty_proto_init() } -func file_github_com_golang_protobuf_ptypes_empty_empty_proto_init() { - if File_github_com_golang_protobuf_ptypes_empty_empty_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc, - NumEnums: 0, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_github_com_golang_protobuf_ptypes_empty_empty_proto_goTypes, - DependencyIndexes: file_github_com_golang_protobuf_ptypes_empty_empty_proto_depIdxs, - }.Build() - File_github_com_golang_protobuf_ptypes_empty_empty_proto = out.File - file_github_com_golang_protobuf_ptypes_empty_empty_proto_rawDesc = nil - file_github_com_golang_protobuf_ptypes_empty_empty_proto_goTypes = nil - file_github_com_golang_protobuf_ptypes_empty_empty_proto_depIdxs = nil -} diff --git a/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go b/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go deleted file mode 100644 index 8d82abe2133..00000000000 --- a/vendor/github.com/golang/protobuf/ptypes/struct/struct.pb.go +++ /dev/null @@ -1,78 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: github.com/golang/protobuf/ptypes/struct/struct.proto - -package structpb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - structpb "google.golang.org/protobuf/types/known/structpb" - reflect "reflect" -) - -// Symbols defined in public import of google/protobuf/struct.proto. - -type NullValue = structpb.NullValue - -const NullValue_NULL_VALUE = structpb.NullValue_NULL_VALUE - -var NullValue_name = structpb.NullValue_name -var NullValue_value = structpb.NullValue_value - -type Struct = structpb.Struct -type Value = structpb.Value -type Value_NullValue = structpb.Value_NullValue -type Value_NumberValue = structpb.Value_NumberValue -type Value_StringValue = structpb.Value_StringValue -type Value_BoolValue = structpb.Value_BoolValue -type Value_StructValue = structpb.Value_StructValue -type Value_ListValue = structpb.Value_ListValue -type ListValue = structpb.ListValue - -var File_github_com_golang_protobuf_ptypes_struct_struct_proto protoreflect.FileDescriptor - -var file_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc = []byte{ - 0x0a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, - 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, - 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, - 0x74, 0x3b, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x70, 0x62, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} - -var file_github_com_golang_protobuf_ptypes_struct_struct_proto_goTypes = []interface{}{} -var file_github_com_golang_protobuf_ptypes_struct_struct_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_github_com_golang_protobuf_ptypes_struct_struct_proto_init() } -func file_github_com_golang_protobuf_ptypes_struct_struct_proto_init() { - if File_github_com_golang_protobuf_ptypes_struct_struct_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc, - NumEnums: 0, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_github_com_golang_protobuf_ptypes_struct_struct_proto_goTypes, - DependencyIndexes: file_github_com_golang_protobuf_ptypes_struct_struct_proto_depIdxs, - }.Build() - File_github_com_golang_protobuf_ptypes_struct_struct_proto = out.File - file_github_com_golang_protobuf_ptypes_struct_struct_proto_rawDesc = nil - file_github_com_golang_protobuf_ptypes_struct_struct_proto_goTypes = nil - file_github_com_golang_protobuf_ptypes_struct_struct_proto_depIdxs = nil -} diff --git a/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go b/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go deleted file mode 100644 index cc40f27ad30..00000000000 --- a/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: github.com/golang/protobuf/ptypes/wrappers/wrappers.proto - -package wrappers - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" - reflect "reflect" -) - -// Symbols defined in public import of google/protobuf/wrappers.proto. - -type DoubleValue = wrapperspb.DoubleValue -type FloatValue = wrapperspb.FloatValue -type Int64Value = wrapperspb.Int64Value -type UInt64Value = wrapperspb.UInt64Value -type Int32Value = wrapperspb.Int32Value -type UInt32Value = wrapperspb.UInt32Value -type BoolValue = wrapperspb.BoolValue -type StringValue = wrapperspb.StringValue -type BytesValue = wrapperspb.BytesValue - -var File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto protoreflect.FileDescriptor - -var file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc = []byte{ - 0x0a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, - 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2f, 0x77, 0x72, 0x61, - 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, - 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x35, 0x5a, 0x33, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65, 0x73, - 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x3b, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, - 0x72, 0x73, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes = []interface{}{} -var file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_init() } -func file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_init() { - if File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc, - NumEnums: 0, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes, - DependencyIndexes: file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs, - }.Build() - File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto = out.File - file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc = nil - file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes = nil - file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs = nil -} diff --git a/vendor/github.com/jhump/protoreflect/codec/codec.go b/vendor/github.com/jhump/protoreflect/codec/codec.go deleted file mode 100644 index b6f4ed092e7..00000000000 --- a/vendor/github.com/jhump/protoreflect/codec/codec.go +++ /dev/null @@ -1,217 +0,0 @@ -package codec - -import ( - "io" - - "github.com/golang/protobuf/proto" - "github.com/jhump/protoreflect/internal/codec" -) - -// ErrOverflow is returned when an integer is too large to be represented. -var ErrOverflow = codec.ErrOverflow - -// ErrBadWireType is returned when decoding a wire-type from a buffer that -// is not valid. -var ErrBadWireType = codec.ErrBadWireType - -// NB: much of the implementation is in an internal package, to avoid an import -// cycle between this codec package and the desc package. We export it from -// this package, but we can't use a type alias because we also need to add -// methods to it, to broaden the exposed API. - -// Buffer is a reader and a writer that wraps a slice of bytes and also -// provides API for decoding and encoding the protobuf binary format. -// -// Its operation is similar to that of a bytes.Buffer: writing pushes -// data to the end of the buffer while reading pops data from the head -// of the buffer. So the same buffer can be used to both read and write. -type Buffer codec.Buffer - -// NewBuffer creates a new buffer with the given slice of bytes as the -// buffer's initial contents. -func NewBuffer(buf []byte) *Buffer { - return (*Buffer)(codec.NewBuffer(buf)) -} - -// SetDeterministic sets this buffer to encode messages deterministically. This -// is useful for tests. But the overhead is non-zero, so it should not likely be -// used outside of tests. When true, map fields in a message must have their -// keys sorted before serialization to ensure deterministic output. Otherwise, -// values in a map field will be serialized in map iteration order. -func (cb *Buffer) SetDeterministic(deterministic bool) { - (*codec.Buffer)(cb).SetDeterministic(deterministic) -} - -// IsDeterministic returns whether or not this buffer is configured to encode -// messages deterministically. -func (cb *Buffer) IsDeterministic() bool { - return (*codec.Buffer)(cb).IsDeterministic() -} - -// Reset resets this buffer back to empty. Any subsequent writes/encodes -// to the buffer will allocate a new backing slice of bytes. -func (cb *Buffer) Reset() { - (*codec.Buffer)(cb).Reset() -} - -// Bytes returns the slice of bytes remaining in the buffer. Note that -// this does not perform a copy: if the contents of the returned slice -// are modified, the modifications will be visible to subsequent reads -// via the buffer. -func (cb *Buffer) Bytes() []byte { - return (*codec.Buffer)(cb).Bytes() -} - -// String returns the remaining bytes in the buffer as a string. -func (cb *Buffer) String() string { - return (*codec.Buffer)(cb).String() -} - -// EOF returns true if there are no more bytes remaining to read. -func (cb *Buffer) EOF() bool { - return (*codec.Buffer)(cb).EOF() -} - -// Skip attempts to skip the given number of bytes in the input. If -// the input has fewer bytes than the given count, io.ErrUnexpectedEOF -// is returned and the buffer is unchanged. Otherwise, the given number -// of bytes are skipped and nil is returned. -func (cb *Buffer) Skip(count int) error { - return (*codec.Buffer)(cb).Skip(count) - -} - -// Len returns the remaining number of bytes in the buffer. -func (cb *Buffer) Len() int { - return (*codec.Buffer)(cb).Len() -} - -// Read implements the io.Reader interface. If there are no bytes -// remaining in the buffer, it will return 0, io.EOF. Otherwise, -// it reads max(len(dest), cb.Len()) bytes from input and copies -// them into dest. It returns the number of bytes copied and a nil -// error in this case. -func (cb *Buffer) Read(dest []byte) (int, error) { - return (*codec.Buffer)(cb).Read(dest) -} - -var _ io.Reader = (*Buffer)(nil) - -// Write implements the io.Writer interface. It always returns -// len(data), nil. -func (cb *Buffer) Write(data []byte) (int, error) { - return (*codec.Buffer)(cb).Write(data) -} - -var _ io.Writer = (*Buffer)(nil) - -// DecodeVarint reads a varint-encoded integer from the Buffer. -// This is the format for the -// int32, int64, uint32, uint64, bool, and enum -// protocol buffer types. -func (cb *Buffer) DecodeVarint() (uint64, error) { - return (*codec.Buffer)(cb).DecodeVarint() -} - -// DecodeTagAndWireType decodes a field tag and wire type from input. -// This reads a varint and then extracts the two fields from the varint -// value read. -func (cb *Buffer) DecodeTagAndWireType() (tag int32, wireType int8, err error) { - return (*codec.Buffer)(cb).DecodeTagAndWireType() -} - -// DecodeFixed64 reads a 64-bit integer from the Buffer. -// This is the format for the -// fixed64, sfixed64, and double protocol buffer types. -func (cb *Buffer) DecodeFixed64() (x uint64, err error) { - return (*codec.Buffer)(cb).DecodeFixed64() -} - -// DecodeFixed32 reads a 32-bit integer from the Buffer. -// This is the format for the -// fixed32, sfixed32, and float protocol buffer types. -func (cb *Buffer) DecodeFixed32() (x uint64, err error) { - return (*codec.Buffer)(cb).DecodeFixed32() -} - -// DecodeRawBytes reads a count-delimited byte buffer from the Buffer. -// This is the format used for the bytes protocol buffer -// type and for embedded messages. -func (cb *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) { - return (*codec.Buffer)(cb).DecodeRawBytes(alloc) -} - -// ReadGroup reads the input until a "group end" tag is found -// and returns the data up to that point. Subsequent reads from -// the buffer will read data after the group end tag. If alloc -// is true, the data is copied to a new slice before being returned. -// Otherwise, the returned slice is a view into the buffer's -// underlying byte slice. -// -// This function correctly handles nested groups: if a "group start" -// tag is found, then that group's end tag will be included in the -// returned data. -func (cb *Buffer) ReadGroup(alloc bool) ([]byte, error) { - return (*codec.Buffer)(cb).ReadGroup(alloc) -} - -// SkipGroup is like ReadGroup, except that it discards the -// data and just advances the buffer to point to the input -// right *after* the "group end" tag. -func (cb *Buffer) SkipGroup() error { - return (*codec.Buffer)(cb).SkipGroup() -} - -// SkipField attempts to skip the value of a field with the given wire -// type. When consuming a protobuf-encoded stream, it can be called immediately -// after DecodeTagAndWireType to discard the subsequent data for the field. -func (cb *Buffer) SkipField(wireType int8) error { - return (*codec.Buffer)(cb).SkipField(wireType) -} - -// EncodeVarint writes a varint-encoded integer to the Buffer. -// This is the format for the -// int32, int64, uint32, uint64, bool, and enum -// protocol buffer types. -func (cb *Buffer) EncodeVarint(x uint64) error { - return (*codec.Buffer)(cb).EncodeVarint(x) -} - -// EncodeTagAndWireType encodes the given field tag and wire type to the -// buffer. This combines the two values and then writes them as a varint. -func (cb *Buffer) EncodeTagAndWireType(tag int32, wireType int8) error { - return (*codec.Buffer)(cb).EncodeTagAndWireType(tag, wireType) -} - -// EncodeFixed64 writes a 64-bit integer to the Buffer. -// This is the format for the -// fixed64, sfixed64, and double protocol buffer types. -func (cb *Buffer) EncodeFixed64(x uint64) error { - return (*codec.Buffer)(cb).EncodeFixed64(x) - -} - -// EncodeFixed32 writes a 32-bit integer to the Buffer. -// This is the format for the -// fixed32, sfixed32, and float protocol buffer types. -func (cb *Buffer) EncodeFixed32(x uint64) error { - return (*codec.Buffer)(cb).EncodeFixed32(x) -} - -// EncodeRawBytes writes a count-delimited byte buffer to the Buffer. -// This is the format used for the bytes protocol buffer -// type and for embedded messages. -func (cb *Buffer) EncodeRawBytes(b []byte) error { - return (*codec.Buffer)(cb).EncodeRawBytes(b) -} - -// EncodeMessage writes the given message to the buffer. -func (cb *Buffer) EncodeMessage(pm proto.Message) error { - return (*codec.Buffer)(cb).EncodeMessage(pm) -} - -// EncodeDelimitedMessage writes the given message to the buffer with a -// varint-encoded length prefix (the delimiter). -func (cb *Buffer) EncodeDelimitedMessage(pm proto.Message) error { - return (*codec.Buffer)(cb).EncodeDelimitedMessage(pm) -} diff --git a/vendor/github.com/jhump/protoreflect/codec/decode_fields.go b/vendor/github.com/jhump/protoreflect/codec/decode_fields.go deleted file mode 100644 index 02f8a321fd9..00000000000 --- a/vendor/github.com/jhump/protoreflect/codec/decode_fields.go +++ /dev/null @@ -1,318 +0,0 @@ -package codec - -import ( - "errors" - "fmt" - "io" - "math" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/descriptor" - - "github.com/jhump/protoreflect/desc" -) - -var varintTypes = map[descriptor.FieldDescriptorProto_Type]bool{} -var fixed32Types = map[descriptor.FieldDescriptorProto_Type]bool{} -var fixed64Types = map[descriptor.FieldDescriptorProto_Type]bool{} - -func init() { - varintTypes[descriptor.FieldDescriptorProto_TYPE_BOOL] = true - varintTypes[descriptor.FieldDescriptorProto_TYPE_INT32] = true - varintTypes[descriptor.FieldDescriptorProto_TYPE_INT64] = true - varintTypes[descriptor.FieldDescriptorProto_TYPE_UINT32] = true - varintTypes[descriptor.FieldDescriptorProto_TYPE_UINT64] = true - varintTypes[descriptor.FieldDescriptorProto_TYPE_SINT32] = true - varintTypes[descriptor.FieldDescriptorProto_TYPE_SINT64] = true - varintTypes[descriptor.FieldDescriptorProto_TYPE_ENUM] = true - - fixed32Types[descriptor.FieldDescriptorProto_TYPE_FIXED32] = true - fixed32Types[descriptor.FieldDescriptorProto_TYPE_SFIXED32] = true - fixed32Types[descriptor.FieldDescriptorProto_TYPE_FLOAT] = true - - fixed64Types[descriptor.FieldDescriptorProto_TYPE_FIXED64] = true - fixed64Types[descriptor.FieldDescriptorProto_TYPE_SFIXED64] = true - fixed64Types[descriptor.FieldDescriptorProto_TYPE_DOUBLE] = true -} - -// ErrWireTypeEndGroup is returned from DecodeFieldValue if the tag and wire-type -// it reads indicates an end-group marker. -var ErrWireTypeEndGroup = errors.New("unexpected wire type: end group") - -// MessageFactory is used to instantiate messages when DecodeFieldValue needs to -// decode a message value. -// -// Also see MessageFactory in "github.com/jhump/protoreflect/dynamic", which -// implements this interface. -type MessageFactory interface { - NewMessage(md *desc.MessageDescriptor) proto.Message -} - -// UnknownField represents a field that was parsed from the binary wire -// format for a message, but was not a recognized field number. Enough -// information is preserved so that re-serializing the message won't lose -// any of the unrecognized data. -type UnknownField struct { - // The tag number for the unrecognized field. - Tag int32 - - // Encoding indicates how the unknown field was encoded on the wire. If it - // is proto.WireBytes or proto.WireGroupStart then Contents will be set to - // the raw bytes. If it is proto.WireTypeFixed32 then the data is in the least - // significant 32 bits of Value. Otherwise, the data is in all 64 bits of - // Value. - Encoding int8 - Contents []byte - Value uint64 -} - -// DecodeZigZag32 decodes a signed 32-bit integer from the given -// zig-zag encoded value. -func DecodeZigZag32(v uint64) int32 { - return int32((uint32(v) >> 1) ^ uint32((int32(v&1)<<31)>>31)) -} - -// DecodeZigZag64 decodes a signed 64-bit integer from the given -// zig-zag encoded value. -func DecodeZigZag64(v uint64) int64 { - return int64((v >> 1) ^ uint64((int64(v&1)<<63)>>63)) -} - -// DecodeFieldValue will read a field value from the buffer and return its -// value and the corresponding field descriptor. The given function is used -// to lookup a field descriptor by tag number. The given factory is used to -// instantiate a message if the field value is (or contains) a message value. -// -// On error, the field descriptor and value are typically nil. However, if the -// error returned is ErrWireTypeEndGroup, the returned value will indicate any -// tag number encoded in the end-group marker. -// -// If the field descriptor returned is nil, that means that the given function -// returned nil. This is expected to happen for unrecognized tag numbers. In -// that case, no error is returned, and the value will be an UnknownField. -func (cb *Buffer) DecodeFieldValue(fieldFinder func(int32) *desc.FieldDescriptor, fact MessageFactory) (*desc.FieldDescriptor, interface{}, error) { - if cb.EOF() { - return nil, nil, io.EOF - } - tagNumber, wireType, err := cb.DecodeTagAndWireType() - if err != nil { - return nil, nil, err - } - if wireType == proto.WireEndGroup { - return nil, tagNumber, ErrWireTypeEndGroup - } - fd := fieldFinder(tagNumber) - if fd == nil { - val, err := cb.decodeUnknownField(tagNumber, wireType) - return nil, val, err - } - val, err := cb.decodeKnownField(fd, wireType, fact) - return fd, val, err -} - -// DecodeScalarField extracts a properly-typed value from v. The returned value's -// type depends on the given field descriptor type. It will be the same type as -// generated structs use for the field descriptor's type. Enum types will return -// an int32. If the given field type uses length-delimited encoding (nested -// messages, bytes, and strings), an error is returned. -func DecodeScalarField(fd *desc.FieldDescriptor, v uint64) (interface{}, error) { - switch fd.GetType() { - case descriptor.FieldDescriptorProto_TYPE_BOOL: - return v != 0, nil - case descriptor.FieldDescriptorProto_TYPE_UINT32, - descriptor.FieldDescriptorProto_TYPE_FIXED32: - if v > math.MaxUint32 { - return nil, ErrOverflow - } - return uint32(v), nil - - case descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_ENUM: - s := int64(v) - if s > math.MaxInt32 || s < math.MinInt32 { - return nil, ErrOverflow - } - return int32(s), nil - - case descriptor.FieldDescriptorProto_TYPE_SFIXED32: - if v > math.MaxUint32 { - return nil, ErrOverflow - } - return int32(v), nil - - case descriptor.FieldDescriptorProto_TYPE_SINT32: - if v > math.MaxUint32 { - return nil, ErrOverflow - } - return DecodeZigZag32(v), nil - - case descriptor.FieldDescriptorProto_TYPE_UINT64, - descriptor.FieldDescriptorProto_TYPE_FIXED64: - return v, nil - - case descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_SFIXED64: - return int64(v), nil - - case descriptor.FieldDescriptorProto_TYPE_SINT64: - return DecodeZigZag64(v), nil - - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - if v > math.MaxUint32 { - return nil, ErrOverflow - } - return math.Float32frombits(uint32(v)), nil - - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - return math.Float64frombits(v), nil - - default: - // bytes, string, message, and group cannot be represented as a simple numeric value - return nil, fmt.Errorf("bad input; field %s requires length-delimited wire type", fd.GetFullyQualifiedName()) - } -} - -// DecodeLengthDelimitedField extracts a properly-typed value from bytes. The -// returned value's type will usually be []byte, string, or, for nested messages, -// the type returned from the given message factory. However, since repeated -// scalar fields can be length-delimited, when they used packed encoding, it can -// also return an []interface{}, where each element is a scalar value. Furthermore, -// it could return a scalar type, not in a slice, if the given field descriptor is -// not repeated. This is to support cases where a field is changed from optional -// to repeated. New code may emit a packed repeated representation, but old code -// still expects a single scalar value. In this case, if the actual data in bytes -// contains multiple values, only the last value is returned. -func DecodeLengthDelimitedField(fd *desc.FieldDescriptor, bytes []byte, mf MessageFactory) (interface{}, error) { - switch { - case fd.GetType() == descriptor.FieldDescriptorProto_TYPE_BYTES: - return bytes, nil - - case fd.GetType() == descriptor.FieldDescriptorProto_TYPE_STRING: - return string(bytes), nil - - case fd.GetType() == descriptor.FieldDescriptorProto_TYPE_MESSAGE || - fd.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP: - msg := mf.NewMessage(fd.GetMessageType()) - err := proto.Unmarshal(bytes, msg) - if err != nil { - return nil, err - } else { - return msg, nil - } - - default: - // even if the field is not repeated or not packed, we still parse it as such for - // backwards compatibility (e.g. message we are de-serializing could have been both - // repeated and packed at the time of serialization) - packedBuf := NewBuffer(bytes) - var slice []interface{} - var val interface{} - for !packedBuf.EOF() { - var v uint64 - var err error - if varintTypes[fd.GetType()] { - v, err = packedBuf.DecodeVarint() - } else if fixed32Types[fd.GetType()] { - v, err = packedBuf.DecodeFixed32() - } else if fixed64Types[fd.GetType()] { - v, err = packedBuf.DecodeFixed64() - } else { - return nil, fmt.Errorf("bad input; cannot parse length-delimited wire type for field %s", fd.GetFullyQualifiedName()) - } - if err != nil { - return nil, err - } - val, err = DecodeScalarField(fd, v) - if err != nil { - return nil, err - } - if fd.IsRepeated() { - slice = append(slice, val) - } - } - if fd.IsRepeated() { - return slice, nil - } else { - // if not a repeated field, last value wins - return val, nil - } - } -} - -func (b *Buffer) decodeKnownField(fd *desc.FieldDescriptor, encoding int8, fact MessageFactory) (interface{}, error) { - var val interface{} - var err error - switch encoding { - case proto.WireFixed32: - var num uint64 - num, err = b.DecodeFixed32() - if err == nil { - val, err = DecodeScalarField(fd, num) - } - case proto.WireFixed64: - var num uint64 - num, err = b.DecodeFixed64() - if err == nil { - val, err = DecodeScalarField(fd, num) - } - case proto.WireVarint: - var num uint64 - num, err = b.DecodeVarint() - if err == nil { - val, err = DecodeScalarField(fd, num) - } - - case proto.WireBytes: - alloc := fd.GetType() == descriptor.FieldDescriptorProto_TYPE_BYTES - var raw []byte - raw, err = b.DecodeRawBytes(alloc) - if err == nil { - val, err = DecodeLengthDelimitedField(fd, raw, fact) - } - - case proto.WireStartGroup: - if fd.GetMessageType() == nil { - return nil, fmt.Errorf("cannot parse field %s from group-encoded wire type", fd.GetFullyQualifiedName()) - } - msg := fact.NewMessage(fd.GetMessageType()) - var data []byte - data, err = b.ReadGroup(false) - if err == nil { - err = proto.Unmarshal(data, msg) - if err == nil { - val = msg - } - } - - default: - return nil, ErrBadWireType - } - if err != nil { - return nil, err - } - - return val, nil -} - -func (b *Buffer) decodeUnknownField(tagNumber int32, encoding int8) (interface{}, error) { - u := UnknownField{Tag: tagNumber, Encoding: encoding} - var err error - switch encoding { - case proto.WireFixed32: - u.Value, err = b.DecodeFixed32() - case proto.WireFixed64: - u.Value, err = b.DecodeFixed64() - case proto.WireVarint: - u.Value, err = b.DecodeVarint() - case proto.WireBytes: - u.Contents, err = b.DecodeRawBytes(true) - case proto.WireStartGroup: - u.Contents, err = b.ReadGroup(true) - default: - err = ErrBadWireType - } - if err != nil { - return nil, err - } - return u, nil -} diff --git a/vendor/github.com/jhump/protoreflect/codec/doc.go b/vendor/github.com/jhump/protoreflect/codec/doc.go deleted file mode 100644 index f76499f6733..00000000000 --- a/vendor/github.com/jhump/protoreflect/codec/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package codec contains a reader/write type that assists with encoding -// and decoding protobuf's binary representation. -// -// The code in this package began as a fork of proto.Buffer but provides -// additional API to make it more useful to code that needs to dynamically -// process or produce the protobuf binary format. -package codec diff --git a/vendor/github.com/jhump/protoreflect/codec/encode_fields.go b/vendor/github.com/jhump/protoreflect/codec/encode_fields.go deleted file mode 100644 index 499aa9564a1..00000000000 --- a/vendor/github.com/jhump/protoreflect/codec/encode_fields.go +++ /dev/null @@ -1,288 +0,0 @@ -package codec - -import ( - "fmt" - "math" - "reflect" - "sort" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/descriptor" - - "github.com/jhump/protoreflect/desc" -) - -// EncodeZigZag64 does zig-zag encoding to convert the given -// signed 64-bit integer into a form that can be expressed -// efficiently as a varint, even for negative values. -func EncodeZigZag64(v int64) uint64 { - return (uint64(v) << 1) ^ uint64(v>>63) -} - -// EncodeZigZag32 does zig-zag encoding to convert the given -// signed 32-bit integer into a form that can be expressed -// efficiently as a varint, even for negative values. -func EncodeZigZag32(v int32) uint64 { - return uint64((uint32(v) << 1) ^ uint32((v >> 31))) -} - -func (cb *Buffer) EncodeFieldValue(fd *desc.FieldDescriptor, val interface{}) error { - if fd.IsMap() { - mp := val.(map[interface{}]interface{}) - entryType := fd.GetMessageType() - keyType := entryType.FindFieldByNumber(1) - valType := entryType.FindFieldByNumber(2) - var entryBuffer Buffer - if cb.IsDeterministic() { - entryBuffer.SetDeterministic(true) - keys := make([]interface{}, 0, len(mp)) - for k := range mp { - keys = append(keys, k) - } - sort.Sort(sortable(keys)) - for _, k := range keys { - v := mp[k] - entryBuffer.Reset() - if err := entryBuffer.encodeFieldElement(keyType, k); err != nil { - return err - } - rv := reflect.ValueOf(v) - if rv.Kind() != reflect.Ptr || !rv.IsNil() { - if err := entryBuffer.encodeFieldElement(valType, v); err != nil { - return err - } - } - if err := cb.EncodeTagAndWireType(fd.GetNumber(), proto.WireBytes); err != nil { - return err - } - if err := cb.EncodeRawBytes(entryBuffer.Bytes()); err != nil { - return err - } - } - } else { - for k, v := range mp { - entryBuffer.Reset() - if err := entryBuffer.encodeFieldElement(keyType, k); err != nil { - return err - } - rv := reflect.ValueOf(v) - if rv.Kind() != reflect.Ptr || !rv.IsNil() { - if err := entryBuffer.encodeFieldElement(valType, v); err != nil { - return err - } - } - if err := cb.EncodeTagAndWireType(fd.GetNumber(), proto.WireBytes); err != nil { - return err - } - if err := cb.EncodeRawBytes(entryBuffer.Bytes()); err != nil { - return err - } - } - } - return nil - } else if fd.IsRepeated() { - sl := val.([]interface{}) - wt, err := getWireType(fd.GetType()) - if err != nil { - return err - } - if isPacked(fd) && len(sl) > 0 && - (wt == proto.WireVarint || wt == proto.WireFixed32 || wt == proto.WireFixed64) { - // packed repeated field - var packedBuffer Buffer - for _, v := range sl { - if err := packedBuffer.encodeFieldValue(fd, v); err != nil { - return err - } - } - if err := cb.EncodeTagAndWireType(fd.GetNumber(), proto.WireBytes); err != nil { - return err - } - return cb.EncodeRawBytes(packedBuffer.Bytes()) - } else { - // non-packed repeated field - for _, v := range sl { - if err := cb.encodeFieldElement(fd, v); err != nil { - return err - } - } - return nil - } - } else { - return cb.encodeFieldElement(fd, val) - } -} - -func isPacked(fd *desc.FieldDescriptor) bool { - opts := fd.AsFieldDescriptorProto().GetOptions() - // if set, use that value - if opts != nil && opts.Packed != nil { - return opts.GetPacked() - } - // if unset: proto2 defaults to false, proto3 to true - return fd.GetFile().IsProto3() -} - -// sortable is used to sort map keys. Values will be integers (int32, int64, uint32, and uint64), -// bools, or strings. -type sortable []interface{} - -func (s sortable) Len() int { - return len(s) -} - -func (s sortable) Less(i, j int) bool { - vi := s[i] - vj := s[j] - switch reflect.TypeOf(vi).Kind() { - case reflect.Int32: - return vi.(int32) < vj.(int32) - case reflect.Int64: - return vi.(int64) < vj.(int64) - case reflect.Uint32: - return vi.(uint32) < vj.(uint32) - case reflect.Uint64: - return vi.(uint64) < vj.(uint64) - case reflect.String: - return vi.(string) < vj.(string) - case reflect.Bool: - return !vi.(bool) && vj.(bool) - default: - panic(fmt.Sprintf("cannot compare keys of type %v", reflect.TypeOf(vi))) - } -} - -func (s sortable) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -func (b *Buffer) encodeFieldElement(fd *desc.FieldDescriptor, val interface{}) error { - wt, err := getWireType(fd.GetType()) - if err != nil { - return err - } - if err := b.EncodeTagAndWireType(fd.GetNumber(), wt); err != nil { - return err - } - if err := b.encodeFieldValue(fd, val); err != nil { - return err - } - if wt == proto.WireStartGroup { - return b.EncodeTagAndWireType(fd.GetNumber(), proto.WireEndGroup) - } - return nil -} - -func (b *Buffer) encodeFieldValue(fd *desc.FieldDescriptor, val interface{}) error { - switch fd.GetType() { - case descriptor.FieldDescriptorProto_TYPE_BOOL: - v := val.(bool) - if v { - return b.EncodeVarint(1) - } - return b.EncodeVarint(0) - - case descriptor.FieldDescriptorProto_TYPE_ENUM, - descriptor.FieldDescriptorProto_TYPE_INT32: - v := val.(int32) - return b.EncodeVarint(uint64(v)) - - case descriptor.FieldDescriptorProto_TYPE_SFIXED32: - v := val.(int32) - return b.EncodeFixed32(uint64(v)) - - case descriptor.FieldDescriptorProto_TYPE_SINT32: - v := val.(int32) - return b.EncodeVarint(EncodeZigZag32(v)) - - case descriptor.FieldDescriptorProto_TYPE_UINT32: - v := val.(uint32) - return b.EncodeVarint(uint64(v)) - - case descriptor.FieldDescriptorProto_TYPE_FIXED32: - v := val.(uint32) - return b.EncodeFixed32(uint64(v)) - - case descriptor.FieldDescriptorProto_TYPE_INT64: - v := val.(int64) - return b.EncodeVarint(uint64(v)) - - case descriptor.FieldDescriptorProto_TYPE_SFIXED64: - v := val.(int64) - return b.EncodeFixed64(uint64(v)) - - case descriptor.FieldDescriptorProto_TYPE_SINT64: - v := val.(int64) - return b.EncodeVarint(EncodeZigZag64(v)) - - case descriptor.FieldDescriptorProto_TYPE_UINT64: - v := val.(uint64) - return b.EncodeVarint(v) - - case descriptor.FieldDescriptorProto_TYPE_FIXED64: - v := val.(uint64) - return b.EncodeFixed64(v) - - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - v := val.(float64) - return b.EncodeFixed64(math.Float64bits(v)) - - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - v := val.(float32) - return b.EncodeFixed32(uint64(math.Float32bits(v))) - - case descriptor.FieldDescriptorProto_TYPE_BYTES: - v := val.([]byte) - return b.EncodeRawBytes(v) - - case descriptor.FieldDescriptorProto_TYPE_STRING: - v := val.(string) - return b.EncodeRawBytes(([]byte)(v)) - - case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - return b.EncodeDelimitedMessage(val.(proto.Message)) - - case descriptor.FieldDescriptorProto_TYPE_GROUP: - // just append the nested message to this buffer - return b.EncodeMessage(val.(proto.Message)) - // whosoever writeth start-group tag (e.g. caller) is responsible for writing end-group tag - - default: - return fmt.Errorf("unrecognized field type: %v", fd.GetType()) - } -} - -func getWireType(t descriptor.FieldDescriptorProto_Type) (int8, error) { - switch t { - case descriptor.FieldDescriptorProto_TYPE_ENUM, - descriptor.FieldDescriptorProto_TYPE_BOOL, - descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_SINT32, - descriptor.FieldDescriptorProto_TYPE_UINT32, - descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_SINT64, - descriptor.FieldDescriptorProto_TYPE_UINT64: - return proto.WireVarint, nil - - case descriptor.FieldDescriptorProto_TYPE_FIXED32, - descriptor.FieldDescriptorProto_TYPE_SFIXED32, - descriptor.FieldDescriptorProto_TYPE_FLOAT: - return proto.WireFixed32, nil - - case descriptor.FieldDescriptorProto_TYPE_FIXED64, - descriptor.FieldDescriptorProto_TYPE_SFIXED64, - descriptor.FieldDescriptorProto_TYPE_DOUBLE: - return proto.WireFixed64, nil - - case descriptor.FieldDescriptorProto_TYPE_BYTES, - descriptor.FieldDescriptorProto_TYPE_STRING, - descriptor.FieldDescriptorProto_TYPE_MESSAGE: - return proto.WireBytes, nil - - case descriptor.FieldDescriptorProto_TYPE_GROUP: - return proto.WireStartGroup, nil - - default: - return 0, ErrBadWireType - } -} diff --git a/vendor/github.com/jhump/protoreflect/desc/cache.go b/vendor/github.com/jhump/protoreflect/desc/cache.go new file mode 100644 index 00000000000..e67cf494e10 --- /dev/null +++ b/vendor/github.com/jhump/protoreflect/desc/cache.go @@ -0,0 +1,57 @@ +package desc + +import ( + "sync" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +type descriptorCache interface { + get(protoreflect.Descriptor) Descriptor + put(protoreflect.Descriptor, Descriptor) +} + +type lockingCache struct { + cacheMu sync.RWMutex + cache mapCache +} + +func (c *lockingCache) get(d protoreflect.Descriptor) Descriptor { + c.cacheMu.RLock() + defer c.cacheMu.RUnlock() + return c.cache.get(d) +} + +func (c *lockingCache) put(key protoreflect.Descriptor, val Descriptor) { + c.cacheMu.Lock() + defer c.cacheMu.Unlock() + c.cache.put(key, val) +} + +func (c *lockingCache) withLock(fn func(descriptorCache)) { + c.cacheMu.Lock() + defer c.cacheMu.Unlock() + // Pass the underlying mapCache. We don't want fn to use + // c.get or c.put sine we already have the lock. So those + // methods would try to re-acquire and then deadlock! + fn(c.cache) +} + +type mapCache map[protoreflect.Descriptor]Descriptor + +func (c mapCache) get(d protoreflect.Descriptor) Descriptor { + return c[d] +} + +func (c mapCache) put(key protoreflect.Descriptor, val Descriptor) { + c[key] = val +} + +type noopCache struct{} + +func (noopCache) get(protoreflect.Descriptor) Descriptor { + return nil +} + +func (noopCache) put(protoreflect.Descriptor, Descriptor) { +} diff --git a/vendor/github.com/jhump/protoreflect/desc/convert.go b/vendor/github.com/jhump/protoreflect/desc/convert.go index 609994218be..9aa72a328ae 100644 --- a/vendor/github.com/jhump/protoreflect/desc/convert.go +++ b/vendor/github.com/jhump/protoreflect/desc/convert.go @@ -5,7 +5,10 @@ import ( "fmt" "strings" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" "github.com/jhump/protoreflect/desc/internal" intn "github.com/jhump/protoreflect/internal" @@ -15,34 +18,89 @@ import ( // The file's direct dependencies must be provided. If the given dependencies do not include // all of the file's dependencies or if the contents of the descriptors are internally // inconsistent (e.g. contain unresolvable symbols) then an error is returned. -func CreateFileDescriptor(fd *dpb.FileDescriptorProto, deps ...*FileDescriptor) (*FileDescriptor, error) { +func CreateFileDescriptor(fd *descriptorpb.FileDescriptorProto, deps ...*FileDescriptor) (*FileDescriptor, error) { return createFileDescriptor(fd, deps, nil) } -func createFileDescriptor(fd *dpb.FileDescriptorProto, deps []*FileDescriptor, r *ImportResolver) (*FileDescriptor, error) { +type descResolver struct { + files []*FileDescriptor + importResolver *ImportResolver + fromPath string +} + +func (r *descResolver) FindFileByPath(path string) (protoreflect.FileDescriptor, error) { + resolvedPath := r.importResolver.ResolveImport(r.fromPath, path) + d := r.findFileByPath(resolvedPath) + if d != nil { + return d, nil + } + if resolvedPath != path { + d := r.findFileByPath(path) + if d != nil { + return d, nil + } + } + return nil, protoregistry.NotFound +} + +func (r *descResolver) findFileByPath(path string) protoreflect.FileDescriptor { + for _, fd := range r.files { + if fd.GetName() == path { + return fd.UnwrapFile() + } + } + return nil +} + +func (r *descResolver) FindDescriptorByName(n protoreflect.FullName) (protoreflect.Descriptor, error) { + for _, fd := range r.files { + d := fd.FindSymbol(string(n)) + if d != nil { + return d.(DescriptorWrapper).Unwrap(), nil + } + } + return nil, protoregistry.NotFound +} + +func createFileDescriptor(fd *descriptorpb.FileDescriptorProto, deps []*FileDescriptor, r *ImportResolver) (*FileDescriptor, error) { + dr := &descResolver{files: deps, importResolver: r, fromPath: fd.GetName()} + d, err := protodesc.NewFile(fd, dr) + if err != nil { + return nil, err + } + + // make sure cache has dependencies populated + cache := mapCache{} + for _, dep := range deps { + fd, err := dr.FindFileByPath(dep.GetName()) + if err != nil { + return nil, err + } + cache.put(fd, dep) + } + + return convertFile(d, fd, cache) +} + +func convertFile(d protoreflect.FileDescriptor, fd *descriptorpb.FileDescriptorProto, cache descriptorCache) (*FileDescriptor, error) { ret := &FileDescriptor{ + wrapped: d, proto: fd, symbols: map[string]Descriptor{}, fieldIndex: map[string]map[int32]*FieldDescriptor{}, } - pkg := fd.GetPackage() + cache.put(d, ret) // populate references to file descriptor dependencies - files := map[string]*FileDescriptor{} - for _, f := range deps { - files[f.proto.GetName()] = f - } ret.deps = make([]*FileDescriptor, len(fd.GetDependency())) - for i, d := range fd.GetDependency() { - resolved := r.ResolveImport(fd.GetName(), d) - ret.deps[i] = files[resolved] - if ret.deps[i] == nil { - if resolved != d { - ret.deps[i] = files[d] - } - if ret.deps[i] == nil { - return nil, intn.ErrNoSuchFile(d) - } + for i := 0; i < d.Imports().Len(); i++ { + f := d.Imports().Get(i).FileDescriptor + if c := cache.get(f); c != nil { + ret.deps[i] = c.(*FileDescriptor) + } else if c, err := wrapFile(f, cache); err != nil { + return nil, err + } else { + ret.deps[i] = c } } ret.publicDeps = make([]*FileDescriptor, len(fd.GetPublicDependency())) @@ -53,27 +111,39 @@ func createFileDescriptor(fd *dpb.FileDescriptorProto, deps []*FileDescriptor, r for i, wd := range fd.GetWeakDependency() { ret.weakDeps[i] = ret.deps[wd] } - ret.isProto3 = fd.GetSyntax() == "proto3" // populate all tables of child descriptors - for _, m := range fd.GetMessageType() { - md, n := createMessageDescriptor(ret, ret, pkg, m, ret.symbols) - ret.symbols[n] = md + path := make([]int32, 1, 8) + path[0] = internal.File_messagesTag + for i := 0; i < d.Messages().Len(); i++ { + src := d.Messages().Get(i) + srcProto := fd.GetMessageType()[src.Index()] + md := createMessageDescriptor(ret, ret, src, srcProto, ret.symbols, cache, append(path, int32(i))) + ret.symbols[string(src.FullName())] = md ret.messages = append(ret.messages, md) } - for _, e := range fd.GetEnumType() { - ed, n := createEnumDescriptor(ret, ret, pkg, e, ret.symbols) - ret.symbols[n] = ed + path[0] = internal.File_enumsTag + for i := 0; i < d.Enums().Len(); i++ { + src := d.Enums().Get(i) + srcProto := fd.GetEnumType()[src.Index()] + ed := createEnumDescriptor(ret, ret, src, srcProto, ret.symbols, cache, append(path, int32(i))) + ret.symbols[string(src.FullName())] = ed ret.enums = append(ret.enums, ed) } - for _, ex := range fd.GetExtension() { - exd, n := createFieldDescriptor(ret, ret, pkg, ex) - ret.symbols[n] = exd + path[0] = internal.File_extensionsTag + for i := 0; i < d.Extensions().Len(); i++ { + src := d.Extensions().Get(i) + srcProto := fd.GetExtension()[src.Index()] + exd := createFieldDescriptor(ret, ret, src, srcProto, cache, append(path, int32(i))) + ret.symbols[string(src.FullName())] = exd ret.extensions = append(ret.extensions, exd) } - for _, s := range fd.GetService() { - sd, n := createServiceDescriptor(ret, pkg, s, ret.symbols) - ret.symbols[n] = sd + path[0] = internal.File_servicesTag + for i := 0; i < d.Services().Len(); i++ { + src := d.Services().Get(i) + srcProto := fd.GetService()[src.Index()] + sd := createServiceDescriptor(ret, src, srcProto, ret.symbols, append(path, int32(i))) + ret.symbols[string(src.FullName())] = sd ret.services = append(ret.services, sd) } @@ -81,27 +151,20 @@ func createFileDescriptor(fd *dpb.FileDescriptorProto, deps []*FileDescriptor, r ret.sourceInfoRecomputeFunc = ret.recomputeSourceInfo // now we can resolve all type references and source code info - scopes := []scope{fileScope(ret)} - path := make([]int32, 1, 8) - path[0] = internal.File_messagesTag - for i, md := range ret.messages { - if err := md.resolve(append(path, int32(i)), scopes); err != nil { + for _, md := range ret.messages { + if err := md.resolve(cache); err != nil { return nil, err } } - path[0] = internal.File_enumsTag - for i, ed := range ret.enums { - ed.resolve(append(path, int32(i))) - } path[0] = internal.File_extensionsTag - for i, exd := range ret.extensions { - if err := exd.resolve(append(path, int32(i)), scopes); err != nil { + for _, exd := range ret.extensions { + if err := exd.resolve(cache); err != nil { return nil, err } } path[0] = internal.File_servicesTag - for i, sd := range ret.services { - if err := sd.resolve(append(path, int32(i)), scopes); err != nil { + for _, sd := range ret.services { + if err := sd.resolve(cache); err != nil { return nil, err } } @@ -112,15 +175,15 @@ func createFileDescriptor(fd *dpb.FileDescriptorProto, deps []*FileDescriptor, r // CreateFileDescriptors constructs a set of descriptors, one for each of the // given descriptor protos. The given set of descriptor protos must include all // transitive dependencies for every file. -func CreateFileDescriptors(fds []*dpb.FileDescriptorProto) (map[string]*FileDescriptor, error) { +func CreateFileDescriptors(fds []*descriptorpb.FileDescriptorProto) (map[string]*FileDescriptor, error) { return createFileDescriptors(fds, nil) } -func createFileDescriptors(fds []*dpb.FileDescriptorProto, r *ImportResolver) (map[string]*FileDescriptor, error) { +func createFileDescriptors(fds []*descriptorpb.FileDescriptorProto, r *ImportResolver) (map[string]*FileDescriptor, error) { if len(fds) == 0 { return nil, nil } - files := map[string]*dpb.FileDescriptorProto{} + files := map[string]*descriptorpb.FileDescriptorProto{} resolved := map[string]*FileDescriptor{} var name string for _, fd := range fds { @@ -139,13 +202,13 @@ func createFileDescriptors(fds []*dpb.FileDescriptorProto, r *ImportResolver) (m // ToFileDescriptorSet creates a FileDescriptorSet proto that contains all of the given // file descriptors and their transitive dependencies. The files are topologically sorted // so that a file will always appear after its dependencies. -func ToFileDescriptorSet(fds ...*FileDescriptor) *dpb.FileDescriptorSet { - var fdps []*dpb.FileDescriptorProto +func ToFileDescriptorSet(fds ...*FileDescriptor) *descriptorpb.FileDescriptorSet { + var fdps []*descriptorpb.FileDescriptorProto addAllFiles(fds, &fdps, map[string]struct{}{}) - return &dpb.FileDescriptorSet{File: fdps} + return &descriptorpb.FileDescriptorSet{File: fdps} } -func addAllFiles(src []*FileDescriptor, results *[]*dpb.FileDescriptorProto, seen map[string]struct{}) { +func addAllFiles(src []*FileDescriptor, results *[]*descriptorpb.FileDescriptorProto, seen map[string]struct{}) { for _, fd := range src { if _, ok := seen[fd.GetName()]; ok { continue @@ -162,11 +225,11 @@ func addAllFiles(src []*FileDescriptor, results *[]*dpb.FileDescriptorProto, see // order used by protoc when emitting a FileDescriptorSet file with an invocation like so: // // protoc --descriptor_set_out=./test.protoset --include_imports -I. test.proto -func CreateFileDescriptorFromSet(fds *dpb.FileDescriptorSet) (*FileDescriptor, error) { +func CreateFileDescriptorFromSet(fds *descriptorpb.FileDescriptorSet) (*FileDescriptor, error) { return createFileDescriptorFromSet(fds, nil) } -func createFileDescriptorFromSet(fds *dpb.FileDescriptorSet, r *ImportResolver) (*FileDescriptor, error) { +func createFileDescriptorFromSet(fds *descriptorpb.FileDescriptorSet, r *ImportResolver) (*FileDescriptor, error) { result, err := createFileDescriptorsFromSet(fds, r) if err != nil { return nil, err @@ -183,11 +246,11 @@ func createFileDescriptorFromSet(fds *dpb.FileDescriptorSet, r *ImportResolver) // protoc when a FileDescriptorSet file with an invocation like so: // // protoc --descriptor_set_out=./test.protoset --include_imports -I. test.proto -func CreateFileDescriptorsFromSet(fds *dpb.FileDescriptorSet) (map[string]*FileDescriptor, error) { +func CreateFileDescriptorsFromSet(fds *descriptorpb.FileDescriptorSet) (map[string]*FileDescriptor, error) { return createFileDescriptorsFromSet(fds, nil) } -func createFileDescriptorsFromSet(fds *dpb.FileDescriptorSet, r *ImportResolver) (map[string]*FileDescriptor, error) { +func createFileDescriptorsFromSet(fds *descriptorpb.FileDescriptorSet, r *ImportResolver) (map[string]*FileDescriptor, error) { files := fds.GetFile() if len(files) == 0 { return nil, errors.New("file descriptor set is empty") @@ -197,7 +260,7 @@ func createFileDescriptorsFromSet(fds *dpb.FileDescriptorSet, r *ImportResolver) // createFromSet creates a descriptor for the given filename. It recursively // creates descriptors for the given file's dependencies. -func createFromSet(filename string, r *ImportResolver, seen []string, files map[string]*dpb.FileDescriptorProto, resolved map[string]*FileDescriptor) (*FileDescriptor, error) { +func createFromSet(filename string, r *ImportResolver, seen []string, files map[string]*descriptorpb.FileDescriptorProto, resolved map[string]*FileDescriptor) (*FileDescriptor, error) { for _, s := range seen { if filename == s { return nil, fmt.Errorf("cycle in imports: %s", strings.Join(append(seen, filename), " -> ")) diff --git a/vendor/github.com/jhump/protoreflect/desc/descriptor.go b/vendor/github.com/jhump/protoreflect/desc/descriptor.go index ff6910da120..6903a3ab831 100644 --- a/vendor/github.com/jhump/protoreflect/desc/descriptor.go +++ b/vendor/github.com/jhump/protoreflect/desc/descriptor.go @@ -5,12 +5,12 @@ import ( "fmt" "sort" "strconv" - "strings" "unicode" "unicode/utf8" "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" "github.com/jhump/protoreflect/desc/internal" ) @@ -40,7 +40,7 @@ type Descriptor interface { // descriptor. Source code info is optional. If no source code info is available for // the element (including if there is none at all in the file descriptor) then this // returns nil - GetSourceInfo() *dpb.SourceCodeInfo_Location + GetSourceInfo() *descriptorpb.SourceCodeInfo_Location // AsProto returns the underlying descriptor proto for this descriptor. AsProto() proto.Message } @@ -49,7 +49,8 @@ type sourceInfoRecomputeFunc = internal.SourceInfoComputeFunc // FileDescriptor describes a proto source file. type FileDescriptor struct { - proto *dpb.FileDescriptorProto + wrapped protoreflect.FileDescriptor + proto *descriptorpb.FileDescriptorProto symbols map[string]Descriptor deps []*FileDescriptor publicDeps []*FileDescriptor @@ -59,11 +60,22 @@ type FileDescriptor struct { extensions []*FieldDescriptor services []*ServiceDescriptor fieldIndex map[string]map[int32]*FieldDescriptor - isProto3 bool sourceInfo internal.SourceInfoMap sourceInfoRecomputeFunc } +// Unwrap returns the underlying protoreflect.Descriptor. Most usages will be more +// interested in UnwrapFile, which has a more specific return type. This generic +// version is present to satisfy the DescriptorWrapper interface. +func (fd *FileDescriptor) Unwrap() protoreflect.Descriptor { + return fd.wrapped +} + +// UnwrapFile returns the underlying protoreflect.FileDescriptor. +func (fd *FileDescriptor) UnwrapFile() protoreflect.FileDescriptor { + return fd.wrapped +} + func (fd *FileDescriptor) recomputeSourceInfo() { internal.PopulateSourceInfoMap(fd.proto, fd.sourceInfo) } @@ -81,18 +93,18 @@ func (fd *FileDescriptor) registerField(field *FieldDescriptor) { // to compile it, possibly including path (relative to a directory in the proto // import path). func (fd *FileDescriptor) GetName() string { - return fd.proto.GetName() + return fd.wrapped.Path() } // GetFullyQualifiedName returns the name of the file, same as GetName. It is // present to satisfy the Descriptor interface. func (fd *FileDescriptor) GetFullyQualifiedName() string { - return fd.proto.GetName() + return fd.wrapped.Path() } // GetPackage returns the name of the package declared in the file. func (fd *FileDescriptor) GetPackage() string { - return fd.proto.GetPackage() + return string(fd.wrapped.Package()) } // GetParent always returns nil: files are the root of descriptor hierarchies. @@ -115,13 +127,13 @@ func (fd *FileDescriptor) GetOptions() proto.Message { } // GetFileOptions returns the file's options. -func (fd *FileDescriptor) GetFileOptions() *dpb.FileOptions { +func (fd *FileDescriptor) GetFileOptions() *descriptorpb.FileOptions { return fd.proto.GetOptions() } // GetSourceInfo returns nil for files. It is present to satisfy the Descriptor // interface. -func (fd *FileDescriptor) GetSourceInfo() *dpb.SourceCodeInfo_Location { +func (fd *FileDescriptor) GetSourceInfo() *descriptorpb.SourceCodeInfo_Location { return nil } @@ -133,7 +145,7 @@ func (fd *FileDescriptor) AsProto() proto.Message { } // AsFileDescriptorProto returns the underlying descriptor proto. -func (fd *FileDescriptor) AsFileDescriptorProto() *dpb.FileDescriptorProto { +func (fd *FileDescriptor) AsFileDescriptorProto() *descriptorpb.FileDescriptorProto { return fd.proto } @@ -144,7 +156,7 @@ func (fd *FileDescriptor) String() string { // IsProto3 returns true if the file declares a syntax of "proto3". func (fd *FileDescriptor) IsProto3() bool { - return fd.isProto3 + return fd.wrapped.Syntax() == protoreflect.Proto3 } // GetDependencies returns all of this file's dependencies. These correspond to @@ -262,7 +274,8 @@ func (fd *FileDescriptor) FindExtensionByName(extName string) *FieldDescriptor { // MessageDescriptor describes a protocol buffer message. type MessageDescriptor struct { - proto *dpb.DescriptorProto + wrapped protoreflect.MessageDescriptor + proto *descriptorpb.DescriptorProto parent Descriptor file *FileDescriptor fields []*FieldDescriptor @@ -271,42 +284,72 @@ type MessageDescriptor struct { extensions []*FieldDescriptor oneOfs []*OneOfDescriptor extRanges extRanges - fqn string sourceInfoPath []int32 jsonNames jsonNameMap - isProto3 bool - isMapEntry bool } -func createMessageDescriptor(fd *FileDescriptor, parent Descriptor, enclosing string, md *dpb.DescriptorProto, symbols map[string]Descriptor) (*MessageDescriptor, string) { - msgName := merge(enclosing, md.GetName()) - ret := &MessageDescriptor{proto: md, parent: parent, file: fd, fqn: msgName} - for _, f := range md.GetField() { - fld, n := createFieldDescriptor(fd, ret, msgName, f) - symbols[n] = fld - ret.fields = append(ret.fields, fld) +// Unwrap returns the underlying protoreflect.Descriptor. Most usages will be more +// interested in UnwrapMessage, which has a more specific return type. This generic +// version is present to satisfy the DescriptorWrapper interface. +func (md *MessageDescriptor) Unwrap() protoreflect.Descriptor { + return md.wrapped +} + +// UnwrapMessage returns the underlying protoreflect.MessageDescriptor. +func (md *MessageDescriptor) UnwrapMessage() protoreflect.MessageDescriptor { + return md.wrapped +} + +func createMessageDescriptor(fd *FileDescriptor, parent Descriptor, md protoreflect.MessageDescriptor, mdp *descriptorpb.DescriptorProto, symbols map[string]Descriptor, cache descriptorCache, path []int32) *MessageDescriptor { + ret := &MessageDescriptor{ + wrapped: md, + proto: mdp, + parent: parent, + file: fd, + sourceInfoPath: append([]int32(nil), path...), // defensive copy } - for _, nm := range md.NestedType { - nmd, n := createMessageDescriptor(fd, ret, msgName, nm, symbols) - symbols[n] = nmd + cache.put(md, ret) + path = append(path, internal.Message_nestedMessagesTag) + for i := 0; i < md.Messages().Len(); i++ { + src := md.Messages().Get(i) + srcProto := mdp.GetNestedType()[src.Index()] + nmd := createMessageDescriptor(fd, ret, src, srcProto, symbols, cache, append(path, int32(i))) + symbols[string(src.FullName())] = nmd ret.nested = append(ret.nested, nmd) } - for _, e := range md.EnumType { - ed, n := createEnumDescriptor(fd, ret, msgName, e, symbols) - symbols[n] = ed + path[len(path)-1] = internal.Message_enumsTag + for i := 0; i < md.Enums().Len(); i++ { + src := md.Enums().Get(i) + srcProto := mdp.GetEnumType()[src.Index()] + ed := createEnumDescriptor(fd, ret, src, srcProto, symbols, cache, append(path, int32(i))) + symbols[string(src.FullName())] = ed ret.enums = append(ret.enums, ed) } - for _, ex := range md.GetExtension() { - exd, n := createFieldDescriptor(fd, ret, msgName, ex) - symbols[n] = exd + path[len(path)-1] = internal.Message_fieldsTag + for i := 0; i < md.Fields().Len(); i++ { + src := md.Fields().Get(i) + srcProto := mdp.GetField()[src.Index()] + fld := createFieldDescriptor(fd, ret, src, srcProto, cache, append(path, int32(i))) + symbols[string(src.FullName())] = fld + ret.fields = append(ret.fields, fld) + } + path[len(path)-1] = internal.Message_extensionsTag + for i := 0; i < md.Extensions().Len(); i++ { + src := md.Extensions().Get(i) + srcProto := mdp.GetExtension()[src.Index()] + exd := createFieldDescriptor(fd, ret, src, srcProto, cache, append(path, int32(i))) + symbols[string(src.FullName())] = exd ret.extensions = append(ret.extensions, exd) } - for i, o := range md.GetOneofDecl() { - od, n := createOneOfDescriptor(fd, ret, i, msgName, o) - symbols[n] = od + path[len(path)-1] = internal.Message_oneOfsTag + for i := 0; i < md.Oneofs().Len(); i++ { + src := md.Oneofs().Get(i) + srcProto := mdp.GetOneofDecl()[src.Index()] + od := createOneOfDescriptor(fd, ret, i, src, srcProto, append(path, int32(i))) + symbols[string(src.FullName())] = od ret.oneOfs = append(ret.oneOfs, od) } - for _, r := range md.GetExtensionRange() { + for _, r := range mdp.GetExtensionRange() { // proto.ExtensionRange is inclusive (and that's how extension ranges are defined in code). // but protoc converts range to exclusive end in descriptor, so we must convert back end := r.GetEnd() - 1 @@ -315,57 +358,39 @@ func createMessageDescriptor(fd *FileDescriptor, parent Descriptor, enclosing st End: end}) } sort.Sort(ret.extRanges) - ret.isProto3 = fd.isProto3 - ret.isMapEntry = md.GetOptions().GetMapEntry() && - len(ret.fields) == 2 && - ret.fields[0].GetNumber() == 1 && - ret.fields[1].GetNumber() == 2 - return ret, msgName + return ret } -func (md *MessageDescriptor) resolve(path []int32, scopes []scope) error { - md.sourceInfoPath = append([]int32(nil), path...) // defensive copy - path = append(path, internal.Message_nestedMessagesTag) - scopes = append(scopes, messageScope(md)) - for i, nmd := range md.nested { - if err := nmd.resolve(append(path, int32(i)), scopes); err != nil { +func (md *MessageDescriptor) resolve(cache descriptorCache) error { + for _, nmd := range md.nested { + if err := nmd.resolve(cache); err != nil { return err } } - path[len(path)-1] = internal.Message_enumsTag - for i, ed := range md.enums { - ed.resolve(append(path, int32(i))) - } - path[len(path)-1] = internal.Message_fieldsTag - for i, fld := range md.fields { - if err := fld.resolve(append(path, int32(i)), scopes); err != nil { + for _, fld := range md.fields { + if err := fld.resolve(cache); err != nil { return err } } - path[len(path)-1] = internal.Message_extensionsTag - for i, exd := range md.extensions { - if err := exd.resolve(append(path, int32(i)), scopes); err != nil { + for _, exd := range md.extensions { + if err := exd.resolve(cache); err != nil { return err } } - path[len(path)-1] = internal.Message_oneOfsTag - for i, od := range md.oneOfs { - od.resolve(append(path, int32(i))) - } return nil } // GetName returns the simple (unqualified) name of the message. func (md *MessageDescriptor) GetName() string { - return md.proto.GetName() + return string(md.wrapped.Name()) } // GetFullyQualifiedName returns the fully qualified name of the message. This // includes the package name (if there is one) as well as the names of any // enclosing messages. func (md *MessageDescriptor) GetFullyQualifiedName() string { - return md.fqn + return string(md.wrapped.FullName()) } // GetParent returns the message's enclosing descriptor. For top-level messages, @@ -388,7 +413,7 @@ func (md *MessageDescriptor) GetOptions() proto.Message { } // GetMessageOptions returns the message's options. -func (md *MessageDescriptor) GetMessageOptions() *dpb.MessageOptions { +func (md *MessageDescriptor) GetMessageOptions() *descriptorpb.MessageOptions { return md.proto.GetOptions() } @@ -397,7 +422,7 @@ func (md *MessageDescriptor) GetMessageOptions() *dpb.MessageOptions { // returned info contains information about the location in the file where the // message was defined and also contains comments associated with the message // definition. -func (md *MessageDescriptor) GetSourceInfo() *dpb.SourceCodeInfo_Location { +func (md *MessageDescriptor) GetSourceInfo() *descriptorpb.SourceCodeInfo_Location { return md.file.sourceInfo.Get(md.sourceInfoPath) } @@ -409,7 +434,7 @@ func (md *MessageDescriptor) AsProto() proto.Message { } // AsDescriptorProto returns the underlying descriptor proto. -func (md *MessageDescriptor) AsDescriptorProto() *dpb.DescriptorProto { +func (md *MessageDescriptor) AsDescriptorProto() *descriptorpb.DescriptorProto { return md.proto } @@ -421,7 +446,7 @@ func (md *MessageDescriptor) String() string { // IsMapEntry returns true if this is a synthetic message type that represents an entry // in a map field. func (md *MessageDescriptor) IsMapEntry() bool { - return md.isMapEntry + return md.wrapped.IsMapEntry() } // GetFields returns all of the fields for this message. @@ -451,7 +476,7 @@ func (md *MessageDescriptor) GetOneOfs() []*OneOfDescriptor { // IsProto3 returns true if the file in which this message is defined declares a syntax of "proto3". func (md *MessageDescriptor) IsProto3() bool { - return md.isProto3 + return md.file.IsProto3() } // GetExtensionRanges returns the ranges of extension field numbers for this message. @@ -506,7 +531,7 @@ func (er extRanges) Swap(i, j int) { // FindFieldByName finds the field with the given name. If no such field exists // then nil is returned. Only regular fields are returned, not extensions. func (md *MessageDescriptor) FindFieldByName(fieldName string) *FieldDescriptor { - fqn := fmt.Sprintf("%s.%s", md.fqn, fieldName) + fqn := fmt.Sprintf("%s.%s", md.GetFullyQualifiedName(), fieldName) if fd, ok := md.file.symbols[fqn].(*FieldDescriptor); ok && !fd.IsExtension() { return fd } else { @@ -517,7 +542,7 @@ func (md *MessageDescriptor) FindFieldByName(fieldName string) *FieldDescriptor // FindFieldByNumber finds the field with the given tag number. If no such field // exists then nil is returned. Only regular fields are returned, not extensions. func (md *MessageDescriptor) FindFieldByNumber(tagNumber int32) *FieldDescriptor { - if fd, ok := md.file.fieldIndex[md.fqn][tagNumber]; ok && !fd.IsExtension() { + if fd, ok := md.file.fieldIndex[md.GetFullyQualifiedName()][tagNumber]; ok && !fd.IsExtension() { return fd } else { return nil @@ -526,27 +551,44 @@ func (md *MessageDescriptor) FindFieldByNumber(tagNumber int32) *FieldDescriptor // FieldDescriptor describes a field of a protocol buffer message. type FieldDescriptor struct { - proto *dpb.FieldDescriptorProto + wrapped protoreflect.FieldDescriptor + proto *descriptorpb.FieldDescriptorProto parent Descriptor owner *MessageDescriptor file *FileDescriptor oneOf *OneOfDescriptor msgType *MessageDescriptor enumType *EnumDescriptor - fqn string sourceInfoPath []int32 def memoizedDefault - isMap bool } -func createFieldDescriptor(fd *FileDescriptor, parent Descriptor, enclosing string, fld *dpb.FieldDescriptorProto) (*FieldDescriptor, string) { - fldName := merge(enclosing, fld.GetName()) - ret := &FieldDescriptor{proto: fld, parent: parent, file: fd, fqn: fldName} - if fld.GetExtendee() == "" { +// Unwrap returns the underlying protoreflect.Descriptor. Most usages will be more +// interested in UnwrapField, which has a more specific return type. This generic +// version is present to satisfy the DescriptorWrapper interface. +func (fd *FieldDescriptor) Unwrap() protoreflect.Descriptor { + return fd.wrapped +} + +// UnwrapField returns the underlying protoreflect.FieldDescriptor. +func (fd *FieldDescriptor) UnwrapField() protoreflect.FieldDescriptor { + return fd.wrapped +} + +func createFieldDescriptor(fd *FileDescriptor, parent Descriptor, fld protoreflect.FieldDescriptor, fldp *descriptorpb.FieldDescriptorProto, cache descriptorCache, path []int32) *FieldDescriptor { + ret := &FieldDescriptor{ + wrapped: fld, + proto: fldp, + parent: parent, + file: fd, + sourceInfoPath: append([]int32(nil), path...), // defensive copy + } + cache.put(fld, ret) + if !fld.IsExtension() { ret.owner = parent.(*MessageDescriptor) } // owner for extensions, field type (be it message or enum), and one-ofs get resolved later - return ret, fldName + return ret } func descriptorType(d Descriptor) string { @@ -575,48 +617,44 @@ func descriptorType(d Descriptor) string { } } -func (fd *FieldDescriptor) resolve(path []int32, scopes []scope) error { +func (fd *FieldDescriptor) resolve(cache descriptorCache) error { if fd.proto.OneofIndex != nil && fd.oneOf == nil { - return fmt.Errorf("could not link field %s to one-of index %d", fd.fqn, *fd.proto.OneofIndex) + return fmt.Errorf("could not link field %s to one-of index %d", fd.GetFullyQualifiedName(), *fd.proto.OneofIndex) } - fd.sourceInfoPath = append([]int32(nil), path...) // defensive copy - if fd.proto.GetType() == dpb.FieldDescriptorProto_TYPE_ENUM { - desc, err := resolve(fd.file, fd.proto.GetTypeName(), scopes) + if fd.proto.GetType() == descriptorpb.FieldDescriptorProto_TYPE_ENUM { + desc, err := resolve(fd.file, fd.wrapped.Enum(), cache) if err != nil { return err } enumType, ok := desc.(*EnumDescriptor) if !ok { - return fmt.Errorf("field %v indicates a type of enum, but references %q which is %s", fd.fqn, fd.proto.GetTypeName(), descriptorType(desc)) + return fmt.Errorf("field %v indicates a type of enum, but references %q which is %s", fd.GetFullyQualifiedName(), fd.proto.GetTypeName(), descriptorType(desc)) } fd.enumType = enumType } - if fd.proto.GetType() == dpb.FieldDescriptorProto_TYPE_MESSAGE || fd.proto.GetType() == dpb.FieldDescriptorProto_TYPE_GROUP { - desc, err := resolve(fd.file, fd.proto.GetTypeName(), scopes) + if fd.proto.GetType() == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE || fd.proto.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP { + desc, err := resolve(fd.file, fd.wrapped.Message(), cache) if err != nil { return err } msgType, ok := desc.(*MessageDescriptor) if !ok { - return fmt.Errorf("field %v indicates a type of message, but references %q which is %s", fd.fqn, fd.proto.GetTypeName(), descriptorType(desc)) + return fmt.Errorf("field %v indicates a type of message, but references %q which is %s", fd.GetFullyQualifiedName(), fd.proto.GetTypeName(), descriptorType(desc)) } fd.msgType = msgType } - if fd.proto.GetExtendee() != "" { - desc, err := resolve(fd.file, fd.proto.GetExtendee(), scopes) + if fd.IsExtension() { + desc, err := resolve(fd.file, fd.wrapped.ContainingMessage(), cache) if err != nil { return err } msgType, ok := desc.(*MessageDescriptor) if !ok { - return fmt.Errorf("field %v extends %q which should be a message but is %s", fd.fqn, fd.proto.GetExtendee(), descriptorType(desc)) + return fmt.Errorf("field %v extends %q which should be a message but is %s", fd.GetFullyQualifiedName(), fd.proto.GetExtendee(), descriptorType(desc)) } fd.owner = msgType } fd.file.registerField(fd) - fd.isMap = fd.proto.GetLabel() == dpb.FieldDescriptorProto_LABEL_REPEATED && - fd.proto.GetType() == dpb.FieldDescriptorProto_TYPE_MESSAGE && - fd.GetMessageType().IsMapEntry() return nil } @@ -629,7 +667,7 @@ func (fd *FieldDescriptor) determineDefault() interface{} { return nil } - proto3 := fd.file.isProto3 + proto3 := fd.file.IsProto3() if !proto3 { def := fd.AsFieldDescriptorProto().GetDefaultValue() if def != "" { @@ -642,31 +680,31 @@ func (fd *FieldDescriptor) determineDefault() interface{} { } switch fd.GetType() { - case dpb.FieldDescriptorProto_TYPE_FIXED32, - dpb.FieldDescriptorProto_TYPE_UINT32: + case descriptorpb.FieldDescriptorProto_TYPE_FIXED32, + descriptorpb.FieldDescriptorProto_TYPE_UINT32: return uint32(0) - case dpb.FieldDescriptorProto_TYPE_SFIXED32, - dpb.FieldDescriptorProto_TYPE_INT32, - dpb.FieldDescriptorProto_TYPE_SINT32: + case descriptorpb.FieldDescriptorProto_TYPE_SFIXED32, + descriptorpb.FieldDescriptorProto_TYPE_INT32, + descriptorpb.FieldDescriptorProto_TYPE_SINT32: return int32(0) - case dpb.FieldDescriptorProto_TYPE_FIXED64, - dpb.FieldDescriptorProto_TYPE_UINT64: + case descriptorpb.FieldDescriptorProto_TYPE_FIXED64, + descriptorpb.FieldDescriptorProto_TYPE_UINT64: return uint64(0) - case dpb.FieldDescriptorProto_TYPE_SFIXED64, - dpb.FieldDescriptorProto_TYPE_INT64, - dpb.FieldDescriptorProto_TYPE_SINT64: + case descriptorpb.FieldDescriptorProto_TYPE_SFIXED64, + descriptorpb.FieldDescriptorProto_TYPE_INT64, + descriptorpb.FieldDescriptorProto_TYPE_SINT64: return int64(0) - case dpb.FieldDescriptorProto_TYPE_FLOAT: + case descriptorpb.FieldDescriptorProto_TYPE_FLOAT: return float32(0.0) - case dpb.FieldDescriptorProto_TYPE_DOUBLE: + case descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: return float64(0.0) - case dpb.FieldDescriptorProto_TYPE_BOOL: + case descriptorpb.FieldDescriptorProto_TYPE_BOOL: return false - case dpb.FieldDescriptorProto_TYPE_BYTES: + case descriptorpb.FieldDescriptorProto_TYPE_BYTES: return []byte(nil) - case dpb.FieldDescriptorProto_TYPE_STRING: + case descriptorpb.FieldDescriptorProto_TYPE_STRING: return "" - case dpb.FieldDescriptorProto_TYPE_ENUM: + case descriptorpb.FieldDescriptorProto_TYPE_ENUM: if proto3 { return int32(0) } @@ -683,60 +721,60 @@ func (fd *FieldDescriptor) determineDefault() interface{} { func parseDefaultValue(fd *FieldDescriptor, val string) interface{} { switch fd.GetType() { - case dpb.FieldDescriptorProto_TYPE_ENUM: + case descriptorpb.FieldDescriptorProto_TYPE_ENUM: vd := fd.GetEnumType().FindValueByName(val) if vd != nil { return vd.GetNumber() } return nil - case dpb.FieldDescriptorProto_TYPE_BOOL: + case descriptorpb.FieldDescriptorProto_TYPE_BOOL: if val == "true" { return true } else if val == "false" { return false } return nil - case dpb.FieldDescriptorProto_TYPE_BYTES: + case descriptorpb.FieldDescriptorProto_TYPE_BYTES: return []byte(unescape(val)) - case dpb.FieldDescriptorProto_TYPE_STRING: + case descriptorpb.FieldDescriptorProto_TYPE_STRING: return val - case dpb.FieldDescriptorProto_TYPE_FLOAT: + case descriptorpb.FieldDescriptorProto_TYPE_FLOAT: if f, err := strconv.ParseFloat(val, 32); err == nil { return float32(f) } else { return float32(0) } - case dpb.FieldDescriptorProto_TYPE_DOUBLE: + case descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: if f, err := strconv.ParseFloat(val, 64); err == nil { return f } else { return float64(0) } - case dpb.FieldDescriptorProto_TYPE_INT32, - dpb.FieldDescriptorProto_TYPE_SINT32, - dpb.FieldDescriptorProto_TYPE_SFIXED32: + case descriptorpb.FieldDescriptorProto_TYPE_INT32, + descriptorpb.FieldDescriptorProto_TYPE_SINT32, + descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: if i, err := strconv.ParseInt(val, 10, 32); err == nil { return int32(i) } else { return int32(0) } - case dpb.FieldDescriptorProto_TYPE_UINT32, - dpb.FieldDescriptorProto_TYPE_FIXED32: + case descriptorpb.FieldDescriptorProto_TYPE_UINT32, + descriptorpb.FieldDescriptorProto_TYPE_FIXED32: if i, err := strconv.ParseUint(val, 10, 32); err == nil { return uint32(i) } else { return uint32(0) } - case dpb.FieldDescriptorProto_TYPE_INT64, - dpb.FieldDescriptorProto_TYPE_SINT64, - dpb.FieldDescriptorProto_TYPE_SFIXED64: + case descriptorpb.FieldDescriptorProto_TYPE_INT64, + descriptorpb.FieldDescriptorProto_TYPE_SINT64, + descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: if i, err := strconv.ParseInt(val, 10, 64); err == nil { return i } else { return int64(0) } - case dpb.FieldDescriptorProto_TYPE_UINT64, - dpb.FieldDescriptorProto_TYPE_FIXED64: + case descriptorpb.FieldDescriptorProto_TYPE_UINT64, + descriptorpb.FieldDescriptorProto_TYPE_FIXED64: if i, err := strconv.ParseUint(val, 10, 64); err == nil { return i } else { @@ -868,12 +906,12 @@ func matchPrefix(s string, limit int, fn func(byte) bool) int { // GetName returns the name of the field. func (fd *FieldDescriptor) GetName() string { - return fd.proto.GetName() + return string(fd.wrapped.Name()) } // GetNumber returns the tag number of this field. func (fd *FieldDescriptor) GetNumber() int32 { - return fd.proto.GetNumber() + return int32(fd.wrapped.Number()) } // GetFullyQualifiedName returns the fully qualified name of the field. Unlike @@ -887,7 +925,7 @@ func (fd *FieldDescriptor) GetNumber() int32 { // If this field is part of a one-of, the fully qualified name does *not* // include the name of the one-of, only of the enclosing message. func (fd *FieldDescriptor) GetFullyQualifiedName() string { - return fd.fqn + return string(fd.wrapped.FullName()) } // GetParent returns the fields's enclosing descriptor. For normal @@ -912,7 +950,7 @@ func (fd *FieldDescriptor) GetOptions() proto.Message { } // GetFieldOptions returns the field's options. -func (fd *FieldDescriptor) GetFieldOptions() *dpb.FieldOptions { +func (fd *FieldDescriptor) GetFieldOptions() *descriptorpb.FieldOptions { return fd.proto.GetOptions() } @@ -921,7 +959,7 @@ func (fd *FieldDescriptor) GetFieldOptions() *dpb.FieldOptions { // returned info contains information about the location in the file where the // field was defined and also contains comments associated with the field // definition. -func (fd *FieldDescriptor) GetSourceInfo() *dpb.SourceCodeInfo_Location { +func (fd *FieldDescriptor) GetSourceInfo() *descriptorpb.SourceCodeInfo_Location { return fd.file.sourceInfo.Get(fd.sourceInfoPath) } @@ -933,7 +971,7 @@ func (fd *FieldDescriptor) AsProto() proto.Message { } // AsFieldDescriptorProto returns the underlying descriptor proto. -func (fd *FieldDescriptor) AsFieldDescriptorProto() *dpb.FieldDescriptorProto { +func (fd *FieldDescriptor) AsFieldDescriptorProto() *descriptorpb.FieldDescriptorProto { return fd.proto } @@ -1003,7 +1041,7 @@ func (fd *FieldDescriptor) GetOwner() *MessageDescriptor { // IsExtension returns true if this is an extension field. func (fd *FieldDescriptor) IsExtension() bool { - return fd.proto.GetExtendee() != "" + return fd.wrapped.IsExtension() } // GetOneOf returns the one-of field set to which this field belongs. If this field @@ -1015,24 +1053,24 @@ func (fd *FieldDescriptor) GetOneOf() *OneOfDescriptor { // GetType returns the type of this field. If the type indicates an enum, the // enum type can be queried via GetEnumType. If the type indicates a message, the // message type can be queried via GetMessageType. -func (fd *FieldDescriptor) GetType() dpb.FieldDescriptorProto_Type { +func (fd *FieldDescriptor) GetType() descriptorpb.FieldDescriptorProto_Type { return fd.proto.GetType() } // GetLabel returns the label for this field. The label can be required (proto2-only), // optional (default for proto3), or required. -func (fd *FieldDescriptor) GetLabel() dpb.FieldDescriptorProto_Label { +func (fd *FieldDescriptor) GetLabel() descriptorpb.FieldDescriptorProto_Label { return fd.proto.GetLabel() } // IsRequired returns true if this field has the "required" label. func (fd *FieldDescriptor) IsRequired() bool { - return fd.proto.GetLabel() == dpb.FieldDescriptorProto_LABEL_REQUIRED + return fd.wrapped.Cardinality() == protoreflect.Required } // IsRepeated returns true if this field has the "repeated" label. func (fd *FieldDescriptor) IsRepeated() bool { - return fd.proto.GetLabel() == dpb.FieldDescriptorProto_LABEL_REPEATED + return fd.wrapped.Cardinality() == protoreflect.Repeated } // IsProto3Optional returns true if this field has an explicit "optional" label @@ -1047,23 +1085,20 @@ func (fd *FieldDescriptor) IsProto3Optional() bool { // present or not. Scalar fields in "proto3" syntax files, for example, return // false since absent values are indistinguishable from zero values. func (fd *FieldDescriptor) HasPresence() bool { - if !fd.file.isProto3 { - return true - } - return fd.msgType != nil || fd.oneOf != nil + return fd.wrapped.HasPresence() } // IsMap returns true if this is a map field. If so, it will have the "repeated" // label its type will be a message that represents a map entry. The map entry // message will have exactly two fields: tag #1 is the key and tag #2 is the value. func (fd *FieldDescriptor) IsMap() bool { - return fd.isMap + return fd.wrapped.IsMap() } // GetMapKeyType returns the type of the key field if this is a map field. If it is // not a map field, nil is returned. func (fd *FieldDescriptor) GetMapKeyType() *FieldDescriptor { - if fd.isMap { + if fd.IsMap() { return fd.msgType.FindFieldByNumber(int32(1)) } return nil @@ -1072,7 +1107,7 @@ func (fd *FieldDescriptor) GetMapKeyType() *FieldDescriptor { // GetMapValueType returns the type of the value field if this is a map field. If it // is not a map field, nil is returned. func (fd *FieldDescriptor) GetMapValueType() *FieldDescriptor { - if fd.isMap { + if fd.IsMap() { return fd.msgType.FindFieldByNumber(int32(2)) } return nil @@ -1121,21 +1156,46 @@ func (fd *FieldDescriptor) GetDefaultValue() interface{} { // EnumDescriptor describes an enum declared in a proto file. type EnumDescriptor struct { - proto *dpb.EnumDescriptorProto + wrapped protoreflect.EnumDescriptor + proto *descriptorpb.EnumDescriptorProto parent Descriptor file *FileDescriptor values []*EnumValueDescriptor valuesByNum sortedValues - fqn string sourceInfoPath []int32 } -func createEnumDescriptor(fd *FileDescriptor, parent Descriptor, enclosing string, ed *dpb.EnumDescriptorProto, symbols map[string]Descriptor) (*EnumDescriptor, string) { - enumName := merge(enclosing, ed.GetName()) - ret := &EnumDescriptor{proto: ed, parent: parent, file: fd, fqn: enumName} - for _, ev := range ed.GetValue() { - evd, n := createEnumValueDescriptor(fd, ret, enumName, ev) - symbols[n] = evd +// Unwrap returns the underlying protoreflect.Descriptor. Most usages will be more +// interested in UnwrapEnum, which has a more specific return type. This generic +// version is present to satisfy the DescriptorWrapper interface. +func (ed *EnumDescriptor) Unwrap() protoreflect.Descriptor { + return ed.wrapped +} + +// UnwrapEnum returns the underlying protoreflect.EnumDescriptor. +func (ed *EnumDescriptor) UnwrapEnum() protoreflect.EnumDescriptor { + return ed.wrapped +} + +func createEnumDescriptor(fd *FileDescriptor, parent Descriptor, ed protoreflect.EnumDescriptor, edp *descriptorpb.EnumDescriptorProto, symbols map[string]Descriptor, cache descriptorCache, path []int32) *EnumDescriptor { + ret := &EnumDescriptor{ + wrapped: ed, + proto: edp, + parent: parent, + file: fd, + sourceInfoPath: append([]int32(nil), path...), // defensive copy + } + path = append(path, internal.Enum_valuesTag) + for i := 0; i < ed.Values().Len(); i++ { + src := ed.Values().Get(i) + srcProto := edp.GetValue()[src.Index()] + evd := createEnumValueDescriptor(fd, ret, src, srcProto, append(path, int32(i))) + symbols[string(src.FullName())] = evd + // NB: for backwards compatibility, also register the enum value as if + // scoped within the enum (counter-intuitively, enum value full names are + // scoped in the enum's parent element). EnumValueDescripto.GetFullyQualifiedName + // returns that alternate full name. + symbols[evd.GetFullyQualifiedName()] = evd ret.values = append(ret.values, evd) } if len(ret.values) > 0 { @@ -1143,7 +1203,7 @@ func createEnumDescriptor(fd *FileDescriptor, parent Descriptor, enclosing strin copy(ret.valuesByNum, ret.values) sort.Stable(ret.valuesByNum) } - return ret, enumName + return ret } type sortedValues []*EnumValueDescriptor @@ -1161,24 +1221,16 @@ func (sv sortedValues) Swap(i, j int) { } -func (ed *EnumDescriptor) resolve(path []int32) { - ed.sourceInfoPath = append([]int32(nil), path...) // defensive copy - path = append(path, internal.Enum_valuesTag) - for i, evd := range ed.values { - evd.resolve(append(path, int32(i))) - } -} - // GetName returns the simple (unqualified) name of the enum type. func (ed *EnumDescriptor) GetName() string { - return ed.proto.GetName() + return string(ed.wrapped.Name()) } // GetFullyQualifiedName returns the fully qualified name of the enum type. // This includes the package name (if there is one) as well as the names of any // enclosing messages. func (ed *EnumDescriptor) GetFullyQualifiedName() string { - return ed.fqn + return string(ed.wrapped.FullName()) } // GetParent returns the enum type's enclosing descriptor. For top-level enums, @@ -1201,7 +1253,7 @@ func (ed *EnumDescriptor) GetOptions() proto.Message { } // GetEnumOptions returns the enum type's options. -func (ed *EnumDescriptor) GetEnumOptions() *dpb.EnumOptions { +func (ed *EnumDescriptor) GetEnumOptions() *descriptorpb.EnumOptions { return ed.proto.GetOptions() } @@ -1210,7 +1262,7 @@ func (ed *EnumDescriptor) GetEnumOptions() *dpb.EnumOptions { // returned info contains information about the location in the file where the // enum type was defined and also contains comments associated with the enum // definition. -func (ed *EnumDescriptor) GetSourceInfo() *dpb.SourceCodeInfo_Location { +func (ed *EnumDescriptor) GetSourceInfo() *descriptorpb.SourceCodeInfo_Location { return ed.file.sourceInfo.Get(ed.sourceInfoPath) } @@ -1222,7 +1274,7 @@ func (ed *EnumDescriptor) AsProto() proto.Message { } // AsEnumDescriptorProto returns the underlying descriptor proto. -func (ed *EnumDescriptor) AsEnumDescriptorProto() *dpb.EnumDescriptorProto { +func (ed *EnumDescriptor) AsEnumDescriptorProto() *descriptorpb.EnumDescriptorProto { return ed.proto } @@ -1239,7 +1291,7 @@ func (ed *EnumDescriptor) GetValues() []*EnumValueDescriptor { // FindValueByName finds the enum value with the given name. If no such value exists // then nil is returned. func (ed *EnumDescriptor) FindValueByName(name string) *EnumValueDescriptor { - fqn := fmt.Sprintf("%s.%s", ed.fqn, name) + fqn := fmt.Sprintf("%s.%s", ed.GetFullyQualifiedName(), name) if vd, ok := ed.file.symbols[fqn].(*EnumValueDescriptor); ok { return vd } else { @@ -1263,16 +1315,33 @@ func (ed *EnumDescriptor) FindValueByNumber(num int32) *EnumValueDescriptor { // EnumValueDescriptor describes an allowed value of an enum declared in a proto file. type EnumValueDescriptor struct { - proto *dpb.EnumValueDescriptorProto + wrapped protoreflect.EnumValueDescriptor + proto *descriptorpb.EnumValueDescriptorProto parent *EnumDescriptor file *FileDescriptor - fqn string sourceInfoPath []int32 } -func createEnumValueDescriptor(fd *FileDescriptor, parent *EnumDescriptor, enclosing string, evd *dpb.EnumValueDescriptorProto) (*EnumValueDescriptor, string) { - valName := merge(enclosing, evd.GetName()) - return &EnumValueDescriptor{proto: evd, parent: parent, file: fd, fqn: valName}, valName +// Unwrap returns the underlying protoreflect.Descriptor. Most usages will be more +// interested in UnwrapEnumValue, which has a more specific return type. This generic +// version is present to satisfy the DescriptorWrapper interface. +func (vd *EnumValueDescriptor) Unwrap() protoreflect.Descriptor { + return vd.wrapped +} + +// UnwrapEnumValue returns the underlying protoreflect.EnumValueDescriptor. +func (vd *EnumValueDescriptor) UnwrapEnumValue() protoreflect.EnumValueDescriptor { + return vd.wrapped +} + +func createEnumValueDescriptor(fd *FileDescriptor, parent *EnumDescriptor, evd protoreflect.EnumValueDescriptor, evdp *descriptorpb.EnumValueDescriptorProto, path []int32) *EnumValueDescriptor { + return &EnumValueDescriptor{ + wrapped: evd, + proto: evdp, + parent: parent, + file: fd, + sourceInfoPath: append([]int32(nil), path...), // defensive copy + } } func (vd *EnumValueDescriptor) resolve(path []int32) { @@ -1281,18 +1350,24 @@ func (vd *EnumValueDescriptor) resolve(path []int32) { // GetName returns the name of the enum value. func (vd *EnumValueDescriptor) GetName() string { - return vd.proto.GetName() + return string(vd.wrapped.Name()) } // GetNumber returns the numeric value associated with this enum value. func (vd *EnumValueDescriptor) GetNumber() int32 { - return vd.proto.GetNumber() + return int32(vd.wrapped.Number()) } // GetFullyQualifiedName returns the fully qualified name of the enum value. // Unlike GetName, this includes fully qualified name of the enclosing enum. func (vd *EnumValueDescriptor) GetFullyQualifiedName() string { - return vd.fqn + // NB: Technically, we do not return the correct value. Enum values are + // scoped within the enclosing element, not within the enum itself (which + // is very non-intuitive, but it follows C++ scoping rules). The value + // returned from vd.wrapped.FullName() is correct. However, we return + // something different, just for backwards compatibility, as this package + // has always instead returned the name scoped inside the enum. + return fmt.Sprintf("%s.%s", vd.parent.GetFullyQualifiedName(), vd.wrapped.Name()) } // GetParent returns the descriptor for the enum in which this enum value is @@ -1321,7 +1396,7 @@ func (vd *EnumValueDescriptor) GetOptions() proto.Message { } // GetEnumValueOptions returns the enum value's options. -func (vd *EnumValueDescriptor) GetEnumValueOptions() *dpb.EnumValueOptions { +func (vd *EnumValueDescriptor) GetEnumValueOptions() *descriptorpb.EnumValueOptions { return vd.proto.GetOptions() } @@ -1330,7 +1405,7 @@ func (vd *EnumValueDescriptor) GetEnumValueOptions() *dpb.EnumValueOptions { // returned info contains information about the location in the file where the // enum value was defined and also contains comments associated with the enum // value definition. -func (vd *EnumValueDescriptor) GetSourceInfo() *dpb.SourceCodeInfo_Location { +func (vd *EnumValueDescriptor) GetSourceInfo() *descriptorpb.SourceCodeInfo_Location { return vd.file.sourceInfo.Get(vd.sourceInfoPath) } @@ -1342,7 +1417,7 @@ func (vd *EnumValueDescriptor) AsProto() proto.Message { } // AsEnumValueDescriptorProto returns the underlying descriptor proto. -func (vd *EnumValueDescriptor) AsEnumValueDescriptorProto() *dpb.EnumValueDescriptorProto { +func (vd *EnumValueDescriptor) AsEnumValueDescriptorProto() *descriptorpb.EnumValueDescriptorProto { return vd.proto } @@ -1353,29 +1428,46 @@ func (vd *EnumValueDescriptor) String() string { // ServiceDescriptor describes an RPC service declared in a proto file. type ServiceDescriptor struct { - proto *dpb.ServiceDescriptorProto + wrapped protoreflect.ServiceDescriptor + proto *descriptorpb.ServiceDescriptorProto file *FileDescriptor methods []*MethodDescriptor - fqn string sourceInfoPath []int32 } -func createServiceDescriptor(fd *FileDescriptor, enclosing string, sd *dpb.ServiceDescriptorProto, symbols map[string]Descriptor) (*ServiceDescriptor, string) { - serviceName := merge(enclosing, sd.GetName()) - ret := &ServiceDescriptor{proto: sd, file: fd, fqn: serviceName} - for _, m := range sd.GetMethod() { - md, n := createMethodDescriptor(fd, ret, serviceName, m) - symbols[n] = md +// Unwrap returns the underlying protoreflect.Descriptor. Most usages will be more +// interested in UnwrapService, which has a more specific return type. This generic +// version is present to satisfy the DescriptorWrapper interface. +func (sd *ServiceDescriptor) Unwrap() protoreflect.Descriptor { + return sd.wrapped +} + +// UnwrapService returns the underlying protoreflect.ServiceDescriptor. +func (sd *ServiceDescriptor) UnwrapService() protoreflect.ServiceDescriptor { + return sd.wrapped +} + +func createServiceDescriptor(fd *FileDescriptor, sd protoreflect.ServiceDescriptor, sdp *descriptorpb.ServiceDescriptorProto, symbols map[string]Descriptor, path []int32) *ServiceDescriptor { + ret := &ServiceDescriptor{ + wrapped: sd, + proto: sdp, + file: fd, + sourceInfoPath: append([]int32(nil), path...), // defensive copy + } + path = append(path, internal.Service_methodsTag) + for i := 0; i < sd.Methods().Len(); i++ { + src := sd.Methods().Get(i) + srcProto := sdp.GetMethod()[src.Index()] + md := createMethodDescriptor(fd, ret, src, srcProto, append(path, int32(i))) + symbols[string(src.FullName())] = md ret.methods = append(ret.methods, md) } - return ret, serviceName + return ret } -func (sd *ServiceDescriptor) resolve(path []int32, scopes []scope) error { - sd.sourceInfoPath = append([]int32(nil), path...) // defensive copy - path = append(path, internal.Service_methodsTag) - for i, md := range sd.methods { - if err := md.resolve(append(path, int32(i)), scopes); err != nil { +func (sd *ServiceDescriptor) resolve(cache descriptorCache) error { + for _, md := range sd.methods { + if err := md.resolve(cache); err != nil { return err } } @@ -1384,13 +1476,13 @@ func (sd *ServiceDescriptor) resolve(path []int32, scopes []scope) error { // GetName returns the simple (unqualified) name of the service. func (sd *ServiceDescriptor) GetName() string { - return sd.proto.GetName() + return string(sd.wrapped.Name()) } // GetFullyQualifiedName returns the fully qualified name of the service. This // includes the package name (if there is one). func (sd *ServiceDescriptor) GetFullyQualifiedName() string { - return sd.fqn + return string(sd.wrapped.FullName()) } // GetParent returns the descriptor for the file in which this service is @@ -1413,7 +1505,7 @@ func (sd *ServiceDescriptor) GetOptions() proto.Message { } // GetServiceOptions returns the service's options. -func (sd *ServiceDescriptor) GetServiceOptions() *dpb.ServiceOptions { +func (sd *ServiceDescriptor) GetServiceOptions() *descriptorpb.ServiceOptions { return sd.proto.GetOptions() } @@ -1422,7 +1514,7 @@ func (sd *ServiceDescriptor) GetServiceOptions() *dpb.ServiceOptions { // returned info contains information about the location in the file where the // service was defined and also contains comments associated with the service // definition. -func (sd *ServiceDescriptor) GetSourceInfo() *dpb.SourceCodeInfo_Location { +func (sd *ServiceDescriptor) GetSourceInfo() *descriptorpb.SourceCodeInfo_Location { return sd.file.sourceInfo.Get(sd.sourceInfoPath) } @@ -1434,7 +1526,7 @@ func (sd *ServiceDescriptor) AsProto() proto.Message { } // AsServiceDescriptorProto returns the underlying descriptor proto. -func (sd *ServiceDescriptor) AsServiceDescriptorProto() *dpb.ServiceDescriptorProto { +func (sd *ServiceDescriptor) AsServiceDescriptorProto() *descriptorpb.ServiceDescriptorProto { return sd.proto } @@ -1451,7 +1543,7 @@ func (sd *ServiceDescriptor) GetMethods() []*MethodDescriptor { // FindMethodByName finds the method with the given name. If no such method exists // then nil is returned. func (sd *ServiceDescriptor) FindMethodByName(name string) *MethodDescriptor { - fqn := fmt.Sprintf("%s.%s", sd.fqn, name) + fqn := fmt.Sprintf("%s.%s", sd.GetFullyQualifiedName(), name) if md, ok := sd.file.symbols[fqn].(*MethodDescriptor); ok { return md } else { @@ -1461,38 +1553,54 @@ func (sd *ServiceDescriptor) FindMethodByName(name string) *MethodDescriptor { // MethodDescriptor describes an RPC method declared in a proto file. type MethodDescriptor struct { - proto *dpb.MethodDescriptorProto + wrapped protoreflect.MethodDescriptor + proto *descriptorpb.MethodDescriptorProto parent *ServiceDescriptor file *FileDescriptor inType *MessageDescriptor outType *MessageDescriptor - fqn string sourceInfoPath []int32 } -func createMethodDescriptor(fd *FileDescriptor, parent *ServiceDescriptor, enclosing string, md *dpb.MethodDescriptorProto) (*MethodDescriptor, string) { +// Unwrap returns the underlying protoreflect.Descriptor. Most usages will be more +// interested in UnwrapMethod, which has a more specific return type. This generic +// version is present to satisfy the DescriptorWrapper interface. +func (md *MethodDescriptor) Unwrap() protoreflect.Descriptor { + return md.wrapped +} + +// UnwrapMethod returns the underlying protoreflect.MethodDescriptor. +func (md *MethodDescriptor) UnwrapMethod() protoreflect.MethodDescriptor { + return md.wrapped +} + +func createMethodDescriptor(fd *FileDescriptor, parent *ServiceDescriptor, md protoreflect.MethodDescriptor, mdp *descriptorpb.MethodDescriptorProto, path []int32) *MethodDescriptor { // request and response types get resolved later - methodName := merge(enclosing, md.GetName()) - return &MethodDescriptor{proto: md, parent: parent, file: fd, fqn: methodName}, methodName + return &MethodDescriptor{ + wrapped: md, + proto: mdp, + parent: parent, + file: fd, + sourceInfoPath: append([]int32(nil), path...), // defensive copy + } } -func (md *MethodDescriptor) resolve(path []int32, scopes []scope) error { - md.sourceInfoPath = append([]int32(nil), path...) // defensive copy - if desc, err := resolve(md.file, md.proto.GetInputType(), scopes); err != nil { +func (md *MethodDescriptor) resolve(cache descriptorCache) error { + if desc, err := resolve(md.file, md.wrapped.Input(), cache); err != nil { return err } else { msgType, ok := desc.(*MessageDescriptor) if !ok { - return fmt.Errorf("method %v has request type %q which should be a message but is %s", md.fqn, md.proto.GetInputType(), descriptorType(desc)) + return fmt.Errorf("method %v has request type %q which should be a message but is %s", md.GetFullyQualifiedName(), md.proto.GetInputType(), descriptorType(desc)) } md.inType = msgType } - if desc, err := resolve(md.file, md.proto.GetOutputType(), scopes); err != nil { + if desc, err := resolve(md.file, md.wrapped.Output(), cache); err != nil { return err } else { msgType, ok := desc.(*MessageDescriptor) if !ok { - return fmt.Errorf("method %v has response type %q which should be a message but is %s", md.fqn, md.proto.GetOutputType(), descriptorType(desc)) + return fmt.Errorf("method %v has response type %q which should be a message but is %s", md.GetFullyQualifiedName(), md.proto.GetOutputType(), descriptorType(desc)) } md.outType = msgType } @@ -1501,13 +1609,13 @@ func (md *MethodDescriptor) resolve(path []int32, scopes []scope) error { // GetName returns the name of the method. func (md *MethodDescriptor) GetName() string { - return md.proto.GetName() + return string(md.wrapped.Name()) } // GetFullyQualifiedName returns the fully qualified name of the method. Unlike // GetName, this includes fully qualified name of the enclosing service. func (md *MethodDescriptor) GetFullyQualifiedName() string { - return md.fqn + return string(md.wrapped.FullName()) } // GetParent returns the descriptor for the service in which this method is @@ -1536,7 +1644,7 @@ func (md *MethodDescriptor) GetOptions() proto.Message { } // GetMethodOptions returns the method's options. -func (md *MethodDescriptor) GetMethodOptions() *dpb.MethodOptions { +func (md *MethodDescriptor) GetMethodOptions() *descriptorpb.MethodOptions { return md.proto.GetOptions() } @@ -1545,7 +1653,7 @@ func (md *MethodDescriptor) GetMethodOptions() *dpb.MethodOptions { // returned info contains information about the location in the file where the // method was defined and also contains comments associated with the method // definition. -func (md *MethodDescriptor) GetSourceInfo() *dpb.SourceCodeInfo_Location { +func (md *MethodDescriptor) GetSourceInfo() *descriptorpb.SourceCodeInfo_Location { return md.file.sourceInfo.Get(md.sourceInfoPath) } @@ -1557,7 +1665,7 @@ func (md *MethodDescriptor) AsProto() proto.Message { } // AsMethodDescriptorProto returns the underlying descriptor proto. -func (md *MethodDescriptor) AsMethodDescriptorProto() *dpb.MethodDescriptorProto { +func (md *MethodDescriptor) AsMethodDescriptorProto() *descriptorpb.MethodDescriptorProto { return md.proto } @@ -1568,12 +1676,12 @@ func (md *MethodDescriptor) String() string { // IsServerStreaming returns true if this is a server-streaming method. func (md *MethodDescriptor) IsServerStreaming() bool { - return md.proto.GetServerStreaming() + return md.wrapped.IsStreamingServer() } // IsClientStreaming returns true if this is a client-streaming method. func (md *MethodDescriptor) IsClientStreaming() bool { - return md.proto.GetClientStreaming() + return md.wrapped.IsStreamingClient() } // GetInputType returns the input type, or request type, of the RPC method. @@ -1588,17 +1696,34 @@ func (md *MethodDescriptor) GetOutputType() *MessageDescriptor { // OneOfDescriptor describes a one-of field set declared in a protocol buffer message. type OneOfDescriptor struct { - proto *dpb.OneofDescriptorProto + wrapped protoreflect.OneofDescriptor + proto *descriptorpb.OneofDescriptorProto parent *MessageDescriptor file *FileDescriptor choices []*FieldDescriptor - fqn string sourceInfoPath []int32 } -func createOneOfDescriptor(fd *FileDescriptor, parent *MessageDescriptor, index int, enclosing string, od *dpb.OneofDescriptorProto) (*OneOfDescriptor, string) { - oneOfName := merge(enclosing, od.GetName()) - ret := &OneOfDescriptor{proto: od, parent: parent, file: fd, fqn: oneOfName} +// Unwrap returns the underlying protoreflect.Descriptor. Most usages will be more +// interested in UnwrapOneOf, which has a more specific return type. This generic +// version is present to satisfy the DescriptorWrapper interface. +func (od *OneOfDescriptor) Unwrap() protoreflect.Descriptor { + return od.wrapped +} + +// UnwrapOneOf returns the underlying protoreflect.OneofDescriptor. +func (od *OneOfDescriptor) UnwrapOneOf() protoreflect.OneofDescriptor { + return od.wrapped +} + +func createOneOfDescriptor(fd *FileDescriptor, parent *MessageDescriptor, index int, od protoreflect.OneofDescriptor, odp *descriptorpb.OneofDescriptorProto, path []int32) *OneOfDescriptor { + ret := &OneOfDescriptor{ + wrapped: od, + proto: odp, + parent: parent, + file: fd, + sourceInfoPath: append([]int32(nil), path...), // defensive copy + } for _, f := range parent.fields { oi := f.proto.OneofIndex if oi != nil && *oi == int32(index) { @@ -1606,22 +1731,18 @@ func createOneOfDescriptor(fd *FileDescriptor, parent *MessageDescriptor, index ret.choices = append(ret.choices, f) } } - return ret, oneOfName -} - -func (od *OneOfDescriptor) resolve(path []int32) { - od.sourceInfoPath = append([]int32(nil), path...) // defensive copy + return ret } // GetName returns the name of the one-of. func (od *OneOfDescriptor) GetName() string { - return od.proto.GetName() + return string(od.wrapped.Name()) } // GetFullyQualifiedName returns the fully qualified name of the one-of. Unlike // GetName, this includes fully qualified name of the enclosing message. func (od *OneOfDescriptor) GetFullyQualifiedName() string { - return od.fqn + return string(od.wrapped.FullName()) } // GetParent returns the descriptor for the message in which this one-of is @@ -1650,7 +1771,7 @@ func (od *OneOfDescriptor) GetOptions() proto.Message { } // GetOneOfOptions returns the one-of's options. -func (od *OneOfDescriptor) GetOneOfOptions() *dpb.OneofOptions { +func (od *OneOfDescriptor) GetOneOfOptions() *descriptorpb.OneofOptions { return od.proto.GetOptions() } @@ -1659,7 +1780,7 @@ func (od *OneOfDescriptor) GetOneOfOptions() *dpb.OneofOptions { // returned info contains information about the location in the file where the // one-of was defined and also contains comments associated with the one-of // definition. -func (od *OneOfDescriptor) GetSourceInfo() *dpb.SourceCodeInfo_Location { +func (od *OneOfDescriptor) GetSourceInfo() *descriptorpb.SourceCodeInfo_Location { return od.file.sourceInfo.Get(od.sourceInfoPath) } @@ -1671,7 +1792,7 @@ func (od *OneOfDescriptor) AsProto() proto.Message { } // AsOneofDescriptorProto returns the underlying descriptor proto. -func (od *OneOfDescriptor) AsOneofDescriptorProto() *dpb.OneofDescriptorProto { +func (od *OneOfDescriptor) AsOneofDescriptorProto() *descriptorpb.OneofDescriptorProto { return od.proto } @@ -1687,88 +1808,28 @@ func (od *OneOfDescriptor) GetChoices() []*FieldDescriptor { } func (od *OneOfDescriptor) IsSynthetic() bool { - return len(od.choices) == 1 && od.choices[0].IsProto3Optional() -} - -// scope represents a lexical scope in a proto file in which messages and enums -// can be declared. -type scope func(string) Descriptor - -func fileScope(fd *FileDescriptor) scope { - // we search symbols in this file, but also symbols in other files that have - // the same package as this file or a "parent" package (in protobuf, - // packages are a hierarchy like C++ namespaces) - prefixes := internal.CreatePrefixList(fd.proto.GetPackage()) - return func(name string) Descriptor { - for _, prefix := range prefixes { - n := merge(prefix, name) - d := findSymbol(fd, n, false) - if d != nil { - return d - } - } - return nil - } + return od.wrapped.IsSynthetic() } -func messageScope(md *MessageDescriptor) scope { - return func(name string) Descriptor { - n := merge(md.fqn, name) - if d, ok := md.file.symbols[n]; ok { - return d - } - return nil +func resolve(fd *FileDescriptor, src protoreflect.Descriptor, cache descriptorCache) (Descriptor, error) { + d := cache.get(src) + if d != nil { + return d, nil } -} -func resolve(fd *FileDescriptor, name string, scopes []scope) (Descriptor, error) { - if strings.HasPrefix(name, ".") { - // already fully-qualified - d := findSymbol(fd, name[1:], false) - if d != nil { - return d, nil - } - } else { - // unqualified, so we look in the enclosing (last) scope first and move - // towards outermost (first) scope, trying to resolve the symbol - for i := len(scopes) - 1; i >= 0; i-- { - d := scopes[i](name) - if d != nil { - return d, nil - } - } - } - return nil, fmt.Errorf("file %q included an unresolvable reference to %q", fd.proto.GetName(), name) -} + fqn := string(src.FullName()) -func findSymbol(fd *FileDescriptor, name string, public bool) Descriptor { - d := fd.symbols[name] + d = fd.FindSymbol(fqn) if d != nil { - return d + return d, nil } - // When public = false, we are searching only directly imported symbols. But we - // also need to search transitive public imports due to semantics of public imports. - var deps []*FileDescriptor - if public { - deps = fd.publicDeps - } else { - deps = fd.deps - } - for _, dep := range deps { - d = findSymbol(dep, name, true) + for _, dep := range fd.deps { + d := dep.FindSymbol(fqn) if d != nil { - return d + return d, nil } } - return nil -} - -func merge(a, b string) string { - if a == "" { - return b - } else { - return a + "." + b - } + return nil, fmt.Errorf("file %q included an unresolvable reference to %q", fd.proto.GetName(), fqn) } diff --git a/vendor/github.com/jhump/protoreflect/desc/imports.go b/vendor/github.com/jhump/protoreflect/desc/imports.go index 0cace1f48f9..8e6a0d6e011 100644 --- a/vendor/github.com/jhump/protoreflect/desc/imports.go +++ b/vendor/github.com/jhump/protoreflect/desc/imports.go @@ -8,7 +8,8 @@ import ( "sync" "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" ) var ( @@ -33,12 +34,16 @@ var ( // package or when the alternate path is only used from one file (so you don't // want the alternate path used when loading every other file), use an // ImportResolver instead. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func RegisterImportPath(registerPath, importPath string) { if len(importPath) == 0 { panic("import path cannot be empty") } - desc := proto.FileDescriptor(registerPath) - if len(desc) == 0 { + _, err := protoregistry.GlobalFiles.FindFileByPath(registerPath) + if err != nil { panic(fmt.Sprintf("path %q is not a registered proto file", registerPath)) } globalImportPathMu.Lock() @@ -55,6 +60,10 @@ func RegisterImportPath(registerPath, importPath string) { // ResolveImport resolves the given import path. If it has been registered as an // alternate via RegisterImportPath, the registered path is returned. Otherwise, // the given import path is returned unchanged. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func ResolveImport(importPath string) string { importPath = clean(importPath) globalImportPathMu.RLock() @@ -106,6 +115,10 @@ func ResolveImport(importPath string) string { // path then how they are registered, consider using the global // RegisterImportPath function, so you don't have to use an ImportResolver for // every file that imports it. +// +// Note that the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// customizing import paths for descriptor resolution is no longer necessary. type ImportResolver struct { children map[string]*ImportResolver importPaths map[string]string @@ -231,77 +244,105 @@ func (r *ImportResolver) registerImportPathFrom(registerPath, importPath, source // LoadFileDescriptor is the same as the package function of the same name, but // any alternate paths configured in this resolver are used when linking the // given descriptor proto. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func (r *ImportResolver) LoadFileDescriptor(filePath string) (*FileDescriptor, error) { - return loadFileDescriptor(filePath, r) + return LoadFileDescriptor(filePath) } // LoadMessageDescriptor is the same as the package function of the same name, // but any alternate paths configured in this resolver are used when linking // files for the returned descriptor. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func (r *ImportResolver) LoadMessageDescriptor(msgName string) (*MessageDescriptor, error) { - return loadMessageDescriptor(msgName, r) + return LoadMessageDescriptor(msgName) } // LoadMessageDescriptorForMessage is the same as the package function of the // same name, but any alternate paths configured in this resolver are used when // linking files for the returned descriptor. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func (r *ImportResolver) LoadMessageDescriptorForMessage(msg proto.Message) (*MessageDescriptor, error) { - return loadMessageDescriptorForMessage(msg, r) + return LoadMessageDescriptorForMessage(msg) } // LoadMessageDescriptorForType is the same as the package function of the same // name, but any alternate paths configured in this resolver are used when // linking files for the returned descriptor. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func (r *ImportResolver) LoadMessageDescriptorForType(msgType reflect.Type) (*MessageDescriptor, error) { - return loadMessageDescriptorForType(msgType, r) + return LoadMessageDescriptorForType(msgType) } // LoadEnumDescriptorForEnum is the same as the package function of the same // name, but any alternate paths configured in this resolver are used when // linking files for the returned descriptor. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func (r *ImportResolver) LoadEnumDescriptorForEnum(enum protoEnum) (*EnumDescriptor, error) { - return loadEnumDescriptorForEnum(enum, r) + return LoadEnumDescriptorForEnum(enum) } // LoadEnumDescriptorForType is the same as the package function of the same // name, but any alternate paths configured in this resolver are used when // linking files for the returned descriptor. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func (r *ImportResolver) LoadEnumDescriptorForType(enumType reflect.Type) (*EnumDescriptor, error) { - return loadEnumDescriptorForType(enumType, r) + return LoadEnumDescriptorForType(enumType) } // LoadFieldDescriptorForExtension is the same as the package function of the // same name, but any alternate paths configured in this resolver are used when // linking files for the returned descriptor. +// +// Deprecated: the new protobuf runtime (v1.4+) verifies that import paths are +// correct and that descriptors can be linked during package initialization. So +// registering alternate paths is no longer useful or necessary. func (r *ImportResolver) LoadFieldDescriptorForExtension(ext *proto.ExtensionDesc) (*FieldDescriptor, error) { - return loadFieldDescriptorForExtension(ext, r) + return LoadFieldDescriptorForExtension(ext) } // CreateFileDescriptor is the same as the package function of the same name, // but any alternate paths configured in this resolver are used when linking the // given descriptor proto. -func (r *ImportResolver) CreateFileDescriptor(fdp *dpb.FileDescriptorProto, deps ...*FileDescriptor) (*FileDescriptor, error) { +func (r *ImportResolver) CreateFileDescriptor(fdp *descriptorpb.FileDescriptorProto, deps ...*FileDescriptor) (*FileDescriptor, error) { return createFileDescriptor(fdp, deps, r) } // CreateFileDescriptors is the same as the package function of the same name, // but any alternate paths configured in this resolver are used when linking the // given descriptor protos. -func (r *ImportResolver) CreateFileDescriptors(fds []*dpb.FileDescriptorProto) (map[string]*FileDescriptor, error) { +func (r *ImportResolver) CreateFileDescriptors(fds []*descriptorpb.FileDescriptorProto) (map[string]*FileDescriptor, error) { return createFileDescriptors(fds, r) } // CreateFileDescriptorFromSet is the same as the package function of the same // name, but any alternate paths configured in this resolver are used when // linking the descriptor protos in the given set. -func (r *ImportResolver) CreateFileDescriptorFromSet(fds *dpb.FileDescriptorSet) (*FileDescriptor, error) { +func (r *ImportResolver) CreateFileDescriptorFromSet(fds *descriptorpb.FileDescriptorSet) (*FileDescriptor, error) { return createFileDescriptorFromSet(fds, r) } // CreateFileDescriptorsFromSet is the same as the package function of the same // name, but any alternate paths configured in this resolver are used when // linking the descriptor protos in the given set. -func (r *ImportResolver) CreateFileDescriptorsFromSet(fds *dpb.FileDescriptorSet) (map[string]*FileDescriptor, error) { +func (r *ImportResolver) CreateFileDescriptorsFromSet(fds *descriptorpb.FileDescriptorSet) (map[string]*FileDescriptor, error) { return createFileDescriptorsFromSet(fds, r) } diff --git a/vendor/github.com/jhump/protoreflect/desc/internal/proto3_optional.go b/vendor/github.com/jhump/protoreflect/desc/internal/proto3_optional.go index 2d4997525cd..aa8c3e993d5 100644 --- a/vendor/github.com/jhump/protoreflect/desc/internal/proto3_optional.go +++ b/vendor/github.com/jhump/protoreflect/desc/internal/proto3_optional.go @@ -1,16 +1,17 @@ package internal import ( - "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" "strings" + + "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/types/descriptorpb" ) // ProcessProto3OptionalFields adds synthetic oneofs to the given message descriptor // for each proto3 optional field. It also updates the fields to have the correct // oneof index reference. The given callback, if not nil, is called for each synthetic // oneof created. -func ProcessProto3OptionalFields(msgd *dpb.DescriptorProto, callback func(*dpb.FieldDescriptorProto, *dpb.OneofDescriptorProto)) { +func ProcessProto3OptionalFields(msgd *descriptorpb.DescriptorProto, callback func(*descriptorpb.FieldDescriptorProto, *descriptorpb.OneofDescriptorProto)) { var allNames map[string]struct{} for _, fd := range msgd.Field { if fd.GetProto3Optional() { @@ -64,7 +65,7 @@ func ProcessProto3OptionalFields(msgd *dpb.DescriptorProto, callback func(*dpb.F } fd.OneofIndex = proto.Int32(int32(len(msgd.OneofDecl))) - ood := &dpb.OneofDescriptorProto{Name: proto.String(ooName)} + ood := &descriptorpb.OneofDescriptorProto{Name: proto.String(ooName)} msgd.OneofDecl = append(msgd.OneofDecl, ood) if callback != nil { callback(fd, ood) diff --git a/vendor/github.com/jhump/protoreflect/desc/internal/registry.go b/vendor/github.com/jhump/protoreflect/desc/internal/registry.go new file mode 100644 index 00000000000..9f160a3e5cb --- /dev/null +++ b/vendor/github.com/jhump/protoreflect/desc/internal/registry.go @@ -0,0 +1,48 @@ +package internal + +import ( + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/dynamicpb" +) + +func RegisterExtensionsForFile(reg *protoregistry.Types, fd protoreflect.FileDescriptor) { + registerTypesForFile(reg, fd, true, false) +} + +func RegisterTypesForFile(reg *protoregistry.Types, fd protoreflect.FileDescriptor) { + registerTypesForFile(reg, fd, false, false) +} + +func registerTypesForFile(reg *protoregistry.Types, fd protoreflect.FileDescriptor, extensionsOnly, publicImportsOnly bool) { + registerTypes(reg, fd, extensionsOnly) + for i := 0; i < fd.Imports().Len(); i++ { + imp := fd.Imports().Get(i) + if imp.IsPublic || !publicImportsOnly { + registerTypesForFile(reg, imp, extensionsOnly, true) + } + } +} + +func registerTypes(reg *protoregistry.Types, elem fileOrMessage, extensionsOnly bool) { + for i := 0; i < elem.Extensions().Len(); i++ { + _ = reg.RegisterExtension(dynamicpb.NewExtensionType(elem.Extensions().Get(i))) + } + if !extensionsOnly { + for i := 0; i < elem.Messages().Len(); i++ { + _ = reg.RegisterMessage(dynamicpb.NewMessageType(elem.Messages().Get(i))) + } + for i := 0; i < elem.Enums().Len(); i++ { + _ = reg.RegisterEnum(dynamicpb.NewEnumType(elem.Enums().Get(i))) + } + } + for i := 0; i < elem.Messages().Len(); i++ { + registerTypes(reg, elem.Messages().Get(i), extensionsOnly) + } +} + +type fileOrMessage interface { + Extensions() protoreflect.ExtensionDescriptors + Messages() protoreflect.MessageDescriptors + Enums() protoreflect.EnumDescriptors +} diff --git a/vendor/github.com/jhump/protoreflect/desc/internal/source_info.go b/vendor/github.com/jhump/protoreflect/desc/internal/source_info.go index b4150b83b4f..60371288850 100644 --- a/vendor/github.com/jhump/protoreflect/desc/internal/source_info.go +++ b/vendor/github.com/jhump/protoreflect/desc/internal/source_info.go @@ -1,16 +1,16 @@ package internal import ( - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "google.golang.org/protobuf/types/descriptorpb" ) // SourceInfoMap is a map of paths in a descriptor to the corresponding source // code info. -type SourceInfoMap map[string][]*dpb.SourceCodeInfo_Location +type SourceInfoMap map[string][]*descriptorpb.SourceCodeInfo_Location // Get returns the source code info for the given path. If there are // multiple locations for the same path, the first one is returned. -func (m SourceInfoMap) Get(path []int32) *dpb.SourceCodeInfo_Location { +func (m SourceInfoMap) Get(path []int32) *descriptorpb.SourceCodeInfo_Location { v := m[asMapKey(path)] if len(v) > 0 { return v[0] @@ -19,24 +19,24 @@ func (m SourceInfoMap) Get(path []int32) *dpb.SourceCodeInfo_Location { } // GetAll returns all source code info for the given path. -func (m SourceInfoMap) GetAll(path []int32) []*dpb.SourceCodeInfo_Location { +func (m SourceInfoMap) GetAll(path []int32) []*descriptorpb.SourceCodeInfo_Location { return m[asMapKey(path)] } // Add stores the given source code info for the given path. -func (m SourceInfoMap) Add(path []int32, loc *dpb.SourceCodeInfo_Location) { +func (m SourceInfoMap) Add(path []int32, loc *descriptorpb.SourceCodeInfo_Location) { m[asMapKey(path)] = append(m[asMapKey(path)], loc) } // PutIfAbsent stores the given source code info for the given path only if the // given path does not exist in the map. This method returns true when the value // is stored, false if the path already exists. -func (m SourceInfoMap) PutIfAbsent(path []int32, loc *dpb.SourceCodeInfo_Location) bool { +func (m SourceInfoMap) PutIfAbsent(path []int32, loc *descriptorpb.SourceCodeInfo_Location) bool { k := asMapKey(path) if _, ok := m[k]; ok { return false } - m[k] = []*dpb.SourceCodeInfo_Location{loc} + m[k] = []*descriptorpb.SourceCodeInfo_Location{loc} return true } @@ -63,7 +63,7 @@ func asMapKey(slice []int32) string { // CreateSourceInfoMap constructs a new SourceInfoMap and populates it with the // source code info in the given file descriptor proto. -func CreateSourceInfoMap(fd *dpb.FileDescriptorProto) SourceInfoMap { +func CreateSourceInfoMap(fd *descriptorpb.FileDescriptorProto) SourceInfoMap { res := SourceInfoMap{} PopulateSourceInfoMap(fd, res) return res @@ -71,7 +71,7 @@ func CreateSourceInfoMap(fd *dpb.FileDescriptorProto) SourceInfoMap { // PopulateSourceInfoMap populates the given SourceInfoMap with information from // the given file descriptor. -func PopulateSourceInfoMap(fd *dpb.FileDescriptorProto, m SourceInfoMap) { +func PopulateSourceInfoMap(fd *descriptorpb.FileDescriptorProto, m SourceInfoMap) { for _, l := range fd.GetSourceCodeInfo().GetLocation() { m.Add(l.Path, l) } diff --git a/vendor/github.com/jhump/protoreflect/desc/load.go b/vendor/github.com/jhump/protoreflect/desc/load.go index 24d3e9b5e0e..193bbe887a7 100644 --- a/vendor/github.com/jhump/protoreflect/desc/load.go +++ b/vendor/github.com/jhump/protoreflect/desc/load.go @@ -6,147 +6,110 @@ import ( "sync" "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" "github.com/jhump/protoreflect/desc/sourceinfo" "github.com/jhump/protoreflect/internal" ) +// The global cache is used to store descriptors that wrap items in +// protoregistry.GlobalTypes and protoregistry.GlobalFiles. This prevents +// repeating work to re-wrap underlying global descriptors. var ( - cacheMu sync.RWMutex - filesCache = map[string]*FileDescriptor{} - messagesCache = map[string]*MessageDescriptor{} - enumCache = map[reflect.Type]*EnumDescriptor{} + // We put all wrapped file and message descriptors in this cache. + loadedDescriptors = lockingCache{cache: mapCache{}} + + // Unfortunately, we need a different mechanism for enums for + // compatibility with old APIs, which required that they were + // registered in a different way :( + loadedEnumsMu sync.RWMutex + loadedEnums = map[reflect.Type]*EnumDescriptor{} ) // LoadFileDescriptor creates a file descriptor using the bytes returned by // proto.FileDescriptor. Descriptors are cached so that they do not need to be // re-processed if the same file is fetched again later. func LoadFileDescriptor(file string) (*FileDescriptor, error) { - return loadFileDescriptor(file, nil) -} - -func loadFileDescriptor(file string, r *ImportResolver) (*FileDescriptor, error) { - f := getFileFromCache(file) - if f != nil { - return f, nil - } - cacheMu.Lock() - defer cacheMu.Unlock() - return loadFileDescriptorLocked(file, r) -} - -func loadFileDescriptorLocked(file string, r *ImportResolver) (*FileDescriptor, error) { - f := filesCache[file] - if f != nil { - return f, nil + d, err := sourceinfo.GlobalFiles.FindFileByPath(file) + if err == protoregistry.NotFound { + // for backwards compatibility, see if this matches a known old + // alias for the file (older versions of libraries that registered + // the files using incorrect/non-canonical paths) + if alt := internal.StdFileAliases[file]; alt != "" { + d, err = sourceinfo.GlobalFiles.FindFileByPath(alt) + } } - fd, err := internal.LoadFileDescriptor(file) if err != nil { + if err != protoregistry.NotFound { + return nil, internal.ErrNoSuchFile(file) + } return nil, err } - - f, err = toFileDescriptorLocked(fd, r) - if err != nil { - return nil, err + if fd := loadedDescriptors.get(d); fd != nil { + return fd.(*FileDescriptor), nil } - putCacheLocked(file, f) - return f, nil -} -func toFileDescriptorLocked(fd *dpb.FileDescriptorProto, r *ImportResolver) (*FileDescriptor, error) { - fd.SourceCodeInfo = sourceinfo.SourceInfoForFile(fd.GetName()) - deps := make([]*FileDescriptor, len(fd.GetDependency())) - for i, dep := range fd.GetDependency() { - resolvedDep := r.ResolveImport(fd.GetName(), dep) - var err error - deps[i], err = loadFileDescriptorLocked(resolvedDep, r) - if _, ok := err.(internal.ErrNoSuchFile); ok && resolvedDep != dep { - // try original path - deps[i], err = loadFileDescriptorLocked(dep, r) - } - if err != nil { - return nil, err + var fd *FileDescriptor + loadedDescriptors.withLock(func(cache descriptorCache) { + // double-check cache, in case it was concurrently added while + // we were waiting for the lock + f := cache.get(d) + if f != nil { + fd = f.(*FileDescriptor) + return } - } - return CreateFileDescriptor(fd, deps...) -} - -func getFileFromCache(file string) *FileDescriptor { - cacheMu.RLock() - defer cacheMu.RUnlock() - return filesCache[file] -} - -func putCacheLocked(filename string, fd *FileDescriptor) { - filesCache[filename] = fd - putMessageCacheLocked(fd.messages) -} - -func putMessageCacheLocked(mds []*MessageDescriptor) { - for _, md := range mds { - messagesCache[md.fqn] = md - putMessageCacheLocked(md.nested) - } -} - -// interface implemented by generated messages, which all have a Descriptor() method in -// addition to the methods of proto.Message -type protoMessage interface { - proto.Message - Descriptor() ([]byte, []int) + fd, err = wrapFile(d, cache) + }) + return fd, err } // LoadMessageDescriptor loads descriptor using the encoded descriptor proto returned by // Message.Descriptor() for the given message type. If the given type is not recognized, // then a nil descriptor is returned. func LoadMessageDescriptor(message string) (*MessageDescriptor, error) { - return loadMessageDescriptor(message, nil) + mt, err := sourceinfo.GlobalTypes.FindMessageByName(protoreflect.FullName(message)) + if err != nil { + if err == protoregistry.NotFound { + return nil, nil + } + return nil, err + } + return loadMessageDescriptor(mt.Descriptor()) } -func loadMessageDescriptor(message string, r *ImportResolver) (*MessageDescriptor, error) { - m := getMessageFromCache(message) - if m != nil { - return m, nil +func loadMessageDescriptor(md protoreflect.MessageDescriptor) (*MessageDescriptor, error) { + d := loadedDescriptors.get(md) + if d != nil { + return d.(*MessageDescriptor), nil } - pt := proto.MessageType(message) - if pt == nil { - return nil, nil - } - msg, err := messageFromType(pt) + var err error + loadedDescriptors.withLock(func(cache descriptorCache) { + d, err = wrapMessage(md, cache) + }) if err != nil { return nil, err } - - cacheMu.Lock() - defer cacheMu.Unlock() - return loadMessageDescriptorForTypeLocked(message, msg, r) + return d.(*MessageDescriptor), err } // LoadMessageDescriptorForType loads descriptor using the encoded descriptor proto returned // by message.Descriptor() for the given message type. If the given type is not recognized, // then a nil descriptor is returned. func LoadMessageDescriptorForType(messageType reflect.Type) (*MessageDescriptor, error) { - return loadMessageDescriptorForType(messageType, nil) -} - -func loadMessageDescriptorForType(messageType reflect.Type, r *ImportResolver) (*MessageDescriptor, error) { m, err := messageFromType(messageType) if err != nil { return nil, err } - return loadMessageDescriptorForMessage(m, r) + return LoadMessageDescriptorForMessage(m) } // LoadMessageDescriptorForMessage loads descriptor using the encoded descriptor proto // returned by message.Descriptor(). If the given type is not recognized, then a nil // descriptor is returned. func LoadMessageDescriptorForMessage(message proto.Message) (*MessageDescriptor, error) { - return loadMessageDescriptorForMessage(message, nil) -} - -func loadMessageDescriptorForMessage(message proto.Message, r *ImportResolver) (*MessageDescriptor, error) { // efficiently handle dynamic messages type descriptorable interface { GetMessageDescriptor() *MessageDescriptor @@ -155,57 +118,26 @@ func loadMessageDescriptorForMessage(message proto.Message, r *ImportResolver) ( return d.GetMessageDescriptor(), nil } - name := proto.MessageName(message) - if name == "" { - return nil, nil + var md protoreflect.MessageDescriptor + if m, ok := message.(protoreflect.ProtoMessage); ok { + md = m.ProtoReflect().Descriptor() + } else { + md = proto.MessageReflect(message).Descriptor() } - m := getMessageFromCache(name) - if m != nil { - return m, nil - } - - cacheMu.Lock() - defer cacheMu.Unlock() - return loadMessageDescriptorForTypeLocked(name, message.(protoMessage), nil) + return loadMessageDescriptor(sourceinfo.WrapMessage(md)) } -func messageFromType(mt reflect.Type) (protoMessage, error) { +func messageFromType(mt reflect.Type) (proto.Message, error) { if mt.Kind() != reflect.Ptr { mt = reflect.PtrTo(mt) } - m, ok := reflect.Zero(mt).Interface().(protoMessage) + m, ok := reflect.Zero(mt).Interface().(proto.Message) if !ok { return nil, fmt.Errorf("failed to create message from type: %v", mt) } return m, nil } -func loadMessageDescriptorForTypeLocked(name string, message protoMessage, r *ImportResolver) (*MessageDescriptor, error) { - m := messagesCache[name] - if m != nil { - return m, nil - } - - fdb, _ := message.Descriptor() - fd, err := internal.DecodeFileDescriptor(name, fdb) - if err != nil { - return nil, err - } - - f, err := toFileDescriptorLocked(fd, r) - if err != nil { - return nil, err - } - putCacheLocked(fd.GetName(), f) - return f.FindSymbol(name).(*MessageDescriptor), nil -} - -func getMessageFromCache(message string) *MessageDescriptor { - cacheMu.RLock() - defer cacheMu.RUnlock() - return messagesCache[message] -} - // interface implemented by all generated enums type protoEnum interface { EnumDescriptor() ([]byte, []int) @@ -222,10 +154,6 @@ type protoEnum interface { // LoadEnumDescriptorForType loads descriptor using the encoded descriptor proto returned // by enum.EnumDescriptor() for the given enum type. func LoadEnumDescriptorForType(enumType reflect.Type) (*EnumDescriptor, error) { - return loadEnumDescriptorForType(enumType, nil) -} - -func loadEnumDescriptorForType(enumType reflect.Type, r *ImportResolver) (*EnumDescriptor, error) { // we cache descriptors using non-pointer type if enumType.Kind() == reflect.Ptr { enumType = enumType.Elem() @@ -239,18 +167,24 @@ func loadEnumDescriptorForType(enumType reflect.Type, r *ImportResolver) (*EnumD return nil, err } - cacheMu.Lock() - defer cacheMu.Unlock() - return loadEnumDescriptorForTypeLocked(enumType, enum, r) + return loadEnumDescriptor(enumType, enum) +} + +func getEnumFromCache(t reflect.Type) *EnumDescriptor { + loadedEnumsMu.RLock() + defer loadedEnumsMu.RUnlock() + return loadedEnums[t] +} + +func putEnumInCache(t reflect.Type, d *EnumDescriptor) { + loadedEnumsMu.Lock() + defer loadedEnumsMu.Unlock() + loadedEnums[t] = d } // LoadEnumDescriptorForEnum loads descriptor using the encoded descriptor proto // returned by enum.EnumDescriptor(). func LoadEnumDescriptorForEnum(enum protoEnum) (*EnumDescriptor, error) { - return loadEnumDescriptorForEnum(enum, nil) -} - -func loadEnumDescriptorForEnum(enum protoEnum, r *ImportResolver) (*EnumDescriptor, error) { et := reflect.TypeOf(enum) // we cache descriptors using non-pointer type if et.Kind() == reflect.Ptr { @@ -262,55 +196,46 @@ func loadEnumDescriptorForEnum(enum protoEnum, r *ImportResolver) (*EnumDescript return e, nil } - cacheMu.Lock() - defer cacheMu.Unlock() - return loadEnumDescriptorForTypeLocked(et, enum, r) + return loadEnumDescriptor(et, enum) } func enumFromType(et reflect.Type) (protoEnum, error) { - if et.Kind() != reflect.Int32 { - et = reflect.PtrTo(et) - } e, ok := reflect.Zero(et).Interface().(protoEnum) + if !ok { + if et.Kind() != reflect.Ptr { + et = et.Elem() + } + e, ok = reflect.Zero(et).Interface().(protoEnum) + } if !ok { return nil, fmt.Errorf("failed to create enum from type: %v", et) } return e, nil } -func loadEnumDescriptorForTypeLocked(et reflect.Type, enum protoEnum, r *ImportResolver) (*EnumDescriptor, error) { - e := enumCache[et] - if e != nil { - return e, nil - } - +func getDescriptorForEnum(enum protoEnum) (*descriptorpb.FileDescriptorProto, []int, error) { fdb, path := enum.EnumDescriptor() - name := fmt.Sprintf("%v", et) + name := fmt.Sprintf("%T", enum) fd, err := internal.DecodeFileDescriptor(name, fdb) + return fd, path, err +} + +func loadEnumDescriptor(et reflect.Type, enum protoEnum) (*EnumDescriptor, error) { + fdp, path, err := getDescriptorForEnum(enum) if err != nil { return nil, err } - // see if we already have cached "rich" descriptor - f, ok := filesCache[fd.GetName()] - if !ok { - f, err = toFileDescriptorLocked(fd, r) - if err != nil { - return nil, err - } - putCacheLocked(fd.GetName(), f) + + fd, err := LoadFileDescriptor(fdp.GetName()) + if err != nil { + return nil, err } - ed := findEnum(f, path) - enumCache[et] = ed + ed := findEnum(fd, path) + putEnumInCache(et, ed) return ed, nil } -func getEnumFromCache(et reflect.Type) *EnumDescriptor { - cacheMu.RLock() - defer cacheMu.RUnlock() - return enumCache[et] -} - func findEnum(fd *FileDescriptor, path []int) *EnumDescriptor { if len(path) == 1 { return fd.GetEnumTypes()[path[0]] @@ -325,11 +250,7 @@ func findEnum(fd *FileDescriptor, path []int) *EnumDescriptor { // LoadFieldDescriptorForExtension loads the field descriptor that corresponds to the given // extension description. func LoadFieldDescriptorForExtension(ext *proto.ExtensionDesc) (*FieldDescriptor, error) { - return loadFieldDescriptorForExtension(ext, nil) -} - -func loadFieldDescriptorForExtension(ext *proto.ExtensionDesc, r *ImportResolver) (*FieldDescriptor, error) { - file, err := loadFileDescriptor(ext.Filename, r) + file, err := LoadFileDescriptor(ext.Filename) if err != nil { return nil, err } diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/ast.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/ast.go index 6a39e754710..0bc0938740c 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/ast.go +++ b/vendor/github.com/jhump/protoreflect/desc/protoparse/ast.go @@ -1,205 +1,724 @@ package protoparse -import "github.com/jhump/protoreflect/desc/protoparse/ast" +import ( + "fmt" -// SourcePos is the same as ast.SourcePos. This alias exists for -// backwards compatibility (SourcePos used to be defined in this package.) -type SourcePos = ast.SourcePos + "github.com/bufbuild/protocompile/ast" -// the types below are accumulator types: linked lists that are -// constructed during parsing and then converted to slices of AST nodes -// once the whole list has been parsed + ast2 "github.com/jhump/protoreflect/desc/protoparse/ast" +) -type compactOptionList struct { - option *ast.OptionNode - comma *ast.RuneNode - next *compactOptionList +func convertAST(file *ast.FileNode) *ast2.FileNode { + elements := make([]ast2.FileElement, len(file.Decls)) + for i := range file.Decls { + elements[i] = convertASTFileElement(file, file.Decls[i]) + } + root := ast2.NewFileNode(convertASTSyntax(file, file.Syntax), elements) + eofInfo := file.NodeInfo(file.EOF) + root.FinalComments = convertASTComments(eofInfo.LeadingComments()) + root.FinalWhitespace = eofInfo.LeadingWhitespace() + return root +} + +func convertASTSyntax(f *ast.FileNode, s *ast.SyntaxNode) *ast2.SyntaxNode { + return ast2.NewSyntaxNode( + convertASTKeyword(f, s.Keyword), + convertASTRune(f, s.Equals), + convertASTString(f, s.Syntax), + convertASTRune(f, s.Semicolon), + ) } -func (list *compactOptionList) toNodes() ([]*ast.OptionNode, []*ast.RuneNode) { - l := 0 - for cur := list; cur != nil; cur = cur.next { - l++ +func convertASTFileElement(f *ast.FileNode, el ast.FileElement) ast2.FileElement { + switch el := el.(type) { + case *ast.ImportNode: + return convertASTImport(f, el) + case *ast.PackageNode: + return convertASTPackage(f, el) + case *ast.OptionNode: + return convertASTOption(f, el) + case *ast.MessageNode: + return convertASTMessage(f, el) + case *ast.EnumNode: + return convertASTEnum(f, el) + case *ast.ExtendNode: + return convertASTExtend(f, el) + case *ast.ServiceNode: + return convertASTService(f, el) + case *ast.EmptyDeclNode: + return convertASTEmpty(f, el) + default: + panic(fmt.Sprintf("unrecognized type of ast.FileElement: %T", el)) } - opts := make([]*ast.OptionNode, l) - commas := make([]*ast.RuneNode, l-1) - for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { - opts[i] = cur.option - if cur.comma != nil { - commas[i] = cur.comma - } +} + +func convertASTImport(f *ast.FileNode, imp *ast.ImportNode) *ast2.ImportNode { + var public, weak *ast2.KeywordNode + if imp.Public != nil { + public = convertASTKeyword(f, imp.Public) + } + if imp.Weak != nil { + weak = convertASTKeyword(f, imp.Weak) } - return opts, commas + return ast2.NewImportNode( + convertASTKeyword(f, imp.Keyword), + public, weak, + convertASTString(f, imp.Name), + convertASTRune(f, imp.Semicolon), + ) } -type stringList struct { - str *ast.StringLiteralNode - next *stringList +func convertASTPackage(f *ast.FileNode, p *ast.PackageNode) *ast2.PackageNode { + return ast2.NewPackageNode( + convertASTKeyword(f, p.Keyword), + convertASTIdent(f, p.Name), + convertASTRune(f, p.Semicolon), + ) } -func (list *stringList) toStringValueNode() ast.StringValueNode { - if list.next == nil { - // single name - return list.str +func convertASTOption(f *ast.FileNode, o *ast.OptionNode) *ast2.OptionNode { + if o.Keyword == nil { + return ast2.NewCompactOptionNode( + convertASTOptionName(f, o.Name), + convertASTRune(f, o.Equals), + convertASTValue(f, o.Val), + ) } + return ast2.NewOptionNode( + convertASTKeyword(f, o.Keyword), + convertASTOptionName(f, o.Name), + convertASTRune(f, o.Equals), + convertASTValue(f, o.Val), + convertASTRune(f, o.Semicolon), + ) +} - l := 0 - for cur := list; cur != nil; cur = cur.next { - l++ +func convertASTOptionName(f *ast.FileNode, n *ast.OptionNameNode) *ast2.OptionNameNode { + parts := make([]*ast2.FieldReferenceNode, len(n.Parts)) + for i := range n.Parts { + parts[i] = convertASTFieldReference(f, n.Parts[i]) } - strs := make([]*ast.StringLiteralNode, l) - for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { - strs[i] = cur.str + dots := make([]*ast2.RuneNode, len(n.Dots)) + for i := range n.Dots { + dots[i] = convertASTRune(f, n.Dots[i]) } - return ast.NewCompoundLiteralStringNode(strs...) + return ast2.NewOptionNameNode(parts, dots) } -type nameList struct { - name ast.StringValueNode - comma *ast.RuneNode - next *nameList +func convertASTFieldReference(f *ast.FileNode, n *ast.FieldReferenceNode) *ast2.FieldReferenceNode { + switch { + case n.IsExtension(): + return ast2.NewExtensionFieldReferenceNode( + convertASTRune(f, n.Open), + convertASTIdent(f, n.Name), + convertASTRune(f, n.Close), + ) + case n.IsAnyTypeReference(): + return ast2.NewAnyTypeReferenceNode( + convertASTRune(f, n.Open), + convertASTIdent(f, n.URLPrefix), + convertASTRune(f, n.Slash), + convertASTIdent(f, n.Name), + convertASTRune(f, n.Close), + ) + default: + return ast2.NewFieldReferenceNode(convertASTIdent(f, n.Name).(*ast2.IdentNode)) + } } -func (list *nameList) toNodes() ([]ast.StringValueNode, []*ast.RuneNode) { - l := 0 - for cur := list; cur != nil; cur = cur.next { - l++ +func convertASTMessage(f *ast.FileNode, m *ast.MessageNode) *ast2.MessageNode { + decls := make([]ast2.MessageElement, len(m.Decls)) + for i := range m.Decls { + decls[i] = convertASTMessageElement(f, m.Decls[i]) } - names := make([]ast.StringValueNode, l) - commas := make([]*ast.RuneNode, l-1) - for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { - names[i] = cur.name - if cur.comma != nil { - commas[i] = cur.comma - } + return ast2.NewMessageNode( + convertASTKeyword(f, m.Keyword), + convertASTIdentToken(f, m.Name), + convertASTRune(f, m.OpenBrace), + decls, + convertASTRune(f, m.CloseBrace), + ) +} + +func convertASTMessageElement(f *ast.FileNode, el ast.MessageElement) ast2.MessageElement { + switch el := el.(type) { + case *ast.OptionNode: + return convertASTOption(f, el) + case *ast.FieldNode: + return convertASTField(f, el) + case *ast.MapFieldNode: + return convertASTMapField(f, el) + case *ast.OneOfNode: + return convertASTOneOf(f, el) + case *ast.GroupNode: + return convertASTGroup(f, el) + case *ast.MessageNode: + return convertASTMessage(f, el) + case *ast.EnumNode: + return convertASTEnum(f, el) + case *ast.ExtendNode: + return convertASTExtend(f, el) + case *ast.ExtensionRangeNode: + return convertASTExtensions(f, el) + case *ast.ReservedNode: + return convertASTReserved(f, el) + case *ast.EmptyDeclNode: + return convertASTEmpty(f, el) + default: + panic(fmt.Sprintf("unrecognized type of ast.MessageElement: %T", el)) + } +} + +func convertASTField(f *ast.FileNode, fld *ast.FieldNode) *ast2.FieldNode { + var lbl *ast2.KeywordNode + if fld.Label.KeywordNode != nil { + lbl = convertASTKeyword(f, fld.Label.KeywordNode) + } + var opts *ast2.CompactOptionsNode + if fld.Options != nil { + opts = convertASTCompactOptions(f, fld.Options) } - return names, commas + return ast2.NewFieldNode( + lbl, + convertASTIdent(f, fld.FldType), + convertASTIdentToken(f, fld.Name), + convertASTRune(f, fld.Equals), + convertASTUintLiteral(f, fld.Tag), + opts, + convertASTRune(f, fld.Semicolon), + ) } -type rangeList struct { - rng *ast.RangeNode - comma *ast.RuneNode - next *rangeList +func convertASTMapField(f *ast.FileNode, fld *ast.MapFieldNode) *ast2.MapFieldNode { + var opts *ast2.CompactOptionsNode + if fld.Options != nil { + opts = convertASTCompactOptions(f, fld.Options) + } + return ast2.NewMapFieldNode( + convertASTMapFieldType(f, fld.MapType), + convertASTIdentToken(f, fld.Name), + convertASTRune(f, fld.Equals), + convertASTUintLiteral(f, fld.Tag), + opts, + convertASTRune(f, fld.Semicolon), + ) } -func (list *rangeList) toNodes() ([]*ast.RangeNode, []*ast.RuneNode) { - l := 0 - for cur := list; cur != nil; cur = cur.next { - l++ +func convertASTMapFieldType(f *ast.FileNode, t *ast.MapTypeNode) *ast2.MapTypeNode { + return ast2.NewMapTypeNode( + convertASTKeyword(f, t.Keyword), + convertASTRune(f, t.OpenAngle), + convertASTIdentToken(f, t.KeyType), + convertASTRune(f, t.Comma), + convertASTIdent(f, t.ValueType), + convertASTRune(f, t.CloseAngle), + ) +} + +func convertASTGroup(f *ast.FileNode, g *ast.GroupNode) *ast2.GroupNode { + var lbl *ast2.KeywordNode + if g.Label.KeywordNode != nil { + lbl = convertASTKeyword(f, g.Label.KeywordNode) } - ranges := make([]*ast.RangeNode, l) - commas := make([]*ast.RuneNode, l-1) - for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { - ranges[i] = cur.rng - if cur.comma != nil { - commas[i] = cur.comma - } + var opts *ast2.CompactOptionsNode + if g.Options != nil { + opts = convertASTCompactOptions(f, g.Options) + } + decls := make([]ast2.MessageElement, len(g.Decls)) + for i := range g.Decls { + decls[i] = convertASTMessageElement(f, g.Decls[i]) } - return ranges, commas + return ast2.NewGroupNode( + lbl, + convertASTKeyword(f, g.Keyword), + convertASTIdentToken(f, g.Name), + convertASTRune(f, g.Equals), + convertASTUintLiteral(f, g.Tag), + opts, + convertASTRune(f, g.OpenBrace), + decls, + convertASTRune(f, g.CloseBrace), + ) } -type valueList struct { - val ast.ValueNode - comma *ast.RuneNode - next *valueList +func convertASTOneOf(f *ast.FileNode, oo *ast.OneOfNode) *ast2.OneOfNode { + decls := make([]ast2.OneOfElement, len(oo.Decls)) + for i := range oo.Decls { + decls[i] = convertASTOneOfElement(f, oo.Decls[i]) + } + return ast2.NewOneOfNode( + convertASTKeyword(f, oo.Keyword), + convertASTIdentToken(f, oo.Name), + convertASTRune(f, oo.OpenBrace), + decls, + convertASTRune(f, oo.CloseBrace), + ) } -func (list *valueList) toNodes() ([]ast.ValueNode, []*ast.RuneNode) { - if list == nil { - return nil, nil +func convertASTOneOfElement(f *ast.FileNode, el ast.OneOfElement) ast2.OneOfElement { + switch el := el.(type) { + case *ast.OptionNode: + return convertASTOption(f, el) + case *ast.FieldNode: + return convertASTField(f, el) + case *ast.GroupNode: + return convertASTGroup(f, el) + case *ast.EmptyDeclNode: + return convertASTEmpty(f, el) + default: + panic(fmt.Sprintf("unrecognized type of ast.OneOfElement: %T", el)) } - l := 0 - for cur := list; cur != nil; cur = cur.next { - l++ +} + +func convertASTExtensions(f *ast.FileNode, e *ast.ExtensionRangeNode) *ast2.ExtensionRangeNode { + var opts *ast2.CompactOptionsNode + if e.Options != nil { + opts = convertASTCompactOptions(f, e.Options) } - vals := make([]ast.ValueNode, l) - commas := make([]*ast.RuneNode, l-1) - for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { - vals[i] = cur.val - if cur.comma != nil { - commas[i] = cur.comma - } + ranges := make([]*ast2.RangeNode, len(e.Ranges)) + for i := range e.Ranges { + ranges[i] = convertASTRange(f, e.Ranges[i]) + } + commas := make([]*ast2.RuneNode, len(e.Commas)) + for i := range e.Commas { + commas[i] = convertASTRune(f, e.Commas[i]) + } + return ast2.NewExtensionRangeNode( + convertASTKeyword(f, e.Keyword), + ranges, commas, opts, + convertASTRune(f, e.Semicolon), + ) +} + +func convertASTReserved(f *ast.FileNode, r *ast.ReservedNode) *ast2.ReservedNode { + ranges := make([]*ast2.RangeNode, len(r.Ranges)) + for i := range r.Ranges { + ranges[i] = convertASTRange(f, r.Ranges[i]) + } + commas := make([]*ast2.RuneNode, len(r.Commas)) + for i := range r.Commas { + commas[i] = convertASTRune(f, r.Commas[i]) + } + names := make([]ast2.StringValueNode, len(r.Names)) + for i := range r.Names { + names[i] = convertASTString(f, r.Names[i]) + } + if len(r.Ranges) > 0 { + return ast2.NewReservedRangesNode( + convertASTKeyword(f, r.Keyword), + ranges, commas, + convertASTRune(f, r.Semicolon), + ) } - return vals, commas + return ast2.NewReservedNamesNode( + convertASTKeyword(f, r.Keyword), + names, commas, + convertASTRune(f, r.Semicolon), + ) } -type fieldRefList struct { - ref *ast.FieldReferenceNode - dot *ast.RuneNode - next *fieldRefList +func convertASTRange(f *ast.FileNode, r *ast.RangeNode) *ast2.RangeNode { + var to, max *ast2.KeywordNode + var end ast2.IntValueNode + if r.To != nil { + to = convertASTKeyword(f, r.To) + } + if r.Max != nil { + max = convertASTKeyword(f, r.Max) + } + if r.EndVal != nil { + end = convertASTInt(f, r.EndVal) + } + return ast2.NewRangeNode( + convertASTInt(f, r.StartVal), + to, end, max, + ) } -func (list *fieldRefList) toNodes() ([]*ast.FieldReferenceNode, []*ast.RuneNode) { - l := 0 - for cur := list; cur != nil; cur = cur.next { - l++ +func convertASTEnum(f *ast.FileNode, e *ast.EnumNode) *ast2.EnumNode { + decls := make([]ast2.EnumElement, len(e.Decls)) + for i := range e.Decls { + decls[i] = convertASTEnumElement(f, e.Decls[i]) } - refs := make([]*ast.FieldReferenceNode, l) - dots := make([]*ast.RuneNode, l-1) - for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { - refs[i] = cur.ref - if cur.dot != nil { - dots[i] = cur.dot - } + return ast2.NewEnumNode( + convertASTKeyword(f, e.Keyword), + convertASTIdentToken(f, e.Name), + convertASTRune(f, e.OpenBrace), + decls, + convertASTRune(f, e.CloseBrace), + ) +} + +func convertASTEnumElement(f *ast.FileNode, el ast.EnumElement) ast2.EnumElement { + switch el := el.(type) { + case *ast.OptionNode: + return convertASTOption(f, el) + case *ast.EnumValueNode: + return convertASTEnumValue(f, el) + case *ast.ReservedNode: + return convertASTReserved(f, el) + case *ast.EmptyDeclNode: + return convertASTEmpty(f, el) + default: + panic(fmt.Sprintf("unrecognized type of ast.EnumElement: %T", el)) } +} - return refs, dots +func convertASTEnumValue(f *ast.FileNode, e *ast.EnumValueNode) *ast2.EnumValueNode { + var opts *ast2.CompactOptionsNode + if e.Options != nil { + opts = convertASTCompactOptions(f, e.Options) + } + return ast2.NewEnumValueNode( + convertASTIdentToken(f, e.Name), + convertASTRune(f, e.Equals), + convertASTInt(f, e.Number), + opts, + convertASTRune(f, e.Semicolon), + ) } -type identList struct { - ident *ast.IdentNode - dot *ast.RuneNode - next *identList +func convertASTExtend(f *ast.FileNode, e *ast.ExtendNode) *ast2.ExtendNode { + decls := make([]ast2.ExtendElement, len(e.Decls)) + for i := range e.Decls { + decls[i] = convertASTExtendElement(f, e.Decls[i]) + } + return ast2.NewExtendNode( + convertASTKeyword(f, e.Keyword), + convertASTIdent(f, e.Extendee), + convertASTRune(f, e.OpenBrace), + decls, + convertASTRune(f, e.CloseBrace), + ) } -func (list *identList) toIdentValueNode(leadingDot *ast.RuneNode) ast.IdentValueNode { - if list.next == nil && leadingDot == nil { - // single name - return list.ident +func convertASTExtendElement(f *ast.FileNode, el ast.ExtendElement) ast2.ExtendElement { + switch el := el.(type) { + case *ast.FieldNode: + return convertASTField(f, el) + case *ast.GroupNode: + return convertASTGroup(f, el) + case *ast.EmptyDeclNode: + return convertASTEmpty(f, el) + default: + panic(fmt.Sprintf("unrecognized type of ast.ExtendElement: %T", el)) } +} - l := 0 - for cur := list; cur != nil; cur = cur.next { - l++ +func convertASTService(f *ast.FileNode, s *ast.ServiceNode) *ast2.ServiceNode { + decls := make([]ast2.ServiceElement, len(s.Decls)) + for i := range s.Decls { + decls[i] = convertASTServiceElement(f, s.Decls[i]) } - idents := make([]*ast.IdentNode, l) - dots := make([]*ast.RuneNode, l-1) - for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { - idents[i] = cur.ident - if cur.dot != nil { - dots[i] = cur.dot - } + return ast2.NewServiceNode( + convertASTKeyword(f, s.Keyword), + convertASTIdentToken(f, s.Name), + convertASTRune(f, s.OpenBrace), + decls, + convertASTRune(f, s.CloseBrace), + ) +} + +func convertASTServiceElement(f *ast.FileNode, el ast.ServiceElement) ast2.ServiceElement { + switch el := el.(type) { + case *ast.OptionNode: + return convertASTOption(f, el) + case *ast.RPCNode: + return convertASTMethod(f, el) + case *ast.EmptyDeclNode: + return convertASTEmpty(f, el) + default: + panic(fmt.Sprintf("unrecognized type of ast.ServiceElement: %T", el)) } +} - return ast.NewCompoundIdentNode(leadingDot, idents, dots) +func convertASTMethod(f *ast.FileNode, m *ast.RPCNode) *ast2.RPCNode { + if m.OpenBrace == nil { + return ast2.NewRPCNode( + convertASTKeyword(f, m.Keyword), + convertASTIdentToken(f, m.Name), + convertASTMethodType(f, m.Input), + convertASTKeyword(f, m.Returns), + convertASTMethodType(f, m.Output), + convertASTRune(f, m.Semicolon), + ) + } + decls := make([]ast2.RPCElement, len(m.Decls)) + for i := range m.Decls { + decls[i] = convertASTMethodElement(f, m.Decls[i]) + } + return ast2.NewRPCNodeWithBody( + convertASTKeyword(f, m.Keyword), + convertASTIdentToken(f, m.Name), + convertASTMethodType(f, m.Input), + convertASTKeyword(f, m.Returns), + convertASTMethodType(f, m.Output), + convertASTRune(f, m.OpenBrace), + decls, + convertASTRune(f, m.CloseBrace), + ) } -type messageFieldEntry struct { - field *ast.MessageFieldNode - delimiter *ast.RuneNode +func convertASTMethodElement(f *ast.FileNode, el ast.RPCElement) ast2.RPCElement { + switch el := el.(type) { + case *ast.OptionNode: + return convertASTOption(f, el) + case *ast.EmptyDeclNode: + return convertASTEmpty(f, el) + default: + panic(fmt.Sprintf("unrecognized type of ast.RPCElement: %T", el)) + } } -type messageFieldList struct { - field *messageFieldEntry - next *messageFieldList +func convertASTMethodType(f *ast.FileNode, t *ast.RPCTypeNode) *ast2.RPCTypeNode { + var stream *ast2.KeywordNode + if t.Stream != nil { + stream = convertASTKeyword(f, t.Stream) + } + return ast2.NewRPCTypeNode( + convertASTRune(f, t.OpenParen), + stream, + convertASTIdent(f, t.MessageType), + convertASTRune(f, t.CloseParen), + ) } -func (list *messageFieldList) toNodes() ([]*ast.MessageFieldNode, []*ast.RuneNode) { - if list == nil { - return nil, nil +func convertASTCompactOptions(f *ast.FileNode, opts *ast.CompactOptionsNode) *ast2.CompactOptionsNode { + elems := make([]*ast2.OptionNode, len(opts.Options)) + for i := range opts.Options { + elems[i] = convertASTOption(f, opts.Options[i]) } - l := 0 - for cur := list; cur != nil; cur = cur.next { - l++ + commas := make([]*ast2.RuneNode, len(opts.Commas)) + for i := range opts.Commas { + commas[i] = convertASTRune(f, opts.Commas[i]) } - fields := make([]*ast.MessageFieldNode, l) - delimiters := make([]*ast.RuneNode, l) - for cur, i := list, 0; cur != nil; cur, i = cur.next, i+1 { - fields[i] = cur.field.field - if cur.field.delimiter != nil { - delimiters[i] = cur.field.delimiter + return ast2.NewCompactOptionsNode( + convertASTRune(f, opts.OpenBracket), + elems, commas, + convertASTRune(f, opts.CloseBracket), + ) +} + +func convertASTEmpty(f *ast.FileNode, e *ast.EmptyDeclNode) *ast2.EmptyDeclNode { + return ast2.NewEmptyDeclNode(convertASTRune(f, e.Semicolon)) +} + +func convertASTValue(f *ast.FileNode, v ast.ValueNode) ast2.ValueNode { + switch v := v.(type) { + case *ast.IdentNode: + return convertASTIdentToken(f, v) + case *ast.CompoundIdentNode: + return convertASTCompoundIdent(f, v) + case *ast.StringLiteralNode: + return convertASTStringLiteral(f, v) + case *ast.CompoundStringLiteralNode: + return convertASTCompoundStringLiteral(f, v) + case *ast.UintLiteralNode: + return convertASTUintLiteral(f, v) + case *ast.PositiveUintLiteralNode: + return convertASTPositiveUintLiteral(f, v) + case *ast.NegativeIntLiteralNode: + return convertASTNegativeIntLiteral(f, v) + case *ast.FloatLiteralNode: + return convertASTFloatLiteral(f, v) + case *ast.SpecialFloatLiteralNode: + return convertASTSpecialFloatLiteral(f, v) + case *ast.SignedFloatLiteralNode: + return convertASTSignedFloatLiteral(f, v) + case *ast.ArrayLiteralNode: + return convertASTArrayLiteral(f, v) + case *ast.MessageLiteralNode: + return convertASTMessageLiteral(f, v) + default: + panic(fmt.Sprintf("unrecognized type of ast.ValueNode: %T", v)) + } +} + +func convertASTIdent(f *ast.FileNode, ident ast.IdentValueNode) ast2.IdentValueNode { + switch ident := ident.(type) { + case *ast.IdentNode: + return convertASTIdentToken(f, ident) + case *ast.CompoundIdentNode: + return convertASTCompoundIdent(f, ident) + default: + panic(fmt.Sprintf("unrecognized type of ast.IdentValueNode: %T", ident)) + } +} + +func convertASTIdentToken(f *ast.FileNode, ident *ast.IdentNode) *ast2.IdentNode { + return ast2.NewIdentNode(ident.Val, convertASTTokenInfo(f, ident.Token())) +} + +func convertASTCompoundIdent(f *ast.FileNode, ident *ast.CompoundIdentNode) *ast2.CompoundIdentNode { + var leadingDot *ast2.RuneNode + if ident.LeadingDot != nil { + leadingDot = convertASTRune(f, ident.LeadingDot) + } + components := make([]*ast2.IdentNode, len(ident.Components)) + for i := range ident.Components { + components[i] = convertASTIdentToken(f, ident.Components[i]) + } + dots := make([]*ast2.RuneNode, len(ident.Dots)) + for i := range ident.Dots { + dots[i] = convertASTRune(f, ident.Dots[i]) + } + return ast2.NewCompoundIdentNode(leadingDot, components, dots) +} + +func convertASTString(f *ast.FileNode, str ast.StringValueNode) ast2.StringValueNode { + switch str := str.(type) { + case *ast.StringLiteralNode: + return convertASTStringLiteral(f, str) + case *ast.CompoundStringLiteralNode: + return convertASTCompoundStringLiteral(f, str) + default: + panic(fmt.Sprintf("unrecognized type of ast.StringValueNode: %T", str)) + } +} + +func convertASTStringLiteral(f *ast.FileNode, str *ast.StringLiteralNode) *ast2.StringLiteralNode { + return ast2.NewStringLiteralNode(str.Val, convertASTTokenInfo(f, str.Token())) +} + +func convertASTCompoundStringLiteral(f *ast.FileNode, str *ast.CompoundStringLiteralNode) *ast2.CompoundStringLiteralNode { + children := str.Children() + components := make([]*ast2.StringLiteralNode, len(children)) + for i := range children { + components[i] = convertASTStringLiteral(f, children[i].(*ast.StringLiteralNode)) + } + return ast2.NewCompoundLiteralStringNode(components...) +} + +func convertASTInt(f *ast.FileNode, n ast.IntValueNode) ast2.IntValueNode { + switch n := n.(type) { + case *ast.UintLiteralNode: + return convertASTUintLiteral(f, n) + case *ast.PositiveUintLiteralNode: + return convertASTPositiveUintLiteral(f, n) + case *ast.NegativeIntLiteralNode: + return convertASTNegativeIntLiteral(f, n) + default: + panic(fmt.Sprintf("unrecognized type of ast.IntValueNode: %T", n)) + } +} + +func convertASTUintLiteral(f *ast.FileNode, n *ast.UintLiteralNode) *ast2.UintLiteralNode { + return ast2.NewUintLiteralNode(n.Val, convertASTTokenInfo(f, n.Token())) +} + +func convertASTPositiveUintLiteral(f *ast.FileNode, n *ast.PositiveUintLiteralNode) *ast2.PositiveUintLiteralNode { + return ast2.NewPositiveUintLiteralNode(convertASTRune(f, n.Plus), convertASTUintLiteral(f, n.Uint)) +} + +func convertASTNegativeIntLiteral(f *ast.FileNode, n *ast.NegativeIntLiteralNode) *ast2.NegativeIntLiteralNode { + return ast2.NewNegativeIntLiteralNode(convertASTRune(f, n.Minus), convertASTUintLiteral(f, n.Uint)) +} + +func convertASTFloat(f *ast.FileNode, n ast.FloatValueNode) ast2.FloatValueNode { + switch n := n.(type) { + case *ast.FloatLiteralNode: + return convertASTFloatLiteral(f, n) + case *ast.SpecialFloatLiteralNode: + return convertASTSpecialFloatLiteral(f, n) + case *ast.UintLiteralNode: + return convertASTUintLiteral(f, n) + default: + panic(fmt.Sprintf("unrecognized type of ast.FloatValueNode: %T", n)) + } +} + +func convertASTFloatLiteral(f *ast.FileNode, n *ast.FloatLiteralNode) *ast2.FloatLiteralNode { + return ast2.NewFloatLiteralNode(n.Val, convertASTTokenInfo(f, n.Token())) +} + +func convertASTSpecialFloatLiteral(f *ast.FileNode, n *ast.SpecialFloatLiteralNode) *ast2.SpecialFloatLiteralNode { + return ast2.NewSpecialFloatLiteralNode(convertASTKeyword(f, n.KeywordNode)) +} + +func convertASTSignedFloatLiteral(f *ast.FileNode, n *ast.SignedFloatLiteralNode) *ast2.SignedFloatLiteralNode { + return ast2.NewSignedFloatLiteralNode(convertASTRune(f, n.Sign), convertASTFloat(f, n.Float)) +} + +func convertASTArrayLiteral(f *ast.FileNode, ar *ast.ArrayLiteralNode) *ast2.ArrayLiteralNode { + vals := make([]ast2.ValueNode, len(ar.Elements)) + for i := range ar.Elements { + vals[i] = convertASTValue(f, ar.Elements[i]) + } + commas := make([]*ast2.RuneNode, len(ar.Commas)) + for i := range ar.Commas { + commas[i] = convertASTRune(f, ar.Commas[i]) + } + return ast2.NewArrayLiteralNode( + convertASTRune(f, ar.OpenBracket), + vals, commas, + convertASTRune(f, ar.CloseBracket), + ) +} + +func convertASTMessageLiteral(f *ast.FileNode, m *ast.MessageLiteralNode) *ast2.MessageLiteralNode { + fields := make([]*ast2.MessageFieldNode, len(m.Elements)) + for i := range m.Elements { + fields[i] = convertASTMessageLiteralField(f, m.Elements[i]) + } + seps := make([]*ast2.RuneNode, len(m.Seps)) + for i := range m.Seps { + if m.Seps[i] != nil { + seps[i] = convertASTRune(f, m.Seps[i]) } } + return ast2.NewMessageLiteralNode( + convertASTRune(f, m.Open), + fields, seps, + convertASTRune(f, m.Close), + ) +} + +func convertASTMessageLiteralField(f *ast.FileNode, fld *ast.MessageFieldNode) *ast2.MessageFieldNode { + var sep *ast2.RuneNode + if fld.Sep != nil { + sep = convertASTRune(f, fld.Sep) + } + return ast2.NewMessageFieldNode( + convertASTFieldReference(f, fld.Name), + sep, + convertASTValue(f, fld.Val), + ) +} - return fields, delimiters +func convertASTKeyword(f *ast.FileNode, k *ast.KeywordNode) *ast2.KeywordNode { + return ast2.NewKeywordNode(k.Val, convertASTTokenInfo(f, k.Token())) +} + +func convertASTRune(f *ast.FileNode, r *ast.RuneNode) *ast2.RuneNode { + return ast2.NewRuneNode(r.Rune, convertASTTokenInfo(f, r.Token())) +} + +func convertASTTokenInfo(f *ast.FileNode, tok ast.Token) ast2.TokenInfo { + info := f.TokenInfo(tok) + return ast2.TokenInfo{ + PosRange: ast2.PosRange{ + Start: info.Start(), + End: info.End(), + }, + RawText: info.RawText(), + LeadingWhitespace: info.LeadingWhitespace(), + LeadingComments: convertASTComments(info.LeadingComments()), + TrailingComments: convertASTComments(info.TrailingComments()), + } +} + +func convertASTComments(comments ast.Comments) []ast2.Comment { + results := make([]ast2.Comment, comments.Len()) + for i := 0; i < comments.Len(); i++ { + cmt := comments.Index(i) + results[i] = ast2.Comment{ + PosRange: ast2.PosRange{ + Start: cmt.Start(), + End: cmt.End(), + }, + LeadingWhitespace: cmt.LeadingWhitespace(), + Text: cmt.RawText(), + } + } + return results } diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/ast/file.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/ast/file.go index 2ddd0ce2efc..2cef3c6c9d4 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/ast/file.go +++ b/vendor/github.com/jhump/protoreflect/desc/protoparse/ast/file.go @@ -26,7 +26,7 @@ type FileNode struct { FinalWhitespace string } -// NewFileElement creates a new *FileNode. The syntax parameter is optional. If it +// NewFileNode creates a new *FileNode. The syntax parameter is optional. If it // is absent, it means the file had no syntax declaration. // // This function panics if the concrete type of any element of decls is not diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/ast/source_pos.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/ast/source_pos.go index 7346a84c513..8ab09c6f253 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/ast/source_pos.go +++ b/vendor/github.com/jhump/protoreflect/desc/protoparse/ast/source_pos.go @@ -1,20 +1,11 @@ package ast -import "fmt" +import ( + "github.com/bufbuild/protocompile/ast" +) // SourcePos identifies a location in a proto source file. -type SourcePos struct { - Filename string - Line, Col int - Offset int -} - -func (pos SourcePos) String() string { - if pos.Line <= 0 || pos.Col <= 0 { - return pos.Filename - } - return fmt.Sprintf("%s:%d:%d", pos.Filename, pos.Line, pos.Col) -} +type SourcePos = ast.SourcePos // PosRange is a range of positions in a source file that indicates // the span of some region of source, such as a single token or diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/descriptor_protos.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/descriptor_protos.go deleted file mode 100644 index afff8d6c0e2..00000000000 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/descriptor_protos.go +++ /dev/null @@ -1,588 +0,0 @@ -package protoparse - -import ( - "bytes" - "math" - "strings" - "unicode" - - "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" - - "github.com/jhump/protoreflect/desc/internal" - "github.com/jhump/protoreflect/desc/protoparse/ast" -) - -func (r *parseResult) createFileDescriptor(filename string, file *ast.FileNode) { - fd := &dpb.FileDescriptorProto{Name: proto.String(filename)} - r.fd = fd - r.putFileNode(fd, file) - - isProto3 := false - if file.Syntax != nil { - if file.Syntax.Syntax.AsString() == "proto3" { - isProto3 = true - } else if file.Syntax.Syntax.AsString() != "proto2" { - if r.errs.handleErrorWithPos(file.Syntax.Syntax.Start(), `syntax value must be "proto2" or "proto3"`) != nil { - return - } - } - - // proto2 is the default, so no need to set unless proto3 - if isProto3 { - fd.Syntax = proto.String(file.Syntax.Syntax.AsString()) - } - } else { - r.errs.warnWithPos(file.Start(), ErrNoSyntax) - } - - for _, decl := range file.Decls { - if r.errs.err != nil { - return - } - switch decl := decl.(type) { - case *ast.EnumNode: - fd.EnumType = append(fd.EnumType, r.asEnumDescriptor(decl)) - case *ast.ExtendNode: - r.addExtensions(decl, &fd.Extension, &fd.MessageType, isProto3) - case *ast.ImportNode: - index := len(fd.Dependency) - fd.Dependency = append(fd.Dependency, decl.Name.AsString()) - if decl.Public != nil { - fd.PublicDependency = append(fd.PublicDependency, int32(index)) - } else if decl.Weak != nil { - fd.WeakDependency = append(fd.WeakDependency, int32(index)) - } - case *ast.MessageNode: - fd.MessageType = append(fd.MessageType, r.asMessageDescriptor(decl, isProto3)) - case *ast.OptionNode: - if fd.Options == nil { - fd.Options = &dpb.FileOptions{} - } - fd.Options.UninterpretedOption = append(fd.Options.UninterpretedOption, r.asUninterpretedOption(decl)) - case *ast.ServiceNode: - fd.Service = append(fd.Service, r.asServiceDescriptor(decl)) - case *ast.PackageNode: - if fd.Package != nil { - if r.errs.handleErrorWithPos(decl.Start(), "files should have only one package declaration") != nil { - return - } - } - fd.Package = proto.String(string(decl.Name.AsIdentifier())) - } - } -} - -func (r *parseResult) asUninterpretedOptions(nodes []*ast.OptionNode) []*dpb.UninterpretedOption { - if len(nodes) == 0 { - return nil - } - opts := make([]*dpb.UninterpretedOption, len(nodes)) - for i, n := range nodes { - opts[i] = r.asUninterpretedOption(n) - } - return opts -} - -func (r *parseResult) asUninterpretedOption(node *ast.OptionNode) *dpb.UninterpretedOption { - opt := &dpb.UninterpretedOption{Name: r.asUninterpretedOptionName(node.Name.Parts)} - r.putOptionNode(opt, node) - - switch val := node.Val.Value().(type) { - case bool: - if val { - opt.IdentifierValue = proto.String("true") - } else { - opt.IdentifierValue = proto.String("false") - } - case int64: - opt.NegativeIntValue = proto.Int64(val) - case uint64: - opt.PositiveIntValue = proto.Uint64(val) - case float64: - opt.DoubleValue = proto.Float64(val) - case string: - opt.StringValue = []byte(val) - case ast.Identifier: - opt.IdentifierValue = proto.String(string(val)) - default: - // the grammar does not allow arrays here, so the only possible case - // left should be []*ast.MessageFieldNode, which corresponds to an - // *ast.MessageLiteralNode - if n, ok := node.Val.(*ast.MessageLiteralNode); ok { - var buf bytes.Buffer - for i, el := range n.Elements { - flattenNode(r.root, el, &buf) - if len(n.Seps) > i && n.Seps[i] != nil { - buf.WriteRune(' ') - buf.WriteRune(n.Seps[i].Rune) - } - } - aggStr := buf.String() - opt.AggregateValue = proto.String(aggStr) - } - // TODO: else that reports an error or panics?? - } - return opt -} - -func flattenNode(f *ast.FileNode, n ast.Node, buf *bytes.Buffer) { - if cn, ok := n.(ast.CompositeNode); ok { - for _, ch := range cn.Children() { - flattenNode(f, ch, buf) - } - return - } - - if buf.Len() > 0 { - buf.WriteRune(' ') - } - buf.WriteString(n.(ast.TerminalNode).RawText()) -} - -func (r *parseResult) asUninterpretedOptionName(parts []*ast.FieldReferenceNode) []*dpb.UninterpretedOption_NamePart { - ret := make([]*dpb.UninterpretedOption_NamePart, len(parts)) - for i, part := range parts { - np := &dpb.UninterpretedOption_NamePart{ - NamePart: proto.String(string(part.Name.AsIdentifier())), - IsExtension: proto.Bool(part.IsExtension()), - } - r.putOptionNamePartNode(np, part) - ret[i] = np - } - return ret -} - -func (r *parseResult) addExtensions(ext *ast.ExtendNode, flds *[]*dpb.FieldDescriptorProto, msgs *[]*dpb.DescriptorProto, isProto3 bool) { - extendee := string(ext.Extendee.AsIdentifier()) - count := 0 - for _, decl := range ext.Decls { - switch decl := decl.(type) { - case *ast.FieldNode: - count++ - // use higher limit since we don't know yet whether extendee is messageset wire format - fd := r.asFieldDescriptor(decl, internal.MaxTag, isProto3) - fd.Extendee = proto.String(extendee) - *flds = append(*flds, fd) - case *ast.GroupNode: - count++ - // ditto: use higher limit right now - fd, md := r.asGroupDescriptors(decl, isProto3, internal.MaxTag) - fd.Extendee = proto.String(extendee) - *flds = append(*flds, fd) - *msgs = append(*msgs, md) - } - } - if count == 0 { - _ = r.errs.handleErrorWithPos(ext.Start(), "extend sections must define at least one extension") - } -} - -func asLabel(lbl *ast.FieldLabel) *dpb.FieldDescriptorProto_Label { - if !lbl.IsPresent() { - return nil - } - switch { - case lbl.Repeated: - return dpb.FieldDescriptorProto_LABEL_REPEATED.Enum() - case lbl.Required: - return dpb.FieldDescriptorProto_LABEL_REQUIRED.Enum() - default: - return dpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum() - } -} - -func (r *parseResult) asFieldDescriptor(node *ast.FieldNode, maxTag int32, isProto3 bool) *dpb.FieldDescriptorProto { - tag := node.Tag.Val - if err := checkTag(node.Tag.Start(), tag, maxTag); err != nil { - _ = r.errs.handleError(err) - } - fd := newFieldDescriptor(node.Name.Val, string(node.FldType.AsIdentifier()), int32(tag), asLabel(&node.Label)) - r.putFieldNode(fd, node) - if opts := node.Options.GetElements(); len(opts) > 0 { - fd.Options = &dpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} - } - if isProto3 && fd.Label != nil && fd.GetLabel() == dpb.FieldDescriptorProto_LABEL_OPTIONAL { - fd.Proto3Optional = proto.Bool(true) - } - return fd -} - -var fieldTypes = map[string]dpb.FieldDescriptorProto_Type{ - "double": dpb.FieldDescriptorProto_TYPE_DOUBLE, - "float": dpb.FieldDescriptorProto_TYPE_FLOAT, - "int32": dpb.FieldDescriptorProto_TYPE_INT32, - "int64": dpb.FieldDescriptorProto_TYPE_INT64, - "uint32": dpb.FieldDescriptorProto_TYPE_UINT32, - "uint64": dpb.FieldDescriptorProto_TYPE_UINT64, - "sint32": dpb.FieldDescriptorProto_TYPE_SINT32, - "sint64": dpb.FieldDescriptorProto_TYPE_SINT64, - "fixed32": dpb.FieldDescriptorProto_TYPE_FIXED32, - "fixed64": dpb.FieldDescriptorProto_TYPE_FIXED64, - "sfixed32": dpb.FieldDescriptorProto_TYPE_SFIXED32, - "sfixed64": dpb.FieldDescriptorProto_TYPE_SFIXED64, - "bool": dpb.FieldDescriptorProto_TYPE_BOOL, - "string": dpb.FieldDescriptorProto_TYPE_STRING, - "bytes": dpb.FieldDescriptorProto_TYPE_BYTES, -} - -func newFieldDescriptor(name string, fieldType string, tag int32, lbl *dpb.FieldDescriptorProto_Label) *dpb.FieldDescriptorProto { - fd := &dpb.FieldDescriptorProto{ - Name: proto.String(name), - JsonName: proto.String(internal.JsonName(name)), - Number: proto.Int32(tag), - Label: lbl, - } - t, ok := fieldTypes[fieldType] - if ok { - fd.Type = t.Enum() - } else { - // NB: we don't have enough info to determine whether this is an enum - // or a message type, so we'll leave Type nil and set it later - // (during linking) - fd.TypeName = proto.String(fieldType) - } - return fd -} - -func (r *parseResult) asGroupDescriptors(group *ast.GroupNode, isProto3 bool, maxTag int32) (*dpb.FieldDescriptorProto, *dpb.DescriptorProto) { - tag := group.Tag.Val - if err := checkTag(group.Tag.Start(), tag, maxTag); err != nil { - _ = r.errs.handleError(err) - } - if !unicode.IsUpper(rune(group.Name.Val[0])) { - _ = r.errs.handleErrorWithPos(group.Name.Start(), "group %s should have a name that starts with a capital letter", group.Name.Val) - } - fieldName := strings.ToLower(group.Name.Val) - fd := &dpb.FieldDescriptorProto{ - Name: proto.String(fieldName), - JsonName: proto.String(internal.JsonName(fieldName)), - Number: proto.Int32(int32(tag)), - Label: asLabel(&group.Label), - Type: dpb.FieldDescriptorProto_TYPE_GROUP.Enum(), - TypeName: proto.String(group.Name.Val), - } - r.putFieldNode(fd, group) - if opts := group.Options.GetElements(); len(opts) > 0 { - fd.Options = &dpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} - } - md := &dpb.DescriptorProto{Name: proto.String(group.Name.Val)} - r.putMessageNode(md, group) - r.addMessageBody(md, &group.MessageBody, isProto3) - return fd, md -} - -func (r *parseResult) asMapDescriptors(mapField *ast.MapFieldNode, isProto3 bool, maxTag int32) (*dpb.FieldDescriptorProto, *dpb.DescriptorProto) { - tag := mapField.Tag.Val - if err := checkTag(mapField.Tag.Start(), tag, maxTag); err != nil { - _ = r.errs.handleError(err) - } - var lbl *dpb.FieldDescriptorProto_Label - if !isProto3 { - lbl = dpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum() - } - keyFd := newFieldDescriptor("key", mapField.MapType.KeyType.Val, 1, lbl) - r.putFieldNode(keyFd, mapField.KeyField()) - valFd := newFieldDescriptor("value", string(mapField.MapType.ValueType.AsIdentifier()), 2, lbl) - r.putFieldNode(valFd, mapField.ValueField()) - entryName := internal.InitCap(internal.JsonName(mapField.Name.Val)) + "Entry" - fd := newFieldDescriptor(mapField.Name.Val, entryName, int32(tag), dpb.FieldDescriptorProto_LABEL_REPEATED.Enum()) - if opts := mapField.Options.GetElements(); len(opts) > 0 { - fd.Options = &dpb.FieldOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} - } - r.putFieldNode(fd, mapField) - md := &dpb.DescriptorProto{ - Name: proto.String(entryName), - Options: &dpb.MessageOptions{MapEntry: proto.Bool(true)}, - Field: []*dpb.FieldDescriptorProto{keyFd, valFd}, - } - r.putMessageNode(md, mapField) - return fd, md -} - -func (r *parseResult) asExtensionRanges(node *ast.ExtensionRangeNode, maxTag int32) []*dpb.DescriptorProto_ExtensionRange { - opts := r.asUninterpretedOptions(node.Options.GetElements()) - ers := make([]*dpb.DescriptorProto_ExtensionRange, len(node.Ranges)) - for i, rng := range node.Ranges { - start, end := getRangeBounds(r, rng, 1, maxTag) - er := &dpb.DescriptorProto_ExtensionRange{ - Start: proto.Int32(start), - End: proto.Int32(end + 1), - } - if len(opts) > 0 { - er.Options = &dpb.ExtensionRangeOptions{UninterpretedOption: opts} - } - r.putExtensionRangeNode(er, rng) - ers[i] = er - } - return ers -} - -func (r *parseResult) asEnumValue(ev *ast.EnumValueNode) *dpb.EnumValueDescriptorProto { - num, ok := ast.AsInt32(ev.Number, math.MinInt32, math.MaxInt32) - if !ok { - _ = r.errs.handleErrorWithPos(ev.Number.Start(), "value %d is out of range: should be between %d and %d", ev.Number.Value(), math.MinInt32, math.MaxInt32) - } - evd := &dpb.EnumValueDescriptorProto{Name: proto.String(ev.Name.Val), Number: proto.Int32(num)} - r.putEnumValueNode(evd, ev) - if opts := ev.Options.GetElements(); len(opts) > 0 { - evd.Options = &dpb.EnumValueOptions{UninterpretedOption: r.asUninterpretedOptions(opts)} - } - return evd -} - -func (r *parseResult) asMethodDescriptor(node *ast.RPCNode) *dpb.MethodDescriptorProto { - md := &dpb.MethodDescriptorProto{ - Name: proto.String(node.Name.Val), - InputType: proto.String(string(node.Input.MessageType.AsIdentifier())), - OutputType: proto.String(string(node.Output.MessageType.AsIdentifier())), - } - r.putMethodNode(md, node) - if node.Input.Stream != nil { - md.ClientStreaming = proto.Bool(true) - } - if node.Output.Stream != nil { - md.ServerStreaming = proto.Bool(true) - } - // protoc always adds a MethodOptions if there are brackets - // We do the same to match protoc as closely as possible - // https://github.com/protocolbuffers/protobuf/blob/0c3f43a6190b77f1f68b7425d1b7e1a8257a8d0c/src/google/protobuf/compiler/parser.cc#L2152 - if node.OpenBrace != nil { - md.Options = &dpb.MethodOptions{} - for _, decl := range node.Decls { - switch decl := decl.(type) { - case *ast.OptionNode: - md.Options.UninterpretedOption = append(md.Options.UninterpretedOption, r.asUninterpretedOption(decl)) - } - } - } - return md -} - -func (r *parseResult) asEnumDescriptor(en *ast.EnumNode) *dpb.EnumDescriptorProto { - ed := &dpb.EnumDescriptorProto{Name: proto.String(en.Name.Val)} - r.putEnumNode(ed, en) - for _, decl := range en.Decls { - switch decl := decl.(type) { - case *ast.OptionNode: - if ed.Options == nil { - ed.Options = &dpb.EnumOptions{} - } - ed.Options.UninterpretedOption = append(ed.Options.UninterpretedOption, r.asUninterpretedOption(decl)) - case *ast.EnumValueNode: - ed.Value = append(ed.Value, r.asEnumValue(decl)) - case *ast.ReservedNode: - for _, n := range decl.Names { - ed.ReservedName = append(ed.ReservedName, n.AsString()) - } - for _, rng := range decl.Ranges { - ed.ReservedRange = append(ed.ReservedRange, r.asEnumReservedRange(rng)) - } - } - } - return ed -} - -func (r *parseResult) asEnumReservedRange(rng *ast.RangeNode) *dpb.EnumDescriptorProto_EnumReservedRange { - start, end := getRangeBounds(r, rng, math.MinInt32, math.MaxInt32) - rr := &dpb.EnumDescriptorProto_EnumReservedRange{ - Start: proto.Int32(start), - End: proto.Int32(end), - } - r.putEnumReservedRangeNode(rr, rng) - return rr -} - -func (r *parseResult) asMessageDescriptor(node *ast.MessageNode, isProto3 bool) *dpb.DescriptorProto { - msgd := &dpb.DescriptorProto{Name: proto.String(node.Name.Val)} - r.putMessageNode(msgd, node) - r.addMessageBody(msgd, &node.MessageBody, isProto3) - return msgd -} - -func (r *parseResult) addMessageBody(msgd *dpb.DescriptorProto, body *ast.MessageBody, isProto3 bool) { - // first process any options - for _, decl := range body.Decls { - if opt, ok := decl.(*ast.OptionNode); ok { - if msgd.Options == nil { - msgd.Options = &dpb.MessageOptions{} - } - msgd.Options.UninterpretedOption = append(msgd.Options.UninterpretedOption, r.asUninterpretedOption(opt)) - } - } - - // now that we have options, we can see if this uses messageset wire format, which - // impacts how we validate tag numbers in any fields in the message - maxTag := int32(internal.MaxNormalTag) - messageSetOpt, err := isMessageSetWireFormat(r, "message "+msgd.GetName(), msgd) - if err != nil { - return - } else if messageSetOpt != nil { - maxTag = internal.MaxTag // higher limit for messageset wire format - } - - rsvdNames := map[string]int{} - - // now we can process the rest - for _, decl := range body.Decls { - switch decl := decl.(type) { - case *ast.EnumNode: - msgd.EnumType = append(msgd.EnumType, r.asEnumDescriptor(decl)) - case *ast.ExtendNode: - r.addExtensions(decl, &msgd.Extension, &msgd.NestedType, isProto3) - case *ast.ExtensionRangeNode: - msgd.ExtensionRange = append(msgd.ExtensionRange, r.asExtensionRanges(decl, maxTag)...) - case *ast.FieldNode: - fd := r.asFieldDescriptor(decl, maxTag, isProto3) - msgd.Field = append(msgd.Field, fd) - case *ast.MapFieldNode: - fd, md := r.asMapDescriptors(decl, isProto3, maxTag) - msgd.Field = append(msgd.Field, fd) - msgd.NestedType = append(msgd.NestedType, md) - case *ast.GroupNode: - fd, md := r.asGroupDescriptors(decl, isProto3, maxTag) - msgd.Field = append(msgd.Field, fd) - msgd.NestedType = append(msgd.NestedType, md) - case *ast.OneOfNode: - oodIndex := len(msgd.OneofDecl) - ood := &dpb.OneofDescriptorProto{Name: proto.String(decl.Name.Val)} - r.putOneOfNode(ood, decl) - msgd.OneofDecl = append(msgd.OneofDecl, ood) - ooFields := 0 - for _, oodecl := range decl.Decls { - switch oodecl := oodecl.(type) { - case *ast.OptionNode: - if ood.Options == nil { - ood.Options = &dpb.OneofOptions{} - } - ood.Options.UninterpretedOption = append(ood.Options.UninterpretedOption, r.asUninterpretedOption(oodecl)) - case *ast.FieldNode: - fd := r.asFieldDescriptor(oodecl, maxTag, isProto3) - fd.OneofIndex = proto.Int32(int32(oodIndex)) - msgd.Field = append(msgd.Field, fd) - ooFields++ - case *ast.GroupNode: - fd, md := r.asGroupDescriptors(oodecl, isProto3, maxTag) - fd.OneofIndex = proto.Int32(int32(oodIndex)) - msgd.Field = append(msgd.Field, fd) - msgd.NestedType = append(msgd.NestedType, md) - ooFields++ - } - } - if ooFields == 0 { - _ = r.errs.handleErrorWithPos(decl.Start(), "oneof must contain at least one field") - } - case *ast.MessageNode: - msgd.NestedType = append(msgd.NestedType, r.asMessageDescriptor(decl, isProto3)) - case *ast.ReservedNode: - for _, n := range decl.Names { - count := rsvdNames[n.AsString()] - if count == 1 { // already seen - _ = r.errs.handleErrorWithPos(n.Start(), "name %q is reserved multiple times", n.AsString()) - } - rsvdNames[n.AsString()] = count + 1 - msgd.ReservedName = append(msgd.ReservedName, n.AsString()) - } - for _, rng := range decl.Ranges { - msgd.ReservedRange = append(msgd.ReservedRange, r.asMessageReservedRange(rng, maxTag)) - } - } - } - - if messageSetOpt != nil { - if len(msgd.Field) > 0 { - node := r.getFieldNode(msgd.Field[0]) - _ = r.errs.handleErrorWithPos(node.Start(), "messages with message-set wire format cannot contain non-extension fields") - } - if len(msgd.ExtensionRange) == 0 { - node := r.getOptionNode(messageSetOpt) - _ = r.errs.handleErrorWithPos(node.Start(), "messages with message-set wire format must contain at least one extension range") - } - } - - // process any proto3_optional fields - if isProto3 { - callback := func(fd *dpb.FieldDescriptorProto, ood *dpb.OneofDescriptorProto) { - node, ok := r.getFieldNode(fd).(*ast.FieldNode) - if ok { - r.putOneOfNode(ood, ast.NewSyntheticOneOf(node)) - } - // TODO: the !ok case should really never happen... log an error? - } - internal.ProcessProto3OptionalFields(msgd, callback) - } -} - -func isMessageSetWireFormat(res *parseResult, scope string, md *dpb.DescriptorProto) (*dpb.UninterpretedOption, error) { - uo := md.GetOptions().GetUninterpretedOption() - index, err := findOption(res, scope, uo, "message_set_wire_format") - if err != nil { - return nil, err - } - if index == -1 { - // no such option - return nil, nil - } - - opt := uo[index] - - switch opt.GetIdentifierValue() { - case "true": - return opt, nil - case "false": - return nil, nil - default: - optNode := res.getOptionNode(opt) - return nil, res.errs.handleErrorWithPos(optNode.GetValue().Start(), "%s: expecting bool value for message_set_wire_format option", scope) - } -} - -func (r *parseResult) asMessageReservedRange(rng *ast.RangeNode, maxTag int32) *dpb.DescriptorProto_ReservedRange { - start, end := getRangeBounds(r, rng, 1, maxTag) - rr := &dpb.DescriptorProto_ReservedRange{ - Start: proto.Int32(start), - End: proto.Int32(end + 1), - } - r.putMessageReservedRangeNode(rr, rng) - return rr -} - -func getRangeBounds(res *parseResult, rng *ast.RangeNode, minVal, maxVal int32) (int32, int32) { - checkOrder := true - start, ok := rng.StartValueAsInt32(minVal, maxVal) - if !ok { - checkOrder = false - _ = res.errs.handleErrorWithPos(rng.StartVal.Start(), "range start %d is out of range: should be between %d and %d", rng.StartValue(), minVal, maxVal) - } - - end, ok := rng.EndValueAsInt32(minVal, maxVal) - if !ok { - checkOrder = false - if rng.EndVal != nil { - _ = res.errs.handleErrorWithPos(rng.EndVal.Start(), "range end %d is out of range: should be between %d and %d", rng.EndValue(), minVal, maxVal) - } - } - - if checkOrder && start > end { - _ = res.errs.handleErrorWithPos(rng.RangeStart().Start(), "range, %d to %d, is invalid: start must be <= end", start, end) - } - - return start, end -} - -func (r *parseResult) asServiceDescriptor(svc *ast.ServiceNode) *dpb.ServiceDescriptorProto { - sd := &dpb.ServiceDescriptorProto{Name: proto.String(svc.Name.Val)} - r.putServiceNode(sd, svc) - for _, decl := range svc.Decls { - switch decl := decl.(type) { - case *ast.OptionNode: - if sd.Options == nil { - sd.Options = &dpb.ServiceOptions{} - } - sd.Options.UninterpretedOption = append(sd.Options.UninterpretedOption, r.asUninterpretedOption(decl)) - case *ast.RPCNode: - sd.Method = append(sd.Method, r.asMethodDescriptor(decl)) - } - } - return sd -} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/errors.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/errors.go index 7c15b7d4af8..c71d651d70c 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/errors.go +++ b/vendor/github.com/jhump/protoreflect/desc/protoparse/errors.go @@ -3,108 +3,53 @@ package protoparse import ( "errors" "fmt" + + "github.com/bufbuild/protocompile/linker" + "github.com/bufbuild/protocompile/parser" + "github.com/bufbuild/protocompile/reporter" + + "github.com/jhump/protoreflect/desc/protoparse/ast" ) +// SourcePos is the same as ast.SourcePos. This alias exists for +// backwards compatibility (SourcePos used to be defined in this package.) +type SourcePos = ast.SourcePos + // ErrInvalidSource is a sentinel error that is returned by calls to // Parser.ParseFiles and Parser.ParseFilesButDoNotLink in the event that syntax // or link errors are encountered, but the parser's configured ErrorReporter // always returns nil. -var ErrInvalidSource = errors.New("parse failed: invalid proto source") +var ErrInvalidSource = reporter.ErrInvalidSource // ErrNoSyntax is a sentinel error that may be passed to a warning reporter. // The error the reporter receives will be wrapped with source position that // indicates the file that had no syntax statement. -var ErrNoSyntax = errors.New("no syntax specified; defaulting to proto2 syntax") +var ErrNoSyntax = parser.ErrNoSyntax // ErrLookupImportAndProtoSet is the error returned if both LookupImport and LookupImportProto are set. +// +// Deprecated: This error is no longer used. It is now legal to set both LookupImport and LookupImportProto +// fields on the Parser. var ErrLookupImportAndProtoSet = errors.New("both LookupImport and LookupImportProto set") // ErrorReporter is responsible for reporting the given error. If the reporter // returns a non-nil error, parsing/linking will abort with that error. If the // reporter returns nil, parsing will continue, allowing the parser to try to // report as many syntax and/or link errors as it can find. -type ErrorReporter func(err ErrorWithPos) error +type ErrorReporter = reporter.ErrorReporter // WarningReporter is responsible for reporting the given warning. This is used // for indicating non-error messages to the calling program for things that do // not cause the parse to fail but are considered bad practice. Though they are // just warnings, the details are supplied to the reporter via an error type. -type WarningReporter func(ErrorWithPos) - -func defaultErrorReporter(err ErrorWithPos) error { - // abort parsing after first error encountered - return err -} - -type errorHandler struct { - errReporter ErrorReporter - errsReported int - err error - - warnReporter WarningReporter -} - -func newErrorHandler(errRep ErrorReporter, warnRep WarningReporter) *errorHandler { - if errRep == nil { - errRep = defaultErrorReporter - } - return &errorHandler{ - errReporter: errRep, - warnReporter: warnRep, - } -} - -func (h *errorHandler) handleErrorWithPos(pos *SourcePos, format string, args ...interface{}) error { - if h.err != nil { - return h.err - } - h.errsReported++ - err := h.errReporter(errorWithPos(pos, format, args...)) - h.err = err - return err -} - -func (h *errorHandler) handleError(err error) error { - if h.err != nil { - return h.err - } - if ewp, ok := err.(ErrorWithPos); ok { - h.errsReported++ - err = h.errReporter(ewp) - } - h.err = err - return err -} - -func (h *errorHandler) warnWithPos(pos *SourcePos, err error) { - if h.warnReporter != nil { - h.warnReporter(ErrorWithSourcePos{Pos: pos, Underlying: err}) - } -} - -func (h *errorHandler) warn(err ErrorWithSourcePos) { - if h.warnReporter != nil { - h.warnReporter(err) - } -} - -func (h *errorHandler) getError() error { - if h.errsReported > 0 && h.err == nil { - return ErrInvalidSource - } - return h.err -} +type WarningReporter = reporter.WarningReporter // ErrorWithPos is an error about a proto source file that includes information // about the location in the file that caused the error. // // The value of Error() will contain both the SourcePos and Underlying error. // The value of Unwrap() will only be the Underlying error. -type ErrorWithPos interface { - error - GetPosition() SourcePos - Unwrap() error -} +type ErrorWithPos = reporter.ErrorWithPos // ErrorWithSourcePos is an error about a proto source file that includes // information about the location in the file that caused the error. @@ -144,10 +89,20 @@ func (e ErrorWithSourcePos) Unwrap() error { var _ ErrorWithPos = ErrorWithSourcePos{} -func errorWithPos(pos *SourcePos, format string, args ...interface{}) ErrorWithSourcePos { - return ErrorWithSourcePos{Pos: pos, Underlying: fmt.Errorf(format, args...)} +func toErrorWithSourcePos(err ErrorWithPos) ErrorWithPos { + pos := err.GetPosition() + return ErrorWithSourcePos{ + Underlying: err.Unwrap(), + Pos: &pos, + } } +// ErrorUnusedImport may be passed to a warning reporter when an unused +// import is detected. The error the reporter receives will be wrapped +// with source position that indicates the file and line where the import +// statement appeared. +type ErrorUnusedImport = linker.ErrorUnusedImport + type errorWithFilename struct { underlying error filename string @@ -160,22 +115,3 @@ func (e errorWithFilename) Error() string { func (e errorWithFilename) Unwrap() error { return e.underlying } - -// ErrorUnusedImport may be passed to a warning reporter when an unused -// import is detected. The error the reporter receives will be wrapped -// with source position that indicates the file and line where the import -// statement appeared. -type ErrorUnusedImport interface { - error - UnusedImport() string -} - -type errUnusedImport string - -func (e errUnusedImport) Error() string { - return fmt.Sprintf("import %q not used", string(e)) -} - -func (e errUnusedImport) UnusedImport() string { - return string(e) -} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/linker.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/linker.go deleted file mode 100644 index d79163629aa..00000000000 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/linker.go +++ /dev/null @@ -1,1326 +0,0 @@ -package protoparse - -import ( - "bytes" - "fmt" - "google.golang.org/protobuf/types/descriptorpb" - "sort" - "strings" - "unicode" - "unicode/utf8" - - "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" - - "github.com/jhump/protoreflect/desc" - "github.com/jhump/protoreflect/desc/internal" - "github.com/jhump/protoreflect/desc/protoparse/ast" -) - -type linker struct { - files map[string]*parseResult - filenames []string - errs *errorHandler - descriptorPool map[*dpb.FileDescriptorProto]map[string]proto.Message - packageNamespaces map[*dpb.FileDescriptorProto]map[string]struct{} - extensions map[string]map[int32]string - usedImports map[*dpb.FileDescriptorProto]map[string]struct{} -} - -func newLinker(files *parseResults, errs *errorHandler) *linker { - return &linker{files: files.resultsByFilename, filenames: files.filenames, errs: errs} -} - -func (l *linker) linkFiles() (map[string]*desc.FileDescriptor, error) { - // First, we put all symbols into a single pool, which lets us ensure there - // are no duplicate symbols and will also let us resolve and revise all type - // references in next step. - if err := l.createDescriptorPool(); err != nil { - return nil, err - } - - // After we've populated the pool, we can now try to resolve all type - // references. All references must be checked for correct type, any fields - // with enum types must be corrected (since we parse them as if they are - // message references since we don't actually know message or enum until - // link time), and references will be re-written to be fully-qualified - // references (e.g. start with a dot "."). - if err := l.resolveReferences(); err != nil { - return nil, err - } - - if err := l.errs.getError(); err != nil { - // we won't be able to create real descriptors if we've encountered - // errors up to this point, so bail at this point - return nil, err - } - - // Now we've validated the descriptors, so we can link them into rich - // descriptors. This is a little redundant since that step does similar - // checking of symbols. But, without breaking encapsulation (e.g. exporting - // a lot of fields from desc package that are currently unexported) or - // merging this into the same package, we can't really prevent it. - linked, err := l.createdLinkedDescriptors() - if err != nil { - return nil, err - } - - // Now that we have linked descriptors, we can interpret any uninterpreted - // options that remain. - for _, r := range l.files { - fd := linked[r.fd.GetName()] - if err := interpretFileOptions(l, r, richFileDescriptorish{FileDescriptor: fd}); err != nil { - return nil, err - } - // we should now have any message_set_wire_format options parsed - // and can do further validation on tag ranges - if err := l.checkExtensionsInFile(fd, r); err != nil { - return nil, err - } - // and final check for json name conflicts - if err := l.checkJsonNamesInFile(fd, r); err != nil { - return nil, err - } - } - - // When Parser calls linkFiles, it does not check errs again, and it expects that linkFiles - // will return all errors it should process. If the ErrorReporter handles all errors itself - // and always returns nil, we should get ErrInvalidSource here, and need to propagate this - if err := l.errs.getError(); err != nil { - return nil, err - } - return linked, nil -} - -func (l *linker) createDescriptorPool() error { - l.descriptorPool = map[*dpb.FileDescriptorProto]map[string]proto.Message{} - l.packageNamespaces = map[*dpb.FileDescriptorProto]map[string]struct{}{} - for _, filename := range l.filenames { - r := l.files[filename] - fd := r.fd - pool := map[string]proto.Message{} - l.descriptorPool[fd] = pool - prefix := fd.GetPackage() - l.packageNamespaces[fd] = namespacesFromPackage(prefix) - if prefix != "" { - prefix += "." - } - for _, md := range fd.MessageType { - if err := addMessageToPool(r, pool, l.errs, prefix, md); err != nil { - return err - } - } - for _, fld := range fd.Extension { - if err := addFieldToPool(r, pool, l.errs, prefix, fld); err != nil { - return err - } - } - for _, ed := range fd.EnumType { - if err := addEnumToPool(r, pool, l.errs, prefix, ed); err != nil { - return err - } - } - for _, sd := range fd.Service { - if err := addServiceToPool(r, pool, l.errs, prefix, sd); err != nil { - return err - } - } - } - // try putting everything into a single pool, to ensure there are no duplicates - // across files (e.g. same symbol, but declared in two different files) - type entry struct { - file string - msg proto.Message - } - pool := map[string]entry{} - for _, filename := range l.filenames { - f := l.files[filename].fd - p := l.descriptorPool[f] - keys := make([]string, 0, len(p)) - for k := range p { - keys = append(keys, k) - } - sort.Strings(keys) // for deterministic error reporting - for _, k := range keys { - v := p[k] - if e, ok := pool[k]; ok { - desc1 := e.msg - file1 := e.file - desc2 := v - file2 := f.GetName() - if file2 < file1 { - file1, file2 = file2, file1 - desc1, desc2 = desc2, desc1 - } - node := l.files[file2].getNode(desc2) - if node == nil { - // TODO: this should never happen, but in case there is a bug where - // we get back a nil node, we'd rather fail to report line+column - // info than panic with a nil dereference below - node = ast.NewNoSourceNode(file2) - } - if err := l.errs.handleErrorWithPos(node.Start(), "duplicate symbol %s: already defined as %s in %q", k, descriptorTypeWithArticle(desc1), file1); err != nil { - return err - } - } - pool[k] = entry{file: f.GetName(), msg: v} - } - } - - return nil -} - -func namespacesFromPackage(pkg string) map[string]struct{} { - if pkg == "" { - return nil - } - offs := 0 - pkgs := map[string]struct{}{} - pkgs[pkg] = struct{}{} - for { - pos := strings.IndexByte(pkg[offs:], '.') - if pos == -1 { - return pkgs - } - pkgs[pkg[:offs+pos]] = struct{}{} - offs = offs + pos + 1 - } -} - -func addMessageToPool(r *parseResult, pool map[string]proto.Message, errs *errorHandler, prefix string, md *dpb.DescriptorProto) error { - fqn := prefix + md.GetName() - if err := addToPool(r, pool, errs, fqn, md); err != nil { - return err - } - prefix = fqn + "." - for _, ood := range md.OneofDecl { - if err := addOneofToPool(r, pool, errs, prefix, ood); err != nil { - return err - } - } - for _, fld := range md.Field { - if err := addFieldToPool(r, pool, errs, prefix, fld); err != nil { - return err - } - } - for _, fld := range md.Extension { - if err := addFieldToPool(r, pool, errs, prefix, fld); err != nil { - return err - } - } - for _, nmd := range md.NestedType { - if err := addMessageToPool(r, pool, errs, prefix, nmd); err != nil { - return err - } - } - for _, ed := range md.EnumType { - if err := addEnumToPool(r, pool, errs, prefix, ed); err != nil { - return err - } - } - return nil -} - -func addFieldToPool(r *parseResult, pool map[string]proto.Message, errs *errorHandler, prefix string, fld *dpb.FieldDescriptorProto) error { - fqn := prefix + fld.GetName() - return addToPool(r, pool, errs, fqn, fld) -} - -func addOneofToPool(r *parseResult, pool map[string]proto.Message, errs *errorHandler, prefix string, ood *dpb.OneofDescriptorProto) error { - fqn := prefix + ood.GetName() - return addToPool(r, pool, errs, fqn, ood) -} - -func addEnumToPool(r *parseResult, pool map[string]proto.Message, errs *errorHandler, prefix string, ed *dpb.EnumDescriptorProto) error { - fqn := prefix + ed.GetName() - if err := addToPool(r, pool, errs, fqn, ed); err != nil { - return err - } - for _, evd := range ed.Value { - // protobuf name-scoping rules for enum values follow C++ scoping rules: - // the enum value name is a symbol in the *parent* scope (the one - // enclosing the enum). - vfqn := prefix + evd.GetName() - if err := addToPool(r, pool, errs, vfqn, evd); err != nil { - return err - } - } - return nil -} - -func addServiceToPool(r *parseResult, pool map[string]proto.Message, errs *errorHandler, prefix string, sd *dpb.ServiceDescriptorProto) error { - fqn := prefix + sd.GetName() - if err := addToPool(r, pool, errs, fqn, sd); err != nil { - return err - } - for _, mtd := range sd.Method { - mfqn := fqn + "." + mtd.GetName() - if err := addToPool(r, pool, errs, mfqn, mtd); err != nil { - return err - } - } - return nil -} - -func addToPool(r *parseResult, pool map[string]proto.Message, errs *errorHandler, fqn string, dsc proto.Message) error { - if d, ok := pool[fqn]; ok { - node := r.nodes[dsc] - _, additionIsEnumVal := dsc.(*dpb.EnumValueDescriptorProto) - _, existingIsEnumVal := d.(*dpb.EnumValueDescriptorProto) - // because of weird scoping for enum values, provide more context in error message - // if this conflict is with an enum value - var suffix string - if additionIsEnumVal || existingIsEnumVal { - suffix = "; protobuf uses C++ scoping rules for enum values, so they exist in the scope enclosing the enum" - } - // TODO: also include the source location for the conflicting symbol - if err := errs.handleErrorWithPos(node.Start(), "duplicate symbol %s: already defined as %s%s", fqn, descriptorTypeWithArticle(d), suffix); err != nil { - return err - } - } - pool[fqn] = dsc - return nil -} - -func descriptorType(m proto.Message) string { - switch m := m.(type) { - case *dpb.DescriptorProto: - return "message" - case *dpb.DescriptorProto_ExtensionRange: - return "extension range" - case *dpb.FieldDescriptorProto: - if m.GetExtendee() == "" { - return "field" - } else { - return "extension" - } - case *dpb.EnumDescriptorProto: - return "enum" - case *dpb.EnumValueDescriptorProto: - return "enum value" - case *dpb.ServiceDescriptorProto: - return "service" - case *dpb.MethodDescriptorProto: - return "method" - case *dpb.FileDescriptorProto: - return "file" - case *dpb.OneofDescriptorProto: - return "oneof" - default: - // shouldn't be possible - return fmt.Sprintf("%T", m) - } -} - -func descriptorTypeWithArticle(m proto.Message) string { - switch m := m.(type) { - case *dpb.DescriptorProto: - return "a message" - case *dpb.DescriptorProto_ExtensionRange: - return "an extension range" - case *dpb.FieldDescriptorProto: - if m.GetExtendee() == "" { - return "a field" - } else { - return "an extension" - } - case *dpb.EnumDescriptorProto: - return "an enum" - case *dpb.EnumValueDescriptorProto: - return "an enum value" - case *dpb.ServiceDescriptorProto: - return "a service" - case *dpb.MethodDescriptorProto: - return "a method" - case *dpb.FileDescriptorProto: - return "a file" - case *dpb.OneofDescriptorProto: - return "a oneof" - default: - // shouldn't be possible - return fmt.Sprintf("a %T", m) - } -} - -func (l *linker) resolveReferences() error { - l.extensions = map[string]map[int32]string{} - l.usedImports = map[*dpb.FileDescriptorProto]map[string]struct{}{} - for _, filename := range l.filenames { - r := l.files[filename] - fd := r.fd - prefix := fd.GetPackage() - scopes := []scope{fileScope(fd, l)} - if prefix != "" { - prefix += "." - } - if fd.Options != nil { - if err := l.resolveOptions(r, fd, "file", fd.GetName(), fd.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - for _, md := range fd.MessageType { - if err := l.resolveMessageTypes(r, fd, prefix, md, scopes); err != nil { - return err - } - } - for _, fld := range fd.Extension { - if err := l.resolveFieldTypes(r, fd, prefix, fld, scopes); err != nil { - return err - } - } - for _, ed := range fd.EnumType { - if err := l.resolveEnumTypes(r, fd, prefix, ed, scopes); err != nil { - return err - } - } - for _, sd := range fd.Service { - if err := l.resolveServiceTypes(r, fd, prefix, sd, scopes); err != nil { - return err - } - } - } - return nil -} - -func (l *linker) resolveEnumTypes(r *parseResult, fd *dpb.FileDescriptorProto, prefix string, ed *dpb.EnumDescriptorProto, scopes []scope) error { - enumFqn := prefix + ed.GetName() - if ed.Options != nil { - if err := l.resolveOptions(r, fd, "enum", enumFqn, ed.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - for _, evd := range ed.Value { - if evd.Options != nil { - evFqn := enumFqn + "." + evd.GetName() - if err := l.resolveOptions(r, fd, "enum value", evFqn, evd.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - } - return nil -} - -func (l *linker) resolveMessageTypes(r *parseResult, fd *dpb.FileDescriptorProto, prefix string, md *dpb.DescriptorProto, scopes []scope) error { - fqn := prefix + md.GetName() - - // Strangely, when protoc resolves extension names, it uses the *enclosing* scope - // instead of the message's scope. So if the message contains an extension named "i", - // an option cannot refer to it as simply "i" but must qualify it (at a minimum "Msg.i"). - // So we don't add this message's scope to our scopes slice until *after* we do options. - if md.Options != nil { - if err := l.resolveOptions(r, fd, "message", fqn, md.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - - scope := messageScope(fqn, isProto3(fd), l, fd) - scopes = append(scopes, scope) - prefix = fqn + "." - - for _, nmd := range md.NestedType { - if err := l.resolveMessageTypes(r, fd, prefix, nmd, scopes); err != nil { - return err - } - } - for _, ned := range md.EnumType { - if err := l.resolveEnumTypes(r, fd, prefix, ned, scopes); err != nil { - return err - } - } - for _, fld := range md.Field { - if err := l.resolveFieldTypes(r, fd, prefix, fld, scopes); err != nil { - return err - } - } - for _, ood := range md.OneofDecl { - if ood.Options != nil { - ooName := fmt.Sprintf("%s.%s", fqn, ood.GetName()) - if err := l.resolveOptions(r, fd, "oneof", ooName, ood.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - } - for _, fld := range md.Extension { - if err := l.resolveFieldTypes(r, fd, prefix, fld, scopes); err != nil { - return err - } - } - for _, er := range md.ExtensionRange { - if er.Options != nil { - erName := fmt.Sprintf("%s:%d-%d", fqn, er.GetStart(), er.GetEnd()-1) - if err := l.resolveOptions(r, fd, "extension range", erName, er.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - } - return nil -} - -func (l *linker) resolveFieldTypes(r *parseResult, fd *dpb.FileDescriptorProto, prefix string, fld *dpb.FieldDescriptorProto, scopes []scope) error { - thisName := prefix + fld.GetName() - scope := fmt.Sprintf("field %s", thisName) - node := r.getFieldNode(fld) - elemType := "field" - if fld.GetExtendee() != "" { - elemType = "extension" - fqn, dsc, _ := l.resolve(fd, fld.GetExtendee(), true, scopes) - if dsc == nil { - return l.errs.handleErrorWithPos(node.FieldExtendee().Start(), "unknown extendee type %s", fld.GetExtendee()) - } - if dsc == sentinelMissingSymbol { - return l.errs.handleErrorWithPos(node.FieldExtendee().Start(), "unknown extendee type %s; resolved to %s which is not defined; consider using a leading dot", fld.GetExtendee(), fqn) - } - extd, ok := dsc.(*dpb.DescriptorProto) - if !ok { - return l.errs.handleErrorWithPos(node.FieldExtendee().Start(), "extendee is invalid: %s is %s, not a message", fqn, descriptorTypeWithArticle(dsc)) - } - fld.Extendee = proto.String("." + fqn) - // make sure the tag number is in range - found := false - tag := fld.GetNumber() - for _, rng := range extd.ExtensionRange { - if tag >= rng.GetStart() && tag < rng.GetEnd() { - found = true - break - } - } - if !found { - if err := l.errs.handleErrorWithPos(node.FieldTag().Start(), "%s: tag %d is not in valid range for extended type %s", scope, tag, fqn); err != nil { - return err - } - } else { - // make sure tag is not a duplicate - usedExtTags := l.extensions[fqn] - if usedExtTags == nil { - usedExtTags = map[int32]string{} - l.extensions[fqn] = usedExtTags - } - if other := usedExtTags[fld.GetNumber()]; other != "" { - if err := l.errs.handleErrorWithPos(node.FieldTag().Start(), "%s: duplicate extension: %s and %s are both using tag %d", scope, other, thisName, fld.GetNumber()); err != nil { - return err - } - } else { - usedExtTags[fld.GetNumber()] = thisName - } - } - } - - if fld.Options != nil { - if err := l.resolveOptions(r, fd, elemType, thisName, fld.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - - if fld.GetTypeName() == "" { - // scalar type; no further resolution required - return nil - } - - fqn, dsc, proto3 := l.resolve(fd, fld.GetTypeName(), true, scopes) - if dsc == nil { - return l.errs.handleErrorWithPos(node.FieldType().Start(), "%s: unknown type %s", scope, fld.GetTypeName()) - } - if dsc == sentinelMissingSymbol { - return l.errs.handleErrorWithPos(node.FieldType().Start(), "%s: unknown type %s; resolved to %s which is not defined; consider using a leading dot", scope, fld.GetTypeName(), fqn) - } - switch dsc := dsc.(type) { - case *dpb.DescriptorProto: - if dsc.GetOptions().GetMapEntry() { - isValid := false - switch node.(type) { - case *ast.MapFieldNode: - // We have an AST for this file and can see this field is from a map declaration - isValid = true - case ast.NoSourceNode: - // We don't have an AST for the file (it came from a provided descriptor). So we - // need to validate that it's not an illegal reference. To be valid, the field - // must be repeated and the entry type must be nested in the same enclosing - // message as the field. - expectFqn := prefix + dsc.GetName() - isValid = expectFqn == fqn && fld.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED - } - if !isValid { - return l.errs.handleErrorWithPos(node.FieldType().Start(), "%s: %s is a synthetic map entry and may not be referenced explicitly", scope, fqn) - } - } - fld.TypeName = proto.String("." + fqn) - // if type was tentatively unset, we now know it's actually a message - if fld.Type == nil { - fld.Type = dpb.FieldDescriptorProto_TYPE_MESSAGE.Enum() - } - case *dpb.EnumDescriptorProto: - if fld.GetExtendee() == "" && isProto3(fd) && !proto3 { - // fields in a proto3 message cannot refer to proto2 enums - return l.errs.handleErrorWithPos(node.FieldType().Start(), "%s: cannot use proto2 enum %s in a proto3 message", scope, fld.GetTypeName()) - } - fld.TypeName = proto.String("." + fqn) - // the type was tentatively unset, but now we know it's actually an enum - fld.Type = dpb.FieldDescriptorProto_TYPE_ENUM.Enum() - default: - return l.errs.handleErrorWithPos(node.FieldType().Start(), "%s: invalid type: %s is %s, not a message or enum", scope, fqn, descriptorTypeWithArticle(dsc)) - } - return nil -} - -func (l *linker) resolveServiceTypes(r *parseResult, fd *dpb.FileDescriptorProto, prefix string, sd *dpb.ServiceDescriptorProto, scopes []scope) error { - svcFqn := prefix + sd.GetName() - if sd.Options != nil { - if err := l.resolveOptions(r, fd, "service", svcFqn, sd.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - - // not a message, but same scoping rules for nested elements as if it were - scope := messageScope(svcFqn, isProto3(fd), l, fd) - scopes = append(scopes, scope) - - for _, mtd := range sd.Method { - if mtd.Options != nil { - if err := l.resolveOptions(r, fd, "method", svcFqn+"."+mtd.GetName(), mtd.Options.UninterpretedOption, scopes); err != nil { - return err - } - } - scope := fmt.Sprintf("method %s.%s", svcFqn, mtd.GetName()) - node := r.getMethodNode(mtd) - fqn, dsc, _ := l.resolve(fd, mtd.GetInputType(), false, scopes) - if dsc == nil { - if err := l.errs.handleErrorWithPos(node.GetInputType().Start(), "%s: unknown request type %s", scope, mtd.GetInputType()); err != nil { - return err - } - } else if dsc == sentinelMissingSymbol { - if err := l.errs.handleErrorWithPos(node.GetInputType().Start(), "%s: unknown request type %s; resolved to %s which is not defined; consider using a leading dot", scope, mtd.GetInputType(), fqn); err != nil { - return err - } - } else if _, ok := dsc.(*dpb.DescriptorProto); !ok { - if err := l.errs.handleErrorWithPos(node.GetInputType().Start(), "%s: invalid request type: %s is %s, not a message", scope, fqn, descriptorTypeWithArticle(dsc)); err != nil { - return err - } - } else { - mtd.InputType = proto.String("." + fqn) - } - - // TODO: make input and output type resolution more DRY - fqn, dsc, _ = l.resolve(fd, mtd.GetOutputType(), false, scopes) - if dsc == nil { - if err := l.errs.handleErrorWithPos(node.GetOutputType().Start(), "%s: unknown response type %s", scope, mtd.GetOutputType()); err != nil { - return err - } - } else if dsc == sentinelMissingSymbol { - if err := l.errs.handleErrorWithPos(node.GetOutputType().Start(), "%s: unknown response type %s; resolved to %s which is not defined; consider using a leading dot", scope, mtd.GetOutputType(), fqn); err != nil { - return err - } - } else if _, ok := dsc.(*dpb.DescriptorProto); !ok { - if err := l.errs.handleErrorWithPos(node.GetOutputType().Start(), "%s: invalid response type: %s is %s, not a message", scope, fqn, descriptorTypeWithArticle(dsc)); err != nil { - return err - } - } else { - mtd.OutputType = proto.String("." + fqn) - } - } - return nil -} - -func (l *linker) resolveOptions(r *parseResult, fd *dpb.FileDescriptorProto, elemType, elemName string, opts []*dpb.UninterpretedOption, scopes []scope) error { - mc := &messageContext{ - res: r, - elementName: elemName, - elementType: elemType, - } -opts: - for _, opt := range opts { - // resolve any extension names found in option names - for _, nm := range opt.Name { - if nm.GetIsExtension() { - fqn, err := l.resolveExtensionName(nm.GetNamePart(), fd, scopes) - if err != nil { - node := r.getOptionNamePartNode(nm) - if err := l.errs.handleErrorWithPos(node.Start(), "%v%v", mc, err); err != nil { - return err - } - continue opts - } - nm.NamePart = proto.String(fqn) - } - } - // also resolve any extension names found inside message literals in option values - mc.option = opt - optVal := r.getOptionNode(opt).GetValue() - if err := l.resolveOptionValue(r, mc, fd, optVal, scopes); err != nil { - return err - } - mc.option = nil - } - return nil -} - -func (l *linker) resolveOptionValue(r *parseResult, mc *messageContext, fd *dpb.FileDescriptorProto, val ast.ValueNode, scopes []scope) error { - optVal := val.Value() - switch optVal := optVal.(type) { - case []ast.ValueNode: - origPath := mc.optAggPath - defer func() { - mc.optAggPath = origPath - }() - for i, v := range optVal { - mc.optAggPath = fmt.Sprintf("%s[%d]", origPath, i) - if err := l.resolveOptionValue(r, mc, fd, v, scopes); err != nil { - return err - } - } - case []*ast.MessageFieldNode: - origPath := mc.optAggPath - defer func() { - mc.optAggPath = origPath - }() - for _, fld := range optVal { - // check for extension name - if fld.Name.IsExtension() { - fqn, err := l.resolveExtensionName(string(fld.Name.Name.AsIdentifier()), fd, scopes) - if err != nil { - if err := l.errs.handleErrorWithPos(fld.Name.Name.Start(), "%v%v", mc, err); err != nil { - return err - } - } else { - r.optionQualifiedNames[fld.Name.Name] = fqn - } - } - - // recurse into value - mc.optAggPath = origPath - if origPath != "" { - mc.optAggPath += "." - } - if fld.Name.IsExtension() { - mc.optAggPath = fmt.Sprintf("%s[%s]", mc.optAggPath, string(fld.Name.Name.AsIdentifier())) - } else { - mc.optAggPath = fmt.Sprintf("%s%s", mc.optAggPath, string(fld.Name.Name.AsIdentifier())) - } - - if err := l.resolveOptionValue(r, mc, fd, fld.Val, scopes); err != nil { - return err - } - } - } - - return nil -} - -func (l *linker) resolveExtensionName(name string, fd *dpb.FileDescriptorProto, scopes []scope) (string, error) { - fqn, dsc, _ := l.resolve(fd, name, false, scopes) - if dsc == nil { - return "", fmt.Errorf("unknown extension %s", name) - } - if dsc == sentinelMissingSymbol { - return "", fmt.Errorf("unknown extension %s; resolved to %s which is not defined; consider using a leading dot", name, fqn) - } - if ext, ok := dsc.(*dpb.FieldDescriptorProto); !ok { - return "", fmt.Errorf("invalid extension: %s is %s, not an extension", name, descriptorTypeWithArticle(dsc)) - } else if ext.GetExtendee() == "" { - return "", fmt.Errorf("invalid extension: %s is a field but not an extension", name) - } - return "." + fqn, nil -} - -func (l *linker) resolve(fd *dpb.FileDescriptorProto, name string, onlyTypes bool, scopes []scope) (fqn string, element proto.Message, proto3 bool) { - if strings.HasPrefix(name, ".") { - // already fully-qualified - d, proto3 := l.findSymbol(fd, name[1:]) - if d != nil { - return name[1:], d, proto3 - } - return "", nil, false - } - // unqualified, so we look in the enclosing (last) scope first and move - // towards outermost (first) scope, trying to resolve the symbol - pos := strings.IndexByte(name, '.') - firstName := name - if pos > 0 { - firstName = name[:pos] - } - var bestGuess proto.Message - var bestGuessFqn string - var bestGuessProto3 bool - for i := len(scopes) - 1; i >= 0; i-- { - fqn, d, proto3 := scopes[i](firstName, name) - if d != nil { - // In `protoc`, it will skip a match of the wrong type and move on - // to the next scope, but only if the reference is unqualified. So - // we mirror that behavior here. When we skip and move on, we go - // ahead and save the match of the wrong type so we can at least use - // it to construct a better error in the event that we don't find - // any match of the right type. - if !onlyTypes || isType(d) || firstName != name { - return fqn, d, proto3 - } else if bestGuess == nil { - bestGuess = d - bestGuessFqn = fqn - bestGuessProto3 = proto3 - } - } - } - // we return best guess, even though it was not an allowed kind of - // descriptor, so caller can print a better error message (e.g. - // indicating that the name was found but that it's the wrong type) - return bestGuessFqn, bestGuess, bestGuessProto3 -} - -func isType(m proto.Message) bool { - switch m.(type) { - case *dpb.DescriptorProto, *dpb.EnumDescriptorProto: - return true - } - return false -} - -// scope represents a lexical scope in a proto file in which messages and enums -// can be declared. -type scope func(firstName, fullName string) (fqn string, element proto.Message, proto3 bool) - -func fileScope(fd *dpb.FileDescriptorProto, l *linker) scope { - // we search symbols in this file, but also symbols in other files that have - // the same package as this file or a "parent" package (in protobuf, - // packages are a hierarchy like C++ namespaces) - prefixes := internal.CreatePrefixList(fd.GetPackage()) - querySymbol := func(n string) (d proto.Message, isProto3 bool) { - return l.findSymbol(fd, n) - } - return func(firstName, fullName string) (string, proto.Message, bool) { - for _, prefix := range prefixes { - var n1, n string - if prefix == "" { - // exhausted all prefixes, so it must be in this one - n1, n = fullName, fullName - } else { - n = prefix + "." + fullName - n1 = prefix + "." + firstName - } - d, proto3 := findSymbolRelative(n1, n, querySymbol) - if d != nil { - return n, d, proto3 - } - } - return "", nil, false - } -} - -func messageScope(messageName string, proto3 bool, l *linker, fd *dpb.FileDescriptorProto) scope { - querySymbol := func(n string) (d proto.Message, isProto3 bool) { - return l.findSymbolInFile(n, fd), false - } - return func(firstName, fullName string) (string, proto.Message, bool) { - n1 := messageName + "." + firstName - n := messageName + "." + fullName - d, _ := findSymbolRelative(n1, n, querySymbol) - if d != nil { - return n, d, proto3 - } - return "", nil, false - } -} - -func findSymbolRelative(firstName, fullName string, query func(name string) (d proto.Message, isProto3 bool)) (d proto.Message, isProto3 bool) { - d, proto3 := query(firstName) - if d == nil { - return nil, false - } - if firstName == fullName { - return d, proto3 - } - if !isAggregateDescriptor(d) { - // can't possibly find the rest of full name if - // the first name indicated a leaf descriptor - return nil, false - } - d, proto3 = query(fullName) - if d == nil { - return sentinelMissingSymbol, false - } - return d, proto3 -} - -func (l *linker) findSymbolInFile(name string, fd *dpb.FileDescriptorProto) proto.Message { - d, ok := l.descriptorPool[fd][name] - if ok { - return d - } - _, ok = l.packageNamespaces[fd][name] - if ok { - // this sentinel means the name is a valid namespace but - // does not refer to a descriptor - return sentinelMissingSymbol - } - return nil -} - -func (l *linker) markUsed(entryPoint, used *dpb.FileDescriptorProto) { - importsForFile := l.usedImports[entryPoint] - if importsForFile == nil { - importsForFile = map[string]struct{}{} - l.usedImports[entryPoint] = importsForFile - } - importsForFile[used.GetName()] = struct{}{} -} - -func isAggregateDescriptor(m proto.Message) bool { - if m == sentinelMissingSymbol { - // this indicates the name matched a package, not a - // descriptor, but a package is an aggregate so - // we return true - return true - } - switch m.(type) { - case *dpb.DescriptorProto, *dpb.EnumDescriptorProto, *dpb.ServiceDescriptorProto: - return true - default: - return false - } -} - -// This value is a bogus/nil value, but results in a non-nil -// proto.Message interface value. So we use it as a sentinel -// to indicate "stop searching for symbol... because it -// definitively does not exist". -var sentinelMissingSymbol = (*dpb.DescriptorProto)(nil) - -func (l *linker) findSymbol(fd *dpb.FileDescriptorProto, name string) (element proto.Message, proto3 bool) { - return l.findSymbolRecursive(fd, fd, name, false, map[*dpb.FileDescriptorProto]struct{}{}) -} - -func (l *linker) findSymbolRecursive(entryPoint, fd *dpb.FileDescriptorProto, name string, public bool, checked map[*dpb.FileDescriptorProto]struct{}) (element proto.Message, proto3 bool) { - if _, ok := checked[fd]; ok { - // already checked this one - return nil, false - } - checked[fd] = struct{}{} - d := l.findSymbolInFile(name, fd) - if d != nil { - return d, isProto3(fd) - } - - // When public = false, we are searching only directly imported symbols. But we - // also need to search transitive public imports due to semantics of public imports. - if public { - for _, depIndex := range fd.PublicDependency { - dep := fd.Dependency[depIndex] - depres := l.files[dep] - if depres == nil { - // we'll catch this error later - continue - } - if d, proto3 := l.findSymbolRecursive(entryPoint, depres.fd, name, true, checked); d != nil { - l.markUsed(entryPoint, depres.fd) - return d, proto3 - } - } - } else { - for _, dep := range fd.Dependency { - depres := l.files[dep] - if depres == nil { - // we'll catch this error later - continue - } - if d, proto3 := l.findSymbolRecursive(entryPoint, depres.fd, name, true, checked); d != nil { - l.markUsed(entryPoint, depres.fd) - return d, proto3 - } - } - } - - return nil, false -} - -func isProto3(fd *dpb.FileDescriptorProto) bool { - return fd.GetSyntax() == "proto3" -} - -func (l *linker) createdLinkedDescriptors() (map[string]*desc.FileDescriptor, error) { - names := make([]string, 0, len(l.files)) - for name := range l.files { - names = append(names, name) - } - sort.Strings(names) - linked := map[string]*desc.FileDescriptor{} - for _, name := range names { - if _, err := l.linkFile(name, nil, nil, linked); err != nil { - return nil, err - } - } - return linked, nil -} - -func (l *linker) linkFile(name string, rootImportLoc *SourcePos, seen []string, linked map[string]*desc.FileDescriptor) (*desc.FileDescriptor, error) { - // check for import cycle - for _, s := range seen { - if name == s { - var msg bytes.Buffer - first := true - for _, s := range seen { - if first { - first = false - } else { - msg.WriteString(" -> ") - } - _, _ = fmt.Fprintf(&msg, "%q", s) - } - _, _ = fmt.Fprintf(&msg, " -> %q", name) - return nil, ErrorWithSourcePos{ - Underlying: fmt.Errorf("cycle found in imports: %s", msg.String()), - Pos: rootImportLoc, - } - } - } - seen = append(seen, name) - - if lfd, ok := linked[name]; ok { - // already linked - return lfd, nil - } - r := l.files[name] - if r == nil { - importer := seen[len(seen)-2] // len-1 is *this* file, before that is the one that imported it - return nil, fmt.Errorf("no descriptor found for %q, imported by %q", name, importer) - } - var deps []*desc.FileDescriptor - if rootImportLoc == nil { - // try to find a source location for this "root" import - decl := r.getFileNode(r.fd) - fnode, ok := decl.(*ast.FileNode) - if ok { - for _, decl := range fnode.Decls { - if dep, ok := decl.(*ast.ImportNode); ok { - ldep, err := l.linkFile(dep.Name.AsString(), dep.Name.Start(), seen, linked) - if err != nil { - return nil, err - } - deps = append(deps, ldep) - } - } - } else { - // no AST? just use the descriptor - for _, dep := range r.fd.Dependency { - ldep, err := l.linkFile(dep, decl.Start(), seen, linked) - if err != nil { - return nil, err - } - deps = append(deps, ldep) - } - } - } else { - // we can just use the descriptor since we don't need source location - // (we'll just attribute any import cycles found to the "root" import) - for _, dep := range r.fd.Dependency { - ldep, err := l.linkFile(dep, rootImportLoc, seen, linked) - if err != nil { - return nil, err - } - deps = append(deps, ldep) - } - } - lfd, err := desc.CreateFileDescriptor(r.fd, deps...) - if err != nil { - return nil, fmt.Errorf("error linking %q: %s", name, err) - } - linked[name] = lfd - return lfd, nil -} - -func (l *linker) checkForUnusedImports(filename string) { - r := l.files[filename] - usedImports := l.usedImports[r.fd] - node := r.nodes[r.fd] - fileNode, _ := node.(*ast.FileNode) - for i, dep := range r.fd.Dependency { - if _, ok := usedImports[dep]; !ok { - isPublic := false - // it's fine if it's a public import - for _, j := range r.fd.PublicDependency { - if i == int(j) { - isPublic = true - break - } - } - if isPublic { - break - } - var pos *SourcePos - if fileNode != nil { - for _, decl := range fileNode.Decls { - imp, ok := decl.(*ast.ImportNode) - if !ok { - continue - } - if imp.Name.AsString() == dep { - pos = imp.Start() - } - } - } - if pos == nil { - pos = ast.UnknownPos(r.fd.GetName()) - } - l.errs.warnWithPos(pos, errUnusedImport(dep)) - } - } -} - -func (l *linker) checkExtensionsInFile(fd *desc.FileDescriptor, res *parseResult) error { - for _, fld := range fd.GetExtensions() { - if err := l.checkExtension(fld, res); err != nil { - return err - } - } - for _, md := range fd.GetMessageTypes() { - if err := l.checkExtensionsInMessage(md, res); err != nil { - return err - } - } - return nil -} - -func (l *linker) checkExtensionsInMessage(md *desc.MessageDescriptor, res *parseResult) error { - for _, fld := range md.GetNestedExtensions() { - if err := l.checkExtension(fld, res); err != nil { - return err - } - } - for _, nmd := range md.GetNestedMessageTypes() { - if err := l.checkExtensionsInMessage(nmd, res); err != nil { - return err - } - } - return nil -} - -func (l *linker) checkExtension(fld *desc.FieldDescriptor, res *parseResult) error { - // NB: It's a little gross that we don't enforce these in validateBasic(). - // But requires some minimal linking to resolve the extendee, so we can - // interrogate its descriptor. - if fld.GetOwner().GetMessageOptions().GetMessageSetWireFormat() { - // Message set wire format requires that all extensions be messages - // themselves (no scalar extensions) - if fld.GetType() != dpb.FieldDescriptorProto_TYPE_MESSAGE { - pos := res.getFieldNode(fld.AsFieldDescriptorProto()).FieldType().Start() - return l.errs.handleErrorWithPos(pos, "messages with message-set wire format cannot contain scalar extensions, only messages") - } - if fld.IsRepeated() { - pos := res.getFieldNode(fld.AsFieldDescriptorProto()).FieldLabel().Start() - return l.errs.handleErrorWithPos(pos, "messages with message-set wire format cannot contain repeated extensions, only optional") - } - } else { - // In validateBasic() we just made sure these were within bounds for any message. But - // now that things are linked, we can check if the extendee is messageset wire format - // and, if not, enforce tighter limit. - if fld.GetNumber() > internal.MaxNormalTag { - pos := res.getFieldNode(fld.AsFieldDescriptorProto()).FieldTag().Start() - return l.errs.handleErrorWithPos(pos, "tag number %d is higher than max allowed tag number (%d)", fld.GetNumber(), internal.MaxNormalTag) - } - } - - return nil -} - -func (l *linker) checkJsonNamesInFile(fd *desc.FileDescriptor, res *parseResult) error { - for _, md := range fd.GetMessageTypes() { - if err := l.checkJsonNamesInMessage(md, res); err != nil { - return err - } - } - for _, ed := range fd.GetEnumTypes() { - if err := l.checkJsonNamesInEnum(ed, res); err != nil { - return err - } - } - return nil -} - -func (l *linker) checkJsonNamesInMessage(md *desc.MessageDescriptor, res *parseResult) error { - if err := checkFieldJsonNames(md, res, false); err != nil { - return err - } - if err := checkFieldJsonNames(md, res, true); err != nil { - return err - } - - for _, nmd := range md.GetNestedMessageTypes() { - if err := l.checkJsonNamesInMessage(nmd, res); err != nil { - return err - } - } - for _, ed := range md.GetNestedEnumTypes() { - if err := l.checkJsonNamesInEnum(ed, res); err != nil { - return err - } - } - return nil -} - -func (l *linker) checkJsonNamesInEnum(ed *desc.EnumDescriptor, res *parseResult) error { - seen := map[string]*dpb.EnumValueDescriptorProto{} - for _, evd := range ed.GetValues() { - scope := "enum value " + ed.GetName() + "." + evd.GetName() - - name := canonicalEnumValueName(evd.GetName(), ed.GetName()) - if existing, ok := seen[name]; ok && evd.GetNumber() != existing.GetNumber() { - fldNode := res.getEnumValueNode(evd.AsEnumValueDescriptorProto()) - existingNode := res.getEnumValueNode(existing) - isProto3 := ed.GetFile().IsProto3() - conflictErr := errorWithPos(fldNode.Start(), "%s: camel-case name (with optional enum name prefix removed) %q conflicts with camel-case name of enum value %s, defined at %v", - scope, name, existing.GetName(), existingNode.Start()) - - // Since proto2 did not originally have a JSON format, we report conflicts as just warnings - if !isProto3 { - res.errs.warn(conflictErr) - } else if err := res.errs.handleError(conflictErr); err != nil { - return err - } - } else { - seen[name] = evd.AsEnumValueDescriptorProto() - } - } - return nil -} - -func canonicalEnumValueName(enumValueName, enumName string) string { - return enumValCamelCase(removePrefix(enumValueName, enumName)) -} - -// removePrefix is used to remove the given prefix from the given str. It does not require -// an exact match and ignores case and underscores. If the all non-underscore characters -// would be removed from str, str is returned unchanged. If str does not have the given -// prefix (even with the very lenient matching, in regard to case and underscores), then -// str is returned unchanged. -// -// The algorithm is adapted from the protoc source: -// -// https://github.com/protocolbuffers/protobuf/blob/v21.3/src/google/protobuf/descriptor.cc#L922 -func removePrefix(str, prefix string) string { - j := 0 - for i, r := range str { - if r == '_' { - // skip underscores in the input - continue - } - - p, sz := utf8.DecodeRuneInString(prefix[j:]) - for p == '_' { - j += sz // consume/skip underscore - p, sz = utf8.DecodeRuneInString(prefix[j:]) - } - - if j == len(prefix) { - // matched entire prefix; return rest of str - // but skipping any leading underscores - result := strings.TrimLeft(str[i:], "_") - if len(result) == 0 { - // result can't be empty string - return str - } - return result - } - if unicode.ToLower(r) != unicode.ToLower(p) { - // does not match prefix - return str - } - j += sz // consume matched rune of prefix - } - return str -} - -// enumValCamelCase converts the given string to upper-camel-case. -// -// The algorithm is adapted from the protoc source: -// -// https://github.com/protocolbuffers/protobuf/blob/v21.3/src/google/protobuf/descriptor.cc#L887 -func enumValCamelCase(name string) string { - var js []rune - nextUpper := true - for _, r := range name { - if r == '_' { - nextUpper = true - continue - } - if nextUpper { - nextUpper = false - js = append(js, unicode.ToUpper(r)) - } else { - js = append(js, unicode.ToLower(r)) - } - } - return string(js) -} - -func checkFieldJsonNames(md *desc.MessageDescriptor, res *parseResult, useCustom bool) error { - type jsonName struct { - source *dpb.FieldDescriptorProto - // field's original JSON nane (which can differ in case from map key) - orig string - // true if orig is a custom JSON name (vs. the field's default JSON name) - custom bool - } - seen := map[string]jsonName{} - - for _, fd := range md.GetFields() { - scope := "field " + md.GetName() + "." + fd.GetName() - defaultName := internal.JsonName(fd.GetName()) - name := defaultName - custom := false - if useCustom { - n := fd.GetJSONName() - if n != defaultName || hasCustomJsonName(res, fd) { - name = n - custom = true - } - } - lcaseName := strings.ToLower(name) - if existing, ok := seen[lcaseName]; ok { - // When useCustom is true, we'll only report an issue when a conflict is - // due to a custom name. That way, we don't double report conflicts on - // non-custom names. - if !useCustom || custom || existing.custom { - fldNode := res.getFieldNode(fd.AsFieldDescriptorProto()) - customStr, srcCustomStr := "custom", "custom" - if !custom { - customStr = "default" - } - if !existing.custom { - srcCustomStr = "default" - } - otherName := "" - if name != existing.orig { - otherName = fmt.Sprintf(" %q", existing.orig) - } - conflictErr := errorWithPos(fldNode.Start(), "%s: %s JSON name %q conflicts with %s JSON name%s of field %s, defined at %v", - scope, customStr, name, srcCustomStr, otherName, existing.source.GetName(), res.getFieldNode(existing.source).Start()) - - // Since proto2 did not originally have default JSON names, we report conflicts involving - // default names as just warnings. - if !md.IsProto3() && (!custom || !existing.custom) { - res.errs.warn(conflictErr) - } else if err := res.errs.handleError(conflictErr); err != nil { - return err - } - } - } else { - seen[lcaseName] = jsonName{source: fd.AsFieldDescriptorProto(), orig: name, custom: custom} - } - } - return nil -} - -func hasCustomJsonName(res *parseResult, fd *desc.FieldDescriptor) bool { - // if we have the AST, we can more precisely determine if there was a custom - // JSON named defined, even if it is explicitly configured to tbe the same - // as the default JSON name for the field. - fdProto := fd.AsFieldDescriptorProto() - opts := res.getFieldNode(fdProto).GetOptions() - if opts == nil { - return false - } - for _, opt := range opts.Options { - if len(opt.Name.Parts) == 1 && - opt.Name.Parts[0].Name.AsIdentifier() == "json_name" && - !opt.Name.Parts[0].IsExtension() { - return true - } - } - return false -} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/options.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/options.go deleted file mode 100644 index f9f306bbf0d..00000000000 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/options.go +++ /dev/null @@ -1,1581 +0,0 @@ -package protoparse - -import ( - "bytes" - "fmt" - "math" - - "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" - - "github.com/jhump/protoreflect/desc" - "github.com/jhump/protoreflect/desc/internal" - "github.com/jhump/protoreflect/desc/protoparse/ast" - "github.com/jhump/protoreflect/dynamic" -) - -// NB: To process options, we need descriptors, but we may not have rich -// descriptors when trying to interpret options for unlinked parsed files. -// So we define minimal interfaces that can be backed by both rich descriptors -// as well as their poorer cousins, plain ol' descriptor protos. - -type descriptorish interface { - GetFile() fileDescriptorish - GetFullyQualifiedName() string - AsProto() proto.Message -} - -type fileDescriptorish interface { - descriptorish - GetFileOptions() *dpb.FileOptions - GetPackage() string - FindSymbol(name string) desc.Descriptor - GetPublicDependencies() []fileDescriptorish - GetDependencies() []fileDescriptorish - GetMessageTypes() []msgDescriptorish - GetExtensions() []fldDescriptorish - GetEnumTypes() []enumDescriptorish - GetServices() []svcDescriptorish -} - -type msgDescriptorish interface { - descriptorish - GetMessageOptions() *dpb.MessageOptions - GetFields() []fldDescriptorish - GetOneOfs() []oneofDescriptorish - GetExtensionRanges() []extRangeDescriptorish - GetNestedMessageTypes() []msgDescriptorish - GetNestedExtensions() []fldDescriptorish - GetNestedEnumTypes() []enumDescriptorish -} - -type fldDescriptorish interface { - descriptorish - GetFieldOptions() *dpb.FieldOptions - GetMessageType() *desc.MessageDescriptor - GetEnumType() *desc.EnumDescriptor - AsFieldDescriptorProto() *dpb.FieldDescriptorProto -} - -type oneofDescriptorish interface { - descriptorish - GetOneOfOptions() *dpb.OneofOptions -} - -type enumDescriptorish interface { - descriptorish - GetEnumOptions() *dpb.EnumOptions - GetValues() []enumValDescriptorish -} - -type enumValDescriptorish interface { - descriptorish - GetEnumValueOptions() *dpb.EnumValueOptions -} - -type svcDescriptorish interface { - descriptorish - GetServiceOptions() *dpb.ServiceOptions - GetMethods() []methodDescriptorish -} - -type methodDescriptorish interface { - descriptorish - GetMethodOptions() *dpb.MethodOptions -} - -// The hierarchy of descriptorish implementations backed by -// rich descriptors: - -type richFileDescriptorish struct { - *desc.FileDescriptor -} - -func (d richFileDescriptorish) GetFile() fileDescriptorish { - return d -} - -func (d richFileDescriptorish) GetPublicDependencies() []fileDescriptorish { - deps := d.FileDescriptor.GetPublicDependencies() - ret := make([]fileDescriptorish, len(deps)) - for i, d := range deps { - ret[i] = richFileDescriptorish{FileDescriptor: d} - } - return ret -} - -func (d richFileDescriptorish) GetDependencies() []fileDescriptorish { - deps := d.FileDescriptor.GetDependencies() - ret := make([]fileDescriptorish, len(deps)) - for i, d := range deps { - ret[i] = richFileDescriptorish{FileDescriptor: d} - } - return ret -} - -func (d richFileDescriptorish) GetMessageTypes() []msgDescriptorish { - msgs := d.FileDescriptor.GetMessageTypes() - ret := make([]msgDescriptorish, len(msgs)) - for i, m := range msgs { - ret[i] = richMsgDescriptorish{MessageDescriptor: m} - } - return ret -} - -func (d richFileDescriptorish) GetExtensions() []fldDescriptorish { - flds := d.FileDescriptor.GetExtensions() - ret := make([]fldDescriptorish, len(flds)) - for i, f := range flds { - ret[i] = richFldDescriptorish{FieldDescriptor: f} - } - return ret -} - -func (d richFileDescriptorish) GetEnumTypes() []enumDescriptorish { - ens := d.FileDescriptor.GetEnumTypes() - ret := make([]enumDescriptorish, len(ens)) - for i, en := range ens { - ret[i] = richEnumDescriptorish{EnumDescriptor: en} - } - return ret -} - -func (d richFileDescriptorish) GetServices() []svcDescriptorish { - svcs := d.FileDescriptor.GetServices() - ret := make([]svcDescriptorish, len(svcs)) - for i, s := range svcs { - ret[i] = richSvcDescriptorish{ServiceDescriptor: s} - } - return ret -} - -type richMsgDescriptorish struct { - *desc.MessageDescriptor -} - -func (d richMsgDescriptorish) GetFile() fileDescriptorish { - return richFileDescriptorish{FileDescriptor: d.MessageDescriptor.GetFile()} -} - -func (d richMsgDescriptorish) GetFields() []fldDescriptorish { - flds := d.MessageDescriptor.GetFields() - ret := make([]fldDescriptorish, len(flds)) - for i, f := range flds { - ret[i] = richFldDescriptorish{FieldDescriptor: f} - } - return ret -} - -func (d richMsgDescriptorish) GetOneOfs() []oneofDescriptorish { - oos := d.MessageDescriptor.GetOneOfs() - ret := make([]oneofDescriptorish, len(oos)) - for i, oo := range oos { - ret[i] = richOneOfDescriptorish{OneOfDescriptor: oo} - } - return ret -} - -func (d richMsgDescriptorish) GetExtensionRanges() []extRangeDescriptorish { - md := d.MessageDescriptor - mdFqn := md.GetFullyQualifiedName() - extrs := md.AsDescriptorProto().GetExtensionRange() - ret := make([]extRangeDescriptorish, len(extrs)) - for i, extr := range extrs { - ret[i] = extRangeDescriptorish{ - er: extr, - qual: mdFqn, - file: richFileDescriptorish{FileDescriptor: md.GetFile()}, - } - } - return ret -} - -func (d richMsgDescriptorish) GetNestedMessageTypes() []msgDescriptorish { - msgs := d.MessageDescriptor.GetNestedMessageTypes() - ret := make([]msgDescriptorish, len(msgs)) - for i, m := range msgs { - ret[i] = richMsgDescriptorish{MessageDescriptor: m} - } - return ret -} - -func (d richMsgDescriptorish) GetNestedExtensions() []fldDescriptorish { - flds := d.MessageDescriptor.GetNestedExtensions() - ret := make([]fldDescriptorish, len(flds)) - for i, f := range flds { - ret[i] = richFldDescriptorish{FieldDescriptor: f} - } - return ret -} - -func (d richMsgDescriptorish) GetNestedEnumTypes() []enumDescriptorish { - ens := d.MessageDescriptor.GetNestedEnumTypes() - ret := make([]enumDescriptorish, len(ens)) - for i, en := range ens { - ret[i] = richEnumDescriptorish{EnumDescriptor: en} - } - return ret -} - -type richFldDescriptorish struct { - *desc.FieldDescriptor -} - -func (d richFldDescriptorish) GetFile() fileDescriptorish { - return richFileDescriptorish{FileDescriptor: d.FieldDescriptor.GetFile()} -} - -func (d richFldDescriptorish) AsFieldDescriptorProto() *dpb.FieldDescriptorProto { - return d.FieldDescriptor.AsFieldDescriptorProto() -} - -type richOneOfDescriptorish struct { - *desc.OneOfDescriptor -} - -func (d richOneOfDescriptorish) GetFile() fileDescriptorish { - return richFileDescriptorish{FileDescriptor: d.OneOfDescriptor.GetFile()} -} - -type richEnumDescriptorish struct { - *desc.EnumDescriptor -} - -func (d richEnumDescriptorish) GetFile() fileDescriptorish { - return richFileDescriptorish{FileDescriptor: d.EnumDescriptor.GetFile()} -} - -func (d richEnumDescriptorish) GetValues() []enumValDescriptorish { - vals := d.EnumDescriptor.GetValues() - ret := make([]enumValDescriptorish, len(vals)) - for i, val := range vals { - ret[i] = richEnumValDescriptorish{EnumValueDescriptor: val} - } - return ret -} - -type richEnumValDescriptorish struct { - *desc.EnumValueDescriptor -} - -func (d richEnumValDescriptorish) GetFile() fileDescriptorish { - return richFileDescriptorish{FileDescriptor: d.EnumValueDescriptor.GetFile()} -} - -type richSvcDescriptorish struct { - *desc.ServiceDescriptor -} - -func (d richSvcDescriptorish) GetFile() fileDescriptorish { - return richFileDescriptorish{FileDescriptor: d.ServiceDescriptor.GetFile()} -} - -func (d richSvcDescriptorish) GetMethods() []methodDescriptorish { - mtds := d.ServiceDescriptor.GetMethods() - ret := make([]methodDescriptorish, len(mtds)) - for i, mtd := range mtds { - ret[i] = richMethodDescriptorish{MethodDescriptor: mtd} - } - return ret -} - -type richMethodDescriptorish struct { - *desc.MethodDescriptor -} - -func (d richMethodDescriptorish) GetFile() fileDescriptorish { - return richFileDescriptorish{FileDescriptor: d.MethodDescriptor.GetFile()} -} - -// The hierarchy of descriptorish implementations backed by -// plain descriptor protos: - -type poorFileDescriptorish struct { - *dpb.FileDescriptorProto -} - -func (d poorFileDescriptorish) GetFile() fileDescriptorish { - return d -} - -func (d poorFileDescriptorish) GetFullyQualifiedName() string { - return d.FileDescriptorProto.GetName() -} - -func (d poorFileDescriptorish) AsProto() proto.Message { - return d.FileDescriptorProto -} - -func (d poorFileDescriptorish) GetFileOptions() *dpb.FileOptions { - return d.FileDescriptorProto.GetOptions() -} - -func (d poorFileDescriptorish) FindSymbol(name string) desc.Descriptor { - return nil -} - -func (d poorFileDescriptorish) GetPublicDependencies() []fileDescriptorish { - return nil -} - -func (d poorFileDescriptorish) GetDependencies() []fileDescriptorish { - return nil -} - -func (d poorFileDescriptorish) GetMessageTypes() []msgDescriptorish { - msgs := d.FileDescriptorProto.GetMessageType() - pkg := d.FileDescriptorProto.GetPackage() - ret := make([]msgDescriptorish, len(msgs)) - for i, m := range msgs { - ret[i] = poorMsgDescriptorish{ - DescriptorProto: m, - qual: pkg, - file: d, - } - } - return ret -} - -func (d poorFileDescriptorish) GetExtensions() []fldDescriptorish { - exts := d.FileDescriptorProto.GetExtension() - pkg := d.FileDescriptorProto.GetPackage() - ret := make([]fldDescriptorish, len(exts)) - for i, e := range exts { - ret[i] = poorFldDescriptorish{ - FieldDescriptorProto: e, - qual: pkg, - file: d, - } - } - return ret -} - -func (d poorFileDescriptorish) GetEnumTypes() []enumDescriptorish { - ens := d.FileDescriptorProto.GetEnumType() - pkg := d.FileDescriptorProto.GetPackage() - ret := make([]enumDescriptorish, len(ens)) - for i, e := range ens { - ret[i] = poorEnumDescriptorish{ - EnumDescriptorProto: e, - qual: pkg, - file: d, - } - } - return ret -} - -func (d poorFileDescriptorish) GetServices() []svcDescriptorish { - svcs := d.FileDescriptorProto.GetService() - pkg := d.FileDescriptorProto.GetPackage() - ret := make([]svcDescriptorish, len(svcs)) - for i, s := range svcs { - ret[i] = poorSvcDescriptorish{ - ServiceDescriptorProto: s, - qual: pkg, - file: d, - } - } - return ret -} - -type poorMsgDescriptorish struct { - *dpb.DescriptorProto - qual string - file fileDescriptorish -} - -func (d poorMsgDescriptorish) GetFile() fileDescriptorish { - return d.file -} - -func (d poorMsgDescriptorish) GetFullyQualifiedName() string { - return qualify(d.qual, d.DescriptorProto.GetName()) -} - -func qualify(qual, name string) string { - if qual == "" { - return name - } else { - return fmt.Sprintf("%s.%s", qual, name) - } -} - -func (d poorMsgDescriptorish) AsProto() proto.Message { - return d.DescriptorProto -} - -func (d poorMsgDescriptorish) GetMessageOptions() *dpb.MessageOptions { - return d.DescriptorProto.GetOptions() -} - -func (d poorMsgDescriptorish) GetFields() []fldDescriptorish { - flds := d.DescriptorProto.GetField() - ret := make([]fldDescriptorish, len(flds)) - for i, f := range flds { - ret[i] = poorFldDescriptorish{ - FieldDescriptorProto: f, - qual: d.GetFullyQualifiedName(), - file: d.file, - } - } - return ret -} - -func (d poorMsgDescriptorish) GetOneOfs() []oneofDescriptorish { - oos := d.DescriptorProto.GetOneofDecl() - ret := make([]oneofDescriptorish, len(oos)) - for i, oo := range oos { - ret[i] = poorOneOfDescriptorish{ - OneofDescriptorProto: oo, - qual: d.GetFullyQualifiedName(), - file: d.file, - } - } - return ret -} - -func (d poorMsgDescriptorish) GetExtensionRanges() []extRangeDescriptorish { - mdFqn := d.GetFullyQualifiedName() - extrs := d.DescriptorProto.GetExtensionRange() - ret := make([]extRangeDescriptorish, len(extrs)) - for i, extr := range extrs { - ret[i] = extRangeDescriptorish{ - er: extr, - qual: mdFqn, - file: d.file, - } - } - return ret -} - -func (d poorMsgDescriptorish) GetNestedMessageTypes() []msgDescriptorish { - msgs := d.DescriptorProto.GetNestedType() - ret := make([]msgDescriptorish, len(msgs)) - for i, m := range msgs { - ret[i] = poorMsgDescriptorish{ - DescriptorProto: m, - qual: d.GetFullyQualifiedName(), - file: d.file, - } - } - return ret -} - -func (d poorMsgDescriptorish) GetNestedExtensions() []fldDescriptorish { - flds := d.DescriptorProto.GetExtension() - ret := make([]fldDescriptorish, len(flds)) - for i, f := range flds { - ret[i] = poorFldDescriptorish{ - FieldDescriptorProto: f, - qual: d.GetFullyQualifiedName(), - file: d.file, - } - } - return ret -} - -func (d poorMsgDescriptorish) GetNestedEnumTypes() []enumDescriptorish { - ens := d.DescriptorProto.GetEnumType() - ret := make([]enumDescriptorish, len(ens)) - for i, en := range ens { - ret[i] = poorEnumDescriptorish{ - EnumDescriptorProto: en, - qual: d.GetFullyQualifiedName(), - file: d.file, - } - } - return ret -} - -type poorFldDescriptorish struct { - *dpb.FieldDescriptorProto - qual string - file fileDescriptorish -} - -func (d poorFldDescriptorish) GetFile() fileDescriptorish { - return d.file -} - -func (d poorFldDescriptorish) GetFullyQualifiedName() string { - return qualify(d.qual, d.FieldDescriptorProto.GetName()) -} - -func (d poorFldDescriptorish) AsProto() proto.Message { - return d.FieldDescriptorProto -} - -func (d poorFldDescriptorish) GetFieldOptions() *dpb.FieldOptions { - return d.FieldDescriptorProto.GetOptions() -} - -func (d poorFldDescriptorish) GetMessageType() *desc.MessageDescriptor { - return nil -} - -func (d poorFldDescriptorish) GetEnumType() *desc.EnumDescriptor { - return nil -} - -type poorOneOfDescriptorish struct { - *dpb.OneofDescriptorProto - qual string - file fileDescriptorish -} - -func (d poorOneOfDescriptorish) GetFile() fileDescriptorish { - return d.file -} - -func (d poorOneOfDescriptorish) GetFullyQualifiedName() string { - return qualify(d.qual, d.OneofDescriptorProto.GetName()) -} - -func (d poorOneOfDescriptorish) AsProto() proto.Message { - return d.OneofDescriptorProto -} - -func (d poorOneOfDescriptorish) GetOneOfOptions() *dpb.OneofOptions { - return d.OneofDescriptorProto.GetOptions() -} - -func (d poorFldDescriptorish) AsFieldDescriptorProto() *dpb.FieldDescriptorProto { - return d.FieldDescriptorProto -} - -type poorEnumDescriptorish struct { - *dpb.EnumDescriptorProto - qual string - file fileDescriptorish -} - -func (d poorEnumDescriptorish) GetFile() fileDescriptorish { - return d.file -} - -func (d poorEnumDescriptorish) GetFullyQualifiedName() string { - return qualify(d.qual, d.EnumDescriptorProto.GetName()) -} - -func (d poorEnumDescriptorish) AsProto() proto.Message { - return d.EnumDescriptorProto -} - -func (d poorEnumDescriptorish) GetEnumOptions() *dpb.EnumOptions { - return d.EnumDescriptorProto.GetOptions() -} - -func (d poorEnumDescriptorish) GetValues() []enumValDescriptorish { - vals := d.EnumDescriptorProto.GetValue() - ret := make([]enumValDescriptorish, len(vals)) - for i, v := range vals { - ret[i] = poorEnumValDescriptorish{ - EnumValueDescriptorProto: v, - qual: d.GetFullyQualifiedName(), - file: d.file, - } - } - return ret -} - -type poorEnumValDescriptorish struct { - *dpb.EnumValueDescriptorProto - qual string - file fileDescriptorish -} - -func (d poorEnumValDescriptorish) GetFile() fileDescriptorish { - return d.file -} - -func (d poorEnumValDescriptorish) GetFullyQualifiedName() string { - return qualify(d.qual, d.EnumValueDescriptorProto.GetName()) -} - -func (d poorEnumValDescriptorish) AsProto() proto.Message { - return d.EnumValueDescriptorProto -} - -func (d poorEnumValDescriptorish) GetEnumValueOptions() *dpb.EnumValueOptions { - return d.EnumValueDescriptorProto.GetOptions() -} - -type poorSvcDescriptorish struct { - *dpb.ServiceDescriptorProto - qual string - file fileDescriptorish -} - -func (d poorSvcDescriptorish) GetFile() fileDescriptorish { - return d.file -} - -func (d poorSvcDescriptorish) GetFullyQualifiedName() string { - return qualify(d.qual, d.ServiceDescriptorProto.GetName()) -} - -func (d poorSvcDescriptorish) AsProto() proto.Message { - return d.ServiceDescriptorProto -} - -func (d poorSvcDescriptorish) GetServiceOptions() *dpb.ServiceOptions { - return d.ServiceDescriptorProto.GetOptions() -} - -func (d poorSvcDescriptorish) GetMethods() []methodDescriptorish { - mtds := d.ServiceDescriptorProto.GetMethod() - ret := make([]methodDescriptorish, len(mtds)) - for i, m := range mtds { - ret[i] = poorMethodDescriptorish{ - MethodDescriptorProto: m, - qual: d.GetFullyQualifiedName(), - file: d.file, - } - } - return ret -} - -type poorMethodDescriptorish struct { - *dpb.MethodDescriptorProto - qual string - file fileDescriptorish -} - -func (d poorMethodDescriptorish) GetFile() fileDescriptorish { - return d.file -} - -func (d poorMethodDescriptorish) GetFullyQualifiedName() string { - return qualify(d.qual, d.MethodDescriptorProto.GetName()) -} - -func (d poorMethodDescriptorish) AsProto() proto.Message { - return d.MethodDescriptorProto -} - -func (d poorMethodDescriptorish) GetMethodOptions() *dpb.MethodOptions { - return d.MethodDescriptorProto.GetOptions() -} - -type extRangeDescriptorish struct { - er *dpb.DescriptorProto_ExtensionRange - qual string - file fileDescriptorish -} - -func (er extRangeDescriptorish) GetFile() fileDescriptorish { - return er.file -} - -func (er extRangeDescriptorish) GetFullyQualifiedName() string { - return qualify(er.qual, fmt.Sprintf("%d-%d", er.er.GetStart(), er.er.GetEnd()-1)) -} - -func (er extRangeDescriptorish) AsProto() proto.Message { - return er.er -} - -func (er extRangeDescriptorish) GetExtensionRangeOptions() *dpb.ExtensionRangeOptions { - return er.er.GetOptions() -} - -func interpretFileOptions(l *linker, r *parseResult, fd fileDescriptorish) error { - opts := fd.GetFileOptions() - if opts != nil { - if len(opts.UninterpretedOption) > 0 { - if remain, err := interpretOptions(l, r, fd, opts, opts.UninterpretedOption); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - } - for _, md := range fd.GetMessageTypes() { - if err := interpretMessageOptions(l, r, md); err != nil { - return err - } - } - for _, fld := range fd.GetExtensions() { - if err := interpretFieldOptions(l, r, fld, true); err != nil { - return err - } - } - for _, ed := range fd.GetEnumTypes() { - if err := interpretEnumOptions(l, r, ed); err != nil { - return err - } - } - for _, sd := range fd.GetServices() { - opts := sd.GetServiceOptions() - if len(opts.GetUninterpretedOption()) > 0 { - if remain, err := interpretOptions(l, r, sd, opts, opts.UninterpretedOption); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - for _, mtd := range sd.GetMethods() { - opts := mtd.GetMethodOptions() - if len(opts.GetUninterpretedOption()) > 0 { - if remain, err := interpretOptions(l, r, mtd, opts, opts.UninterpretedOption); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - } - } - return nil -} - -func interpretMessageOptions(l *linker, r *parseResult, md msgDescriptorish) error { - opts := md.GetMessageOptions() - if opts != nil { - if len(opts.UninterpretedOption) > 0 { - if remain, err := interpretOptions(l, r, md, opts, opts.UninterpretedOption); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - } - for _, fld := range md.GetFields() { - if err := interpretFieldOptions(l, r, fld, false); err != nil { - return err - } - } - for _, ood := range md.GetOneOfs() { - opts := ood.GetOneOfOptions() - if len(opts.GetUninterpretedOption()) > 0 { - if remain, err := interpretOptions(l, r, ood, opts, opts.UninterpretedOption); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - } - for _, fld := range md.GetNestedExtensions() { - if err := interpretFieldOptions(l, r, fld, true); err != nil { - return err - } - } - for _, er := range md.GetExtensionRanges() { - opts := er.GetExtensionRangeOptions() - if len(opts.GetUninterpretedOption()) > 0 { - if remain, err := interpretOptions(l, r, er, opts, opts.UninterpretedOption); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - } - for _, nmd := range md.GetNestedMessageTypes() { - if err := interpretMessageOptions(l, r, nmd); err != nil { - return err - } - } - for _, ed := range md.GetNestedEnumTypes() { - if err := interpretEnumOptions(l, r, ed); err != nil { - return err - } - } - return nil -} - -func interpretFieldOptions(l *linker, r *parseResult, fld fldDescriptorish, isExtension bool) error { - opts := fld.GetFieldOptions() - if len(opts.GetUninterpretedOption()) > 0 { - uo := opts.UninterpretedOption - scope := fmt.Sprintf("field %s", fld.GetFullyQualifiedName()) - - // process json_name pseudo-option - if index, err := findOption(r, scope, uo, "json_name"); err != nil && !r.lenient { - return err - } else if index >= 0 { - opt := uo[index] - optNode := r.getOptionNode(opt) - - // attribute source code info - if on, ok := optNode.(*ast.OptionNode); ok { - r.interpretedOptions[on] = []int32{-1, internal.Field_jsonNameTag} - } - uo = removeOption(uo, index) - if opt.StringValue == nil { - if err := r.errs.handleErrorWithPos(optNode.GetValue().Start(), "%s: expecting string value for json_name option", scope); err != nil { - return err - } - } else if isExtension { - if err := r.errs.handleErrorWithPos(optNode.GetName().Start(), "%s: option json_name is not allowed on extensions", scope); err != nil { - return err - } - } else { - fld.AsFieldDescriptorProto().JsonName = proto.String(string(opt.StringValue)) - } - } - - // and process default pseudo-option - if index, err := processDefaultOption(r, scope, fld, uo); err != nil && !r.lenient { - return err - } else if index >= 0 { - // attribute source code info - optNode := r.getOptionNode(uo[index]) - if on, ok := optNode.(*ast.OptionNode); ok { - r.interpretedOptions[on] = []int32{-1, internal.Field_defaultTag} - } - uo = removeOption(uo, index) - } - - if len(uo) == 0 { - // no real options, only pseudo-options above? clear out options - fld.AsFieldDescriptorProto().Options = nil - } else if remain, err := interpretOptions(l, r, fld, opts, uo); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - return nil -} - -func processDefaultOption(res *parseResult, scope string, fld fldDescriptorish, uos []*dpb.UninterpretedOption) (defaultIndex int, err error) { - found, err := findOption(res, scope, uos, "default") - if err != nil || found == -1 { - return -1, err - } - opt := uos[found] - optNode := res.getOptionNode(opt) - fdp := fld.AsFieldDescriptorProto() - if fdp.GetLabel() == dpb.FieldDescriptorProto_LABEL_REPEATED { - return -1, res.errs.handleErrorWithPos(optNode.GetName().Start(), "%s: default value cannot be set because field is repeated", scope) - } - if fdp.GetType() == dpb.FieldDescriptorProto_TYPE_GROUP || fdp.GetType() == dpb.FieldDescriptorProto_TYPE_MESSAGE { - return -1, res.errs.handleErrorWithPos(optNode.GetName().Start(), "%s: default value cannot be set because field is a message", scope) - } - val := optNode.GetValue() - if _, ok := val.(*ast.MessageLiteralNode); ok { - return -1, res.errs.handleErrorWithPos(val.Start(), "%s: default value cannot be a message", scope) - } - mc := &messageContext{ - res: res, - file: fld.GetFile(), - elementName: fld.GetFullyQualifiedName(), - elementType: descriptorType(fld.AsProto()), - option: opt, - } - v, err := fieldValue(res, mc, fld, val, true, false) - if err != nil { - return -1, res.errs.handleError(err) - } - if str, ok := v.(string); ok { - fld.AsFieldDescriptorProto().DefaultValue = proto.String(str) - } else if b, ok := v.([]byte); ok { - fld.AsFieldDescriptorProto().DefaultValue = proto.String(encodeDefaultBytes(b)) - } else { - var flt float64 - var ok bool - if flt, ok = v.(float64); !ok { - var flt32 float32 - if flt32, ok = v.(float32); ok { - flt = float64(flt32) - } - } - if ok { - if math.IsInf(flt, 1) { - fld.AsFieldDescriptorProto().DefaultValue = proto.String("inf") - } else if ok && math.IsInf(flt, -1) { - fld.AsFieldDescriptorProto().DefaultValue = proto.String("-inf") - } else if ok && math.IsNaN(flt) { - fld.AsFieldDescriptorProto().DefaultValue = proto.String("nan") - } else { - fld.AsFieldDescriptorProto().DefaultValue = proto.String(fmt.Sprintf("%v", v)) - } - } else { - fld.AsFieldDescriptorProto().DefaultValue = proto.String(fmt.Sprintf("%v", v)) - } - } - return found, nil -} - -func encodeDefaultBytes(b []byte) string { - var buf bytes.Buffer - writeEscapedBytes(&buf, b) - return buf.String() -} - -func interpretEnumOptions(l *linker, r *parseResult, ed enumDescriptorish) error { - opts := ed.GetEnumOptions() - if opts != nil { - if len(opts.UninterpretedOption) > 0 { - if remain, err := interpretOptions(l, r, ed, opts, opts.UninterpretedOption); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - } - for _, evd := range ed.GetValues() { - opts := evd.GetEnumValueOptions() - if len(opts.GetUninterpretedOption()) > 0 { - if remain, err := interpretOptions(l, r, evd, opts, opts.UninterpretedOption); err != nil { - return err - } else { - opts.UninterpretedOption = remain - } - } - } - return nil -} - -func interpretOptions(l *linker, res *parseResult, element descriptorish, opts proto.Message, uninterpreted []*dpb.UninterpretedOption) ([]*dpb.UninterpretedOption, error) { - optsd, err := loadMessageDescriptorForOptions(l, element.GetFile(), opts) - if err != nil { - if res.lenient { - return uninterpreted, nil - } - return nil, res.errs.handleError(err) - } - dm := dynamic.NewMessage(optsd) - err = dm.ConvertFrom(opts) - if err != nil { - if res.lenient { - return uninterpreted, nil - } - node := res.nodes[element.AsProto()] - return nil, res.errs.handleError(ErrorWithSourcePos{Pos: node.Start(), Underlying: err}) - } - - mc := &messageContext{res: res, file: element.GetFile(), elementName: element.GetFullyQualifiedName(), elementType: descriptorType(element.AsProto())} - var remain []*dpb.UninterpretedOption - for _, uo := range uninterpreted { - node := res.getOptionNode(uo) - if !uo.Name[0].GetIsExtension() && uo.Name[0].GetNamePart() == "uninterpreted_option" { - if res.lenient { - remain = append(remain, uo) - continue - } - // uninterpreted_option might be found reflectively, but is not actually valid for use - if err := res.errs.handleErrorWithPos(node.GetName().Start(), "%vinvalid option 'uninterpreted_option'", mc); err != nil { - return nil, err - } - } - mc.option = uo - path, err := interpretField(res, mc, element, dm, uo, 0, nil) - if err != nil { - if res.lenient { - remain = append(remain, uo) - continue - } - return nil, err - } - if optn, ok := node.(*ast.OptionNode); ok { - res.interpretedOptions[optn] = path - } - } - - if res.lenient { - // If we're lenient, then we don't want to clobber the passed in message - // and leave it partially populated. So we convert into a copy first - optsClone := proto.Clone(opts) - if err := dm.ConvertToDeterministic(optsClone); err != nil { - // TODO: do this in a more granular way, so we can convert individual - // fields and leave bad ones uninterpreted instead of skipping all of - // the work we've done so far. - return uninterpreted, nil - } - // conversion from dynamic message above worked, so now - // it is safe to overwrite the passed in message - opts.Reset() - proto.Merge(opts, optsClone) - - return remain, nil - } - - if err := dm.ValidateRecursive(); err != nil { - node := res.nodes[element.AsProto()] - if err := res.errs.handleErrorWithPos(node.Start(), "error in %s options: %v", descriptorType(element.AsProto()), err); err != nil { - return nil, err - } - } - - // now try to convert into the passed in message and fail if not successful - if err := dm.ConvertToDeterministic(opts); err != nil { - node := res.nodes[element.AsProto()] - return nil, res.errs.handleError(ErrorWithSourcePos{Pos: node.Start(), Underlying: err}) - } - - return nil, nil -} - -func loadMessageDescriptorForOptions(l *linker, fd fileDescriptorish, opts proto.Message) (*desc.MessageDescriptor, error) { - // see if the file imports a custom version of descriptor.proto - fqn := proto.MessageName(opts) - d := findMessageDescriptorForOptions(l, fd, fqn) - if d != nil { - return d, nil - } - // fall back to built-in options descriptors - return desc.LoadMessageDescriptorForMessage(opts) -} - -func findMessageDescriptorForOptions(l *linker, fd fileDescriptorish, messageName string) *desc.MessageDescriptor { - d := fd.FindSymbol(messageName) - if d != nil { - md, _ := d.(*desc.MessageDescriptor) - return md - } - - // TODO: should this support public imports and be recursive? - for _, dep := range fd.GetDependencies() { - d := dep.FindSymbol(messageName) - if d != nil { - if l != nil { - l.markUsed(fd.AsProto().(*dpb.FileDescriptorProto), d.GetFile().AsFileDescriptorProto()) - } - md, _ := d.(*desc.MessageDescriptor) - return md - } - } - - return nil -} - -func interpretField(res *parseResult, mc *messageContext, element descriptorish, dm *dynamic.Message, opt *dpb.UninterpretedOption, nameIndex int, pathPrefix []int32) (path []int32, err error) { - var fld *desc.FieldDescriptor - nm := opt.GetName()[nameIndex] - node := res.getOptionNamePartNode(nm) - if nm.GetIsExtension() { - extName := nm.GetNamePart() - if extName[0] == '.' { - extName = extName[1:] /* skip leading dot */ - } - fld = findExtension(element.GetFile(), extName) - if fld == nil { - return nil, res.errs.handleErrorWithPos(node.Start(), - "%vunrecognized extension %s of %s", - mc, extName, dm.GetMessageDescriptor().GetFullyQualifiedName()) - } - if fld.GetOwner().GetFullyQualifiedName() != dm.GetMessageDescriptor().GetFullyQualifiedName() { - return nil, res.errs.handleErrorWithPos(node.Start(), - "%vextension %s should extend %s but instead extends %s", - mc, extName, dm.GetMessageDescriptor().GetFullyQualifiedName(), fld.GetOwner().GetFullyQualifiedName()) - } - } else { - fld = dm.GetMessageDescriptor().FindFieldByName(nm.GetNamePart()) - if fld == nil { - return nil, res.errs.handleErrorWithPos(node.Start(), - "%vfield %s of %s does not exist", - mc, nm.GetNamePart(), dm.GetMessageDescriptor().GetFullyQualifiedName()) - } - } - - path = append(pathPrefix, fld.GetNumber()) - - if len(opt.GetName()) > nameIndex+1 { - nextnm := opt.GetName()[nameIndex+1] - nextnode := res.getOptionNamePartNode(nextnm) - if fld.GetType() != dpb.FieldDescriptorProto_TYPE_MESSAGE && fld.GetType() != dpb.FieldDescriptorProto_TYPE_GROUP { - return nil, res.errs.handleErrorWithPos(nextnode.Start(), - "%vcannot set field %s because %s is not a message", - mc, nextnm.GetNamePart(), nm.GetNamePart()) - } - if fld.IsRepeated() { - return nil, res.errs.handleErrorWithPos(nextnode.Start(), - "%vcannot set field %s because %s is repeated (must use an aggregate)", - mc, nextnm.GetNamePart(), nm.GetNamePart()) - } - var fdm *dynamic.Message - var err error - if dm.HasField(fld) { - var v interface{} - v, err = dm.TryGetField(fld) - fdm, _ = v.(*dynamic.Message) - } else { - if ood := fld.GetOneOf(); ood != nil { - existingFld, _, err := dm.TryGetOneOfField(ood) - if err != nil { - return nil, res.errs.handleErrorWithPos(node.Start(), "%verror querying value: %s", mc, err) - } - if existingFld != nil && existingFld.GetNumber() != fld.GetNumber() { - return nil, res.errs.handleErrorWithPos(node.Start(), "%voneof %q already has field %q set", mc, ood.GetName(), fieldName(existingFld)) - } - } - fdm = dynamic.NewMessage(fld.GetMessageType()) - err = dm.TrySetField(fld, fdm) - } - if err != nil { - return nil, res.errs.handleError(ErrorWithSourcePos{Pos: node.Start(), Underlying: err}) - } - // recurse to set next part of name - return interpretField(res, mc, element, fdm, opt, nameIndex+1, path) - } - - optNode := res.getOptionNode(opt) - if err := setOptionField(res, mc, dm, fld, node, optNode.GetValue(), false); err != nil { - return nil, res.errs.handleError(err) - } - if fld.IsRepeated() { - path = append(path, int32(dm.FieldLength(fld))-1) - } - return path, nil -} - -func findExtension(fd fileDescriptorish, name string) *desc.FieldDescriptor { - d := findSymbol(fd, name, false, map[fileDescriptorish]struct{}{}) - if fld, ok := d.(*desc.FieldDescriptor); ok { - return fld - } - return nil -} - -func findMessage(fd fileDescriptorish, name string) *desc.MessageDescriptor { - d := findSymbol(fd, name, false, map[fileDescriptorish]struct{}{}) - if md, ok := d.(*desc.MessageDescriptor); ok { - return md - } - return nil -} - -func findSymbol(fd fileDescriptorish, name string, public bool, checked map[fileDescriptorish]struct{}) desc.Descriptor { - if _, ok := checked[fd]; ok { - return nil - } - checked[fd] = struct{}{} - d := fd.FindSymbol(name) - if d != nil { - return d - } - - // When public = false, we are searching only directly imported symbols. But we - // also need to search transitive public imports due to semantics of public imports. - if public { - for _, dep := range fd.GetPublicDependencies() { - d := findSymbol(dep, name, true, checked) - if d != nil { - return d - } - } - } else { - for _, dep := range fd.GetDependencies() { - d := findSymbol(dep, name, true, checked) - if d != nil { - return d - } - } - } - return nil -} - -func setOptionField(res *parseResult, mc *messageContext, dm *dynamic.Message, fld *desc.FieldDescriptor, name ast.Node, val ast.ValueNode, insideMsgLiteral bool) error { - v := val.Value() - if sl, ok := v.([]ast.ValueNode); ok { - // handle slices a little differently than the others - if !fld.IsRepeated() { - return errorWithPos(val.Start(), "%vvalue is an array but field is not repeated", mc) - } - origPath := mc.optAggPath - defer func() { - mc.optAggPath = origPath - }() - for index, item := range sl { - mc.optAggPath = fmt.Sprintf("%s[%d]", origPath, index) - if v, err := fieldValue(res, mc, richFldDescriptorish{FieldDescriptor: fld}, item, false, insideMsgLiteral); err != nil { - return err - } else if err = dm.TryAddRepeatedField(fld, v); err != nil { - return errorWithPos(val.Start(), "%verror setting value: %s", mc, err) - } - } - return nil - } - - v, err := fieldValue(res, mc, richFldDescriptorish{FieldDescriptor: fld}, val, false, insideMsgLiteral) - if err != nil { - return err - } - - if ood := fld.GetOneOf(); ood != nil { - existingFld, _, err := dm.TryGetOneOfField(ood) - if err != nil { - return errorWithPos(name.Start(), "%verror querying value: %s", mc, err) - } - if existingFld != nil && existingFld.GetNumber() != fld.GetNumber() { - return errorWithPos(name.Start(), "%voneof %q already has field %q set", mc, ood.GetName(), fieldName(existingFld)) - } - } - - if fld.IsRepeated() { - err = dm.TryAddRepeatedField(fld, v) - } else { - if dm.HasField(fld) { - return errorWithPos(name.Start(), "%vnon-repeated option field %s already set", mc, fieldName(fld)) - } - err = dm.TrySetField(fld, v) - } - if err != nil { - return errorWithPos(val.Start(), "%verror setting value: %s", mc, err) - } - - return nil -} - -func findOption(res *parseResult, scope string, opts []*dpb.UninterpretedOption, name string) (int, error) { - found := -1 - for i, opt := range opts { - if len(opt.Name) != 1 { - continue - } - if opt.Name[0].GetIsExtension() || opt.Name[0].GetNamePart() != name { - continue - } - if found >= 0 { - optNode := res.getOptionNode(opt) - return -1, res.errs.handleErrorWithPos(optNode.GetName().Start(), "%s: option %s cannot be defined more than once", scope, name) - } - found = i - } - return found, nil -} - -func removeOption(uo []*dpb.UninterpretedOption, indexToRemove int) []*dpb.UninterpretedOption { - if indexToRemove == 0 { - return uo[1:] - } else if int(indexToRemove) == len(uo)-1 { - return uo[:len(uo)-1] - } else { - return append(uo[:indexToRemove], uo[indexToRemove+1:]...) - } -} - -type messageContext struct { - res *parseResult - file fileDescriptorish - elementType string - elementName string - option *dpb.UninterpretedOption - optAggPath string -} - -func (c *messageContext) String() string { - var ctx bytes.Buffer - if c.elementType != "file" { - _, _ = fmt.Fprintf(&ctx, "%s %s: ", c.elementType, c.elementName) - } - if c.option != nil && c.option.Name != nil { - ctx.WriteString("option ") - writeOptionName(&ctx, c.option.Name) - if c.res.nodes == nil { - // if we have no source position info, try to provide as much context - // as possible (if nodes != nil, we don't need this because any errors - // will actually have file and line numbers) - if c.optAggPath != "" { - _, _ = fmt.Fprintf(&ctx, " at %s", c.optAggPath) - } - } - ctx.WriteString(": ") - } - return ctx.String() -} - -func writeOptionName(buf *bytes.Buffer, parts []*dpb.UninterpretedOption_NamePart) { - first := true - for _, p := range parts { - if first { - first = false - } else { - buf.WriteByte('.') - } - nm := p.GetNamePart() - if nm[0] == '.' { - // skip leading dot - nm = nm[1:] - } - if p.GetIsExtension() { - buf.WriteByte('(') - buf.WriteString(nm) - buf.WriteByte(')') - } else { - buf.WriteString(nm) - } - } -} - -func fieldName(fld *desc.FieldDescriptor) string { - if fld.IsExtension() { - return fld.GetFullyQualifiedName() - } else { - return fld.GetName() - } -} - -func valueKind(val interface{}) string { - switch val := val.(type) { - case ast.Identifier: - return "identifier" - case bool: - return "bool" - case int64: - if val < 0 { - return "negative integer" - } - return "integer" - case uint64: - return "integer" - case float64: - return "double" - case string, []byte: - return "string" - case []*ast.MessageFieldNode: - return "message" - case []ast.ValueNode: - return "array" - default: - return fmt.Sprintf("%T", val) - } -} - -func fieldValue(res *parseResult, mc *messageContext, fld fldDescriptorish, val ast.ValueNode, enumAsString, insideMsgLiteral bool) (interface{}, error) { - v := val.Value() - t := fld.AsFieldDescriptorProto().GetType() - switch t { - case dpb.FieldDescriptorProto_TYPE_ENUM: - if id, ok := v.(ast.Identifier); ok { - ev := fld.GetEnumType().FindValueByName(string(id)) - if ev == nil { - return nil, errorWithPos(val.Start(), "%venum %s has no value named %s", mc, fld.GetEnumType().GetFullyQualifiedName(), id) - } - if enumAsString { - return ev.GetName(), nil - } else { - return ev.GetNumber(), nil - } - } - return nil, errorWithPos(val.Start(), "%vexpecting enum, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_MESSAGE, dpb.FieldDescriptorProto_TYPE_GROUP: - if aggs, ok := v.([]*ast.MessageFieldNode); ok { - fmd := fld.GetMessageType() - return messageLiteralValue(res, mc, aggs, fmd) - } - return nil, errorWithPos(val.Start(), "%vexpecting message, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_BOOL: - if b, ok := v.(bool); ok { - return b, nil - } - if id, ok := v.(ast.Identifier); ok { - if insideMsgLiteral { - // inside a message literal, values use the protobuf text format, - // which is lenient in that it accepts "t" and "f" or "True" and "False" - switch id { - case "t", "true", "True": - return true, nil - case "f", "false", "False": - return false, nil - } - } else { - // options with simple scalar values (no message literal) are stricter - switch id { - case "true": - return true, nil - case "false": - return false, nil - } - } - } - return nil, errorWithPos(val.Start(), "%vexpecting bool, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_BYTES: - if str, ok := v.(string); ok { - return []byte(str), nil - } - return nil, errorWithPos(val.Start(), "%vexpecting bytes, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_STRING: - if str, ok := v.(string); ok { - return str, nil - } - return nil, errorWithPos(val.Start(), "%vexpecting string, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_INT32, dpb.FieldDescriptorProto_TYPE_SINT32, dpb.FieldDescriptorProto_TYPE_SFIXED32: - if i, ok := v.(int64); ok { - if i > math.MaxInt32 || i < math.MinInt32 { - return nil, errorWithPos(val.Start(), "%vvalue %d is out of range for int32", mc, i) - } - return int32(i), nil - } - if ui, ok := v.(uint64); ok { - if ui > math.MaxInt32 { - return nil, errorWithPos(val.Start(), "%vvalue %d is out of range for int32", mc, ui) - } - return int32(ui), nil - } - return nil, errorWithPos(val.Start(), "%vexpecting int32, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_UINT32, dpb.FieldDescriptorProto_TYPE_FIXED32: - if i, ok := v.(int64); ok { - if i > math.MaxUint32 || i < 0 { - return nil, errorWithPos(val.Start(), "%vvalue %d is out of range for uint32", mc, i) - } - return uint32(i), nil - } - if ui, ok := v.(uint64); ok { - if ui > math.MaxUint32 { - return nil, errorWithPos(val.Start(), "%vvalue %d is out of range for uint32", mc, ui) - } - return uint32(ui), nil - } - return nil, errorWithPos(val.Start(), "%vexpecting uint32, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_INT64, dpb.FieldDescriptorProto_TYPE_SINT64, dpb.FieldDescriptorProto_TYPE_SFIXED64: - if i, ok := v.(int64); ok { - return i, nil - } - if ui, ok := v.(uint64); ok { - if ui > math.MaxInt64 { - return nil, errorWithPos(val.Start(), "%vvalue %d is out of range for int64", mc, ui) - } - return int64(ui), nil - } - return nil, errorWithPos(val.Start(), "%vexpecting int64, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_UINT64, dpb.FieldDescriptorProto_TYPE_FIXED64: - if i, ok := v.(int64); ok { - if i < 0 { - return nil, errorWithPos(val.Start(), "%vvalue %d is out of range for uint64", mc, i) - } - return uint64(i), nil - } - if ui, ok := v.(uint64); ok { - return ui, nil - } - return nil, errorWithPos(val.Start(), "%vexpecting uint64, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_DOUBLE: - if id, ok := v.(ast.Identifier); ok { - switch id { - case "inf": - return math.Inf(1), nil - case "nan": - return math.NaN(), nil - } - } - if d, ok := v.(float64); ok { - return d, nil - } - if i, ok := v.(int64); ok { - return float64(i), nil - } - if u, ok := v.(uint64); ok { - return float64(u), nil - } - return nil, errorWithPos(val.Start(), "%vexpecting double, got %s", mc, valueKind(v)) - case dpb.FieldDescriptorProto_TYPE_FLOAT: - if id, ok := v.(ast.Identifier); ok { - switch id { - case "inf": - return float32(math.Inf(1)), nil - case "nan": - return float32(math.NaN()), nil - } - } - if d, ok := v.(float64); ok { - if (d > math.MaxFloat32 || d < -math.MaxFloat32) && !math.IsInf(d, 1) && !math.IsInf(d, -1) && !math.IsNaN(d) { - return nil, errorWithPos(val.Start(), "%vvalue %f is out of range for float", mc, d) - } - return float32(d), nil - } - if i, ok := v.(int64); ok { - return float32(i), nil - } - if u, ok := v.(uint64); ok { - return float32(u), nil - } - return nil, errorWithPos(val.Start(), "%vexpecting float, got %s", mc, valueKind(v)) - default: - return nil, errorWithPos(val.Start(), "%vunrecognized field type: %s", mc, t) - } -} - -func messageLiteralValue(res *parseResult, mc *messageContext, val []*ast.MessageFieldNode, fmd *desc.MessageDescriptor) (*dynamic.Message, error) { - fdm := dynamic.NewMessage(fmd) - origPath := mc.optAggPath - defer func() { - mc.optAggPath = origPath - }() - for _, fldNode := range val { - if origPath == "" { - mc.optAggPath = fldNode.Name.Value() - } else { - mc.optAggPath = origPath + "." + fldNode.Name.Value() - } - - if fldNode.Name.IsAnyTypeReference() { - if fmd.GetFullyQualifiedName() == "google.protobuf.Any" { - // TODO: Support other URLs dynamically -- the caller of protoparse - // should be able to provide fldNode custom resolver that can resolve type - // URLs into message descriptors. The default resolver would be - // implemented as below, only accepting "type.googleapis.com" and - // "type.googleprod.com" as hosts/prefixes and using the compiled - // file's transitive closure to find the named message. - urlPrefix := fldNode.Name.UrlPrefix.AsIdentifier() - msgName := fldNode.Name.Name.AsIdentifier() - fullUrl := fmt.Sprintf("%s/%s", urlPrefix, msgName) - if urlPrefix != "type.googleapis.com" && urlPrefix != "type.googleprod.com" { - return nil, errorWithPos(fldNode.Name.UrlPrefix.Start(), "%vcould not resolve type reference %s", mc, fullUrl) - } - anyFields, ok := fldNode.Val.Value().([]*ast.MessageFieldNode) - if !ok { - return nil, errorWithPos(fldNode.Val.Start(), "%vtype references for google.protobuf.Any must have message literal value", mc) - } - anyMd := findMessage(mc.file, string(msgName)) - if anyMd == nil { - return nil, errorWithPos(fldNode.Name.UrlPrefix.Start(), "%vcould not resolve type reference %s", mc, fullUrl) - } - // parse the message value - msgVal, err := messageLiteralValue(res, mc, anyFields, anyMd) - if err != nil { - return nil, err - } - - // Any is defined with two fields: - // string type_url = 1 - // bytes value = 2 - if err := fdm.TrySetFieldByNumber(1, fullUrl); err != nil { - return nil, errorWithPos(fldNode.Name.Start(), "%vfailed to set type_url string field on Any: %w", mc, err) - } - b, err := msgVal.MarshalDeterministic() - if err != nil { - return nil, errorWithPos(fldNode.Val.Start(), "%vfailed to serialize message value: %w", mc, err) - } - if err := fdm.TrySetFieldByNumber(2, b); err != nil { - return nil, errorWithPos(fldNode.Name.Start(), "%vfailed to set value bytes field on Any: %w", mc, err) - } - } else { - return nil, errorWithPos(fldNode.Name.UrlPrefix.Start(), "%vtype references are only allowed for google.protobuf.Any, but this type is %s", mc, fmd.GetFullyQualifiedName()) - } - } else { - var ffld *desc.FieldDescriptor - if fldNode.Name.IsExtension() { - if n := res.optionQualifiedNames[fldNode.Name.Name]; n != "" { - ffld = findExtension(mc.file, n) - } - } else { - ffld = fmd.FindFieldByName(fldNode.Name.Value()) - // Groups are indicated in the text format by the group name (which is - // camel-case), NOT the field name (which is lower-case). - // ...but only regular fields, not extensions that are groups... - if ffld != nil && ffld.GetType() == dpb.FieldDescriptorProto_TYPE_GROUP && ffld.GetMessageType().GetName() != fldNode.Name.Value() { - // this is kind of silly to fail here, but this mimics protoc behavior - return nil, errorWithPos(fldNode.Start(), "%vfield %s not found (did you mean the group named %s?)", mc, fldNode.Name.Value(), ffld.GetMessageType().GetName()) - } - if ffld == nil { - // could be fldNode group name - for _, fd := range fmd.GetFields() { - if fd.GetType() == dpb.FieldDescriptorProto_TYPE_GROUP && fd.GetMessageType().GetName() == fldNode.Name.Value() { - // found it! - ffld = fd - break - } - } - } - } - if ffld == nil { - return nil, errorWithPos(fldNode.Name.Name.Start(), "%vfield %s not found", mc, string(fldNode.Name.Name.AsIdentifier())) - } - if err := setOptionField(res, mc, fdm, ffld, fldNode.Name, fldNode.Val, true); err != nil { - return nil, err - } - } - } - return fdm, nil -} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/parser.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/parser.go index 5ab50870da8..1febe6bad15 100644 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/parser.go +++ b/vendor/github.com/jhump/protoreflect/desc/protoparse/parser.go @@ -1,8 +1,7 @@ package protoparse import ( - "bytes" - "errors" + "context" "fmt" "io" "io/ioutil" @@ -11,61 +10,21 @@ import ( "sort" "strings" - "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "github.com/bufbuild/protocompile" + ast2 "github.com/bufbuild/protocompile/ast" + "github.com/bufbuild/protocompile/options" + "github.com/bufbuild/protocompile/parser" + "github.com/bufbuild/protocompile/protoutil" + "github.com/bufbuild/protocompile/reporter" + "github.com/bufbuild/protocompile/sourceinfo" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/descriptorpb" "github.com/jhump/protoreflect/desc" - "github.com/jhump/protoreflect/desc/internal" "github.com/jhump/protoreflect/desc/protoparse/ast" ) -//go:generate goyacc -o proto.y.go -p proto proto.y - -func init() { - protoErrorVerbose = true - - // fix up the generated "token name" array so that error messages are nicer - setTokenName(_STRING_LIT, "string literal") - setTokenName(_INT_LIT, "int literal") - setTokenName(_FLOAT_LIT, "float literal") - setTokenName(_NAME, "identifier") - setTokenName(_ERROR, "error") - // for keywords, just show the keyword itself wrapped in quotes - for str, i := range keywords { - setTokenName(i, fmt.Sprintf(`"%s"`, str)) - } -} - -func setTokenName(token int, text string) { - // NB: this is based on logic in generated parse code that translates the - // int returned from the lexer into an internal token number. - var intern int - if token < len(protoTok1) { - intern = protoTok1[token] - } else { - if token >= protoPrivate { - if token < protoPrivate+len(protoTok2) { - intern = protoTok2[token-protoPrivate] - } - } - if intern == 0 { - for i := 0; i+1 < len(protoTok3); i += 2 { - if protoTok3[i] == token { - intern = protoTok3[i+1] - break - } - } - } - } - - if intern >= 1 && intern-1 < len(protoToknames) { - protoToknames[intern-1] = text - return - } - - panic(fmt.Sprintf("Unknown token value: %d", token)) -} - // FileAccessor is an abstraction for opening proto source files. It takes the // name of the file to open and returns either the input reader or an error. type FileAccessor func(filename string) (io.ReadCloser, error) @@ -120,9 +79,7 @@ type Parser struct { // LookupImportProto has the same functionality as LookupImport, however it returns // a FileDescriptorProto instead of a FileDescriptor. - // - // It is an error to set both LookupImport and LookupImportProto. - LookupImportProto func(string) (*dpb.FileDescriptorProto, error) + LookupImportProto func(string) (*descriptorpb.FileDescriptorProto, error) // Used to create a reader for a given filename, when loading proto source // file contents. If unset, os.Open is used. If ImportPaths is also empty @@ -182,73 +139,48 @@ type Parser struct { // error it returns. If syntax or link errors are encountered but the configured // ErrorReporter always returns nil, the parse fails with ErrInvalidSource. func (p Parser) ParseFiles(filenames ...string) ([]*desc.FileDescriptor, error) { - accessor := p.Accessor - if accessor == nil { - accessor = func(name string) (io.ReadCloser, error) { - return os.Open(name) - } - } - paths := p.ImportPaths - if len(paths) > 0 { - acc := accessor - accessor = func(name string) (io.ReadCloser, error) { - var ret error - for _, path := range paths { - f, err := acc(filepath.Join(path, name)) - if err != nil { - if ret == nil { - ret = err - } - continue - } - return f, nil - } - return nil, ret - } - } - lookupImport, err := p.getLookupImport() - if err != nil { - return nil, err + srcInfoMode := protocompile.SourceInfoNone + if p.IncludeSourceCodeInfo { + srcInfoMode = protocompile.SourceInfoExtraComments } + rep := newReporter(p.ErrorReporter, p.WarningReporter) + res, srcPosAddr := p.getResolver(filenames) - protos := map[string]*parseResult{} - results := &parseResults{ - resultsByFilename: protos, - recursive: true, - validate: true, - createDescriptorProtos: true, - } - errs := newErrorHandler(p.ErrorReporter, p.WarningReporter) - parseProtoFiles(accessor, filenames, errs, results, lookupImport) - if err := errs.getError(); err != nil { - return nil, err - } if p.InferImportPaths { + // we must first compile everything to protos + results, err := parseToProtosRecursive(res, filenames, reporter.NewHandler(rep), srcPosAddr) + if err != nil { + return nil, err + } + // then we can infer import paths // TODO: if this re-writes one of the names in filenames, lookups below will break - protos = fixupFilenames(protos) + results = fixupFilenames(results) + resolverFromResults := protocompile.ResolverFunc(func(path string) (protocompile.SearchResult, error) { + res, ok := results[path] + if !ok { + return protocompile.SearchResult{}, os.ErrNotExist + } + return protocompile.SearchResult{ParseResult: res}, nil + }) + res = protocompile.CompositeResolver{resolverFromResults, res} } - l := newLinker(results, errs) - linkedProtos, err := l.linkFiles() + + c := protocompile.Compiler{ + Resolver: res, + MaxParallelism: 1, + SourceInfoMode: srcInfoMode, + Reporter: rep, + } + results, err := c.Compile(context.Background(), filenames...) if err != nil { return nil, err } - // Now we're done linking, so we can check to see if any imports were unused - for _, file := range filenames { - l.checkForUnusedImports(file) - } - if p.IncludeSourceCodeInfo { - for name, fd := range linkedProtos { - pr := protos[name] - fd.AsFileDescriptorProto().SourceCodeInfo = pr.generateSourceCodeInfo() - internal.RecomputeSourceInfo(fd) - } - } - fds := make([]*desc.FileDescriptor, len(filenames)) - for i, name := range filenames { - fd := linkedProtos[name] - fds[i] = fd + + fds := make([]protoreflect.FileDescriptor, len(results)) + for i := range results { + fds[i] = results[i] } - return fds, nil + return desc.WrapFiles(fds) } // ParseFilesButDoNotLink parses the named files into descriptor protos. The @@ -282,52 +214,42 @@ func (p Parser) ParseFiles(filenames ...string) ([]*desc.FileDescriptor, error) // ErrorReporter configured and it returns non-nil, parsing will abort with the // error it returns. If syntax errors are encountered but the configured // ErrorReporter always returns nil, the parse fails with ErrInvalidSource. -func (p Parser) ParseFilesButDoNotLink(filenames ...string) ([]*dpb.FileDescriptorProto, error) { - accessor := p.Accessor - if accessor == nil { - accessor = func(name string) (io.ReadCloser, error) { - return os.Open(name) - } - } - lookupImport, err := p.getLookupImport() +func (p Parser) ParseFilesButDoNotLink(filenames ...string) ([]*descriptorpb.FileDescriptorProto, error) { + rep := newReporter(p.ErrorReporter, p.WarningReporter) + res, _ := p.getResolver(filenames) + results, err := parseToProtos(res, filenames, reporter.NewHandler(rep), p.ValidateUnlinkedFiles) if err != nil { return nil, err } - protos := map[string]*parseResult{} - errs := newErrorHandler(p.ErrorReporter, p.WarningReporter) - results := &parseResults{ - resultsByFilename: protos, - validate: p.ValidateUnlinkedFiles, - createDescriptorProtos: true, - } - parseProtoFiles(accessor, filenames, errs, results, lookupImport) - if err := errs.getError(); err != nil { - return nil, err - } if p.InferImportPaths { - // TODO: if this re-writes one of the names in filenames, lookups below will break - protos = fixupFilenames(protos) + resultsMap := make(map[string]parser.Result, len(results)) + for _, res := range results { + resultsMap[res.FileDescriptorProto().GetName()] = res + } + resultsMap = fixupFilenames(resultsMap) + for i := range filenames { + results[i] = resultsMap[filenames[i]] + } } - fds := make([]*dpb.FileDescriptorProto, len(filenames)) - for i, name := range filenames { - pr := protos[name] - fd := pr.fd + + protos := make([]*descriptorpb.FileDescriptorProto, len(results)) + for i, res := range results { + protos[i] = res.FileDescriptorProto() + var optsIndex options.Index if p.InterpretOptionsInUnlinkedFiles { - // parsing options will be best effort - pr.lenient = true - // we don't want the real error reporter see any errors - pr.errs.errReporter = func(err ErrorWithPos) error { - return err + var err error + optsIndex, err = options.InterpretUnlinkedOptions(res) + if err != nil { + return nil, err } - _ = interpretFileOptions(nil, pr, poorFileDescriptorish{FileDescriptorProto: fd}) } if p.IncludeSourceCodeInfo { - fd.SourceCodeInfo = pr.generateSourceCodeInfo() + protos[i].SourceCodeInfo = sourceinfo.GenerateSourceInfo(res.AST(), optsIndex) } - fds[i] = fd } - return fds, nil + + return protos, nil } // ParseToAST parses the named files into ASTs, or Abstract Syntax Trees. This @@ -348,54 +270,210 @@ func (p Parser) ParseFilesButDoNotLink(filenames ...string) ([]*dpb.FileDescript // error it returns. If syntax errors are encountered but the configured // ErrorReporter always returns nil, the parse fails with ErrInvalidSource. func (p Parser) ParseToAST(filenames ...string) ([]*ast.FileNode, error) { - accessor := p.Accessor - if accessor == nil { - accessor = func(name string) (io.ReadCloser, error) { - return os.Open(name) + rep := newReporter(p.ErrorReporter, p.WarningReporter) + res, _ := p.getResolver(filenames) + asts, _, err := parseToASTs(res, filenames, reporter.NewHandler(rep)) + if err != nil { + return nil, err + } + results := make([]*ast.FileNode, len(asts)) + for i := range asts { + if asts[i] == nil { + // should not be possible but... + return nil, fmt.Errorf("resolver did not produce source for %v", filenames[i]) } + results[i] = convertAST(asts[i]) } - lookupImport, err := p.getLookupImport() + return results, nil +} + +func parseToAST(res protocompile.Resolver, filename string, rep *reporter.Handler) (*ast2.FileNode, parser.Result, error) { + searchResult, err := res.FindFileByPath(filename) if err != nil { - return nil, err + _ = rep.HandleError(err) + return nil, nil, rep.Error() + } + switch { + case searchResult.ParseResult != nil: + return nil, searchResult.ParseResult, nil + case searchResult.Proto != nil: + return nil, parser.ResultWithoutAST(searchResult.Proto), nil + case searchResult.Desc != nil: + return nil, parser.ResultWithoutAST(protoutil.ProtoFromFileDescriptor(searchResult.Desc)), nil + case searchResult.AST != nil: + return searchResult.AST, nil, nil + case searchResult.Source != nil: + astRoot, err := parser.Parse(filename, searchResult.Source, rep) + return astRoot, nil, err + default: + _ = rep.HandleError(fmt.Errorf("resolver did not produce a result for %v", filename)) + return nil, nil, rep.Error() + } +} + +func parseToASTs(res protocompile.Resolver, filenames []string, rep *reporter.Handler) ([]*ast2.FileNode, []parser.Result, error) { + asts := make([]*ast2.FileNode, len(filenames)) + results := make([]parser.Result, len(filenames)) + for i := range filenames { + asts[i], results[i], _ = parseToAST(res, filenames[i], rep) + if rep.ReporterError() != nil { + break + } } + return asts, results, rep.Error() +} - protos := map[string]*parseResult{} - errs := newErrorHandler(p.ErrorReporter, p.WarningReporter) - parseProtoFiles(accessor, filenames, errs, &parseResults{resultsByFilename: protos}, lookupImport) - if err := errs.getError(); err != nil { +func parseToProtos(res protocompile.Resolver, filenames []string, rep *reporter.Handler, validate bool) ([]parser.Result, error) { + asts, results, err := parseToASTs(res, filenames, rep) + if err != nil { return nil, err } - ret := make([]*ast.FileNode, 0, len(filenames)) - for _, name := range filenames { - ret = append(ret, protos[name].root) + for i := range results { + if results[i] != nil { + continue + } + var err error + results[i], err = parser.ResultFromAST(asts[i], validate, rep) + if err != nil { + return nil, err + } } - return ret, nil + return results, nil } -func (p Parser) getLookupImport() (func(string) (*dpb.FileDescriptorProto, error), error) { - if p.LookupImport != nil && p.LookupImportProto != nil { - return nil, ErrLookupImportAndProtoSet +func parseToProtosRecursive(res protocompile.Resolver, filenames []string, rep *reporter.Handler, srcPosAddr *SourcePos) (map[string]parser.Result, error) { + results := make(map[string]parser.Result, len(filenames)) + for _, filename := range filenames { + parseToProtoRecursive(res, filename, rep, srcPosAddr, results) } - if p.LookupImportProto != nil { - return p.LookupImportProto, nil + return results, rep.Error() +} + +func parseToProtoRecursive(res protocompile.Resolver, filename string, rep *reporter.Handler, srcPosAddr *SourcePos, results map[string]parser.Result) { + if _, ok := results[filename]; ok { + // already processed this one + return + } + results[filename] = nil // placeholder entry + + astRoot, parseResult, _ := parseToAST(res, filename, rep) + if rep.ReporterError() != nil { + return + } + if parseResult == nil { + parseResult, _ = parser.ResultFromAST(astRoot, true, rep) + if rep.ReporterError() != nil { + return + } + } + results[filename] = parseResult + + for _, decl := range astRoot.Decls { + imp, ok := decl.(*ast2.ImportNode) + if !ok { + continue + } + func() { + orig := *srcPosAddr + *srcPosAddr = astRoot.NodeInfo(imp.Name).Start() + defer func() { + *srcPosAddr = orig + }() + + parseToProtoRecursive(res, imp.Name.AsString(), rep, srcPosAddr, results) + }() + if rep.ReporterError() != nil { + return + } + } +} + +func newReporter(errRep ErrorReporter, warnRep WarningReporter) reporter.Reporter { + if errRep != nil { + delegate := errRep + errRep = func(err ErrorWithPos) error { + if _, ok := err.(ErrorWithSourcePos); !ok { + err = toErrorWithSourcePos(err) + } + return delegate(err) + } + } + if warnRep != nil { + delegate := warnRep + warnRep = func(err ErrorWithPos) { + if _, ok := err.(ErrorWithSourcePos); !ok { + err = toErrorWithSourcePos(err) + } + delegate(err) + } } + return reporter.NewReporter(errRep, warnRep) +} + +func (p Parser) getResolver(filenames []string) (protocompile.Resolver, *SourcePos) { + var srcPos SourcePos + accessor := p.Accessor + if accessor == nil { + accessor = func(name string) (io.ReadCloser, error) { + return os.Open(name) + } + } + sourceResolver := &protocompile.SourceResolver{ + Accessor: func(filename string) (io.ReadCloser, error) { + in, err := accessor(filename) + if err != nil { + if !strings.Contains(err.Error(), filename) { + // errors that don't include the filename that failed are no bueno + err = errorWithFilename{filename: filename, underlying: err} + } + if srcPos.Filename != "" { + err = reporter.Error(srcPos, err) + } + } + return in, err + }, + ImportPaths: p.ImportPaths, + } + var importResolver protocompile.CompositeResolver if p.LookupImport != nil { - return func(path string) (*dpb.FileDescriptorProto, error) { - value, err := p.LookupImport(path) - if value != nil { - return value.AsFileDescriptorProto(), err + importResolver = append(importResolver, protocompile.ResolverFunc(func(path string) (protocompile.SearchResult, error) { + fd, err := p.LookupImport(path) + if err != nil { + return protocompile.SearchResult{}, err } - return nil, err - }, nil + return protocompile.SearchResult{Desc: fd.UnwrapFile()}, nil + })) + } + if p.LookupImportProto != nil { + importResolver = append(importResolver, protocompile.ResolverFunc(func(path string) (protocompile.SearchResult, error) { + fd, err := p.LookupImportProto(path) + if err != nil { + return protocompile.SearchResult{}, err + } + return protocompile.SearchResult{Proto: fd}, nil + })) + } + backupResolver := protocompile.WithStandardImports(importResolver) + mustBeSource := make(map[string]struct{}, len(filenames)) + for _, name := range filenames { + mustBeSource[name] = struct{}{} } - return nil, nil + return protocompile.CompositeResolver{ + sourceResolver, + protocompile.ResolverFunc(func(path string) (protocompile.SearchResult, error) { + if _, ok := mustBeSource[path]; ok { + return protocompile.SearchResult{}, os.ErrNotExist + } + return backupResolver.FindFileByPath(path) + }), + }, &srcPos } -func fixupFilenames(protos map[string]*parseResult) map[string]*parseResult { +func fixupFilenames(protos map[string]parser.Result) map[string]parser.Result { // In the event that the given filenames (keys in the supplied map) do not // match the actual paths used in 'import' statements in the files, we try // to revise names in the protos so that they will match and be linkable. - revisedProtos := map[string]*parseResult{} + revisedProtos := map[string]parser.Result{} protoPaths := map[string]struct{}{} // TODO: this is O(n^2) but could likely be O(n) with a clever data structure (prefix tree that is indexed backwards?) @@ -404,7 +482,7 @@ func fixupFilenames(protos map[string]*parseResult) map[string]*parseResult { for name := range protos { candidatesAvailable[name] = struct{}{} for _, f := range protos { - for _, imp := range f.fd.Dependency { + for _, imp := range f.FileDescriptorProto().Dependency { if strings.HasSuffix(name, imp) { candidates := importCandidates[imp] if candidates == nil { @@ -449,7 +527,7 @@ func fixupFilenames(protos map[string]*parseResult) map[string]*parseResult { protoPaths[prefix] = struct{}{} } f := protos[best] - f.fd.Name = proto.String(imp) + f.FileDescriptorProto().Name = proto.String(imp) revisedProtos[imp] = f delete(candidatesAvailable, best) } @@ -489,7 +567,8 @@ func fixupFilenames(protos map[string]*parseResult) map[string]*parseResult { } if imp != "" { f := protos[c] - f.fd.Name = proto.String(imp) + f.FileDescriptorProto().Name = proto.String(imp) + f.FileNode() revisedProtos[imp] = f } else { revisedProtos[c] = protos[c] @@ -498,350 +577,3 @@ func fixupFilenames(protos map[string]*parseResult) map[string]*parseResult { return revisedProtos } - -func parseProtoFiles(acc FileAccessor, filenames []string, errs *errorHandler, parsed *parseResults, lookupImport func(string) (*dpb.FileDescriptorProto, error)) { - for _, name := range filenames { - parseProtoFile(acc, name, nil, errs, parsed, lookupImport) - if errs.err != nil { - return - } - } -} - -func parseProtoFile(acc FileAccessor, filename string, importLoc *SourcePos, errs *errorHandler, results *parseResults, lookupImport func(string) (*dpb.FileDescriptorProto, error)) { - if results.has(filename) { - return - } - if lookupImport == nil { - lookupImport = func(string) (*dpb.FileDescriptorProto, error) { - return nil, errors.New("no import lookup function") - } - } - in, err := acc(filename) - var result *parseResult - if err == nil { - // try to parse the bytes accessed - func() { - defer func() { - // if we've already parsed contents, an error - // closing need not fail this operation - _ = in.Close() - }() - result = parseProto(filename, in, errs, results.validate, results.createDescriptorProtos) - }() - } else if d, lookupErr := lookupImport(filename); lookupErr == nil { - // This is a user-provided descriptor, which is acting similarly to a - // well-known import. - result = &parseResult{fd: proto.Clone(d).(*dpb.FileDescriptorProto), errs: errs} - } else if d, ok := standardImports[filename]; ok { - // it's a well-known import - // (we clone it to make sure we're not sharing state with other - // parsers, which could result in unsafe races if multiple - // parsers are trying to access it concurrently) - result = &parseResult{fd: proto.Clone(d).(*dpb.FileDescriptorProto), errs: errs} - } else { - if !strings.Contains(err.Error(), filename) { - // an error message that doesn't indicate the file is awful! - // this cannot be %w as this is not compatible with go <= 1.13 - err = errorWithFilename{ - underlying: err, - filename: filename, - } - } - // The top-level loop in parseProtoFiles calls this with nil for the top-level files - // importLoc is only for imports, otherwise we do not want to return a ErrorWithSourcePos - // ErrorWithSourcePos should always have a non-nil SourcePos - if importLoc != nil { - // associate the error with the import line - err = ErrorWithSourcePos{ - Pos: importLoc, - Underlying: err, - } - } - _ = errs.handleError(err) - return - } - - results.add(filename, result) - - if errs.err != nil { - return // abort - } - - if results.recursive { - fd := result.fd - decl := result.getFileNode(fd) - fnode, ok := decl.(*ast.FileNode) - if !ok { - // no AST for this file? use imports in descriptor - for _, dep := range fd.Dependency { - parseProtoFile(acc, dep, decl.Start(), errs, results, lookupImport) - if errs.getError() != nil { - return // abort - } - } - return - } - // we have an AST; use it so we can report import location in errors - for _, decl := range fnode.Decls { - if dep, ok := decl.(*ast.ImportNode); ok { - parseProtoFile(acc, dep.Name.AsString(), dep.Name.Start(), errs, results, lookupImport) - if errs.getError() != nil { - return // abort - } - } - } - } -} - -type parseResults struct { - resultsByFilename map[string]*parseResult - filenames []string - - recursive, validate, createDescriptorProtos bool -} - -func (r *parseResults) has(filename string) bool { - _, ok := r.resultsByFilename[filename] - return ok -} - -func (r *parseResults) add(filename string, result *parseResult) { - r.resultsByFilename[filename] = result - r.filenames = append(r.filenames, filename) -} - -type parseResult struct { - // handles any errors encountered during parsing, construction of file descriptor, - // or validation - errs *errorHandler - - // the root of the AST - root *ast.FileNode - // the parsed file descriptor - fd *dpb.FileDescriptorProto - - // if set to true, enables lenient interpretation of options, where - // unrecognized options will be left uninterpreted instead of resulting in a - // link error - lenient bool - - // a map of elements in the descriptor to nodes in the AST - // (for extracting position information when validating the descriptor) - nodes map[proto.Message]ast.Node - - // a map of uninterpreted option AST nodes to their relative path - // in the resulting options message - interpretedOptions map[*ast.OptionNode][]int32 - - // a map of AST nodes that represent identifiers in ast.FieldReferenceNodes - // to their fully-qualified name. The identifiers are for field names in - // message literals (in option values) that are extension fields. These names - // are resolved during linking and stored here, to be used to interpret options. - optionQualifiedNames map[ast.IdentValueNode]string -} - -func (r *parseResult) getFileNode(f *dpb.FileDescriptorProto) ast.FileDeclNode { - if r.nodes == nil { - return ast.NewNoSourceNode(f.GetName()) - } - return r.nodes[f].(ast.FileDeclNode) -} - -func (r *parseResult) getOptionNode(o *dpb.UninterpretedOption) ast.OptionDeclNode { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[o].(ast.OptionDeclNode) -} - -func (r *parseResult) getOptionNamePartNode(o *dpb.UninterpretedOption_NamePart) ast.Node { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[o] -} - -func (r *parseResult) getFieldNode(f *dpb.FieldDescriptorProto) ast.FieldDeclNode { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[f].(ast.FieldDeclNode) -} - -func (r *parseResult) getExtensionRangeNode(e *dpb.DescriptorProto_ExtensionRange) ast.RangeDeclNode { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[e].(ast.RangeDeclNode) -} - -func (r *parseResult) getMessageReservedRangeNode(rr *dpb.DescriptorProto_ReservedRange) ast.RangeDeclNode { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[rr].(ast.RangeDeclNode) -} - -func (r *parseResult) getEnumNode(e *dpb.EnumDescriptorProto) ast.Node { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[e] -} - -func (r *parseResult) getEnumValueNode(e *dpb.EnumValueDescriptorProto) ast.EnumValueDeclNode { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[e].(ast.EnumValueDeclNode) -} - -func (r *parseResult) getEnumReservedRangeNode(rr *dpb.EnumDescriptorProto_EnumReservedRange) ast.RangeDeclNode { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[rr].(ast.RangeDeclNode) -} - -func (r *parseResult) getMethodNode(m *dpb.MethodDescriptorProto) ast.RPCDeclNode { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[m].(ast.RPCDeclNode) -} - -func (r *parseResult) getNode(m proto.Message) ast.Node { - if r.nodes == nil { - return ast.NewNoSourceNode(r.fd.GetName()) - } - return r.nodes[m] -} - -func (r *parseResult) putFileNode(f *dpb.FileDescriptorProto, n *ast.FileNode) { - r.nodes[f] = n -} - -func (r *parseResult) putOptionNode(o *dpb.UninterpretedOption, n *ast.OptionNode) { - r.nodes[o] = n -} - -func (r *parseResult) putOptionNamePartNode(o *dpb.UninterpretedOption_NamePart, n *ast.FieldReferenceNode) { - r.nodes[o] = n -} - -func (r *parseResult) putMessageNode(m *dpb.DescriptorProto, n ast.MessageDeclNode) { - r.nodes[m] = n -} - -func (r *parseResult) putFieldNode(f *dpb.FieldDescriptorProto, n ast.FieldDeclNode) { - r.nodes[f] = n -} - -func (r *parseResult) putOneOfNode(o *dpb.OneofDescriptorProto, n ast.OneOfDeclNode) { - r.nodes[o] = n -} - -func (r *parseResult) putExtensionRangeNode(e *dpb.DescriptorProto_ExtensionRange, n *ast.RangeNode) { - r.nodes[e] = n -} - -func (r *parseResult) putMessageReservedRangeNode(rr *dpb.DescriptorProto_ReservedRange, n *ast.RangeNode) { - r.nodes[rr] = n -} - -func (r *parseResult) putEnumNode(e *dpb.EnumDescriptorProto, n *ast.EnumNode) { - r.nodes[e] = n -} - -func (r *parseResult) putEnumValueNode(e *dpb.EnumValueDescriptorProto, n *ast.EnumValueNode) { - r.nodes[e] = n -} - -func (r *parseResult) putEnumReservedRangeNode(rr *dpb.EnumDescriptorProto_EnumReservedRange, n *ast.RangeNode) { - r.nodes[rr] = n -} - -func (r *parseResult) putServiceNode(s *dpb.ServiceDescriptorProto, n *ast.ServiceNode) { - r.nodes[s] = n -} - -func (r *parseResult) putMethodNode(m *dpb.MethodDescriptorProto, n *ast.RPCNode) { - r.nodes[m] = n -} - -func parseProto(filename string, r io.Reader, errs *errorHandler, validate, createProtos bool) *parseResult { - beforeErrs := errs.errsReported - lx := newLexer(r, filename, errs) - protoParse(lx) - if lx.res == nil || len(lx.res.Children()) == 0 { - // nil AST means there was an error that prevented any parsing - // or the file was empty; synthesize empty non-nil AST - lx.res = ast.NewEmptyFileNode(filename) - } - if lx.eof != nil { - lx.res.FinalComments = lx.eof.LeadingComments() - lx.res.FinalWhitespace = lx.eof.LeadingWhitespace() - } - res := createParseResult(filename, lx.res, errs, createProtos) - if validate && errs.err == nil { - validateBasic(res, errs.errsReported > beforeErrs) - } - - return res -} - -func createParseResult(filename string, file *ast.FileNode, errs *errorHandler, createProtos bool) *parseResult { - res := &parseResult{ - errs: errs, - root: file, - nodes: map[proto.Message]ast.Node{}, - interpretedOptions: map[*ast.OptionNode][]int32{}, - optionQualifiedNames: map[ast.IdentValueNode]string{}, - } - if createProtos { - res.createFileDescriptor(filename, file) - } - return res -} - -func checkTag(pos *SourcePos, v uint64, maxTag int32) error { - if v < 1 { - return errorWithPos(pos, "tag number %d must be greater than zero", v) - } else if v > uint64(maxTag) { - return errorWithPos(pos, "tag number %d is higher than max allowed tag number (%d)", v, maxTag) - } else if v >= internal.SpecialReservedStart && v <= internal.SpecialReservedEnd { - return errorWithPos(pos, "tag number %d is in disallowed reserved range %d-%d", v, internal.SpecialReservedStart, internal.SpecialReservedEnd) - } - return nil -} - -func writeEscapedBytes(buf *bytes.Buffer, b []byte) { - for _, c := range b { - switch c { - case '\n': - buf.WriteString("\\n") - case '\r': - buf.WriteString("\\r") - case '\t': - buf.WriteString("\\t") - case '"': - buf.WriteString("\\\"") - case '\'': - buf.WriteString("\\'") - case '\\': - buf.WriteString("\\\\") - default: - if c >= 0x20 && c <= 0x7f && c != '"' && c != '\\' { - // simple printable characters - buf.WriteByte(c) - } else { - // use octal escape for all other values - buf.WriteRune('\\') - buf.WriteByte('0' + ((c >> 6) & 0x7)) - buf.WriteByte('0' + ((c >> 3) & 0x7)) - buf.WriteByte('0' + (c & 0x7)) - } - } - } -} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/source_code_info.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/source_code_info.go deleted file mode 100644 index 02df689a951..00000000000 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/source_code_info.go +++ /dev/null @@ -1,544 +0,0 @@ -package protoparse - -import ( - "bytes" - "strings" - - "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" - - "github.com/jhump/protoreflect/desc/internal" - "github.com/jhump/protoreflect/desc/protoparse/ast" -) - -func (r *parseResult) generateSourceCodeInfo() *dpb.SourceCodeInfo { - if r.nodes == nil { - // skip files that do not have AST info (these will be files - // that came from well-known descriptors, instead of from source) - return nil - } - - sci := sourceCodeInfo{commentsUsed: map[*ast.Comment]struct{}{}} - path := make([]int32, 0, 10) - - fn := r.getFileNode(r.fd).(*ast.FileNode) - sci.newLocWithoutComments(fn, nil) - - if fn.Syntax != nil { - sci.newLoc(fn.Syntax, append(path, internal.File_syntaxTag)) - } - - var depIndex, optIndex, msgIndex, enumIndex, extendIndex, svcIndex int32 - - for _, child := range fn.Decls { - switch child := child.(type) { - case *ast.ImportNode: - sci.newLoc(child, append(path, internal.File_dependencyTag, int32(depIndex))) - depIndex++ - case *ast.PackageNode: - sci.newLoc(child, append(path, internal.File_packageTag)) - case *ast.OptionNode: - r.generateSourceCodeInfoForOption(&sci, child, false, &optIndex, append(path, internal.File_optionsTag)) - case *ast.MessageNode: - r.generateSourceCodeInfoForMessage(&sci, child, nil, append(path, internal.File_messagesTag, msgIndex)) - msgIndex++ - case *ast.EnumNode: - r.generateSourceCodeInfoForEnum(&sci, child, append(path, internal.File_enumsTag, enumIndex)) - enumIndex++ - case *ast.ExtendNode: - r.generateSourceCodeInfoForExtensions(&sci, child, &extendIndex, &msgIndex, append(path, internal.File_extensionsTag), append(dup(path), internal.File_messagesTag)) - case *ast.ServiceNode: - r.generateSourceCodeInfoForService(&sci, child, append(path, internal.File_servicesTag, svcIndex)) - svcIndex++ - } - } - - return &dpb.SourceCodeInfo{Location: sci.locs} -} - -func (r *parseResult) generateSourceCodeInfoForOption(sci *sourceCodeInfo, n *ast.OptionNode, compact bool, uninterpIndex *int32, path []int32) { - if !compact { - sci.newLocWithoutComments(n, path) - } - subPath := r.interpretedOptions[n] - if len(subPath) > 0 { - p := path - if subPath[0] == -1 { - // used by "default" and "json_name" field pseudo-options - // to attribute path to parent element (since those are - // stored directly on the descriptor, not its options) - p = make([]int32, len(path)-1) - copy(p, path) - subPath = subPath[1:] - } - sci.newLoc(n, append(p, subPath...)) - return - } - - // it's an uninterpreted option - optPath := append(path, internal.UninterpretedOptionsTag, *uninterpIndex) - *uninterpIndex++ - sci.newLoc(n, optPath) - var valTag int32 - switch n.Val.(type) { - case ast.IdentValueNode: - valTag = internal.Uninterpreted_identTag - case *ast.NegativeIntLiteralNode: - valTag = internal.Uninterpreted_negIntTag - case ast.IntValueNode: - valTag = internal.Uninterpreted_posIntTag - case ast.FloatValueNode: - valTag = internal.Uninterpreted_doubleTag - case ast.StringValueNode: - valTag = internal.Uninterpreted_stringTag - case *ast.MessageLiteralNode: - valTag = internal.Uninterpreted_aggregateTag - } - if valTag != 0 { - sci.newLoc(n.Val, append(optPath, valTag)) - } - for j, nn := range n.Name.Parts { - optNmPath := append(optPath, internal.Uninterpreted_nameTag, int32(j)) - sci.newLoc(nn, optNmPath) - sci.newLoc(nn.Name, append(optNmPath, internal.UninterpretedName_nameTag)) - } -} - -func (r *parseResult) generateSourceCodeInfoForMessage(sci *sourceCodeInfo, n ast.MessageDeclNode, fieldPath []int32, path []int32) { - var openBrace ast.Node - var decls []ast.MessageElement - switch n := n.(type) { - case *ast.MessageNode: - openBrace = n.OpenBrace - decls = n.Decls - case *ast.GroupNode: - openBrace = n.OpenBrace - decls = n.Decls - case *ast.MapFieldNode: - sci.newLoc(n, path) - // map entry so nothing else to do - return - } - sci.newBlockLoc(n, openBrace, path) - - sci.newLoc(n.MessageName(), append(path, internal.Message_nameTag)) - // matching protoc, which emits the corresponding field type name (for group fields) - // right after the source location for the group message name - if fieldPath != nil { - sci.newLoc(n.MessageName(), append(fieldPath, internal.Field_typeNameTag)) - } - - var optIndex, fieldIndex, oneOfIndex, extendIndex, nestedMsgIndex int32 - var nestedEnumIndex, extRangeIndex, reservedRangeIndex, reservedNameIndex int32 - for _, child := range decls { - switch child := child.(type) { - case *ast.OptionNode: - r.generateSourceCodeInfoForOption(sci, child, false, &optIndex, append(path, internal.Message_optionsTag)) - case *ast.FieldNode: - r.generateSourceCodeInfoForField(sci, child, append(path, internal.Message_fieldsTag, fieldIndex)) - fieldIndex++ - case *ast.GroupNode: - fldPath := append(path, internal.Message_fieldsTag, fieldIndex) - r.generateSourceCodeInfoForField(sci, child, fldPath) - fieldIndex++ - r.generateSourceCodeInfoForMessage(sci, child, fldPath, append(dup(path), internal.Message_nestedMessagesTag, nestedMsgIndex)) - nestedMsgIndex++ - case *ast.MapFieldNode: - r.generateSourceCodeInfoForField(sci, child, append(path, internal.Message_fieldsTag, fieldIndex)) - fieldIndex++ - nestedMsgIndex++ - case *ast.OneOfNode: - r.generateSourceCodeInfoForOneOf(sci, child, &fieldIndex, &nestedMsgIndex, append(path, internal.Message_fieldsTag), append(dup(path), internal.Message_nestedMessagesTag), append(dup(path), internal.Message_oneOfsTag, oneOfIndex)) - oneOfIndex++ - case *ast.MessageNode: - r.generateSourceCodeInfoForMessage(sci, child, nil, append(path, internal.Message_nestedMessagesTag, nestedMsgIndex)) - nestedMsgIndex++ - case *ast.EnumNode: - r.generateSourceCodeInfoForEnum(sci, child, append(path, internal.Message_enumsTag, nestedEnumIndex)) - nestedEnumIndex++ - case *ast.ExtendNode: - r.generateSourceCodeInfoForExtensions(sci, child, &extendIndex, &nestedMsgIndex, append(path, internal.Message_extensionsTag), append(dup(path), internal.Message_nestedMessagesTag)) - case *ast.ExtensionRangeNode: - r.generateSourceCodeInfoForExtensionRanges(sci, child, &extRangeIndex, append(path, internal.Message_extensionRangeTag)) - case *ast.ReservedNode: - if len(child.Names) > 0 { - resPath := append(path, internal.Message_reservedNameTag) - sci.newLoc(child, resPath) - for _, rn := range child.Names { - sci.newLoc(rn, append(resPath, reservedNameIndex)) - reservedNameIndex++ - } - } - if len(child.Ranges) > 0 { - resPath := append(path, internal.Message_reservedRangeTag) - sci.newLoc(child, resPath) - for _, rr := range child.Ranges { - r.generateSourceCodeInfoForReservedRange(sci, rr, append(resPath, reservedRangeIndex)) - reservedRangeIndex++ - } - } - } - } -} - -func (r *parseResult) generateSourceCodeInfoForEnum(sci *sourceCodeInfo, n *ast.EnumNode, path []int32) { - sci.newBlockLoc(n, n.OpenBrace, path) - sci.newLoc(n.Name, append(path, internal.Enum_nameTag)) - - var optIndex, valIndex, reservedNameIndex, reservedRangeIndex int32 - for _, child := range n.Decls { - switch child := child.(type) { - case *ast.OptionNode: - r.generateSourceCodeInfoForOption(sci, child, false, &optIndex, append(path, internal.Enum_optionsTag)) - case *ast.EnumValueNode: - r.generateSourceCodeInfoForEnumValue(sci, child, append(path, internal.Enum_valuesTag, valIndex)) - valIndex++ - case *ast.ReservedNode: - if len(child.Names) > 0 { - resPath := append(path, internal.Enum_reservedNameTag) - sci.newLoc(child, resPath) - for _, rn := range child.Names { - sci.newLoc(rn, append(resPath, reservedNameIndex)) - reservedNameIndex++ - } - } - if len(child.Ranges) > 0 { - resPath := append(path, internal.Enum_reservedRangeTag) - sci.newLoc(child, resPath) - for _, rr := range child.Ranges { - r.generateSourceCodeInfoForReservedRange(sci, rr, append(resPath, reservedRangeIndex)) - reservedRangeIndex++ - } - } - } - } -} - -func (r *parseResult) generateSourceCodeInfoForEnumValue(sci *sourceCodeInfo, n *ast.EnumValueNode, path []int32) { - sci.newLoc(n, path) - sci.newLoc(n.Name, append(path, internal.EnumVal_nameTag)) - sci.newLoc(n.Number, append(path, internal.EnumVal_numberTag)) - - // enum value options - if n.Options != nil { - optsPath := append(path, internal.EnumVal_optionsTag) - sci.newLoc(n.Options, optsPath) - var optIndex int32 - for _, opt := range n.Options.GetElements() { - r.generateSourceCodeInfoForOption(sci, opt, true, &optIndex, optsPath) - } - } -} - -func (r *parseResult) generateSourceCodeInfoForReservedRange(sci *sourceCodeInfo, n *ast.RangeNode, path []int32) { - sci.newLoc(n, path) - sci.newLoc(n.StartVal, append(path, internal.ReservedRange_startTag)) - if n.EndVal != nil { - sci.newLoc(n.EndVal, append(path, internal.ReservedRange_endTag)) - } else if n.Max != nil { - sci.newLoc(n.Max, append(path, internal.ReservedRange_endTag)) - } -} - -func (r *parseResult) generateSourceCodeInfoForExtensions(sci *sourceCodeInfo, n *ast.ExtendNode, extendIndex, msgIndex *int32, extendPath, msgPath []int32) { - sci.newBlockLoc(n, n.OpenBrace, extendPath) - for _, decl := range n.Decls { - switch decl := decl.(type) { - case *ast.FieldNode: - r.generateSourceCodeInfoForField(sci, decl, append(extendPath, *extendIndex)) - *extendIndex++ - case *ast.GroupNode: - fldPath := append(extendPath, *extendIndex) - r.generateSourceCodeInfoForField(sci, decl, fldPath) - *extendIndex++ - r.generateSourceCodeInfoForMessage(sci, decl, fldPath, append(msgPath, *msgIndex)) - *msgIndex++ - } - } -} - -func (r *parseResult) generateSourceCodeInfoForOneOf(sci *sourceCodeInfo, n *ast.OneOfNode, fieldIndex, nestedMsgIndex *int32, fieldPath, nestedMsgPath, oneOfPath []int32) { - sci.newBlockLoc(n, n.OpenBrace, oneOfPath) - sci.newLoc(n.Name, append(oneOfPath, internal.OneOf_nameTag)) - - var optIndex int32 - for _, child := range n.Decls { - switch child := child.(type) { - case *ast.OptionNode: - r.generateSourceCodeInfoForOption(sci, child, false, &optIndex, append(oneOfPath, internal.OneOf_optionsTag)) - case *ast.FieldNode: - r.generateSourceCodeInfoForField(sci, child, append(fieldPath, *fieldIndex)) - *fieldIndex++ - case *ast.GroupNode: - fldPath := append(fieldPath, *fieldIndex) - r.generateSourceCodeInfoForField(sci, child, fldPath) - *fieldIndex++ - r.generateSourceCodeInfoForMessage(sci, child, fldPath, append(nestedMsgPath, *nestedMsgIndex)) - *nestedMsgIndex++ - } - } -} - -func (r *parseResult) generateSourceCodeInfoForField(sci *sourceCodeInfo, n ast.FieldDeclNode, path []int32) { - var fieldType string - if f, ok := n.(*ast.FieldNode); ok { - fieldType = string(f.FldType.AsIdentifier()) - } - - if n.GetGroupKeyword() != nil { - // comments will appear on group message - sci.newLocWithoutComments(n, path) - if n.FieldExtendee() != nil { - sci.newLoc(n.FieldExtendee(), append(path, internal.Field_extendeeTag)) - } - if n.FieldLabel() != nil { - // no comments here either (label is first token for group, so we want - // to leave the comments to be associated with the group message instead) - sci.newLocWithoutComments(n.FieldLabel(), append(path, internal.Field_labelTag)) - } - sci.newLoc(n.FieldType(), append(path, internal.Field_typeTag)) - // let the name comments be attributed to the group name - sci.newLocWithoutComments(n.FieldName(), append(path, internal.Field_nameTag)) - } else { - sci.newLoc(n, path) - if n.FieldExtendee() != nil { - sci.newLoc(n.FieldExtendee(), append(path, internal.Field_extendeeTag)) - } - if n.FieldLabel() != nil { - sci.newLoc(n.FieldLabel(), append(path, internal.Field_labelTag)) - } - var tag int32 - if _, isScalar := fieldTypes[fieldType]; isScalar { - tag = internal.Field_typeTag - } else { - // this is a message or an enum, so attribute type location - // to the type name field - tag = internal.Field_typeNameTag - } - sci.newLoc(n.FieldType(), append(path, tag)) - sci.newLoc(n.FieldName(), append(path, internal.Field_nameTag)) - } - sci.newLoc(n.FieldTag(), append(path, internal.Field_numberTag)) - - if n.GetOptions() != nil { - optsPath := append(path, internal.Field_optionsTag) - sci.newLoc(n.GetOptions(), optsPath) - var optIndex int32 - for _, opt := range n.GetOptions().GetElements() { - r.generateSourceCodeInfoForOption(sci, opt, true, &optIndex, optsPath) - } - } -} - -func (r *parseResult) generateSourceCodeInfoForExtensionRanges(sci *sourceCodeInfo, n *ast.ExtensionRangeNode, extRangeIndex *int32, path []int32) { - sci.newLoc(n, path) - for _, child := range n.Ranges { - path := append(path, *extRangeIndex) - *extRangeIndex++ - sci.newLoc(child, path) - sci.newLoc(child.StartVal, append(path, internal.ExtensionRange_startTag)) - if child.EndVal != nil { - sci.newLoc(child.EndVal, append(path, internal.ExtensionRange_endTag)) - } else if child.Max != nil { - sci.newLoc(child.Max, append(path, internal.ExtensionRange_endTag)) - } - if n.Options != nil { - optsPath := append(path, internal.ExtensionRange_optionsTag) - sci.newLoc(n.Options, optsPath) - var optIndex int32 - for _, opt := range n.Options.GetElements() { - r.generateSourceCodeInfoForOption(sci, opt, true, &optIndex, optsPath) - } - } - } -} - -func (r *parseResult) generateSourceCodeInfoForService(sci *sourceCodeInfo, n *ast.ServiceNode, path []int32) { - sci.newBlockLoc(n, n.OpenBrace, path) - sci.newLoc(n.Name, append(path, internal.Service_nameTag)) - var optIndex, rpcIndex int32 - for _, child := range n.Decls { - switch child := child.(type) { - case *ast.OptionNode: - r.generateSourceCodeInfoForOption(sci, child, false, &optIndex, append(path, internal.Service_optionsTag)) - case *ast.RPCNode: - r.generateSourceCodeInfoForMethod(sci, child, append(path, internal.Service_methodsTag, rpcIndex)) - rpcIndex++ - } - } -} - -func (r *parseResult) generateSourceCodeInfoForMethod(sci *sourceCodeInfo, n *ast.RPCNode, path []int32) { - if n.OpenBrace != nil { - sci.newBlockLoc(n, n.OpenBrace, path) - } else { - sci.newLoc(n, path) - } - sci.newLoc(n.Name, append(path, internal.Method_nameTag)) - if n.Input.Stream != nil { - sci.newLoc(n.Input.Stream, append(path, internal.Method_inputStreamTag)) - } - sci.newLoc(n.Input.MessageType, append(path, internal.Method_inputTag)) - if n.Output.Stream != nil { - sci.newLoc(n.Output.Stream, append(path, internal.Method_outputStreamTag)) - } - sci.newLoc(n.Output.MessageType, append(path, internal.Method_outputTag)) - - optsPath := append(path, internal.Method_optionsTag) - var optIndex int32 - for _, decl := range n.Decls { - if opt, ok := decl.(*ast.OptionNode); ok { - r.generateSourceCodeInfoForOption(sci, opt, false, &optIndex, optsPath) - } - } -} - -type sourceCodeInfo struct { - locs []*dpb.SourceCodeInfo_Location - commentsUsed map[*ast.Comment]struct{} -} - -func (sci *sourceCodeInfo) newLocWithoutComments(n ast.Node, path []int32) { - dup := make([]int32, len(path)) - copy(dup, path) - sci.locs = append(sci.locs, &dpb.SourceCodeInfo_Location{ - Path: dup, - Span: makeSpan(n.Start(), n.End()), - }) -} - -func (sci *sourceCodeInfo) newBlockLoc(n, openBrace ast.Node, path []int32) { - // Block definitions use trailing comments after the open brace "{" as the - // element's trailing comments. For example: - // - // message Foo { // this is a trailing comment for a message - // - // } // not this - // - sci.newLocWithComments(n, n.LeadingComments(), openBrace.TrailingComments(), path) -} - -func (sci *sourceCodeInfo) newLoc(n ast.Node, path []int32) { - sci.newLocWithComments(n, n.LeadingComments(), n.TrailingComments(), path) -} - -func (sci *sourceCodeInfo) newLocWithComments(n ast.Node, leadingComments, trailingComments []ast.Comment, path []int32) { - if sci.commentUsed(leadingComments) { - leadingComments = nil - } - if sci.commentUsed(trailingComments) { - trailingComments = nil - } - detached := groupComments(leadingComments) - var trail *string - if str, ok := combineComments(trailingComments); ok { - trail = proto.String(str) - } - var lead *string - if len(leadingComments) > 0 && leadingComments[len(leadingComments)-1].End.Line >= n.Start().Line-1 { - lead = proto.String(detached[len(detached)-1]) - detached = detached[:len(detached)-1] - } - dup := make([]int32, len(path)) - copy(dup, path) - sci.locs = append(sci.locs, &dpb.SourceCodeInfo_Location{ - LeadingDetachedComments: detached, - LeadingComments: lead, - TrailingComments: trail, - Path: dup, - Span: makeSpan(n.Start(), n.End()), - }) -} - -func makeSpan(start, end *SourcePos) []int32 { - if start.Line == end.Line { - return []int32{int32(start.Line) - 1, int32(start.Col) - 1, int32(end.Col) - 1} - } - return []int32{int32(start.Line) - 1, int32(start.Col) - 1, int32(end.Line) - 1, int32(end.Col) - 1} -} - -func (sci *sourceCodeInfo) commentUsed(c []ast.Comment) bool { - if len(c) == 0 { - return false - } - if _, ok := sci.commentsUsed[&c[0]]; ok { - return true - } - - sci.commentsUsed[&c[0]] = struct{}{} - return false -} - -func groupComments(comments []ast.Comment) []string { - if len(comments) == 0 { - return nil - } - - var groups []string - singleLineStyle := comments[0].Text[:2] == "//" - line := comments[0].End.Line - start := 0 - for i := 1; i < len(comments); i++ { - c := comments[i] - prevSingleLine := singleLineStyle - singleLineStyle = strings.HasPrefix(comments[i].Text, "//") - if !singleLineStyle || prevSingleLine != singleLineStyle || c.Start.Line > line+1 { - // new group! - if str, ok := combineComments(comments[start:i]); ok { - groups = append(groups, str) - } - start = i - } - line = c.End.Line - } - // don't forget last group - if str, ok := combineComments(comments[start:]); ok { - groups = append(groups, str) - } - return groups -} - -func combineComments(comments []ast.Comment) (string, bool) { - if len(comments) == 0 { - return "", false - } - var buf bytes.Buffer - for _, c := range comments { - if c.Text[:2] == "//" { - buf.WriteString(c.Text[2:]) - } else { - lines := strings.Split(c.Text[2:len(c.Text)-2], "\n") - first := true - for _, l := range lines { - if first { - first = false - } else { - buf.WriteByte('\n') - } - - // strip a prefix of whitespace followed by '*' - j := 0 - for j < len(l) { - if l[j] != ' ' && l[j] != '\t' { - break - } - j++ - } - if j == len(l) { - l = "" - } else if l[j] == '*' { - l = l[j+1:] - } else if j > 0 { - l = " " + l[j:] - } - - buf.WriteString(l) - } - } - } - return buf.String(), true -} - -func dup(p []int32) []int32 { - return append(([]int32)(nil), p...) -} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/std_imports.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/std_imports.go deleted file mode 100644 index 8fbc1fc3151..00000000000 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/std_imports.go +++ /dev/null @@ -1,50 +0,0 @@ -package protoparse - -import ( - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" - // link in packages that include the standard protos included with protoc - _ "github.com/golang/protobuf/protoc-gen-go/plugin" - _ "github.com/golang/protobuf/ptypes/any" - _ "github.com/golang/protobuf/ptypes/duration" - _ "github.com/golang/protobuf/ptypes/empty" - _ "github.com/golang/protobuf/ptypes/struct" - _ "github.com/golang/protobuf/ptypes/timestamp" - _ "github.com/golang/protobuf/ptypes/wrappers" - _ "google.golang.org/genproto/protobuf/api" - _ "google.golang.org/genproto/protobuf/field_mask" - _ "google.golang.org/genproto/protobuf/ptype" - _ "google.golang.org/genproto/protobuf/source_context" - - "github.com/jhump/protoreflect/internal" -) - -// All files that are included with protoc are also included with this package -// so that clients do not need to explicitly supply a copy of these protos (just -// like callers of protoc do not need to supply them). -var standardImports map[string]*dpb.FileDescriptorProto - -func init() { - standardFilenames := []string{ - "google/protobuf/any.proto", - "google/protobuf/api.proto", - "google/protobuf/compiler/plugin.proto", - "google/protobuf/descriptor.proto", - "google/protobuf/duration.proto", - "google/protobuf/empty.proto", - "google/protobuf/field_mask.proto", - "google/protobuf/source_context.proto", - "google/protobuf/struct.proto", - "google/protobuf/timestamp.proto", - "google/protobuf/type.proto", - "google/protobuf/wrappers.proto", - } - - standardImports = map[string]*dpb.FileDescriptorProto{} - for _, fn := range standardFilenames { - fd, err := internal.LoadFileDescriptor(fn) - if err != nil { - panic(err.Error()) - } - standardImports[fn] = fd - } -} diff --git a/vendor/github.com/jhump/protoreflect/desc/protoparse/validate.go b/vendor/github.com/jhump/protoreflect/desc/protoparse/validate.go deleted file mode 100644 index 2dd91618e52..00000000000 --- a/vendor/github.com/jhump/protoreflect/desc/protoparse/validate.go +++ /dev/null @@ -1,383 +0,0 @@ -package protoparse - -import ( - "fmt" - "sort" - - "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" - - "github.com/jhump/protoreflect/desc/protoparse/ast" -) - -func validateBasic(res *parseResult, containsErrors bool) { - fd := res.fd - isProto3 := fd.GetSyntax() == "proto3" - - if validateImports(res) != nil { - return - } - - for _, md := range fd.MessageType { - if validateMessage(res, isProto3, "", md, containsErrors) != nil { - return - } - } - - for _, ed := range fd.EnumType { - if validateEnum(res, isProto3, "", ed, containsErrors) != nil { - return - } - } - - for _, fld := range fd.Extension { - if validateField(res, isProto3, "", fld) != nil { - return - } - } -} - -func validateImports(res *parseResult) error { - fileNode := res.root - if fileNode == nil { - return nil - } - imports := make(map[string]*ast.SourcePos, len(fileNode.Decls)) - for _, decl := range fileNode.Decls { - imp, ok := decl.(*ast.ImportNode) - if !ok { - continue - } - - name := imp.Name.AsString() - if imports[name] != nil { - return res.errs.handleErrorWithPos(imp.Start(), `%q was already imported at %v`, name, imports[name]) - } - imports[name] = imp.Start() - } - return nil -} - -func validateMessage(res *parseResult, isProto3 bool, prefix string, md *dpb.DescriptorProto, containsErrors bool) error { - nextPrefix := md.GetName() + "." - - for _, fld := range md.Field { - if err := validateField(res, isProto3, nextPrefix, fld); err != nil { - return err - } - } - for _, fld := range md.Extension { - if err := validateField(res, isProto3, nextPrefix, fld); err != nil { - return err - } - } - for _, ed := range md.EnumType { - if err := validateEnum(res, isProto3, nextPrefix, ed, containsErrors); err != nil { - return err - } - } - for _, nmd := range md.NestedType { - if err := validateMessage(res, isProto3, nextPrefix, nmd, containsErrors); err != nil { - return err - } - } - - scope := fmt.Sprintf("message %s%s", prefix, md.GetName()) - - if isProto3 && len(md.ExtensionRange) > 0 { - n := res.getExtensionRangeNode(md.ExtensionRange[0]) - if err := res.errs.handleErrorWithPos(n.Start(), "%s: extension ranges are not allowed in proto3", scope); err != nil { - return err - } - } - - if index, err := findOption(res, scope, md.Options.GetUninterpretedOption(), "map_entry"); err != nil { - return err - } else if index >= 0 { - opt := md.Options.UninterpretedOption[index] - optn := res.getOptionNode(opt) - md.Options.UninterpretedOption = removeOption(md.Options.UninterpretedOption, index) - valid := false - if opt.IdentifierValue != nil { - if opt.GetIdentifierValue() == "true" { - valid = true - if err := res.errs.handleErrorWithPos(optn.GetValue().Start(), "%s: map_entry option should not be set explicitly; use map type instead", scope); err != nil { - return err - } - } else if opt.GetIdentifierValue() == "false" { - valid = true - md.Options.MapEntry = proto.Bool(false) - } - } - if !valid { - if err := res.errs.handleErrorWithPos(optn.GetValue().Start(), "%s: expecting bool value for map_entry option", scope); err != nil { - return err - } - } - } - - // reserved ranges should not overlap - rsvd := make(tagRanges, len(md.ReservedRange)) - for i, r := range md.ReservedRange { - n := res.getMessageReservedRangeNode(r) - rsvd[i] = tagRange{start: r.GetStart(), end: r.GetEnd(), node: n} - - } - sort.Sort(rsvd) - for i := 1; i < len(rsvd); i++ { - if rsvd[i].start < rsvd[i-1].end { - if err := res.errs.handleErrorWithPos(rsvd[i].node.Start(), "%s: reserved ranges overlap: %d to %d and %d to %d", scope, rsvd[i-1].start, rsvd[i-1].end-1, rsvd[i].start, rsvd[i].end-1); err != nil { - return err - } - } - } - - // extensions ranges should not overlap - exts := make(tagRanges, len(md.ExtensionRange)) - for i, r := range md.ExtensionRange { - n := res.getExtensionRangeNode(r) - exts[i] = tagRange{start: r.GetStart(), end: r.GetEnd(), node: n} - } - sort.Sort(exts) - for i := 1; i < len(exts); i++ { - if exts[i].start < exts[i-1].end { - if err := res.errs.handleErrorWithPos(exts[i].node.Start(), "%s: extension ranges overlap: %d to %d and %d to %d", scope, exts[i-1].start, exts[i-1].end-1, exts[i].start, exts[i].end-1); err != nil { - return err - } - } - } - - // see if any extension range overlaps any reserved range - var i, j int // i indexes rsvd; j indexes exts - for i < len(rsvd) && j < len(exts) { - if rsvd[i].start >= exts[j].start && rsvd[i].start < exts[j].end || - exts[j].start >= rsvd[i].start && exts[j].start < rsvd[i].end { - - var pos *SourcePos - if rsvd[i].start >= exts[j].start && rsvd[i].start < exts[j].end { - pos = rsvd[i].node.Start() - } else { - pos = exts[j].node.Start() - } - // ranges overlap - if err := res.errs.handleErrorWithPos(pos, "%s: extension range %d to %d overlaps reserved range %d to %d", scope, exts[j].start, exts[j].end-1, rsvd[i].start, rsvd[i].end-1); err != nil { - return err - } - } - if rsvd[i].start < exts[j].start { - i++ - } else { - j++ - } - } - - // now, check that fields don't re-use tags and don't try to use extension - // or reserved ranges or reserved names - rsvdNames := map[string]struct{}{} - for _, n := range md.ReservedName { - rsvdNames[n] = struct{}{} - } - fieldTags := map[int32]string{} - for _, fld := range md.Field { - fn := res.getFieldNode(fld) - if _, ok := rsvdNames[fld.GetName()]; ok { - if err := res.errs.handleErrorWithPos(fn.FieldName().Start(), "%s: field %s is using a reserved name", scope, fld.GetName()); err != nil { - return err - } - } - if existing := fieldTags[fld.GetNumber()]; existing != "" { - if err := res.errs.handleErrorWithPos(fn.FieldTag().Start(), "%s: fields %s and %s both have the same tag %d", scope, existing, fld.GetName(), fld.GetNumber()); err != nil { - return err - } - } - fieldTags[fld.GetNumber()] = fld.GetName() - // check reserved ranges - r := sort.Search(len(rsvd), func(index int) bool { return rsvd[index].end > fld.GetNumber() }) - if r < len(rsvd) && rsvd[r].start <= fld.GetNumber() { - if err := res.errs.handleErrorWithPos(fn.FieldTag().Start(), "%s: field %s is using tag %d which is in reserved range %d to %d", scope, fld.GetName(), fld.GetNumber(), rsvd[r].start, rsvd[r].end-1); err != nil { - return err - } - } - // and check extension ranges - e := sort.Search(len(exts), func(index int) bool { return exts[index].end > fld.GetNumber() }) - if e < len(exts) && exts[e].start <= fld.GetNumber() { - if err := res.errs.handleErrorWithPos(fn.FieldTag().Start(), "%s: field %s is using tag %d which is in extension range %d to %d", scope, fld.GetName(), fld.GetNumber(), exts[e].start, exts[e].end-1); err != nil { - return err - } - } - } - - return nil -} - -func validateEnum(res *parseResult, isProto3 bool, prefix string, ed *dpb.EnumDescriptorProto, containsErrors bool) error { - scope := fmt.Sprintf("enum %s%s", prefix, ed.GetName()) - - if !containsErrors && len(ed.Value) == 0 { - // we only check this if file parsing had no errors; otherwise, the file may have - // had an enum value, but the parser encountered an error processing it, in which - // case the value would be absent from the descriptor. In such a case, this error - // would be confusing and incorrect, so we just skip this check. - enNode := res.getEnumNode(ed) - if err := res.errs.handleErrorWithPos(enNode.Start(), "%s: enums must define at least one value", scope); err != nil { - return err - } - } - - allowAlias := false - var allowAliasOpt *dpb.UninterpretedOption - if index, err := findOption(res, scope, ed.Options.GetUninterpretedOption(), "allow_alias"); err != nil { - return err - } else if index >= 0 { - allowAliasOpt = ed.Options.UninterpretedOption[index] - valid := false - if allowAliasOpt.IdentifierValue != nil { - if allowAliasOpt.GetIdentifierValue() == "true" { - allowAlias = true - valid = true - } else if allowAliasOpt.GetIdentifierValue() == "false" { - valid = true - } - } - if !valid { - optNode := res.getOptionNode(allowAliasOpt) - if err := res.errs.handleErrorWithPos(optNode.GetValue().Start(), "%s: expecting bool value for allow_alias option", scope); err != nil { - return err - } - } - } - - if isProto3 && len(ed.Value) > 0 && ed.Value[0].GetNumber() != 0 { - evNode := res.getEnumValueNode(ed.Value[0]) - if err := res.errs.handleErrorWithPos(evNode.GetNumber().Start(), "%s: proto3 requires that first value in enum have numeric value of 0", scope); err != nil { - return err - } - } - - // check for aliases - vals := map[int32]string{} - hasAlias := false - for _, evd := range ed.Value { - existing := vals[evd.GetNumber()] - if existing != "" { - if allowAlias { - hasAlias = true - } else { - evNode := res.getEnumValueNode(evd) - if err := res.errs.handleErrorWithPos(evNode.GetNumber().Start(), "%s: values %s and %s both have the same numeric value %d; use allow_alias option if intentional", scope, existing, evd.GetName(), evd.GetNumber()); err != nil { - return err - } - } - } - vals[evd.GetNumber()] = evd.GetName() - } - if allowAlias && !hasAlias { - optNode := res.getOptionNode(allowAliasOpt) - if err := res.errs.handleErrorWithPos(optNode.GetValue().Start(), "%s: allow_alias is true but no values are aliases", scope); err != nil { - return err - } - } - - // reserved ranges should not overlap - rsvd := make(tagRanges, len(ed.ReservedRange)) - for i, r := range ed.ReservedRange { - n := res.getEnumReservedRangeNode(r) - rsvd[i] = tagRange{start: r.GetStart(), end: r.GetEnd(), node: n} - } - sort.Sort(rsvd) - for i := 1; i < len(rsvd); i++ { - if rsvd[i].start <= rsvd[i-1].end { - if err := res.errs.handleErrorWithPos(rsvd[i].node.Start(), "%s: reserved ranges overlap: %d to %d and %d to %d", scope, rsvd[i-1].start, rsvd[i-1].end, rsvd[i].start, rsvd[i].end); err != nil { - return err - } - } - } - - // now, check that fields don't re-use tags and don't try to use extension - // or reserved ranges or reserved names - rsvdNames := map[string]struct{}{} - for _, n := range ed.ReservedName { - rsvdNames[n] = struct{}{} - } - for _, ev := range ed.Value { - evn := res.getEnumValueNode(ev) - if _, ok := rsvdNames[ev.GetName()]; ok { - if err := res.errs.handleErrorWithPos(evn.GetName().Start(), "%s: value %s is using a reserved name", scope, ev.GetName()); err != nil { - return err - } - } - // check reserved ranges - r := sort.Search(len(rsvd), func(index int) bool { return rsvd[index].end >= ev.GetNumber() }) - if r < len(rsvd) && rsvd[r].start <= ev.GetNumber() { - if err := res.errs.handleErrorWithPos(evn.GetNumber().Start(), "%s: value %s is using number %d which is in reserved range %d to %d", scope, ev.GetName(), ev.GetNumber(), rsvd[r].start, rsvd[r].end); err != nil { - return err - } - } - } - - return nil -} - -func validateField(res *parseResult, isProto3 bool, prefix string, fld *dpb.FieldDescriptorProto) error { - scope := fmt.Sprintf("field %s%s", prefix, fld.GetName()) - - node := res.getFieldNode(fld) - if isProto3 { - if fld.GetType() == dpb.FieldDescriptorProto_TYPE_GROUP { - if err := res.errs.handleErrorWithPos(node.GetGroupKeyword().Start(), "%s: groups are not allowed in proto3", scope); err != nil { - return err - } - } else if fld.Label != nil && fld.GetLabel() == dpb.FieldDescriptorProto_LABEL_REQUIRED { - if err := res.errs.handleErrorWithPos(node.FieldLabel().Start(), "%s: label 'required' is not allowed in proto3", scope); err != nil { - return err - } - } - if index, err := findOption(res, scope, fld.Options.GetUninterpretedOption(), "default"); err != nil { - return err - } else if index >= 0 { - optNode := res.getOptionNode(fld.Options.GetUninterpretedOption()[index]) - if err := res.errs.handleErrorWithPos(optNode.GetName().Start(), "%s: default values are not allowed in proto3", scope); err != nil { - return err - } - } - } else { - if fld.Label == nil && fld.OneofIndex == nil { - if err := res.errs.handleErrorWithPos(node.FieldName().Start(), "%s: field has no label; proto2 requires explicit 'optional' label", scope); err != nil { - return err - } - } - if fld.GetExtendee() != "" && fld.Label != nil && fld.GetLabel() == dpb.FieldDescriptorProto_LABEL_REQUIRED { - if err := res.errs.handleErrorWithPos(node.FieldLabel().Start(), "%s: extension fields cannot be 'required'", scope); err != nil { - return err - } - } - } - - // finally, set any missing label to optional - if fld.Label == nil { - fld.Label = dpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum() - } - - return nil -} - -type tagRange struct { - start int32 - end int32 - node ast.RangeDeclNode -} - -type tagRanges []tagRange - -func (r tagRanges) Len() int { - return len(r) -} - -func (r tagRanges) Less(i, j int) bool { - return r[i].start < r[j].start || - (r[i].start == r[j].start && r[i].end < r[j].end) -} - -func (r tagRanges) Swap(i, j int) { - r[i], r[j] = r[j], r[i] -} diff --git a/vendor/github.com/jhump/protoreflect/desc/sourceinfo/registry.go b/vendor/github.com/jhump/protoreflect/desc/sourceinfo/registry.go index ad3bce0acac..de38e0d1e23 100644 --- a/vendor/github.com/jhump/protoreflect/desc/sourceinfo/registry.go +++ b/vendor/github.com/jhump/protoreflect/desc/sourceinfo/registry.go @@ -43,23 +43,47 @@ import ( var ( // GlobalFiles is a registry of descriptors that include source code info, if the - // file they belong to were processed with protoc-gen-gosrcinfo. + // files they belong to were processed with protoc-gen-gosrcinfo. // // If is mean to serve as a drop-in alternative to protoregistry.GlobalFiles that // can include source code info in the returned descriptors. GlobalFiles Resolver = registry{} + // GlobalTypes is a registry of descriptors that include source code info, if the + // files they belong to were processed with protoc-gen-gosrcinfo. + // + // If is mean to serve as a drop-in alternative to protoregistry.GlobalTypes that + // can include source code info in the returned descriptors. + GlobalTypes TypeResolver = registry{} + mu sync.RWMutex sourceInfoByFile = map[string]*descriptorpb.SourceCodeInfo{} fileDescriptors = map[protoreflect.FileDescriptor]protoreflect.FileDescriptor{} ) +// Resolver can resolve file names into file descriptors and also provides methods for +// resolving extensions. type Resolver interface { protodesc.Resolver protoregistry.ExtensionTypeResolver RangeExtensionsByMessage(message protoreflect.FullName, f func(protoreflect.ExtensionType) bool) } +// NB: These interfaces are far from ideal. Ideally, Resolver would have +// * EITHER been named FileResolver and not included the extension methods. +// * OR also included message methods (i.e. embed protoregistry.MessageTypeResolver). +// Now (since it's been released) we can't add the message methods to the interface as +// that's not a backwards-compatible change. So we have to introduce the new interface +// below, which is now a little confusing since it has some overlap with Resolver. + +// TypeResolver can resolve message names and URLs into message descriptors and also +// provides methods for resolving extensions. +type TypeResolver interface { + protoregistry.MessageTypeResolver + protoregistry.ExtensionTypeResolver + RangeExtensionsByMessage(message protoreflect.FullName, f func(protoreflect.ExtensionType) bool) +} + // RegisterSourceInfo registers the given source code info for the file descriptor // with the given path/name. // @@ -105,6 +129,11 @@ func SourceInfoForFile(file string) *descriptorpb.SourceCodeInfo { return sourceInfoByFile[file] } +func canWrap(d protoreflect.Descriptor) bool { + srcInfo := SourceInfoForFile(d.ParentFile().Path()) + return len(srcInfo.GetLocation()) > 0 +} + func getFile(fd protoreflect.FileDescriptor) protoreflect.FileDescriptor { if fd == nil { return nil @@ -156,6 +185,9 @@ func (r registry) FindFileByPath(path string) (protoreflect.FileDescriptor, erro func (r registry) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error) { d, err := protoregistry.GlobalFiles.FindDescriptorByName(name) + if !canWrap(d) { + return d, nil + } if err != nil { return nil, err } @@ -183,11 +215,36 @@ func (r registry) FindDescriptorByName(name protoreflect.FullName) (protoreflect } } +func (r registry) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) { + mt, err := protoregistry.GlobalTypes.FindMessageByName(message) + if err != nil { + return nil, err + } + if !canWrap(mt.Descriptor()) { + return mt, nil + } + return messageType{mt}, nil +} + +func (r registry) FindMessageByURL(url string) (protoreflect.MessageType, error) { + mt, err := protoregistry.GlobalTypes.FindMessageByURL(url) + if err != nil { + return nil, err + } + if !canWrap(mt.Descriptor()) { + return mt, nil + } + return messageType{mt}, nil +} + func (r registry) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error) { xt, err := protoregistry.GlobalTypes.FindExtensionByName(field) if err != nil { return nil, err } + if !canWrap(xt.TypeDescriptor()) { + return xt, nil + } return extensionType{xt}, nil } @@ -196,11 +253,17 @@ func (r registry) FindExtensionByNumber(message protoreflect.FullName, field pro if err != nil { return nil, err } + if !canWrap(xt.TypeDescriptor()) { + return xt, nil + } return extensionType{xt}, nil } func (r registry) RangeExtensionsByMessage(message protoreflect.FullName, fn func(protoreflect.ExtensionType) bool) { protoregistry.GlobalTypes.RangeExtensionsByMessage(message, func(xt protoreflect.ExtensionType) bool { - return fn(extensionType{xt}) + if canWrap(xt.TypeDescriptor()) { + xt = extensionType{xt} + } + return fn(xt) }) } diff --git a/vendor/github.com/jhump/protoreflect/desc/sourceinfo/wrappers.go b/vendor/github.com/jhump/protoreflect/desc/sourceinfo/wrappers.go index 134dadf4078..8cbb5bbb2f2 100644 --- a/vendor/github.com/jhump/protoreflect/desc/sourceinfo/wrappers.go +++ b/vendor/github.com/jhump/protoreflect/desc/sourceinfo/wrappers.go @@ -506,3 +506,124 @@ type extensionType struct { func (e extensionType) TypeDescriptor() protoreflect.ExtensionTypeDescriptor { return extensionDescriptor{e.ExtensionType.TypeDescriptor()} } + +type messageType struct { + protoreflect.MessageType +} + +func (m messageType) Descriptor() protoreflect.MessageDescriptor { + return messageDescriptor{m.MessageType.Descriptor()} +} + +// WrapFile wraps the given file descriptor so that it will include source +// code info that was registered with this package if the given file was +// processed with protoc-gen-gosrcinfo. Returns fd without wrapping if fd +// already contains source code info. +func WrapFile(fd protoreflect.FileDescriptor) protoreflect.FileDescriptor { + if wrapper, ok := fd.(fileDescriptor); ok { + // already wrapped + return wrapper + } + if fd.SourceLocations().Len() > 0 { + // no need to wrap since it includes source info already + return fd + } + return getFile(fd) +} + +// WrapMessage wraps the given message descriptor so that it will include source +// code info that was registered with this package if the file it is defined in +// was processed with protoc-gen-gosrcinfo. Returns md without wrapping if md's +// parent file already contains source code info. +func WrapMessage(md protoreflect.MessageDescriptor) protoreflect.MessageDescriptor { + if wrapper, ok := md.(messageDescriptor); ok { + // already wrapped + return wrapper + } + if md.ParentFile().SourceLocations().Len() > 0 { + // no need to wrap since it includes source info already + return md + } + if !canWrap(md) { + return md + } + return messageDescriptor{md} +} + +// WrapEnum wraps the given enum descriptor so that it will include source +// code info that was registered with this package if the file it is defined in +// was processed with protoc-gen-gosrcinfo. Returns ed without wrapping if ed's +// parent file already contains source code info. +func WrapEnum(ed protoreflect.EnumDescriptor) protoreflect.EnumDescriptor { + if wrapper, ok := ed.(enumDescriptor); ok { + // already wrapped + return wrapper + } + if ed.ParentFile().SourceLocations().Len() > 0 { + // no need to wrap since it includes source info already + return ed + } + if !canWrap(ed) { + return ed + } + return enumDescriptor{ed} +} + +// WrapService wraps the given service descriptor so that it will include source +// code info that was registered with this package if the file it is defined in +// was processed with protoc-gen-gosrcinfo. Returns sd without wrapping if sd's +// parent file already contains source code info. +func WrapService(sd protoreflect.ServiceDescriptor) protoreflect.ServiceDescriptor { + if wrapper, ok := sd.(serviceDescriptor); ok { + // already wrapped + return wrapper + } + if sd.ParentFile().SourceLocations().Len() > 0 { + // no need to wrap since it includes source info already + return sd + } + if !canWrap(sd) { + return sd + } + return serviceDescriptor{sd} +} + +// WrapExtensionType wraps the given extension type so that its associated +// descriptor will include source code info that was registered with this package +// if the file it is defined in was processed with protoc-gen-gosrcinfo. Returns +// xt without wrapping if the parent file of xt's descriptor already contains +// source code info. +func WrapExtensionType(xt protoreflect.ExtensionType) protoreflect.ExtensionType { + if wrapper, ok := xt.(extensionType); ok { + // already wrapped + return wrapper + } + if xt.TypeDescriptor().ParentFile().SourceLocations().Len() > 0 { + // no need to wrap since it includes source info already + return xt + } + if !canWrap(xt.TypeDescriptor()) { + return xt + } + return extensionType{xt} +} + +// WrapMessageType wraps the given message type so that its associated +// descriptor will include source code info that was registered with this package +// if the file it is defined in was processed with protoc-gen-gosrcinfo. Returns +// mt without wrapping if the parent file of mt's descriptor already contains +// source code info. +func WrapMessageType(mt protoreflect.MessageType) protoreflect.MessageType { + if wrapper, ok := mt.(messageType); ok { + // already wrapped + return wrapper + } + if mt.Descriptor().ParentFile().SourceLocations().Len() > 0 { + // no need to wrap since it includes source info already + return mt + } + if !canWrap(mt.Descriptor()) { + return mt + } + return messageType{mt} +} diff --git a/vendor/github.com/jhump/protoreflect/desc/wrap.go b/vendor/github.com/jhump/protoreflect/desc/wrap.go new file mode 100644 index 00000000000..82610a45571 --- /dev/null +++ b/vendor/github.com/jhump/protoreflect/desc/wrap.go @@ -0,0 +1,208 @@ +package desc + +import ( + "fmt" + + "github.com/bufbuild/protocompile/protoutil" + "google.golang.org/protobuf/reflect/protoreflect" +) + +// DescriptorWrapper wraps a protoreflect.Descriptor. All of the Descriptor +// implementations in this package implement this interface. This can be +// used to recover the underlying descriptor. Each descriptor type in this +// package also provides a strongly-typed form of this method, such as the +// following method for *FileDescriptor: +// +// UnwrapFile() protoreflect.FileDescriptor +type DescriptorWrapper interface { + Unwrap() protoreflect.Descriptor +} + +// WrapDescriptor wraps the given descriptor, returning a desc.Descriptor +// value that represents the same element. +func WrapDescriptor(d protoreflect.Descriptor) (Descriptor, error) { + return wrapDescriptor(d, noopCache{}) +} + +func wrapDescriptor(d protoreflect.Descriptor, cache descriptorCache) (Descriptor, error) { + switch d := d.(type) { + case protoreflect.FileDescriptor: + return wrapFile(d, cache) + case protoreflect.MessageDescriptor: + return wrapMessage(d, cache) + case protoreflect.FieldDescriptor: + return wrapField(d, cache) + case protoreflect.OneofDescriptor: + return wrapOneOf(d, cache) + case protoreflect.EnumDescriptor: + return wrapEnum(d, cache) + case protoreflect.EnumValueDescriptor: + return wrapEnumValue(d, cache) + case protoreflect.ServiceDescriptor: + return wrapService(d, cache) + case protoreflect.MethodDescriptor: + return wrapMethod(d, cache) + default: + return nil, fmt.Errorf("unknown descriptor type: %T", d) + } +} + +// WrapFiles wraps the given file descriptors, returning a slice of *desc.FileDescriptor +// values that represent the same files. +func WrapFiles(d []protoreflect.FileDescriptor) ([]*FileDescriptor, error) { + cache := mapCache{} + results := make([]*FileDescriptor, len(d)) + for i := range d { + var err error + results[i], err = wrapFile(d[i], cache) + if err != nil { + return nil, err + } + } + return results, nil +} + +// WrapFile wraps the given file descriptor, returning a *desc.FileDescriptor +// value that represents the same file. +func WrapFile(d protoreflect.FileDescriptor) (*FileDescriptor, error) { + return wrapFile(d, noopCache{}) +} + +func wrapFile(d protoreflect.FileDescriptor, cache descriptorCache) (*FileDescriptor, error) { + fdp := protoutil.ProtoFromFileDescriptor(d) + return convertFile(d, fdp, cache) +} + +// WrapMessage wraps the given message descriptor, returning a *desc.MessageDescriptor +// value that represents the same message. +func WrapMessage(d protoreflect.MessageDescriptor) (*MessageDescriptor, error) { + return wrapMessage(d, noopCache{}) +} + +func wrapMessage(d protoreflect.MessageDescriptor, cache descriptorCache) (*MessageDescriptor, error) { + parent, err := wrapDescriptor(d.Parent(), cache) + if err != nil { + return nil, err + } + switch p := parent.(type) { + case *FileDescriptor: + return p.messages[d.Index()], nil + case *MessageDescriptor: + return p.nested[d.Index()], nil + default: + return nil, fmt.Errorf("message has unexpected parent type: %T", parent) + } +} + +// WrapField wraps the given field descriptor, returning a *desc.FieldDescriptor +// value that represents the same field. +func WrapField(d protoreflect.FieldDescriptor) (*FieldDescriptor, error) { + return wrapField(d, noopCache{}) +} + +func wrapField(d protoreflect.FieldDescriptor, cache descriptorCache) (*FieldDescriptor, error) { + parent, err := wrapDescriptor(d.Parent(), cache) + if err != nil { + return nil, err + } + switch p := parent.(type) { + case *FileDescriptor: + return p.extensions[d.Index()], nil + case *MessageDescriptor: + if d.IsExtension() { + return p.extensions[d.Index()], nil + } + return p.fields[d.Index()], nil + default: + return nil, fmt.Errorf("field has unexpected parent type: %T", parent) + } +} + +// WrapOneOf wraps the given oneof descriptor, returning a *desc.OneOfDescriptor +// value that represents the same oneof. +func WrapOneOf(d protoreflect.OneofDescriptor) (*OneOfDescriptor, error) { + return wrapOneOf(d, noopCache{}) +} + +func wrapOneOf(d protoreflect.OneofDescriptor, cache descriptorCache) (*OneOfDescriptor, error) { + parent, err := wrapDescriptor(d.Parent(), cache) + if err != nil { + return nil, err + } + if p, ok := parent.(*MessageDescriptor); ok { + return p.oneOfs[d.Index()], nil + } + return nil, fmt.Errorf("oneof has unexpected parent type: %T", parent) +} + +// WrapEnum wraps the given enum descriptor, returning a *desc.EnumDescriptor +// value that represents the same enum. +func WrapEnum(d protoreflect.EnumDescriptor) (*EnumDescriptor, error) { + return wrapEnum(d, noopCache{}) +} + +func wrapEnum(d protoreflect.EnumDescriptor, cache descriptorCache) (*EnumDescriptor, error) { + parent, err := wrapDescriptor(d.Parent(), cache) + if err != nil { + return nil, err + } + switch p := parent.(type) { + case *FileDescriptor: + return p.enums[d.Index()], nil + case *MessageDescriptor: + return p.enums[d.Index()], nil + default: + return nil, fmt.Errorf("enum has unexpected parent type: %T", parent) + } +} + +// WrapEnumValue wraps the given enum value descriptor, returning a *desc.EnumValueDescriptor +// value that represents the same enum value. +func WrapEnumValue(d protoreflect.EnumValueDescriptor) (*EnumValueDescriptor, error) { + return wrapEnumValue(d, noopCache{}) +} + +func wrapEnumValue(d protoreflect.EnumValueDescriptor, cache descriptorCache) (*EnumValueDescriptor, error) { + parent, err := wrapDescriptor(d.Parent(), cache) + if err != nil { + return nil, err + } + if p, ok := parent.(*EnumDescriptor); ok { + return p.values[d.Index()], nil + } + return nil, fmt.Errorf("enum value has unexpected parent type: %T", parent) +} + +// WrapService wraps the given service descriptor, returning a *desc.ServiceDescriptor +// value that represents the same service. +func WrapService(d protoreflect.ServiceDescriptor) (*ServiceDescriptor, error) { + return wrapService(d, noopCache{}) +} + +func wrapService(d protoreflect.ServiceDescriptor, cache descriptorCache) (*ServiceDescriptor, error) { + parent, err := wrapDescriptor(d.Parent(), cache) + if err != nil { + return nil, err + } + if p, ok := parent.(*FileDescriptor); ok { + return p.services[d.Index()], nil + } + return nil, fmt.Errorf("service has unexpected parent type: %T", parent) +} + +// WrapMethod wraps the given method descriptor, returning a *desc.MethodDescriptor +// value that represents the same method. +func WrapMethod(d protoreflect.MethodDescriptor) (*MethodDescriptor, error) { + return wrapMethod(d, noopCache{}) +} + +func wrapMethod(d protoreflect.MethodDescriptor, cache descriptorCache) (*MethodDescriptor, error) { + parent, err := wrapDescriptor(d.Parent(), cache) + if err != nil { + return nil, err + } + if p, ok := parent.(*ServiceDescriptor); ok { + return p.methods[d.Index()], nil + } + return nil, fmt.Errorf("method has unexpected parent type: %T", parent) +} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/binary.go b/vendor/github.com/jhump/protoreflect/dynamic/binary.go deleted file mode 100644 index 91fd6723ab8..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/binary.go +++ /dev/null @@ -1,185 +0,0 @@ -package dynamic - -// Binary serialization and de-serialization for dynamic messages - -import ( - "fmt" - "github.com/golang/protobuf/proto" - "github.com/jhump/protoreflect/codec" - "io" -) - -// defaultDeterminism, if true, will mean that calls to Marshal will produce -// deterministic output. This is used to make the output of proto.Marshal(...) -// deterministic (since there is no way to have that convey determinism intent). -// **This is only used from tests.** -var defaultDeterminism = false - -// Marshal serializes this message to bytes, returning an error if the operation -// fails. The resulting bytes are in the standard protocol buffer binary format. -func (m *Message) Marshal() ([]byte, error) { - var b codec.Buffer - b.SetDeterministic(defaultDeterminism) - if err := m.marshal(&b); err != nil { - return nil, err - } - return b.Bytes(), nil -} - -// MarshalAppend behaves exactly the same as Marshal, except instead of allocating a -// new byte slice to marshal into, it uses the provided byte slice. The backing array -// for the returned byte slice *may* be the same as the one that was passed in, but -// it's not guaranteed as a new backing array will automatically be allocated if -// more bytes need to be written than the provided buffer has capacity for. -func (m *Message) MarshalAppend(b []byte) ([]byte, error) { - codedBuf := codec.NewBuffer(b) - codedBuf.SetDeterministic(defaultDeterminism) - if err := m.marshal(codedBuf); err != nil { - return nil, err - } - return codedBuf.Bytes(), nil -} - -// MarshalDeterministic serializes this message to bytes in a deterministic way, -// returning an error if the operation fails. This differs from Marshal in that -// map keys will be sorted before serializing to bytes. The protobuf spec does -// not define ordering for map entries, so Marshal will use standard Go map -// iteration order (which will be random). But for cases where determinism is -// more important than performance, use this method instead. -func (m *Message) MarshalDeterministic() ([]byte, error) { - var b codec.Buffer - b.SetDeterministic(true) - if err := m.marshal(&b); err != nil { - return nil, err - } - return b.Bytes(), nil -} - -// MarshalAppendDeterministic behaves exactly the same as MarshalDeterministic, -// except instead of allocating a new byte slice to marshal into, it uses the -// provided byte slice. The backing array for the returned byte slice *may* be -// the same as the one that was passed in, but it's not guaranteed as a new -// backing array will automatically be allocated if more bytes need to be written -// than the provided buffer has capacity for. -func (m *Message) MarshalAppendDeterministic(b []byte) ([]byte, error) { - codedBuf := codec.NewBuffer(b) - codedBuf.SetDeterministic(true) - if err := m.marshal(codedBuf); err != nil { - return nil, err - } - return codedBuf.Bytes(), nil -} - -func (m *Message) marshal(b *codec.Buffer) error { - if err := m.marshalKnownFields(b); err != nil { - return err - } - return m.marshalUnknownFields(b) -} - -func (m *Message) marshalKnownFields(b *codec.Buffer) error { - for _, tag := range m.knownFieldTags() { - itag := int32(tag) - val := m.values[itag] - fd := m.FindFieldDescriptor(itag) - if fd == nil { - panic(fmt.Sprintf("Couldn't find field for tag %d", itag)) - } - if err := b.EncodeFieldValue(fd, val); err != nil { - return err - } - } - return nil -} - -func (m *Message) marshalUnknownFields(b *codec.Buffer) error { - for _, tag := range m.unknownFieldTags() { - itag := int32(tag) - sl := m.unknownFields[itag] - for _, u := range sl { - if err := b.EncodeTagAndWireType(itag, u.Encoding); err != nil { - return err - } - switch u.Encoding { - case proto.WireBytes: - if err := b.EncodeRawBytes(u.Contents); err != nil { - return err - } - case proto.WireStartGroup: - _, _ = b.Write(u.Contents) - if err := b.EncodeTagAndWireType(itag, proto.WireEndGroup); err != nil { - return err - } - case proto.WireFixed32: - if err := b.EncodeFixed32(u.Value); err != nil { - return err - } - case proto.WireFixed64: - if err := b.EncodeFixed64(u.Value); err != nil { - return err - } - case proto.WireVarint: - if err := b.EncodeVarint(u.Value); err != nil { - return err - } - default: - return codec.ErrBadWireType - } - } - } - return nil -} - -// Unmarshal de-serializes the message that is present in the given bytes into -// this message. It first resets the current message. It returns an error if the -// given bytes do not contain a valid encoding of this message type. -func (m *Message) Unmarshal(b []byte) error { - m.Reset() - if err := m.UnmarshalMerge(b); err != nil { - return err - } - return m.Validate() -} - -// UnmarshalMerge de-serializes the message that is present in the given bytes -// into this message. Unlike Unmarshal, it does not first reset the message, -// instead merging the data in the given bytes into the existing data in this -// message. -func (m *Message) UnmarshalMerge(b []byte) error { - return m.unmarshal(codec.NewBuffer(b), false) -} - -func (m *Message) unmarshal(buf *codec.Buffer, isGroup bool) error { - for !buf.EOF() { - fd, val, err := buf.DecodeFieldValue(m.FindFieldDescriptor, m.mf) - if err != nil { - if err == codec.ErrWireTypeEndGroup { - if isGroup { - // finished parsing group - return nil - } - return codec.ErrBadWireType - } - return err - } - - if fd == nil { - if m.unknownFields == nil { - m.unknownFields = map[int32][]UnknownField{} - } - uv := val.(codec.UnknownField) - u := UnknownField{ - Encoding: uv.Encoding, - Value: uv.Value, - Contents: uv.Contents, - } - m.unknownFields[uv.Tag] = append(m.unknownFields[uv.Tag], u) - } else if err := mergeField(m, fd, val); err != nil { - return err - } - } - if isGroup { - return io.ErrUnexpectedEOF - } - return nil -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/doc.go b/vendor/github.com/jhump/protoreflect/dynamic/doc.go deleted file mode 100644 index 5d7f45e474e..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/doc.go +++ /dev/null @@ -1,159 +0,0 @@ -// Package dynamic provides an implementation for a dynamic protobuf message. -// -// The dynamic message is essentially a message descriptor along with a map of -// tag numbers to values. It has a broad API for interacting with the message, -// including inspection and modification. Generally, most operations have two -// forms: a regular method that panics on bad input or error and a "Try" form -// of the method that will instead return an error. -// -// A dynamic message can optionally be constructed with a MessageFactory. The -// MessageFactory has various registries that may be used by the dynamic message, -// such as during de-serialization. The message factory is "inherited" by any -// other dynamic messages created, such as nested messages that are created -// during de-serialization. Similarly, any dynamic message created using -// MessageFactory.NewMessage will be associated with that factory, which in turn -// will be used to create other messages or parse extension fields during -// de-serialization. -// -// # Field Types -// -// The types of values expected by setters and returned by getters are the -// same as protoc generates for scalar fields. For repeated fields, there are -// methods for getting and setting values at a particular index or for adding -// an element. Similarly, for map fields, there are methods for getting and -// setting values for a particular key. -// -// If you use GetField for a repeated field, it will return a copy of all -// elements as a slice []interface{}. Similarly, using GetField for a map field -// will return a copy of all mappings as a map[interface{}]interface{}. You can -// also use SetField to supply an entire slice or map for repeated or map fields. -// The slice need not be []interface{} but can actually be typed according to -// the field's expected type. For example, a repeated uint64 field can be set -// using a slice of type []uint64. -// -// Descriptors for map fields describe them as repeated fields with a nested -// message type. The nested message type is a special generated type that -// represents a single mapping: key and value pair. The dynamic message has some -// special affordances for this representation. For example, you can use -// SetField to set a map field using a slice of these entry messages. Internally, -// the slice of entries will be converted to an actual map. Similarly, you can -// use AddRepeatedField with an entry message to add (or overwrite) a mapping. -// However, you cannot use GetRepeatedField or SetRepeatedField to modify maps, -// since those take numeric index arguments which are not relevant to maps -// (since maps in Go have no defined ordering). -// -// When setting field values in dynamic messages, the type-checking is lenient -// in that it accepts any named type with the right kind. So a string field can -// be assigned to any type that is defined as a string. Enum fields require -// int32 values (or any type that is defined as an int32). -// -// Unlike normal use of numeric values in Go, values will be automatically -// widened when assigned. So, for example, an int64 field can be set using an -// int32 value since it can be safely widened without truncation or loss of -// precision. Similar goes for uint32 values being converted to uint64 and -// float32 being converted to float64. Narrowing conversions are not done, -// however. Also, unsigned values will never be automatically converted to -// signed (and vice versa), and floating point values will never be -// automatically converted to integral values (and vice versa). Since the bit -// width of int and uint fields is allowed to be platform dependent, but will -// always be less than or equal to 64, they can only be used as values for -// int64 and uint64 fields, respectively. They cannot be used to set int32 or -// uint32 fields, which includes enums fields. -// -// Fields whose type is a nested message can have values set to either other -// dynamic messages or generated messages (e.g. pointers to structs generated by -// protoc). Getting a value for such a field will return the actual type it is -// set to (e.g. either a dynamic message or a generated message). If the value -// is not set and the message uses proto2 syntax, the default message returned -// will be whatever is returned by the dynamic message's MessageFactory (if the -// dynamic message was not created with a factory, it will use the logic of the -// zero value factory). In most typical cases, it will return a dynamic message, -// but if the factory is configured with a KnownTypeRegistry, or if the field's -// type is a well-known type, it will return a zero value generated message. -// -// # Unrecognized Fields -// -// Unrecognized fields are preserved by the dynamic message when unmarshaling -// from the standard binary format. If the message's MessageFactory was -// configured with an ExtensionRegistry, it will be used to identify and parse -// extension fields for the message. -// -// Unrecognized fields can dynamically become recognized fields if the -// application attempts to retrieve an unrecognized field's value using a -// FieldDescriptor. In this case, the given FieldDescriptor is used to parse the -// unknown field and move the parsed value into the message's set of known -// fields. This behavior is most suited to the use of extensions, where an -// ExtensionRegistry is not setup with all known extensions ahead of time. But -// it can even happen for non-extension fields! Here's an example scenario where -// a non-extension field can initially be unknown and become known: -// -// 1. A dynamic message is created with a descriptor, A, and then -// de-serialized from a stream of bytes. The stream includes an -// unrecognized tag T. The message will include tag T in its unrecognized -// field set. -// 2. Another call site retrieves a newer descriptor, A', which includes a -// newly added field with tag T. -// 3. That other call site then uses a FieldDescriptor to access the value of -// the new field. This will cause the dynamic message to parse the bytes -// for the unknown tag T and store them as a known field. -// 4. Subsequent operations for tag T, including setting the field using only -// tag number or de-serializing a stream that includes tag T, will operate -// as if that tag were part of the original descriptor, A. -// -// # Compatibility -// -// In addition to implementing the proto.Message interface, the included -// Message type also provides an XXX_MessageName() method, so it can work with -// proto.MessageName. And it provides a Descriptor() method that behaves just -// like the method of the same signature in messages generated by protoc. -// Because of this, it is actually compatible with proto.Message in many (though -// not all) contexts. In particular, it is compatible with proto.Marshal and -// proto.Unmarshal for serializing and de-serializing messages. -// -// The dynamic message supports binary and text marshaling, using protobuf's -// well-defined binary format and the same text format that protoc-generated -// types use. It also supports JSON serialization/de-serialization by -// implementing the json.Marshaler and json.Unmarshaler interfaces. And dynamic -// messages can safely be used with the jsonpb package for JSON serialization -// and de-serialization. -// -// In addition to implementing the proto.Message interface and numerous related -// methods, it also provides inter-op with generated messages via conversion. -// The ConvertTo, ConvertFrom, MergeInto, and MergeFrom methods copy message -// contents from a dynamic message to a generated message and vice versa. -// -// When copying from a generated message into a dynamic message, if the -// generated message contains fields unknown to the dynamic message (e.g. not -// present in the descriptor used to create the dynamic message), these fields -// become known to the dynamic message (as per behavior described above in -// "Unrecognized Fields"). If the generated message has unrecognized fields of -// its own, including unrecognized extensions, they are preserved in the dynamic -// message. It is possible that the dynamic message knows about fields that the -// generated message did not, like if it has a different version of the -// descriptor or its MessageFactory has an ExtensionRegistry that knows about -// different extensions than were linked into the program. In this case, these -// unrecognized fields in the generated message will be known fields in the -// dynamic message. -// -// Similarly, when copying from a dynamic message into a generated message, if -// the dynamic message has unrecognized fields they can be preserved in the -// generated message (currently only for syntax proto2 since proto3 generated -// messages do not preserve unrecognized fields). If the generated message knows -// about fields that the dynamic message does not, these unrecognized fields may -// become known fields in the generated message. -// -// # Registries -// -// This package also contains a couple of registries, for managing known types -// and descriptors. -// -// The KnownTypeRegistry allows de-serialization of a dynamic message to use -// generated message types, instead of dynamic messages, for some kinds of -// nested message fields. This is particularly useful for working with proto -// messages that have special encodings as JSON (e.g. the well-known types), -// since the dynamic message does not try to handle these special cases in its -// JSON marshaling facilities. -// -// The ExtensionRegistry allows for recognizing and parsing extensions fields -// (for proto2 messages). -package dynamic diff --git a/vendor/github.com/jhump/protoreflect/dynamic/dynamic_message.go b/vendor/github.com/jhump/protoreflect/dynamic/dynamic_message.go deleted file mode 100644 index 9b049193a43..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/dynamic_message.go +++ /dev/null @@ -1,2774 +0,0 @@ -package dynamic - -import ( - "bytes" - "compress/gzip" - "errors" - "fmt" - "reflect" - "sort" - "strings" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/descriptor" - protov2 "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" - - "github.com/jhump/protoreflect/codec" - "github.com/jhump/protoreflect/desc" - "github.com/jhump/protoreflect/internal" -) - -// ErrUnknownTagNumber is an error that is returned when an operation refers -// to an unknown tag number. -var ErrUnknownTagNumber = errors.New("unknown tag number") - -// UnknownTagNumberError is the same as ErrUnknownTagNumber. -// Deprecated: use ErrUnknownTagNumber -var UnknownTagNumberError = ErrUnknownTagNumber - -// ErrUnknownFieldName is an error that is returned when an operation refers -// to an unknown field name. -var ErrUnknownFieldName = errors.New("unknown field name") - -// UnknownFieldNameError is the same as ErrUnknownFieldName. -// Deprecated: use ErrUnknownFieldName -var UnknownFieldNameError = ErrUnknownFieldName - -// ErrFieldIsNotMap is an error that is returned when map-related operations -// are attempted with fields that are not maps. -var ErrFieldIsNotMap = errors.New("field is not a map type") - -// FieldIsNotMapError is the same as ErrFieldIsNotMap. -// Deprecated: use ErrFieldIsNotMap -var FieldIsNotMapError = ErrFieldIsNotMap - -// ErrFieldIsNotRepeated is an error that is returned when repeated field -// operations are attempted with fields that are not repeated. -var ErrFieldIsNotRepeated = errors.New("field is not repeated") - -// FieldIsNotRepeatedError is the same as ErrFieldIsNotRepeated. -// Deprecated: use ErrFieldIsNotRepeated -var FieldIsNotRepeatedError = ErrFieldIsNotRepeated - -// ErrIndexOutOfRange is an error that is returned when an invalid index is -// provided when access a single element of a repeated field. -var ErrIndexOutOfRange = errors.New("index is out of range") - -// IndexOutOfRangeError is the same as ErrIndexOutOfRange. -// Deprecated: use ErrIndexOutOfRange -var IndexOutOfRangeError = ErrIndexOutOfRange - -// ErrNumericOverflow is an error returned by operations that encounter a -// numeric value that is too large, for example de-serializing a value into an -// int32 field when the value is larger that can fit into a 32-bit value. -var ErrNumericOverflow = errors.New("numeric value is out of range") - -// NumericOverflowError is the same as ErrNumericOverflow. -// Deprecated: use ErrNumericOverflow -var NumericOverflowError = ErrNumericOverflow - -var typeOfProtoMessage = reflect.TypeOf((*proto.Message)(nil)).Elem() -var typeOfDynamicMessage = reflect.TypeOf((*Message)(nil)) -var typeOfBytes = reflect.TypeOf(([]byte)(nil)) - -// Message is a dynamic protobuf message. Instead of a generated struct, -// like most protobuf messages, this is a map of field number to values and -// a message descriptor, which is used to validate the field values and -// also to de-serialize messages (from the standard binary format, as well -// as from the text format and from JSON). -type Message struct { - md *desc.MessageDescriptor - er *ExtensionRegistry - mf *MessageFactory - extraFields map[int32]*desc.FieldDescriptor - values map[int32]interface{} - unknownFields map[int32][]UnknownField -} - -// UnknownField represents a field that was parsed from the binary wire -// format for a message, but was not a recognized field number. Enough -// information is preserved so that re-serializing the message won't lose -// any of the unrecognized data. -type UnknownField struct { - // Encoding indicates how the unknown field was encoded on the wire. If it - // is proto.WireBytes or proto.WireGroupStart then Contents will be set to - // the raw bytes. If it is proto.WireTypeFixed32 then the data is in the least - // significant 32 bits of Value. Otherwise, the data is in all 64 bits of - // Value. - Encoding int8 - Contents []byte - Value uint64 -} - -// NewMessage creates a new dynamic message for the type represented by the given -// message descriptor. During de-serialization, a default MessageFactory is used to -// instantiate any nested message fields and no extension fields will be parsed. To -// use a custom MessageFactory or ExtensionRegistry, use MessageFactory.NewMessage. -func NewMessage(md *desc.MessageDescriptor) *Message { - return NewMessageWithMessageFactory(md, nil) -} - -// NewMessageWithExtensionRegistry creates a new dynamic message for the type -// represented by the given message descriptor. During de-serialization, the given -// ExtensionRegistry is used to parse extension fields and nested messages will be -// instantiated using dynamic.NewMessageFactoryWithExtensionRegistry(er). -func NewMessageWithExtensionRegistry(md *desc.MessageDescriptor, er *ExtensionRegistry) *Message { - mf := NewMessageFactoryWithExtensionRegistry(er) - return NewMessageWithMessageFactory(md, mf) -} - -// NewMessageWithMessageFactory creates a new dynamic message for the type -// represented by the given message descriptor. During de-serialization, the given -// MessageFactory is used to instantiate nested messages. -func NewMessageWithMessageFactory(md *desc.MessageDescriptor, mf *MessageFactory) *Message { - var er *ExtensionRegistry - if mf != nil { - er = mf.er - } - return &Message{ - md: md, - mf: mf, - er: er, - } -} - -// AsDynamicMessage converts the given message to a dynamic message. If the -// given message is dynamic, it is returned. Otherwise, a dynamic message is -// created using NewMessage. -func AsDynamicMessage(msg proto.Message) (*Message, error) { - return AsDynamicMessageWithMessageFactory(msg, nil) -} - -// AsDynamicMessageWithExtensionRegistry converts the given message to a dynamic -// message. If the given message is dynamic, it is returned. Otherwise, a -// dynamic message is created using NewMessageWithExtensionRegistry. -func AsDynamicMessageWithExtensionRegistry(msg proto.Message, er *ExtensionRegistry) (*Message, error) { - mf := NewMessageFactoryWithExtensionRegistry(er) - return AsDynamicMessageWithMessageFactory(msg, mf) -} - -// AsDynamicMessageWithMessageFactory converts the given message to a dynamic -// message. If the given message is dynamic, it is returned. Otherwise, a -// dynamic message is created using NewMessageWithMessageFactory. -func AsDynamicMessageWithMessageFactory(msg proto.Message, mf *MessageFactory) (*Message, error) { - if dm, ok := msg.(*Message); ok { - return dm, nil - } - md, err := desc.LoadMessageDescriptorForMessage(msg) - if err != nil { - return nil, err - } - dm := NewMessageWithMessageFactory(md, mf) - err = dm.mergeFrom(msg) - if err != nil { - return nil, err - } - return dm, nil -} - -// GetMessageDescriptor returns a descriptor for this message's type. -func (m *Message) GetMessageDescriptor() *desc.MessageDescriptor { - return m.md -} - -// GetKnownFields returns a slice of descriptors for all known fields. The -// fields will not be in any defined order. -func (m *Message) GetKnownFields() []*desc.FieldDescriptor { - if len(m.extraFields) == 0 { - return m.md.GetFields() - } - flds := make([]*desc.FieldDescriptor, len(m.md.GetFields()), len(m.md.GetFields())+len(m.extraFields)) - copy(flds, m.md.GetFields()) - for _, fld := range m.extraFields { - if !fld.IsExtension() { - flds = append(flds, fld) - } - } - return flds -} - -// GetKnownExtensions returns a slice of descriptors for all extensions known by -// the message's extension registry. The fields will not be in any defined order. -func (m *Message) GetKnownExtensions() []*desc.FieldDescriptor { - if !m.md.IsExtendable() { - return nil - } - exts := m.er.AllExtensionsForType(m.md.GetFullyQualifiedName()) - for _, fld := range m.extraFields { - if fld.IsExtension() { - exts = append(exts, fld) - } - } - return exts -} - -// GetUnknownFields returns a slice of tag numbers for all unknown fields that -// this message contains. The tags will not be in any defined order. -func (m *Message) GetUnknownFields() []int32 { - flds := make([]int32, 0, len(m.unknownFields)) - for tag := range m.unknownFields { - flds = append(flds, tag) - } - return flds -} - -// Descriptor returns the serialized form of the file descriptor in which the -// message was defined and a path to the message type therein. This mimics the -// method of the same name on message types generated by protoc. -func (m *Message) Descriptor() ([]byte, []int) { - // get encoded file descriptor - b, err := proto.Marshal(m.md.GetFile().AsProto()) - if err != nil { - panic(fmt.Sprintf("failed to get encoded descriptor for %s: %v", m.md.GetFile().GetName(), err)) - } - var zippedBytes bytes.Buffer - w := gzip.NewWriter(&zippedBytes) - if _, err := w.Write(b); err != nil { - panic(fmt.Sprintf("failed to get encoded descriptor for %s: %v", m.md.GetFile().GetName(), err)) - } - if err := w.Close(); err != nil { - panic(fmt.Sprintf("failed to get an encoded descriptor for %s: %v", m.md.GetFile().GetName(), err)) - } - - // and path to message - path := []int{} - var d desc.Descriptor - name := m.md.GetFullyQualifiedName() - for d = m.md.GetParent(); d != nil; name, d = d.GetFullyQualifiedName(), d.GetParent() { - found := false - switch d := d.(type) { - case (*desc.FileDescriptor): - for i, md := range d.GetMessageTypes() { - if md.GetFullyQualifiedName() == name { - found = true - path = append(path, i) - } - } - case (*desc.MessageDescriptor): - for i, md := range d.GetNestedMessageTypes() { - if md.GetFullyQualifiedName() == name { - found = true - path = append(path, i) - } - } - } - if !found { - panic(fmt.Sprintf("failed to compute descriptor path for %s", m.md.GetFullyQualifiedName())) - } - } - // reverse the path - i := 0 - j := len(path) - 1 - for i < j { - path[i], path[j] = path[j], path[i] - i++ - j-- - } - - return zippedBytes.Bytes(), path -} - -// XXX_MessageName returns the fully qualified name of this message's type. This -// allows dynamic messages to be used with proto.MessageName. -func (m *Message) XXX_MessageName() string { - return m.md.GetFullyQualifiedName() -} - -// FindFieldDescriptor returns a field descriptor for the given tag number. This -// searches known fields in the descriptor, known fields discovered during calls -// to GetField or SetField, and extension fields known by the message's extension -// registry. It returns nil if the tag is unknown. -func (m *Message) FindFieldDescriptor(tagNumber int32) *desc.FieldDescriptor { - fd := m.md.FindFieldByNumber(tagNumber) - if fd != nil { - return fd - } - fd = m.er.FindExtension(m.md.GetFullyQualifiedName(), tagNumber) - if fd != nil { - return fd - } - return m.extraFields[tagNumber] -} - -// FindFieldDescriptorByName returns a field descriptor for the given field -// name. This searches known fields in the descriptor, known fields discovered -// during calls to GetField or SetField, and extension fields known by the -// message's extension registry. It returns nil if the name is unknown. If the -// given name refers to an extension, it should be fully qualified and may be -// optionally enclosed in parentheses or brackets. -func (m *Message) FindFieldDescriptorByName(name string) *desc.FieldDescriptor { - if name == "" { - return nil - } - fd := m.md.FindFieldByName(name) - if fd != nil { - return fd - } - mustBeExt := false - if name[0] == '(' { - if name[len(name)-1] != ')' { - // malformed name - return nil - } - mustBeExt = true - name = name[1 : len(name)-1] - } else if name[0] == '[' { - if name[len(name)-1] != ']' { - // malformed name - return nil - } - mustBeExt = true - name = name[1 : len(name)-1] - } - fd = m.er.FindExtensionByName(m.md.GetFullyQualifiedName(), name) - if fd != nil { - return fd - } - for _, fd := range m.extraFields { - if fd.IsExtension() && name == fd.GetFullyQualifiedName() { - return fd - } else if !mustBeExt && !fd.IsExtension() && name == fd.GetName() { - return fd - } - } - - return nil -} - -// FindFieldDescriptorByJSONName returns a field descriptor for the given JSON -// name. This searches known fields in the descriptor, known fields discovered -// during calls to GetField or SetField, and extension fields known by the -// message's extension registry. If no field matches the given JSON name, it -// will fall back to searching field names (e.g. FindFieldDescriptorByName). If -// this also yields no match, nil is returned. -func (m *Message) FindFieldDescriptorByJSONName(name string) *desc.FieldDescriptor { - if name == "" { - return nil - } - fd := m.md.FindFieldByJSONName(name) - if fd != nil { - return fd - } - mustBeExt := false - if name[0] == '(' { - if name[len(name)-1] != ')' { - // malformed name - return nil - } - mustBeExt = true - name = name[1 : len(name)-1] - } else if name[0] == '[' { - if name[len(name)-1] != ']' { - // malformed name - return nil - } - mustBeExt = true - name = name[1 : len(name)-1] - } - fd = m.er.FindExtensionByJSONName(m.md.GetFullyQualifiedName(), name) - if fd != nil { - return fd - } - for _, fd := range m.extraFields { - if fd.IsExtension() && name == fd.GetFullyQualifiedJSONName() { - return fd - } else if !mustBeExt && !fd.IsExtension() && name == fd.GetJSONName() { - return fd - } - } - - // try non-JSON names - return m.FindFieldDescriptorByName(name) -} - -func (m *Message) checkField(fd *desc.FieldDescriptor) error { - return checkField(fd, m.md) -} - -func checkField(fd *desc.FieldDescriptor, md *desc.MessageDescriptor) error { - if fd.GetOwner().GetFullyQualifiedName() != md.GetFullyQualifiedName() { - return fmt.Errorf("given field, %s, is for wrong message type: %s; expecting %s", fd.GetName(), fd.GetOwner().GetFullyQualifiedName(), md.GetFullyQualifiedName()) - } - if fd.IsExtension() && !md.IsExtension(fd.GetNumber()) { - return fmt.Errorf("given field, %s, is an extension but is not in message extension range: %v", fd.GetFullyQualifiedName(), md.GetExtensionRanges()) - } - return nil -} - -// GetField returns the value for the given field descriptor. It panics if an -// error is encountered. See TryGetField. -func (m *Message) GetField(fd *desc.FieldDescriptor) interface{} { - if v, err := m.TryGetField(fd); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetField returns the value for the given field descriptor. An error is -// returned if the given field descriptor does not belong to the right message -// type. -// -// The Go type of the returned value, for scalar fields, is the same as protoc -// would generate for the field (in a non-dynamic message). The table below -// lists the scalar types and the corresponding Go types. -// -// +-------------------------+-----------+ -// | Declared Type | Go Type | -// +-------------------------+-----------+ -// | int32, sint32, sfixed32 | int32 | -// | int64, sint64, sfixed64 | int64 | -// | uint32, fixed32 | uint32 | -// | uint64, fixed64 | uint64 | -// | float | float32 | -// | double | double32 | -// | bool | bool | -// | string | string | -// | bytes | []byte | -// +-------------------------+-----------+ -// -// Values for enum fields will always be int32 values. You can use the enum -// descriptor associated with the field to lookup value names with those values. -// Values for message type fields may be an instance of the generated type *or* -// may be another *dynamic.Message that represents the type. -// -// If the given field is a map field, the returned type will be -// map[interface{}]interface{}. The actual concrete types of keys and values is -// as described above. If the given field is a (non-map) repeated field, the -// returned type is always []interface{}; the type of the actual elements is as -// described above. -// -// If this message has no value for the given field, its default value is -// returned. If the message is defined in a file with "proto3" syntax, the -// default is always the zero value for the field. The default value for map and -// repeated fields is a nil map or slice (respectively). For field's whose types -// is a message, the default value is an empty message for "proto2" syntax or a -// nil message for "proto3" syntax. Note that the in the latter case, a non-nil -// interface with a nil pointer is returned, not a nil interface. Also note that -// whether the returned value is an empty message or nil depends on if *this* -// message was defined as "proto3" syntax, not the message type referred to by -// the field's type. -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) but corresponds to an unknown field, the unknown value will be -// parsed and become known. The parsed value will be returned, or an error will -// be returned if the unknown value cannot be parsed according to the field -// descriptor's type information. -func (m *Message) TryGetField(fd *desc.FieldDescriptor) (interface{}, error) { - if err := m.checkField(fd); err != nil { - return nil, err - } - return m.getField(fd) -} - -// GetFieldByName returns the value for the field with the given name. It panics -// if an error is encountered. See TryGetFieldByName. -func (m *Message) GetFieldByName(name string) interface{} { - if v, err := m.TryGetFieldByName(name); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetFieldByName returns the value for the field with the given name. An -// error is returned if the given name is unknown. If the given name refers to -// an extension field, it should be fully qualified and optionally enclosed in -// parenthesis or brackets. -// -// If this message has no value for the given field, its default value is -// returned. (See TryGetField for more info on types and default field values.) -func (m *Message) TryGetFieldByName(name string) (interface{}, error) { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return nil, UnknownFieldNameError - } - return m.getField(fd) -} - -// GetFieldByNumber returns the value for the field with the given tag number. -// It panics if an error is encountered. See TryGetFieldByNumber. -func (m *Message) GetFieldByNumber(tagNumber int) interface{} { - if v, err := m.TryGetFieldByNumber(tagNumber); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetFieldByNumber returns the value for the field with the given tag -// number. An error is returned if the given tag is unknown. -// -// If this message has no value for the given field, its default value is -// returned. (See TryGetField for more info on types and default field values.) -func (m *Message) TryGetFieldByNumber(tagNumber int) (interface{}, error) { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return nil, UnknownTagNumberError - } - return m.getField(fd) -} - -func (m *Message) getField(fd *desc.FieldDescriptor) (interface{}, error) { - return m.doGetField(fd, false) -} - -func (m *Message) doGetField(fd *desc.FieldDescriptor, nilIfAbsent bool) (interface{}, error) { - res := m.values[fd.GetNumber()] - if res == nil { - var err error - if res, err = m.parseUnknownField(fd); err != nil { - return nil, err - } - if res == nil { - if nilIfAbsent { - return nil, nil - } else { - def := fd.GetDefaultValue() - if def != nil { - return def, nil - } - // GetDefaultValue only returns nil for message types - md := fd.GetMessageType() - if m.md.IsProto3() { - return nilMessage(md), nil - } else { - // for proto2, return default instance of message - return m.mf.NewMessage(md), nil - } - } - } - } - rt := reflect.TypeOf(res) - if rt.Kind() == reflect.Map { - // make defensive copies to prevent caller from storing illegal keys and values - m := res.(map[interface{}]interface{}) - res := map[interface{}]interface{}{} - for k, v := range m { - res[k] = v - } - return res, nil - } else if rt.Kind() == reflect.Slice && rt != typeOfBytes { - // make defensive copies to prevent caller from storing illegal elements - sl := res.([]interface{}) - res := make([]interface{}, len(sl)) - copy(res, sl) - return res, nil - } - return res, nil -} - -func nilMessage(md *desc.MessageDescriptor) interface{} { - // try to return a proper nil pointer - msgType := proto.MessageType(md.GetFullyQualifiedName()) - if msgType != nil && msgType.Implements(typeOfProtoMessage) { - return reflect.Zero(msgType).Interface().(proto.Message) - } - // fallback to nil dynamic message pointer - return (*Message)(nil) -} - -// HasField returns true if this message has a value for the given field. If the -// given field is not valid (e.g. belongs to a different message type), false is -// returned. If this message is defined in a file with "proto3" syntax, this -// will return false even if a field was explicitly assigned its zero value (the -// zero values for a field are intentionally indistinguishable from absent). -func (m *Message) HasField(fd *desc.FieldDescriptor) bool { - if err := m.checkField(fd); err != nil { - return false - } - return m.HasFieldNumber(int(fd.GetNumber())) -} - -// HasFieldName returns true if this message has a value for a field with the -// given name. If the given name is unknown, this returns false. -func (m *Message) HasFieldName(name string) bool { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return false - } - return m.HasFieldNumber(int(fd.GetNumber())) -} - -// HasFieldNumber returns true if this message has a value for a field with the -// given tag number. If the given tag is unknown, this returns false. -func (m *Message) HasFieldNumber(tagNumber int) bool { - if _, ok := m.values[int32(tagNumber)]; ok { - return true - } - _, ok := m.unknownFields[int32(tagNumber)] - return ok -} - -// SetField sets the value for the given field descriptor to the given value. It -// panics if an error is encountered. See TrySetField. -func (m *Message) SetField(fd *desc.FieldDescriptor, val interface{}) { - if err := m.TrySetField(fd, val); err != nil { - panic(err.Error()) - } -} - -// TrySetField sets the value for the given field descriptor to the given value. -// An error is returned if the given field descriptor does not belong to the -// right message type or if the given value is not a correct/compatible type for -// the given field. -// -// The Go type expected for a field is the same as TryGetField would return for -// the field. So message values can be supplied as either the correct generated -// message type or as a *dynamic.Message. -// -// Since it is cumbersome to work with dynamic messages, some concessions are -// made to simplify usage regarding types: -// -// 1. If a numeric type is provided that can be converted *without loss or -// overflow*, it is accepted. This allows for setting int64 fields using int -// or int32 values. Similarly for uint64 with uint and uint32 values and for -// float64 fields with float32 values. -// 2. The value can be a named type, as long as its underlying type is correct. -// 3. Map and repeated fields can be set using any kind of concrete map or -// slice type, as long as the values within are all of the correct type. So -// a field defined as a 'map` can be set using a -// map[string]int32, a map[string]interface{}, or even a -// map[interface{}]interface{}. -// 4. Finally, dynamic code that chooses to not treat maps as a special-case -// find that they can set map fields using a slice where each element is a -// message that matches the implicit map-entry field message type. -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) it will become known. Subsequent operations using tag numbers or -// names will be able to resolve the newly-known type. If the message has a -// value for the unknown value, it is cleared, replaced by the given known -// value. -func (m *Message) TrySetField(fd *desc.FieldDescriptor, val interface{}) error { - if err := m.checkField(fd); err != nil { - return err - } - return m.setField(fd, val) -} - -// SetFieldByName sets the value for the field with the given name to the given -// value. It panics if an error is encountered. See TrySetFieldByName. -func (m *Message) SetFieldByName(name string, val interface{}) { - if err := m.TrySetFieldByName(name, val); err != nil { - panic(err.Error()) - } -} - -// TrySetFieldByName sets the value for the field with the given name to the -// given value. An error is returned if the given name is unknown or if the -// given value has an incorrect type. If the given name refers to an extension -// field, it should be fully qualified and optionally enclosed in parenthesis or -// brackets. -// -// (See TrySetField for more info on types.) -func (m *Message) TrySetFieldByName(name string, val interface{}) error { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return UnknownFieldNameError - } - return m.setField(fd, val) -} - -// SetFieldByNumber sets the value for the field with the given tag number to -// the given value. It panics if an error is encountered. See -// TrySetFieldByNumber. -func (m *Message) SetFieldByNumber(tagNumber int, val interface{}) { - if err := m.TrySetFieldByNumber(tagNumber, val); err != nil { - panic(err.Error()) - } -} - -// TrySetFieldByNumber sets the value for the field with the given tag number to -// the given value. An error is returned if the given tag is unknown or if the -// given value has an incorrect type. -// -// (See TrySetField for more info on types.) -func (m *Message) TrySetFieldByNumber(tagNumber int, val interface{}) error { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return UnknownTagNumberError - } - return m.setField(fd, val) -} - -func (m *Message) setField(fd *desc.FieldDescriptor, val interface{}) error { - var err error - if val, err = validFieldValue(fd, val); err != nil { - return err - } - m.internalSetField(fd, val) - return nil -} - -func (m *Message) internalSetField(fd *desc.FieldDescriptor, val interface{}) { - if fd.IsRepeated() { - // Unset fields and zero-length fields are indistinguishable, in both - // proto2 and proto3 syntax - if reflect.ValueOf(val).Len() == 0 { - if m.values != nil { - delete(m.values, fd.GetNumber()) - } - return - } - } else if m.md.IsProto3() && fd.GetOneOf() == nil { - // proto3 considers fields that are set to their zero value as unset - // (we already handled repeated fields above) - var equal bool - if b, ok := val.([]byte); ok { - // can't compare slices, so we have to special-case []byte values - equal = ok && bytes.Equal(b, fd.GetDefaultValue().([]byte)) - } else { - defVal := fd.GetDefaultValue() - equal = defVal == val - if !equal && defVal == nil { - // above just checks if value is the nil interface, - // but we should also test if the given value is a - // nil pointer - rv := reflect.ValueOf(val) - if rv.Kind() == reflect.Ptr && rv.IsNil() { - equal = true - } - } - } - if equal { - if m.values != nil { - delete(m.values, fd.GetNumber()) - } - return - } - } - if m.values == nil { - m.values = map[int32]interface{}{} - } - m.values[fd.GetNumber()] = val - // if this field is part of a one-of, make sure all other one-of choices are cleared - od := fd.GetOneOf() - if od != nil { - for _, other := range od.GetChoices() { - if other.GetNumber() != fd.GetNumber() { - delete(m.values, other.GetNumber()) - } - } - } - // also clear any unknown fields - if m.unknownFields != nil { - delete(m.unknownFields, fd.GetNumber()) - } - // and add this field if it was previously unknown - if existing := m.FindFieldDescriptor(fd.GetNumber()); existing == nil { - m.addField(fd) - } -} - -func (m *Message) addField(fd *desc.FieldDescriptor) { - if m.extraFields == nil { - m.extraFields = map[int32]*desc.FieldDescriptor{} - } - m.extraFields[fd.GetNumber()] = fd -} - -// ClearField removes any value for the given field. It panics if an error is -// encountered. See TryClearField. -func (m *Message) ClearField(fd *desc.FieldDescriptor) { - if err := m.TryClearField(fd); err != nil { - panic(err.Error()) - } -} - -// TryClearField removes any value for the given field. An error is returned if -// the given field descriptor does not belong to the right message type. -func (m *Message) TryClearField(fd *desc.FieldDescriptor) error { - if err := m.checkField(fd); err != nil { - return err - } - m.clearField(fd) - return nil -} - -// ClearFieldByName removes any value for the field with the given name. It -// panics if an error is encountered. See TryClearFieldByName. -func (m *Message) ClearFieldByName(name string) { - if err := m.TryClearFieldByName(name); err != nil { - panic(err.Error()) - } -} - -// TryClearFieldByName removes any value for the field with the given name. An -// error is returned if the given name is unknown. If the given name refers to -// an extension field, it should be fully qualified and optionally enclosed in -// parenthesis or brackets. -func (m *Message) TryClearFieldByName(name string) error { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return UnknownFieldNameError - } - m.clearField(fd) - return nil -} - -// ClearFieldByNumber removes any value for the field with the given tag number. -// It panics if an error is encountered. See TryClearFieldByNumber. -func (m *Message) ClearFieldByNumber(tagNumber int) { - if err := m.TryClearFieldByNumber(tagNumber); err != nil { - panic(err.Error()) - } -} - -// TryClearFieldByNumber removes any value for the field with the given tag -// number. An error is returned if the given tag is unknown. -func (m *Message) TryClearFieldByNumber(tagNumber int) error { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return UnknownTagNumberError - } - m.clearField(fd) - return nil -} - -func (m *Message) clearField(fd *desc.FieldDescriptor) { - // clear value - if m.values != nil { - delete(m.values, fd.GetNumber()) - } - // also clear any unknown fields - if m.unknownFields != nil { - delete(m.unknownFields, fd.GetNumber()) - } - // and add this field if it was previously unknown - if existing := m.FindFieldDescriptor(fd.GetNumber()); existing == nil { - m.addField(fd) - } -} - -// GetOneOfField returns which of the given one-of's fields is set and the -// corresponding value. It panics if an error is encountered. See -// TryGetOneOfField. -func (m *Message) GetOneOfField(od *desc.OneOfDescriptor) (*desc.FieldDescriptor, interface{}) { - if fd, val, err := m.TryGetOneOfField(od); err != nil { - panic(err.Error()) - } else { - return fd, val - } -} - -// TryGetOneOfField returns which of the given one-of's fields is set and the -// corresponding value. An error is returned if the given one-of belongs to the -// wrong message type. If the given one-of has no field set, this method will -// return nil, nil. -// -// The type of the value, if one is set, is the same as would be returned by -// TryGetField using the returned field descriptor. -// -// Like with TryGetField, if the given one-of contains any fields that are not -// known (e.g. not present in this message's descriptor), they will become known -// and any unknown value will be parsed (and become a known value on success). -func (m *Message) TryGetOneOfField(od *desc.OneOfDescriptor) (*desc.FieldDescriptor, interface{}, error) { - if od.GetOwner().GetFullyQualifiedName() != m.md.GetFullyQualifiedName() { - return nil, nil, fmt.Errorf("given one-of, %s, is for wrong message type: %s; expecting %s", od.GetName(), od.GetOwner().GetFullyQualifiedName(), m.md.GetFullyQualifiedName()) - } - for _, fd := range od.GetChoices() { - val, err := m.doGetField(fd, true) - if err != nil { - return nil, nil, err - } - if val != nil { - return fd, val, nil - } - } - return nil, nil, nil -} - -// ClearOneOfField removes any value for any of the given one-of's fields. It -// panics if an error is encountered. See TryClearOneOfField. -func (m *Message) ClearOneOfField(od *desc.OneOfDescriptor) { - if err := m.TryClearOneOfField(od); err != nil { - panic(err.Error()) - } -} - -// TryClearOneOfField removes any value for any of the given one-of's fields. An -// error is returned if the given one-of descriptor does not belong to the right -// message type. -func (m *Message) TryClearOneOfField(od *desc.OneOfDescriptor) error { - if od.GetOwner().GetFullyQualifiedName() != m.md.GetFullyQualifiedName() { - return fmt.Errorf("given one-of, %s, is for wrong message type: %s; expecting %s", od.GetName(), od.GetOwner().GetFullyQualifiedName(), m.md.GetFullyQualifiedName()) - } - for _, fd := range od.GetChoices() { - m.clearField(fd) - } - return nil -} - -// GetMapField returns the value for the given map field descriptor and given -// key. It panics if an error is encountered. See TryGetMapField. -func (m *Message) GetMapField(fd *desc.FieldDescriptor, key interface{}) interface{} { - if v, err := m.TryGetMapField(fd, key); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetMapField returns the value for the given map field descriptor and given -// key. An error is returned if the given field descriptor does not belong to -// the right message type or if it is not a map field. -// -// If the map field does not contain the requested key, this method returns -// nil, nil. The Go type of the value returned mirrors the type that protoc -// would generate for the field. (See TryGetField for more details on types). -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) but corresponds to an unknown field, the unknown value will be -// parsed and become known. The parsed value will be searched for the requested -// key and any value returned. An error will be returned if the unknown value -// cannot be parsed according to the field descriptor's type information. -func (m *Message) TryGetMapField(fd *desc.FieldDescriptor, key interface{}) (interface{}, error) { - if err := m.checkField(fd); err != nil { - return nil, err - } - return m.getMapField(fd, key) -} - -// GetMapFieldByName returns the value for the map field with the given name and -// given key. It panics if an error is encountered. See TryGetMapFieldByName. -func (m *Message) GetMapFieldByName(name string, key interface{}) interface{} { - if v, err := m.TryGetMapFieldByName(name, key); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetMapFieldByName returns the value for the map field with the given name -// and given key. An error is returned if the given name is unknown or if it -// names a field that is not a map field. -// -// If this message has no value for the given field or the value has no value -// for the requested key, then this method returns nil, nil. -// -// (See TryGetField for more info on types.) -func (m *Message) TryGetMapFieldByName(name string, key interface{}) (interface{}, error) { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return nil, UnknownFieldNameError - } - return m.getMapField(fd, key) -} - -// GetMapFieldByNumber returns the value for the map field with the given tag -// number and given key. It panics if an error is encountered. See -// TryGetMapFieldByNumber. -func (m *Message) GetMapFieldByNumber(tagNumber int, key interface{}) interface{} { - if v, err := m.TryGetMapFieldByNumber(tagNumber, key); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetMapFieldByNumber returns the value for the map field with the given tag -// number and given key. An error is returned if the given tag is unknown or if -// it indicates a field that is not a map field. -// -// If this message has no value for the given field or the value has no value -// for the requested key, then this method returns nil, nil. -// -// (See TryGetField for more info on types.) -func (m *Message) TryGetMapFieldByNumber(tagNumber int, key interface{}) (interface{}, error) { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return nil, UnknownTagNumberError - } - return m.getMapField(fd, key) -} - -func (m *Message) getMapField(fd *desc.FieldDescriptor, key interface{}) (interface{}, error) { - if !fd.IsMap() { - return nil, FieldIsNotMapError - } - kfd := fd.GetMessageType().GetFields()[0] - ki, err := validElementFieldValue(kfd, key, false) - if err != nil { - return nil, err - } - mp := m.values[fd.GetNumber()] - if mp == nil { - if mp, err = m.parseUnknownField(fd); err != nil { - return nil, err - } else if mp == nil { - return nil, nil - } - } - return mp.(map[interface{}]interface{})[ki], nil -} - -// ForEachMapFieldEntry executes the given function for each entry in the map -// value for the given field descriptor. It stops iteration if the function -// returns false. It panics if an error is encountered. See -// TryForEachMapFieldEntry. -func (m *Message) ForEachMapFieldEntry(fd *desc.FieldDescriptor, fn func(key, val interface{}) bool) { - if err := m.TryForEachMapFieldEntry(fd, fn); err != nil { - panic(err.Error()) - } -} - -// TryForEachMapFieldEntry executes the given function for each entry in the map -// value for the given field descriptor. An error is returned if the given field -// descriptor does not belong to the right message type or if it is not a map -// field. -// -// Iteration ends either when all entries have been examined or when the given -// function returns false. So the function is expected to return true for normal -// iteration and false to break out. If this message has no value for the given -// field, it returns without invoking the given function. -// -// The Go type of the key and value supplied to the function mirrors the type -// that protoc would generate for the field. (See TryGetField for more details -// on types). -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) but corresponds to an unknown field, the unknown value will be -// parsed and become known. The parsed value will be searched for the requested -// key and any value returned. An error will be returned if the unknown value -// cannot be parsed according to the field descriptor's type information. -func (m *Message) TryForEachMapFieldEntry(fd *desc.FieldDescriptor, fn func(key, val interface{}) bool) error { - if err := m.checkField(fd); err != nil { - return err - } - return m.forEachMapFieldEntry(fd, fn) -} - -// ForEachMapFieldEntryByName executes the given function for each entry in the -// map value for the field with the given name. It stops iteration if the -// function returns false. It panics if an error is encountered. See -// TryForEachMapFieldEntryByName. -func (m *Message) ForEachMapFieldEntryByName(name string, fn func(key, val interface{}) bool) { - if err := m.TryForEachMapFieldEntryByName(name, fn); err != nil { - panic(err.Error()) - } -} - -// TryForEachMapFieldEntryByName executes the given function for each entry in -// the map value for the field with the given name. It stops iteration if the -// function returns false. An error is returned if the given name is unknown or -// if it names a field that is not a map field. -// -// If this message has no value for the given field, it returns without ever -// invoking the given function. -// -// (See TryGetField for more info on types supplied to the function.) -func (m *Message) TryForEachMapFieldEntryByName(name string, fn func(key, val interface{}) bool) error { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return UnknownFieldNameError - } - return m.forEachMapFieldEntry(fd, fn) -} - -// ForEachMapFieldEntryByNumber executes the given function for each entry in -// the map value for the field with the given tag number. It stops iteration if -// the function returns false. It panics if an error is encountered. See -// TryForEachMapFieldEntryByNumber. -func (m *Message) ForEachMapFieldEntryByNumber(tagNumber int, fn func(key, val interface{}) bool) { - if err := m.TryForEachMapFieldEntryByNumber(tagNumber, fn); err != nil { - panic(err.Error()) - } -} - -// TryForEachMapFieldEntryByNumber executes the given function for each entry in -// the map value for the field with the given tag number. It stops iteration if -// the function returns false. An error is returned if the given tag is unknown -// or if it indicates a field that is not a map field. -// -// If this message has no value for the given field, it returns without ever -// invoking the given function. -// -// (See TryGetField for more info on types supplied to the function.) -func (m *Message) TryForEachMapFieldEntryByNumber(tagNumber int, fn func(key, val interface{}) bool) error { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return UnknownTagNumberError - } - return m.forEachMapFieldEntry(fd, fn) -} - -func (m *Message) forEachMapFieldEntry(fd *desc.FieldDescriptor, fn func(key, val interface{}) bool) error { - if !fd.IsMap() { - return FieldIsNotMapError - } - mp := m.values[fd.GetNumber()] - if mp == nil { - if mp, err := m.parseUnknownField(fd); err != nil { - return err - } else if mp == nil { - return nil - } - } - for k, v := range mp.(map[interface{}]interface{}) { - if !fn(k, v) { - break - } - } - return nil -} - -// PutMapField sets the value for the given map field descriptor and given key -// to the given value. It panics if an error is encountered. See TryPutMapField. -func (m *Message) PutMapField(fd *desc.FieldDescriptor, key interface{}, val interface{}) { - if err := m.TryPutMapField(fd, key, val); err != nil { - panic(err.Error()) - } -} - -// TryPutMapField sets the value for the given map field descriptor and given -// key to the given value. An error is returned if the given field descriptor -// does not belong to the right message type, if the given field is not a map -// field, or if the given value is not a correct/compatible type for the given -// field. -// -// The Go type expected for a field is the same as required by TrySetField for -// a field with the same type as the map's value type. -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) it will become known. Subsequent operations using tag numbers or -// names will be able to resolve the newly-known type. If the message has a -// value for the unknown value, it is cleared, replaced by the given known -// value. -func (m *Message) TryPutMapField(fd *desc.FieldDescriptor, key interface{}, val interface{}) error { - if err := m.checkField(fd); err != nil { - return err - } - return m.putMapField(fd, key, val) -} - -// PutMapFieldByName sets the value for the map field with the given name and -// given key to the given value. It panics if an error is encountered. See -// TryPutMapFieldByName. -func (m *Message) PutMapFieldByName(name string, key interface{}, val interface{}) { - if err := m.TryPutMapFieldByName(name, key, val); err != nil { - panic(err.Error()) - } -} - -// TryPutMapFieldByName sets the value for the map field with the given name and -// the given key to the given value. An error is returned if the given name is -// unknown, if it names a field that is not a map, or if the given value has an -// incorrect type. -// -// (See TrySetField for more info on types.) -func (m *Message) TryPutMapFieldByName(name string, key interface{}, val interface{}) error { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return UnknownFieldNameError - } - return m.putMapField(fd, key, val) -} - -// PutMapFieldByNumber sets the value for the map field with the given tag -// number and given key to the given value. It panics if an error is -// encountered. See TryPutMapFieldByNumber. -func (m *Message) PutMapFieldByNumber(tagNumber int, key interface{}, val interface{}) { - if err := m.TryPutMapFieldByNumber(tagNumber, key, val); err != nil { - panic(err.Error()) - } -} - -// TryPutMapFieldByNumber sets the value for the map field with the given tag -// number and the given key to the given value. An error is returned if the -// given tag is unknown, if it indicates a field that is not a map, or if the -// given value has an incorrect type. -// -// (See TrySetField for more info on types.) -func (m *Message) TryPutMapFieldByNumber(tagNumber int, key interface{}, val interface{}) error { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return UnknownTagNumberError - } - return m.putMapField(fd, key, val) -} - -func (m *Message) putMapField(fd *desc.FieldDescriptor, key interface{}, val interface{}) error { - if !fd.IsMap() { - return FieldIsNotMapError - } - kfd := fd.GetMessageType().GetFields()[0] - ki, err := validElementFieldValue(kfd, key, false) - if err != nil { - return err - } - vfd := fd.GetMessageType().GetFields()[1] - vi, err := validElementFieldValue(vfd, val, true) - if err != nil { - return err - } - mp := m.values[fd.GetNumber()] - if mp == nil { - if mp, err = m.parseUnknownField(fd); err != nil { - return err - } else if mp == nil { - m.internalSetField(fd, map[interface{}]interface{}{ki: vi}) - return nil - } - } - mp.(map[interface{}]interface{})[ki] = vi - return nil -} - -// RemoveMapField changes the value for the given field descriptor by removing -// any value associated with the given key. It panics if an error is -// encountered. See TryRemoveMapField. -func (m *Message) RemoveMapField(fd *desc.FieldDescriptor, key interface{}) { - if err := m.TryRemoveMapField(fd, key); err != nil { - panic(err.Error()) - } -} - -// TryRemoveMapField changes the value for the given field descriptor by -// removing any value associated with the given key. An error is returned if the -// given field descriptor does not belong to the right message type or if the -// given field is not a map field. -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) it will become known. Subsequent operations using tag numbers or -// names will be able to resolve the newly-known type. If the message has a -// value for the unknown value, it is parsed and any value for the given key -// removed. -func (m *Message) TryRemoveMapField(fd *desc.FieldDescriptor, key interface{}) error { - if err := m.checkField(fd); err != nil { - return err - } - return m.removeMapField(fd, key) -} - -// RemoveMapFieldByName changes the value for the field with the given name by -// removing any value associated with the given key. It panics if an error is -// encountered. See TryRemoveMapFieldByName. -func (m *Message) RemoveMapFieldByName(name string, key interface{}) { - if err := m.TryRemoveMapFieldByName(name, key); err != nil { - panic(err.Error()) - } -} - -// TryRemoveMapFieldByName changes the value for the field with the given name -// by removing any value associated with the given key. An error is returned if -// the given name is unknown or if it names a field that is not a map. -func (m *Message) TryRemoveMapFieldByName(name string, key interface{}) error { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return UnknownFieldNameError - } - return m.removeMapField(fd, key) -} - -// RemoveMapFieldByNumber changes the value for the field with the given tag -// number by removing any value associated with the given key. It panics if an -// error is encountered. See TryRemoveMapFieldByNumber. -func (m *Message) RemoveMapFieldByNumber(tagNumber int, key interface{}) { - if err := m.TryRemoveMapFieldByNumber(tagNumber, key); err != nil { - panic(err.Error()) - } -} - -// TryRemoveMapFieldByNumber changes the value for the field with the given tag -// number by removing any value associated with the given key. An error is -// returned if the given tag is unknown or if it indicates a field that is not -// a map. -func (m *Message) TryRemoveMapFieldByNumber(tagNumber int, key interface{}) error { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return UnknownTagNumberError - } - return m.removeMapField(fd, key) -} - -func (m *Message) removeMapField(fd *desc.FieldDescriptor, key interface{}) error { - if !fd.IsMap() { - return FieldIsNotMapError - } - kfd := fd.GetMessageType().GetFields()[0] - ki, err := validElementFieldValue(kfd, key, false) - if err != nil { - return err - } - mp := m.values[fd.GetNumber()] - if mp == nil { - if mp, err = m.parseUnknownField(fd); err != nil { - return err - } else if mp == nil { - return nil - } - } - res := mp.(map[interface{}]interface{}) - delete(res, ki) - if len(res) == 0 { - delete(m.values, fd.GetNumber()) - } - return nil -} - -// FieldLength returns the number of elements in this message for the given -// field descriptor. It panics if an error is encountered. See TryFieldLength. -func (m *Message) FieldLength(fd *desc.FieldDescriptor) int { - l, err := m.TryFieldLength(fd) - if err != nil { - panic(err.Error()) - } - return l -} - -// TryFieldLength returns the number of elements in this message for the given -// field descriptor. An error is returned if the given field descriptor does not -// belong to the right message type or if it is neither a map field nor a -// repeated field. -func (m *Message) TryFieldLength(fd *desc.FieldDescriptor) (int, error) { - if err := m.checkField(fd); err != nil { - return 0, err - } - return m.fieldLength(fd) -} - -// FieldLengthByName returns the number of elements in this message for the -// field with the given name. It panics if an error is encountered. See -// TryFieldLengthByName. -func (m *Message) FieldLengthByName(name string) int { - l, err := m.TryFieldLengthByName(name) - if err != nil { - panic(err.Error()) - } - return l -} - -// TryFieldLengthByName returns the number of elements in this message for the -// field with the given name. An error is returned if the given name is unknown -// or if the named field is neither a map field nor a repeated field. -func (m *Message) TryFieldLengthByName(name string) (int, error) { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return 0, UnknownFieldNameError - } - return m.fieldLength(fd) -} - -// FieldLengthByNumber returns the number of elements in this message for the -// field with the given tag number. It panics if an error is encountered. See -// TryFieldLengthByNumber. -func (m *Message) FieldLengthByNumber(tagNumber int32) int { - l, err := m.TryFieldLengthByNumber(tagNumber) - if err != nil { - panic(err.Error()) - } - return l -} - -// TryFieldLengthByNumber returns the number of elements in this message for the -// field with the given tag number. An error is returned if the given tag is -// unknown or if the named field is neither a map field nor a repeated field. -func (m *Message) TryFieldLengthByNumber(tagNumber int32) (int, error) { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return 0, UnknownTagNumberError - } - return m.fieldLength(fd) -} - -func (m *Message) fieldLength(fd *desc.FieldDescriptor) (int, error) { - if !fd.IsRepeated() { - return 0, FieldIsNotRepeatedError - } - val := m.values[fd.GetNumber()] - if val == nil { - var err error - if val, err = m.parseUnknownField(fd); err != nil { - return 0, err - } else if val == nil { - return 0, nil - } - } - if sl, ok := val.([]interface{}); ok { - return len(sl), nil - } else if mp, ok := val.(map[interface{}]interface{}); ok { - return len(mp), nil - } - return 0, nil -} - -// GetRepeatedField returns the value for the given repeated field descriptor at -// the given index. It panics if an error is encountered. See -// TryGetRepeatedField. -func (m *Message) GetRepeatedField(fd *desc.FieldDescriptor, index int) interface{} { - if v, err := m.TryGetRepeatedField(fd, index); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetRepeatedField returns the value for the given repeated field descriptor -// at the given index. An error is returned if the given field descriptor does -// not belong to the right message type, if it is not a repeated field, or if -// the given index is out of range (less than zero or greater than or equal to -// the length of the repeated field). Also, even though map fields technically -// are repeated fields, if the given field is a map field an error will result: -// map representation does not lend itself to random access by index. -// -// The Go type of the value returned mirrors the type that protoc would generate -// for the field's element type. (See TryGetField for more details on types). -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) but corresponds to an unknown field, the unknown value will be -// parsed and become known. The value at the given index in the parsed value -// will be returned. An error will be returned if the unknown value cannot be -// parsed according to the field descriptor's type information. -func (m *Message) TryGetRepeatedField(fd *desc.FieldDescriptor, index int) (interface{}, error) { - if index < 0 { - return nil, IndexOutOfRangeError - } - if err := m.checkField(fd); err != nil { - return nil, err - } - return m.getRepeatedField(fd, index) -} - -// GetRepeatedFieldByName returns the value for the repeated field with the -// given name at the given index. It panics if an error is encountered. See -// TryGetRepeatedFieldByName. -func (m *Message) GetRepeatedFieldByName(name string, index int) interface{} { - if v, err := m.TryGetRepeatedFieldByName(name, index); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetRepeatedFieldByName returns the value for the repeated field with the -// given name at the given index. An error is returned if the given name is -// unknown, if it names a field that is not a repeated field (or is a map -// field), or if the given index is out of range (less than zero or greater -// than or equal to the length of the repeated field). -// -// (See TryGetField for more info on types.) -func (m *Message) TryGetRepeatedFieldByName(name string, index int) (interface{}, error) { - if index < 0 { - return nil, IndexOutOfRangeError - } - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return nil, UnknownFieldNameError - } - return m.getRepeatedField(fd, index) -} - -// GetRepeatedFieldByNumber returns the value for the repeated field with the -// given tag number at the given index. It panics if an error is encountered. -// See TryGetRepeatedFieldByNumber. -func (m *Message) GetRepeatedFieldByNumber(tagNumber int, index int) interface{} { - if v, err := m.TryGetRepeatedFieldByNumber(tagNumber, index); err != nil { - panic(err.Error()) - } else { - return v - } -} - -// TryGetRepeatedFieldByNumber returns the value for the repeated field with the -// given tag number at the given index. An error is returned if the given tag is -// unknown, if it indicates a field that is not a repeated field (or is a map -// field), or if the given index is out of range (less than zero or greater than -// or equal to the length of the repeated field). -// -// (See TryGetField for more info on types.) -func (m *Message) TryGetRepeatedFieldByNumber(tagNumber int, index int) (interface{}, error) { - if index < 0 { - return nil, IndexOutOfRangeError - } - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return nil, UnknownTagNumberError - } - return m.getRepeatedField(fd, index) -} - -func (m *Message) getRepeatedField(fd *desc.FieldDescriptor, index int) (interface{}, error) { - if fd.IsMap() || !fd.IsRepeated() { - return nil, FieldIsNotRepeatedError - } - sl := m.values[fd.GetNumber()] - if sl == nil { - var err error - if sl, err = m.parseUnknownField(fd); err != nil { - return nil, err - } else if sl == nil { - return nil, IndexOutOfRangeError - } - } - res := sl.([]interface{}) - if index >= len(res) { - return nil, IndexOutOfRangeError - } - return res[index], nil -} - -// AddRepeatedField appends the given value to the given repeated field. It -// panics if an error is encountered. See TryAddRepeatedField. -func (m *Message) AddRepeatedField(fd *desc.FieldDescriptor, val interface{}) { - if err := m.TryAddRepeatedField(fd, val); err != nil { - panic(err.Error()) - } -} - -// TryAddRepeatedField appends the given value to the given repeated field. An -// error is returned if the given field descriptor does not belong to the right -// message type, if the given field is not repeated, or if the given value is -// not a correct/compatible type for the given field. If the given field is a -// map field, the call will succeed if the given value is an instance of the -// map's entry message type. -// -// The Go type expected for a field is the same as required by TrySetField for -// a non-repeated field of the same type. -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) it will become known. Subsequent operations using tag numbers or -// names will be able to resolve the newly-known type. If the message has a -// value for the unknown value, it is parsed and the given value is appended to -// it. -func (m *Message) TryAddRepeatedField(fd *desc.FieldDescriptor, val interface{}) error { - if err := m.checkField(fd); err != nil { - return err - } - return m.addRepeatedField(fd, val) -} - -// AddRepeatedFieldByName appends the given value to the repeated field with the -// given name. It panics if an error is encountered. See -// TryAddRepeatedFieldByName. -func (m *Message) AddRepeatedFieldByName(name string, val interface{}) { - if err := m.TryAddRepeatedFieldByName(name, val); err != nil { - panic(err.Error()) - } -} - -// TryAddRepeatedFieldByName appends the given value to the repeated field with -// the given name. An error is returned if the given name is unknown, if it -// names a field that is not repeated, or if the given value has an incorrect -// type. -// -// (See TrySetField for more info on types.) -func (m *Message) TryAddRepeatedFieldByName(name string, val interface{}) error { - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return UnknownFieldNameError - } - return m.addRepeatedField(fd, val) -} - -// AddRepeatedFieldByNumber appends the given value to the repeated field with -// the given tag number. It panics if an error is encountered. See -// TryAddRepeatedFieldByNumber. -func (m *Message) AddRepeatedFieldByNumber(tagNumber int, val interface{}) { - if err := m.TryAddRepeatedFieldByNumber(tagNumber, val); err != nil { - panic(err.Error()) - } -} - -// TryAddRepeatedFieldByNumber appends the given value to the repeated field -// with the given tag number. An error is returned if the given tag is unknown, -// if it indicates a field that is not repeated, or if the given value has an -// incorrect type. -// -// (See TrySetField for more info on types.) -func (m *Message) TryAddRepeatedFieldByNumber(tagNumber int, val interface{}) error { - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return UnknownTagNumberError - } - return m.addRepeatedField(fd, val) -} - -func (m *Message) addRepeatedField(fd *desc.FieldDescriptor, val interface{}) error { - if !fd.IsRepeated() { - return FieldIsNotRepeatedError - } - val, err := validElementFieldValue(fd, val, false) - if err != nil { - return err - } - - if fd.IsMap() { - // We're lenient. Just as we allow setting a map field to a slice of entry messages, we also allow - // adding entries one at a time (as if the field were a normal repeated field). - msg := val.(proto.Message) - dm, err := asDynamicMessage(msg, fd.GetMessageType(), m.mf) - if err != nil { - return err - } - k, err := dm.TryGetFieldByNumber(1) - if err != nil { - return err - } - v, err := dm.TryGetFieldByNumber(2) - if err != nil { - return err - } - return m.putMapField(fd, k, v) - } - - sl := m.values[fd.GetNumber()] - if sl == nil { - if sl, err = m.parseUnknownField(fd); err != nil { - return err - } else if sl == nil { - sl = []interface{}{} - } - } - res := sl.([]interface{}) - res = append(res, val) - m.internalSetField(fd, res) - return nil -} - -// SetRepeatedField sets the value for the given repeated field descriptor and -// given index to the given value. It panics if an error is encountered. See -// SetRepeatedField. -func (m *Message) SetRepeatedField(fd *desc.FieldDescriptor, index int, val interface{}) { - if err := m.TrySetRepeatedField(fd, index, val); err != nil { - panic(err.Error()) - } -} - -// TrySetRepeatedField sets the value for the given repeated field descriptor -// and given index to the given value. An error is returned if the given field -// descriptor does not belong to the right message type, if the given field is -// not repeated, or if the given value is not a correct/compatible type for the -// given field. Also, even though map fields technically are repeated fields, if -// the given field is a map field an error will result: map representation does -// not lend itself to random access by index. -// -// The Go type expected for a field is the same as required by TrySetField for -// a non-repeated field of the same type. -// -// If the given field descriptor is not known (e.g. not present in the message -// descriptor) it will become known. Subsequent operations using tag numbers or -// names will be able to resolve the newly-known type. If the message has a -// value for the unknown value, it is parsed and the element at the given index -// is replaced with the given value. -func (m *Message) TrySetRepeatedField(fd *desc.FieldDescriptor, index int, val interface{}) error { - if index < 0 { - return IndexOutOfRangeError - } - if err := m.checkField(fd); err != nil { - return err - } - return m.setRepeatedField(fd, index, val) -} - -// SetRepeatedFieldByName sets the value for the repeated field with the given -// name and given index to the given value. It panics if an error is -// encountered. See TrySetRepeatedFieldByName. -func (m *Message) SetRepeatedFieldByName(name string, index int, val interface{}) { - if err := m.TrySetRepeatedFieldByName(name, index, val); err != nil { - panic(err.Error()) - } -} - -// TrySetRepeatedFieldByName sets the value for the repeated field with the -// given name and the given index to the given value. An error is returned if -// the given name is unknown, if it names a field that is not repeated (or is a -// map field), or if the given value has an incorrect type. -// -// (See TrySetField for more info on types.) -func (m *Message) TrySetRepeatedFieldByName(name string, index int, val interface{}) error { - if index < 0 { - return IndexOutOfRangeError - } - fd := m.FindFieldDescriptorByName(name) - if fd == nil { - return UnknownFieldNameError - } - return m.setRepeatedField(fd, index, val) -} - -// SetRepeatedFieldByNumber sets the value for the repeated field with the given -// tag number and given index to the given value. It panics if an error is -// encountered. See TrySetRepeatedFieldByNumber. -func (m *Message) SetRepeatedFieldByNumber(tagNumber int, index int, val interface{}) { - if err := m.TrySetRepeatedFieldByNumber(tagNumber, index, val); err != nil { - panic(err.Error()) - } -} - -// TrySetRepeatedFieldByNumber sets the value for the repeated field with the -// given tag number and the given index to the given value. An error is returned -// if the given tag is unknown, if it indicates a field that is not repeated (or -// is a map field), or if the given value has an incorrect type. -// -// (See TrySetField for more info on types.) -func (m *Message) TrySetRepeatedFieldByNumber(tagNumber int, index int, val interface{}) error { - if index < 0 { - return IndexOutOfRangeError - } - fd := m.FindFieldDescriptor(int32(tagNumber)) - if fd == nil { - return UnknownTagNumberError - } - return m.setRepeatedField(fd, index, val) -} - -func (m *Message) setRepeatedField(fd *desc.FieldDescriptor, index int, val interface{}) error { - if fd.IsMap() || !fd.IsRepeated() { - return FieldIsNotRepeatedError - } - val, err := validElementFieldValue(fd, val, false) - if err != nil { - return err - } - sl := m.values[fd.GetNumber()] - if sl == nil { - if sl, err = m.parseUnknownField(fd); err != nil { - return err - } else if sl == nil { - return IndexOutOfRangeError - } - } - res := sl.([]interface{}) - if index >= len(res) { - return IndexOutOfRangeError - } - res[index] = val - return nil -} - -// GetUnknownField gets the value(s) for the given unknown tag number. If this -// message has no unknown fields with the given tag, nil is returned. -func (m *Message) GetUnknownField(tagNumber int32) []UnknownField { - if u, ok := m.unknownFields[tagNumber]; ok { - return u - } else { - return nil - } -} - -func (m *Message) parseUnknownField(fd *desc.FieldDescriptor) (interface{}, error) { - unks, ok := m.unknownFields[fd.GetNumber()] - if !ok { - return nil, nil - } - var v interface{} - var sl []interface{} - var mp map[interface{}]interface{} - if fd.IsMap() { - mp = map[interface{}]interface{}{} - } - var err error - for _, unk := range unks { - var val interface{} - if unk.Encoding == proto.WireBytes || unk.Encoding == proto.WireStartGroup { - val, err = codec.DecodeLengthDelimitedField(fd, unk.Contents, m.mf) - } else { - val, err = codec.DecodeScalarField(fd, unk.Value) - } - if err != nil { - return nil, err - } - if fd.IsMap() { - newEntry := val.(*Message) - kk, err := newEntry.TryGetFieldByNumber(1) - if err != nil { - return nil, err - } - vv, err := newEntry.TryGetFieldByNumber(2) - if err != nil { - return nil, err - } - mp[kk] = vv - v = mp - } else if fd.IsRepeated() { - t := reflect.TypeOf(val) - if t.Kind() == reflect.Slice && t != typeOfBytes { - // append slices if we unmarshalled a packed repeated field - newVals := val.([]interface{}) - sl = append(sl, newVals...) - } else { - sl = append(sl, val) - } - v = sl - } else { - v = val - } - } - m.internalSetField(fd, v) - return v, nil -} - -func validFieldValue(fd *desc.FieldDescriptor, val interface{}) (interface{}, error) { - return validFieldValueForRv(fd, reflect.ValueOf(val)) -} - -func validFieldValueForRv(fd *desc.FieldDescriptor, val reflect.Value) (interface{}, error) { - if fd.IsMap() && val.Kind() == reflect.Map { - return validFieldValueForMapField(fd, val) - } - - if fd.IsRepeated() { // this will also catch map fields where given value was not a map - if val.Kind() != reflect.Array && val.Kind() != reflect.Slice { - if fd.IsMap() { - return nil, fmt.Errorf("value for map field must be a map; instead was %v", val.Type()) - } else { - return nil, fmt.Errorf("value for repeated field must be a slice; instead was %v", val.Type()) - } - } - - if fd.IsMap() { - // value should be a slice of entry messages that we need convert into a map[interface{}]interface{} - m := map[interface{}]interface{}{} - for i := 0; i < val.Len(); i++ { - e, err := validElementFieldValue(fd, val.Index(i).Interface(), false) - if err != nil { - return nil, err - } - msg := e.(proto.Message) - dm, err := asDynamicMessage(msg, fd.GetMessageType(), nil) - if err != nil { - return nil, err - } - k, err := dm.TryGetFieldByNumber(1) - if err != nil { - return nil, err - } - v, err := dm.TryGetFieldByNumber(2) - if err != nil { - return nil, err - } - m[k] = v - } - return m, nil - } - - // make a defensive copy while checking contents (also converts to []interface{}) - s := make([]interface{}, val.Len()) - for i := 0; i < val.Len(); i++ { - ev := val.Index(i) - if ev.Kind() == reflect.Interface { - // unwrap it - ev = reflect.ValueOf(ev.Interface()) - } - e, err := validElementFieldValueForRv(fd, ev, false) - if err != nil { - return nil, err - } - s[i] = e - } - - return s, nil - } - - return validElementFieldValueForRv(fd, val, false) -} - -func asDynamicMessage(m proto.Message, md *desc.MessageDescriptor, mf *MessageFactory) (*Message, error) { - if dm, ok := m.(*Message); ok { - return dm, nil - } - dm := NewMessageWithMessageFactory(md, mf) - if err := dm.mergeFrom(m); err != nil { - return nil, err - } - return dm, nil -} - -func validElementFieldValue(fd *desc.FieldDescriptor, val interface{}, allowNilMessage bool) (interface{}, error) { - return validElementFieldValueForRv(fd, reflect.ValueOf(val), allowNilMessage) -} - -func validElementFieldValueForRv(fd *desc.FieldDescriptor, val reflect.Value, allowNilMessage bool) (interface{}, error) { - t := fd.GetType() - if !val.IsValid() { - return nil, typeError(fd, nil) - } - - switch t { - case descriptor.FieldDescriptorProto_TYPE_SFIXED32, - descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_SINT32, - descriptor.FieldDescriptorProto_TYPE_ENUM: - return toInt32(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_SFIXED64, - descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_SINT64: - return toInt64(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_FIXED32, - descriptor.FieldDescriptorProto_TYPE_UINT32: - return toUint32(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_FIXED64, - descriptor.FieldDescriptorProto_TYPE_UINT64: - return toUint64(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - return toFloat32(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - return toFloat64(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_BOOL: - return toBool(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_BYTES: - return toBytes(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_STRING: - return toString(reflect.Indirect(val), fd) - - case descriptor.FieldDescriptorProto_TYPE_MESSAGE, - descriptor.FieldDescriptorProto_TYPE_GROUP: - m, err := asMessage(val, fd.GetFullyQualifiedName()) - // check that message is correct type - if err != nil { - return nil, err - } - var msgType string - if dm, ok := m.(*Message); ok { - if allowNilMessage && dm == nil { - // if dm == nil, we'll panic below, so early out if that is allowed - // (only allowed for map values, to indicate an entry w/ no value) - return m, nil - } - msgType = dm.GetMessageDescriptor().GetFullyQualifiedName() - } else { - msgType = proto.MessageName(m) - } - if msgType != fd.GetMessageType().GetFullyQualifiedName() { - return nil, fmt.Errorf("message field %s requires value of type %s; received %s", fd.GetFullyQualifiedName(), fd.GetMessageType().GetFullyQualifiedName(), msgType) - } - return m, nil - - default: - return nil, fmt.Errorf("unable to handle unrecognized field type: %v", fd.GetType()) - } -} - -func toInt32(v reflect.Value, fd *desc.FieldDescriptor) (int32, error) { - if v.Kind() == reflect.Int32 { - return int32(v.Int()), nil - } - return 0, typeError(fd, v.Type()) -} - -func toUint32(v reflect.Value, fd *desc.FieldDescriptor) (uint32, error) { - if v.Kind() == reflect.Uint32 { - return uint32(v.Uint()), nil - } - return 0, typeError(fd, v.Type()) -} - -func toFloat32(v reflect.Value, fd *desc.FieldDescriptor) (float32, error) { - if v.Kind() == reflect.Float32 { - return float32(v.Float()), nil - } - return 0, typeError(fd, v.Type()) -} - -func toInt64(v reflect.Value, fd *desc.FieldDescriptor) (int64, error) { - if v.Kind() == reflect.Int64 || v.Kind() == reflect.Int || v.Kind() == reflect.Int32 { - return v.Int(), nil - } - return 0, typeError(fd, v.Type()) -} - -func toUint64(v reflect.Value, fd *desc.FieldDescriptor) (uint64, error) { - if v.Kind() == reflect.Uint64 || v.Kind() == reflect.Uint || v.Kind() == reflect.Uint32 { - return v.Uint(), nil - } - return 0, typeError(fd, v.Type()) -} - -func toFloat64(v reflect.Value, fd *desc.FieldDescriptor) (float64, error) { - if v.Kind() == reflect.Float64 || v.Kind() == reflect.Float32 { - return v.Float(), nil - } - return 0, typeError(fd, v.Type()) -} - -func toBool(v reflect.Value, fd *desc.FieldDescriptor) (bool, error) { - if v.Kind() == reflect.Bool { - return v.Bool(), nil - } - return false, typeError(fd, v.Type()) -} - -func toBytes(v reflect.Value, fd *desc.FieldDescriptor) ([]byte, error) { - if v.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8 { - return v.Bytes(), nil - } - return nil, typeError(fd, v.Type()) -} - -func toString(v reflect.Value, fd *desc.FieldDescriptor) (string, error) { - if v.Kind() == reflect.String { - return v.String(), nil - } - return "", typeError(fd, v.Type()) -} - -func typeError(fd *desc.FieldDescriptor, t reflect.Type) error { - return fmt.Errorf( - "%s field %s is not compatible with value of type %v", - getTypeString(fd), fd.GetFullyQualifiedName(), t) -} - -func getTypeString(fd *desc.FieldDescriptor) string { - return strings.ToLower(fd.GetType().String()) -} - -func asMessage(v reflect.Value, fieldName string) (proto.Message, error) { - t := v.Type() - // we need a pointer to a struct that implements proto.Message - if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct || !t.Implements(typeOfProtoMessage) { - return nil, fmt.Errorf("message field %s requires is not compatible with value of type %v", fieldName, v.Type()) - } - return v.Interface().(proto.Message), nil -} - -// Reset resets this message to an empty message. It removes all values set in -// the message. -func (m *Message) Reset() { - for k := range m.values { - delete(m.values, k) - } - for k := range m.unknownFields { - delete(m.unknownFields, k) - } -} - -// String returns this message rendered in compact text format. -func (m *Message) String() string { - b, err := m.MarshalText() - if err != nil { - panic(fmt.Sprintf("Failed to create string representation of message: %s", err.Error())) - } - return string(b) -} - -// ProtoMessage is present to satisfy the proto.Message interface. -func (m *Message) ProtoMessage() { -} - -// ConvertTo converts this dynamic message into the given message. This is -// shorthand for resetting then merging: -// -// target.Reset() -// m.MergeInto(target) -func (m *Message) ConvertTo(target proto.Message) error { - if err := m.checkType(target); err != nil { - return err - } - - target.Reset() - return m.mergeInto(target, defaultDeterminism) -} - -// ConvertToDeterministic converts this dynamic message into the given message. -// It is just like ConvertTo, but it attempts to produce deterministic results. -// That means that if the target is a generated message (not another dynamic -// message) and the current runtime is unaware of any fields or extensions that -// are present in m, they will be serialized into the target's unrecognized -// fields deterministically. -func (m *Message) ConvertToDeterministic(target proto.Message) error { - if err := m.checkType(target); err != nil { - return err - } - - target.Reset() - return m.mergeInto(target, true) -} - -// ConvertFrom converts the given message into this dynamic message. This is -// shorthand for resetting then merging: -// -// m.Reset() -// m.MergeFrom(target) -func (m *Message) ConvertFrom(target proto.Message) error { - if err := m.checkType(target); err != nil { - return err - } - - m.Reset() - return m.mergeFrom(target) -} - -// MergeInto merges this dynamic message into the given message. All field -// values in this message will be set on the given message. For map fields, -// entries are added to the given message (if the given message has existing -// values for like keys, they are overwritten). For slice fields, elements are -// added. -// -// If the given message has a different set of known fields, it is possible for -// some known fields in this message to be represented as unknown fields in the -// given message after merging, and vice versa. -func (m *Message) MergeInto(target proto.Message) error { - if err := m.checkType(target); err != nil { - return err - } - return m.mergeInto(target, defaultDeterminism) -} - -// MergeIntoDeterministic merges this dynamic message into the given message. -// It is just like MergeInto, but it attempts to produce deterministic results. -// That means that if the target is a generated message (not another dynamic -// message) and the current runtime is unaware of any fields or extensions that -// are present in m, they will be serialized into the target's unrecognized -// fields deterministically. -func (m *Message) MergeIntoDeterministic(target proto.Message) error { - if err := m.checkType(target); err != nil { - return err - } - return m.mergeInto(target, true) -} - -// MergeFrom merges the given message into this dynamic message. All field -// values in the given message will be set on this message. For map fields, -// entries are added to this message (if this message has existing values for -// like keys, they are overwritten). For slice fields, elements are added. -// -// If the given message has a different set of known fields, it is possible for -// some known fields in that message to be represented as unknown fields in this -// message after merging, and vice versa. -func (m *Message) MergeFrom(source proto.Message) error { - if err := m.checkType(source); err != nil { - return err - } - return m.mergeFrom(source) -} - -// Merge implements the proto.Merger interface so that dynamic messages are -// compatible with the proto.Merge function. It delegates to MergeFrom but will -// panic on error as the proto.Merger interface doesn't allow for returning an -// error. -// -// Unlike nearly all other methods, this method can work if this message's type -// is not defined (such as instantiating the message without using NewMessage). -// This is strictly so that dynamic message's are compatible with the -// proto.Clone function, which instantiates a new message via reflection (thus -// its message descriptor will not be set) and than calls Merge. -func (m *Message) Merge(source proto.Message) { - if m.md == nil { - // To support proto.Clone, initialize the descriptor from the source. - if dm, ok := source.(*Message); ok { - m.md = dm.md - // also make sure the clone uses the same message factory and - // extensions and also knows about the same extra fields (if any) - m.mf = dm.mf - m.er = dm.er - m.extraFields = dm.extraFields - } else if md, err := desc.LoadMessageDescriptorForMessage(source); err != nil { - panic(err.Error()) - } else { - m.md = md - } - } - - if err := m.MergeFrom(source); err != nil { - panic(err.Error()) - } -} - -func (m *Message) checkType(target proto.Message) error { - if dm, ok := target.(*Message); ok { - if dm.md.GetFullyQualifiedName() != m.md.GetFullyQualifiedName() { - return fmt.Errorf("given message has wrong type: %q; expecting %q", dm.md.GetFullyQualifiedName(), m.md.GetFullyQualifiedName()) - } - return nil - } - - msgName := proto.MessageName(target) - if msgName != m.md.GetFullyQualifiedName() { - return fmt.Errorf("given message has wrong type: %q; expecting %q", msgName, m.md.GetFullyQualifiedName()) - } - return nil -} - -func (m *Message) mergeInto(pm proto.Message, deterministic bool) error { - if dm, ok := pm.(*Message); ok { - return dm.mergeFrom(m) - } - - target := reflect.ValueOf(pm) - if target.Kind() == reflect.Ptr { - target = target.Elem() - } - - // track tags for which the dynamic message has data but the given - // message doesn't know about it - unknownTags := map[int32]struct{}{} - for tag := range m.values { - unknownTags[tag] = struct{}{} - } - - // check that we can successfully do the merge - structProps := proto.GetProperties(reflect.TypeOf(pm).Elem()) - for _, prop := range structProps.Prop { - if prop.Tag == 0 { - continue // one-of or special field (such as XXX_unrecognized, etc.) - } - tag := int32(prop.Tag) - v, ok := m.values[tag] - if !ok { - continue - } - if unknownTags != nil { - delete(unknownTags, tag) - } - f := target.FieldByName(prop.Name) - ft := f.Type() - val := reflect.ValueOf(v) - if !canConvert(val, ft) { - return fmt.Errorf("cannot convert %v to %v", val.Type(), ft) - } - } - // check one-of fields - for _, oop := range structProps.OneofTypes { - prop := oop.Prop - tag := int32(prop.Tag) - v, ok := m.values[tag] - if !ok { - continue - } - if unknownTags != nil { - delete(unknownTags, tag) - } - stf, ok := oop.Type.Elem().FieldByName(prop.Name) - if !ok { - return fmt.Errorf("one-of field indicates struct field name %s, but type %v has no such field", prop.Name, oop.Type.Elem()) - } - ft := stf.Type - val := reflect.ValueOf(v) - if !canConvert(val, ft) { - return fmt.Errorf("cannot convert %v to %v", val.Type(), ft) - } - } - // and check extensions, too - for tag, ext := range proto.RegisteredExtensions(pm) { - v, ok := m.values[tag] - if !ok { - continue - } - if unknownTags != nil { - delete(unknownTags, tag) - } - ft := reflect.TypeOf(ext.ExtensionType) - val := reflect.ValueOf(v) - if !canConvert(val, ft) { - return fmt.Errorf("cannot convert %v to %v", val.Type(), ft) - } - } - - // now actually perform the merge - for _, prop := range structProps.Prop { - v, ok := m.values[int32(prop.Tag)] - if !ok { - continue - } - f := target.FieldByName(prop.Name) - if err := mergeVal(reflect.ValueOf(v), f, deterministic); err != nil { - return err - } - } - // merge one-ofs - for _, oop := range structProps.OneofTypes { - prop := oop.Prop - tag := int32(prop.Tag) - v, ok := m.values[tag] - if !ok { - continue - } - oov := reflect.New(oop.Type.Elem()) - f := oov.Elem().FieldByName(prop.Name) - if err := mergeVal(reflect.ValueOf(v), f, deterministic); err != nil { - return err - } - target.Field(oop.Field).Set(oov) - } - // merge extensions, too - for tag, ext := range proto.RegisteredExtensions(pm) { - v, ok := m.values[tag] - if !ok { - continue - } - e := reflect.New(reflect.TypeOf(ext.ExtensionType)).Elem() - if err := mergeVal(reflect.ValueOf(v), e, deterministic); err != nil { - return err - } - if err := proto.SetExtension(pm, ext, e.Interface()); err != nil { - // shouldn't happen since we already checked that the extension type was compatible above - return err - } - } - - // if we have fields that the given message doesn't know about, add to its unknown fields - if len(unknownTags) > 0 { - var b codec.Buffer - b.SetDeterministic(deterministic) - if deterministic { - // if we need to emit things deterministically, sort the - // extensions by their tag number - sortedUnknownTags := make([]int32, 0, len(unknownTags)) - for tag := range unknownTags { - sortedUnknownTags = append(sortedUnknownTags, tag) - } - sort.Slice(sortedUnknownTags, func(i, j int) bool { - return sortedUnknownTags[i] < sortedUnknownTags[j] - }) - for _, tag := range sortedUnknownTags { - fd := m.FindFieldDescriptor(tag) - if err := b.EncodeFieldValue(fd, m.values[tag]); err != nil { - return err - } - } - } else { - for tag := range unknownTags { - fd := m.FindFieldDescriptor(tag) - if err := b.EncodeFieldValue(fd, m.values[tag]); err != nil { - return err - } - } - } - - internal.SetUnrecognized(pm, b.Bytes()) - } - - // finally, convey unknown fields into the given message by letting it unmarshal them - // (this will append to its unknown fields if not known; if somehow the given message recognizes - // a field even though the dynamic message did not, it will get correctly unmarshalled) - if unknownTags != nil && len(m.unknownFields) > 0 { - var b codec.Buffer - _ = m.marshalUnknownFields(&b) - _ = proto.UnmarshalMerge(b.Bytes(), pm) - } - - return nil -} - -func canConvert(src reflect.Value, target reflect.Type) bool { - if src.Kind() == reflect.Interface { - src = reflect.ValueOf(src.Interface()) - } - srcType := src.Type() - // we allow convertible types instead of requiring exact types so that calling - // code can, for example, assign an enum constant to an enum field. In that case, - // one type is the enum type (a sub-type of int32) and the other may be the int32 - // type. So we automatically do the conversion in that case. - if srcType.ConvertibleTo(target) { - return true - } else if target.Kind() == reflect.Ptr && srcType.ConvertibleTo(target.Elem()) { - return true - } else if target.Kind() == reflect.Slice { - if srcType.Kind() != reflect.Slice { - return false - } - et := target.Elem() - for i := 0; i < src.Len(); i++ { - if !canConvert(src.Index(i), et) { - return false - } - } - return true - } else if target.Kind() == reflect.Map { - if srcType.Kind() != reflect.Map { - return false - } - return canConvertMap(src, target) - } else if srcType == typeOfDynamicMessage && target.Implements(typeOfProtoMessage) { - z := reflect.Zero(target).Interface() - msgType := proto.MessageName(z.(proto.Message)) - return msgType == src.Interface().(*Message).GetMessageDescriptor().GetFullyQualifiedName() - } else { - return false - } -} - -func mergeVal(src, target reflect.Value, deterministic bool) error { - if src.Kind() == reflect.Interface && !src.IsNil() { - src = src.Elem() - } - srcType := src.Type() - targetType := target.Type() - if srcType.ConvertibleTo(targetType) { - if targetType.Implements(typeOfProtoMessage) && !target.IsNil() { - Merge(target.Interface().(proto.Message), src.Convert(targetType).Interface().(proto.Message)) - } else { - target.Set(src.Convert(targetType)) - } - } else if targetType.Kind() == reflect.Ptr && srcType.ConvertibleTo(targetType.Elem()) { - if !src.CanAddr() { - target.Set(reflect.New(targetType.Elem())) - target.Elem().Set(src.Convert(targetType.Elem())) - } else { - target.Set(src.Addr().Convert(targetType)) - } - } else if targetType.Kind() == reflect.Slice { - l := target.Len() - newL := l + src.Len() - if target.Cap() < newL { - // expand capacity of the slice and copy - newSl := reflect.MakeSlice(targetType, newL, newL) - for i := 0; i < target.Len(); i++ { - newSl.Index(i).Set(target.Index(i)) - } - target.Set(newSl) - } else { - target.SetLen(newL) - } - for i := 0; i < src.Len(); i++ { - dest := target.Index(l + i) - if dest.Kind() == reflect.Ptr { - dest.Set(reflect.New(dest.Type().Elem())) - } - if err := mergeVal(src.Index(i), dest, deterministic); err != nil { - return err - } - } - } else if targetType.Kind() == reflect.Map { - return mergeMapVal(src, target, targetType, deterministic) - } else if srcType == typeOfDynamicMessage && targetType.Implements(typeOfProtoMessage) { - dm := src.Interface().(*Message) - if target.IsNil() { - target.Set(reflect.New(targetType.Elem())) - } - m := target.Interface().(proto.Message) - if err := dm.mergeInto(m, deterministic); err != nil { - return err - } - } else { - return fmt.Errorf("cannot convert %v to %v", srcType, targetType) - } - return nil -} - -func (m *Message) mergeFrom(pm proto.Message) error { - if dm, ok := pm.(*Message); ok { - // if given message is also a dynamic message, we merge differently - for tag, v := range dm.values { - fd := m.FindFieldDescriptor(tag) - if fd == nil { - fd = dm.FindFieldDescriptor(tag) - } - if err := mergeField(m, fd, v); err != nil { - return err - } - } - return nil - } - - pmrv := reflect.ValueOf(pm) - if pmrv.IsNil() { - // nil is an empty message, so nothing to do - return nil - } - - // check that we can successfully do the merge - src := pmrv.Elem() - values := map[*desc.FieldDescriptor]interface{}{} - props := proto.GetProperties(reflect.TypeOf(pm).Elem()) - if props == nil { - return fmt.Errorf("could not determine message properties to merge for %v", reflect.TypeOf(pm).Elem()) - } - - // regular fields - for _, prop := range props.Prop { - if prop.Tag == 0 { - continue // one-of or special field (such as XXX_unrecognized, etc.) - } - fd := m.FindFieldDescriptor(int32(prop.Tag)) - if fd == nil { - // Our descriptor has different fields than this message object. So - // try to reflect on the message object's fields. - md, err := desc.LoadMessageDescriptorForMessage(pm) - if err != nil { - return err - } - fd = md.FindFieldByNumber(int32(prop.Tag)) - if fd == nil { - return fmt.Errorf("message descriptor %q did not contain field for tag %d (%q)", md.GetFullyQualifiedName(), prop.Tag, prop.Name) - } - } - rv := src.FieldByName(prop.Name) - if (rv.Kind() == reflect.Ptr || rv.Kind() == reflect.Slice) && rv.IsNil() { - continue - } - if v, err := validFieldValueForRv(fd, rv); err != nil { - return err - } else { - values[fd] = v - } - } - - // one-of fields - for _, oop := range props.OneofTypes { - oov := src.Field(oop.Field).Elem() - if !oov.IsValid() || oov.Type() != oop.Type { - // this field is unset (in other words, one-of message field is not currently set to this option) - continue - } - prop := oop.Prop - rv := oov.Elem().FieldByName(prop.Name) - fd := m.FindFieldDescriptor(int32(prop.Tag)) - if fd == nil { - // Our descriptor has different fields than this message object. So - // try to reflect on the message object's fields. - md, err := desc.LoadMessageDescriptorForMessage(pm) - if err != nil { - return err - } - fd = md.FindFieldByNumber(int32(prop.Tag)) - if fd == nil { - return fmt.Errorf("message descriptor %q did not contain field for tag %d (%q in one-of %q)", md.GetFullyQualifiedName(), prop.Tag, prop.Name, src.Type().Field(oop.Field).Name) - } - } - if v, err := validFieldValueForRv(fd, rv); err != nil { - return err - } else { - values[fd] = v - } - } - - // extension fields - rexts, _ := proto.ExtensionDescs(pm) - for _, ed := range rexts { - v, _ := proto.GetExtension(pm, ed) - if v == nil { - continue - } - if ed.ExtensionType == nil { - // unrecognized extension: we'll handle that below when we - // handle other unrecognized fields - continue - } - fd := m.er.FindExtension(m.md.GetFullyQualifiedName(), ed.Field) - if fd == nil { - var err error - if fd, err = desc.LoadFieldDescriptorForExtension(ed); err != nil { - return err - } - } - if v, err := validFieldValue(fd, v); err != nil { - return err - } else { - values[fd] = v - } - } - - // unrecognized extensions fields: - // In API v2 of proto, some extensions may NEITHER be included in ExtensionDescs - // above NOR included in unrecognized fields below. These are extensions that use - // a custom extension type (not a generated one -- i.e. not a linked in extension). - mr := proto.MessageReflect(pm) - var extBytes []byte - var retErr error - mr.Range(func(fld protoreflect.FieldDescriptor, val protoreflect.Value) bool { - if !fld.IsExtension() { - // normal field, already processed above - return true - } - if extd, ok := fld.(protoreflect.ExtensionTypeDescriptor); ok { - if _, ok := extd.Type().(*proto.ExtensionDesc); ok { - // normal known extension, already processed above - return true - } - } - - // marshal the extension to bytes and then handle as unknown field below - mr.New() - mr.Set(fld, val) - extBytes, retErr = protov2.MarshalOptions{}.MarshalAppend(extBytes, mr.Interface()) - return retErr == nil - }) - if retErr != nil { - return retErr - } - - // now actually perform the merge - for fd, v := range values { - if err := mergeField(m, fd, v); err != nil { - return err - } - } - - if len(extBytes) > 0 { - // treating unrecognized extensions like unknown fields: best-effort - // ignore any error returned: pulling in unknown fields is best-effort - _ = m.UnmarshalMerge(extBytes) - } - - data := internal.GetUnrecognized(pm) - if len(data) > 0 { - // ignore any error returned: pulling in unknown fields is best-effort - _ = m.UnmarshalMerge(data) - } - - return nil -} - -// Validate checks that all required fields are present. It returns an error if any are absent. -func (m *Message) Validate() error { - missingFields := m.findMissingFields() - if len(missingFields) == 0 { - return nil - } - return fmt.Errorf("some required fields missing: %v", strings.Join(missingFields, ", ")) -} - -func (m *Message) findMissingFields() []string { - if m.md.IsProto3() { - // proto3 does not allow required fields - return nil - } - var missingFields []string - for _, fd := range m.md.GetFields() { - if fd.IsRequired() { - if _, ok := m.values[fd.GetNumber()]; !ok { - missingFields = append(missingFields, fd.GetName()) - } - } - } - return missingFields -} - -// ValidateRecursive checks that all required fields are present and also -// recursively validates all fields who are also messages. It returns an error -// if any required fields, in this message or nested within, are absent. -func (m *Message) ValidateRecursive() error { - return m.validateRecursive("") -} - -func (m *Message) validateRecursive(prefix string) error { - if missingFields := m.findMissingFields(); len(missingFields) > 0 { - for i := range missingFields { - missingFields[i] = fmt.Sprintf("%s%s", prefix, missingFields[i]) - } - return fmt.Errorf("some required fields missing: %v", strings.Join(missingFields, ", ")) - } - - for tag, fld := range m.values { - fd := m.FindFieldDescriptor(tag) - var chprefix string - var md *desc.MessageDescriptor - checkMsg := func(pm proto.Message) error { - var dm *Message - if d, ok := pm.(*Message); ok { - dm = d - } else if pm != nil { - dm = m.mf.NewDynamicMessage(md) - if err := dm.ConvertFrom(pm); err != nil { - return nil - } - } - if dm == nil { - return nil - } - if err := dm.validateRecursive(chprefix); err != nil { - return err - } - return nil - } - isMap := fd.IsMap() - if isMap && fd.GetMapValueType().GetMessageType() != nil { - md = fd.GetMapValueType().GetMessageType() - mp := fld.(map[interface{}]interface{}) - for k, v := range mp { - chprefix = fmt.Sprintf("%s%s[%v].", prefix, getName(fd), k) - if err := checkMsg(v.(proto.Message)); err != nil { - return err - } - } - } else if !isMap && fd.GetMessageType() != nil { - md = fd.GetMessageType() - if fd.IsRepeated() { - sl := fld.([]interface{}) - for i, v := range sl { - chprefix = fmt.Sprintf("%s%s[%d].", prefix, getName(fd), i) - if err := checkMsg(v.(proto.Message)); err != nil { - return err - } - } - } else { - chprefix = fmt.Sprintf("%s%s.", prefix, getName(fd)) - if err := checkMsg(fld.(proto.Message)); err != nil { - return err - } - } - } - } - - return nil -} - -func getName(fd *desc.FieldDescriptor) string { - if fd.IsExtension() { - return fmt.Sprintf("(%s)", fd.GetFullyQualifiedName()) - } else { - return fd.GetName() - } -} - -// knownFieldTags return tags of present and recognized fields, in sorted order. -func (m *Message) knownFieldTags() []int { - if len(m.values) == 0 { - return []int(nil) - } - - keys := make([]int, len(m.values)) - i := 0 - for k := range m.values { - keys[i] = int(k) - i++ - } - - sort.Ints(keys) - return keys -} - -// allKnownFieldTags return tags of present and recognized fields, including -// those that are unset, in sorted order. This only includes extensions that are -// present. Known but not-present extensions are not included in the returned -// set of tags. -func (m *Message) allKnownFieldTags() []int { - fds := m.md.GetFields() - keys := make([]int, 0, len(fds)+len(m.extraFields)) - - for k := range m.values { - keys = append(keys, int(k)) - } - - // also include known fields that are not present - for _, fd := range fds { - if _, ok := m.values[fd.GetNumber()]; !ok { - keys = append(keys, int(fd.GetNumber())) - } - } - for _, fd := range m.extraFields { - if !fd.IsExtension() { // skip extensions that are not present - if _, ok := m.values[fd.GetNumber()]; !ok { - keys = append(keys, int(fd.GetNumber())) - } - } - } - - sort.Ints(keys) - return keys -} - -// unknownFieldTags return tags of present but unrecognized fields, in sorted order. -func (m *Message) unknownFieldTags() []int { - if len(m.unknownFields) == 0 { - return []int(nil) - } - keys := make([]int, len(m.unknownFields)) - i := 0 - for k := range m.unknownFields { - keys[i] = int(k) - i++ - } - sort.Ints(keys) - return keys -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/equal.go b/vendor/github.com/jhump/protoreflect/dynamic/equal.go deleted file mode 100644 index e44c6c53c57..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/equal.go +++ /dev/null @@ -1,157 +0,0 @@ -package dynamic - -import ( - "bytes" - "reflect" - - "github.com/golang/protobuf/proto" - - "github.com/jhump/protoreflect/desc" -) - -// Equal returns true if the given two dynamic messages are equal. Two messages are equal when they -// have the same message type and same fields set to equal values. For proto3 messages, fields set -// to their zero value are considered unset. -func Equal(a, b *Message) bool { - if a == b { - return true - } - if (a == nil) != (b == nil) { - return false - } - if a.md.GetFullyQualifiedName() != b.md.GetFullyQualifiedName() { - return false - } - if len(a.values) != len(b.values) { - return false - } - if len(a.unknownFields) != len(b.unknownFields) { - return false - } - for tag, aval := range a.values { - bval, ok := b.values[tag] - if !ok { - return false - } - if !fieldsEqual(aval, bval) { - return false - } - } - for tag, au := range a.unknownFields { - bu, ok := b.unknownFields[tag] - if !ok { - return false - } - if len(au) != len(bu) { - return false - } - for i, aval := range au { - bval := bu[i] - if aval.Encoding != bval.Encoding { - return false - } - if aval.Encoding == proto.WireBytes || aval.Encoding == proto.WireStartGroup { - if !bytes.Equal(aval.Contents, bval.Contents) { - return false - } - } else if aval.Value != bval.Value { - return false - } - } - } - // all checks pass! - return true -} - -func fieldsEqual(aval, bval interface{}) bool { - arv := reflect.ValueOf(aval) - brv := reflect.ValueOf(bval) - if arv.Type() != brv.Type() { - // it is possible that one is a dynamic message and one is not - apm, ok := aval.(proto.Message) - if !ok { - return false - } - bpm, ok := bval.(proto.Message) - if !ok { - return false - } - return MessagesEqual(apm, bpm) - - } else { - switch arv.Kind() { - case reflect.Ptr: - apm, ok := aval.(proto.Message) - if !ok { - // Don't know how to compare pointer values that aren't messages! - // Maybe this should panic? - return false - } - bpm := bval.(proto.Message) // we know it will succeed because we know a and b have same type - return MessagesEqual(apm, bpm) - - case reflect.Map: - return mapsEqual(arv, brv) - - case reflect.Slice: - if arv.Type() == typeOfBytes { - return bytes.Equal(aval.([]byte), bval.([]byte)) - } else { - return slicesEqual(arv, brv) - } - - default: - return aval == bval - } - } -} - -func slicesEqual(a, b reflect.Value) bool { - if a.Len() != b.Len() { - return false - } - for i := 0; i < a.Len(); i++ { - ai := a.Index(i) - bi := b.Index(i) - if !fieldsEqual(ai.Interface(), bi.Interface()) { - return false - } - } - return true -} - -// MessagesEqual returns true if the given two messages are equal. Use this instead of proto.Equal -// when one or both of the messages might be a dynamic message. -func MessagesEqual(a, b proto.Message) bool { - da, aok := a.(*Message) - db, bok := b.(*Message) - // Both dynamic messages - if aok && bok { - return Equal(da, db) - } - // Neither dynamic messages - if !aok && !bok { - return proto.Equal(a, b) - } - // Mixed - if bok { - // we want a to be the dynamic one - b, da = a, db - } - - // Instead of panic'ing below if we have a nil dynamic message, check - // now and return false if the input message is not also nil. - if da == nil { - return isNil(b) - } - - md, err := desc.LoadMessageDescriptorForMessage(b) - if err != nil { - return false - } - db = NewMessageWithMessageFactory(md, da.mf) - if db.ConvertFrom(b) != nil { - return false - } - return Equal(da, db) -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/extension.go b/vendor/github.com/jhump/protoreflect/dynamic/extension.go deleted file mode 100644 index 1d38161031f..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/extension.go +++ /dev/null @@ -1,46 +0,0 @@ -package dynamic - -import ( - "fmt" - - "github.com/golang/protobuf/proto" - - "github.com/jhump/protoreflect/codec" - "github.com/jhump/protoreflect/desc" -) - -// SetExtension sets the given extension value. If the given message is not a -// dynamic message, the given extension may not be recognized (or may differ -// from the compiled and linked in version of the extension. So in that case, -// this function will serialize the given value to bytes and then use -// proto.SetRawExtension to set the value. -func SetExtension(msg proto.Message, extd *desc.FieldDescriptor, val interface{}) error { - if !extd.IsExtension() { - return fmt.Errorf("given field %s is not an extension", extd.GetFullyQualifiedName()) - } - - if dm, ok := msg.(*Message); ok { - return dm.TrySetField(extd, val) - } - - md, err := desc.LoadMessageDescriptorForMessage(msg) - if err != nil { - return err - } - if err := checkField(extd, md); err != nil { - return err - } - - val, err = validFieldValue(extd, val) - if err != nil { - return err - } - - var b codec.Buffer - b.SetDeterministic(defaultDeterminism) - if err := b.EncodeFieldValue(extd, val); err != nil { - return err - } - proto.SetRawExtension(msg, extd.GetNumber(), b.Bytes()) - return nil -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/extension_registry.go b/vendor/github.com/jhump/protoreflect/dynamic/extension_registry.go deleted file mode 100644 index 68768278f20..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/extension_registry.go +++ /dev/null @@ -1,241 +0,0 @@ -package dynamic - -import ( - "fmt" - "reflect" - "sync" - - "github.com/golang/protobuf/proto" - - "github.com/jhump/protoreflect/desc" -) - -// ExtensionRegistry is a registry of known extension fields. This is used to parse -// extension fields encountered when de-serializing a dynamic message. -type ExtensionRegistry struct { - includeDefault bool - mu sync.RWMutex - exts map[string]map[int32]*desc.FieldDescriptor -} - -// NewExtensionRegistryWithDefaults is a registry that includes all "default" extensions, -// which are those that are statically linked into the current program (e.g. registered by -// protoc-generated code via proto.RegisterExtension). Extensions explicitly added to the -// registry will override any default extensions that are for the same extendee and have the -// same tag number and/or name. -func NewExtensionRegistryWithDefaults() *ExtensionRegistry { - return &ExtensionRegistry{includeDefault: true} -} - -// AddExtensionDesc adds the given extensions to the registry. -func (r *ExtensionRegistry) AddExtensionDesc(exts ...*proto.ExtensionDesc) error { - flds := make([]*desc.FieldDescriptor, len(exts)) - for i, ext := range exts { - fd, err := desc.LoadFieldDescriptorForExtension(ext) - if err != nil { - return err - } - flds[i] = fd - } - r.mu.Lock() - defer r.mu.Unlock() - if r.exts == nil { - r.exts = map[string]map[int32]*desc.FieldDescriptor{} - } - for _, fd := range flds { - r.putExtensionLocked(fd) - } - return nil -} - -// AddExtension adds the given extensions to the registry. The given extensions -// will overwrite any previously added extensions that are for the same extendee -// message and same extension tag number. -func (r *ExtensionRegistry) AddExtension(exts ...*desc.FieldDescriptor) error { - for _, ext := range exts { - if !ext.IsExtension() { - return fmt.Errorf("given field is not an extension: %s", ext.GetFullyQualifiedName()) - } - } - r.mu.Lock() - defer r.mu.Unlock() - if r.exts == nil { - r.exts = map[string]map[int32]*desc.FieldDescriptor{} - } - for _, ext := range exts { - r.putExtensionLocked(ext) - } - return nil -} - -// AddExtensionsFromFile adds to the registry all extension fields defined in the given file descriptor. -func (r *ExtensionRegistry) AddExtensionsFromFile(fd *desc.FileDescriptor) { - r.mu.Lock() - defer r.mu.Unlock() - r.addExtensionsFromFileLocked(fd, false, nil) -} - -// AddExtensionsFromFileRecursively adds to the registry all extension fields defined in the give file -// descriptor and also recursively adds all extensions defined in that file's dependencies. This adds -// extensions from the entire transitive closure for the given file. -func (r *ExtensionRegistry) AddExtensionsFromFileRecursively(fd *desc.FileDescriptor) { - r.mu.Lock() - defer r.mu.Unlock() - already := map[*desc.FileDescriptor]struct{}{} - r.addExtensionsFromFileLocked(fd, true, already) -} - -func (r *ExtensionRegistry) addExtensionsFromFileLocked(fd *desc.FileDescriptor, recursive bool, alreadySeen map[*desc.FileDescriptor]struct{}) { - if _, ok := alreadySeen[fd]; ok { - return - } - - if r.exts == nil { - r.exts = map[string]map[int32]*desc.FieldDescriptor{} - } - for _, ext := range fd.GetExtensions() { - r.putExtensionLocked(ext) - } - for _, msg := range fd.GetMessageTypes() { - r.addExtensionsFromMessageLocked(msg) - } - - if recursive { - alreadySeen[fd] = struct{}{} - for _, dep := range fd.GetDependencies() { - r.addExtensionsFromFileLocked(dep, recursive, alreadySeen) - } - } -} - -func (r *ExtensionRegistry) addExtensionsFromMessageLocked(md *desc.MessageDescriptor) { - for _, ext := range md.GetNestedExtensions() { - r.putExtensionLocked(ext) - } - for _, msg := range md.GetNestedMessageTypes() { - r.addExtensionsFromMessageLocked(msg) - } -} - -func (r *ExtensionRegistry) putExtensionLocked(fd *desc.FieldDescriptor) { - msgName := fd.GetOwner().GetFullyQualifiedName() - m := r.exts[msgName] - if m == nil { - m = map[int32]*desc.FieldDescriptor{} - r.exts[msgName] = m - } - m[fd.GetNumber()] = fd -} - -// FindExtension queries for the extension field with the given extendee name (must be a fully-qualified -// message name) and tag number. If no extension is known, nil is returned. -func (r *ExtensionRegistry) FindExtension(messageName string, tagNumber int32) *desc.FieldDescriptor { - if r == nil { - return nil - } - r.mu.RLock() - defer r.mu.RUnlock() - fd := r.exts[messageName][tagNumber] - if fd == nil && r.includeDefault { - ext := getDefaultExtensions(messageName)[tagNumber] - if ext != nil { - fd, _ = desc.LoadFieldDescriptorForExtension(ext) - } - } - return fd -} - -// FindExtensionByName queries for the extension field with the given extendee name (must be a fully-qualified -// message name) and field name (must also be a fully-qualified extension name). If no extension is known, nil -// is returned. -func (r *ExtensionRegistry) FindExtensionByName(messageName string, fieldName string) *desc.FieldDescriptor { - if r == nil { - return nil - } - r.mu.RLock() - defer r.mu.RUnlock() - for _, fd := range r.exts[messageName] { - if fd.GetFullyQualifiedName() == fieldName { - return fd - } - } - if r.includeDefault { - for _, ext := range getDefaultExtensions(messageName) { - fd, _ := desc.LoadFieldDescriptorForExtension(ext) - if fd.GetFullyQualifiedName() == fieldName { - return fd - } - } - } - return nil -} - -// FindExtensionByJSONName queries for the extension field with the given extendee name (must be a fully-qualified -// message name) and JSON field name (must also be a fully-qualified name). If no extension is known, nil is returned. -// The fully-qualified JSON name is the same as the extension's normal fully-qualified name except that the last -// component uses the field's JSON name (if present). -func (r *ExtensionRegistry) FindExtensionByJSONName(messageName string, fieldName string) *desc.FieldDescriptor { - if r == nil { - return nil - } - r.mu.RLock() - defer r.mu.RUnlock() - for _, fd := range r.exts[messageName] { - if fd.GetFullyQualifiedJSONName() == fieldName { - return fd - } - } - if r.includeDefault { - for _, ext := range getDefaultExtensions(messageName) { - fd, _ := desc.LoadFieldDescriptorForExtension(ext) - if fd.GetFullyQualifiedJSONName() == fieldName { - return fd - } - } - } - return nil -} - -func getDefaultExtensions(messageName string) map[int32]*proto.ExtensionDesc { - t := proto.MessageType(messageName) - if t != nil { - msg := reflect.Zero(t).Interface().(proto.Message) - return proto.RegisteredExtensions(msg) - } - return nil -} - -// AllExtensionsForType returns all known extension fields for the given extendee name (must be a -// fully-qualified message name). -func (r *ExtensionRegistry) AllExtensionsForType(messageName string) []*desc.FieldDescriptor { - if r == nil { - return []*desc.FieldDescriptor(nil) - } - r.mu.RLock() - defer r.mu.RUnlock() - flds := r.exts[messageName] - var ret []*desc.FieldDescriptor - if r.includeDefault { - exts := getDefaultExtensions(messageName) - if len(exts) > 0 || len(flds) > 0 { - ret = make([]*desc.FieldDescriptor, 0, len(exts)+len(flds)) - } - for tag, ext := range exts { - if _, ok := flds[tag]; ok { - // skip default extension and use the one explicitly registered instead - continue - } - fd, _ := desc.LoadFieldDescriptorForExtension(ext) - if fd != nil { - ret = append(ret, fd) - } - } - } else if len(flds) > 0 { - ret = make([]*desc.FieldDescriptor, 0, len(flds)) - } - - for _, ext := range flds { - ret = append(ret, ext) - } - return ret -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/indent.go b/vendor/github.com/jhump/protoreflect/dynamic/indent.go deleted file mode 100644 index bd7fcaa5271..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/indent.go +++ /dev/null @@ -1,76 +0,0 @@ -package dynamic - -import "bytes" - -type indentBuffer struct { - bytes.Buffer - indent string - indentCount int - comma bool -} - -func (b *indentBuffer) start() error { - if b.indentCount >= 0 { - b.indentCount++ - return b.newLine(false) - } - return nil -} - -func (b *indentBuffer) sep() error { - if b.indentCount >= 0 { - _, err := b.WriteString(": ") - return err - } else { - return b.WriteByte(':') - } -} - -func (b *indentBuffer) end() error { - if b.indentCount >= 0 { - b.indentCount-- - return b.newLine(false) - } - return nil -} - -func (b *indentBuffer) maybeNext(first *bool) error { - if *first { - *first = false - return nil - } else { - return b.next() - } -} - -func (b *indentBuffer) next() error { - if b.indentCount >= 0 { - return b.newLine(b.comma) - } else if b.comma { - return b.WriteByte(',') - } else { - return b.WriteByte(' ') - } -} - -func (b *indentBuffer) newLine(comma bool) error { - if comma { - err := b.WriteByte(',') - if err != nil { - return err - } - } - - err := b.WriteByte('\n') - if err != nil { - return err - } - - for i := 0; i < b.indentCount; i++ { - _, err := b.WriteString(b.indent) - if err != nil { - return err - } - } - return nil -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/json.go b/vendor/github.com/jhump/protoreflect/dynamic/json.go deleted file mode 100644 index 2efd5849b71..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/json.go +++ /dev/null @@ -1,1256 +0,0 @@ -package dynamic - -// JSON marshalling and unmarshalling for dynamic messages - -import ( - "bytes" - "encoding/base64" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "math" - "reflect" - "sort" - "strconv" - "strings" - - "github.com/golang/protobuf/jsonpb" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/descriptor" - // link in the well-known-types that have a special JSON format - _ "github.com/golang/protobuf/ptypes/any" - _ "github.com/golang/protobuf/ptypes/duration" - _ "github.com/golang/protobuf/ptypes/empty" - _ "github.com/golang/protobuf/ptypes/struct" - _ "github.com/golang/protobuf/ptypes/timestamp" - _ "github.com/golang/protobuf/ptypes/wrappers" - - "github.com/jhump/protoreflect/desc" -) - -var wellKnownTypeNames = map[string]struct{}{ - "google.protobuf.Any": {}, - "google.protobuf.Empty": {}, - "google.protobuf.Duration": {}, - "google.protobuf.Timestamp": {}, - // struct.proto - "google.protobuf.Struct": {}, - "google.protobuf.Value": {}, - "google.protobuf.ListValue": {}, - // wrappers.proto - "google.protobuf.DoubleValue": {}, - "google.protobuf.FloatValue": {}, - "google.protobuf.Int64Value": {}, - "google.protobuf.UInt64Value": {}, - "google.protobuf.Int32Value": {}, - "google.protobuf.UInt32Value": {}, - "google.protobuf.BoolValue": {}, - "google.protobuf.StringValue": {}, - "google.protobuf.BytesValue": {}, -} - -// MarshalJSON serializes this message to bytes in JSON format, returning an -// error if the operation fails. The resulting bytes will be a valid UTF8 -// string. -// -// This method uses a compact form: no newlines, and spaces between fields and -// between field identifiers and values are elided. -// -// This method is convenient shorthand for invoking MarshalJSONPB with a default -// (zero value) marshaler: -// -// m.MarshalJSONPB(&jsonpb.Marshaler{}) -// -// So enums are serialized using enum value name strings, and values that are -// not present (including those with default/zero value for messages defined in -// "proto3" syntax) are omitted. -func (m *Message) MarshalJSON() ([]byte, error) { - return m.MarshalJSONPB(&jsonpb.Marshaler{}) -} - -// MarshalJSONIndent serializes this message to bytes in JSON format, returning -// an error if the operation fails. The resulting bytes will be a valid UTF8 -// string. -// -// This method uses a "pretty-printed" form, with each field on its own line and -// spaces between field identifiers and values. Indentation of two spaces is -// used. -// -// This method is convenient shorthand for invoking MarshalJSONPB with a default -// (zero value) marshaler: -// -// m.MarshalJSONPB(&jsonpb.Marshaler{Indent: " "}) -// -// So enums are serialized using enum value name strings, and values that are -// not present (including those with default/zero value for messages defined in -// "proto3" syntax) are omitted. -func (m *Message) MarshalJSONIndent() ([]byte, error) { - return m.MarshalJSONPB(&jsonpb.Marshaler{Indent: " "}) -} - -// MarshalJSONPB serializes this message to bytes in JSON format, returning an -// error if the operation fails. The resulting bytes will be a valid UTF8 -// string. The given marshaler is used to convey options used during marshaling. -// -// If this message contains nested messages that are generated message types (as -// opposed to dynamic messages), the given marshaler is used to marshal it. -// -// When marshaling any nested messages, any jsonpb.AnyResolver configured in the -// given marshaler is augmented with knowledge of message types known to this -// message's descriptor (and its enclosing file and set of transitive -// dependencies). -func (m *Message) MarshalJSONPB(opts *jsonpb.Marshaler) ([]byte, error) { - var b indentBuffer - b.indent = opts.Indent - if len(opts.Indent) == 0 { - b.indentCount = -1 - } - b.comma = true - if err := m.marshalJSON(&b, opts); err != nil { - return nil, err - } - return b.Bytes(), nil -} - -func (m *Message) marshalJSON(b *indentBuffer, opts *jsonpb.Marshaler) error { - if m == nil { - _, err := b.WriteString("null") - return err - } - if r, changed := wrapResolver(opts.AnyResolver, m.mf, m.md.GetFile()); changed { - newOpts := *opts - newOpts.AnyResolver = r - opts = &newOpts - } - - if ok, err := marshalWellKnownType(m, b, opts); ok { - return err - } - - err := b.WriteByte('{') - if err != nil { - return err - } - err = b.start() - if err != nil { - return err - } - - var tags []int - if opts.EmitDefaults { - tags = m.allKnownFieldTags() - } else { - tags = m.knownFieldTags() - } - - first := true - - for _, tag := range tags { - itag := int32(tag) - fd := m.FindFieldDescriptor(itag) - - v, ok := m.values[itag] - if !ok { - if fd.GetOneOf() != nil { - // don't print defaults for fields in a oneof - continue - } - v = fd.GetDefaultValue() - } - - err := b.maybeNext(&first) - if err != nil { - return err - } - err = marshalKnownFieldJSON(b, fd, v, opts) - if err != nil { - return err - } - } - - err = b.end() - if err != nil { - return err - } - err = b.WriteByte('}') - if err != nil { - return err - } - - return nil -} - -func marshalWellKnownType(m *Message, b *indentBuffer, opts *jsonpb.Marshaler) (bool, error) { - fqn := m.md.GetFullyQualifiedName() - if _, ok := wellKnownTypeNames[fqn]; !ok { - return false, nil - } - - msgType := proto.MessageType(fqn) - if msgType == nil { - // wtf? - panic(fmt.Sprintf("could not find registered message type for %q", fqn)) - } - - // convert dynamic message to well-known type and let jsonpb marshal it - msg := reflect.New(msgType.Elem()).Interface().(proto.Message) - if err := m.MergeInto(msg); err != nil { - return true, err - } - return true, opts.Marshal(b, msg) -} - -func marshalKnownFieldJSON(b *indentBuffer, fd *desc.FieldDescriptor, v interface{}, opts *jsonpb.Marshaler) error { - var jsonName string - if opts.OrigName { - jsonName = fd.GetName() - } else { - jsonName = fd.AsFieldDescriptorProto().GetJsonName() - if jsonName == "" { - jsonName = fd.GetName() - } - } - if fd.IsExtension() { - var scope string - switch parent := fd.GetParent().(type) { - case *desc.FileDescriptor: - scope = parent.GetPackage() - default: - scope = parent.GetFullyQualifiedName() - } - if scope == "" { - jsonName = fmt.Sprintf("[%s]", jsonName) - } else { - jsonName = fmt.Sprintf("[%s.%s]", scope, jsonName) - } - } - err := writeJsonString(b, jsonName) - if err != nil { - return err - } - err = b.sep() - if err != nil { - return err - } - - if isNil(v) { - _, err := b.WriteString("null") - return err - } - - if fd.IsMap() { - err = b.WriteByte('{') - if err != nil { - return err - } - err = b.start() - if err != nil { - return err - } - - md := fd.GetMessageType() - vfd := md.FindFieldByNumber(2) - - mp := v.(map[interface{}]interface{}) - keys := make([]interface{}, 0, len(mp)) - for k := range mp { - keys = append(keys, k) - } - sort.Sort(sortable(keys)) - first := true - for _, mk := range keys { - mv := mp[mk] - err := b.maybeNext(&first) - if err != nil { - return err - } - - err = marshalKnownFieldMapEntryJSON(b, mk, vfd, mv, opts) - if err != nil { - return err - } - } - - err = b.end() - if err != nil { - return err - } - return b.WriteByte('}') - - } else if fd.IsRepeated() { - err = b.WriteByte('[') - if err != nil { - return err - } - err = b.start() - if err != nil { - return err - } - - sl := v.([]interface{}) - first := true - for _, slv := range sl { - err := b.maybeNext(&first) - if err != nil { - return err - } - err = marshalKnownFieldValueJSON(b, fd, slv, opts) - if err != nil { - return err - } - } - - err = b.end() - if err != nil { - return err - } - return b.WriteByte(']') - - } else { - return marshalKnownFieldValueJSON(b, fd, v, opts) - } -} - -// sortable is used to sort map keys. Values will be integers (int32, int64, uint32, and uint64), -// bools, or strings. -type sortable []interface{} - -func (s sortable) Len() int { - return len(s) -} - -func (s sortable) Less(i, j int) bool { - vi := s[i] - vj := s[j] - switch reflect.TypeOf(vi).Kind() { - case reflect.Int32: - return vi.(int32) < vj.(int32) - case reflect.Int64: - return vi.(int64) < vj.(int64) - case reflect.Uint32: - return vi.(uint32) < vj.(uint32) - case reflect.Uint64: - return vi.(uint64) < vj.(uint64) - case reflect.String: - return vi.(string) < vj.(string) - case reflect.Bool: - return !vi.(bool) && vj.(bool) - default: - panic(fmt.Sprintf("cannot compare keys of type %v", reflect.TypeOf(vi))) - } -} - -func (s sortable) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -func isNil(v interface{}) bool { - if v == nil { - return true - } - rv := reflect.ValueOf(v) - return rv.Kind() == reflect.Ptr && rv.IsNil() -} - -func marshalKnownFieldMapEntryJSON(b *indentBuffer, mk interface{}, vfd *desc.FieldDescriptor, mv interface{}, opts *jsonpb.Marshaler) error { - rk := reflect.ValueOf(mk) - var strkey string - switch rk.Kind() { - case reflect.Bool: - strkey = strconv.FormatBool(rk.Bool()) - case reflect.Int32, reflect.Int64: - strkey = strconv.FormatInt(rk.Int(), 10) - case reflect.Uint32, reflect.Uint64: - strkey = strconv.FormatUint(rk.Uint(), 10) - case reflect.String: - strkey = rk.String() - default: - return fmt.Errorf("invalid map key value: %v (%v)", mk, rk.Type()) - } - err := writeJsonString(b, strkey) - if err != nil { - return err - } - err = b.sep() - if err != nil { - return err - } - return marshalKnownFieldValueJSON(b, vfd, mv, opts) -} - -func marshalKnownFieldValueJSON(b *indentBuffer, fd *desc.FieldDescriptor, v interface{}, opts *jsonpb.Marshaler) error { - rv := reflect.ValueOf(v) - switch rv.Kind() { - case reflect.Int64: - return writeJsonString(b, strconv.FormatInt(rv.Int(), 10)) - case reflect.Int32: - ed := fd.GetEnumType() - if !opts.EnumsAsInts && ed != nil { - n := int32(rv.Int()) - vd := ed.FindValueByNumber(n) - if vd == nil { - _, err := b.WriteString(strconv.FormatInt(rv.Int(), 10)) - return err - } else { - return writeJsonString(b, vd.GetName()) - } - } else { - _, err := b.WriteString(strconv.FormatInt(rv.Int(), 10)) - return err - } - case reflect.Uint64: - return writeJsonString(b, strconv.FormatUint(rv.Uint(), 10)) - case reflect.Uint32: - _, err := b.WriteString(strconv.FormatUint(rv.Uint(), 10)) - return err - case reflect.Float32, reflect.Float64: - f := rv.Float() - var str string - if math.IsNaN(f) { - str = `"NaN"` - } else if math.IsInf(f, 1) { - str = `"Infinity"` - } else if math.IsInf(f, -1) { - str = `"-Infinity"` - } else { - var bits int - if rv.Kind() == reflect.Float32 { - bits = 32 - } else { - bits = 64 - } - str = strconv.FormatFloat(rv.Float(), 'g', -1, bits) - } - _, err := b.WriteString(str) - return err - case reflect.Bool: - _, err := b.WriteString(strconv.FormatBool(rv.Bool())) - return err - case reflect.Slice: - bstr := base64.StdEncoding.EncodeToString(rv.Bytes()) - return writeJsonString(b, bstr) - case reflect.String: - return writeJsonString(b, rv.String()) - default: - // must be a message - if isNil(v) { - _, err := b.WriteString("null") - return err - } - - if dm, ok := v.(*Message); ok { - return dm.marshalJSON(b, opts) - } - - var err error - if b.indentCount <= 0 || len(b.indent) == 0 { - err = opts.Marshal(b, v.(proto.Message)) - } else { - str, err := opts.MarshalToString(v.(proto.Message)) - if err != nil { - return err - } - indent := strings.Repeat(b.indent, b.indentCount) - pos := 0 - // add indention prefix to each line - for pos < len(str) { - start := pos - nextPos := strings.Index(str[pos:], "\n") - if nextPos == -1 { - nextPos = len(str) - } else { - nextPos = pos + nextPos + 1 // include newline - } - line := str[start:nextPos] - if pos > 0 { - _, err = b.WriteString(indent) - if err != nil { - return err - } - } - _, err = b.WriteString(line) - if err != nil { - return err - } - pos = nextPos - } - } - return err - } -} - -func writeJsonString(b *indentBuffer, s string) error { - if sbytes, err := json.Marshal(s); err != nil { - return err - } else { - _, err := b.Write(sbytes) - return err - } -} - -// UnmarshalJSON de-serializes the message that is present, in JSON format, in -// the given bytes into this message. It first resets the current message. It -// returns an error if the given bytes do not contain a valid encoding of this -// message type in JSON format. -// -// This method is shorthand for invoking UnmarshalJSONPB with a default (zero -// value) unmarshaler: -// -// m.UnmarshalMergeJSONPB(&jsonpb.Unmarshaler{}, js) -// -// So unknown fields will result in an error, and no provided jsonpb.AnyResolver -// will be used when parsing google.protobuf.Any messages. -func (m *Message) UnmarshalJSON(js []byte) error { - return m.UnmarshalJSONPB(&jsonpb.Unmarshaler{}, js) -} - -// UnmarshalMergeJSON de-serializes the message that is present, in JSON format, -// in the given bytes into this message. Unlike UnmarshalJSON, it does not first -// reset the message, instead merging the data in the given bytes into the -// existing data in this message. -func (m *Message) UnmarshalMergeJSON(js []byte) error { - return m.UnmarshalMergeJSONPB(&jsonpb.Unmarshaler{}, js) -} - -// UnmarshalJSONPB de-serializes the message that is present, in JSON format, in -// the given bytes into this message. The given unmarshaler conveys options used -// when parsing the JSON. This function first resets the current message. It -// returns an error if the given bytes do not contain a valid encoding of this -// message type in JSON format. -// -// The decoding is lenient: -// 1. The JSON can refer to fields either by their JSON name or by their -// declared name. -// 2. The JSON can use either numeric values or string names for enum values. -// -// When instantiating nested messages, if this message's associated factory -// returns a generated message type (as opposed to a dynamic message), the given -// unmarshaler is used to unmarshal it. -// -// When unmarshaling any nested messages, any jsonpb.AnyResolver configured in -// the given unmarshaler is augmented with knowledge of message types known to -// this message's descriptor (and its enclosing file and set of transitive -// dependencies). -func (m *Message) UnmarshalJSONPB(opts *jsonpb.Unmarshaler, js []byte) error { - m.Reset() - if err := m.UnmarshalMergeJSONPB(opts, js); err != nil { - return err - } - return m.Validate() -} - -// UnmarshalMergeJSONPB de-serializes the message that is present, in JSON -// format, in the given bytes into this message. The given unmarshaler conveys -// options used when parsing the JSON. Unlike UnmarshalJSONPB, it does not first -// reset the message, instead merging the data in the given bytes into the -// existing data in this message. -func (m *Message) UnmarshalMergeJSONPB(opts *jsonpb.Unmarshaler, js []byte) error { - r := newJsReader(js) - err := m.unmarshalJson(r, opts) - if err != nil { - return err - } - if t, err := r.poll(); err != io.EOF { - b, _ := ioutil.ReadAll(r.unread()) - s := fmt.Sprintf("%v%s", t, string(b)) - return fmt.Errorf("superfluous data found after JSON object: %q", s) - } - return nil -} - -func unmarshalWellKnownType(m *Message, r *jsReader, opts *jsonpb.Unmarshaler) (bool, error) { - fqn := m.md.GetFullyQualifiedName() - if _, ok := wellKnownTypeNames[fqn]; !ok { - return false, nil - } - - msgType := proto.MessageType(fqn) - if msgType == nil { - // wtf? - panic(fmt.Sprintf("could not find registered message type for %q", fqn)) - } - - // extract json value from r - var js json.RawMessage - if err := json.NewDecoder(r.unread()).Decode(&js); err != nil { - return true, err - } - if err := r.skip(); err != nil { - return true, err - } - - // unmarshal into well-known type and then convert to dynamic message - msg := reflect.New(msgType.Elem()).Interface().(proto.Message) - if err := opts.Unmarshal(bytes.NewReader(js), msg); err != nil { - return true, err - } - return true, m.MergeFrom(msg) -} - -func (m *Message) unmarshalJson(r *jsReader, opts *jsonpb.Unmarshaler) error { - if r, changed := wrapResolver(opts.AnyResolver, m.mf, m.md.GetFile()); changed { - newOpts := *opts - newOpts.AnyResolver = r - opts = &newOpts - } - - if ok, err := unmarshalWellKnownType(m, r, opts); ok { - return err - } - - t, err := r.peek() - if err != nil { - return err - } - if t == nil { - // if json is simply "null" we do nothing - r.poll() - return nil - } - - if err := r.beginObject(); err != nil { - return err - } - - for r.hasNext() { - f, err := r.nextObjectKey() - if err != nil { - return err - } - fd := m.FindFieldDescriptorByJSONName(f) - if fd == nil { - if opts.AllowUnknownFields { - r.skip() - continue - } - return fmt.Errorf("message type %s has no known field named %s", m.md.GetFullyQualifiedName(), f) - } - v, err := unmarshalJsField(fd, r, m.mf, opts) - if err != nil { - return err - } - if v != nil { - if err := mergeField(m, fd, v); err != nil { - return err - } - } else if fd.GetOneOf() != nil { - // preserve explicit null for oneof fields (this is a little odd but - // mimics the behavior of jsonpb with oneofs in generated message types) - if fd.GetMessageType() != nil { - typ := m.mf.GetKnownTypeRegistry().GetKnownType(fd.GetMessageType().GetFullyQualifiedName()) - if typ != nil { - // typed nil - if typ.Kind() != reflect.Ptr { - typ = reflect.PtrTo(typ) - } - v = reflect.Zero(typ).Interface() - } else { - // can't use nil dynamic message, so we just use empty one instead - v = m.mf.NewDynamicMessage(fd.GetMessageType()) - } - if err := m.setField(fd, v); err != nil { - return err - } - } else { - // not a message... explicit null makes no sense - return fmt.Errorf("message type %s cannot set field %s to null: it is not a message type", m.md.GetFullyQualifiedName(), f) - } - } else { - m.clearField(fd) - } - } - - if err := r.endObject(); err != nil { - return err - } - - return nil -} - -func isWellKnownValue(fd *desc.FieldDescriptor) bool { - return !fd.IsRepeated() && fd.GetType() == descriptor.FieldDescriptorProto_TYPE_MESSAGE && - fd.GetMessageType().GetFullyQualifiedName() == "google.protobuf.Value" -} - -func isWellKnownListValue(fd *desc.FieldDescriptor) bool { - // we look for ListValue; but we also look for Value, which can be assigned a ListValue - return !fd.IsRepeated() && fd.GetType() == descriptor.FieldDescriptorProto_TYPE_MESSAGE && - (fd.GetMessageType().GetFullyQualifiedName() == "google.protobuf.ListValue" || - fd.GetMessageType().GetFullyQualifiedName() == "google.protobuf.Value") -} - -func unmarshalJsField(fd *desc.FieldDescriptor, r *jsReader, mf *MessageFactory, opts *jsonpb.Unmarshaler) (interface{}, error) { - t, err := r.peek() - if err != nil { - return nil, err - } - if t == nil && !isWellKnownValue(fd) { - // if value is null, just return nil - // (unless field is google.protobuf.Value, in which case - // we fall through to parse it as an instance where its - // underlying value is set to a NullValue) - r.poll() - return nil, nil - } - - if t == json.Delim('{') && fd.IsMap() { - entryType := fd.GetMessageType() - keyType := entryType.FindFieldByNumber(1) - valueType := entryType.FindFieldByNumber(2) - mp := map[interface{}]interface{}{} - - // TODO: if there are just two map keys "key" and "value" and they have the right type of values, - // treat this JSON object as a single map entry message. (In keeping with support of map fields as - // if they were normal repeated field of entry messages as well as supporting a transition from - // optional to repeated...) - - if err := r.beginObject(); err != nil { - return nil, err - } - for r.hasNext() { - kk, err := unmarshalJsFieldElement(keyType, r, mf, opts, false) - if err != nil { - return nil, err - } - vv, err := unmarshalJsFieldElement(valueType, r, mf, opts, true) - if err != nil { - return nil, err - } - mp[kk] = vv - } - if err := r.endObject(); err != nil { - return nil, err - } - - return mp, nil - } else if t == json.Delim('[') && !isWellKnownListValue(fd) { - // We support parsing an array, even if field is not repeated, to mimic support in proto - // binary wire format that supports changing an optional field to repeated and vice versa. - // If the field is not repeated, we only keep the last value in the array. - - if err := r.beginArray(); err != nil { - return nil, err - } - var sl []interface{} - var v interface{} - for r.hasNext() { - var err error - v, err = unmarshalJsFieldElement(fd, r, mf, opts, false) - if err != nil { - return nil, err - } - if fd.IsRepeated() && v != nil { - sl = append(sl, v) - } - } - if err := r.endArray(); err != nil { - return nil, err - } - if fd.IsMap() { - mp := map[interface{}]interface{}{} - for _, m := range sl { - msg := m.(*Message) - kk, err := msg.TryGetFieldByNumber(1) - if err != nil { - return nil, err - } - vv, err := msg.TryGetFieldByNumber(2) - if err != nil { - return nil, err - } - mp[kk] = vv - } - return mp, nil - } else if fd.IsRepeated() { - return sl, nil - } else { - return v, nil - } - } else { - // We support parsing a singular value, even if field is repeated, to mimic support in proto - // binary wire format that supports changing an optional field to repeated and vice versa. - // If the field is repeated, we store value as singleton slice of that one value. - - v, err := unmarshalJsFieldElement(fd, r, mf, opts, false) - if err != nil { - return nil, err - } - if v == nil { - return nil, nil - } - if fd.IsRepeated() { - return []interface{}{v}, nil - } else { - return v, nil - } - } -} - -func unmarshalJsFieldElement(fd *desc.FieldDescriptor, r *jsReader, mf *MessageFactory, opts *jsonpb.Unmarshaler, allowNilMessage bool) (interface{}, error) { - t, err := r.peek() - if err != nil { - return nil, err - } - - switch fd.GetType() { - case descriptor.FieldDescriptorProto_TYPE_MESSAGE, - descriptor.FieldDescriptorProto_TYPE_GROUP: - - if t == nil && allowNilMessage { - // if json is simply "null" return a nil pointer - r.poll() - return nilMessage(fd.GetMessageType()), nil - } - - m := mf.NewMessage(fd.GetMessageType()) - if dm, ok := m.(*Message); ok { - if err := dm.unmarshalJson(r, opts); err != nil { - return nil, err - } - } else { - var msg json.RawMessage - if err := json.NewDecoder(r.unread()).Decode(&msg); err != nil { - return nil, err - } - if err := r.skip(); err != nil { - return nil, err - } - if err := opts.Unmarshal(bytes.NewReader([]byte(msg)), m); err != nil { - return nil, err - } - } - return m, nil - - case descriptor.FieldDescriptorProto_TYPE_ENUM: - if e, err := r.nextNumber(); err != nil { - return nil, err - } else { - // value could be string or number - if i, err := e.Int64(); err != nil { - // number cannot be parsed, so see if it's an enum value name - vd := fd.GetEnumType().FindValueByName(string(e)) - if vd != nil { - return vd.GetNumber(), nil - } else { - return nil, fmt.Errorf("enum %q does not have value named %q", fd.GetEnumType().GetFullyQualifiedName(), e) - } - } else if i > math.MaxInt32 || i < math.MinInt32 { - return nil, NumericOverflowError - } else { - return int32(i), err - } - } - - case descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_SINT32, - descriptor.FieldDescriptorProto_TYPE_SFIXED32: - if i, err := r.nextInt(); err != nil { - return nil, err - } else if i > math.MaxInt32 || i < math.MinInt32 { - return nil, NumericOverflowError - } else { - return int32(i), err - } - - case descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_SINT64, - descriptor.FieldDescriptorProto_TYPE_SFIXED64: - return r.nextInt() - - case descriptor.FieldDescriptorProto_TYPE_UINT32, - descriptor.FieldDescriptorProto_TYPE_FIXED32: - if i, err := r.nextUint(); err != nil { - return nil, err - } else if i > math.MaxUint32 { - return nil, NumericOverflowError - } else { - return uint32(i), err - } - - case descriptor.FieldDescriptorProto_TYPE_UINT64, - descriptor.FieldDescriptorProto_TYPE_FIXED64: - return r.nextUint() - - case descriptor.FieldDescriptorProto_TYPE_BOOL: - if str, ok := t.(string); ok { - if str == "true" { - r.poll() // consume token - return true, err - } else if str == "false" { - r.poll() // consume token - return false, err - } - } - return r.nextBool() - - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - if f, err := r.nextFloat(); err != nil { - return nil, err - } else { - return float32(f), nil - } - - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - return r.nextFloat() - - case descriptor.FieldDescriptorProto_TYPE_BYTES: - return r.nextBytes() - - case descriptor.FieldDescriptorProto_TYPE_STRING: - return r.nextString() - - default: - return nil, fmt.Errorf("unknown field type: %v", fd.GetType()) - } -} - -type jsReader struct { - reader *bytes.Reader - dec *json.Decoder - current json.Token - peeked bool -} - -func newJsReader(b []byte) *jsReader { - reader := bytes.NewReader(b) - dec := json.NewDecoder(reader) - dec.UseNumber() - return &jsReader{reader: reader, dec: dec} -} - -func (r *jsReader) unread() io.Reader { - bufs := make([]io.Reader, 3) - var peeked []byte - if r.peeked { - if _, ok := r.current.(json.Delim); ok { - peeked = []byte(fmt.Sprintf("%v", r.current)) - } else { - peeked, _ = json.Marshal(r.current) - } - } - readerCopy := *r.reader - decCopy := *r.dec - - bufs[0] = bytes.NewReader(peeked) - bufs[1] = decCopy.Buffered() - bufs[2] = &readerCopy - return &concatReader{bufs: bufs} -} - -func (r *jsReader) hasNext() bool { - return r.dec.More() -} - -func (r *jsReader) peek() (json.Token, error) { - if r.peeked { - return r.current, nil - } - t, err := r.dec.Token() - if err != nil { - return nil, err - } - r.peeked = true - r.current = t - return t, nil -} - -func (r *jsReader) poll() (json.Token, error) { - if r.peeked { - ret := r.current - r.current = nil - r.peeked = false - return ret, nil - } - return r.dec.Token() -} - -func (r *jsReader) beginObject() error { - _, err := r.expect(func(t json.Token) bool { return t == json.Delim('{') }, nil, "start of JSON object: '{'") - return err -} - -func (r *jsReader) endObject() error { - _, err := r.expect(func(t json.Token) bool { return t == json.Delim('}') }, nil, "end of JSON object: '}'") - return err -} - -func (r *jsReader) beginArray() error { - _, err := r.expect(func(t json.Token) bool { return t == json.Delim('[') }, nil, "start of array: '['") - return err -} - -func (r *jsReader) endArray() error { - _, err := r.expect(func(t json.Token) bool { return t == json.Delim(']') }, nil, "end of array: ']'") - return err -} - -func (r *jsReader) nextObjectKey() (string, error) { - return r.nextString() -} - -func (r *jsReader) nextString() (string, error) { - t, err := r.expect(func(t json.Token) bool { _, ok := t.(string); return ok }, "", "string") - if err != nil { - return "", err - } - return t.(string), nil -} - -func (r *jsReader) nextBytes() ([]byte, error) { - str, err := r.nextString() - if err != nil { - return nil, err - } - return base64.StdEncoding.DecodeString(str) -} - -func (r *jsReader) nextBool() (bool, error) { - t, err := r.expect(func(t json.Token) bool { _, ok := t.(bool); return ok }, false, "boolean") - if err != nil { - return false, err - } - return t.(bool), nil -} - -func (r *jsReader) nextInt() (int64, error) { - n, err := r.nextNumber() - if err != nil { - return 0, err - } - return n.Int64() -} - -func (r *jsReader) nextUint() (uint64, error) { - n, err := r.nextNumber() - if err != nil { - return 0, err - } - return strconv.ParseUint(string(n), 10, 64) -} - -func (r *jsReader) nextFloat() (float64, error) { - n, err := r.nextNumber() - if err != nil { - return 0, err - } - return n.Float64() -} - -func (r *jsReader) nextNumber() (json.Number, error) { - t, err := r.expect(func(t json.Token) bool { return reflect.TypeOf(t).Kind() == reflect.String }, "0", "number") - if err != nil { - return "", err - } - switch t := t.(type) { - case json.Number: - return t, nil - case string: - return json.Number(t), nil - } - return "", fmt.Errorf("expecting a number but got %v", t) -} - -func (r *jsReader) skip() error { - t, err := r.poll() - if err != nil { - return err - } - if t == json.Delim('[') { - if err := r.skipArray(); err != nil { - return err - } - } else if t == json.Delim('{') { - if err := r.skipObject(); err != nil { - return err - } - } - return nil -} - -func (r *jsReader) skipArray() error { - for r.hasNext() { - if err := r.skip(); err != nil { - return err - } - } - if err := r.endArray(); err != nil { - return err - } - return nil -} - -func (r *jsReader) skipObject() error { - for r.hasNext() { - // skip object key - if err := r.skip(); err != nil { - return err - } - // and value - if err := r.skip(); err != nil { - return err - } - } - if err := r.endObject(); err != nil { - return err - } - return nil -} - -func (r *jsReader) expect(predicate func(json.Token) bool, ifNil interface{}, expected string) (interface{}, error) { - t, err := r.poll() - if err != nil { - return nil, err - } - if t == nil && ifNil != nil { - return ifNil, nil - } - if !predicate(t) { - return t, fmt.Errorf("bad input: expecting %s ; instead got %v", expected, t) - } - return t, nil -} - -type concatReader struct { - bufs []io.Reader - curr int -} - -func (r *concatReader) Read(p []byte) (n int, err error) { - for { - if r.curr >= len(r.bufs) { - err = io.EOF - return - } - var c int - c, err = r.bufs[r.curr].Read(p) - n += c - if err != io.EOF { - return - } - r.curr++ - p = p[c:] - } -} - -// AnyResolver returns a jsonpb.AnyResolver that uses the given file descriptors -// to resolve message names. It uses the given factory, which may be nil, to -// instantiate messages. The messages that it returns when resolving a type name -// may often be dynamic messages. -func AnyResolver(mf *MessageFactory, files ...*desc.FileDescriptor) jsonpb.AnyResolver { - return &anyResolver{mf: mf, files: files} -} - -type anyResolver struct { - mf *MessageFactory - files []*desc.FileDescriptor - ignored map[*desc.FileDescriptor]struct{} - other jsonpb.AnyResolver -} - -func wrapResolver(r jsonpb.AnyResolver, mf *MessageFactory, f *desc.FileDescriptor) (jsonpb.AnyResolver, bool) { - if r, ok := r.(*anyResolver); ok { - if _, ok := r.ignored[f]; ok { - // if the current resolver is ignoring this file, it's because another - // (upstream) resolver is already handling it, so nothing to do - return r, false - } - for _, file := range r.files { - if file == f { - // no need to wrap! - return r, false - } - } - // ignore files that will be checked by the resolver we're wrapping - // (we'll just delegate and let it search those files) - ignored := map[*desc.FileDescriptor]struct{}{} - for i := range r.ignored { - ignored[i] = struct{}{} - } - ignore(r.files, ignored) - return &anyResolver{mf: mf, files: []*desc.FileDescriptor{f}, ignored: ignored, other: r}, true - } - return &anyResolver{mf: mf, files: []*desc.FileDescriptor{f}, other: r}, true -} - -func ignore(files []*desc.FileDescriptor, ignored map[*desc.FileDescriptor]struct{}) { - for _, f := range files { - if _, ok := ignored[f]; ok { - continue - } - ignored[f] = struct{}{} - ignore(f.GetDependencies(), ignored) - } -} - -func (r *anyResolver) Resolve(typeUrl string) (proto.Message, error) { - mname := typeUrl - if slash := strings.LastIndex(mname, "/"); slash >= 0 { - mname = mname[slash+1:] - } - - // see if the user-specified resolver is able to do the job - if r.other != nil { - msg, err := r.other.Resolve(typeUrl) - if err == nil { - return msg, nil - } - } - - // try to find the message in our known set of files - checked := map[*desc.FileDescriptor]struct{}{} - for _, f := range r.files { - md := r.findMessage(f, mname, checked) - if md != nil { - return r.mf.NewMessage(md), nil - } - } - // failing that, see if the message factory knows about this type - var ktr *KnownTypeRegistry - if r.mf != nil { - ktr = r.mf.ktr - } else { - ktr = (*KnownTypeRegistry)(nil) - } - m := ktr.CreateIfKnown(mname) - if m != nil { - return m, nil - } - - // no other resolver to fallback to? mimic default behavior - mt := proto.MessageType(mname) - if mt == nil { - return nil, fmt.Errorf("unknown message type %q", mname) - } - return reflect.New(mt.Elem()).Interface().(proto.Message), nil -} - -func (r *anyResolver) findMessage(fd *desc.FileDescriptor, msgName string, checked map[*desc.FileDescriptor]struct{}) *desc.MessageDescriptor { - // if this is an ignored descriptor, skip - if _, ok := r.ignored[fd]; ok { - return nil - } - - // bail if we've already checked this file - if _, ok := checked[fd]; ok { - return nil - } - checked[fd] = struct{}{} - - // see if this file has the message - md := fd.FindMessage(msgName) - if md != nil { - return md - } - - // if not, recursively search the file's imports - for _, dep := range fd.GetDependencies() { - md = r.findMessage(dep, msgName, checked) - if md != nil { - return md - } - } - return nil -} - -var _ jsonpb.AnyResolver = (*anyResolver)(nil) diff --git a/vendor/github.com/jhump/protoreflect/dynamic/maps_1.11.go b/vendor/github.com/jhump/protoreflect/dynamic/maps_1.11.go deleted file mode 100644 index 03162a4de11..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/maps_1.11.go +++ /dev/null @@ -1,130 +0,0 @@ -//go:build !go1.12 -// +build !go1.12 - -package dynamic - -import ( - "github.com/jhump/protoreflect/desc" - "reflect" -) - -// Pre-Go-1.12, we must use reflect.Value.MapKeys to reflectively -// iterate a map. (We can be more efficient in Go 1.12 and up...) - -func mapsEqual(a, b reflect.Value) bool { - if a.Len() != b.Len() { - return false - } - if a.Len() == 0 && b.Len() == 0 { - // Optimize the case where maps are frequently empty because MapKeys() - // function allocates heavily. - return true - } - - for _, k := range a.MapKeys() { - av := a.MapIndex(k) - bv := b.MapIndex(k) - if !bv.IsValid() { - return false - } - if !fieldsEqual(av.Interface(), bv.Interface()) { - return false - } - } - return true -} - -func validFieldValueForMapField(fd *desc.FieldDescriptor, val reflect.Value) (interface{}, error) { - // make a defensive copy while we check the contents - // (also converts to map[interface{}]interface{} if it's some other type) - keyField := fd.GetMessageType().GetFields()[0] - valField := fd.GetMessageType().GetFields()[1] - m := map[interface{}]interface{}{} - for _, k := range val.MapKeys() { - if k.Kind() == reflect.Interface { - // unwrap it - k = reflect.ValueOf(k.Interface()) - } - kk, err := validElementFieldValueForRv(keyField, k, false) - if err != nil { - return nil, err - } - v := val.MapIndex(k) - if v.Kind() == reflect.Interface { - // unwrap it - v = reflect.ValueOf(v.Interface()) - } - vv, err := validElementFieldValueForRv(valField, v, true) - if err != nil { - return nil, err - } - m[kk] = vv - } - return m, nil -} - -func canConvertMap(src reflect.Value, target reflect.Type) bool { - kt := target.Key() - vt := target.Elem() - for _, k := range src.MapKeys() { - if !canConvert(k, kt) { - return false - } - if !canConvert(src.MapIndex(k), vt) { - return false - } - } - return true -} - -func mergeMapVal(src, target reflect.Value, targetType reflect.Type, deterministic bool) error { - tkt := targetType.Key() - tvt := targetType.Elem() - for _, k := range src.MapKeys() { - v := src.MapIndex(k) - skt := k.Type() - svt := v.Type() - var nk, nv reflect.Value - if tkt == skt { - nk = k - } else if tkt.Kind() == reflect.Ptr && tkt.Elem() == skt { - nk = k.Addr() - } else { - nk = reflect.New(tkt).Elem() - if err := mergeVal(k, nk, deterministic); err != nil { - return err - } - } - if tvt == svt { - nv = v - } else if tvt.Kind() == reflect.Ptr && tvt.Elem() == svt { - nv = v.Addr() - } else { - nv = reflect.New(tvt).Elem() - if err := mergeVal(v, nv, deterministic); err != nil { - return err - } - } - if target.IsNil() { - target.Set(reflect.MakeMap(targetType)) - } - target.SetMapIndex(nk, nv) - } - return nil -} - -func mergeMapField(m *Message, fd *desc.FieldDescriptor, rv reflect.Value) error { - for _, k := range rv.MapKeys() { - if k.Kind() == reflect.Interface && !k.IsNil() { - k = k.Elem() - } - v := rv.MapIndex(k) - if v.Kind() == reflect.Interface && !v.IsNil() { - v = v.Elem() - } - if err := m.putMapField(fd, k.Interface(), v.Interface()); err != nil { - return err - } - } - return nil -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/maps_1.12.go b/vendor/github.com/jhump/protoreflect/dynamic/maps_1.12.go deleted file mode 100644 index ef1b37050f6..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/maps_1.12.go +++ /dev/null @@ -1,138 +0,0 @@ -//go:build go1.12 -// +build go1.12 - -package dynamic - -import ( - "github.com/jhump/protoreflect/desc" - "reflect" -) - -// With Go 1.12 and above, we can use reflect.Value.MapRange to iterate -// over maps more efficiently than using reflect.Value.MapKeys. - -func mapsEqual(a, b reflect.Value) bool { - if a.Len() != b.Len() { - return false - } - if a.Len() == 0 && b.Len() == 0 { - // Optimize the case where maps are frequently empty - return true - } - - iter := a.MapRange() - for iter.Next() { - k := iter.Key() - av := iter.Value() - bv := b.MapIndex(k) - if !bv.IsValid() { - return false - } - if !fieldsEqual(av.Interface(), bv.Interface()) { - return false - } - } - return true -} - -func validFieldValueForMapField(fd *desc.FieldDescriptor, val reflect.Value) (interface{}, error) { - // make a defensive copy while we check the contents - // (also converts to map[interface{}]interface{} if it's some other type) - keyField := fd.GetMessageType().GetFields()[0] - valField := fd.GetMessageType().GetFields()[1] - m := map[interface{}]interface{}{} - iter := val.MapRange() - for iter.Next() { - k := iter.Key() - if k.Kind() == reflect.Interface { - // unwrap it - k = reflect.ValueOf(k.Interface()) - } - kk, err := validElementFieldValueForRv(keyField, k, false) - if err != nil { - return nil, err - } - v := iter.Value() - if v.Kind() == reflect.Interface { - // unwrap it - v = reflect.ValueOf(v.Interface()) - } - vv, err := validElementFieldValueForRv(valField, v, true) - if err != nil { - return nil, err - } - m[kk] = vv - } - return m, nil -} - -func canConvertMap(src reflect.Value, target reflect.Type) bool { - kt := target.Key() - vt := target.Elem() - iter := src.MapRange() - for iter.Next() { - if !canConvert(iter.Key(), kt) { - return false - } - if !canConvert(iter.Value(), vt) { - return false - } - } - return true -} - -func mergeMapVal(src, target reflect.Value, targetType reflect.Type, deterministic bool) error { - tkt := targetType.Key() - tvt := targetType.Elem() - iter := src.MapRange() - for iter.Next() { - k := iter.Key() - v := iter.Value() - skt := k.Type() - svt := v.Type() - var nk, nv reflect.Value - if tkt == skt { - nk = k - } else if tkt.Kind() == reflect.Ptr && tkt.Elem() == skt { - nk = k.Addr() - } else { - nk = reflect.New(tkt).Elem() - if err := mergeVal(k, nk, deterministic); err != nil { - return err - } - } - if tvt == svt { - nv = v - } else if tvt.Kind() == reflect.Ptr && tvt.Elem() == svt { - nv = v.Addr() - } else { - nv = reflect.New(tvt).Elem() - if err := mergeVal(v, nv, deterministic); err != nil { - return err - } - } - if target.IsNil() { - target.Set(reflect.MakeMap(targetType)) - } - target.SetMapIndex(nk, nv) - } - return nil -} - -func mergeMapField(m *Message, fd *desc.FieldDescriptor, rv reflect.Value) error { - iter := rv.MapRange() - for iter.Next() { - k := iter.Key() - v := iter.Value() - if k.Kind() == reflect.Interface && !k.IsNil() { - k = k.Elem() - } - if v.Kind() == reflect.Interface && !v.IsNil() { - v = v.Elem() - } - if err := m.putMapField(fd, k.Interface(), v.Interface()); err != nil { - return err - } - } - return nil -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/merge.go b/vendor/github.com/jhump/protoreflect/dynamic/merge.go deleted file mode 100644 index ce727fd57a7..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/merge.go +++ /dev/null @@ -1,100 +0,0 @@ -package dynamic - -import ( - "errors" - "reflect" - - "github.com/golang/protobuf/proto" - - "github.com/jhump/protoreflect/desc" -) - -// Merge merges the given source message into the given destination message. Use -// use this instead of proto.Merge when one or both of the messages might be a -// a dynamic message. If there is a problem merging the messages, such as the -// two messages having different types, then this method will panic (just as -// proto.Merges does). -func Merge(dst, src proto.Message) { - if dm, ok := dst.(*Message); ok { - if err := dm.MergeFrom(src); err != nil { - panic(err.Error()) - } - } else if dm, ok := src.(*Message); ok { - if err := dm.MergeInto(dst); err != nil { - panic(err.Error()) - } - } else { - proto.Merge(dst, src) - } -} - -// TryMerge merges the given source message into the given destination message. -// You can use this instead of proto.Merge when one or both of the messages -// might be a dynamic message. Unlike proto.Merge, this method will return an -// error on failure instead of panic'ing. -func TryMerge(dst, src proto.Message) error { - if dm, ok := dst.(*Message); ok { - if err := dm.MergeFrom(src); err != nil { - return err - } - } else if dm, ok := src.(*Message); ok { - if err := dm.MergeInto(dst); err != nil { - return err - } - } else { - // proto.Merge panics on bad input, so we first verify - // inputs and return error instead of panic - out := reflect.ValueOf(dst) - if out.IsNil() { - return errors.New("proto: nil destination") - } - in := reflect.ValueOf(src) - if in.Type() != out.Type() { - return errors.New("proto: type mismatch") - } - proto.Merge(dst, src) - } - return nil -} - -func mergeField(m *Message, fd *desc.FieldDescriptor, val interface{}) error { - rv := reflect.ValueOf(val) - - if fd.IsMap() && rv.Kind() == reflect.Map { - return mergeMapField(m, fd, rv) - } - - if fd.IsRepeated() && rv.Kind() == reflect.Slice && rv.Type() != typeOfBytes { - for i := 0; i < rv.Len(); i++ { - e := rv.Index(i) - if e.Kind() == reflect.Interface && !e.IsNil() { - e = e.Elem() - } - if err := m.addRepeatedField(fd, e.Interface()); err != nil { - return err - } - } - return nil - } - - if fd.IsRepeated() { - return m.addRepeatedField(fd, val) - } else if fd.GetMessageType() == nil { - return m.setField(fd, val) - } - - // it's a message type, so we want to merge contents - var err error - if val, err = validFieldValue(fd, val); err != nil { - return err - } - - existing, _ := m.doGetField(fd, true) - if existing != nil && !reflect.ValueOf(existing).IsNil() { - return TryMerge(existing.(proto.Message), val.(proto.Message)) - } - - // no existing message, so just set field - m.internalSetField(fd, val) - return nil -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/message_factory.go b/vendor/github.com/jhump/protoreflect/dynamic/message_factory.go deleted file mode 100644 index 683e7b334b8..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/message_factory.go +++ /dev/null @@ -1,207 +0,0 @@ -package dynamic - -import ( - "reflect" - "sync" - - "github.com/golang/protobuf/proto" - - "github.com/jhump/protoreflect/desc" -) - -// MessageFactory can be used to create new empty message objects. A default instance -// (without extension registry or known-type registry specified) will always return -// dynamic messages (e.g. type will be *dynamic.Message) except for "well-known" types. -// The well-known types include primitive wrapper types and a handful of other special -// types defined in standard protobuf definitions, like Any, Duration, and Timestamp. -type MessageFactory struct { - er *ExtensionRegistry - ktr *KnownTypeRegistry -} - -// NewMessageFactoryWithExtensionRegistry creates a new message factory where any -// dynamic messages produced will use the given extension registry to recognize and -// parse extension fields. -func NewMessageFactoryWithExtensionRegistry(er *ExtensionRegistry) *MessageFactory { - return NewMessageFactoryWithRegistries(er, nil) -} - -// NewMessageFactoryWithKnownTypeRegistry creates a new message factory where the -// known types, per the given registry, will be returned as normal protobuf messages -// (e.g. generated structs, instead of dynamic messages). -func NewMessageFactoryWithKnownTypeRegistry(ktr *KnownTypeRegistry) *MessageFactory { - return NewMessageFactoryWithRegistries(nil, ktr) -} - -// NewMessageFactoryWithDefaults creates a new message factory where all "default" types -// (those for which protoc-generated code is statically linked into the Go program) are -// known types. If any dynamic messages are produced, they will recognize and parse all -// "default" extension fields. This is the equivalent of: -// -// NewMessageFactoryWithRegistries( -// NewExtensionRegistryWithDefaults(), -// NewKnownTypeRegistryWithDefaults()) -func NewMessageFactoryWithDefaults() *MessageFactory { - return NewMessageFactoryWithRegistries(NewExtensionRegistryWithDefaults(), NewKnownTypeRegistryWithDefaults()) -} - -// NewMessageFactoryWithRegistries creates a new message factory with the given extension -// and known type registries. -func NewMessageFactoryWithRegistries(er *ExtensionRegistry, ktr *KnownTypeRegistry) *MessageFactory { - return &MessageFactory{ - er: er, - ktr: ktr, - } -} - -// NewMessage creates a new empty message that corresponds to the given descriptor. -// If the given descriptor describes a "known type" then that type is instantiated. -// Otherwise, an empty dynamic message is returned. -func (f *MessageFactory) NewMessage(md *desc.MessageDescriptor) proto.Message { - var ktr *KnownTypeRegistry - if f != nil { - ktr = f.ktr - } - if m := ktr.CreateIfKnown(md.GetFullyQualifiedName()); m != nil { - return m - } - return NewMessageWithMessageFactory(md, f) -} - -// NewDynamicMessage creates a new empty dynamic message that corresponds to the given -// descriptor. This is like f.NewMessage(md) except the known type registry is not -// consulted so the return value is always a dynamic message. -// -// This is also like dynamic.NewMessage(md) except that the returned message will use -// this factory when creating other messages, like during de-serialization of fields -// that are themselves message types. -func (f *MessageFactory) NewDynamicMessage(md *desc.MessageDescriptor) *Message { - return NewMessageWithMessageFactory(md, f) -} - -// GetKnownTypeRegistry returns the known type registry that this factory uses to -// instantiate known (e.g. generated) message types. -func (f *MessageFactory) GetKnownTypeRegistry() *KnownTypeRegistry { - if f == nil { - return nil - } - return f.ktr -} - -// GetExtensionRegistry returns the extension registry that this factory uses to -// create dynamic messages. The registry is used by dynamic messages to recognize -// and parse extension fields during de-serialization. -func (f *MessageFactory) GetExtensionRegistry() *ExtensionRegistry { - if f == nil { - return nil - } - return f.er -} - -type wkt interface { - XXX_WellKnownType() string -} - -var typeOfWkt = reflect.TypeOf((*wkt)(nil)).Elem() - -// KnownTypeRegistry is a registry of known message types, as identified by their -// fully-qualified name. A known message type is one for which a protoc-generated -// struct exists, so a dynamic message is not necessary to represent it. A -// MessageFactory uses a KnownTypeRegistry to decide whether to create a generated -// struct or a dynamic message. The zero-value registry (including the behavior of -// a nil pointer) only knows about the "well-known types" in protobuf. These -// include only the wrapper types and a handful of other special types like Any, -// Duration, and Timestamp. -type KnownTypeRegistry struct { - excludeWkt bool - includeDefault bool - mu sync.RWMutex - types map[string]reflect.Type -} - -// NewKnownTypeRegistryWithDefaults creates a new registry that knows about all -// "default" types (those for which protoc-generated code is statically linked -// into the Go program). -func NewKnownTypeRegistryWithDefaults() *KnownTypeRegistry { - return &KnownTypeRegistry{includeDefault: true} -} - -// NewKnownTypeRegistryWithoutWellKnownTypes creates a new registry that does *not* -// include the "well-known types" in protobuf. So even well-known types would be -// represented by a dynamic message. -func NewKnownTypeRegistryWithoutWellKnownTypes() *KnownTypeRegistry { - return &KnownTypeRegistry{excludeWkt: true} -} - -// AddKnownType adds the types of the given messages as known types. -func (r *KnownTypeRegistry) AddKnownType(kts ...proto.Message) { - r.mu.Lock() - defer r.mu.Unlock() - if r.types == nil { - r.types = map[string]reflect.Type{} - } - for _, kt := range kts { - r.types[proto.MessageName(kt)] = reflect.TypeOf(kt) - } -} - -// CreateIfKnown will construct an instance of the given message if it is a known type. -// If the given name is unknown, nil is returned. -func (r *KnownTypeRegistry) CreateIfKnown(messageName string) proto.Message { - msgType := r.GetKnownType(messageName) - if msgType == nil { - return nil - } - - if msgType.Kind() == reflect.Ptr { - return reflect.New(msgType.Elem()).Interface().(proto.Message) - } else { - return reflect.New(msgType).Elem().Interface().(proto.Message) - } -} - -func isWellKnownType(t reflect.Type) bool { - if t.Implements(typeOfWkt) { - return true - } - if msg, ok := reflect.Zero(t).Interface().(proto.Message); ok { - name := proto.MessageName(msg) - _, ok := wellKnownTypeNames[name] - return ok - } - return false -} - -// GetKnownType will return the reflect.Type for the given message name if it is -// known. If it is not known, nil is returned. -func (r *KnownTypeRegistry) GetKnownType(messageName string) reflect.Type { - if r == nil { - // a nil registry behaves the same as zero value instance: only know of well-known types - t := proto.MessageType(messageName) - if t != nil && isWellKnownType(t) { - return t - } - return nil - } - - if r.includeDefault { - t := proto.MessageType(messageName) - if t != nil && isMessage(t) { - return t - } - } else if !r.excludeWkt { - t := proto.MessageType(messageName) - if t != nil && isWellKnownType(t) { - return t - } - } - - r.mu.RLock() - defer r.mu.RUnlock() - return r.types[messageName] -} - -func isMessage(t reflect.Type) bool { - _, ok := reflect.Zero(t).Interface().(proto.Message) - return ok -} diff --git a/vendor/github.com/jhump/protoreflect/dynamic/text.go b/vendor/github.com/jhump/protoreflect/dynamic/text.go deleted file mode 100644 index 5784d3efd9e..00000000000 --- a/vendor/github.com/jhump/protoreflect/dynamic/text.go +++ /dev/null @@ -1,1177 +0,0 @@ -package dynamic - -// Marshalling and unmarshalling of dynamic messages to/from proto's standard text format - -import ( - "bytes" - "fmt" - "io" - "math" - "reflect" - "sort" - "strconv" - "strings" - "text/scanner" - "unicode" - - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/protoc-gen-go/descriptor" - - "github.com/jhump/protoreflect/codec" - "github.com/jhump/protoreflect/desc" -) - -// MarshalText serializes this message to bytes in the standard text format, -// returning an error if the operation fails. The resulting bytes will be a -// valid UTF8 string. -// -// This method uses a compact form: no newlines, and spaces between field -// identifiers and values are elided. -func (m *Message) MarshalText() ([]byte, error) { - var b indentBuffer - b.indentCount = -1 // no indentation - if err := m.marshalText(&b); err != nil { - return nil, err - } - return b.Bytes(), nil -} - -// MarshalTextIndent serializes this message to bytes in the standard text -// format, returning an error if the operation fails. The resulting bytes will -// be a valid UTF8 string. -// -// This method uses a "pretty-printed" form, with each field on its own line and -// spaces between field identifiers and values. -func (m *Message) MarshalTextIndent() ([]byte, error) { - var b indentBuffer - b.indent = " " // TODO: option for indent? - if err := m.marshalText(&b); err != nil { - return nil, err - } - return b.Bytes(), nil -} - -func (m *Message) marshalText(b *indentBuffer) error { - // TODO: option for emitting extended Any format? - first := true - // first the known fields - for _, tag := range m.knownFieldTags() { - itag := int32(tag) - v := m.values[itag] - fd := m.FindFieldDescriptor(itag) - if fd.IsMap() { - md := fd.GetMessageType() - kfd := md.FindFieldByNumber(1) - vfd := md.FindFieldByNumber(2) - mp := v.(map[interface{}]interface{}) - keys := make([]interface{}, 0, len(mp)) - for k := range mp { - keys = append(keys, k) - } - sort.Sort(sortable(keys)) - for _, mk := range keys { - mv := mp[mk] - err := b.maybeNext(&first) - if err != nil { - return err - } - err = marshalKnownFieldMapEntryText(b, fd, kfd, mk, vfd, mv) - if err != nil { - return err - } - } - } else if fd.IsRepeated() { - sl := v.([]interface{}) - for _, slv := range sl { - err := b.maybeNext(&first) - if err != nil { - return err - } - err = marshalKnownFieldText(b, fd, slv) - if err != nil { - return err - } - } - } else { - err := b.maybeNext(&first) - if err != nil { - return err - } - err = marshalKnownFieldText(b, fd, v) - if err != nil { - return err - } - } - } - // then the unknown fields - for _, tag := range m.unknownFieldTags() { - itag := int32(tag) - ufs := m.unknownFields[itag] - for _, uf := range ufs { - err := b.maybeNext(&first) - if err != nil { - return err - } - _, err = fmt.Fprintf(b, "%d", tag) - if err != nil { - return err - } - if uf.Encoding == proto.WireStartGroup { - err = b.WriteByte('{') - if err != nil { - return err - } - err = b.start() - if err != nil { - return err - } - in := codec.NewBuffer(uf.Contents) - err = marshalUnknownGroupText(b, in, true) - if err != nil { - return err - } - err = b.end() - if err != nil { - return err - } - err = b.WriteByte('}') - if err != nil { - return err - } - } else { - err = b.sep() - if err != nil { - return err - } - if uf.Encoding == proto.WireBytes { - err = writeString(b, string(uf.Contents)) - if err != nil { - return err - } - } else { - _, err = b.WriteString(strconv.FormatUint(uf.Value, 10)) - if err != nil { - return err - } - } - } - } - } - return nil -} - -func marshalKnownFieldMapEntryText(b *indentBuffer, fd *desc.FieldDescriptor, kfd *desc.FieldDescriptor, mk interface{}, vfd *desc.FieldDescriptor, mv interface{}) error { - var name string - if fd.IsExtension() { - name = fmt.Sprintf("[%s]", fd.GetFullyQualifiedName()) - } else { - name = fd.GetName() - } - _, err := b.WriteString(name) - if err != nil { - return err - } - err = b.sep() - if err != nil { - return err - } - - err = b.WriteByte('<') - if err != nil { - return err - } - err = b.start() - if err != nil { - return err - } - - err = marshalKnownFieldText(b, kfd, mk) - if err != nil { - return err - } - err = b.next() - if err != nil { - return err - } - if !isNil(mv) { - err = marshalKnownFieldText(b, vfd, mv) - if err != nil { - return err - } - } - - err = b.end() - if err != nil { - return err - } - return b.WriteByte('>') -} - -func marshalKnownFieldText(b *indentBuffer, fd *desc.FieldDescriptor, v interface{}) error { - group := fd.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP - if group { - var name string - if fd.IsExtension() { - name = fmt.Sprintf("[%s]", fd.GetMessageType().GetFullyQualifiedName()) - } else { - name = fd.GetMessageType().GetName() - } - _, err := b.WriteString(name) - if err != nil { - return err - } - } else { - var name string - if fd.IsExtension() { - name = fmt.Sprintf("[%s]", fd.GetFullyQualifiedName()) - } else { - name = fd.GetName() - } - _, err := b.WriteString(name) - if err != nil { - return err - } - err = b.sep() - if err != nil { - return err - } - } - rv := reflect.ValueOf(v) - switch rv.Kind() { - case reflect.Int32, reflect.Int64: - ed := fd.GetEnumType() - if ed != nil { - n := int32(rv.Int()) - vd := ed.FindValueByNumber(n) - if vd == nil { - _, err := b.WriteString(strconv.FormatInt(rv.Int(), 10)) - return err - } else { - _, err := b.WriteString(vd.GetName()) - return err - } - } else { - _, err := b.WriteString(strconv.FormatInt(rv.Int(), 10)) - return err - } - case reflect.Uint32, reflect.Uint64: - _, err := b.WriteString(strconv.FormatUint(rv.Uint(), 10)) - return err - case reflect.Float32, reflect.Float64: - f := rv.Float() - var str string - if math.IsNaN(f) { - str = "nan" - } else if math.IsInf(f, 1) { - str = "inf" - } else if math.IsInf(f, -1) { - str = "-inf" - } else { - var bits int - if rv.Kind() == reflect.Float32 { - bits = 32 - } else { - bits = 64 - } - str = strconv.FormatFloat(rv.Float(), 'g', -1, bits) - } - _, err := b.WriteString(str) - return err - case reflect.Bool: - _, err := b.WriteString(strconv.FormatBool(rv.Bool())) - return err - case reflect.Slice: - return writeString(b, string(rv.Bytes())) - case reflect.String: - return writeString(b, rv.String()) - default: - var err error - if group { - err = b.WriteByte('{') - } else { - err = b.WriteByte('<') - } - if err != nil { - return err - } - err = b.start() - if err != nil { - return err - } - // must be a message - if dm, ok := v.(*Message); ok { - err = dm.marshalText(b) - if err != nil { - return err - } - } else { - err = proto.CompactText(b, v.(proto.Message)) - if err != nil { - return err - } - } - err = b.end() - if err != nil { - return err - } - if group { - return b.WriteByte('}') - } else { - return b.WriteByte('>') - } - } -} - -// writeString writes a string in the protocol buffer text format. -// It is similar to strconv.Quote except we don't use Go escape sequences, -// we treat the string as a byte sequence, and we use octal escapes. -// These differences are to maintain interoperability with the other -// languages' implementations of the text format. -func writeString(b *indentBuffer, s string) error { - // use WriteByte here to get any needed indent - if err := b.WriteByte('"'); err != nil { - return err - } - // Loop over the bytes, not the runes. - for i := 0; i < len(s); i++ { - var err error - // Divergence from C++: we don't escape apostrophes. - // There's no need to escape them, and the C++ parser - // copes with a naked apostrophe. - switch c := s[i]; c { - case '\n': - _, err = b.WriteString("\\n") - case '\r': - _, err = b.WriteString("\\r") - case '\t': - _, err = b.WriteString("\\t") - case '"': - _, err = b.WriteString("\\\"") - case '\\': - _, err = b.WriteString("\\\\") - default: - if c >= 0x20 && c < 0x7f { - err = b.WriteByte(c) - } else { - _, err = fmt.Fprintf(b, "\\%03o", c) - } - } - if err != nil { - return err - } - } - return b.WriteByte('"') -} - -func marshalUnknownGroupText(b *indentBuffer, in *codec.Buffer, topLevel bool) error { - first := true - for { - if in.EOF() { - if topLevel { - return nil - } - // this is a nested message: we are expecting an end-group tag, not EOF! - return io.ErrUnexpectedEOF - } - tag, wireType, err := in.DecodeTagAndWireType() - if err != nil { - return err - } - if wireType == proto.WireEndGroup { - return nil - } - err = b.maybeNext(&first) - if err != nil { - return err - } - _, err = fmt.Fprintf(b, "%d", tag) - if err != nil { - return err - } - if wireType == proto.WireStartGroup { - err = b.WriteByte('{') - if err != nil { - return err - } - err = b.start() - if err != nil { - return err - } - err = marshalUnknownGroupText(b, in, false) - if err != nil { - return err - } - err = b.end() - if err != nil { - return err - } - err = b.WriteByte('}') - if err != nil { - return err - } - continue - } else { - err = b.sep() - if err != nil { - return err - } - if wireType == proto.WireBytes { - contents, err := in.DecodeRawBytes(false) - if err != nil { - return err - } - err = writeString(b, string(contents)) - if err != nil { - return err - } - } else { - var v uint64 - switch wireType { - case proto.WireVarint: - v, err = in.DecodeVarint() - case proto.WireFixed32: - v, err = in.DecodeFixed32() - case proto.WireFixed64: - v, err = in.DecodeFixed64() - default: - return proto.ErrInternalBadWireType - } - if err != nil { - return err - } - _, err = b.WriteString(strconv.FormatUint(v, 10)) - if err != nil { - return err - } - } - } - } -} - -// UnmarshalText de-serializes the message that is present, in text format, in -// the given bytes into this message. It first resets the current message. It -// returns an error if the given bytes do not contain a valid encoding of this -// message type in the standard text format -func (m *Message) UnmarshalText(text []byte) error { - m.Reset() - if err := m.UnmarshalMergeText(text); err != nil { - return err - } - return m.Validate() -} - -// UnmarshalMergeText de-serializes the message that is present, in text format, -// in the given bytes into this message. Unlike UnmarshalText, it does not first -// reset the message, instead merging the data in the given bytes into the -// existing data in this message. -func (m *Message) UnmarshalMergeText(text []byte) error { - return m.unmarshalText(newReader(text), tokenEOF) -} - -func (m *Message) unmarshalText(tr *txtReader, end tokenType) error { - for { - tok := tr.next() - if tok.tokTyp == end { - return nil - } - if tok.tokTyp == tokenEOF { - return io.ErrUnexpectedEOF - } - var fd *desc.FieldDescriptor - var extendedAnyType *desc.MessageDescriptor - if tok.tokTyp == tokenInt { - // tag number (indicates unknown field) - tag, err := strconv.ParseInt(tok.val.(string), 10, 32) - if err != nil { - return err - } - itag := int32(tag) - fd = m.FindFieldDescriptor(itag) - if fd == nil { - // can't parse the value w/out field descriptor, so skip it - tok = tr.next() - if tok.tokTyp == tokenEOF { - return io.ErrUnexpectedEOF - } else if tok.tokTyp == tokenOpenBrace { - if err := skipMessageText(tr, true); err != nil { - return err - } - } else if tok.tokTyp == tokenColon { - if err := skipFieldValueText(tr); err != nil { - return err - } - } else { - return textError(tok, "Expecting a colon ':' or brace '{'; instead got %q", tok.txt) - } - tok = tr.peek() - if tok.tokTyp.IsSep() { - tr.next() // consume separator - } - continue - } - } else { - fieldName, err := unmarshalFieldNameText(tr, tok) - if err != nil { - return err - } - fd = m.FindFieldDescriptorByName(fieldName) - if fd == nil { - // See if it's a group name - for _, field := range m.md.GetFields() { - if field.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP && field.GetMessageType().GetName() == fieldName { - fd = field - break - } - } - if fd == nil { - // maybe this is an extended Any - if m.md.GetFullyQualifiedName() == "google.protobuf.Any" && fieldName[0] == '[' && strings.Contains(fieldName, "/") { - // strip surrounding "[" and "]" and extract type name from URL - typeUrl := fieldName[1 : len(fieldName)-1] - mname := typeUrl - if slash := strings.LastIndex(mname, "/"); slash >= 0 { - mname = mname[slash+1:] - } - // TODO: add a way to weave an AnyResolver to this point - extendedAnyType = findMessageDescriptor(mname, m.md.GetFile()) - if extendedAnyType == nil { - return textError(tok, "could not parse Any with unknown type URL %q", fieldName) - } - // field 1 is "type_url" - typeUrlField := m.md.FindFieldByNumber(1) - if err := m.TrySetField(typeUrlField, typeUrl); err != nil { - return err - } - } else { - // TODO: add a flag to just ignore unrecognized field names - return textError(tok, "%q is not a recognized field name of %q", fieldName, m.md.GetFullyQualifiedName()) - } - } - } - } - tok = tr.next() - if tok.tokTyp == tokenEOF { - return io.ErrUnexpectedEOF - } - if extendedAnyType != nil { - // consume optional colon; make sure this is a "start message" token - if tok.tokTyp == tokenColon { - tok = tr.next() - if tok.tokTyp == tokenEOF { - return io.ErrUnexpectedEOF - } - } - if tok.tokTyp.EndToken() == tokenError { - return textError(tok, "Expecting a '<' or '{'; instead got %q", tok.txt) - } - - // TODO: use mf.NewMessage and, if not a dynamic message, use proto.UnmarshalText to unmarshal it - g := m.mf.NewDynamicMessage(extendedAnyType) - if err := g.unmarshalText(tr, tok.tokTyp.EndToken()); err != nil { - return err - } - // now we marshal the message to bytes and store in the Any - b, err := g.Marshal() - if err != nil { - return err - } - // field 2 is "value" - anyValueField := m.md.FindFieldByNumber(2) - if err := m.TrySetField(anyValueField, b); err != nil { - return err - } - - } else if (fd.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP || - fd.GetType() == descriptor.FieldDescriptorProto_TYPE_MESSAGE) && - tok.tokTyp.EndToken() != tokenError { - - // TODO: use mf.NewMessage and, if not a dynamic message, use proto.UnmarshalText to unmarshal it - g := m.mf.NewDynamicMessage(fd.GetMessageType()) - if err := g.unmarshalText(tr, tok.tokTyp.EndToken()); err != nil { - return err - } - if fd.IsRepeated() { - if err := m.TryAddRepeatedField(fd, g); err != nil { - return err - } - } else { - if err := m.TrySetField(fd, g); err != nil { - return err - } - } - } else { - if tok.tokTyp != tokenColon { - return textError(tok, "Expecting a colon ':'; instead got %q", tok.txt) - } - if err := m.unmarshalFieldValueText(fd, tr); err != nil { - return err - } - } - tok = tr.peek() - if tok.tokTyp.IsSep() { - tr.next() // consume separator - } - } -} -func findMessageDescriptor(name string, fd *desc.FileDescriptor) *desc.MessageDescriptor { - md := findMessageInTransitiveDeps(name, fd, map[*desc.FileDescriptor]struct{}{}) - if md == nil { - // couldn't find it; see if we have this message linked in - md, _ = desc.LoadMessageDescriptor(name) - } - return md -} - -func findMessageInTransitiveDeps(name string, fd *desc.FileDescriptor, seen map[*desc.FileDescriptor]struct{}) *desc.MessageDescriptor { - if _, ok := seen[fd]; ok { - // already checked this file - return nil - } - seen[fd] = struct{}{} - md := fd.FindMessage(name) - if md != nil { - return md - } - // not in this file so recursively search its deps - for _, dep := range fd.GetDependencies() { - md = findMessageInTransitiveDeps(name, dep, seen) - if md != nil { - return md - } - } - // couldn't find it - return nil -} - -func textError(tok *token, format string, args ...interface{}) error { - var msg string - if tok.tokTyp == tokenError { - msg = tok.val.(error).Error() - } else { - msg = fmt.Sprintf(format, args...) - } - return fmt.Errorf("line %d, col %d: %s", tok.pos.Line, tok.pos.Column, msg) -} - -type setFunction func(*Message, *desc.FieldDescriptor, interface{}) error - -func (m *Message) unmarshalFieldValueText(fd *desc.FieldDescriptor, tr *txtReader) error { - var set setFunction - if fd.IsRepeated() { - set = (*Message).addRepeatedField - } else { - set = mergeField - } - tok := tr.peek() - if tok.tokTyp == tokenOpenBracket { - tr.next() // consume tok - for { - if err := m.unmarshalFieldElementText(fd, tr, set); err != nil { - return err - } - tok = tr.peek() - if tok.tokTyp == tokenCloseBracket { - tr.next() // consume tok - return nil - } else if tok.tokTyp.IsSep() { - tr.next() // consume separator - } - } - } - return m.unmarshalFieldElementText(fd, tr, set) -} - -func (m *Message) unmarshalFieldElementText(fd *desc.FieldDescriptor, tr *txtReader, set setFunction) error { - tok := tr.next() - if tok.tokTyp == tokenEOF { - return io.ErrUnexpectedEOF - } - - var expected string - switch fd.GetType() { - case descriptor.FieldDescriptorProto_TYPE_BOOL: - if tok.tokTyp == tokenIdent { - if tok.val.(string) == "true" { - return set(m, fd, true) - } else if tok.val.(string) == "false" { - return set(m, fd, false) - } - } - expected = "boolean value" - case descriptor.FieldDescriptorProto_TYPE_BYTES: - if tok.tokTyp == tokenString { - return set(m, fd, []byte(tok.val.(string))) - } - expected = "bytes string value" - case descriptor.FieldDescriptorProto_TYPE_STRING: - if tok.tokTyp == tokenString { - return set(m, fd, tok.val) - } - expected = "string value" - case descriptor.FieldDescriptorProto_TYPE_FLOAT: - switch tok.tokTyp { - case tokenFloat: - return set(m, fd, float32(tok.val.(float64))) - case tokenInt: - if f, err := strconv.ParseFloat(tok.val.(string), 32); err != nil { - return err - } else { - return set(m, fd, float32(f)) - } - case tokenIdent: - ident := strings.ToLower(tok.val.(string)) - if ident == "inf" { - return set(m, fd, float32(math.Inf(1))) - } else if ident == "nan" { - return set(m, fd, float32(math.NaN())) - } - case tokenMinus: - peeked := tr.peek() - if peeked.tokTyp == tokenIdent { - ident := strings.ToLower(peeked.val.(string)) - if ident == "inf" { - tr.next() // consume peeked token - return set(m, fd, float32(math.Inf(-1))) - } - } - } - expected = "float value" - case descriptor.FieldDescriptorProto_TYPE_DOUBLE: - switch tok.tokTyp { - case tokenFloat: - return set(m, fd, tok.val) - case tokenInt: - if f, err := strconv.ParseFloat(tok.val.(string), 64); err != nil { - return err - } else { - return set(m, fd, f) - } - case tokenIdent: - ident := strings.ToLower(tok.val.(string)) - if ident == "inf" { - return set(m, fd, math.Inf(1)) - } else if ident == "nan" { - return set(m, fd, math.NaN()) - } - case tokenMinus: - peeked := tr.peek() - if peeked.tokTyp == tokenIdent { - ident := strings.ToLower(peeked.val.(string)) - if ident == "inf" { - tr.next() // consume peeked token - return set(m, fd, math.Inf(-1)) - } - } - } - expected = "float value" - case descriptor.FieldDescriptorProto_TYPE_INT32, - descriptor.FieldDescriptorProto_TYPE_SINT32, - descriptor.FieldDescriptorProto_TYPE_SFIXED32: - if tok.tokTyp == tokenInt { - if i, err := strconv.ParseInt(tok.val.(string), 10, 32); err != nil { - return err - } else { - return set(m, fd, int32(i)) - } - } - expected = "int value" - case descriptor.FieldDescriptorProto_TYPE_INT64, - descriptor.FieldDescriptorProto_TYPE_SINT64, - descriptor.FieldDescriptorProto_TYPE_SFIXED64: - if tok.tokTyp == tokenInt { - if i, err := strconv.ParseInt(tok.val.(string), 10, 64); err != nil { - return err - } else { - return set(m, fd, i) - } - } - expected = "int value" - case descriptor.FieldDescriptorProto_TYPE_UINT32, - descriptor.FieldDescriptorProto_TYPE_FIXED32: - if tok.tokTyp == tokenInt { - if i, err := strconv.ParseUint(tok.val.(string), 10, 32); err != nil { - return err - } else { - return set(m, fd, uint32(i)) - } - } - expected = "unsigned int value" - case descriptor.FieldDescriptorProto_TYPE_UINT64, - descriptor.FieldDescriptorProto_TYPE_FIXED64: - if tok.tokTyp == tokenInt { - if i, err := strconv.ParseUint(tok.val.(string), 10, 64); err != nil { - return err - } else { - return set(m, fd, i) - } - } - expected = "unsigned int value" - case descriptor.FieldDescriptorProto_TYPE_ENUM: - if tok.tokTyp == tokenIdent { - // TODO: add a flag to just ignore unrecognized enum value names? - vd := fd.GetEnumType().FindValueByName(tok.val.(string)) - if vd != nil { - return set(m, fd, vd.GetNumber()) - } - } else if tok.tokTyp == tokenInt { - if i, err := strconv.ParseInt(tok.val.(string), 10, 32); err != nil { - return err - } else { - return set(m, fd, int32(i)) - } - } - expected = fmt.Sprintf("enum %s value", fd.GetEnumType().GetFullyQualifiedName()) - case descriptor.FieldDescriptorProto_TYPE_MESSAGE, - descriptor.FieldDescriptorProto_TYPE_GROUP: - - endTok := tok.tokTyp.EndToken() - if endTok != tokenError { - dm := m.mf.NewDynamicMessage(fd.GetMessageType()) - if err := dm.unmarshalText(tr, endTok); err != nil { - return err - } - // TODO: ideally we would use mf.NewMessage and, if not a dynamic message, use - // proto package to unmarshal it. But the text parser isn't particularly amenable - // to that, so we instead convert a dynamic message to a generated one if the - // known-type registry knows about the generated type... - var ktr *KnownTypeRegistry - if m.mf != nil { - ktr = m.mf.ktr - } - pm := ktr.CreateIfKnown(fd.GetMessageType().GetFullyQualifiedName()) - if pm != nil { - if err := dm.ConvertTo(pm); err != nil { - return set(m, fd, pm) - } - } - return set(m, fd, dm) - } - expected = fmt.Sprintf("message %s value", fd.GetMessageType().GetFullyQualifiedName()) - default: - return fmt.Errorf("field %q of message %q has unrecognized type: %v", fd.GetFullyQualifiedName(), m.md.GetFullyQualifiedName(), fd.GetType()) - } - - // if we get here, token was wrong type; create error message - var article string - if strings.Contains("aieou", expected[0:1]) { - article = "an" - } else { - article = "a" - } - return textError(tok, "Expecting %s %s; got %q", article, expected, tok.txt) -} - -func unmarshalFieldNameText(tr *txtReader, tok *token) (string, error) { - if tok.tokTyp == tokenOpenBracket || tok.tokTyp == tokenOpenParen { - // extension name - var closeType tokenType - var closeChar string - if tok.tokTyp == tokenOpenBracket { - closeType = tokenCloseBracket - closeChar = "close bracket ']'" - } else { - closeType = tokenCloseParen - closeChar = "close paren ')'" - } - // must be followed by an identifier - idents := make([]string, 0, 1) - for { - tok = tr.next() - if tok.tokTyp == tokenEOF { - return "", io.ErrUnexpectedEOF - } else if tok.tokTyp != tokenIdent { - return "", textError(tok, "Expecting an identifier; instead got %q", tok.txt) - } - idents = append(idents, tok.val.(string)) - // and then close bracket/paren, or "/" to keep adding URL elements to name - tok = tr.next() - if tok.tokTyp == tokenEOF { - return "", io.ErrUnexpectedEOF - } else if tok.tokTyp == closeType { - break - } else if tok.tokTyp != tokenSlash { - return "", textError(tok, "Expecting a %s; instead got %q", closeChar, tok.txt) - } - } - return "[" + strings.Join(idents, "/") + "]", nil - } else if tok.tokTyp == tokenIdent { - // normal field name - return tok.val.(string), nil - } else { - return "", textError(tok, "Expecting an identifier or tag number; instead got %q", tok.txt) - } -} - -func skipFieldNameText(tr *txtReader) error { - tok := tr.next() - if tok.tokTyp == tokenEOF { - return io.ErrUnexpectedEOF - } else if tok.tokTyp == tokenInt || tok.tokTyp == tokenIdent { - return nil - } else { - _, err := unmarshalFieldNameText(tr, tok) - return err - } -} - -func skipFieldValueText(tr *txtReader) error { - tok := tr.peek() - if tok.tokTyp == tokenOpenBracket { - tr.next() // consume tok - for { - if err := skipFieldElementText(tr); err != nil { - return err - } - tok = tr.peek() - if tok.tokTyp == tokenCloseBracket { - tr.next() // consume tok - return nil - } else if tok.tokTyp.IsSep() { - tr.next() // consume separator - } - - } - } - return skipFieldElementText(tr) -} - -func skipFieldElementText(tr *txtReader) error { - tok := tr.next() - switch tok.tokTyp { - case tokenEOF: - return io.ErrUnexpectedEOF - case tokenInt, tokenFloat, tokenString, tokenIdent: - return nil - case tokenOpenAngle: - return skipMessageText(tr, false) - default: - return textError(tok, "Expecting an angle bracket '<' or a value; instead got %q", tok.txt) - } -} - -func skipMessageText(tr *txtReader, isGroup bool) error { - for { - tok := tr.peek() - if tok.tokTyp == tokenEOF { - return io.ErrUnexpectedEOF - } else if isGroup && tok.tokTyp == tokenCloseBrace { - return nil - } else if !isGroup && tok.tokTyp == tokenCloseAngle { - return nil - } - - // field name or tag - if err := skipFieldNameText(tr); err != nil { - return err - } - - // field value - tok = tr.next() - if tok.tokTyp == tokenEOF { - return io.ErrUnexpectedEOF - } else if tok.tokTyp == tokenOpenBrace { - if err := skipMessageText(tr, true); err != nil { - return err - } - } else if tok.tokTyp == tokenColon { - if err := skipFieldValueText(tr); err != nil { - return err - } - } else { - return textError(tok, "Expecting a colon ':' or brace '{'; instead got %q", tok.txt) - } - - tok = tr.peek() - if tok.tokTyp.IsSep() { - tr.next() // consume separator - } - } -} - -type tokenType int - -const ( - tokenError tokenType = iota - tokenEOF - tokenIdent - tokenString - tokenInt - tokenFloat - tokenColon - tokenComma - tokenSemiColon - tokenOpenBrace - tokenCloseBrace - tokenOpenBracket - tokenCloseBracket - tokenOpenAngle - tokenCloseAngle - tokenOpenParen - tokenCloseParen - tokenSlash - tokenMinus -) - -func (t tokenType) IsSep() bool { - return t == tokenComma || t == tokenSemiColon -} - -func (t tokenType) EndToken() tokenType { - switch t { - case tokenOpenAngle: - return tokenCloseAngle - case tokenOpenBrace: - return tokenCloseBrace - default: - return tokenError - } -} - -type token struct { - tokTyp tokenType - val interface{} - txt string - pos scanner.Position -} - -type txtReader struct { - scanner scanner.Scanner - peeked token - havePeeked bool -} - -func newReader(text []byte) *txtReader { - sc := scanner.Scanner{} - sc.Init(bytes.NewReader(text)) - sc.Mode = scanner.ScanIdents | scanner.ScanInts | scanner.ScanFloats | scanner.ScanChars | - scanner.ScanStrings | scanner.ScanComments | scanner.SkipComments - // identifiers are same restrictions as Go identifiers, except we also allow dots since - // we accept fully-qualified names - sc.IsIdentRune = func(ch rune, i int) bool { - return ch == '_' || unicode.IsLetter(ch) || - (i > 0 && unicode.IsDigit(ch)) || - (i > 0 && ch == '.') - } - // ignore errors; we handle them if/when we see malformed tokens - sc.Error = func(s *scanner.Scanner, msg string) {} - return &txtReader{scanner: sc} -} - -func (p *txtReader) peek() *token { - if p.havePeeked { - return &p.peeked - } - t := p.scanner.Scan() - if t == scanner.EOF { - p.peeked.tokTyp = tokenEOF - p.peeked.val = nil - p.peeked.txt = "" - p.peeked.pos = p.scanner.Position - } else if err := p.processToken(t, p.scanner.TokenText(), p.scanner.Position); err != nil { - p.peeked.tokTyp = tokenError - p.peeked.val = err - } - p.havePeeked = true - return &p.peeked -} - -func (p *txtReader) processToken(t rune, text string, pos scanner.Position) error { - p.peeked.pos = pos - p.peeked.txt = text - switch t { - case scanner.Ident: - p.peeked.tokTyp = tokenIdent - p.peeked.val = text - case scanner.Int: - p.peeked.tokTyp = tokenInt - p.peeked.val = text // can't parse the number because we don't know if it's signed or unsigned - case scanner.Float: - p.peeked.tokTyp = tokenFloat - var err error - if p.peeked.val, err = strconv.ParseFloat(text, 64); err != nil { - return err - } - case scanner.Char, scanner.String: - p.peeked.tokTyp = tokenString - var err error - if p.peeked.val, err = strconv.Unquote(text); err != nil { - return err - } - case '-': // unary minus, for negative ints and floats - ch := p.scanner.Peek() - if ch < '0' || ch > '9' { - p.peeked.tokTyp = tokenMinus - p.peeked.val = '-' - } else { - t := p.scanner.Scan() - if t == scanner.EOF { - return io.ErrUnexpectedEOF - } else if t == scanner.Float { - p.peeked.tokTyp = tokenFloat - text += p.scanner.TokenText() - p.peeked.txt = text - var err error - if p.peeked.val, err = strconv.ParseFloat(text, 64); err != nil { - p.peeked.pos = p.scanner.Position - return err - } - } else if t == scanner.Int { - p.peeked.tokTyp = tokenInt - text += p.scanner.TokenText() - p.peeked.txt = text - p.peeked.val = text // can't parse the number because we don't know if it's signed or unsigned - } else { - p.peeked.pos = p.scanner.Position - return fmt.Errorf("expecting an int or float but got %q", p.scanner.TokenText()) - } - } - case ':': - p.peeked.tokTyp = tokenColon - p.peeked.val = ':' - case ',': - p.peeked.tokTyp = tokenComma - p.peeked.val = ',' - case ';': - p.peeked.tokTyp = tokenSemiColon - p.peeked.val = ';' - case '{': - p.peeked.tokTyp = tokenOpenBrace - p.peeked.val = '{' - case '}': - p.peeked.tokTyp = tokenCloseBrace - p.peeked.val = '}' - case '<': - p.peeked.tokTyp = tokenOpenAngle - p.peeked.val = '<' - case '>': - p.peeked.tokTyp = tokenCloseAngle - p.peeked.val = '>' - case '[': - p.peeked.tokTyp = tokenOpenBracket - p.peeked.val = '[' - case ']': - p.peeked.tokTyp = tokenCloseBracket - p.peeked.val = ']' - case '(': - p.peeked.tokTyp = tokenOpenParen - p.peeked.val = '(' - case ')': - p.peeked.tokTyp = tokenCloseParen - p.peeked.val = ')' - case '/': - // only allowed to separate URL components in expanded Any format - p.peeked.tokTyp = tokenSlash - p.peeked.val = '/' - default: - return fmt.Errorf("invalid character: %c", t) - } - return nil -} - -func (p *txtReader) next() *token { - t := p.peek() - if t.tokTyp != tokenEOF && t.tokTyp != tokenError { - p.havePeeked = false - } - return t -} diff --git a/vendor/github.com/jhump/protoreflect/internal/codec/buffer.go b/vendor/github.com/jhump/protoreflect/internal/codec/buffer.go deleted file mode 100644 index 09f8849edeb..00000000000 --- a/vendor/github.com/jhump/protoreflect/internal/codec/buffer.go +++ /dev/null @@ -1,118 +0,0 @@ -package codec - -import ( - "fmt" - "io" -) - -// Buffer is a reader and a writer that wraps a slice of bytes and also -// provides API for decoding and encoding the protobuf binary format. -// -// Its operation is similar to that of a bytes.Buffer: writing pushes -// data to the end of the buffer while reading pops data from the head -// of the buffer. So the same buffer can be used to both read and write. -type Buffer struct { - buf []byte - index int - - // tmp is used when another byte slice is needed, such as when - // serializing messages, since we need to know the length before - // we can write the length prefix; by caching this, including - // after it is grown by serialization operations, we reduce the - // number of allocations needed - tmp []byte - - deterministic bool -} - -// NewBuffer creates a new buffer with the given slice of bytes as the -// buffer's initial contents. -func NewBuffer(buf []byte) *Buffer { - return &Buffer{buf: buf} -} - -// SetDeterministic sets this buffer to encode messages deterministically. This -// is useful for tests. But the overhead is non-zero, so it should not likely be -// used outside of tests. When true, map fields in a message must have their -// keys sorted before serialization to ensure deterministic output. Otherwise, -// values in a map field will be serialized in map iteration order. -func (cb *Buffer) SetDeterministic(deterministic bool) { - cb.deterministic = deterministic -} - -// IsDeterministic returns whether or not this buffer is configured to encode -// messages deterministically. -func (cb *Buffer) IsDeterministic() bool { - return cb.deterministic -} - -// Reset resets this buffer back to empty. Any subsequent writes/encodes -// to the buffer will allocate a new backing slice of bytes. -func (cb *Buffer) Reset() { - cb.buf = []byte(nil) - cb.index = 0 -} - -// Bytes returns the slice of bytes remaining in the buffer. Note that -// this does not perform a copy: if the contents of the returned slice -// are modified, the modifications will be visible to subsequent reads -// via the buffer. -func (cb *Buffer) Bytes() []byte { - return cb.buf[cb.index:] -} - -// String returns the remaining bytes in the buffer as a string. -func (cb *Buffer) String() string { - return string(cb.Bytes()) -} - -// EOF returns true if there are no more bytes remaining to read. -func (cb *Buffer) EOF() bool { - return cb.index >= len(cb.buf) -} - -// Skip attempts to skip the given number of bytes in the input. If -// the input has fewer bytes than the given count, io.ErrUnexpectedEOF -// is returned and the buffer is unchanged. Otherwise, the given number -// of bytes are skipped and nil is returned. -func (cb *Buffer) Skip(count int) error { - if count < 0 { - return fmt.Errorf("proto: bad byte length %d", count) - } - newIndex := cb.index + count - if newIndex < cb.index || newIndex > len(cb.buf) { - return io.ErrUnexpectedEOF - } - cb.index = newIndex - return nil -} - -// Len returns the remaining number of bytes in the buffer. -func (cb *Buffer) Len() int { - return len(cb.buf) - cb.index -} - -// Read implements the io.Reader interface. If there are no bytes -// remaining in the buffer, it will return 0, io.EOF. Otherwise, -// it reads max(len(dest), cb.Len()) bytes from input and copies -// them into dest. It returns the number of bytes copied and a nil -// error in this case. -func (cb *Buffer) Read(dest []byte) (int, error) { - if cb.index == len(cb.buf) { - return 0, io.EOF - } - copied := copy(dest, cb.buf[cb.index:]) - cb.index += copied - return copied, nil -} - -var _ io.Reader = (*Buffer)(nil) - -// Write implements the io.Writer interface. It always returns -// len(data), nil. -func (cb *Buffer) Write(data []byte) (int, error) { - cb.buf = append(cb.buf, data...) - return len(data), nil -} - -var _ io.Writer = (*Buffer)(nil) diff --git a/vendor/github.com/jhump/protoreflect/internal/codec/decode.go b/vendor/github.com/jhump/protoreflect/internal/codec/decode.go deleted file mode 100644 index a25f680f82c..00000000000 --- a/vendor/github.com/jhump/protoreflect/internal/codec/decode.go +++ /dev/null @@ -1,346 +0,0 @@ -package codec - -import ( - "errors" - "fmt" - "io" - "math" - - "github.com/golang/protobuf/proto" -) - -// ErrOverflow is returned when an integer is too large to be represented. -var ErrOverflow = errors.New("proto: integer overflow") - -// ErrBadWireType is returned when decoding a wire-type from a buffer that -// is not valid. -var ErrBadWireType = errors.New("proto: bad wiretype") - -func (cb *Buffer) decodeVarintSlow() (x uint64, err error) { - i := cb.index - l := len(cb.buf) - - for shift := uint(0); shift < 64; shift += 7 { - if i >= l { - err = io.ErrUnexpectedEOF - return - } - b := cb.buf[i] - i++ - x |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - cb.index = i - return - } - } - - // The number is too large to represent in a 64-bit value. - err = ErrOverflow - return -} - -// DecodeVarint reads a varint-encoded integer from the Buffer. -// This is the format for the -// int32, int64, uint32, uint64, bool, and enum -// protocol buffer types. -func (cb *Buffer) DecodeVarint() (uint64, error) { - i := cb.index - buf := cb.buf - - if i >= len(buf) { - return 0, io.ErrUnexpectedEOF - } else if buf[i] < 0x80 { - cb.index++ - return uint64(buf[i]), nil - } else if len(buf)-i < 10 { - return cb.decodeVarintSlow() - } - - var b uint64 - // we already checked the first byte - x := uint64(buf[i]) - 0x80 - i++ - - b = uint64(buf[i]) - i++ - x += b << 7 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 7 - - b = uint64(buf[i]) - i++ - x += b << 14 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 14 - - b = uint64(buf[i]) - i++ - x += b << 21 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 21 - - b = uint64(buf[i]) - i++ - x += b << 28 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 28 - - b = uint64(buf[i]) - i++ - x += b << 35 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 35 - - b = uint64(buf[i]) - i++ - x += b << 42 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 42 - - b = uint64(buf[i]) - i++ - x += b << 49 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 49 - - b = uint64(buf[i]) - i++ - x += b << 56 - if b&0x80 == 0 { - goto done - } - x -= 0x80 << 56 - - b = uint64(buf[i]) - i++ - x += b << 63 - if b&0x80 == 0 { - goto done - } - // x -= 0x80 << 63 // Always zero. - - return 0, ErrOverflow - -done: - cb.index = i - return x, nil -} - -// DecodeTagAndWireType decodes a field tag and wire type from input. -// This reads a varint and then extracts the two fields from the varint -// value read. -func (cb *Buffer) DecodeTagAndWireType() (tag int32, wireType int8, err error) { - var v uint64 - v, err = cb.DecodeVarint() - if err != nil { - return - } - // low 7 bits is wire type - wireType = int8(v & 7) - // rest is int32 tag number - v = v >> 3 - if v > math.MaxInt32 { - err = fmt.Errorf("tag number out of range: %d", v) - return - } - tag = int32(v) - return -} - -// DecodeFixed64 reads a 64-bit integer from the Buffer. -// This is the format for the -// fixed64, sfixed64, and double protocol buffer types. -func (cb *Buffer) DecodeFixed64() (x uint64, err error) { - // x, err already 0 - i := cb.index + 8 - if i < 0 || i > len(cb.buf) { - err = io.ErrUnexpectedEOF - return - } - cb.index = i - - x = uint64(cb.buf[i-8]) - x |= uint64(cb.buf[i-7]) << 8 - x |= uint64(cb.buf[i-6]) << 16 - x |= uint64(cb.buf[i-5]) << 24 - x |= uint64(cb.buf[i-4]) << 32 - x |= uint64(cb.buf[i-3]) << 40 - x |= uint64(cb.buf[i-2]) << 48 - x |= uint64(cb.buf[i-1]) << 56 - return -} - -// DecodeFixed32 reads a 32-bit integer from the Buffer. -// This is the format for the -// fixed32, sfixed32, and float protocol buffer types. -func (cb *Buffer) DecodeFixed32() (x uint64, err error) { - // x, err already 0 - i := cb.index + 4 - if i < 0 || i > len(cb.buf) { - err = io.ErrUnexpectedEOF - return - } - cb.index = i - - x = uint64(cb.buf[i-4]) - x |= uint64(cb.buf[i-3]) << 8 - x |= uint64(cb.buf[i-2]) << 16 - x |= uint64(cb.buf[i-1]) << 24 - return -} - -// DecodeRawBytes reads a count-delimited byte buffer from the Buffer. -// This is the format used for the bytes protocol buffer -// type and for embedded messages. -func (cb *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) { - n, err := cb.DecodeVarint() - if err != nil { - return nil, err - } - - nb := int(n) - if nb < 0 { - return nil, fmt.Errorf("proto: bad byte length %d", nb) - } - end := cb.index + nb - if end < cb.index || end > len(cb.buf) { - return nil, io.ErrUnexpectedEOF - } - - if !alloc { - buf = cb.buf[cb.index:end] - cb.index = end - return - } - - buf = make([]byte, nb) - copy(buf, cb.buf[cb.index:]) - cb.index = end - return -} - -// ReadGroup reads the input until a "group end" tag is found -// and returns the data up to that point. Subsequent reads from -// the buffer will read data after the group end tag. If alloc -// is true, the data is copied to a new slice before being returned. -// Otherwise, the returned slice is a view into the buffer's -// underlying byte slice. -// -// This function correctly handles nested groups: if a "group start" -// tag is found, then that group's end tag will be included in the -// returned data. -func (cb *Buffer) ReadGroup(alloc bool) ([]byte, error) { - var groupEnd, dataEnd int - groupEnd, dataEnd, err := cb.findGroupEnd() - if err != nil { - return nil, err - } - var results []byte - if !alloc { - results = cb.buf[cb.index:dataEnd] - } else { - results = make([]byte, dataEnd-cb.index) - copy(results, cb.buf[cb.index:]) - } - cb.index = groupEnd - return results, nil -} - -// SkipGroup is like ReadGroup, except that it discards the -// data and just advances the buffer to point to the input -// right *after* the "group end" tag. -func (cb *Buffer) SkipGroup() error { - groupEnd, _, err := cb.findGroupEnd() - if err != nil { - return err - } - cb.index = groupEnd - return nil -} - -// SkipField attempts to skip the value of a field with the given wire -// type. When consuming a protobuf-encoded stream, it can be called immediately -// after DecodeTagAndWireType to discard the subsequent data for the field. -func (cb *Buffer) SkipField(wireType int8) error { - switch wireType { - case proto.WireFixed32: - if err := cb.Skip(4); err != nil { - return err - } - case proto.WireFixed64: - if err := cb.Skip(8); err != nil { - return err - } - case proto.WireVarint: - // skip varint by finding last byte (has high bit unset) - i := cb.index - limit := i + 10 // varint cannot be >10 bytes - for { - if i >= limit { - return ErrOverflow - } - if i >= len(cb.buf) { - return io.ErrUnexpectedEOF - } - if cb.buf[i]&0x80 == 0 { - break - } - i++ - } - // TODO: This would only overflow if buffer length was MaxInt and we - // read the last byte. This is not a real/feasible concern on 64-bit - // systems. Something to worry about for 32-bit systems? Do we care? - cb.index = i + 1 - case proto.WireBytes: - l, err := cb.DecodeVarint() - if err != nil { - return err - } - if err := cb.Skip(int(l)); err != nil { - return err - } - case proto.WireStartGroup: - if err := cb.SkipGroup(); err != nil { - return err - } - default: - return ErrBadWireType - } - return nil -} - -func (cb *Buffer) findGroupEnd() (groupEnd int, dataEnd int, err error) { - start := cb.index - defer func() { - cb.index = start - }() - for { - fieldStart := cb.index - // read a field tag - _, wireType, err := cb.DecodeTagAndWireType() - if err != nil { - return 0, 0, err - } - if wireType == proto.WireEndGroup { - return cb.index, fieldStart, nil - } - // skip past the field's data - if err := cb.SkipField(wireType); err != nil { - return 0, 0, err - } - } -} diff --git a/vendor/github.com/jhump/protoreflect/internal/codec/encode.go b/vendor/github.com/jhump/protoreflect/internal/codec/encode.go deleted file mode 100644 index 524f1bcbe0c..00000000000 --- a/vendor/github.com/jhump/protoreflect/internal/codec/encode.go +++ /dev/null @@ -1,147 +0,0 @@ -package codec - -import ( - "github.com/golang/protobuf/proto" -) - -// EncodeVarint writes a varint-encoded integer to the Buffer. -// This is the format for the -// int32, int64, uint32, uint64, bool, and enum -// protocol buffer types. -func (cb *Buffer) EncodeVarint(x uint64) error { - for x >= 1<<7 { - cb.buf = append(cb.buf, uint8(x&0x7f|0x80)) - x >>= 7 - } - cb.buf = append(cb.buf, uint8(x)) - return nil -} - -// EncodeTagAndWireType encodes the given field tag and wire type to the -// buffer. This combines the two values and then writes them as a varint. -func (cb *Buffer) EncodeTagAndWireType(tag int32, wireType int8) error { - v := uint64((int64(tag) << 3) | int64(wireType)) - return cb.EncodeVarint(v) -} - -// EncodeFixed64 writes a 64-bit integer to the Buffer. -// This is the format for the -// fixed64, sfixed64, and double protocol buffer types. -func (cb *Buffer) EncodeFixed64(x uint64) error { - cb.buf = append(cb.buf, - uint8(x), - uint8(x>>8), - uint8(x>>16), - uint8(x>>24), - uint8(x>>32), - uint8(x>>40), - uint8(x>>48), - uint8(x>>56)) - return nil -} - -// EncodeFixed32 writes a 32-bit integer to the Buffer. -// This is the format for the -// fixed32, sfixed32, and float protocol buffer types. -func (cb *Buffer) EncodeFixed32(x uint64) error { - cb.buf = append(cb.buf, - uint8(x), - uint8(x>>8), - uint8(x>>16), - uint8(x>>24)) - return nil -} - -// EncodeRawBytes writes a count-delimited byte buffer to the Buffer. -// This is the format used for the bytes protocol buffer -// type and for embedded messages. -func (cb *Buffer) EncodeRawBytes(b []byte) error { - if err := cb.EncodeVarint(uint64(len(b))); err != nil { - return err - } - cb.buf = append(cb.buf, b...) - return nil -} - -// EncodeMessage writes the given message to the buffer. -func (cb *Buffer) EncodeMessage(pm proto.Message) error { - bytes, err := marshalMessage(cb.buf, pm, cb.deterministic) - if err != nil { - return err - } - cb.buf = bytes - return nil -} - -// EncodeDelimitedMessage writes the given message to the buffer with a -// varint-encoded length prefix (the delimiter). -func (cb *Buffer) EncodeDelimitedMessage(pm proto.Message) error { - bytes, err := marshalMessage(cb.tmp, pm, cb.deterministic) - if err != nil { - return err - } - // save truncated buffer if it was grown (so we can re-use it and - // curtail future allocations) - if cap(bytes) > cap(cb.tmp) { - cb.tmp = bytes[:0] - } - return cb.EncodeRawBytes(bytes) -} - -func marshalMessage(b []byte, pm proto.Message, deterministic bool) ([]byte, error) { - // We try to use the most efficient way to marshal to existing slice. - - if deterministic { - // see if the message has custom deterministic methods, preferring an - // "append" method over one that must always re-allocate - madm, ok := pm.(interface { - MarshalAppendDeterministic(b []byte) ([]byte, error) - }) - if ok { - return madm.MarshalAppendDeterministic(b) - } - - mdm, ok := pm.(interface { - MarshalDeterministic() ([]byte, error) - }) - if ok { - bytes, err := mdm.MarshalDeterministic() - if err != nil { - return nil, err - } - if len(b) == 0 { - return bytes, nil - } - return append(b, bytes...), nil - } - - var buf proto.Buffer - buf.SetDeterministic(true) - if err := buf.Marshal(pm); err != nil { - return nil, err - } - bytes := buf.Bytes() - if len(b) == 0 { - return bytes, nil - } - return append(b, bytes...), nil - } - - mam, ok := pm.(interface { - // see if we can append the message, vs. having to re-allocate - MarshalAppend(b []byte) ([]byte, error) - }) - if ok { - return mam.MarshalAppend(b) - } - - // lowest common denominator - bytes, err := proto.Marshal(pm) - if err != nil { - return nil, err - } - if len(b) == 0 { - return bytes, nil - } - return append(b, bytes...), nil -} diff --git a/vendor/github.com/jhump/protoreflect/internal/standard_files.go b/vendor/github.com/jhump/protoreflect/internal/standard_files.go index 4a8b47a93f4..777c3a43a8c 100644 --- a/vendor/github.com/jhump/protoreflect/internal/standard_files.go +++ b/vendor/github.com/jhump/protoreflect/internal/standard_files.go @@ -9,7 +9,7 @@ import ( "io/ioutil" "github.com/golang/protobuf/proto" - dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" + "google.golang.org/protobuf/types/descriptorpb" ) // TODO: replace this alias configuration with desc.RegisterImportPath? @@ -68,7 +68,7 @@ func (e ErrNoSuchFile) Error() string { // name cannot be loaded but is a known standard name, an alias will be tried, // so the standard files can be loaded even if linked against older "known bad" // versions of packages. -func LoadFileDescriptor(file string) (*dpb.FileDescriptorProto, error) { +func LoadFileDescriptor(file string) (*descriptorpb.FileDescriptorProto, error) { fdb := proto.FileDescriptor(file) aliased := false if fdb == nil { @@ -102,12 +102,12 @@ func LoadFileDescriptor(file string) (*dpb.FileDescriptorProto, error) { // Registered file descriptors are first "proto encoded" (e.g. binary format // for the descriptor protos) and then gzipped. So this function gunzips and // then unmarshals into a descriptor proto. -func DecodeFileDescriptor(element string, fdb []byte) (*dpb.FileDescriptorProto, error) { +func DecodeFileDescriptor(element string, fdb []byte) (*descriptorpb.FileDescriptorProto, error) { raw, err := decompress(fdb) if err != nil { return nil, fmt.Errorf("failed to decompress %q descriptor: %v", element, err) } - fd := dpb.FileDescriptorProto{} + fd := descriptorpb.FileDescriptorProto{} if err := proto.Unmarshal(raw, &fd); err != nil { return nil, fmt.Errorf("bad descriptor for %q: %v", element, err) } diff --git a/vendor/github.com/jhump/protoreflect/internal/unrecognized.go b/vendor/github.com/jhump/protoreflect/internal/unrecognized.go index e4cda55520f..25376c7b8c1 100644 --- a/vendor/github.com/jhump/protoreflect/internal/unrecognized.go +++ b/vendor/github.com/jhump/protoreflect/internal/unrecognized.go @@ -1,41 +1,20 @@ package internal import ( - "reflect" - "github.com/golang/protobuf/proto" ) -var typeOfBytes = reflect.TypeOf([]byte(nil)) - // GetUnrecognized fetches the bytes of unrecognized fields for the given message. func GetUnrecognized(msg proto.Message) []byte { - val := reflect.Indirect(reflect.ValueOf(msg)) - u := val.FieldByName("XXX_unrecognized") - if u.IsValid() && u.Type() == typeOfBytes { - return u.Interface().([]byte) - } - // if we didn't get it from the field, try using V2 API to get it return proto.MessageReflect(msg).GetUnknown() } // SetUnrecognized adds the given bytes to the unrecognized fields for the given message. func SetUnrecognized(msg proto.Message, data []byte) { - val := reflect.Indirect(reflect.ValueOf(msg)) - u := val.FieldByName("XXX_unrecognized") - if u.IsValid() && u.Type() == typeOfBytes { - // Just store the bytes in the unrecognized field - ub := u.Interface().([]byte) - ub = append(ub, data...) - u.Set(reflect.ValueOf(ub)) - return - } - - // if we can't set the field, try using V2 API to get it - mr := proto.MessageReflect(msg) - existing := mr.GetUnknown() + refl := proto.MessageReflect(msg) + existing := refl.GetUnknown() if len(existing) > 0 { data = append(existing, data...) } - mr.SetUnknown(data) + refl.SetUnknown(data) } diff --git a/vendor/golang.org/x/sync/LICENSE b/vendor/golang.org/x/sync/LICENSE new file mode 100644 index 00000000000..6a66aea5eaf --- /dev/null +++ b/vendor/golang.org/x/sync/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/sync/PATENTS b/vendor/golang.org/x/sync/PATENTS new file mode 100644 index 00000000000..733099041f8 --- /dev/null +++ b/vendor/golang.org/x/sync/PATENTS @@ -0,0 +1,22 @@ +Additional IP Rights Grant (Patents) + +"This implementation" means the copyrightable works distributed by +Google as part of the Go project. + +Google hereby grants to You a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable (except as stated in this section) +patent license to make, have made, use, offer to sell, sell, import, +transfer and otherwise run, modify and propagate the contents of this +implementation of Go, where such license applies only to those patent +claims, both currently owned or controlled by Google and acquired in +the future, licensable by Google that are necessarily infringed by this +implementation of Go. This grant does not include claims that would be +infringed only as a consequence of further modification of this +implementation. If you or your agent or exclusive licensee institute or +order or agree to the institution of patent litigation against any +entity (including a cross-claim or counterclaim in a lawsuit) alleging +that this implementation of Go or any code incorporated within this +implementation of Go constitutes direct or contributory patent +infringement, or inducement of patent infringement, then any patent +rights granted to you under this License for this implementation of Go +shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/sync/semaphore/semaphore.go b/vendor/golang.org/x/sync/semaphore/semaphore.go new file mode 100644 index 00000000000..30f632c577b --- /dev/null +++ b/vendor/golang.org/x/sync/semaphore/semaphore.go @@ -0,0 +1,136 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package semaphore provides a weighted semaphore implementation. +package semaphore // import "golang.org/x/sync/semaphore" + +import ( + "container/list" + "context" + "sync" +) + +type waiter struct { + n int64 + ready chan<- struct{} // Closed when semaphore acquired. +} + +// NewWeighted creates a new weighted semaphore with the given +// maximum combined weight for concurrent access. +func NewWeighted(n int64) *Weighted { + w := &Weighted{size: n} + return w +} + +// Weighted provides a way to bound concurrent access to a resource. +// The callers can request access with a given weight. +type Weighted struct { + size int64 + cur int64 + mu sync.Mutex + waiters list.List +} + +// Acquire acquires the semaphore with a weight of n, blocking until resources +// are available or ctx is done. On success, returns nil. On failure, returns +// ctx.Err() and leaves the semaphore unchanged. +// +// If ctx is already done, Acquire may still succeed without blocking. +func (s *Weighted) Acquire(ctx context.Context, n int64) error { + s.mu.Lock() + if s.size-s.cur >= n && s.waiters.Len() == 0 { + s.cur += n + s.mu.Unlock() + return nil + } + + if n > s.size { + // Don't make other Acquire calls block on one that's doomed to fail. + s.mu.Unlock() + <-ctx.Done() + return ctx.Err() + } + + ready := make(chan struct{}) + w := waiter{n: n, ready: ready} + elem := s.waiters.PushBack(w) + s.mu.Unlock() + + select { + case <-ctx.Done(): + err := ctx.Err() + s.mu.Lock() + select { + case <-ready: + // Acquired the semaphore after we were canceled. Rather than trying to + // fix up the queue, just pretend we didn't notice the cancelation. + err = nil + default: + isFront := s.waiters.Front() == elem + s.waiters.Remove(elem) + // If we're at the front and there're extra tokens left, notify other waiters. + if isFront && s.size > s.cur { + s.notifyWaiters() + } + } + s.mu.Unlock() + return err + + case <-ready: + return nil + } +} + +// TryAcquire acquires the semaphore with a weight of n without blocking. +// On success, returns true. On failure, returns false and leaves the semaphore unchanged. +func (s *Weighted) TryAcquire(n int64) bool { + s.mu.Lock() + success := s.size-s.cur >= n && s.waiters.Len() == 0 + if success { + s.cur += n + } + s.mu.Unlock() + return success +} + +// Release releases the semaphore with a weight of n. +func (s *Weighted) Release(n int64) { + s.mu.Lock() + s.cur -= n + if s.cur < 0 { + s.mu.Unlock() + panic("semaphore: released more than held") + } + s.notifyWaiters() + s.mu.Unlock() +} + +func (s *Weighted) notifyWaiters() { + for { + next := s.waiters.Front() + if next == nil { + break // No more waiters blocked. + } + + w := next.Value.(waiter) + if s.size-s.cur < w.n { + // Not enough tokens for the next waiter. We could keep going (to try to + // find a waiter with a smaller request), but under load that could cause + // starvation for large requests; instead, we leave all remaining waiters + // blocked. + // + // Consider a semaphore used as a read-write lock, with N tokens, N + // readers, and one writer. Each reader can Acquire(1) to obtain a read + // lock. The writer can Acquire(N) to obtain a write lock, excluding all + // of the readers. If we allow the readers to jump ahead in the queue, + // the writer will starve — there is always one token available for every + // reader. + break + } + + s.cur += w.n + s.waiters.Remove(next) + close(w.ready) + } +} diff --git a/vendor/google.golang.org/genproto/protobuf/field_mask/field_mask.go b/vendor/google.golang.org/genproto/protobuf/field_mask/field_mask.go deleted file mode 100644 index d10ad665333..00000000000 --- a/vendor/google.golang.org/genproto/protobuf/field_mask/field_mask.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package field_mask aliases all exported identifiers in -// package "google.golang.org/protobuf/types/known/fieldmaskpb". -package field_mask - -import "google.golang.org/protobuf/types/known/fieldmaskpb" - -type FieldMask = fieldmaskpb.FieldMask - -var File_google_protobuf_field_mask_proto = fieldmaskpb.File_google_protobuf_field_mask_proto diff --git a/vendor/google.golang.org/genproto/protobuf/ptype/type.go b/vendor/google.golang.org/genproto/protobuf/ptype/type.go deleted file mode 100644 index 2c49be99aec..00000000000 --- a/vendor/google.golang.org/genproto/protobuf/ptype/type.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package ptype aliases all exported identifiers in -// package "google.golang.org/protobuf/types/known/typepb". -package ptype - -import "google.golang.org/protobuf/types/known/typepb" - -type Syntax = typepb.Syntax - -const ( - Syntax_SYNTAX_PROTO2 = typepb.Syntax_SYNTAX_PROTO2 - Syntax_SYNTAX_PROTO3 = typepb.Syntax_SYNTAX_PROTO3 -) - -var ( - Syntax_name = typepb.Syntax_name - Syntax_value = typepb.Syntax_value -) - -type Field_Kind = typepb.Field_Kind - -const ( - Field_TYPE_UNKNOWN = typepb.Field_TYPE_UNKNOWN - Field_TYPE_DOUBLE = typepb.Field_TYPE_DOUBLE - Field_TYPE_FLOAT = typepb.Field_TYPE_FLOAT - Field_TYPE_INT64 = typepb.Field_TYPE_INT64 - Field_TYPE_UINT64 = typepb.Field_TYPE_UINT64 - Field_TYPE_INT32 = typepb.Field_TYPE_INT32 - Field_TYPE_FIXED64 = typepb.Field_TYPE_FIXED64 - Field_TYPE_FIXED32 = typepb.Field_TYPE_FIXED32 - Field_TYPE_BOOL = typepb.Field_TYPE_BOOL - Field_TYPE_STRING = typepb.Field_TYPE_STRING - Field_TYPE_GROUP = typepb.Field_TYPE_GROUP - Field_TYPE_MESSAGE = typepb.Field_TYPE_MESSAGE - Field_TYPE_BYTES = typepb.Field_TYPE_BYTES - Field_TYPE_UINT32 = typepb.Field_TYPE_UINT32 - Field_TYPE_ENUM = typepb.Field_TYPE_ENUM - Field_TYPE_SFIXED32 = typepb.Field_TYPE_SFIXED32 - Field_TYPE_SFIXED64 = typepb.Field_TYPE_SFIXED64 - Field_TYPE_SINT32 = typepb.Field_TYPE_SINT32 - Field_TYPE_SINT64 = typepb.Field_TYPE_SINT64 -) - -var ( - Field_Kind_name = typepb.Field_Kind_name - Field_Kind_value = typepb.Field_Kind_value -) - -type Field_Cardinality = typepb.Field_Cardinality - -const ( - Field_CARDINALITY_UNKNOWN = typepb.Field_CARDINALITY_UNKNOWN - Field_CARDINALITY_OPTIONAL = typepb.Field_CARDINALITY_OPTIONAL - Field_CARDINALITY_REQUIRED = typepb.Field_CARDINALITY_REQUIRED - Field_CARDINALITY_REPEATED = typepb.Field_CARDINALITY_REPEATED -) - -var ( - Field_Cardinality_name = typepb.Field_Cardinality_name - Field_Cardinality_value = typepb.Field_Cardinality_value -) - -type Type = typepb.Type -type Field = typepb.Field -type Enum = typepb.Enum -type EnumValue = typepb.EnumValue -type Option = typepb.Option - -var File_google_protobuf_type_proto = typepb.File_google_protobuf_type_proto diff --git a/vendor/google.golang.org/genproto/protobuf/source_context/source_context.go b/vendor/google.golang.org/genproto/protobuf/source_context/source_context.go deleted file mode 100644 index 3f31da92f40..00000000000 --- a/vendor/google.golang.org/genproto/protobuf/source_context/source_context.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package source_context aliases all exported identifiers in -// package "google.golang.org/protobuf/types/known/sourcecontextpb". -package source_context - -import "google.golang.org/protobuf/types/known/sourcecontextpb" - -type SourceContext = sourcecontextpb.SourceContext - -var File_google_protobuf_source_context_proto = sourcecontextpb.File_google_protobuf_source_context_proto diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go b/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go index c85f8469480..6c37d417449 100644 --- a/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go +++ b/vendor/google.golang.org/protobuf/encoding/protojson/well_known_types.go @@ -814,16 +814,22 @@ func (d decoder) unmarshalTimestamp(m protoreflect.Message) error { return d.unexpectedTokenError(tok) } - t, err := time.Parse(time.RFC3339Nano, tok.ParsedString()) + s := tok.ParsedString() + t, err := time.Parse(time.RFC3339Nano, s) if err != nil { return d.newError(tok.Pos(), "invalid %v value %v", genid.Timestamp_message_fullname, tok.RawString()) } - // Validate seconds. No need to validate nanos because time.Parse would have - // covered that already. + // Validate seconds. secs := t.Unix() if secs < minTimestampSeconds || secs > maxTimestampSeconds { return d.newError(tok.Pos(), "%v value out of range: %v", genid.Timestamp_message_fullname, tok.RawString()) } + // Validate subseconds. + i := strings.LastIndexByte(s, '.') // start of subsecond field + j := strings.LastIndexAny(s, "Z-+") // start of timezone field + if i >= 0 && j >= i && j-i > len(".999999999") { + return d.newError(tok.Pos(), "invalid %v value %v", genid.Timestamp_message_fullname, tok.RawString()) + } fds := m.Descriptor().Fields() fdSeconds := fds.ByNumber(genid.Timestamp_Seconds_field_number) diff --git a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go index e3cdf1c2059..e7e65f5098b 100644 --- a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +++ b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go @@ -528,6 +528,7 @@ const ( FieldOptions_Packed_field_name protoreflect.Name = "packed" FieldOptions_Jstype_field_name protoreflect.Name = "jstype" FieldOptions_Lazy_field_name protoreflect.Name = "lazy" + FieldOptions_UnverifiedLazy_field_name protoreflect.Name = "unverified_lazy" FieldOptions_Deprecated_field_name protoreflect.Name = "deprecated" FieldOptions_Weak_field_name protoreflect.Name = "weak" FieldOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option" @@ -536,6 +537,7 @@ const ( FieldOptions_Packed_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.packed" FieldOptions_Jstype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.jstype" FieldOptions_Lazy_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.lazy" + FieldOptions_UnverifiedLazy_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.unverified_lazy" FieldOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.deprecated" FieldOptions_Weak_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.weak" FieldOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.uninterpreted_option" @@ -547,6 +549,7 @@ const ( FieldOptions_Packed_field_number protoreflect.FieldNumber = 2 FieldOptions_Jstype_field_number protoreflect.FieldNumber = 6 FieldOptions_Lazy_field_number protoreflect.FieldNumber = 5 + FieldOptions_UnverifiedLazy_field_number protoreflect.FieldNumber = 15 FieldOptions_Deprecated_field_number protoreflect.FieldNumber = 3 FieldOptions_Weak_field_number protoreflect.FieldNumber = 10 FieldOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999 diff --git a/vendor/google.golang.org/protobuf/internal/version/version.go b/vendor/google.golang.org/protobuf/internal/version/version.go index b480c5010f1..6c25e588e81 100644 --- a/vendor/google.golang.org/protobuf/internal/version/version.go +++ b/vendor/google.golang.org/protobuf/internal/version/version.go @@ -53,7 +53,7 @@ const ( Major = 1 Minor = 28 Patch = 1 - PreRelease = "" + PreRelease = "devel" ) // String formats the version string for this module in semver format. diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go index b03c1223c4a..74d0ce9b22e 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go @@ -345,6 +345,8 @@ func (p *SourcePath) appendFieldOptions(b []byte) []byte { b = p.appendSingularField(b, "jstype", nil) case 5: b = p.appendSingularField(b, "lazy", nil) + case 15: + b = p.appendSingularField(b, "unverified_lazy", nil) case 3: b = p.appendSingularField(b, "deprecated", nil) case 10: diff --git a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go index abe4ab5115b..c62f27ad088 100644 --- a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +++ b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go @@ -860,7 +860,6 @@ type FieldDescriptorProto struct { // For booleans, "true" or "false". // For strings, contains the default text contents (not escaped in any way). // For bytes, contains the C escaped value. All bytes >= 128 are escaped. - // TODO(kenton): Base-64 encode? DefaultValue *string `protobuf:"bytes,7,opt,name=default_value,json=defaultValue" json:"default_value,omitempty"` // If set, gives the index of a oneof in the containing type's oneof_decl // list. This field is a member of that oneof. @@ -1382,16 +1381,16 @@ type FileOptions struct { // inappropriate because proto packages do not normally start with backwards // domain names. JavaPackage *string `protobuf:"bytes,1,opt,name=java_package,json=javaPackage" json:"java_package,omitempty"` - // If set, all the classes from the .proto file are wrapped in a single - // outer class with the given name. This applies to both Proto1 - // (equivalent to the old "--one_java_file" option) and Proto2 (where - // a .proto always translates to a single class, but you may want to - // explicitly choose the class name). + // Controls the name of the wrapper Java class generated for the .proto file. + // That class will always contain the .proto file's getDescriptor() method as + // well as any top-level extensions defined in the .proto file. + // If java_multiple_files is disabled, then all the other classes from the + // .proto file will be nested inside the single wrapper outer class. JavaOuterClassname *string `protobuf:"bytes,8,opt,name=java_outer_classname,json=javaOuterClassname" json:"java_outer_classname,omitempty"` - // If set true, then the Java code generator will generate a separate .java + // If enabled, then the Java code generator will generate a separate .java // file for each top-level message, enum, and service defined in the .proto - // file. Thus, these types will *not* be nested inside the outer class - // named by java_outer_classname. However, the outer class will still be + // file. Thus, these types will *not* be nested inside the wrapper class + // named by java_outer_classname. However, the wrapper class will still be // generated to contain the file's getDescriptor() method as well as any // top-level extensions defined in the file. JavaMultipleFiles *bool `protobuf:"varint,10,opt,name=java_multiple_files,json=javaMultipleFiles,def=0" json:"java_multiple_files,omitempty"` @@ -1849,7 +1848,17 @@ type FieldOptions struct { // implementation must either *always* check its required fields, or *never* // check its required fields, regardless of whether or not the message has // been parsed. + // + // As of 2021, lazy does no correctness checks on the byte stream during + // parsing. This may lead to crashes if and when an invalid byte stream is + // finally parsed upon access. + // + // TODO(b/211906113): Enable validation on lazy fields. Lazy *bool `protobuf:"varint,5,opt,name=lazy,def=0" json:"lazy,omitempty"` + // unverified_lazy does no correctness checks on the byte stream. This should + // only be used where lazy with verification is prohibitive for performance + // reasons. + UnverifiedLazy *bool `protobuf:"varint,15,opt,name=unverified_lazy,json=unverifiedLazy,def=0" json:"unverified_lazy,omitempty"` // Is this field deprecated? // Depending on the target platform, this can emit Deprecated annotations // for accessors, or it will be completely ignored; in the very least, this @@ -1863,11 +1872,12 @@ type FieldOptions struct { // Default values for FieldOptions fields. const ( - Default_FieldOptions_Ctype = FieldOptions_STRING - Default_FieldOptions_Jstype = FieldOptions_JS_NORMAL - Default_FieldOptions_Lazy = bool(false) - Default_FieldOptions_Deprecated = bool(false) - Default_FieldOptions_Weak = bool(false) + Default_FieldOptions_Ctype = FieldOptions_STRING + Default_FieldOptions_Jstype = FieldOptions_JS_NORMAL + Default_FieldOptions_Lazy = bool(false) + Default_FieldOptions_UnverifiedLazy = bool(false) + Default_FieldOptions_Deprecated = bool(false) + Default_FieldOptions_Weak = bool(false) ) func (x *FieldOptions) Reset() { @@ -1930,6 +1940,13 @@ func (x *FieldOptions) GetLazy() bool { return Default_FieldOptions_Lazy } +func (x *FieldOptions) GetUnverifiedLazy() bool { + if x != nil && x.UnverifiedLazy != nil { + return *x.UnverifiedLazy + } + return Default_FieldOptions_UnverifiedLazy +} + func (x *FieldOptions) GetDeprecated() bool { if x != nil && x.Deprecated != nil { return *x.Deprecated @@ -2715,8 +2732,8 @@ func (x *EnumDescriptorProto_EnumReservedRange) GetEnd() int32 { // The name of the uninterpreted option. Each string represents a segment in // a dot-separated name. is_extension is true iff a segment represents an // extension (denoted with parentheses in options specs in .proto files). -// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents -// "foo.(bar.baz).qux". +// E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents +// "foo.(bar.baz).moo". type UninterpretedOption_NamePart struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2781,8 +2798,8 @@ type SourceCodeInfo_Location struct { // location. // // Each element is a field number or an index. They form a path from - // the root FileDescriptorProto to the place where the definition. For - // example, this path: + // the root FileDescriptorProto to the place where the definition occurs. + // For example, this path: // [ 4, 3, 2, 7, 1 ] // refers to: // file.message_type(3) // 4, 3 @@ -2834,13 +2851,13 @@ type SourceCodeInfo_Location struct { // // Comment attached to baz. // // Another line attached to baz. // - // // Comment attached to qux. + // // Comment attached to moo. // // - // // Another line attached to qux. - // optional double qux = 4; + // // Another line attached to moo. + // optional double moo = 4; // // // Detached comment for corge. This is not leading or trailing comments - // // to qux or corge because there are blank lines separating it from + // // to moo or corge because there are blank lines separating it from // // both. // // // Detached comment for corge paragraph 2. @@ -3304,7 +3321,7 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{ 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x49, 0x5a, 0x45, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x4c, 0x49, 0x54, 0x45, 0x5f, 0x52, 0x55, 0x4e, 0x54, 0x49, 0x4d, 0x45, 0x10, 0x03, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x26, - 0x10, 0x27, 0x22, 0xd1, 0x02, 0x0a, 0x0e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, + 0x10, 0x27, 0x22, 0xe3, 0x02, 0x0a, 0x0e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3c, 0x0a, 0x17, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x77, 0x69, 0x72, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x14, 0x6d, @@ -3324,166 +3341,170 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, - 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, - 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x22, 0xe2, 0x03, 0x0a, 0x0c, 0x46, 0x69, 0x65, 0x6c, 0x64, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x05, 0x63, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x06, 0x53, 0x54, 0x52, - 0x49, 0x4e, 0x47, 0x52, 0x05, 0x63, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, - 0x63, 0x6b, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x61, 0x63, 0x6b, - 0x65, 0x64, 0x12, 0x47, 0x0a, 0x06, 0x6a, 0x73, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x2e, 0x4a, 0x53, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x09, 0x4a, 0x53, 0x5f, 0x4e, 0x4f, 0x52, - 0x4d, 0x41, 0x4c, 0x52, 0x06, 0x6a, 0x73, 0x74, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x04, 0x6c, - 0x61, 0x7a, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, - 0x52, 0x04, 0x6c, 0x61, 0x7a, 0x79, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, - 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, - 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x19, 0x0a, - 0x04, 0x77, 0x65, 0x61, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, - 0x73, 0x65, 0x52, 0x04, 0x77, 0x65, 0x61, 0x6b, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, - 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0x2f, 0x0a, 0x05, 0x43, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x53, - 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x4f, 0x52, 0x44, 0x10, - 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x50, 0x49, 0x45, 0x43, - 0x45, 0x10, 0x02, 0x22, 0x35, 0x0a, 0x06, 0x4a, 0x53, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, - 0x09, 0x4a, 0x53, 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, - 0x4a, 0x53, 0x5f, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x4a, - 0x53, 0x5f, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x02, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, - 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x22, 0x73, 0x0a, 0x0c, 0x4f, - 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, - 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, - 0x22, 0xc0, 0x01, 0x0a, 0x0b, 0x45, 0x6e, 0x75, 0x6d, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x41, 0x6c, 0x69, 0x61, - 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, - 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, - 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, - 0x05, 0x10, 0x06, 0x22, 0x9e, 0x01, 0x0a, 0x10, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, - 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, + 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, + 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x08, + 0x10, 0x09, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x22, 0x92, 0x04, 0x0a, 0x0c, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x05, 0x63, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x06, 0x53, + 0x54, 0x52, 0x49, 0x4e, 0x47, 0x52, 0x05, 0x63, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x70, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x61, + 0x63, 0x6b, 0x65, 0x64, 0x12, 0x47, 0x0a, 0x06, 0x6a, 0x73, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x09, 0x4a, 0x53, 0x5f, 0x4e, + 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x52, 0x06, 0x6a, 0x73, 0x74, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, + 0x04, 0x6c, 0x61, 0x7a, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, + 0x73, 0x65, 0x52, 0x04, 0x6c, 0x61, 0x7a, 0x79, 0x12, 0x2e, 0x0a, 0x0f, 0x75, 0x6e, 0x76, 0x65, + 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x6c, 0x61, 0x7a, 0x79, 0x18, 0x0f, 0x20, 0x01, 0x28, + 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0e, 0x75, 0x6e, 0x76, 0x65, 0x72, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x4c, 0x61, 0x7a, 0x79, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, + 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, - 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, - 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, - 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, - 0x80, 0x80, 0x80, 0x02, 0x22, 0x9c, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x19, 0x0a, 0x04, 0x77, 0x65, 0x61, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, + 0x61, 0x6c, 0x73, 0x65, 0x52, 0x04, 0x77, 0x65, 0x61, 0x6b, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2f, 0x0a, 0x05, 0x43, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, + 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x4f, 0x52, + 0x44, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x50, 0x49, + 0x45, 0x43, 0x45, 0x10, 0x02, 0x22, 0x35, 0x0a, 0x06, 0x4a, 0x53, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x0d, 0x0a, 0x09, 0x4a, 0x53, 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0d, + 0x0a, 0x09, 0x4a, 0x53, 0x5f, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0d, 0x0a, + 0x09, 0x4a, 0x53, 0x5f, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x02, 0x2a, 0x09, 0x08, 0xe8, + 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x22, 0x73, 0x0a, + 0x0c, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x58, 0x0a, + 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, + 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, + 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, + 0x80, 0x02, 0x22, 0xc0, 0x01, 0x0a, 0x0b, 0x45, 0x6e, 0x75, 0x6d, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x61, 0x6c, 0x69, 0x61, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x41, 0x6c, + 0x69, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, + 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, + 0x04, 0x08, 0x05, 0x10, 0x06, 0x22, 0x9e, 0x01, 0x0a, 0x10, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, + 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, + 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, + 0x64, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, + 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, + 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, + 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0x9c, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, + 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x21, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, + 0x61, 0x6c, 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, + 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, + 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, + 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, + 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0xe0, 0x02, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x21, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, - 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x58, - 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, - 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, - 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, - 0x80, 0x80, 0x02, 0x22, 0xe0, 0x02, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x25, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, - 0x74, 0x65, 0x64, 0x18, 0x21, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, - 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x71, 0x0a, 0x11, - 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x6c, 0x65, 0x76, 0x65, - 0x6c, 0x18, 0x22, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, - 0x6e, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x3a, 0x13, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, - 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x52, 0x10, 0x69, + 0x73, 0x65, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x71, + 0x0a, 0x11, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x6c, 0x65, + 0x76, 0x65, 0x6c, 0x18, 0x22, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, + 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x3a, 0x13, 0x49, 0x44, 0x45, 0x4d, + 0x50, 0x4f, 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x52, + 0x10, 0x69, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, + 0x6c, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, + 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, + 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x50, 0x0a, 0x10, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, - 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, - 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, + 0x17, 0x0a, 0x13, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, + 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x4e, 0x4f, 0x5f, 0x53, + 0x49, 0x44, 0x45, 0x5f, 0x45, 0x46, 0x46, 0x45, 0x43, 0x54, 0x53, 0x10, 0x01, 0x12, 0x0e, 0x0a, + 0x0a, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, 0x54, 0x45, 0x4e, 0x54, 0x10, 0x02, 0x2a, 0x09, 0x08, + 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0x9a, 0x03, 0x0a, 0x13, 0x55, 0x6e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x41, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, - 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x50, 0x0a, 0x10, 0x49, 0x64, 0x65, - 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x17, 0x0a, - 0x13, 0x49, 0x44, 0x45, 0x4d, 0x50, 0x4f, 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x4b, - 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x4e, 0x4f, 0x5f, 0x53, 0x49, 0x44, - 0x45, 0x5f, 0x45, 0x46, 0x46, 0x45, 0x43, 0x54, 0x53, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x49, - 0x44, 0x45, 0x4d, 0x50, 0x4f, 0x54, 0x45, 0x4e, 0x54, 0x10, 0x02, 0x2a, 0x09, 0x08, 0xe8, 0x07, - 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0x9a, 0x03, 0x0a, 0x13, 0x55, 0x6e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, - 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x69, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2c, 0x0a, 0x12, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x76, 0x65, 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x6e, 0x65, - 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, - 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, - 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, - 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, - 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x27, - 0x0a, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, - 0x74, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x4a, 0x0a, 0x08, 0x4e, 0x61, 0x6d, 0x65, 0x50, - 0x61, 0x72, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, 0x61, 0x72, 0x74, - 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, - 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x02, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, - 0x69, 0x6f, 0x6e, 0x22, 0xa7, 0x02, 0x0a, 0x0e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, - 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x44, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xce, 0x01, 0x0a, - 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x16, 0x0a, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x42, - 0x02, 0x10, 0x01, 0x52, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x6c, 0x65, 0x61, - 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, - 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x10, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, - 0x61, 0x63, 0x68, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x06, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x17, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x74, - 0x61, 0x63, 0x68, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xd1, 0x01, - 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x4d, 0x0a, 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, - 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x1a, 0x6d, 0x0a, 0x0a, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, - 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x65, 0x67, - 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x12, - 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x6e, - 0x64, 0x42, 0x7e, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x10, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01, 0x5a, 0x2d, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x64, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, - 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x69, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2c, + 0x0a, 0x12, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2c, 0x0a, 0x12, + 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, + 0x76, 0x65, 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, + 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, + 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, + 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x5f, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x61, 0x67, 0x67, 0x72, 0x65, + 0x67, 0x61, 0x74, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x4a, 0x0a, 0x08, 0x4e, 0x61, 0x6d, + 0x65, 0x50, 0x61, 0x72, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, 0x61, + 0x72, 0x74, 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x61, 0x6d, 0x65, 0x50, 0x61, + 0x72, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x02, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x45, 0x78, 0x74, 0x65, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa7, 0x02, 0x0a, 0x0e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x44, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x6f, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xce, + 0x01, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x6c, + 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, + 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x10, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x64, + 0x65, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x17, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x44, + 0x65, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0xd1, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x4d, 0x0a, 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x65, 0x6e, 0x65, + 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, + 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x6d, 0x0a, 0x0a, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, + 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, + 0x65, 0x67, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x65, 0x67, 0x69, + 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, + 0x65, 0x6e, 0x64, 0x42, 0x7e, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x10, 0x44, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01, 0x5a, 0x2d, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xf8, 0x01, 0x01, + 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, } var ( diff --git a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go index 8c10797b905..cc8449757f7 100644 --- a/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/anypb/any.pb.go @@ -153,7 +153,7 @@ import ( // foo = any.unpack(Foo.class); // } // -// Example 3: Pack and unpack a message in Python. +// Example 3: Pack and unpack a message in Python. // // foo = Foo(...) // any = Any() @@ -163,7 +163,7 @@ import ( // any.Unpack(foo) // ... // -// Example 4: Pack and unpack a message in Go +// Example 4: Pack and unpack a message in Go // // foo := &pb.Foo{...} // any, err := anypb.New(foo) @@ -184,7 +184,7 @@ import ( // // // JSON -// ==== +// // The JSON representation of an `Any` value uses the regular // representation of the deserialized, embedded message, with an // additional field `@type` which contains the type URL. Example: diff --git a/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go b/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go index e7fcea31f62..6568280191b 100644 --- a/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/emptypb/empty.pb.go @@ -48,7 +48,6 @@ import ( // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); // } // -// The JSON representation for `Empty` is empty JSON object `{}`. type Empty struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go b/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go index 586690522a4..882b0af65fb 100644 --- a/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go +++ b/vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go @@ -274,8 +274,8 @@ func (x *Struct) GetFields() map[string]*Value { // `Value` represents a dynamically typed value which can be either // null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of that -// variants, absence of any variant indicates an error. +// list of values. A producer of value is expected to set one of these +// variants. Absence of any variant indicates an error. // // The JSON representation for `Value` is JSON value. type Value struct { diff --git a/vendor/modules.txt b/vendor/modules.txt index e3e2bbebac2..9d1a277e45a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -19,6 +19,18 @@ github.com/andybalholm/cascadia # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 github.com/beorn7/perks/quantile +# github.com/bufbuild/protocompile v0.2.1-0.20230123224550-da57cd758c2f +## explicit; go 1.18 +github.com/bufbuild/protocompile +github.com/bufbuild/protocompile/ast +github.com/bufbuild/protocompile/internal +github.com/bufbuild/protocompile/linker +github.com/bufbuild/protocompile/options +github.com/bufbuild/protocompile/parser +github.com/bufbuild/protocompile/protoutil +github.com/bufbuild/protocompile/reporter +github.com/bufbuild/protocompile/sourceinfo +github.com/bufbuild/protocompile/walk # github.com/cespare/xxhash/v2 v2.2.0 ## explicit; go 1.11 github.com/cespare/xxhash/v2 @@ -116,15 +128,10 @@ github.com/go-sourcemap/sourcemap/internal/base64vlq ## explicit; go 1.9 github.com/golang/protobuf/jsonpb github.com/golang/protobuf/proto -github.com/golang/protobuf/protoc-gen-go/descriptor -github.com/golang/protobuf/protoc-gen-go/plugin github.com/golang/protobuf/ptypes github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration -github.com/golang/protobuf/ptypes/empty -github.com/golang/protobuf/ptypes/struct github.com/golang/protobuf/ptypes/timestamp -github.com/golang/protobuf/ptypes/wrappers # github.com/golang/snappy v0.0.4 ## explicit github.com/golang/snappy @@ -165,17 +172,14 @@ github.com/inconshreveable/mousetrap github.com/influxdata/influxdb1-client/models github.com/influxdata/influxdb1-client/pkg/escape github.com/influxdata/influxdb1-client/v2 -# github.com/jhump/protoreflect v1.14.1 -## explicit; go 1.13 -github.com/jhump/protoreflect/codec +# github.com/jhump/protoreflect v1.15.0 +## explicit; go 1.18 github.com/jhump/protoreflect/desc github.com/jhump/protoreflect/desc/internal github.com/jhump/protoreflect/desc/protoparse github.com/jhump/protoreflect/desc/protoparse/ast github.com/jhump/protoreflect/desc/sourceinfo -github.com/jhump/protoreflect/dynamic github.com/jhump/protoreflect/internal -github.com/jhump/protoreflect/internal/codec # github.com/josharian/intern v1.0.0 ## explicit; go 1.5 github.com/josharian/intern @@ -300,6 +304,9 @@ golang.org/x/net/http2/hpack golang.org/x/net/idna golang.org/x/net/internal/timeseries golang.org/x/net/trace +# golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde +## explicit +golang.org/x/sync/semaphore # golang.org/x/sys v0.5.0 ## explicit; go 1.17 golang.org/x/sys/internal/unsafeheader @@ -330,10 +337,6 @@ golang.org/x/time/rate # google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f ## explicit; go 1.19 google.golang.org/genproto/googleapis/rpc/status -google.golang.org/genproto/protobuf/api -google.golang.org/genproto/protobuf/field_mask -google.golang.org/genproto/protobuf/ptype -google.golang.org/genproto/protobuf/source_context # google.golang.org/grpc v1.53.0 ## explicit; go 1.17 google.golang.org/grpc @@ -387,7 +390,7 @@ google.golang.org/grpc/stats google.golang.org/grpc/status google.golang.org/grpc/tap google.golang.org/grpc/test/grpc_testing -# google.golang.org/protobuf v1.28.1 +# google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 ## explicit; go 1.11 google.golang.org/protobuf/encoding/protojson google.golang.org/protobuf/encoding/prototext From 0b5083e03b9961561ecba82c6cb2e9f8e9885cc5 Mon Sep 17 00:00:00 2001 From: Nedyalko Andreev Date: Mon, 27 Feb 2023 13:38:19 +0200 Subject: [PATCH 4/6] Update github.com/stretchr/testify from v1.8.1 to v1.8.2 --- go.mod | 2 +- go.sum | 4 +- .../stretchr/testify/assert/assertions.go | 78 ++++++++----------- vendor/modules.txt | 2 +- 4 files changed, 37 insertions(+), 49 deletions(-) diff --git a/go.mod b/go.mod index 1046ca7ce00..eb68e94c3d3 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/spf13/afero v1.1.2 github.com/spf13/cobra v1.4.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.1 + github.com/stretchr/testify v1.8.2 github.com/tidwall/gjson v1.14.4 github.com/tidwall/pretty v1.2.1 go.uber.org/goleak v1.2.1 diff --git a/go.sum b/go.sum index 925984793ed..dc67998e4c9 100644 --- a/go.sum +++ b/go.sum @@ -302,8 +302,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go index fa1245b1897..2924cf3a149 100644 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/vendor/github.com/stretchr/testify/assert/assertions.go @@ -8,7 +8,6 @@ import ( "fmt" "math" "os" - "path/filepath" "reflect" "regexp" "runtime" @@ -141,12 +140,11 @@ func CallerInfo() []string { } parts := strings.Split(file, "/") - file = parts[len(parts)-1] if len(parts) > 1 { + filename := parts[len(parts)-1] dir := parts[len(parts)-2] - if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { - path, _ := filepath.Abs(file) - callers = append(callers, fmt.Sprintf("%s:%d", path, line)) + if (dir != "assert" && dir != "mock" && dir != "require") || filename == "mock_test.go" { + callers = append(callers, fmt.Sprintf("%s:%d", file, line)) } } @@ -530,7 +528,7 @@ func isNil(object interface{}) bool { []reflect.Kind{ reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, - reflect.Ptr, reflect.Slice}, + reflect.Ptr, reflect.Slice, reflect.UnsafePointer}, kind) if isNilableKind && value.IsNil() { @@ -818,49 +816,44 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok return true // we consider nil to be equal to the nil set } - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) } + subsetKind := reflect.TypeOf(subset).Kind() if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) } - subsetValue := reflect.ValueOf(subset) if subsetKind == reflect.Map && listKind == reflect.Map { - listValue := reflect.ValueOf(list) - subsetKeys := subsetValue.MapKeys() + subsetMap := reflect.ValueOf(subset) + actualMap := reflect.ValueOf(list) - for i := 0; i < len(subsetKeys); i++ { - subsetKey := subsetKeys[i] - subsetElement := subsetValue.MapIndex(subsetKey).Interface() - listElement := listValue.MapIndex(subsetKey).Interface() + for _, k := range subsetMap.MapKeys() { + ev := subsetMap.MapIndex(k) + av := actualMap.MapIndex(k) - if !ObjectsAreEqual(subsetElement, listElement) { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, subsetElement), msgAndArgs...) + if !av.IsValid() { + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) + } + if !ObjectsAreEqual(ev.Interface(), av.Interface()) { + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) } } return true } - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() + subsetList := reflect.ValueOf(subset) + for i := 0; i < subsetList.Len(); i++ { + element := subsetList.Index(i).Interface() ok, found := containsElement(list, element) if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", list), msgAndArgs...) } if !found { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, element), msgAndArgs...) } } @@ -879,34 +872,28 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...) } - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) } + subsetKind := reflect.TypeOf(subset).Kind() if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) } - subsetValue := reflect.ValueOf(subset) if subsetKind == reflect.Map && listKind == reflect.Map { - listValue := reflect.ValueOf(list) - subsetKeys := subsetValue.MapKeys() + subsetMap := reflect.ValueOf(subset) + actualMap := reflect.ValueOf(list) - for i := 0; i < len(subsetKeys); i++ { - subsetKey := subsetKeys[i] - subsetElement := subsetValue.MapIndex(subsetKey).Interface() - listElement := listValue.MapIndex(subsetKey).Interface() + for _, k := range subsetMap.MapKeys() { + ev := subsetMap.MapIndex(k) + av := actualMap.MapIndex(k) - if !ObjectsAreEqual(subsetElement, listElement) { + if !av.IsValid() { + return true + } + if !ObjectsAreEqual(ev.Interface(), av.Interface()) { return true } } @@ -914,8 +901,9 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...) } - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() + subsetList := reflect.ValueOf(subset) + for i := 0; i < subsetList.Len(); i++ { + element := subsetList.Index(i).Interface() ok, found := containsElement(list, element) if !ok { return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) diff --git a/vendor/modules.txt b/vendor/modules.txt index 9d1a277e45a..cf11215c5ce 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -266,7 +266,7 @@ github.com/spf13/cobra # github.com/spf13/pflag v1.0.5 ## explicit; go 1.12 github.com/spf13/pflag -# github.com/stretchr/testify v1.8.1 +# github.com/stretchr/testify v1.8.2 ## explicit; go 1.13 github.com/stretchr/testify/assert github.com/stretchr/testify/require From d535ba97f05fee253b66278c29b3ec45cb83d251 Mon Sep 17 00:00:00 2001 From: Nedyalko Andreev Date: Mon, 27 Feb 2023 14:40:16 +0200 Subject: [PATCH 5/6] Clean up github.com/golang/protobuf usage and update policy --- Dependencies.md | 8 +- modtools_frozen.yml | 9 - samples/grpc_server/go.mod | 4 +- samples/grpc_server/go.sum | 1092 ----------------------------------- samples/grpc_server/main.go | 2 +- 5 files changed, 6 insertions(+), 1109 deletions(-) diff --git a/Dependencies.md b/Dependencies.md index d506c530830..5e50dd6b1e1 100644 --- a/Dependencies.md +++ b/Dependencies.md @@ -15,8 +15,8 @@ For example some dependencies that were in the middle of big updates were skippe Through the rest of the development cycle dependencies shouldn't be updated unless: 1. required for development 2. a particular bug fix/feature is really important - - + + The last part predominantly goes for `golang.org/x/*` and particularly `golang.org/x/net` which usually have updates through the development of Go itself. [Goja](https://github.com/dop251/goja) has special considerations as it's heavily used and bug fixes there or new features usually have high impact on k6. Which means that we usually try to update it whenever something new lands there. @@ -37,8 +37,6 @@ List (as of March 2022): - github.com/spf13/pflag - similar to above - gopkg.in/guregu/null.v3 - no new interesting features and we probably want to drop it in favor of [croconf](https://github.com/grafana/croconf) - gopkg.in/yaml.v3 - no new features wanted - actually used directly in only one place to output yaml to stdout. -- google.golang.org/genproto, google.golang.org/protobuf, github.com/golang/protobuf - get update by `google.golang.org/grpc` when needed - ## How to do it @@ -48,7 +46,7 @@ Currently, I will recommend using [modtools](https://github.com/dop251/modtools) Running `modtools check --direct-only` will give you a list of packages that aren't frozen (the ones above in the exceptions). Alternatively just running `go get ` for each direct dependency, which also will tell you if there was an update. Then take a look at the changelog between the versions. - + You can use the command `modtools check --direct-only` provided you, to update it. Run tests and if relevant check that bugs are fixed or any other verification that is appropriate. Commit dependencies one by one with a message like `Update from vX.Y.Z to vX.Y.Z` and a relevant changelog for k6. Sometimes that means "nothing of relevance for k6", sometimes it means a list of bug fixes or new features. diff --git a/modtools_frozen.yml b/modtools_frozen.yml index 6b626b99b4a..6224f5ccb69 100644 --- a/modtools_frozen.yml +++ b/modtools_frozen.yml @@ -13,15 +13,6 @@ - path: gopkg.in/yaml.v3 minVersion: v3.0.0-20200313102051-9f266ea9e77c validUntil: 2029-08-04T16:32:56+03:00 -- path: google.golang.org/genproto - minVersion: v0.0.0-20200903010400-9bfcb5116336 - validUntil: 2029-08-04T17:01:00+03:00 -- path: google.golang.org/protobuf - minVersion: v1.25.1-0.20200805231151-a709e31e5d12 - validUntil: 2029-08-04T17:01:13+03:00 -- path: github.com/golang/protobuf - minVersion: v1.4.2 - validUntil: 2029-08-04T17:01:43+03:00 - path: github.com/spf13/cobra minVersion: v1.4.0 validUntil: 2049-07-26T17:21:52+03:00 diff --git a/samples/grpc_server/go.mod b/samples/grpc_server/go.mod index ffc9795384c..e77d9e98d10 100644 --- a/samples/grpc_server/go.mod +++ b/samples/grpc_server/go.mod @@ -1,14 +1,14 @@ module go.k6.io/k6/samples/grpc_server -go 1.17 +go 1.19 require ( - github.com/golang/protobuf v1.5.2 google.golang.org/grpc v1.53.0 google.golang.org/protobuf v1.28.1 ) require ( + github.com/golang/protobuf v1.5.2 // indirect golang.org/x/net v0.5.0 // indirect golang.org/x/sys v0.4.0 // indirect golang.org/x/text v0.6.0 // indirect diff --git a/samples/grpc_server/go.sum b/samples/grpc_server/go.sum index 2c5b51f0ce7..751fe9d3621 100644 --- a/samples/grpc_server/go.sum +++ b/samples/grpc_server/go.sum @@ -1,1112 +1,20 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.1/go.mod h1:fs4QogzfH5n2pBXBP9vRiU+eCny7lD2vmFZy79Iuw1U= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= -cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= -cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= -cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= -cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4= -cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw= -cloud.google.com/go/accesscontextmanager v1.3.0/go.mod h1:TgCBehyr5gNMz7ZaH9xubp+CE8dkrszb4oK9CWyvD4o= -cloud.google.com/go/accesscontextmanager v1.4.0/go.mod h1:/Kjh7BBu/Gh83sv+K60vN9QE5NJcd80sU33vIe2IFPE= -cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= -cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= -cloud.google.com/go/aiplatform v1.27.0/go.mod h1:Bvxqtl40l0WImSb04d0hXFU7gDOiq9jQmorivIiWcKg= -cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= -cloud.google.com/go/analytics v0.12.0/go.mod h1:gkfj9h6XRf9+TS4bmuhPEShsh3hH8PAZzm/41OOhQd4= -cloud.google.com/go/apigateway v1.3.0/go.mod h1:89Z8Bhpmxu6AmUxuVRg/ECRGReEdiP3vQtk4Z1J9rJk= -cloud.google.com/go/apigateway v1.4.0/go.mod h1:pHVY9MKGaH9PQ3pJ4YLzoj6U5FUDeDFBllIz7WmzJoc= -cloud.google.com/go/apigeeconnect v1.3.0/go.mod h1:G/AwXFAKo0gIXkPTVfZDd2qA1TxBXJ3MgMRBQkIi9jc= -cloud.google.com/go/apigeeconnect v1.4.0/go.mod h1:kV4NwOKqjvt2JYR0AoIWo2QGfoRtn/pkS3QlHp0Ni04= -cloud.google.com/go/appengine v1.4.0/go.mod h1:CS2NhuBuDXM9f+qscZ6V86m1MIIqPj3WC/UoEuR1Sno= -cloud.google.com/go/appengine v1.5.0/go.mod h1:TfasSozdkFI0zeoxW3PTBLiNqRmzraodCWatWI9Dmak= -cloud.google.com/go/area120 v0.5.0/go.mod h1:DE/n4mp+iqVyvxHN41Vf1CR602GiHQjFPusMFW6bGR4= -cloud.google.com/go/area120 v0.6.0/go.mod h1:39yFJqWVgm0UZqWTOdqkLhjoC7uFfgXRC8g/ZegeAh0= -cloud.google.com/go/artifactregistry v1.6.0/go.mod h1:IYt0oBPSAGYj/kprzsBjZ/4LnG/zOcHyFHjWPCi6SAQ= -cloud.google.com/go/artifactregistry v1.7.0/go.mod h1:mqTOFOnGZx8EtSqK/ZWcsm/4U8B77rbcLP6ruDU2Ixk= -cloud.google.com/go/artifactregistry v1.8.0/go.mod h1:w3GQXkJX8hiKN0v+at4b0qotwijQbYUqF2GWkZzAhC0= -cloud.google.com/go/artifactregistry v1.9.0/go.mod h1:2K2RqvA2CYvAeARHRkLDhMDJ3OXy26h3XW+3/Jh2uYc= -cloud.google.com/go/asset v1.5.0/go.mod h1:5mfs8UvcM5wHhqtSv8J1CtxxaQq3AdBxxQi2jGW/K4o= -cloud.google.com/go/asset v1.7.0/go.mod h1:YbENsRK4+xTiL+Ofoj5Ckf+O17kJtgp3Y3nn4uzZz5s= -cloud.google.com/go/asset v1.8.0/go.mod h1:mUNGKhiqIdbr8X7KNayoYvyc4HbbFO9URsjbytpUaW0= -cloud.google.com/go/asset v1.9.0/go.mod h1:83MOE6jEJBMqFKadM9NLRcs80Gdw76qGuHn8m3h8oHQ= -cloud.google.com/go/asset v1.10.0/go.mod h1:pLz7uokL80qKhzKr4xXGvBQXnzHn5evJAEAtZiIb0wY= -cloud.google.com/go/assuredworkloads v1.5.0/go.mod h1:n8HOZ6pff6re5KYfBXcFvSViQjDwxFkAkmUFffJRbbY= -cloud.google.com/go/assuredworkloads v1.6.0/go.mod h1:yo2YOk37Yc89Rsd5QMVECvjaMKymF9OP+QXWlKXUkXw= -cloud.google.com/go/assuredworkloads v1.7.0/go.mod h1:z/736/oNmtGAyU47reJgGN+KVoYoxeLBoj4XkKYscNI= -cloud.google.com/go/assuredworkloads v1.8.0/go.mod h1:AsX2cqyNCOvEQC8RMPnoc0yEarXQk6WEKkxYfL6kGIo= -cloud.google.com/go/assuredworkloads v1.9.0/go.mod h1:kFuI1P78bplYtT77Tb1hi0FMxM0vVpRC7VVoJC3ZoT0= -cloud.google.com/go/automl v1.5.0/go.mod h1:34EjfoFGMZ5sgJ9EoLsRtdPSNZLcfflJR39VbVNS2M0= -cloud.google.com/go/automl v1.6.0/go.mod h1:ugf8a6Fx+zP0D59WLhqgTDsQI9w07o64uf/Is3Nh5p8= -cloud.google.com/go/automl v1.7.0/go.mod h1:RL9MYCCsJEOmt0Wf3z9uzG0a7adTT1fe+aObgSpkCt8= -cloud.google.com/go/automl v1.8.0/go.mod h1:xWx7G/aPEe/NP+qzYXktoBSDfjO+vnKMGgsApGJJquM= -cloud.google.com/go/baremetalsolution v0.3.0/go.mod h1:XOrocE+pvK1xFfleEnShBlNAXf+j5blPPxrhjKgnIFc= -cloud.google.com/go/baremetalsolution v0.4.0/go.mod h1:BymplhAadOO/eBa7KewQ0Ppg4A4Wplbn+PsFKRLo0uI= -cloud.google.com/go/batch v0.3.0/go.mod h1:TR18ZoAekj1GuirsUsR1ZTKN3FC/4UDnScjT8NXImFE= -cloud.google.com/go/batch v0.4.0/go.mod h1:WZkHnP43R/QCGQsZ+0JyG4i79ranE2u8xvjq/9+STPE= -cloud.google.com/go/beyondcorp v0.2.0/go.mod h1:TB7Bd+EEtcw9PCPQhCJtJGjk/7TC6ckmnSFS+xwTfm4= -cloud.google.com/go/beyondcorp v0.3.0/go.mod h1:E5U5lcrcXMsCuoDNyGrpyTm/hn7ne941Jz2vmksAxW8= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/bigquery v1.42.0/go.mod h1:8dRTJxhtG+vwBKzE5OseQn/hiydoQN3EedCaOdYmxRA= -cloud.google.com/go/bigquery v1.43.0/go.mod h1:ZMQcXHsl+xmU1z36G2jNGZmKp9zNY5BUua5wDgmNCfw= -cloud.google.com/go/bigquery v1.44.0/go.mod h1:0Y33VqXTEsbamHJvJHdFmtqHvMIY28aK1+dFsvaChGc= -cloud.google.com/go/billing v1.4.0/go.mod h1:g9IdKBEFlItS8bTtlrZdVLWSSdSyFUZKXNS02zKMOZY= -cloud.google.com/go/billing v1.5.0/go.mod h1:mztb1tBc3QekhjSgmpf/CV4LzWXLzCArwpLmP2Gm88s= -cloud.google.com/go/billing v1.6.0/go.mod h1:WoXzguj+BeHXPbKfNWkqVtDdzORazmCjraY+vrxcyvI= -cloud.google.com/go/billing v1.7.0/go.mod h1:q457N3Hbj9lYwwRbnlD7vUpyjq6u5U1RAOArInEiD5Y= -cloud.google.com/go/binaryauthorization v1.1.0/go.mod h1:xwnoWu3Y84jbuHa0zd526MJYmtnVXn0syOjaJgy4+dM= -cloud.google.com/go/binaryauthorization v1.2.0/go.mod h1:86WKkJHtRcv5ViNABtYMhhNWRrD1Vpi//uKEy7aYEfI= -cloud.google.com/go/binaryauthorization v1.3.0/go.mod h1:lRZbKgjDIIQvzYQS1p99A7/U1JqvqeZg0wiI5tp6tg0= -cloud.google.com/go/binaryauthorization v1.4.0/go.mod h1:tsSPQrBd77VLplV70GUhBf/Zm3FsKmgSqgm4UmiDItk= -cloud.google.com/go/certificatemanager v1.3.0/go.mod h1:n6twGDvcUBFu9uBgt4eYvvf3sQ6My8jADcOVwHmzadg= -cloud.google.com/go/certificatemanager v1.4.0/go.mod h1:vowpercVFyqs8ABSmrdV+GiFf2H/ch3KyudYQEMM590= -cloud.google.com/go/channel v1.8.0/go.mod h1:W5SwCXDJsq/rg3tn3oG0LOxpAo6IMxNa09ngphpSlnk= -cloud.google.com/go/channel v1.9.0/go.mod h1:jcu05W0my9Vx4mt3/rEHpfxc9eKi9XwsdDL8yBMbKUk= -cloud.google.com/go/cloudbuild v1.3.0/go.mod h1:WequR4ULxlqvMsjDEEEFnOG5ZSRSgWOywXYDb1vPE6U= -cloud.google.com/go/cloudbuild v1.4.0/go.mod h1:5Qwa40LHiOXmz3386FrjrYM93rM/hdRr7b53sySrTqA= -cloud.google.com/go/clouddms v1.3.0/go.mod h1:oK6XsCDdW4Ib3jCCBugx+gVjevp2TMXFtgxvPSee3OM= -cloud.google.com/go/clouddms v1.4.0/go.mod h1:Eh7sUGCC+aKry14O1NRljhjyrr0NFC0G2cjwX0cByRk= -cloud.google.com/go/cloudtasks v1.5.0/go.mod h1:fD92REy1x5woxkKEkLdvavGnPJGEn8Uic9nWuLzqCpY= -cloud.google.com/go/cloudtasks v1.6.0/go.mod h1:C6Io+sxuke9/KNRkbQpihnW93SWDU3uXt92nu85HkYI= -cloud.google.com/go/cloudtasks v1.7.0/go.mod h1:ImsfdYWwlWNJbdgPIIGJWC+gemEGTBK/SunNQQNCAb4= -cloud.google.com/go/cloudtasks v1.8.0/go.mod h1:gQXUIwCSOI4yPVK7DgTVFiiP0ZW/eQkydWzwVMdHxrI= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= -cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.12.0/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= -cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= -cloud.google.com/go/compute v1.13.0/go.mod h1:5aPTS0cUNMIc1CE546K+Th6weJUNQErARyZtRXDJ8GE= -cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= -cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63rR+SXhcpA= -cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= -cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/contactcenterinsights v1.3.0/go.mod h1:Eu2oemoePuEFc/xKFPjbTuPSj0fYJcPls9TFlPNnHHY= -cloud.google.com/go/contactcenterinsights v1.4.0/go.mod h1:L2YzkGbPsv+vMQMCADxJoT9YiTTnSEd6fEvCeHTYVck= -cloud.google.com/go/container v1.6.0/go.mod h1:Xazp7GjJSeUYo688S+6J5V+n/t+G5sKBTFkKNudGRxg= -cloud.google.com/go/container v1.7.0/go.mod h1:Dp5AHtmothHGX3DwwIHPgq45Y8KmNsgN3amoYfxVkLo= -cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= -cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= -cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= -cloud.google.com/go/datacatalog v1.5.0/go.mod h1:M7GPLNQeLfWqeIm3iuiruhPzkt65+Bx8dAKvScX8jvs= -cloud.google.com/go/datacatalog v1.6.0/go.mod h1:+aEyF8JKg+uXcIdAmmaMUmZ3q1b/lKLtXCmXdnc0lbc= -cloud.google.com/go/datacatalog v1.7.0/go.mod h1:9mEl4AuDYWw81UGc41HonIHH7/sn52H0/tc8f8ZbZIE= -cloud.google.com/go/datacatalog v1.8.0/go.mod h1:KYuoVOv9BM8EYz/4eMFxrr4DUKhGIOXxZoKYF5wdISM= -cloud.google.com/go/dataflow v0.6.0/go.mod h1:9QwV89cGoxjjSR9/r7eFDqqjtvbKxAK2BaYU6PVk9UM= -cloud.google.com/go/dataflow v0.7.0/go.mod h1:PX526vb4ijFMesO1o202EaUmouZKBpjHsTlCtB4parQ= -cloud.google.com/go/dataform v0.3.0/go.mod h1:cj8uNliRlHpa6L3yVhDOBrUXH+BPAO1+KFMQQNSThKo= -cloud.google.com/go/dataform v0.4.0/go.mod h1:fwV6Y4Ty2yIFL89huYlEkwUPtS7YZinZbzzj5S9FzCE= -cloud.google.com/go/dataform v0.5.0/go.mod h1:GFUYRe8IBa2hcomWplodVmUx/iTL0FrsauObOM3Ipr0= -cloud.google.com/go/datafusion v1.4.0/go.mod h1:1Zb6VN+W6ALo85cXnM1IKiPw+yQMKMhB9TsTSRDo/38= -cloud.google.com/go/datafusion v1.5.0/go.mod h1:Kz+l1FGHB0J+4XF2fud96WMmRiq/wj8N9u007vyXZ2w= -cloud.google.com/go/datalabeling v0.5.0/go.mod h1:TGcJ0G2NzcsXSE/97yWjIZO0bXj0KbVlINXMG9ud42I= -cloud.google.com/go/datalabeling v0.6.0/go.mod h1:WqdISuk/+WIGeMkpw/1q7bK/tFEZxsrFJOJdY2bXvTQ= -cloud.google.com/go/dataplex v1.3.0/go.mod h1:hQuRtDg+fCiFgC8j0zV222HvzFQdRd+SVX8gdmFcZzA= -cloud.google.com/go/dataplex v1.4.0/go.mod h1:X51GfLXEMVJ6UN47ESVqvlsRplbLhcsAt0kZCCKsU0A= -cloud.google.com/go/dataproc v1.7.0/go.mod h1:CKAlMjII9H90RXaMpSxQ8EU6dQx6iAYNPcYPOkSbi8s= -cloud.google.com/go/dataproc v1.8.0/go.mod h1:5OW+zNAH0pMpw14JVrPONsxMQYMBqJuzORhIBfBn9uI= -cloud.google.com/go/dataqna v0.5.0/go.mod h1:90Hyk596ft3zUQ8NkFfvICSIfHFh1Bc7C4cK3vbhkeo= -cloud.google.com/go/dataqna v0.6.0/go.mod h1:1lqNpM7rqNLVgWBJyk5NF6Uen2PHym0jtVJonplVsDA= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/datastore v1.10.0/go.mod h1:PC5UzAmDEkAmkfaknstTYbNpgE49HAgW2J1gcgUfmdM= -cloud.google.com/go/datastream v1.2.0/go.mod h1:i/uTP8/fZwgATHS/XFu0TcNUhuA0twZxxQ3EyCUQMwo= -cloud.google.com/go/datastream v1.3.0/go.mod h1:cqlOX8xlyYF/uxhiKn6Hbv6WjwPPuI9W2M9SAXwaLLQ= -cloud.google.com/go/datastream v1.4.0/go.mod h1:h9dpzScPhDTs5noEMQVWP8Wx8AFBRyS0s8KWPx/9r0g= -cloud.google.com/go/datastream v1.5.0/go.mod h1:6TZMMNPwjUqZHBKPQ1wwXpb0d5VDVPl2/XoS5yi88q4= -cloud.google.com/go/deploy v1.4.0/go.mod h1:5Xghikd4VrmMLNaF6FiRFDlHb59VM59YoDQnOUdsH/c= -cloud.google.com/go/deploy v1.5.0/go.mod h1:ffgdD0B89tToyW/U/D2eL0jN2+IEV/3EMuXHA0l4r+s= -cloud.google.com/go/dialogflow v1.15.0/go.mod h1:HbHDWs33WOGJgn6rfzBW1Kv807BE3O1+xGbn59zZWI4= -cloud.google.com/go/dialogflow v1.16.1/go.mod h1:po6LlzGfK+smoSmTBnbkIZY2w8ffjz/RcGSS+sh1el0= -cloud.google.com/go/dialogflow v1.17.0/go.mod h1:YNP09C/kXA1aZdBgC/VtXX74G/TKn7XVCcVumTflA+8= -cloud.google.com/go/dialogflow v1.18.0/go.mod h1:trO7Zu5YdyEuR+BhSNOqJezyFQ3aUzz0njv7sMx/iek= -cloud.google.com/go/dialogflow v1.19.0/go.mod h1:JVmlG1TwykZDtxtTXujec4tQ+D8SBFMoosgy+6Gn0s0= -cloud.google.com/go/dlp v1.6.0/go.mod h1:9eyB2xIhpU0sVwUixfBubDoRwP+GjeUoxxeueZmqvmM= -cloud.google.com/go/dlp v1.7.0/go.mod h1:68ak9vCiMBjbasxeVD17hVPxDEck+ExiHavX8kiHG+Q= -cloud.google.com/go/documentai v1.7.0/go.mod h1:lJvftZB5NRiFSX4moiye1SMxHx0Bc3x1+p9e/RfXYiU= -cloud.google.com/go/documentai v1.8.0/go.mod h1:xGHNEB7CtsnySCNrCFdCyyMz44RhFEEX2Q7UD0c5IhU= -cloud.google.com/go/documentai v1.9.0/go.mod h1:FS5485S8R00U10GhgBC0aNGrJxBP8ZVpEeJ7PQDZd6k= -cloud.google.com/go/documentai v1.10.0/go.mod h1:vod47hKQIPeCfN2QS/jULIvQTugbmdc0ZvxxfQY1bg4= -cloud.google.com/go/domains v0.6.0/go.mod h1:T9Rz3GasrpYk6mEGHh4rymIhjlnIuB4ofT1wTxDeT4Y= -cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg= -cloud.google.com/go/edgecontainer v0.1.0/go.mod h1:WgkZ9tp10bFxqO8BLPqv2LlfmQF1X8lZqwW4r1BTajk= -cloud.google.com/go/edgecontainer v0.2.0/go.mod h1:RTmLijy+lGpQ7BXuTDa4C4ssxyXT34NIuHIgKuP4s5w= -cloud.google.com/go/errorreporting v0.3.0/go.mod h1:xsP2yaAp+OAW4OIm60An2bbLpqIhKXdWR/tawvl7QzU= -cloud.google.com/go/essentialcontacts v1.3.0/go.mod h1:r+OnHa5jfj90qIfZDO/VztSFqbQan7HV75p8sA+mdGI= -cloud.google.com/go/essentialcontacts v1.4.0/go.mod h1:8tRldvHYsmnBCHdFpvU+GL75oWiBKl80BiqlFh9tp+8= -cloud.google.com/go/eventarc v1.7.0/go.mod h1:6ctpF3zTnaQCxUjHUdcfgcA1A2T309+omHZth7gDfmc= -cloud.google.com/go/eventarc v1.8.0/go.mod h1:imbzxkyAU4ubfsaKYdQg04WS1NvncblHEup4kvF+4gw= -cloud.google.com/go/filestore v1.3.0/go.mod h1:+qbvHGvXU1HaKX2nD0WEPo92TP/8AQuCVEBXNY9z0+w= -cloud.google.com/go/filestore v1.4.0/go.mod h1:PaG5oDfo9r224f8OYXURtAsY+Fbyq/bLYoINEK8XQAI= -cloud.google.com/go/firestore v1.9.0/go.mod h1:HMkjKHNTtRyZNiMzu7YAsLr9K3X2udY2AMwDaMEQiiE= -cloud.google.com/go/functions v1.6.0/go.mod h1:3H1UA3qiIPRWD7PeZKLvHZ9SaQhR26XIJcC0A5GbvAk= -cloud.google.com/go/functions v1.7.0/go.mod h1:+d+QBcWM+RsrgZfV9xo6KfA1GlzJfxcfZcRPEhDDfzg= -cloud.google.com/go/functions v1.8.0/go.mod h1:RTZ4/HsQjIqIYP9a9YPbU+QFoQsAlYgrwOXJWHn1POY= -cloud.google.com/go/functions v1.9.0/go.mod h1:Y+Dz8yGguzO3PpIjhLTbnqV1CWmgQ5UwtlpzoyquQ08= -cloud.google.com/go/gaming v1.5.0/go.mod h1:ol7rGcxP/qHTRQE/RO4bxkXq+Fix0j6D4LFPzYTIrDM= -cloud.google.com/go/gaming v1.6.0/go.mod h1:YMU1GEvA39Qt3zWGyAVA9bpYz/yAhTvaQ1t2sK4KPUA= -cloud.google.com/go/gaming v1.7.0/go.mod h1:LrB8U7MHdGgFG851iHAfqUdLcKBdQ55hzXy9xBJz0+w= -cloud.google.com/go/gaming v1.8.0/go.mod h1:xAqjS8b7jAVW0KFYeRUxngo9My3f33kFmua++Pi+ggM= -cloud.google.com/go/gkebackup v0.2.0/go.mod h1:XKvv/4LfG829/B8B7xRkk8zRrOEbKtEam6yNfuQNH60= -cloud.google.com/go/gkebackup v0.3.0/go.mod h1:n/E671i1aOQvUxT541aTkCwExO/bTer2HDlj4TsBRAo= -cloud.google.com/go/gkeconnect v0.5.0/go.mod h1:c5lsNAg5EwAy7fkqX/+goqFsU1Da/jQFqArp+wGNr/o= -cloud.google.com/go/gkeconnect v0.6.0/go.mod h1:Mln67KyU/sHJEBY8kFZ0xTeyPtzbq9StAVvEULYK16A= -cloud.google.com/go/gkehub v0.9.0/go.mod h1:WYHN6WG8w9bXU0hqNxt8rm5uxnk8IH+lPY9J2TV7BK0= -cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y977wO+hBH0= -cloud.google.com/go/gkemulticloud v0.3.0/go.mod h1:7orzy7O0S+5kq95e4Hpn7RysVA7dPs8W/GgfUtsPbrA= -cloud.google.com/go/gkemulticloud v0.4.0/go.mod h1:E9gxVBnseLWCk24ch+P9+B2CoDFJZTyIgLKSalC7tuI= -cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= -cloud.google.com/go/gsuiteaddons v1.3.0/go.mod h1:EUNK/J1lZEZO8yPtykKxLXI6JSVN2rg9bN8SXOa0bgM= -cloud.google.com/go/gsuiteaddons v1.4.0/go.mod h1:rZK5I8hht7u7HxFQcFei0+AtfS9uSushomRlg+3ua1o= -cloud.google.com/go/iam v0.1.0/go.mod h1:vcUNEa0pEm0qRVpmWepWaFMIAI8/hjB9mO8rNCJtF6c= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= -cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHDMFMc= -cloud.google.com/go/iam v0.7.0/go.mod h1:H5Br8wRaDGNc8XP3keLc4unfUUZeyH3Sfl9XpQEYOeg= -cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGESjkE= -cloud.google.com/go/iap v1.4.0/go.mod h1:RGFwRJdihTINIe4wZ2iCP0zF/qu18ZwyKxrhMhygBEc= -cloud.google.com/go/iap v1.5.0/go.mod h1:UH/CGgKd4KyohZL5Pt0jSKE4m3FR51qg6FKQ/z/Ix9A= -cloud.google.com/go/ids v1.1.0/go.mod h1:WIuwCaYVOzHIj2OhN9HAwvW+DBdmUAdcWlFxRl+KubM= -cloud.google.com/go/ids v1.2.0/go.mod h1:5WXvp4n25S0rA/mQWAg1YEEBBq6/s+7ml1RDCW1IrcY= -cloud.google.com/go/iot v1.3.0/go.mod h1:r7RGh2B61+B8oz0AGE+J72AhA0G7tdXItODWsaA2oLs= -cloud.google.com/go/iot v1.4.0/go.mod h1:dIDxPOn0UvNDUMD8Ger7FIaTuvMkj+aGk94RPP0iV+g= -cloud.google.com/go/kms v1.4.0/go.mod h1:fajBHndQ+6ubNw6Ss2sSd+SWvjL26RNo/dr7uxsnnOA= -cloud.google.com/go/kms v1.5.0/go.mod h1:QJS2YY0eJGBg3mnDfuaCyLauWwBJiHRboYxJ++1xJNg= -cloud.google.com/go/kms v1.6.0/go.mod h1:Jjy850yySiasBUDi6KFUwUv2n1+o7QZFyuUJg6OgjA0= -cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= -cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= -cloud.google.com/go/language v1.7.0/go.mod h1:DJ6dYN/W+SQOjF8e1hLQXMF21AkH2w9wiPzPCJa2MIE= -cloud.google.com/go/language v1.8.0/go.mod h1:qYPVHf7SPoNNiCL2Dr0FfEFNil1qi3pQEyygwpgVKB8= -cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= -cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= -cloud.google.com/go/logging v1.6.1/go.mod h1:5ZO0mHHbvm8gEmeEUHrmDlTDSu5imF6MUP9OfilNXBw= -cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE= -cloud.google.com/go/longrunning v0.3.0/go.mod h1:qth9Y41RRSUE69rDcOn6DdK3HfQfsUI0YSmW3iIlLJc= -cloud.google.com/go/managedidentities v1.3.0/go.mod h1:UzlW3cBOiPrzucO5qWkNkh0w33KFtBJU281hacNvsdE= -cloud.google.com/go/managedidentities v1.4.0/go.mod h1:NWSBYbEMgqmbZsLIyKvxrYbtqOsxY1ZrGM+9RgDqInM= -cloud.google.com/go/maps v0.1.0/go.mod h1:BQM97WGyfw9FWEmQMpZ5T6cpovXXSd1cGmFma94eubI= -cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4= -cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= -cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE= -cloud.google.com/go/memcache v1.5.0/go.mod h1:dk3fCK7dVo0cUU2c36jKb4VqKPS22BTkf81Xq617aWM= -cloud.google.com/go/memcache v1.6.0/go.mod h1:XS5xB0eQZdHtTuTF9Hf8eJkKtR3pVRCcvJwtm68T3rA= -cloud.google.com/go/memcache v1.7.0/go.mod h1:ywMKfjWhNtkQTxrWxCkCFkoPjLHPW6A7WOTVI8xy3LY= -cloud.google.com/go/metastore v1.5.0/go.mod h1:2ZNrDcQwghfdtCwJ33nM0+GrBGlVuh8rakL3vdPY3XY= -cloud.google.com/go/metastore v1.6.0/go.mod h1:6cyQTls8CWXzk45G55x57DVQ9gWg7RiH65+YgPsNh9s= -cloud.google.com/go/metastore v1.7.0/go.mod h1:s45D0B4IlsINu87/AsWiEVYbLaIMeUSoxlKKDqBGFS8= -cloud.google.com/go/metastore v1.8.0/go.mod h1:zHiMc4ZUpBiM7twCIFQmJ9JMEkDSyZS9U12uf7wHqSI= -cloud.google.com/go/monitoring v1.7.0/go.mod h1:HpYse6kkGo//7p6sT0wsIC6IBDET0RhIsnmlA53dvEk= -cloud.google.com/go/monitoring v1.8.0/go.mod h1:E7PtoMJ1kQXWxPjB6mv2fhC5/15jInuulFdYYtlcvT4= -cloud.google.com/go/networkconnectivity v1.4.0/go.mod h1:nOl7YL8odKyAOtzNX73/M5/mGZgqqMeryi6UPZTk/rA= -cloud.google.com/go/networkconnectivity v1.5.0/go.mod h1:3GzqJx7uhtlM3kln0+x5wyFvuVH1pIBJjhCpjzSt75o= -cloud.google.com/go/networkconnectivity v1.6.0/go.mod h1:OJOoEXW+0LAxHh89nXd64uGG+FbQoeH8DtxCHVOMlaM= -cloud.google.com/go/networkconnectivity v1.7.0/go.mod h1:RMuSbkdbPwNMQjB5HBWD5MpTBnNm39iAVpC3TmsExt8= -cloud.google.com/go/networkmanagement v1.4.0/go.mod h1:Q9mdLLRn60AsOrPc8rs8iNV6OHXaGcDdsIQe1ohekq8= -cloud.google.com/go/networkmanagement v1.5.0/go.mod h1:ZnOeZ/evzUdUsnvRt792H0uYEnHQEMaz+REhhzJRcf4= -cloud.google.com/go/networksecurity v0.5.0/go.mod h1:xS6fOCoqpVC5zx15Z/MqkfDwH4+m/61A3ODiDV1xmiQ= -cloud.google.com/go/networksecurity v0.6.0/go.mod h1:Q5fjhTr9WMI5mbpRYEbiexTzROf7ZbDzvzCrNl14nyU= -cloud.google.com/go/notebooks v1.2.0/go.mod h1:9+wtppMfVPUeJ8fIWPOq1UnATHISkGXGqTkxeieQ6UY= -cloud.google.com/go/notebooks v1.3.0/go.mod h1:bFR5lj07DtCPC7YAAJ//vHskFBxA5JzYlH68kXVdk34= -cloud.google.com/go/notebooks v1.4.0/go.mod h1:4QPMngcwmgb6uw7Po99B2xv5ufVoIQ7nOGDyL4P8AgA= -cloud.google.com/go/notebooks v1.5.0/go.mod h1:q8mwhnP9aR8Hpfnrc5iN5IBhrXUy8S2vuYs+kBJ/gu0= -cloud.google.com/go/optimization v1.1.0/go.mod h1:5po+wfvX5AQlPznyVEZjGJTMr4+CAkJf2XSTQOOl9l4= -cloud.google.com/go/optimization v1.2.0/go.mod h1:Lr7SOHdRDENsh+WXVmQhQTrzdu9ybg0NecjHidBq6xs= -cloud.google.com/go/orchestration v1.3.0/go.mod h1:Sj5tq/JpWiB//X/q3Ngwdl5K7B7Y0KZ7bfv0wL6fqVA= -cloud.google.com/go/orchestration v1.4.0/go.mod h1:6W5NLFWs2TlniBphAViZEVhrXRSMgUGDfW7vrWKvsBk= -cloud.google.com/go/orgpolicy v1.4.0/go.mod h1:xrSLIV4RePWmP9P3tBl8S93lTmlAxjm06NSm2UTmKvE= -cloud.google.com/go/orgpolicy v1.5.0/go.mod h1:hZEc5q3wzwXJaKrsx5+Ewg0u1LxJ51nNFlext7Tanwc= -cloud.google.com/go/osconfig v1.7.0/go.mod h1:oVHeCeZELfJP7XLxcBGTMBvRO+1nQ5tFG9VQTmYS2Fs= -cloud.google.com/go/osconfig v1.8.0/go.mod h1:EQqZLu5w5XA7eKizepumcvWx+m8mJUhEwiPqWiZeEdg= -cloud.google.com/go/osconfig v1.9.0/go.mod h1:Yx+IeIZJ3bdWmzbQU4fxNl8xsZ4amB+dygAwFPlvnNo= -cloud.google.com/go/osconfig v1.10.0/go.mod h1:uMhCzqC5I8zfD9zDEAfvgVhDS8oIjySWh+l4WK6GnWw= -cloud.google.com/go/oslogin v1.4.0/go.mod h1:YdgMXWRaElXz/lDk1Na6Fh5orF7gvmJ0FGLIs9LId4E= -cloud.google.com/go/oslogin v1.5.0/go.mod h1:D260Qj11W2qx/HVF29zBg+0fd6YCSjSqLUkY/qEenQU= -cloud.google.com/go/oslogin v1.6.0/go.mod h1:zOJ1O3+dTU8WPlGEkFSh7qeHPPSoxrcMbbK1Nm2iX70= -cloud.google.com/go/oslogin v1.7.0/go.mod h1:e04SN0xO1UNJ1M5GP0vzVBFicIe4O53FOfcixIqTyXo= -cloud.google.com/go/phishingprotection v0.5.0/go.mod h1:Y3HZknsK9bc9dMi+oE8Bim0lczMU6hrX0UpADuMefr0= -cloud.google.com/go/phishingprotection v0.6.0/go.mod h1:9Y3LBLgy0kDTcYET8ZH3bq/7qni15yVUoAxiFxnlSUA= -cloud.google.com/go/policytroubleshooter v1.3.0/go.mod h1:qy0+VwANja+kKrjlQuOzmlvscn4RNsAc0e15GGqfMxg= -cloud.google.com/go/policytroubleshooter v1.4.0/go.mod h1:DZT4BcRw3QoO8ota9xw/LKtPa8lKeCByYeKTIf/vxdE= -cloud.google.com/go/privatecatalog v0.5.0/go.mod h1:XgosMUvvPyxDjAVNDYxJ7wBW8//hLDDYmnsNcMGq1K0= -cloud.google.com/go/privatecatalog v0.6.0/go.mod h1:i/fbkZR0hLN29eEWiiwue8Pb+GforiEIBnV9yrRUOKI= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/pubsub v1.26.0/go.mod h1:QgBH3U/jdJy/ftjPhTkyXNj543Tin1pRYcdcPRnFIRI= -cloud.google.com/go/pubsub v1.27.1/go.mod h1:hQN39ymbV9geqBnfQq6Xf63yNhUAhv9CZhzp5O6qsW0= -cloud.google.com/go/pubsublite v1.5.0/go.mod h1:xapqNQ1CuLfGi23Yda/9l4bBCKz/wC3KIJ5gKcxveZg= -cloud.google.com/go/recaptchaenterprise v1.3.1/go.mod h1:OdD+q+y4XGeAlxRaMn1Y7/GveP6zmq76byL6tjPE7d4= -cloud.google.com/go/recaptchaenterprise/v2 v2.1.0/go.mod h1:w9yVqajwroDNTfGuhmOjPDN//rZGySaf6PtFVcSCa7o= -cloud.google.com/go/recaptchaenterprise/v2 v2.2.0/go.mod h1:/Zu5jisWGeERrd5HnlS3EUGb/D335f9k51B/FVil0jk= -cloud.google.com/go/recaptchaenterprise/v2 v2.3.0/go.mod h1:O9LwGCjrhGHBQET5CA7dd5NwwNQUErSgEDit1DLNTdo= -cloud.google.com/go/recaptchaenterprise/v2 v2.4.0/go.mod h1:Am3LHfOuBstrLrNCBrlI5sbwx9LBg3te2N6hGvHn2mE= -cloud.google.com/go/recaptchaenterprise/v2 v2.5.0/go.mod h1:O8LzcHXN3rz0j+LBC91jrwI3R+1ZSZEWrfL7XHgNo9U= -cloud.google.com/go/recommendationengine v0.5.0/go.mod h1:E5756pJcVFeVgaQv3WNpImkFP8a+RptV6dDLGPILjvg= -cloud.google.com/go/recommendationengine v0.6.0/go.mod h1:08mq2umu9oIqc7tDy8sx+MNJdLG0fUi3vaSVbztHgJ4= -cloud.google.com/go/recommender v1.5.0/go.mod h1:jdoeiBIVrJe9gQjwd759ecLJbxCDED4A6p+mqoqDvTg= -cloud.google.com/go/recommender v1.6.0/go.mod h1:+yETpm25mcoiECKh9DEScGzIRyDKpZ0cEhWGo+8bo+c= -cloud.google.com/go/recommender v1.7.0/go.mod h1:XLHs/W+T8olwlGOgfQenXBTbIseGclClff6lhFVe9Bs= -cloud.google.com/go/recommender v1.8.0/go.mod h1:PkjXrTT05BFKwxaUxQmtIlrtj0kph108r02ZZQ5FE70= -cloud.google.com/go/redis v1.7.0/go.mod h1:V3x5Jq1jzUcg+UNsRvdmsfuFnit1cfe3Z/PGyq/lm4Y= -cloud.google.com/go/redis v1.8.0/go.mod h1:Fm2szCDavWzBk2cDKxrkmWBqoCiL1+Ctwq7EyqBCA/A= -cloud.google.com/go/redis v1.9.0/go.mod h1:HMYQuajvb2D0LvMgZmLDZW8V5aOC/WxstZHiy4g8OiA= -cloud.google.com/go/redis v1.10.0/go.mod h1:ThJf3mMBQtW18JzGgh41/Wld6vnDDc/F/F35UolRZPM= -cloud.google.com/go/resourcemanager v1.3.0/go.mod h1:bAtrTjZQFJkiWTPDb1WBjzvc6/kifjj4QBYuKCCoqKA= -cloud.google.com/go/resourcemanager v1.4.0/go.mod h1:MwxuzkumyTX7/a3n37gmsT3py7LIXwrShilPh3P1tR0= -cloud.google.com/go/resourcesettings v1.3.0/go.mod h1:lzew8VfESA5DQ8gdlHwMrqZs1S9V87v3oCnKCWoOuQU= -cloud.google.com/go/resourcesettings v1.4.0/go.mod h1:ldiH9IJpcrlC3VSuCGvjR5of/ezRrOxFtpJoJo5SmXg= -cloud.google.com/go/retail v1.8.0/go.mod h1:QblKS8waDmNUhghY2TI9O3JLlFk8jybHeV4BF19FrE4= -cloud.google.com/go/retail v1.9.0/go.mod h1:g6jb6mKuCS1QKnH/dpu7isX253absFl6iE92nHwlBUY= -cloud.google.com/go/retail v1.10.0/go.mod h1:2gDk9HsL4HMS4oZwz6daui2/jmKvqShXKQuB2RZ+cCc= -cloud.google.com/go/retail v1.11.0/go.mod h1:MBLk1NaWPmh6iVFSz9MeKG/Psyd7TAgm6y/9L2B4x9Y= -cloud.google.com/go/run v0.2.0/go.mod h1:CNtKsTA1sDcnqqIFR3Pb5Tq0usWxJJvsWOCPldRU3Do= -cloud.google.com/go/run v0.3.0/go.mod h1:TuyY1+taHxTjrD0ZFk2iAR+xyOXEA0ztb7U3UNA0zBo= -cloud.google.com/go/scheduler v1.4.0/go.mod h1:drcJBmxF3aqZJRhmkHQ9b3uSSpQoltBPGPxGAWROx6s= -cloud.google.com/go/scheduler v1.5.0/go.mod h1:ri073ym49NW3AfT6DZi21vLZrG07GXr5p3H1KxN5QlI= -cloud.google.com/go/scheduler v1.6.0/go.mod h1:SgeKVM7MIwPn3BqtcBntpLyrIJftQISRrYB5ZtT+KOk= -cloud.google.com/go/scheduler v1.7.0/go.mod h1:jyCiBqWW956uBjjPMMuX09n3x37mtyPJegEWKxRsn44= -cloud.google.com/go/secretmanager v1.6.0/go.mod h1:awVa/OXF6IiyaU1wQ34inzQNc4ISIDIrId8qE5QGgKA= -cloud.google.com/go/secretmanager v1.8.0/go.mod h1:hnVgi/bN5MYHd3Gt0SPuTPPp5ENina1/LxM+2W9U9J4= -cloud.google.com/go/secretmanager v1.9.0/go.mod h1:b71qH2l1yHmWQHt9LC80akm86mX8AL6X1MA01dW8ht4= -cloud.google.com/go/security v1.5.0/go.mod h1:lgxGdyOKKjHL4YG3/YwIL2zLqMFCKs0UbQwgyZmfJl4= -cloud.google.com/go/security v1.7.0/go.mod h1:mZklORHl6Bg7CNnnjLH//0UlAlaXqiG7Lb9PsPXLfD0= -cloud.google.com/go/security v1.8.0/go.mod h1:hAQOwgmaHhztFhiQ41CjDODdWP0+AE1B3sX4OFlq+GU= -cloud.google.com/go/security v1.9.0/go.mod h1:6Ta1bO8LXI89nZnmnsZGp9lVoVWXqsVbIq/t9dzI+2Q= -cloud.google.com/go/security v1.10.0/go.mod h1:QtOMZByJVlibUT2h9afNDWRZ1G96gVywH8T5GUSb9IA= -cloud.google.com/go/securitycenter v1.13.0/go.mod h1:cv5qNAqjY84FCN6Y9z28WlkKXyWsgLO832YiWwkCWcU= -cloud.google.com/go/securitycenter v1.14.0/go.mod h1:gZLAhtyKv85n52XYWt6RmeBdydyxfPeTrpToDPw4Auc= -cloud.google.com/go/securitycenter v1.15.0/go.mod h1:PeKJ0t8MoFmmXLXWm41JidyzI3PJjd8sXWaVqg43WWk= -cloud.google.com/go/securitycenter v1.16.0/go.mod h1:Q9GMaLQFUD+5ZTabrbujNWLtSLZIZF7SAR0wWECrjdk= -cloud.google.com/go/servicecontrol v1.4.0/go.mod h1:o0hUSJ1TXJAmi/7fLJAedOovnujSEvjKCAFNXPQ1RaU= -cloud.google.com/go/servicecontrol v1.5.0/go.mod h1:qM0CnXHhyqKVuiZnGKrIurvVImCs8gmqWsDoqe9sU1s= -cloud.google.com/go/servicedirectory v1.4.0/go.mod h1:gH1MUaZCgtP7qQiI+F+A+OpeKF/HQWgtAddhTbhL2bs= -cloud.google.com/go/servicedirectory v1.5.0/go.mod h1:QMKFL0NUySbpZJ1UZs3oFAmdvVxhhxB6eJ/Vlp73dfg= -cloud.google.com/go/servicedirectory v1.6.0/go.mod h1:pUlbnWsLH9c13yGkxCmfumWEPjsRs1RlmJ4pqiNjVL4= -cloud.google.com/go/servicedirectory v1.7.0/go.mod h1:5p/U5oyvgYGYejufvxhgwjL8UVXjkuw7q5XcG10wx1U= -cloud.google.com/go/servicemanagement v1.4.0/go.mod h1:d8t8MDbezI7Z2R1O/wu8oTggo3BI2GKYbdG4y/SJTco= -cloud.google.com/go/servicemanagement v1.5.0/go.mod h1:XGaCRe57kfqu4+lRxaFEAuqmjzF0r+gWHjWqKqBvKFo= -cloud.google.com/go/serviceusage v1.3.0/go.mod h1:Hya1cozXM4SeSKTAgGXgj97GlqUvF5JaoXacR1JTP/E= -cloud.google.com/go/serviceusage v1.4.0/go.mod h1:SB4yxXSaYVuUBYUml6qklyONXNLt83U0Rb+CXyhjEeU= -cloud.google.com/go/shell v1.3.0/go.mod h1:VZ9HmRjZBsjLGXusm7K5Q5lzzByZmJHf1d0IWHEN5X4= -cloud.google.com/go/shell v1.4.0/go.mod h1:HDxPzZf3GkDdhExzD/gs8Grqk+dmYcEjGShZgYa9URw= -cloud.google.com/go/spanner v1.41.0/go.mod h1:MLYDBJR/dY4Wt7ZaMIQ7rXOTLjYrmxLE/5ve9vFfWos= -cloud.google.com/go/speech v1.6.0/go.mod h1:79tcr4FHCimOp56lwC01xnt/WPJZc4v3gzyT7FoBkCM= -cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ= -cloud.google.com/go/speech v1.8.0/go.mod h1:9bYIl1/tjsAnMgKGHKmBZzXKEkGgtU+MpdDPTE9f7y0= -cloud.google.com/go/speech v1.9.0/go.mod h1:xQ0jTcmnRFFM2RfX/U+rk6FQNUF6DQlydUSyoooSpco= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= -cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= -cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -cloud.google.com/go/storagetransfer v1.5.0/go.mod h1:dxNzUopWy7RQevYFHewchb29POFv3/AaBgnhqzqiK0w= -cloud.google.com/go/storagetransfer v1.6.0/go.mod h1:y77xm4CQV/ZhFZH75PLEXY0ROiS7Gh6pSKrM8dJyg6I= -cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= -cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= -cloud.google.com/go/talent v1.3.0/go.mod h1:CmcxwJ/PKfRgd1pBjQgU6W3YBwiewmUzQYH5HHmSCmM= -cloud.google.com/go/talent v1.4.0/go.mod h1:ezFtAgVuRf8jRsvyE6EwmbTK5LKciD4KVnHuDEFmOOA= -cloud.google.com/go/texttospeech v1.4.0/go.mod h1:FX8HQHA6sEpJ7rCMSfXuzBcysDAuWusNNNvN9FELDd8= -cloud.google.com/go/texttospeech v1.5.0/go.mod h1:oKPLhR4n4ZdQqWKURdwxMy0uiTS1xU161C8W57Wkea4= -cloud.google.com/go/tpu v1.3.0/go.mod h1:aJIManG0o20tfDQlRIej44FcwGGl/cD0oiRyMKG19IQ= -cloud.google.com/go/tpu v1.4.0/go.mod h1:mjZaX8p0VBgllCzF6wcU2ovUXN9TONFLd7iz227X2Xg= -cloud.google.com/go/trace v1.3.0/go.mod h1:FFUE83d9Ca57C+K8rDl/Ih8LwOzWIV1krKgxg6N0G28= -cloud.google.com/go/trace v1.4.0/go.mod h1:UG0v8UBqzusp+z63o7FK74SdFE+AXpCLdFb1rshXG+Y= -cloud.google.com/go/translate v1.3.0/go.mod h1:gzMUwRjvOqj5i69y/LYLd8RrNQk+hOmIXTi9+nb3Djs= -cloud.google.com/go/translate v1.4.0/go.mod h1:06Dn/ppvLD6WvA5Rhdp029IX2Mi3Mn7fpMRLPvXT5Wg= -cloud.google.com/go/video v1.8.0/go.mod h1:sTzKFc0bUSByE8Yoh8X0mn8bMymItVGPfTuUBUyRgxk= -cloud.google.com/go/video v1.9.0/go.mod h1:0RhNKFRF5v92f8dQt0yhaHrEuH95m068JYOvLZYnJSw= -cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= -cloud.google.com/go/videointelligence v1.7.0/go.mod h1:k8pI/1wAhjznARtVT9U1llUaFNPh7muw8QyOUpavru4= -cloud.google.com/go/videointelligence v1.8.0/go.mod h1:dIcCn4gVDdS7yte/w+koiXn5dWVplOZkE+xwG9FgK+M= -cloud.google.com/go/videointelligence v1.9.0/go.mod h1:29lVRMPDYHikk3v8EdPSaL8Ku+eMzDljjuvRs105XoU= -cloud.google.com/go/vision v1.2.0/go.mod h1:SmNwgObm5DpFBme2xpyOyasvBc1aPdjvMk2bBk0tKD0= -cloud.google.com/go/vision/v2 v2.2.0/go.mod h1:uCdV4PpN1S0jyCyq8sIM42v2Y6zOLkZs+4R9LrGYwFo= -cloud.google.com/go/vision/v2 v2.3.0/go.mod h1:UO61abBx9QRMFkNBbf1D8B1LXdS2cGiiCRx0vSpZoUo= -cloud.google.com/go/vision/v2 v2.4.0/go.mod h1:VtI579ll9RpVTrdKdkMzckdnwMyX2JILb+MhPqRbPsY= -cloud.google.com/go/vision/v2 v2.5.0/go.mod h1:MmaezXOOE+IWa+cS7OhRRLK2cNv1ZL98zhqFFZaaH2E= -cloud.google.com/go/vmmigration v1.2.0/go.mod h1:IRf0o7myyWFSmVR1ItrBSFLFD/rJkfDCUTO4vLlJvsE= -cloud.google.com/go/vmmigration v1.3.0/go.mod h1:oGJ6ZgGPQOFdjHuocGcLqX4lc98YQ7Ygq8YQwHh9A7g= -cloud.google.com/go/vmwareengine v0.1.0/go.mod h1:RsdNEf/8UDvKllXhMz5J40XxDrNJNN4sagiox+OI208= -cloud.google.com/go/vpcaccess v1.4.0/go.mod h1:aQHVbTWDYUR1EbTApSVvMq1EnT57ppDmQzZ3imqIk4w= -cloud.google.com/go/vpcaccess v1.5.0/go.mod h1:drmg4HLk9NkZpGfCmZ3Tz0Bwnm2+DKqViEpeEpOq0m8= -cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xXZmFiHmGE= -cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= -cloud.google.com/go/webrisk v1.6.0/go.mod h1:65sW9V9rOosnc9ZY7A7jsy1zoHS5W9IAXv6dGqhMQMc= -cloud.google.com/go/webrisk v1.7.0/go.mod h1:mVMHgEYH0r337nmt1JyLthzMr6YxwN1aAIEc2fTcq7A= -cloud.google.com/go/websecurityscanner v1.3.0/go.mod h1:uImdKm2wyeXQevQJXeh8Uun/Ym1VqworNDlBXQevGMo= -cloud.google.com/go/websecurityscanner v1.4.0/go.mod h1:ebit/Fp0a+FWu5j4JOmJEV8S8CzdTkAS77oDsiSqYWQ= -cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= -cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M= -cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= -github.com/envoyproxy/go-control-plane v0.10.3/go.mod h1:fJJn/j26vwOu972OllsvAgJJM//w9BV6Fxbg2LuVd34= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= -github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= -github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= -github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= -github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.77.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= -google.golang.org/api v0.85.0/go.mod h1:AqZf8Ep9uZ2pyTvgL+x0D3Zt0eoT9b5E8fmzfu6FO2g= -google.golang.org/api v0.90.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.93.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.95.0/go.mod h1:eADj+UBuxkh5zlrSntJghuNeg8HwQ1w5lTKkuqaETEI= -google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.99.0/go.mod h1:1YOf74vkVndF7pG6hIHuINsM7eWwpVTAfNMNiL91A08= -google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= -google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo= -google.golang.org/api v0.103.0/go.mod h1:hGtW6nK1AC+d9si/UBhw8Xli+QMOf6xyNAyJw4qU9w0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220329172620-7be39ac1afc7/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220722212130-b98a9ff5e252/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE= -google.golang.org/genproto v0.0.0-20220801145646-83ce21fca29f/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= -google.golang.org/genproto v0.0.0-20220815135757-37a418bb8959/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220817144833-d7fd3f11b9b1/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829144015-23454907ede3/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220913154956-18f8339a66a5/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220914142337-ca0e39ece12f/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220915135415-7fd63a7952de/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220916172020-2692e8806bfa/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220919141832-68c03719ef51/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006/go.mod h1:ht8XFiar2npT/g4vkk7O0WYS1sHOHbdujxbEp7CJWbw= -google.golang.org/genproto v0.0.0-20220926165614-551eb538f295/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20220926220553-6981cbe3cfce/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqwhZAwq4wsRUaVG555sVgsNmIjRtO7t/JH29U= -google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20221024153911-1573dae28c9c/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo= -google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221117204609-8f9c96812029/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd/go.mod h1:cTsE614GARnxrLsqKREzmNYJACSWWpAWdNMwnD7c2BE= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/samples/grpc_server/main.go b/samples/grpc_server/main.go index f441f6f45a2..86ea5d85d96 100644 --- a/samples/grpc_server/main.go +++ b/samples/grpc_server/main.go @@ -37,11 +37,11 @@ import ( "time" "google.golang.org/grpc" + "google.golang.org/protobuf/proto" "google.golang.org/grpc/credentials" "google.golang.org/grpc/testdata" - "github.com/golang/protobuf/proto" "google.golang.org/grpc/reflection" ) From 71aa71a354953ada064aaef5daa8e5fc0e9e8ca0 Mon Sep 17 00:00:00 2001 From: Nedyalko Andreev Date: Mon, 27 Feb 2023 14:41:19 +0200 Subject: [PATCH 6/6] Update golang.org/x dependencies in samples/grpc_server/ --- samples/grpc_server/go.mod | 6 +++--- samples/grpc_server/go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/samples/grpc_server/go.mod b/samples/grpc_server/go.mod index e77d9e98d10..9e06ab7c858 100644 --- a/samples/grpc_server/go.mod +++ b/samples/grpc_server/go.mod @@ -9,8 +9,8 @@ require ( require ( github.com/golang/protobuf v1.5.2 // indirect - golang.org/x/net v0.5.0 // indirect - golang.org/x/sys v0.4.0 // indirect - golang.org/x/text v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect ) diff --git a/samples/grpc_server/go.sum b/samples/grpc_server/go.sum index 751fe9d3621..b4639f1f65f 100644 --- a/samples/grpc_server/go.sum +++ b/samples/grpc_server/go.sum @@ -3,12 +3,12 @@ github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=