diff --git a/go.mod b/go.mod index 2e0d30ebd5..9e68a247d5 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ go 1.27.0 // so no build can restore it. require ( - charm.land/bubbles/v2 v2.1.1 - charm.land/bubbletea/v2 v2.0.8 + charm.land/bubbles/v2 v2.2.1 + charm.land/bubbletea/v2 v2.0.9 charm.land/lipgloss/v2 v2.0.6 charm.land/ssh v0.4.3 charm.land/wish/v2 v2.0.3 @@ -24,20 +24,20 @@ require ( github.com/gaissmai/bart v0.29.0 github.com/gokrazy/tools v0.0.0-20260703063348-3fe400c13246 github.com/gokrazy/updater v0.0.0-20260620140544-0a84d8ab3878 - github.com/golangci/golangci-lint/v2 v2.13.1 + github.com/golangci/golangci-lint/v2 v2.13.2 github.com/google/nftables v0.3.0 github.com/insomniacslk/dhcp v0.0.0-20260719225207-c76316d4aa82 github.com/mdlayher/genetlink v1.4.0 github.com/mdlayher/netlink v1.11.2 github.com/mdlayher/packet v1.1.2 - github.com/miekg/dns v1.1.72 + github.com/miekg/dns v1.1.73 github.com/muesli/reflow v0.3.0 github.com/openconfig/gnmi v0.14.1 github.com/openconfig/goyang v1.6.3 github.com/packetcap/go-pcap v0.0.0-20251215121130-f2cf9f991e7c github.com/prometheus/client_golang v1.24.1 - github.com/prometheus/procfs v0.21.1 - github.com/sirupsen/logrus v1.10.1 + github.com/prometheus/procfs v0.22.0 + github.com/sirupsen/logrus v1.10.2 github.com/sivchari/gomu v0.2.1 github.com/stretchr/testify v1.12.1 github.com/vishvananda/netlink v1.3.1 @@ -50,10 +50,10 @@ require ( golang.org/x/sys v0.47.0 golang.org/x/term v0.45.0 golang.org/x/tools v0.49.0 - golang.org/x/tools/gopls v0.0.0-20260827201838-8471f958f05f // first Go 1.27-compatible revision after v0.23.0 - golang.org/x/vuln v1.6.0 + golang.org/x/tools/gopls v0.23.0 // first Go 1.27-compatible revision after v0.23.0 + golang.org/x/vuln v1.7.0 golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10 - google.golang.org/grpc v1.83.1 + google.golang.org/grpc v1.83.2 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.2 google.golang.org/protobuf v1.36.12 gopkg.in/yaml.v3 v3.0.1 @@ -154,6 +154,7 @@ require ( github.com/gokrazy/gokapi v0.0.0-20251205165548-0927bab199d4 // indirect github.com/gokrazy/internal v0.0.0-20260625065634-6994f9152c44 // indirect github.com/golangci/asciicheck v0.5.0 // indirect + github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6 // indirect github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 // indirect github.com/golangci/go-printf-func-name v0.1.1 // indirect github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792 // indirect @@ -188,7 +189,6 @@ require ( github.com/klauspost/compress v1.19.1 // indirect github.com/kulti/thelper v0.7.1 // indirect github.com/kunwardeep/paralleltest v1.0.15 // indirect - github.com/lasiar/canonicalheader v1.1.2 // indirect github.com/ldez/exptostd v0.4.5 // indirect github.com/ldez/gomoddirectives v0.9.0 // indirect github.com/ldez/grignotin v0.10.1 // indirect @@ -207,7 +207,7 @@ require ( github.com/matoous/godox v1.1.0 // indirect github.com/mattn/go-colorable v0.1.15 // indirect github.com/mattn/go-isatty v0.0.22 // indirect - github.com/mattn/go-runewidth v0.0.24 // indirect + github.com/mattn/go-runewidth v0.0.27 // indirect github.com/mdlayher/socket v0.6.0 // indirect github.com/mgechev/revive v1.15.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -267,7 +267,7 @@ require ( github.com/ultraware/funlen v0.2.0 // indirect github.com/ultraware/whitespace v0.2.0 // indirect github.com/uudashr/gocognit v1.2.1 // indirect - github.com/uudashr/iface v1.5.0 // indirect + github.com/uudashr/iface v1.5.1 // indirect github.com/xen0n/gosmopolitan v1.3.0 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yagipy/maintidx v1.0.0 // indirect @@ -294,6 +294,6 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect mvdan.cc/gofumpt v0.11.0 // indirect - mvdan.cc/unparam v0.0.0-20260818115549-3f964bcb5673 // indirect + mvdan.cc/unparam v0.0.0-20260823230713-2fa3d841b0c8 // indirect mvdan.cc/xurls/v2 v2.6.0 // indirect ) diff --git a/go.sum b/go.sum index 407f955676..19ed85aba1 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ 4d63.com/gocheckcompilerdirectives v1.4.0/go.mod h1:9ZOAiMOjqC/nRwci2fcUXVHUNLG/cH6r6rhUh+jTFtQ= 4d63.com/gochecknoglobals v0.2.2 h1:H1vdnwnMaZdQW/N+NrkT1SZMTBmcwHe9Vq8lJcYYTtU= 4d63.com/gochecknoglobals v0.2.2/go.mod h1:lLxwTQjL5eIesRbvnzIP3jZtG140FnTdz+AlMa+ogt0= -charm.land/bubbles/v2 v2.1.1 h1:7r55WzBxpo/R3z98hGmY7KKPd3ET6vsf0Fb9sDHOV60= -charm.land/bubbles/v2 v2.1.1/go.mod h1:GE6M31gaWZVXzGw73OeuTTgy4lX+OtkH0E5ymnNsHxo= -charm.land/bubbletea/v2 v2.0.8 h1:SxTJMhCAI3lbPmy4SgX5LWZ24AdINr4I6UEqzZvYJuY= -charm.land/bubbletea/v2 v2.0.8/go.mod h1:2SkdgoTXluXJHOUwAoRlRXF/28vklb1rFl6GcgV1/ss= +charm.land/bubbles/v2 v2.2.1 h1:Fq1+qm5hV6GkvzLQDhCBpXXE5tLgvh1PRriCLwSvIQU= +charm.land/bubbles/v2 v2.2.1/go.mod h1:wdMgn+sje1KNXdwFizIWjbf328fIUBxqEmJ/vYPo8yc= +charm.land/bubbletea/v2 v2.0.9 h1:DpJCMWKgzQK8SJv4zbKKFHAI10ymWy/evClPFk0k0f8= +charm.land/bubbletea/v2 v2.0.9/go.mod h1:2SkdgoTXluXJHOUwAoRlRXF/28vklb1rFl6GcgV1/ss= charm.land/lipgloss/v2 v2.0.6 h1:EaGKeuA8FvF+v2BT5VmZd2LoYLaMZJXA5n34th8nCIQ= charm.land/lipgloss/v2 v2.0.6/go.mod h1:ipDDJNSGa1hlwDtSfW1s2/xR8Vdhbut4PXh2zEKZd0Q= charm.land/log/v2 v2.0.0 h1:SY3Cey7ipx86/MBXQHwsguOT6X1exT94mmJRdzTNs+s= @@ -250,14 +250,16 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golangci/asciicheck v0.5.0 h1:jczN/BorERZwK8oiFBOGvlGPknhvq0bjnysTj4nUfo0= github.com/golangci/asciicheck v0.5.0/go.mod h1:5RMNAInbNFw2krqN6ibBxN/zfRFa9S6tA1nPdM0l8qQ= +github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6 h1:fVLolA3dG6s0brGetsiDAtcnpMSwVa2LqXJEw/9RJG4= +github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6/go.mod h1:1xo+NFW5S+bEf2DKXhaxuzvcDN5AR6o/KMwvqC5Mkpo= github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 h1:CbTB8KpqnViI6lIXxp03Oclc4VFHi3K4BWC1TacsZ+A= github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202/go.mod h1:NUw9Zr2Sy7+HxzdjIULge71wI6yEg1lWQr7Evcu8K0E= github.com/golangci/go-printf-func-name v0.1.1 h1:hIYTFJqAGp1iwoIfsNTpoq1xZAarogrvjO9AfiW3B4U= github.com/golangci/go-printf-func-name v0.1.1/go.mod h1:Es64MpWEZbh0UBtTAICOZiB+miW53w/K9Or/4QogJss= github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792 h1:WL8YKrt3UbOBqSRU7GpP5BTtQTMWtVtj+mfPijgZeIg= github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792/go.mod h1:te5hX0dW4C5r6YbXs+6ysNr8Q5UTmdIqGbb+mlFiYmA= -github.com/golangci/golangci-lint/v2 v2.13.1 h1:RuM4OcluM4xFQcGuRE6R7jA33pqxK/W1EsBxpugdZjg= -github.com/golangci/golangci-lint/v2 v2.13.1/go.mod h1:HwX7mDzqHbcSxlhrTygjX1GJbAfQ3sJAqOx41qQlhDE= +github.com/golangci/golangci-lint/v2 v2.13.2 h1:bCyq3E4vo9qwzifjpzJqYndEt7Ncva80qkk8G2B4TXU= +github.com/golangci/golangci-lint/v2 v2.13.2/go.mod h1:5xaMd1kAxV7GSBPEyngw8gnnjoRocqW9UVKdBR6627w= github.com/golangci/golines v0.15.0 h1:Qnph25g8Y1c5fdo1X7GaRDGgnMHgnxh4Gk4VfPTtRx0= github.com/golangci/golines v0.15.0/go.mod h1:AZjXd23tbHMpowhtnGlj9KCNsysj72aeZVVHnVcZx10= github.com/golangci/misspell v0.8.0 h1:qvxQhiE2/5z+BVRo1kwYA8yGz+lOlu5Jfvtx2b04Jbg= @@ -361,8 +363,6 @@ github.com/kunwardeep/paralleltest v1.0.15 h1:ZMk4Qt306tHIgKISHWFJAO1IDQJLc6uDyJ github.com/kunwardeep/paralleltest v1.0.15/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4= -github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI= github.com/ldez/exptostd v0.4.5 h1:kv2ZGUVI6VwRfp/+bcQ6Nbx0ghFWcGIKInkG/oFn1aQ= github.com/ldez/exptostd v0.4.5/go.mod h1:QRjHRMXJrCTIm9WxVNH6VW7oN7KrGSht69bIRwvdFsM= github.com/ldez/gomoddirectives v0.9.0 h1:2YV/EX7nVlWL4jySusYTzBKHuE3D2fgcRsQuMa3yIoo= @@ -403,8 +403,8 @@ github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stg github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4= github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU= -github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= +github.com/mattn/go-runewidth v0.0.27 h1:Feg/Oou5zI/wnpgDF6omIU0OokC9GxLC/WRknhVlIR0= +github.com/mattn/go-runewidth v0.0.27/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8= github.com/mdlayher/genetlink v1.4.0 h1:f/Xs7Y2T+GyX9b3dbiUhnLE9InGs5F9RxJ2JwBMl71o= github.com/mdlayher/genetlink v1.4.0/go.mod h1:d1hrKr8fwZU2JkcAtQUAzeTrI7nbgQSl+5k1cC0biSA= github.com/mdlayher/netlink v1.11.2 h1:HKh2jqe+omdSWcQ88nrT7INE61B0NXfiSPFdgL4YbNI= @@ -415,8 +415,8 @@ github.com/mdlayher/socket v0.6.0 h1:ScZPaAGyO1icQnbFrhPM8mnXyMu9qukC1K4ZoM2IQKU github.com/mdlayher/socket v0.6.0/go.mod h1:q7vozUAnxSqnjHc12Fik5yUKIzfZ8ITCfMkhOtE9z18= github.com/mgechev/revive v1.15.0 h1:vJ0HzSBzfNyPbHKolgiFjHxLek9KUijhqh42yGoqZ8Q= github.com/mgechev/revive v1.15.0/go.mod h1:LlAKO3QQe9OJ0pVZzI2GPa8CbXGZ/9lNpCGvK4T/a8A= -github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI= -github.com/miekg/dns v1.1.72/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs= +github.com/miekg/dns v1.1.73 h1:uhT8nJxmTrPJYClxVxTCX+CVn6qnzSiybRk72Z6DgrE= +github.com/miekg/dns v1.1.73/go.mod h1:RW2Obtfd5NZHvOFe3zYG0W8koWOQtAzyHaLo8vASBuQ= github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721 h1:RlZweED6sbSArvlE924+mUcZuXKLBHA35U7LN621Bws= github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -475,8 +475,8 @@ github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNw github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY= github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc= -github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI= -github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY= +github.com/prometheus/procfs v0.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics= +github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58= github.com/quasilyte/go-ruleguard v0.4.5 h1:AGY0tiOT5hJX9BTdx/xBdoCubQUAE2grkqY2lSwvZcA= github.com/quasilyte/go-ruleguard v0.4.5/go.mod h1:Vl05zJ538vcEEwu16V/Hdu7IYZWyKSwIy4c88Ro1kRE= github.com/quasilyte/go-ruleguard/dsl v0.3.23 h1:lxjt5B6ZCiBeeNO8/oQsegE6fLeCzuMRoVWSkXC4uvY= @@ -518,8 +518,8 @@ github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfv github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= -github.com/sirupsen/logrus v1.10.1 h1:xi4336Zh11WpU14fXR6I67V3yaTPQYwRx2WEtHbRg4Q= -github.com/sirupsen/logrus v1.10.1/go.mod h1:vsQHnG7xzNsxk3NrwboUiWPnIC3dmbjcGPykD7+tiHk= +github.com/sirupsen/logrus v1.10.2 h1:G2SED73/qrAu6YwbdxOD6peLkCBI3z7L+ykJFTXJBBo= +github.com/sirupsen/logrus v1.10.2/go.mod h1:SLEg8TqYulVKKfIGHldVp2K2aYz2DKSVBq4g/H5bR7Q= github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE= github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= github.com/sivchari/gomu v0.2.1 h1:w+CwPZXXeYFlLnbcNQ/3VbSClx5yf5pite56V+m9Xuo= @@ -578,8 +578,8 @@ github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSW github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= github.com/uudashr/gocognit v1.2.1 h1:CSJynt5txTnORn/DkhiB4mZjwPuifyASC8/6Q0I/QS4= github.com/uudashr/gocognit v1.2.1/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q= -github.com/uudashr/iface v1.5.0 h1:PgdMt4uAettGG8K/Kbamc4B9FABgUgnS3TLbl6fnjEk= -github.com/uudashr/iface v1.5.0/go.mod h1:pbeBPlbuU2qkNDn0mmfrxP2X+wjPMIQAy+r1MBXSXtg= +github.com/uudashr/iface v1.5.1 h1:BS3yrgaT55s3dAtJoxuTnsZNbsejq/mVuzp49YDyfBA= +github.com/uudashr/iface v1.5.1/go.mod h1:5UWoT6SvTdTww/KToRj6clO+n4Kg3/NrAQvgOB+5Ggw= github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW6bV0= github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= @@ -768,10 +768,10 @@ golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnps golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= -golang.org/x/tools/gopls v0.0.0-20260827201838-8471f958f05f h1:S8P21cqEuoxTVxZRLrNt+NeIgSBtJ7KPH7EplvOmdFc= -golang.org/x/tools/gopls v0.0.0-20260827201838-8471f958f05f/go.mod h1:uEkESENIgVvy7qQxNvYYmnbHzbetLR0ckeqTfQ3VCn4= -golang.org/x/vuln v1.6.0 h1:FeMO9Rm/HwyduOztbvKcOw+zvDEPr4I4aQNSfevFcKY= -golang.org/x/vuln v1.6.0/go.mod h1:bWlG2493/sjR7ksvicBgMrznH3eYQEyK8ifUYBrqUbg= +golang.org/x/tools/gopls v0.23.0 h1:Dn6mf9WXu9iLnTftDDMb9wV0c6Se7PjzEMqP0LEe08Y= +golang.org/x/tools/gopls v0.23.0/go.mod h1:Ijg67bAdTicg9IINxII7MV+dQpHEXM4646WpNWVYBP0= +golang.org/x/vuln v1.7.0 h1:4MQBuhmXbz2uepNJrf3v+aaZLGDqw1JluwYboegA1qg= +golang.org/x/vuln v1.7.0/go.mod h1:Xw7zvU3e1bsCYYBXu+w4wcn2Kgn27f34WBCTw8LL5Us= 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= @@ -784,8 +784,8 @@ gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 h1:qEHAMpSaUhtD0p3NbEEI83HwNGFxEwaSJ1G9PLnCBZE= google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/grpc v1.83.1 h1:HIO0+BEtBP6soyqvqC8sNUjZ7bTs+0hFQuFF+RAy++Y= -google.golang.org/grpc v1.83.1/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ= +google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= +google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.2 h1:rgSNvqscFZ1JgV/4wH5GOsZFSFkR2Eua9As3KIr2LlM= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.2/go.mod h1:iMEtFwDlAhjDU9L5mY6U1XLwlIId/G3h+QcBHDIvrJ8= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= @@ -804,7 +804,7 @@ honnef.co/go/tools v0.8.1 h1:+JKf3xJ1ni4CwrhVg4/pqsfPGP6vNAXcKbMXJodYx3w= honnef.co/go/tools v0.8.1/go.mod h1:XA+OnlRA9EDh/ukGvXMNSZNKGwFQJ+5dER0ioUkOxks= mvdan.cc/gofumpt v0.11.0 h1:0H01XB95PnN2QgCSR9ELdZyTlJqNZ7181B0BTMh5VZc= mvdan.cc/gofumpt v0.11.0/go.mod h1:BeT5wCsOJt6J9zT2MZIOGszjUHzFkn1/l9g6xAzqsXo= -mvdan.cc/unparam v0.0.0-20260818115549-3f964bcb5673 h1:dEE6li4OPIE54oojY2qaayFS1fSp17G14si0gXRxl0U= -mvdan.cc/unparam v0.0.0-20260818115549-3f964bcb5673/go.mod h1:62roFV3D3nYOWIXv3PfGO4UYEKAotz2WgLywT87ONd8= +mvdan.cc/unparam v0.0.0-20260823230713-2fa3d841b0c8 h1:Re1NRyLpiAt9kB+ImaaoapwWiQXrKwER4tY8fLOkDew= +mvdan.cc/unparam v0.0.0-20260823230713-2fa3d841b0c8/go.mod h1:MrS/+zJ1M2xvGXhKktiHbNQeQPyg3Qel+KkzT+f7/i4= mvdan.cc/xurls/v2 v2.6.0 h1:3NTZpeTxYVWNSokW3MKeyVkz/j7uYXYiMtXRUfmjbgI= mvdan.cc/xurls/v2 v2.6.0/go.mod h1:bCvEZ1XvdA6wDnxY7jPPjEmigDtvtvPXAD/Exa9IMSk= diff --git a/vendor/charm.land/bubbles/v2/textinput/textinput.go b/vendor/charm.land/bubbles/v2/textinput/textinput.go index 9b4a75499b..c47738c111 100644 --- a/vendor/charm.land/bubbles/v2/textinput/textinput.go +++ b/vendor/charm.land/bubbles/v2/textinput/textinput.go @@ -71,8 +71,8 @@ func DefaultKeyMap() KeyMap { CharacterBackward: key.NewBinding(key.WithKeys("left", "ctrl+b")), WordForward: key.NewBinding(key.WithKeys("alt+right", "ctrl+right", "alt+f")), WordBackward: key.NewBinding(key.WithKeys("alt+left", "ctrl+left", "alt+b")), - DeleteWordBackward: key.NewBinding(key.WithKeys("alt+backspace", "ctrl+w")), - DeleteWordForward: key.NewBinding(key.WithKeys("alt+delete", "alt+d")), + DeleteWordBackward: key.NewBinding(key.WithKeys("alt+backspace", "ctrl+w", "ctrl+backspace")), + DeleteWordForward: key.NewBinding(key.WithKeys("alt+delete", "alt+d", "ctrl+delete")), DeleteAfterCursor: key.NewBinding(key.WithKeys("ctrl+k")), DeleteBeforeCursor: key.NewBinding(key.WithKeys("ctrl+u")), DeleteCharacterBackward: key.NewBinding(key.WithKeys("backspace", "ctrl+h")), @@ -921,12 +921,7 @@ func (m Model) Cursor() *tea.Cursor { w := lipgloss.Width promptWidth := w(m.promptView()) - // ze patch (charmbracelet/bubbles#1001, not upstream yet): the hardware - // cursor must use the SCROLL-ADJUSTED position, the same one View() draws - // with. m.Position() is absolute, so once the text is longer than the - // input width the cursor is placed past the viewport and every column - // after it is reported one place out. See internal/le/vendorpatch/patches/. - xOffset := max(0, m.pos-m.offset) + + xOffset := m.Position() + promptWidth if m.width > 0 { xOffset = min(xOffset, m.width+promptWidth) diff --git a/vendor/charm.land/bubbletea/v2/color.go b/vendor/charm.land/bubbletea/v2/color.go index 54514e4b34..ee287de2fa 100644 --- a/vendor/charm.land/bubbletea/v2/color.go +++ b/vendor/charm.land/bubbletea/v2/color.go @@ -54,8 +54,8 @@ func (e ForegroundColorMsg) IsDark() bool { // [BackgroundColorMsg.IsDark] to determine if the color is dark or light. For // example: // -// func (m Model) Init() (Model, Cmd) { -// return m, RequestBackgroundColor() +// func (m Model) Init() Cmd { +// return RequestBackgroundColor() // } // // func (m Model) Update(msg Msg) (Model, Cmd) { diff --git a/vendor/charm.land/bubbletea/v2/cursed_renderer.go b/vendor/charm.land/bubbletea/v2/cursed_renderer.go index f45fee3205..0ad3e602b2 100644 --- a/vendor/charm.land/bubbletea/v2/cursed_renderer.go +++ b/vendor/charm.land/bubbletea/v2/cursed_renderer.go @@ -33,6 +33,8 @@ type cursedRenderer struct { mapnl bool syncdUpdates bool // whether to use synchronized output mode for updates starting bool // indicates whether the renderer is starting after being stopped + pendingErase bool // an scr.Erase() is pending and hasn't been drained by flush yet + noInput bool // whether input is disabled, in which case keyboard enhancement queries are pointless } var _ renderer = &cursedRenderer{} @@ -55,6 +57,29 @@ func (s *cursedRenderer) setLogger(logger uv.Logger) { s.mu.Unlock() } +// setNoInput disables keyboard enhancement requests. When the program runs +// without input, the terminal's response to a keyboard enhancement query +// would arrive after the program has exited and leak into the shell. +func (s *cursedRenderer) setNoInput(noInput bool) { + s.noInput = noInput +} + +// resetKeyboardEnhancements writes the sequences that reset keyboard +// enhancement protocols when switching between the main and alt screens. +// modifyOtherKeys has no stack, so it is reset in place; the Kitty keyboard +// stack is popped, but only if we previously pushed an entry (i.e. this is +// not the first render). With input disabled the keyboard protocol is never +// touched. +func (s *cursedRenderer) resetKeyboardEnhancements(buf *bytes.Buffer) { + if s.noInput { + return + } + _, _ = buf.WriteString(ansi.ResetModifyOtherKeys) + if s.lastView != nil { + _, _ = buf.WriteString(ansi.PopKittyKeyboard(1)) + } +} + // setOptimizations sets the cursor movement optimizations. func (s *cursedRenderer) setOptimizations(hardTabs, backspace, mapnl bool) { s.mu.Lock() @@ -131,12 +156,16 @@ func (s *cursedRenderer) start() { if s.lastView.ProgressBar != nil { setProgressBar(s, s.lastView.ProgressBar) } - // Enable modifyOtherKeys and Kitty keyboard protocol. - // Both can coexist; terminals ignore what they don't support. - _, _ = s.scr.WriteString(ansi.SetModifyOtherKeys2) + if !s.noInput { + // Enable modifyOtherKeys and Kitty keyboard protocol. + // Both can coexist; terminals ignore what they don't support. + _, _ = s.scr.WriteString(ansi.SetModifyOtherKeys2) - kittyFlags := keyboardEnhancementsFlags(s.lastView.KeyboardEnhancements) - _, _ = s.scr.WriteString(ansi.KittyKeyboard(kittyFlags, 1)) + kittyFlags := keyboardEnhancementsFlags(s.lastView.KeyboardEnhancements) + // The entry was popped when the renderer was stopped, so push a fresh + // one for the screen we're about to restore. + _, _ = s.scr.WriteString(ansi.PushKittyKeyboard(kittyFlags)) + } } // close implements renderer. @@ -153,10 +182,14 @@ func (s *cursedRenderer) close() (err error) { // two registries for the main and alt screens. We disable keyboard // enhancements whenever we enter/exit alt screen mode in // [cursedRenderer.flush]. - // Here, we reset the keyboard protocol of the last screen used - // assuming the other screen is already reset when we switched screens. - _, _ = s.buf.WriteString(ansi.ResetModifyOtherKeys) - _, _ = s.buf.WriteString(ansi.KittyKeyboard(0, 1)) + // Here, we pop the keyboard protocol of the last screen used + // assuming the other screen is already popped when we switched + // screens. With input disabled we never pushed an entry, so there is + // nothing to pop. + if !s.noInput { + _, _ = s.buf.WriteString(ansi.ResetModifyOtherKeys) + _, _ = s.buf.WriteString(ansi.PopKittyKeyboard(1)) + } // Go to the bottom of the screen. // We need to go to the bottom of the screen regardless of whether @@ -284,13 +317,14 @@ func (s *cursedRenderer) flush(closing bool) error { _, _ = s.scr.WriteString(ansi.SetTabEvery8Columns) } - if !s.starting && !closing && s.lastView != nil && viewEquals(s.lastView, &view) && frameArea == s.cellbuf.Bounds() { + if !s.starting && !closing && !s.pendingErase && s.lastView != nil && viewEquals(s.lastView, &view) && frameArea == s.cellbuf.Bounds() { // No changes, nothing to do. return nil } // We're no longer starting. s.starting = false + s.pendingErase = false if frameArea != s.cellbuf.Bounds() { s.scr.Erase() // Force a full redraw to avoid artifacts. @@ -375,9 +409,12 @@ func (s *cursedRenderer) flush(closing bool) error { } } - // kitty keyboard protocol - if s.lastView == nil || view.KeyboardEnhancements != s.lastView.KeyboardEnhancements || - view.AltScreen != s.lastView.AltScreen { + // kitty keyboard protocol. Skipped entirely when input is disabled: the + // enhancements only affect keyboard input, and querying the terminal + // would leave its response unconsumed, leaking into the shell after + // the program exits. + if !s.noInput && (s.lastView == nil || view.KeyboardEnhancements != s.lastView.KeyboardEnhancements || + view.AltScreen != s.lastView.AltScreen) { // NOTE: We need to reset the keyboard protocol when switching // between main and alt screen. This is because the specs specify // two different states for the main and alt screen. @@ -386,7 +423,19 @@ func (s *cursedRenderer) flush(closing bool) error { _, _ = s.scr.WriteString(ansi.SetModifyOtherKeys2) kittyFlags := keyboardEnhancementsFlags(view.KeyboardEnhancements) - _, _ = s.scr.WriteString(ansi.KittyKeyboard(kittyFlags, 1)) + if s.lastView == nil || view.AltScreen != s.lastView.AltScreen { + // First render or screen switch: the previous screen's entry + // (if any) is popped below, so push a fresh one for this + // screen. + _, _ = s.scr.WriteString(ansi.PushKittyKeyboard(kittyFlags)) + } else { + // Only the flags changed while the same screen stays active. + // Update the topmost stack entry in place instead of popping + // and re-pushing, so a keyboard change doesn't churn the + // stack. Note that this overwrites whatever entry is currently + // on top, which is normally ours. + _, _ = s.scr.WriteString(ansi.KittyKeyboard(kittyFlags, 1)) + } if !closing { // Request keyboard enhancements when they change _, _ = s.scr.WriteString(ansi.RequestKittyKeyboard) @@ -511,11 +560,10 @@ func (s *cursedRenderer) flush(closing bool) error { var buf bytes.Buffer if shouldUpdateAltScreen { - // We always disable keyboard enhancements when switching screens + // We always reset keyboard enhancements when switching screens // because the terminal is expected to have two different keyboard // registries for main and alt screens. - _, _ = buf.WriteString(ansi.ResetModifyOtherKeys) - _, _ = buf.WriteString(ansi.KittyKeyboard(0, 1)) + s.resetKeyboardEnhancements(&buf) if view.AltScreen { // Entering alt screen mode. buf.WriteString(ansi.SetModeAltScreenSaveCursor) @@ -627,6 +675,7 @@ func (s *cursedRenderer) resize(w, h int) { s.scr.Erase() s.width, s.height = w, h s.scr.Resize(s.width, s.height) + s.pendingErase = true s.mu.Unlock() } @@ -637,6 +686,7 @@ func (s *cursedRenderer) clearScreen() { // screen redraw. s.scr.MoveTo(0, 0) s.scr.Erase() + s.pendingErase = true s.mu.Unlock() } diff --git a/vendor/charm.land/bubbletea/v2/key.go b/vendor/charm.land/bubbletea/v2/key.go index b16e53c2f1..d6798ee6a6 100644 --- a/vendor/charm.land/bubbletea/v2/key.go +++ b/vendor/charm.land/bubbletea/v2/key.go @@ -152,7 +152,7 @@ const ( KeyMediaRewind = uv.KeyMediaRewind KeyMediaNext = uv.KeyMediaNext KeyMediaPrev = uv.KeyMediaPrev - KeyMediaRecord + KeyMediaRecord = uv.KeyMediaRecord KeyLowerVol = uv.KeyLowerVol KeyRaiseVol = uv.KeyRaiseVol diff --git a/vendor/charm.land/bubbletea/v2/mouse.go b/vendor/charm.land/bubbletea/v2/mouse.go index 05b83128b1..ee28c7fdc0 100644 --- a/vendor/charm.land/bubbletea/v2/mouse.go +++ b/vendor/charm.land/bubbletea/v2/mouse.go @@ -38,7 +38,7 @@ const ( MouseBackward = uv.MouseBackward MouseForward = uv.MouseForward MouseButton10 = uv.MouseButton10 - MouseButton11 + MouseButton11 = uv.MouseButton11 ) // MouseMsg represents a mouse message. This is a generic mouse message that diff --git a/vendor/charm.land/bubbletea/v2/screen.go b/vendor/charm.land/bubbletea/v2/screen.go index f835bb376b..e799a54248 100644 --- a/vendor/charm.land/bubbletea/v2/screen.go +++ b/vendor/charm.land/bubbletea/v2/screen.go @@ -3,9 +3,7 @@ package tea import "github.com/charmbracelet/x/ansi" // WindowSizeMsg is used to report the terminal size. It's sent to Update once -// initially and then on every terminal resize. Note that Windows does not -// have support for reporting when resizes occur as it does not support the -// SIGWINCH signal. +// initially and then on every terminal resize. type WindowSizeMsg struct { Width int Height int diff --git a/vendor/charm.land/bubbletea/v2/tea.go b/vendor/charm.land/bubbletea/v2/tea.go index e249d71bba..f5dac71235 100644 --- a/vendor/charm.land/bubbletea/v2/tea.go +++ b/vendor/charm.land/bubbletea/v2/tea.go @@ -4,9 +4,9 @@ // both. It's been battle-tested in several large projects and is // production-ready. // -// A tutorial is available at https://github.com/charmbracelet/bubbletea/tree/master/tutorials +// A tutorial is available at https://github.com/charmbracelet/bubbletea/tree/main/tutorials // -// Example programs can be found at https://github.com/charmbracelet/bubbletea/tree/master/examples +// Example programs can be found at https://github.com/charmbracelet/bubbletea/tree/main/examples package tea import ( @@ -317,15 +317,23 @@ const ( ProgressBarWarning ) -// String return a human-readable value for the given [ProgressBarState]. +// String returns a human-readable name for the given [ProgressBarState]. +// Values outside the known range return "Unknown". func (s ProgressBarState) String() string { - return [...]string{ - "None", - "Default", - "Error", - "Indeterminate", - "Warning", - }[s] + switch s { + case ProgressBarNone: + return "None" + case ProgressBarDefault: + return "Default" + case ProgressBarError: + return "Error" + case ProgressBarIndeterminate: + return "Indeterminate" + case ProgressBarWarning: + return "Warning" + default: + return "Unknown" + } } // ProgressBar represents the terminal progress bar. @@ -336,7 +344,7 @@ func (s ProgressBarState) String() string { type ProgressBar struct { // State is the current state of the progress bar. It can be one of // [ProgressBarNone], [ProgressBarDefault], [ProgressBarError], - // [ProgressBarIndeterminate], and [ProgressBarWarn]. + // [ProgressBarIndeterminate], and [ProgressBarWarning]. State ProgressBarState // Value is the current value of the progress bar. It should be between // 0 and 100. @@ -1065,6 +1073,7 @@ func (p *Program) Run() (returnModel Model, returnErr error) { p.height, ) r.setLogger(p.logger) + r.setNoInput(p.disableInput) // XXX: This breaks many things especially when we want the output // to be compatible with terminals that are not necessary a TTY. // This was originally done to work around a Wish emulated-pty diff --git a/vendor/github.com/lasiar/canonicalheader/.gitignore b/vendor/github.com/golangci/canonicalheader/.gitignore similarity index 100% rename from vendor/github.com/lasiar/canonicalheader/.gitignore rename to vendor/github.com/golangci/canonicalheader/.gitignore diff --git a/vendor/github.com/golangci/canonicalheader/.golangci.yaml b/vendor/github.com/golangci/canonicalheader/.golangci.yaml new file mode 100644 index 0000000000..560daea806 --- /dev/null +++ b/vendor/github.com/golangci/canonicalheader/.golangci.yaml @@ -0,0 +1,425 @@ +version: "2" + +run: + build-tags: + - integration + modules-download-mode: readonly + +output: + formats: + text: + path: stdout + print-linter-name: true + print-issued-lines: false + colors: false + + +linters: + enable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - contextcheck + - copyloopvar + - dupword + - durationcheck + - errname + - errorlint + - gochecknoglobals + - gochecknoinits + - gocritic + - godot + - gomoddirectives + - gosec + - intrange + - mirror + - misspell + - nakedret + - nilerr + - nilnil + - noctx + - nolintlint + - perfsprint + - prealloc + - predeclared + - promlinter + - reassign + - revive + - rowserrcheck + - sloglint + - sqlclosecheck + - staticcheck + - tagliatelle + - testableexamples + - testifylint + - thelper + - tparallel + - unconvert + - unparam + - usestdlibvars + - wastedassign + disable: + - containedctx + - cyclop + - decorder + - depguard + - dogsled + - dupl + - err113 + - errchkjson + - exhaustive + - exhaustruct + - forbidigo + - forcetypeassert + - funlen + - ginkgolinter + - gocheckcompilerdirectives + - gocognit + - goconst + - gocyclo + - godox + - goheader + - gomodguard + - goprintffuncname + - grouper + - importas + - interfacebloat + - ireturn + - lll + - loggercheck + - maintidx + - makezero + - mnd + - musttag + - nestif + - nlreturn + - nonamedreturns + - nosprintfhostport + - paralleltest + - testpackage + - varnamelen + - whitespace + - wrapcheck + - wsl + + settings: + errcheck: + check-type-assertions: true + check-blank: true + exclude-functions: + - io/ioutil.ReadFile + - io.Copy(*bytes.Buffer) + - io.Copy(os.Stdout) + gocritic: + disabled-checks: + - hugeParam + - rangeExprCopy + - rangeValCopy + enabled-tags: + - diagnostic + - experimental + - opinionated + - performance + - style + godot: + scope: all + govet: + disable: + - fieldalignment + nakedret: + max-func-lines: 1 + revive: + max-open-files: 2048 + confidence: 0.1 + severity: error + enable-all-rules: true + rules: + - name: add-constant + arguments: + - allowFloats: 0.0,0.,1.0,1.,2.0,2. + allowInts: 0,1,2 + allowStrs: '""' + maxLitCount: "3" + severity: warning + disabled: false + - name: argument-limit + arguments: + - 4 + severity: warning + disabled: false + - name: atomic + severity: warning + disabled: false + - name: banned-characters + severity: warning + disabled: false + - name: bare-return + severity: warning + disabled: false + - name: blank-imports + severity: warning + disabled: false + - name: bool-literal-in-expr + severity: warning + disabled: false + - name: call-to-gc + severity: warning + disabled: false + - name: cognitive-complexity + arguments: + - 7 + severity: warning + disabled: true + - name: comment-spacings + severity: warning + disabled: false + - name: confusing-naming + severity: warning + disabled: false + - name: confusing-results + severity: warning + disabled: false + - name: constant-logical-expr + severity: warning + disabled: false + - name: context-as-argument + severity: warning + disabled: false + - name: context-keys-type + severity: warning + disabled: false + - name: cyclomatic + arguments: + - 3 + severity: warning + disabled: true + - name: datarace + severity: warning + disabled: false + - name: deep-exit + severity: warning + disabled: true + - name: defer + severity: warning + disabled: false + - name: dot-imports + severity: warning + disabled: false + - name: duplicated-imports + severity: warning + disabled: false + - name: early-return + severity: warning + disabled: false + - name: empty-block + severity: warning + disabled: false + - name: empty-lines + severity: warning + disabled: false + - name: enforce-map-style + severity: warning + disabled: false + - name: error-naming + severity: warning + disabled: false + - name: error-return + severity: warning + disabled: false + - name: function-length + arguments: + - 10 + - 0 + severity: warning + disabled: true + - name: error-strings + severity: warning + disabled: false + - name: errorf + severity: warning + disabled: false + - name: exported + severity: warning + disabled: false + - name: file-header + severity: warning + disabled: true + - name: flag-parameter + severity: warning + disabled: false + - name: function-result-limit + arguments: + - 2 + severity: warning + disabled: false + - name: get-return + severity: warning + disabled: false + - name: identical-branches + severity: warning + disabled: false + - name: if-return + severity: warning + disabled: false + - name: increment-decrement + severity: warning + disabled: false + - name: indent-error-flow + severity: warning + disabled: false + - name: import-alias-naming + arguments: + - ^[a-z][a-z0-9]{0,}$ + severity: warning + disabled: false + - name: imports-blocklist + severity: warning + disabled: false + - name: import-shadowing + severity: warning + disabled: false + - name: line-length-limit + arguments: + - 80 + severity: warning + disabled: true + - name: max-public-structs + arguments: + - 3 + severity: warning + disabled: false + - name: modifies-parameter + severity: warning + disabled: false + - name: modifies-value-receiver + severity: warning + disabled: false + - name: nested-structs + severity: warning + disabled: false + - name: optimize-operands-order + severity: warning + disabled: false + - name: package-comments + severity: warning + disabled: false + - name: range + severity: warning + disabled: false + - name: range-val-in-closure + severity: warning + disabled: false + - name: range-val-address + severity: warning + disabled: false + - name: receiver-naming + severity: warning + disabled: false + - name: redundant-import-alias + severity: warning + disabled: false + - name: redefines-builtin-id + severity: warning + disabled: false + - name: string-of-int + severity: warning + disabled: false + - name: string-format + arguments: + - - core.WriteError[1].Message + - /^([^A-Z]|$)/ + - must not start with a capital letter + - - fmt.Errorf[0] + - /(^|[^\.!?])$/ + - must not end in punctuation + - - panic + - /^[^\n]*$/ + - must not contain line breaks + severity: warning + disabled: false + - name: struct-tag + arguments: + - json,inline + - bson,outline,gnu + severity: warning + disabled: false + - name: superfluous-else + severity: warning + disabled: false + - name: time-equal + severity: warning + disabled: false + - name: time-naming + severity: warning + disabled: false + - name: var-naming + severity: warning + disabled: false + - name: var-declaration + severity: warning + disabled: false + - name: unconditional-recursion + severity: warning + disabled: false + - name: unexported-naming + severity: warning + disabled: false + - name: unexported-return + severity: warning + disabled: false + - name: unhandled-error + severity: warning + disabled: false + - name: unnecessary-stmt + severity: warning + disabled: false + - name: unreachable-code + severity: warning + disabled: false + - name: unused-parameter + arguments: + - allowRegex: ^_ + severity: warning + disabled: false + - name: unused-receiver + severity: warning + disabled: false + - name: useless-break + severity: warning + disabled: false + - name: waitgroup-by-value + severity: warning + disabled: false + tagliatelle: + case: + rules: + avro: snake + bson: camel + json: snake + mapstructure: kebab + xml: camel + yaml: snake + exclusions: + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + +formatters: + enable: + - gci + - gofmt + - gofumpt + - goimports + settings: + gci: + sections: + - standard + - default + - localmodule diff --git a/vendor/github.com/lasiar/canonicalheader/.goreleaser.yaml b/vendor/github.com/golangci/canonicalheader/.goreleaser.yaml similarity index 100% rename from vendor/github.com/lasiar/canonicalheader/.goreleaser.yaml rename to vendor/github.com/golangci/canonicalheader/.goreleaser.yaml diff --git a/vendor/github.com/lasiar/canonicalheader/LICENCE b/vendor/github.com/golangci/canonicalheader/LICENCE similarity index 100% rename from vendor/github.com/lasiar/canonicalheader/LICENCE rename to vendor/github.com/golangci/canonicalheader/LICENCE diff --git a/vendor/github.com/lasiar/canonicalheader/README.md b/vendor/github.com/golangci/canonicalheader/README.md similarity index 100% rename from vendor/github.com/lasiar/canonicalheader/README.md rename to vendor/github.com/golangci/canonicalheader/README.md diff --git a/vendor/github.com/lasiar/canonicalheader/analyzer.go b/vendor/github.com/golangci/canonicalheader/analyzer.go similarity index 74% rename from vendor/github.com/lasiar/canonicalheader/analyzer.go rename to vendor/github.com/golangci/canonicalheader/analyzer.go index 258ebdfd4d..4c0efaaa54 100644 --- a/vendor/github.com/lasiar/canonicalheader/analyzer.go +++ b/vendor/github.com/golangci/canonicalheader/analyzer.go @@ -1,6 +1,7 @@ package canonicalheader import ( + "flag" "fmt" "go/ast" "go/types" @@ -18,12 +19,29 @@ const ( name = "Header" ) -//nolint:gochecknoglobals // struct is not big, can be skip. -var Analyzer = &analysis.Analyzer{ - Name: "canonicalheader", - Doc: "canonicalheader checks whether net/http.Header uses canonical header", - Run: run, - Requires: []*analysis.Analyzer{inspect.Analyzer}, +//nolint:gochecknoglobals // for backward compatibility. +var Analyzer = New() + +func New() *analysis.Analyzer { + c := &canonicalHeader{} + + a := &analysis.Analyzer{ + Name: "canonicalheader", + Doc: "canonicalheader checks whether net/http.Header uses canonical header", + Requires: []*analysis.Analyzer{inspect.Analyzer}, + Run: c.run, + } + + a.Flags.Init("canonicalheader", flag.ExitOnError) + a.Flags.Var(&c.exclusions, "exclusions", "comma-separated list of exclusion rules") + a.Flags.BoolVar(&c.useDefaultExclusion, "useDefaultExclusion", true, "use default exclusion rules") + + return a +} + +type canonicalHeader struct { + useDefaultExclusion bool + exclusions stringSet } type argumenter interface { @@ -31,7 +49,26 @@ type argumenter interface { value() string } -func run(pass *analysis.Pass) (any, error) { +func (c *canonicalHeader) buildExclusions() map[string]string { + var defEx map[string]string + if c.useDefaultExclusion { + defEx = initialism() + } + + result := make(map[string]string, len(c.exclusions)+len(defEx)) + + for canonical, noCanonical := range defEx { + result[canonical] = noCanonical + } + + for _, ex := range c.exclusions { + result[http.CanonicalHeaderKey(ex)] = ex + } + + return result +} + +func (c *canonicalHeader) run(pass *analysis.Pass) (any, error) { var headerObject types.Object for _, object := range pass.TypesInfo.Uses { if object.Pkg() != nil && @@ -52,7 +89,7 @@ func run(pass *analysis.Pass) (any, error) { return nil, fmt.Errorf("want %T, got %T", spctor, pass.ResultOf[inspect.Analyzer]) } - wellKnownHeaders := initialism() + exclusions := c.buildExclusions() nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), @@ -91,8 +128,15 @@ func run(pass *analysis.Pass) (any, error) { if recv == nil { return } + gotType = recv.Type() - gotMethodName = astcast.ToSelectorExpr(callExp.Fun).Sel.Name + + sel := astcast.ToSelectorExpr(callExp.Fun).Sel + if sel == nil { + return + } + + gotMethodName = sel.Name // h := http.Header{} // f := h.Get @@ -137,6 +181,10 @@ func run(pass *analysis.Pass) (any, error) { return } + if sel.Sel == nil { + return + } + gotMethodName = sel.Sel.Name ident, ok = sel.X.(*ast.Ident) if !ok { @@ -228,13 +276,9 @@ func run(pass *analysis.Pass) (any, error) { } argValue := arg.value() - headerKeyCanonical := http.CanonicalHeaderKey(argValue) - if argValue == headerKeyCanonical { - return - } - headerKeyCanonical, isWellKnown := canonicalHeaderKey(argValue, wellKnownHeaders) - if argValue == headerKeyCanonical || isWellKnown { + headerKeyCanonical := canonicalHeaderKey(argValue, exclusions) + if argValue == headerKeyCanonical { return } @@ -244,15 +288,15 @@ func run(pass *analysis.Pass) (any, error) { return nil, outerErr } -func canonicalHeaderKey(s string, m map[string]string) (string, bool) { +func canonicalHeaderKey(s string, m map[string]string) string { canonical := http.CanonicalHeaderKey(s) wellKnown, ok := m[canonical] if !ok { - return canonical, ok + return canonical } - return wellKnown, ok + return wellKnown } func isValidMethod(name string) bool { diff --git a/vendor/github.com/golangci/canonicalheader/configure.go b/vendor/github.com/golangci/canonicalheader/configure.go new file mode 100644 index 0000000000..302a5a0788 --- /dev/null +++ b/vendor/github.com/golangci/canonicalheader/configure.go @@ -0,0 +1,28 @@ +package canonicalheader + +import ( + "strings" +) + +// stringSet is a set-of-nonempty-strings-valued flag. +type stringSet []string + +func (s *stringSet) String() string { + return strings.Join(*s, ",") +} + +func (s *stringSet) Set(flag string) error { + list := strings.Split(flag, ",") + + *s = make(stringSet, 0, len(list)) + + for _, element := range list { + element = strings.TrimSpace(element) + if element == "" { + continue + } + + *s = append(*s, element) + } + return nil +} diff --git a/vendor/github.com/lasiar/canonicalheader/constant_string.go b/vendor/github.com/golangci/canonicalheader/constant_string.go similarity index 90% rename from vendor/github.com/lasiar/canonicalheader/constant_string.go rename to vendor/github.com/golangci/canonicalheader/constant_string.go index 27988f0d53..9df31361b4 100644 --- a/vendor/github.com/lasiar/canonicalheader/constant_string.go +++ b/vendor/github.com/golangci/canonicalheader/constant_string.go @@ -37,10 +37,9 @@ func (c constantString) diagnostic(canonicalHeader string) analysis.Diagnostic { Pos: c.pos, End: c.end, Message: fmt.Sprintf( - "const %q used as a key at http.Header, but %q is not canonical, want %q", - c.nameOfConst, - c.originalValue, + "use %q instead of %q", canonicalHeader, + c.originalValue, ), } } diff --git a/vendor/github.com/lasiar/canonicalheader/initialism.go b/vendor/github.com/golangci/canonicalheader/initialism.go similarity index 100% rename from vendor/github.com/lasiar/canonicalheader/initialism.go rename to vendor/github.com/golangci/canonicalheader/initialism.go diff --git a/vendor/github.com/lasiar/canonicalheader/literal_string.go b/vendor/github.com/golangci/canonicalheader/literal_string.go similarity index 90% rename from vendor/github.com/lasiar/canonicalheader/literal_string.go rename to vendor/github.com/golangci/canonicalheader/literal_string.go index 71cd5f3974..d1bd010f76 100644 --- a/vendor/github.com/lasiar/canonicalheader/literal_string.go +++ b/vendor/github.com/golangci/canonicalheader/literal_string.go @@ -59,10 +59,10 @@ func (l literalString) diagnostic(canonicalHeader string) analysis.Diagnostic { return analysis.Diagnostic{ Pos: l.pos, End: l.end, - Message: fmt.Sprintf("non-canonical header %q, instead use: %q", l.originalValue, canonicalHeader), + Message: fmt.Sprintf("use %q instead of %q", canonicalHeader, l.originalValue), SuggestedFixes: []analysis.SuggestedFix{ { - Message: fmt.Sprintf("should replace %q with %q", l.originalValue, canonicalHeader), + Message: fmt.Sprintf("should be replaced %q with %q", l.originalValue, canonicalHeader), TextEdits: []analysis.TextEdit{ { Pos: l.pos, diff --git a/vendor/github.com/lasiar/canonicalheader/makefile b/vendor/github.com/golangci/canonicalheader/makefile similarity index 66% rename from vendor/github.com/lasiar/canonicalheader/makefile rename to vendor/github.com/golangci/canonicalheader/makefile index a96cb628e5..0f7a912ad1 100644 --- a/vendor/github.com/lasiar/canonicalheader/makefile +++ b/vendor/github.com/golangci/canonicalheader/makefile @@ -9,4 +9,5 @@ linter: generate: go run ./cmd/initialismer/*.go -target="mapping" > ./initialism.go go run ./cmd/initialismer/*.go -target="test" > ./testdata/src/initialism/initialism.go - gofmt -w ./initialism.go ./testdata/src/initialism/initialism.go + go run ./cmd/initialismer/*.go -target="test-golden" > ./testdata/src/initialism/initialism.go.golden + gofmt -w ./initialism.go ./testdata/src/initialism/initialism.go ./testdata/src/initialism/initialism.go.golden diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/cache/cache.go b/vendor/github.com/golangci/golangci-lint/v2/internal/cache/cache.go index cf20b175dd..e681b6ee46 100644 --- a/vendor/github.com/golangci/golangci-lint/v2/internal/cache/cache.go +++ b/vendor/github.com/golangci/golangci-lint/v2/internal/cache/cache.go @@ -172,6 +172,10 @@ func (c *Cache) computePkgHash(pkg *packages.Package) (hashResults, error) { return nil, fmt.Errorf("failed to calculate file %s hash: %w", f, fErr) } + if rel, ok := toRelativePath(pkg.Module, f); ok { + f = pkg.Module.Path + "/" + rel + } + fmt.Fprintf(key, "file %s %x\n", f, h) } diff --git a/vendor/github.com/golangci/golangci-lint/v2/internal/cache/position.go b/vendor/github.com/golangci/golangci-lint/v2/internal/cache/position.go new file mode 100644 index 0000000000..88cf2b4a40 --- /dev/null +++ b/vendor/github.com/golangci/golangci-lint/v2/internal/cache/position.go @@ -0,0 +1,54 @@ +package cache + +import ( + "go/token" + "path/filepath" + "strings" + + "golang.org/x/tools/go/packages" +) + +// RelativePosition creates a [token.Position] with a filename relative to the module directory. +func RelativePosition(mod *packages.Module, pos token.Position) token.Position { + pos.Filename, _ = toRelativePath(mod, pos.Filename) + + return pos +} + +// AbsolutionPosition creates the absolute path base on the module directory. +func AbsolutionPosition(mod *packages.Module, pos token.Position) token.Position { + pos.Filename = toAbsolutePath(mod, pos.Filename) + + return pos +} + +func toRelativePath(mod *packages.Module, filename string) (string, bool) { + if filename == "" || !isCurrentModule(mod) { + return filename, false + } + + rel, err := filepath.Rel(mod.Dir, filename) + if err != nil { + return filename, false + } + + rel = filepath.ToSlash(rel) + + if rel == ".." || strings.HasPrefix(rel, "../") { + return filename, false + } + + return rel, true +} + +func toAbsolutePath(mod *packages.Module, filename string) string { + if filename == "" || !isCurrentModule(mod) || filepath.IsAbs(filename) { + return filename + } + + return filepath.Join(mod.Dir, filepath.FromSlash(filename)) +} + +func isCurrentModule(mod *packages.Module) bool { + return mod != nil && mod.Dir != "" && mod.Version == "" +} diff --git a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.next.jsonschema.json b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.next.jsonschema.json index bb4f0398e1..0d8b5be51e 100644 --- a/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.next.jsonschema.json +++ b/vendor/github.com/golangci/golangci-lint/v2/jsonschema/golangci.next.jsonschema.json @@ -1087,6 +1087,23 @@ } } }, + "canonicalheaderSettings": { + "type": "object", + "additionalProperties": false, + "properties": { + "use-default-exclusions": { + "type": "boolean", + "default": true + }, + "exclusions": { + "additionalProperties": false, + "type": "array", + "items": { + "type": "string" + } + } + } + }, "cyclopSettings": { "type": "object", "additionalProperties": false, @@ -5085,6 +5102,9 @@ "bodyclose": { "$ref": "#/definitions/settings/definitions/bodycloseSettings" }, + "canonicalheader": { + "$ref": "#/definitions/settings/definitions/canonicalheaderSettings" + }, "cyclop": { "$ref": "#/definitions/settings/definitions/cyclopSettings" }, diff --git a/vendor/github.com/golangci/golangci-lint/v2/pkg/commands/run.go b/vendor/github.com/golangci/golangci-lint/v2/pkg/commands/run.go index a7efa264ac..58417f9dc7 100644 --- a/vendor/github.com/golangci/golangci-lint/v2/pkg/commands/run.go +++ b/vendor/github.com/golangci/golangci-lint/v2/pkg/commands/run.go @@ -640,6 +640,7 @@ func initHashSalt(logger logutils.Log, version string, cfg *config.Config) error } b := bytes.NewBuffer(binSalt) + b.WriteString("golangci-lint-cache/v2") b.Write(configSalt) b.WriteString(goModSalt) @@ -712,7 +713,8 @@ func computeGoModSalt() (string, error) { return "", fmt.Errorf("failed to read go.mod: %w", err) } - sum, err := dirhash.Hash1([]string{goModPath}, func(string) (io.ReadCloser, error) { + // NOTE: the variable `goModPath` is not used here to ensure getting the same hash, independently of the location, for the same content. + sum, err := dirhash.Hash1([]string{"go.mod"}, func(string) (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(data)), nil }) if err != nil { diff --git a/vendor/github.com/golangci/golangci-lint/v2/pkg/config/linters_settings.go b/vendor/github.com/golangci/golangci-lint/v2/pkg/config/linters_settings.go index e856119731..527c5f6fe5 100644 --- a/vendor/github.com/golangci/golangci-lint/v2/pkg/config/linters_settings.go +++ b/vendor/github.com/golangci/golangci-lint/v2/pkg/config/linters_settings.go @@ -12,6 +12,9 @@ var defaultLintersSettings = LintersSettings{ Asasalint: AsasalintSettings{ UseBuiltinExclusions: true, }, + CanonicalHeader: CanonicalHeaderSettings{ + UseDefaultExclusions: true, + }, Decorder: DecorderSettings{ DecOrder: []string{"type", "const", "var", "func"}, DisableDecNumCheck: true, @@ -252,6 +255,7 @@ type LintersSettings struct { Asasalint AsasalintSettings `mapstructure:"asasalint"` BiDiChk BiDiChkSettings `mapstructure:"bidichk"` BodyClose BodyCloseSettings `mapstructure:"bodyclose"` + CanonicalHeader CanonicalHeaderSettings `mapstructure:"canonicalheader"` CopyLoopVar CopyLoopVarSettings `mapstructure:"copyloopvar"` Cyclop CyclopSettings `mapstructure:"cyclop"` Decorder DecorderSettings `mapstructure:"decorder"` @@ -376,6 +380,11 @@ type BodyCloseSettings struct { CheckConsumption bool `mapstructure:"check-consumption"` } +type CanonicalHeaderSettings struct { + Exclusions []string `mapstructure:"exclusions"` + UseDefaultExclusions bool `mapstructure:"use-default-exclusions"` +} + type CopyLoopVarSettings struct { CheckAlias bool `mapstructure:"check-alias"` } diff --git a/vendor/github.com/golangci/golangci-lint/v2/pkg/goanalysis/runners_cache.go b/vendor/github.com/golangci/golangci-lint/v2/pkg/goanalysis/runners_cache.go index b74d4f94ff..4e6ab9a198 100644 --- a/vendor/github.com/golangci/golangci-lint/v2/pkg/goanalysis/runners_cache.go +++ b/vendor/github.com/golangci/golangci-lint/v2/pkg/goanalysis/runners_cache.go @@ -42,7 +42,7 @@ func saveIssuesToCache(allPkgs []*packages.Package, pkgsFromCache map[*packages. FromLinter: issue.FromLinter, Text: issue.Text, Severity: issue.Severity, - Pos: issue.Pos, + Pos: cache.RelativePosition(pkg.Module, issue.Pos), LineRange: issue.LineRange, SuggestedFixes: issue.SuggestedFixes, ExpectNoLint: issue.ExpectNoLint, @@ -114,7 +114,7 @@ func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context, FromLinter: issue.FromLinter, Text: issue.Text, Severity: issue.Severity, - Pos: issue.Pos, + Pos: cache.AbsolutionPosition(pkg.Module, issue.Pos), LineRange: issue.LineRange, SuggestedFixes: issue.SuggestedFixes, Pkg: pkg, diff --git a/vendor/github.com/golangci/golangci-lint/v2/pkg/golinters/canonicalheader/canonicalheader.go b/vendor/github.com/golangci/golangci-lint/v2/pkg/golinters/canonicalheader/canonicalheader.go index 24e95f143e..bbd6dbe4a4 100644 --- a/vendor/github.com/golangci/golangci-lint/v2/pkg/golinters/canonicalheader/canonicalheader.go +++ b/vendor/github.com/golangci/golangci-lint/v2/pkg/golinters/canonicalheader/canonicalheader.go @@ -1,13 +1,29 @@ package canonicalheader import ( - "github.com/lasiar/canonicalheader" + "strings" + "github.com/golangci/canonicalheader" + + "github.com/golangci/golangci-lint/v2/pkg/config" "github.com/golangci/golangci-lint/v2/pkg/goanalysis" ) -func New() *goanalysis.Linter { +func New(settings *config.CanonicalHeaderSettings) *goanalysis.Linter { + var cfg map[string]any + + if settings != nil { + cfg = map[string]any{ + "useDefaultExclusion": settings.UseDefaultExclusions, + } + + if len(settings.Exclusions) > 0 { + cfg["exclusions"] = strings.Join(settings.Exclusions, ",") + } + } + return goanalysis. - NewLinterFromAnalyzer(canonicalheader.Analyzer). + NewLinterFromAnalyzer(canonicalheader.New()). + WithConfig(cfg). WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/vendor/github.com/golangci/golangci-lint/v2/pkg/lint/lintersdb/builder_linter.go b/vendor/github.com/golangci/golangci-lint/v2/pkg/lint/lintersdb/builder_linter.go index d2b6ac047b..fb70920abe 100644 --- a/vendor/github.com/golangci/golangci-lint/v2/pkg/lint/lintersdb/builder_linter.go +++ b/vendor/github.com/golangci/golangci-lint/v2/pkg/lint/lintersdb/builder_linter.go @@ -167,7 +167,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) { WithLoadForGoAnalysis(). WithURL("https://github.com/timakin/bodyclose"), - linter.NewConfig(canonicalheader.New()). + linter.NewConfig(canonicalheader.New(&cfg.Linters.Settings.CanonicalHeader)). WithSince("v1.58.0"). WithLoadForGoAnalysis(). WithAutoFix(). diff --git a/vendor/github.com/lasiar/canonicalheader/.golangci.yaml b/vendor/github.com/lasiar/canonicalheader/.golangci.yaml deleted file mode 100644 index 997ec0cb01..0000000000 --- a/vendor/github.com/lasiar/canonicalheader/.golangci.yaml +++ /dev/null @@ -1,784 +0,0 @@ -# See: https://olegk.dev/go-linters-configuration-the-right-version - -run: - # Automatically adjust the maximum concurrency to the container CPU quota. - concurrency: 0 - - # I really care about the result, so I'm fine to wait for it. - timeout: 30m - - # Fail if the error was met. - issues-exit-code: 1 - - # This is very important, bugs in tests are not acceptable either. - tests: true - - # In most cases this can be empty but there is a popular pattern - # to keep integration tests under this tag. Such tests often require - # additional setups like Postgres, Redis etc and are run separately. - # (to be honest I don't find this useful but I have such tags) - build-tags: - - integration - - # Autogenerated files can be skipped (I'm looking at you gRPC). - # AFAIK autogen files are skipped but skipping the whole directory should be somewhat faster. - #skip-files: - # - "protobuf/.*.go" - - # With the read-only mode linter will fail if go.mod file is outdated. - modules-download-mode: readonly - - # Till today I didn't know this param exists, never ran 2 golangci-lint at once. - allow-parallel-runners: false - - # Keep this empty to use the Go version from the go.mod file. - go: "" - -linters: - # Set to true runs only fast linters. - # Good option for 'lint on save', pre-commit hook or CI. - fast: false - - enable: - # Globals and init() are no ok, because this linter use on golangci lint. - - gochecknoglobals - - gochecknoinits - # Check for pass []any as any in variadic func(...any). - # Rare case but saved me from debugging a few times. - - asasalint - - # I prefer plane ASCII identifiers. - # Symbol `∆` instead of `delta` looks cool but no thanks. - - asciicheck - - # Checks for dangerous unicode character sequences. - # Super rare but why not to be a bit paranoid? - - bidichk - - # Checks whether HTTP response body is closed successfully. - - bodyclose - - # Check whether the function uses a non-inherited context. - - contextcheck - - # after go 1.22 don't need copy var at for range. - - copyloopvar - - # Find duplicate words, rare. - - dupword - - # Check for two durations multiplied together. - - durationcheck - - # Forces to not skip error check. - - errcheck - - # Checks `Err-` prefix for var and `-Error` suffix for error type. - - errname - - # Suggests to use `%w` for error-wrapping. - - errorlint - - # Checks for pointers to enclosing loop variables. - - exportloopref - - - # Imports order. - - gci - - # As you already know I'm a co-author. It would be strange to not use - # one of my warmly loved projects. - - gocritic - - # Forces to put `.` at the end of the comment. Code is poetry. - - godot - - # Might not be that important but I prefer to keep all of them. - # `gofumpt` is amazing, kudos to Daniel Marti https://github.com/mvdan/gofumpt - - gofmt - - gofumpt - - goimports - - # Allow or ban replace directives in go.mod - # or force explanation for retract directives. - - gomoddirectives - - # Powerful security-oriented linter. But requires some time to - # configure it properly, see https://github.com/securego/gosec#available-rules - - gosec - - # Linter that specializes in simplifying code. - - gosimple - - # Official Go tool. Must have. - - govet - - # Detects when assignments to existing variables are not used - # Last week I caught a bug with it. - - ineffassign - - # range over int, work after go 1.22 - - intrange - - # Fix all the misspells, amazing thing. - - misspell - - # Reports wrong mirror patterns of bytes/strings usage. - - mirror - - # Finds naked/bare returns and requires change them. - - nakedret - - # Both require a bit more explicit returns. - - nilerr - - nilnil - - # Finds sending HTTP request without context.Context. - - noctx - - # Forces comment why another check is disabled. - # Better not to have //nolint: at all ;) - - nolintlint - - # aiming at usages of fmt.Sprintf which have faster alternatives. - - perfsprint - - # Finds slices that could potentially be pre-allocated. - # Small performance win + cleaner code. - - prealloc - - # Finds shadowing of Go's predeclared identifiers. - # I hear a lot of complaints from junior developers. - # But after some time they find it very useful. - - predeclared - - # Lint your Prometheus metrics name. - - promlinter - - # Checks that package variables are not reassigned. - # Super rare case but can catch bad things (like `io.EOF = nil`) - - reassign - - # Drop-in replacement of `golint`. - - revive - - # Somewhat similar to `bodyclose` but for `database/sql` package. - - rowserrcheck - - sqlclosecheck - - # Ensure consistent code style when using log/slog. - - sloglint - - # I have found that it's not the same as staticcheck binary :\ - - staticcheck - - # Is a replacement for `golint`, similar to `revive`. - - stylecheck - - # Check struct tags. - - tagliatelle - - # Test-related checks. All of them are good. - - tenv - - testableexamples - - testifylint - - thelper - - tparallel - - # Remove unnecessary type conversions, make code cleaner - - unconvert - - # Might be noisy but better to know what is unused - - unparam - - # Must have. Finds unused declarations. - - unused - - # Detect the possibility to use variables/constants from stdlib. - - usestdlibvars - - # Finds wasted assignment statements. - - wastedassign - - disable: - # Detects struct contained context.Context field. Not a problem. - - containedctx - - # Checks function and package cyclomatic complexity. - # I can have a long but trivial switch-case. - # - # Cyclomatic complexity is a measurement, not a goal. - # (c) Bryan C. Mills / https://github.com/bcmills - - cyclop - - # Check declaration order of types, consts, vars and funcs. - # I like it but I don't use it. - - decorder - - # Checks if package imports are in a list of acceptable packages. - # I'm very picky about what I import, so no automation. - - depguard - - # Checks assignments with too many blank identifiers. Very rare. - - dogsled - - # Tool for code clone detection. - - dupl - - # I'm fine to check the error from json.Marshal ¯\_(ツ)_/¯ - - errchkjson - - # All SQL queries MUST BE covered with tests. - - execinquery - - # Forces to handle more cases. Cool but noisy. - - exhaustive - - exhaustruct - - # Forbids some identifiers. I don't have a case for it. - - forbidigo - - # Finds forced type assertions, very good for juniors. - - forcetypeassert - - # I might have long but a simple function. - - funlen - - # I'm not a fan of ginkgo and gomega packages. - - ginkgolinter - - # Checks that compiler directive comments (//go:) are valid. Rare. - - gocheckcompilerdirectives - - # Same as `cyclop` linter (see above) - - gocognit - - goconst - - gocyclo - - # TODO and friends are ok. - - godox - - # Check the error handling expressions. Too noisy. - - err113 - - # I don't use file headers. - - goheader - - # Reports magic consts. Might be noisy but still good. - - mnd - - # Allowed/blocked packages to import. I prefer to do it manually. - - gomodguard - - # Printf-like functions must have -f. - - goprintffuncname - - # Groupt declarations, I prefer manually. - - grouper - - # Checks imports aliases, rare. - - importas - - # Forces tiny interfaces, very subjective. - - interfacebloat - - # Accept interfaces, return types. Not always. - - ireturn - - # I don't set line length. 120 is fine by the way ;) - - lll - - # Some log checkers, might be useful. - - loggercheck - - # Maintainability index of each function, subjective. - - maintidx - - # Slice declarations with non-zero initial length. Not my case. - - makezero - - # Enforce tags in un/marshaled structs. Cool but not my case. - - musttag - - # Deeply nested if statements, subjective. - - nestif - - # Forces newlines in some places. - - nlreturn - - # Reports all named returns, not that bad. - - nonamedreturns - - # Finds misuse of Sprintf with host:port in a URL. Cool but rare. - - nosprintfhostport - - # I don't use t.Parallel() that much. - - paralleltest - - # Often non-`_test` package is ok. - - testpackage - - # Compiler can do it too :) - - typecheck - - # I'm fine with long variable names with a small scope. - - varnamelen - - # gofmt,gofumpt covers that (from what I know). - - whitespace - - # Don't find it useful to wrap all errors from external packages. - - wrapcheck - - # Forces you to use empty lines. Great if configured correctly. - # I mean there is an agreement in a team. - - wsl - -linters-settings: - gci: - sections: - - standard - - default - - localmodule - - revive: - # Maximum number of open files at the same time. - # See https://github.com/mgechev/revive#command-line-flags - # Defaults to unlimited. - max-open-files: 2048 - # When set to false, ignores files with "GENERATED" header, similar to golint. - # See https://github.com/mgechev/revive#available-rules for details. - # Default: false - ignore-generated-header: true - # Sets the default severity. - # See https://github.com/mgechev/revive#configuration - # Default: warning - severity: error - # Enable all available rules. - # Default: false - enable-all-rules: true - # Sets the default failure confidence. - # This means that linting errors with less than 0.8 confidence will be ignored. - # Default: 0.8 - confidence: 0.1 - rules: - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#add-constant - - name: add-constant - severity: warning - disabled: false - arguments: - - maxLitCount: "3" - allowStrs: '""' - allowInts: "0,1,2" - allowFloats: "0.0,0.,1.0,1.,2.0,2." - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#argument-limit - - name: argument-limit - severity: warning - disabled: false - arguments: [4] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic - - name: atomic - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters - - name: banned-characters - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return - - name: bare-return - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports - - name: blank-imports - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr - - name: bool-literal-in-expr - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#call-to-gc - - name: call-to-gc - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity - - name: cognitive-complexity - severity: warning - disabled: true - arguments: [7] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#comment-spacings - - name: comment-spacings - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-naming - - name: confusing-naming - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-results - - name: confusing-results - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr - - name: constant-logical-expr - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument - - name: context-as-argument - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type - - name: context-keys-type - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cyclomatic - - name: cyclomatic - severity: warning - disabled: true - arguments: [3] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#datarace - - name: datarace - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit - - name: deep-exit - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer - - name: defer - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports - - name: dot-imports - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports - - name: duplicated-imports - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return - - name: early-return - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block - - name: empty-block - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines - - name: empty-lines - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#enforce-map-style - - name: enforce-map-style - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming - - name: error-naming - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return - - name: error-return - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length - - name: function-length - severity: warning - disabled: true - arguments: [10, 0] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings - - name: error-strings - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf - - name: errorf - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported - - name: exported - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header - - name: file-header - severity: warning - disabled: true - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter - - name: flag-parameter - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit - - name: function-result-limit - severity: warning - disabled: false - arguments: [2] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return - - name: get-return - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches - - name: identical-branches - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return - - name: if-return - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement - - name: increment-decrement - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow - - name: indent-error-flow - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-alias-naming - - name: import-alias-naming - severity: warning - disabled: false - arguments: - - "^[a-z][a-z0-9]{0,}$" - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blacklist - - name: imports-blacklist - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing - - name: import-shadowing - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit - - name: line-length-limit - severity: warning - disabled: true - arguments: [80] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs - - name: max-public-structs - severity: warning - disabled: false - arguments: [3] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-parameter - - name: modifies-parameter - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-value-receiver - - name: modifies-value-receiver - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#nested-structs - - name: nested-structs - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#optimize-operands-order - - name: optimize-operands-order - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments - - name: package-comments - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range - - name: range - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure - - name: range-val-in-closure - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address - - name: range-val-address - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming - - name: receiver-naming - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias - - name: redundant-import-alias - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id - - name: redefines-builtin-id - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int - - name: string-of-int - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format - - name: string-format - severity: warning - disabled: false - arguments: - - - 'core.WriteError[1].Message' - - '/^([^A-Z]|$)/' - - must not start with a capital letter - - - 'fmt.Errorf[0]' - - '/(^|[^\.!?])$/' - - must not end in punctuation - - - panic - - '/^[^\n]*$/' - - must not contain line breaks - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag - - name: struct-tag - arguments: - - "json,inline" - - "bson,outline,gnu" - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else - - name: superfluous-else - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal - - name: time-equal - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-naming - - name: time-naming - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming - - name: var-naming - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration - - name: var-declaration - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion - - name: unconditional-recursion - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming - - name: unexported-naming - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return - - name: unexported-return - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error - - name: unhandled-error - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt - - name: unnecessary-stmt - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code - - name: unreachable-code - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter - - name: unused-parameter - severity: warning - disabled: false - arguments: - - allowRegex: "^_" - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver - - name: unused-receiver - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break - - name: useless-break - severity: warning - disabled: false - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value - - name: waitgroup-by-value - severity: warning - disabled: false - # I'm biased and I'm enabling more than 100 checks - # Might be too much for you. See https://go-critic.com/overview.html - gocritic: - enabled-tags: - - diagnostic - - experimental - - opinionated - - performance - - style - disabled-checks: - # These 3 will detect many cases, but they do sense - # if it's performance oriented code - - hugeParam - - rangeExprCopy - - rangeValCopy - - godot: - scope: all - - errcheck: - # Report `a := b.(MyStruct)` when `a, ok := ...` should be. - check-type-assertions: true # Default: false - - # Report skipped checks:`num, _ := strconv.Atoi(numStr)`. - check-blank: true # Default: false - - # Function to skip. - exclude-functions: - - io/ioutil.ReadFile - - io.Copy(*bytes.Buffer) - - io.Copy(os.Stdout) - - govet: - disable: - - fieldalignment # I'm ok to waste some bytes - - nakedret: - # No naked returns, ever. - max-func-lines: 1 # Default: 30 - - tagliatelle: - case: - rules: - json: snake # why it's not a `snake` by default?! - yaml: snake # why it's not a `snake` by default?! - xml: camel - bson: camel - avro: snake - mapstructure: kebab - -# See also https://gist.github.com/cristaloleg/dc29ca0ef2fb554de28d94c3c6f6dc88 - -output: - # I prefer the simplest one: `line-number` and saving to `lint.txt` - # - # The `tab` also looks good and with the next release I will switch to it - # (ref: https://github.com/golangci/golangci-lint/issues/3728) - # - # There are more formats which can be used on CI or by your IDE. - formats: - - format: line-number - - # I do not find this useful, parameter above already enables filepath - # with a line and column. For me, it's easier to follow the path and - # see the line in an IDE where I see more code and understand it better. - print-issued-lines: false - - # Must have. Easier to understand the output. - print-linter-name: true - - # No, no skips, everything should be reported. - uniq-by-line: false - - # To be honest no idea when this can be needed, maybe a multi-module setup? - path-prefix: "" - - # Slightly easier to follow the results + getting deterministic output. - sort-results: true - -issues: - exclude-dirs-use-default: false - # I found it strange to skip the errors, setting 0 to have all the results. - max-issues-per-linter: 0 - - # Same here, nothing should be skipped to not miss errors. - max-same-issues: 0 - - # When set to `true` linter will analyze only new code which are - # not committed or after some specific revision. This is a cool - # feature when you're going to introduce linter into a big project. - # But I prefer going gradually package by package. - # So, it's set to `false` to scan all code. - new: false - - # 2 other params regarding git integration - - # Even with a recent GPT-4 release I still believe that - # I know better how to do my job and fix the suggestions. - fix: false \ No newline at end of file diff --git a/vendor/github.com/mattn/go-runewidth/runewidth.go b/vendor/github.com/mattn/go-runewidth/runewidth.go index 6b958fdd49..d977fb872a 100644 --- a/vendor/github.com/mattn/go-runewidth/runewidth.go +++ b/vendor/github.com/mattn/go-runewidth/runewidth.go @@ -18,6 +18,14 @@ var ( // StrictEmojiNeutral should be set false if handle broken fonts StrictEmojiNeutral bool = true + // ZeroWidthJoiner is flag to set to use UTR#51 ZWJ. + // + // Deprecated: ZWJ sequences are always handled through Unicode + // grapheme cluster segmentation now, so this flag has no effect. + // It is kept only for compatibility with code written against + // v0.0.9 and earlier. + ZeroWidthJoiner bool + // DefaultCondition is a condition in current locale DefaultCondition = &Condition{ EastAsianWidth: false, @@ -30,6 +38,7 @@ var ( widewidth table // ambiguous + doublewidth merged for EA path eastAsianWidth widthTable eastAsianWidth0 [0x300]byte + strictWidthLUT [2][0x110000]byte ) func init() { @@ -37,8 +46,9 @@ func init() { widewidth = mergeIntervals(ambiguous, doublewidth) eastAsianWidth = makeWidthTable(zerowidth, widewidth) for r := range eastAsianWidth0 { - eastAsianWidth0[r] = byte(runeWidthEastAsian(rune(r))) + eastAsianWidth0[r] = byte(runeWidthEastAsianNoCache(rune(r), true)) } + initStrictWidthLUT() handleEnv() } @@ -189,13 +199,57 @@ func inWidthTable(r rune, t widthTable) (int, bool) { return 0, false } -func runeWidthEastAsian(r rune) int { +func runeWidthNoLUT(r rune, eastAsian, strictEmojiNeutral bool) int { + if !eastAsian { + if r < 0x20 { + return 0 + } + if (r >= 0x7F && r <= 0x9F) || r == 0xAD { // nonprint + return 0 + } + if r < 0x300 { + return 1 + } + switch { + case inTable(r, zerowidth): + return 0 + case inTable(r, doublewidth): + return 2 + default: + return 1 + } + } + + if r < 0x300 { + return int(eastAsianWidth0[r]) + } + if w, ok := inWidthTable(r, eastAsianWidth); ok { + return w + } + if !strictEmojiNeutral && inTable(r, emoji) { + return 2 + } + return 1 +} + +func runeWidthEastAsianNoCache(r rune, strictEmojiNeutral bool) int { if w, ok := inWidthTable(r, eastAsianWidth); ok { return w } + if !strictEmojiNeutral && inTable(r, emoji) { + return 2 + } return 1 } +func initStrictWidthLUT() { + for i := range strictWidthLUT[0] { + r := rune(i) + strictWidthLUT[0][i] = byte(runeWidthNoLUT(r, false, true)) + strictWidthLUT[1][i] = byte(runeWidthNoLUT(r, true, true)) + } +} + var private = table{ {0x00E000, 0x00F8FF}, {0x0F0000, 0x0FFFFD}, {0x100000, 0x10FFFD}, } @@ -212,6 +266,12 @@ type Condition struct { combinedLut []byte EastAsianWidth bool StrictEmojiNeutral bool + + // Deprecated: ZWJ sequences are always handled through Unicode + // grapheme cluster segmentation now, so this flag has no effect. + // It is kept only for compatibility with code written against + // v0.0.9 and earlier. + ZeroWidthJoiner bool } // NewCondition return new instance of Condition which is current locale. @@ -219,6 +279,7 @@ func NewCondition() *Condition { return &Condition{ EastAsianWidth: EastAsianWidth, StrictEmojiNeutral: StrictEmojiNeutral, + ZeroWidthJoiner: ZeroWidthJoiner, } } @@ -231,37 +292,13 @@ func (c *Condition) RuneWidth(r rune) int { if len(c.combinedLut) > 0 { return int(c.combinedLut[r>>1]>>(uint(r&1)*4)) & 3 } - // optimized version, verified by TestRuneWidthChecksums() - if !c.EastAsianWidth { - if r < 0x20 { - return 0 - } - if (r >= 0x7F && r <= 0x9F) || r == 0xAD { // nonprint - return 0 + if c.StrictEmojiNeutral { + if c.EastAsianWidth { + return int(strictWidthLUT[1][r]) } - if r < 0x300 { - return 1 - } - switch { - case inTable(r, zerowidth): - return 0 - case inTable(r, doublewidth): - return 2 - default: - return 1 - } - } - - if r < 0x300 { - return int(eastAsianWidth0[r]) - } - if w, ok := inWidthTable(r, eastAsianWidth); ok { - return w + return int(strictWidthLUT[0][r]) } - if !c.StrictEmojiNeutral && inTable(r, emoji) { - return 2 - } - return 1 + return runeWidthNoLUT(r, c.EastAsianWidth, c.StrictEmojiNeutral) } // CreateLUT will create an in-memory lookup table of 557056 bytes for faster operation. @@ -285,6 +322,21 @@ func (c *Condition) CreateLUT() { c.combinedLut = lut } +// graphemeWidth returns the width of a single grapheme cluster: the sum of +// the widths of its runes, capped at 2 cells. The cap keeps multi-rune +// sequences that render as a single glyph (ZWJ emoji, flags, Hangul jamo) +// from being counted wider than the two cells terminals give them. +func (c *Condition) graphemeWidth(cluster string) int { + width := 0 + for _, r := range cluster { + width += c.RuneWidth(r) + } + if width > 2 { + width = 2 + } + return width +} + // StringWidth return width as you can see func (c *Condition) StringWidth(s string) (width int) { if len(s) == 1 { @@ -316,14 +368,7 @@ graphemes: width = 0 g := graphemes.FromString(s) for g.Next() { - var chWidth int - for _, r := range g.Value() { - chWidth = c.RuneWidth(r) - if chWidth > 0 { - break // Our best guess at this point is to use the width of the first non-zero-width rune. - } - } - width += chWidth + width += c.graphemeWidth(g.Value()) } return } @@ -338,13 +383,7 @@ func (c *Condition) Truncate(s string, w int, tail string) string { pos := len(s) g := graphemes.FromString(s) for g.Next() { - var chWidth int - for _, r := range g.Value() { - chWidth = c.RuneWidth(r) - if chWidth > 0 { - break // See StringWidth() for details. - } - } + chWidth := c.graphemeWidth(g.Value()) if width+chWidth > w { pos = g.Start() break @@ -365,13 +404,7 @@ func (c *Condition) TruncateLeft(s string, w int, prefix string) string { g := graphemes.FromString(s) for g.Next() { - var chWidth int - for _, r := range g.Value() { - chWidth = c.RuneWidth(r) - if chWidth > 0 { - break // See StringWidth() for details. - } - } + chWidth := c.graphemeWidth(g.Value()) if width+chWidth > w { if width < w { @@ -390,6 +423,32 @@ func (c *Condition) TruncateLeft(s string, w int, prefix string) string { return prefix + s[pos:] } +// TruncatePrefix cuts the beginning of `s` so the result fits in w cells, with prefix prepended +func (c *Condition) TruncatePrefix(s string, w int, prefix string) string { + if c.StringWidth(prefix) >= w { + return prefix + } + + sw := c.StringWidth(s) + if sw <= w { + return s + } + w -= c.StringWidth(prefix) + var width int + var pos int + g := graphemes.FromString(s) + for g.Next() { + chWidth := c.graphemeWidth(g.Value()) + if sw-(width+chWidth) <= w { + pos = g.End() + break + } + width += chWidth + } + + return prefix + s[pos:] +} + // Wrap return string wrapped with w cells func (c *Condition) Wrap(s string, w int) string { width := 0 @@ -419,11 +478,7 @@ func (c *Condition) FillLeft(s string, w int) string { width := c.StringWidth(s) count := w - width if count > 0 { - b := make([]byte, count) - for i := range b { - b[i] = ' ' - } - return string(b) + s + return strings.Repeat(" ", count) + s } return s } @@ -433,11 +488,7 @@ func (c *Condition) FillRight(s string, w int) string { width := c.StringWidth(s) count := w - width if count > 0 { - b := make([]byte, count) - for i := range b { - b[i] = ' ' - } - return s + string(b) + return s + strings.Repeat(" ", count) } return s } @@ -478,6 +529,11 @@ func TruncateLeft(s string, w int, prefix string) string { return DefaultCondition.TruncateLeft(s, w, prefix) } +// TruncatePrefix cuts the beginning of `s` so the result fits in w cells, with prefix prepended +func TruncatePrefix(s string, w int, prefix string) string { + return DefaultCondition.TruncatePrefix(s, w, prefix) +} + // Wrap return string wrapped with w cells func Wrap(s string, w int) string { return DefaultCondition.Wrap(s, w) diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_table.go b/vendor/github.com/mattn/go-runewidth/runewidth_table.go index cdd003e646..62488d97da 100644 --- a/vendor/github.com/mattn/go-runewidth/runewidth_table.go +++ b/vendor/github.com/mattn/go-runewidth/runewidth_table.go @@ -3,23 +3,127 @@ package runewidth var combining = table{ - {0x0300, 0x036F}, {0x0483, 0x0489}, {0x07EB, 0x07F3}, - {0x0C00, 0x0C00}, {0x0C04, 0x0C04}, {0x0CF3, 0x0CF3}, - {0x0D00, 0x0D01}, {0x135D, 0x135F}, {0x180B, 0x180D}, - {0x180F, 0x180F}, {0x1A7F, 0x1A7F}, {0x1AB0, 0x1ADD}, - {0x1AE0, 0x1AEB}, {0x1B6B, 0x1B73}, {0x1DC0, 0x1DFF}, - {0x20D0, 0x20F0}, {0x2CEF, 0x2CF1}, {0x2DE0, 0x2DFF}, - {0x3099, 0x309A}, {0xA66F, 0xA672}, {0xA674, 0xA67D}, - {0xA69E, 0xA69F}, {0xA6F0, 0xA6F1}, {0xA8E0, 0xA8F1}, - {0xFE00, 0xFE0F}, {0xFE20, 0xFE2F}, {0x101FD, 0x101FD}, - {0x10376, 0x1037A}, {0x10EAB, 0x10EAC}, {0x10F46, 0x10F50}, - {0x10F82, 0x10F85}, {0x11300, 0x11301}, {0x1133B, 0x1133C}, - {0x11366, 0x1136C}, {0x11370, 0x11374}, {0x16AF0, 0x16AF4}, - {0x1CF00, 0x1CF2D}, {0x1CF30, 0x1CF46}, {0x1D165, 0x1D169}, - {0x1D16D, 0x1D172}, {0x1D17B, 0x1D182}, {0x1D185, 0x1D18B}, - {0x1D1AA, 0x1D1AD}, {0x1D242, 0x1D244}, {0x1E000, 0x1E006}, - {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, {0x1E023, 0x1E024}, - {0x1E026, 0x1E02A}, {0x1E08F, 0x1E08F}, {0x1E8D0, 0x1E8D6}, + {0x0300, 0x036F}, {0x0483, 0x0489}, {0x0591, 0x05BD}, + {0x05BF, 0x05BF}, {0x05C1, 0x05C2}, {0x05C4, 0x05C5}, + {0x05C7, 0x05C7}, {0x0610, 0x061A}, {0x064B, 0x065F}, + {0x0670, 0x0670}, {0x06D6, 0x06DC}, {0x06DF, 0x06E4}, + {0x06E7, 0x06E8}, {0x06EA, 0x06ED}, {0x0711, 0x0711}, + {0x0730, 0x074A}, {0x07A6, 0x07B0}, {0x07EB, 0x07F3}, + {0x07FD, 0x07FD}, {0x0816, 0x0819}, {0x081B, 0x0823}, + {0x0825, 0x0827}, {0x0829, 0x082D}, {0x0859, 0x085B}, + {0x0897, 0x089F}, {0x08CA, 0x08E1}, {0x08E3, 0x0902}, + {0x093A, 0x093A}, {0x093C, 0x093C}, {0x0941, 0x0948}, + {0x094D, 0x094D}, {0x0951, 0x0957}, {0x0962, 0x0963}, + {0x0981, 0x0981}, {0x09BC, 0x09BC}, {0x09C1, 0x09C4}, + {0x09CD, 0x09CD}, {0x09E2, 0x09E3}, {0x09FE, 0x09FE}, + {0x0A01, 0x0A02}, {0x0A3C, 0x0A3C}, {0x0A41, 0x0A42}, + {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51}, + {0x0A70, 0x0A71}, {0x0A75, 0x0A75}, {0x0A81, 0x0A82}, + {0x0ABC, 0x0ABC}, {0x0AC1, 0x0AC5}, {0x0AC7, 0x0AC8}, + {0x0ACD, 0x0ACD}, {0x0AE2, 0x0AE3}, {0x0AFA, 0x0AFF}, + {0x0B01, 0x0B01}, {0x0B3C, 0x0B3C}, {0x0B3F, 0x0B3F}, + {0x0B41, 0x0B44}, {0x0B4D, 0x0B4D}, {0x0B55, 0x0B56}, + {0x0B62, 0x0B63}, {0x0B82, 0x0B82}, {0x0BC0, 0x0BC0}, + {0x0BCD, 0x0BCD}, {0x0C00, 0x0C00}, {0x0C04, 0x0C04}, + {0x0C3C, 0x0C3C}, {0x0C3E, 0x0C40}, {0x0C46, 0x0C48}, + {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56}, {0x0C62, 0x0C63}, + {0x0C81, 0x0C81}, {0x0CBC, 0x0CBC}, {0x0CBF, 0x0CBF}, + {0x0CC6, 0x0CC6}, {0x0CCC, 0x0CCD}, {0x0CE2, 0x0CE3}, + {0x0CF3, 0x0CF3}, {0x0D00, 0x0D01}, {0x0D3B, 0x0D3C}, + {0x0D41, 0x0D44}, {0x0D4D, 0x0D4D}, {0x0D62, 0x0D63}, + {0x0D81, 0x0D81}, {0x0DCA, 0x0DCA}, {0x0DD2, 0x0DD4}, + {0x0DD6, 0x0DD6}, {0x0E31, 0x0E31}, {0x0E34, 0x0E3A}, + {0x0E47, 0x0E4E}, {0x0EB1, 0x0EB1}, {0x0EB4, 0x0EBC}, + {0x0EC8, 0x0ECE}, {0x0F18, 0x0F19}, {0x0F35, 0x0F35}, + {0x0F37, 0x0F37}, {0x0F39, 0x0F39}, {0x0F71, 0x0F7E}, + {0x0F80, 0x0F84}, {0x0F86, 0x0F87}, {0x0F8D, 0x0F97}, + {0x0F99, 0x0FBC}, {0x0FC6, 0x0FC6}, {0x102D, 0x1030}, + {0x1032, 0x1037}, {0x1039, 0x103A}, {0x103D, 0x103E}, + {0x1058, 0x1059}, {0x105E, 0x1060}, {0x1071, 0x1074}, + {0x1082, 0x1082}, {0x1085, 0x1086}, {0x108D, 0x108D}, + {0x109D, 0x109D}, {0x135D, 0x135F}, {0x1712, 0x1714}, + {0x1732, 0x1733}, {0x1752, 0x1753}, {0x1772, 0x1773}, + {0x17B4, 0x17B5}, {0x17B7, 0x17BD}, {0x17C6, 0x17C6}, + {0x17C9, 0x17D3}, {0x17DD, 0x17DD}, {0x180B, 0x180D}, + {0x180F, 0x180F}, {0x1885, 0x1886}, {0x18A9, 0x18A9}, + {0x1920, 0x1922}, {0x1927, 0x1928}, {0x1932, 0x1932}, + {0x1939, 0x193B}, {0x1A17, 0x1A18}, {0x1A1B, 0x1A1B}, + {0x1A56, 0x1A56}, {0x1A58, 0x1A5E}, {0x1A60, 0x1A60}, + {0x1A62, 0x1A62}, {0x1A65, 0x1A6C}, {0x1A73, 0x1A7C}, + {0x1A7F, 0x1A7F}, {0x1AB0, 0x1ADD}, {0x1AE0, 0x1AEB}, + {0x1B00, 0x1B03}, {0x1B34, 0x1B34}, {0x1B36, 0x1B3A}, + {0x1B3C, 0x1B3C}, {0x1B42, 0x1B42}, {0x1B6B, 0x1B73}, + {0x1B80, 0x1B81}, {0x1BA2, 0x1BA5}, {0x1BA8, 0x1BA9}, + {0x1BAB, 0x1BAD}, {0x1BE6, 0x1BE6}, {0x1BE8, 0x1BE9}, + {0x1BED, 0x1BED}, {0x1BEF, 0x1BF1}, {0x1C2C, 0x1C33}, + {0x1C36, 0x1C37}, {0x1CD0, 0x1CD2}, {0x1CD4, 0x1CE0}, + {0x1CE2, 0x1CE8}, {0x1CED, 0x1CED}, {0x1CF4, 0x1CF4}, + {0x1CF8, 0x1CF9}, {0x1DC0, 0x1DFF}, {0x20D0, 0x20F0}, + {0x2CEF, 0x2CF1}, {0x2D7F, 0x2D7F}, {0x2DE0, 0x2DFF}, + {0x302A, 0x302D}, {0x3099, 0x309A}, {0xA66F, 0xA672}, + {0xA674, 0xA67D}, {0xA69E, 0xA69F}, {0xA6F0, 0xA6F1}, + {0xA802, 0xA802}, {0xA806, 0xA806}, {0xA80B, 0xA80B}, + {0xA825, 0xA826}, {0xA82C, 0xA82C}, {0xA8C4, 0xA8C5}, + {0xA8E0, 0xA8F1}, {0xA8FF, 0xA8FF}, {0xA926, 0xA92D}, + {0xA947, 0xA951}, {0xA980, 0xA982}, {0xA9B3, 0xA9B3}, + {0xA9B6, 0xA9B9}, {0xA9BC, 0xA9BD}, {0xA9E5, 0xA9E5}, + {0xAA29, 0xAA2E}, {0xAA31, 0xAA32}, {0xAA35, 0xAA36}, + {0xAA43, 0xAA43}, {0xAA4C, 0xAA4C}, {0xAA7C, 0xAA7C}, + {0xAAB0, 0xAAB0}, {0xAAB2, 0xAAB4}, {0xAAB7, 0xAAB8}, + {0xAABE, 0xAABF}, {0xAAC1, 0xAAC1}, {0xAAEC, 0xAAED}, + {0xAAF6, 0xAAF6}, {0xABE5, 0xABE5}, {0xABE8, 0xABE8}, + {0xABED, 0xABED}, {0xFB1E, 0xFB1E}, {0xFE00, 0xFE0F}, + {0xFE20, 0xFE2F}, {0x101FD, 0x101FD}, {0x102E0, 0x102E0}, + {0x10376, 0x1037A}, {0x10A01, 0x10A03}, {0x10A05, 0x10A06}, + {0x10A0C, 0x10A0F}, {0x10A38, 0x10A3A}, {0x10A3F, 0x10A3F}, + {0x10AE5, 0x10AE6}, {0x10D24, 0x10D27}, {0x10D69, 0x10D6D}, + {0x10EAB, 0x10EAC}, {0x10EFA, 0x10EFF}, {0x10F46, 0x10F50}, + {0x10F82, 0x10F85}, {0x11001, 0x11001}, {0x11038, 0x11046}, + {0x11070, 0x11070}, {0x11073, 0x11074}, {0x1107F, 0x11081}, + {0x110B3, 0x110B6}, {0x110B9, 0x110BA}, {0x110C2, 0x110C2}, + {0x11100, 0x11102}, {0x11127, 0x1112B}, {0x1112D, 0x11134}, + {0x11173, 0x11173}, {0x11180, 0x11181}, {0x111B6, 0x111BE}, + {0x111C9, 0x111CC}, {0x111CF, 0x111CF}, {0x1122F, 0x11231}, + {0x11234, 0x11234}, {0x11236, 0x11237}, {0x1123E, 0x1123E}, + {0x11241, 0x11241}, {0x112DF, 0x112DF}, {0x112E3, 0x112EA}, + {0x11300, 0x11301}, {0x1133B, 0x1133C}, {0x11340, 0x11340}, + {0x11366, 0x1136C}, {0x11370, 0x11374}, {0x113BB, 0x113C0}, + {0x113CE, 0x113CE}, {0x113D0, 0x113D0}, {0x113D2, 0x113D2}, + {0x113E1, 0x113E2}, {0x11438, 0x1143F}, {0x11442, 0x11444}, + {0x11446, 0x11446}, {0x1145E, 0x1145E}, {0x114B3, 0x114B8}, + {0x114BA, 0x114BA}, {0x114BF, 0x114C0}, {0x114C2, 0x114C3}, + {0x115B2, 0x115B5}, {0x115BC, 0x115BD}, {0x115BF, 0x115C0}, + {0x115DC, 0x115DD}, {0x11633, 0x1163A}, {0x1163D, 0x1163D}, + {0x1163F, 0x11640}, {0x116AB, 0x116AB}, {0x116AD, 0x116AD}, + {0x116B0, 0x116B5}, {0x116B7, 0x116B7}, {0x1171D, 0x1171D}, + {0x1171F, 0x1171F}, {0x11722, 0x11725}, {0x11727, 0x1172B}, + {0x1182F, 0x11837}, {0x11839, 0x1183A}, {0x1193B, 0x1193C}, + {0x1193E, 0x1193E}, {0x11943, 0x11943}, {0x119D4, 0x119D7}, + {0x119DA, 0x119DB}, {0x119E0, 0x119E0}, {0x11A01, 0x11A0A}, + {0x11A33, 0x11A38}, {0x11A3B, 0x11A3E}, {0x11A47, 0x11A47}, + {0x11A51, 0x11A56}, {0x11A59, 0x11A5B}, {0x11A8A, 0x11A96}, + {0x11A98, 0x11A99}, {0x11B60, 0x11B60}, {0x11B62, 0x11B64}, + {0x11B66, 0x11B66}, {0x11C30, 0x11C36}, {0x11C38, 0x11C3D}, + {0x11C3F, 0x11C3F}, {0x11C92, 0x11CA7}, {0x11CAA, 0x11CB0}, + {0x11CB2, 0x11CB3}, {0x11CB5, 0x11CB6}, {0x11D31, 0x11D36}, + {0x11D3A, 0x11D3A}, {0x11D3C, 0x11D3D}, {0x11D3F, 0x11D45}, + {0x11D47, 0x11D47}, {0x11D90, 0x11D91}, {0x11D95, 0x11D95}, + {0x11D97, 0x11D97}, {0x11EF3, 0x11EF4}, {0x11F00, 0x11F01}, + {0x11F36, 0x11F3A}, {0x11F40, 0x11F40}, {0x11F42, 0x11F42}, + {0x11F5A, 0x11F5A}, {0x13440, 0x13440}, {0x13447, 0x13455}, + {0x1611E, 0x16129}, {0x1612D, 0x1612F}, {0x16AF0, 0x16AF4}, + {0x16B30, 0x16B36}, {0x16F4F, 0x16F4F}, {0x16F8F, 0x16F92}, + {0x16FE4, 0x16FE4}, {0x1BC9D, 0x1BC9E}, {0x1CF00, 0x1CF2D}, + {0x1CF30, 0x1CF46}, {0x1D165, 0x1D169}, {0x1D16D, 0x1D172}, + {0x1D17B, 0x1D182}, {0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD}, + {0x1D242, 0x1D244}, {0x1DA00, 0x1DA36}, {0x1DA3B, 0x1DA6C}, + {0x1DA75, 0x1DA75}, {0x1DA84, 0x1DA84}, {0x1DA9B, 0x1DA9F}, + {0x1DAA1, 0x1DAAF}, {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, + {0x1E01B, 0x1E021}, {0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, + {0x1E08F, 0x1E08F}, {0x1E130, 0x1E136}, {0x1E2AE, 0x1E2AE}, + {0x1E2EC, 0x1E2EF}, {0x1E4EC, 0x1E4EF}, {0x1E5EE, 0x1E5EF}, + {0x1E6E3, 0x1E6E3}, {0x1E6E6, 0x1E6E6}, {0x1E6EE, 0x1E6EF}, + {0x1E6F5, 0x1E6F5}, {0x1E8D0, 0x1E8D6}, {0x1E944, 0x1E94A}, {0xE0100, 0xE01EF}, } diff --git a/vendor/github.com/miekg/dns/README.md b/vendor/github.com/miekg/dns/README.md index 8dc2472360..7e09e1d1b3 100644 --- a/vendor/github.com/miekg/dns/README.md +++ b/vendor/github.com/miekg/dns/README.md @@ -3,15 +3,10 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/miekg/dns)](https://goreportcard.com/report/miekg/dns) [![](https://godoc.org/github.com/miekg/dns?status.svg)](https://godoc.org/github.com/miekg/dns) -DNS version 2 is now available at , check it out if you want to -help shape the next 15 years of the Go DNS package. +DNS version 2 is now available at . This version should be 2x faster across +the board. Further optimizations welcome. -The version here will see no new features and less and less development, and my time (if any) will be fully -devoted towards v2. - -**December 2025**: v2 should be (already) a good replacement, the coming months would be a good time to -migrate, see [this file describing the -differences](https://codeberg.org/miekg/dns/src/branch/main/README-diff-with-v1.md), to help you get started. +The version here will only see specific fixes and nothing else. At some point this repo will be archived. # Alternative (more granular) approach to a DNS library diff --git a/vendor/github.com/miekg/dns/dnssec.go b/vendor/github.com/miekg/dns/dnssec.go index ffdafcebda..ef04f490ca 100644 --- a/vendor/github.com/miekg/dns/dnssec.go +++ b/vendor/github.com/miekg/dns/dnssec.go @@ -12,7 +12,6 @@ import ( _ "crypto/sha256" // need its init function _ "crypto/sha512" // need its init function "encoding/asn1" - "encoding/binary" "encoding/hex" "math/big" "sort" @@ -134,38 +133,27 @@ func (k *DNSKEY) KeyTag() uint16 { return 0 } var keytag int - switch k.Algorithm { - case RSAMD5: - // This algorithm has been deprecated, but keep this key-tag calculation. - // Look at the bottom two bytes of the modules, which the last item in the pubkey. - // See https://www.rfc-editor.org/errata/eid193 . - modulus, _ := fromBase64([]byte(k.PublicKey)) - if len(modulus) > 1 { - x := binary.BigEndian.Uint16(modulus[len(modulus)-3:]) - keytag = int(x) - } - default: - keywire := new(dnskeyWireFmt) - keywire.Flags = k.Flags - keywire.Protocol = k.Protocol - keywire.Algorithm = k.Algorithm - keywire.PublicKey = k.PublicKey - wire := make([]byte, DefaultMsgSize) - n, err := packKeyWire(keywire, wire) - if err != nil { - return 0 - } - wire = wire[:n] - for i, v := range wire { - if i&1 != 0 { - keytag += int(v) // must be larger than uint32 - } else { - keytag += int(v) << 8 - } + keywire := new(dnskeyWireFmt) + keywire.Flags = k.Flags + keywire.Protocol = k.Protocol + keywire.Algorithm = k.Algorithm + keywire.PublicKey = k.PublicKey + wire := make([]byte, DefaultMsgSize) + n, err := packKeyWire(keywire, wire) + if err != nil { + return 0 + } + wire = wire[:n] + for i, v := range wire { + if i&1 != 0 { + keytag += int(v) // must be larger than uint32 + } else { + keytag += int(v) << 8 } - keytag += keytag >> 16 & 0xFFFF - keytag &= 0xFFFF } + keytag += keytag >> 16 & 0xFFFF + keytag &= 0xFFFF + return uint16(keytag) } diff --git a/vendor/github.com/miekg/dns/tools.go b/vendor/github.com/miekg/dns/tools.go deleted file mode 100644 index ccf8f6bfc7..0000000000 --- a/vendor/github.com/miekg/dns/tools.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build tools -// +build tools - -// We include our tool dependencies for `go generate` here to ensure they're -// properly tracked by the go tool. See the Go Wiki for the rationale behind this: -// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module. - -package dns - -import _ "golang.org/x/tools/go/packages" diff --git a/vendor/github.com/miekg/dns/version.go b/vendor/github.com/miekg/dns/version.go index 33cb83e5ac..78cfcc39ea 100644 --- a/vendor/github.com/miekg/dns/version.go +++ b/vendor/github.com/miekg/dns/version.go @@ -3,7 +3,7 @@ package dns import "fmt" // Version is current version of this library. -var Version = v{1, 1, 72} +var Version = v{1, 1, 73} // v holds the version of this library. type v struct { diff --git a/vendor/github.com/miekg/dns/zmsg.go b/vendor/github.com/miekg/dns/zmsg.go index 8143ddc1b9..b2b49b1537 100644 --- a/vendor/github.com/miekg/dns/zmsg.go +++ b/vendor/github.com/miekg/dns/zmsg.go @@ -2369,7 +2369,7 @@ func (rr *RESINFO) unpack(msg []byte, off int) (off1 int, err error) { rr.Txt, off, err = unpackStringTxt(msg, off) if err != nil { - return off, err + return off, fmt.Errorf("RESINFO.Txt: %w", err) } return off, nil } diff --git a/vendor/github.com/prometheus/procfs/.golangci.yml b/vendor/github.com/prometheus/procfs/.golangci.yml index eac920ba80..23ecd4505b 100644 --- a/vendor/github.com/prometheus/procfs/.golangci.yml +++ b/vendor/github.com/prometheus/procfs/.golangci.yml @@ -34,14 +34,6 @@ linters: capital: true misspell: locale: US - revive: - rules: - - name: var-naming - # TODO(SuperQ): See: https://github.com/prometheus/prometheus/issues/17766 - arguments: - - [] - - [] - - - skip-package-name-checks: true exclusions: presets: - comments diff --git a/vendor/github.com/prometheus/procfs/CONTRIBUTING.md b/vendor/github.com/prometheus/procfs/CONTRIBUTING.md index 853eb9d49b..812a71bb97 100644 --- a/vendor/github.com/prometheus/procfs/CONTRIBUTING.md +++ b/vendor/github.com/prometheus/procfs/CONTRIBUTING.md @@ -96,7 +96,7 @@ The `proc` and `sys` filesystems are pseudo file systems and work a bit differen Many of the files are changing continuously and the data being read can in some cases change between subsequent reads in the same file. Also, most of the files are relatively small (less than a few KBs), and system calls to the `stat` function will often return the wrong size. Therefore, for most files it's recommended to read the -full file in a single operation using an internal utility function called `util.ReadFileNoStat`. +full file in a single operation using an internal utility function called `parsers.ReadFileNoStat`. This function is similar to `os.ReadFile`, but it avoids the system call to `stat` to get the current size of the file. @@ -104,7 +104,7 @@ Note that parsing the file's contents can still be performed one line at a time. the full file, and then using a scanner on the `[]byte` or `string` containing the data. ``` - data, err := util.ReadFileNoStat("/proc/cpuinfo") + data, err := parsers.ReadFileNoStat("/proc/cpuinfo") if err != nil { return err } @@ -113,9 +113,9 @@ the full file, and then using a scanner on the `[]byte` or `string` containing t ``` The `/sys` filesystem contains many very small files which contain only a single numeric or text value. These files -can be read using an internal function called `util.SysReadFile` which is similar to `os.ReadFile` but does +can be read using an internal function called `parsers.SysReadFile` which is similar to `os.ReadFile` but does not bother to check the size of the file before reading. ``` - data, err := util.SysReadFile("/sys/class/power_supply/BAT0/capacity") + data, err := parsers.SysReadFile("/sys/class/power_supply/BAT0/capacity") ``` diff --git a/vendor/github.com/prometheus/procfs/Makefile.common b/vendor/github.com/prometheus/procfs/Makefile.common index a7c5f553e1..cd54cb419c 100644 --- a/vendor/github.com/prometheus/procfs/Makefile.common +++ b/vendor/github.com/prometheus/procfs/Makefile.common @@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_ SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v2.11.4 +GOLANGCI_LINT_VERSION ?= v2.12.2 GOLANGCI_FMT_OPTS ?= # golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64. # windows isn't included here because of the path separator being different. @@ -165,8 +165,9 @@ common-deps: .PHONY: update-go-deps update-go-deps: @echo ">> updating Go dependencies" + # GOTOOLCHAIN prevents go get from pulling deps that require a newer Go version. @for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \ - $(GO) get $$m; \ + GOTOOLCHAIN=go$$($(GO) mod edit -json | jq -r .Go) $(GO) get $$m; \ done $(GO) mod tidy @@ -246,6 +247,7 @@ common-docker-repo-name: .PHONY: common-docker $(BUILD_DOCKER_ARCHS) common-docker: $(BUILD_DOCKER_ARCHS) +# DOCKER_ARCHS holds promu architecture names, which are not OCI platform strings. $(BUILD_DOCKER_ARCHS): common-docker-%: @for variant in $(DOCKERFILE_VARIANTS_WITH_NAMES); do \ dockerfile=$${variant#*:}; \ @@ -254,10 +256,16 @@ $(BUILD_DOCKER_ARCHS): common-docker-%: if [ "$*" = "armv7" ]; then \ distroless_arch="arm"; \ fi; \ + arch="$*"; \ + case "$$arch" in \ + armv*) docker_platform="linux/arm/v$${arch#armv}";; \ + *) docker_platform="linux/$$arch";; \ + esac; \ if [ "$$dockerfile" = "Dockerfile" ]; then \ echo "Building default variant ($$variant_name) for linux-$* using $$dockerfile"; \ docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" \ -f $$dockerfile \ + --platform "$$docker_platform" \ --build-arg ARCH="$*" \ --build-arg OS="linux" \ --build-arg DISTROLESS_ARCH="$$distroless_arch" \ @@ -271,6 +279,7 @@ $(BUILD_DOCKER_ARCHS): common-docker-%: echo "Building $$variant_name variant for linux-$* using $$dockerfile"; \ docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)-$$variant_name" \ -f $$dockerfile \ + --platform "$$docker_platform" \ --build-arg ARCH="$*" \ --build-arg OS="linux" \ --build-arg DISTROLESS_ARCH="$$distroless_arch" \ diff --git a/vendor/github.com/prometheus/procfs/cmdline.go b/vendor/github.com/prometheus/procfs/cmdline.go index 4f1cac1f0a..6a2e7bb0ec 100644 --- a/vendor/github.com/prometheus/procfs/cmdline.go +++ b/vendor/github.com/prometheus/procfs/cmdline.go @@ -16,12 +16,12 @@ package procfs import ( "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // CmdLine returns the command line of the kernel. func (fs FS) CmdLine() ([]string, error) { - data, err := util.ReadFileNoStat(fs.proc.Path("cmdline")) + data, err := parsers.ReadFileNoStat(fs.proc.Path("cmdline")) if err != nil { return nil, err } diff --git a/vendor/github.com/prometheus/procfs/cpuinfo.go b/vendor/github.com/prometheus/procfs/cpuinfo.go index 4b23d8d6b5..7a31a4555b 100644 --- a/vendor/github.com/prometheus/procfs/cpuinfo.go +++ b/vendor/github.com/prometheus/procfs/cpuinfo.go @@ -24,7 +24,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // CPUInfo contains general information about a system CPU found in /proc/cpuinfo. @@ -65,7 +65,7 @@ var ( // CPUInfo returns information about current system CPUs. // See https://www.kernel.org/doc/Documentation/filesystems/proc.txt func (fs FS) CPUInfo() ([]CPUInfo, error) { - data, err := util.ReadFileNoStat(fs.proc.Path("cpuinfo")) + data, err := parsers.ReadFileNoStat(fs.proc.Path("cpuinfo")) if err != nil { return nil, err } diff --git a/vendor/github.com/prometheus/procfs/crypto.go b/vendor/github.com/prometheus/procfs/crypto.go index d93b712e05..c4ba05b15a 100644 --- a/vendor/github.com/prometheus/procfs/crypto.go +++ b/vendor/github.com/prometheus/procfs/crypto.go @@ -20,7 +20,7 @@ import ( "io" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // Crypto holds info parsed from /proc/crypto. @@ -55,7 +55,7 @@ var cryptoFile = "crypto" // https://kernel.readthedocs.io/en/sphinx-samples/crypto-API.html func (fs FS) Crypto() ([]Crypto, error) { path := fs.proc.Path(cryptoFile) - b, err := util.ReadFileNoStat(path) + b, err := parsers.ReadFileNoStat(path) if err != nil { return nil, fmt.Errorf("%w: Cannot read file %v: %w", ErrFileRead, b, err) @@ -112,7 +112,7 @@ func parseCrypto(r io.Reader) ([]Crypto, error) { // parseKV parses a key/value pair into the appropriate field of c. func (c *Crypto) parseKV(k, v string) error { - vp := util.NewValueParser(v) + vp := parsers.NewValueParser(v) switch k { case "async": diff --git a/vendor/github.com/prometheus/procfs/fs_statfs_notype.go b/vendor/github.com/prometheus/procfs/fs_statfs_notype.go index 0bef25bdd9..fc16802dcb 100644 --- a/vendor/github.com/prometheus/procfs/fs_statfs_notype.go +++ b/vendor/github.com/prometheus/procfs/fs_statfs_notype.go @@ -15,8 +15,8 @@ package procfs -// isRealProc returns true on architectures that don't have a Type argument +// isRealProc returns false on architectures that don't have a Type argument // in their Statfs_t struct. func isRealProc(_ string) (bool, error) { - return true, nil + return false, nil } diff --git a/vendor/github.com/prometheus/procfs/fscache.go b/vendor/github.com/prometheus/procfs/fscache.go index 9dde857073..388295cb46 100644 --- a/vendor/github.com/prometheus/procfs/fscache.go +++ b/vendor/github.com/prometheus/procfs/fscache.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // Fscacheinfo represents fscache statistics. @@ -229,7 +229,7 @@ type Fscacheinfo struct { // Fscacheinfo returns information about current fscache statistics. // See https://www.kernel.org/doc/Documentation/filesystems/caching/fscache.txt func (fs FS) Fscacheinfo() (Fscacheinfo, error) { - b, err := util.ReadFileNoStat(fs.proc.Path("fs/fscache/stats")) + b, err := parsers.ReadFileNoStat(fs.proc.Path("fs/fscache/stats")) if err != nil { return Fscacheinfo{}, err } diff --git a/vendor/github.com/prometheus/procfs/internal/fs/fs.go b/vendor/github.com/prometheus/procfs/internal/fs/fs.go index e7ccad66b2..bdd8010a48 100644 --- a/vendor/github.com/prometheus/procfs/internal/fs/fs.go +++ b/vendor/github.com/prometheus/procfs/internal/fs/fs.go @@ -31,6 +31,9 @@ const ( // DefaultSelinuxMountPoint is the common mount point of the selinuxfs. DefaultSelinuxMountPoint = "/sys/fs/selinux" + + // DefaultResctrlMountPoint is the common mount point of the resctrl filesystem. + DefaultResctrlMountPoint = "/sys/fs/resctrl" ) // FS represents a pseudo-filesystem, normally /proc or /sys, which provides an diff --git a/vendor/github.com/prometheus/procfs/internal/util/parse.go b/vendor/github.com/prometheus/procfs/internal/parsers/parse.go similarity index 99% rename from vendor/github.com/prometheus/procfs/internal/util/parse.go rename to vendor/github.com/prometheus/procfs/internal/parsers/parse.go index 30c5872019..5789ae5db0 100644 --- a/vendor/github.com/prometheus/procfs/internal/util/parse.go +++ b/vendor/github.com/prometheus/procfs/internal/parsers/parse.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package util +package parsers import ( "errors" diff --git a/vendor/github.com/prometheus/procfs/internal/util/readfile.go b/vendor/github.com/prometheus/procfs/internal/parsers/readfile.go similarity index 98% rename from vendor/github.com/prometheus/procfs/internal/util/readfile.go rename to vendor/github.com/prometheus/procfs/internal/parsers/readfile.go index 0e41f71af1..c68d292153 100644 --- a/vendor/github.com/prometheus/procfs/internal/util/readfile.go +++ b/vendor/github.com/prometheus/procfs/internal/parsers/readfile.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package util +package parsers import ( "io" diff --git a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile.go b/vendor/github.com/prometheus/procfs/internal/parsers/sysreadfile.go similarity index 99% rename from vendor/github.com/prometheus/procfs/internal/util/sysreadfile.go rename to vendor/github.com/prometheus/procfs/internal/parsers/sysreadfile.go index f6a4a4de62..0f72f6021c 100644 --- a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile.go +++ b/vendor/github.com/prometheus/procfs/internal/parsers/sysreadfile.go @@ -13,7 +13,7 @@ //go:build (linux || darwin) && !appengine -package util +package parsers import ( "bytes" diff --git a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile_compat.go b/vendor/github.com/prometheus/procfs/internal/parsers/sysreadfile_compat.go similarity index 98% rename from vendor/github.com/prometheus/procfs/internal/util/sysreadfile_compat.go rename to vendor/github.com/prometheus/procfs/internal/parsers/sysreadfile_compat.go index c80e082cb9..6e19c45559 100644 --- a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile_compat.go +++ b/vendor/github.com/prometheus/procfs/internal/parsers/sysreadfile_compat.go @@ -13,7 +13,7 @@ //go:build (linux && appengine) || (!linux && !darwin) -package util +package parsers import ( "fmt" diff --git a/vendor/github.com/prometheus/procfs/internal/util/valueparser.go b/vendor/github.com/prometheus/procfs/internal/parsers/valueparser.go similarity index 99% rename from vendor/github.com/prometheus/procfs/internal/util/valueparser.go rename to vendor/github.com/prometheus/procfs/internal/parsers/valueparser.go index e0ed671ea0..6289fd6704 100644 --- a/vendor/github.com/prometheus/procfs/internal/util/valueparser.go +++ b/vendor/github.com/prometheus/procfs/internal/parsers/valueparser.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package util +package parsers import ( "strconv" diff --git a/vendor/github.com/prometheus/procfs/ipvs.go b/vendor/github.com/prometheus/procfs/ipvs.go index 5374da9fa8..8a6f737478 100644 --- a/vendor/github.com/prometheus/procfs/ipvs.go +++ b/vendor/github.com/prometheus/procfs/ipvs.go @@ -25,7 +25,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // IPVSStats holds IPVS statistics, as exposed by the kernel in `/proc/net/ip_vs_stats`. @@ -66,7 +66,7 @@ type IPVSBackendStatus struct { // IPVSStats reads the IPVS statistics from the specified `proc` filesystem. func (fs FS) IPVSStats() (IPVSStats, error) { - data, err := util.ReadFileNoStat(fs.proc.Path("net/ip_vs_stats")) + data, err := parsers.ReadFileNoStat(fs.proc.Path("net/ip_vs_stats")) if err != nil { return IPVSStats{}, err } diff --git a/vendor/github.com/prometheus/procfs/kernel_random.go b/vendor/github.com/prometheus/procfs/kernel_random.go index e7c5b8cf2b..cbcd12b436 100644 --- a/vendor/github.com/prometheus/procfs/kernel_random.go +++ b/vendor/github.com/prometheus/procfs/kernel_random.go @@ -18,7 +18,7 @@ package procfs import ( "os" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // KernelRandom contains information about to the kernel's random number generator. @@ -48,7 +48,7 @@ func (fs FS) KernelRandom() (KernelRandom, error) { "write_wakeup_threshold": &random.WriteWakeupThreshold, "read_wakeup_threshold": &random.ReadWakeupThreshold, } { - val, err := util.ReadUintFromFile(fs.proc.Path("sys", "kernel", "random", file)) + val, err := parsers.ReadUintFromFile(fs.proc.Path("sys", "kernel", "random", file)) if os.IsNotExist(err) { continue } diff --git a/vendor/github.com/prometheus/procfs/kernel_tainted.go b/vendor/github.com/prometheus/procfs/kernel_tainted.go new file mode 100644 index 0000000000..9707f02808 --- /dev/null +++ b/vendor/github.com/prometheus/procfs/kernel_tainted.go @@ -0,0 +1,95 @@ +// Copyright The Prometheus Authors +// 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 linux + +package procfs + +import ( + "github.com/prometheus/procfs/internal/parsers" +) + +// KernelTaintBit represents a single kernel taint flag. +type KernelTaintBit struct { + // Index is the zero-based bit position in the tainted bitmask. + Index int + // Flag is the letter code identifying this taint (e.g. "L" for soft lockup). + // See https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html + Flag string + // Description is a human-readable explanation of what this taint means. + Description string + // Set indicates whether this taint flag is currently active. + Set bool +} + +// KernelTainted holds the kernel taint state read from /proc/sys/kernel/tainted. +type KernelTainted struct { + // Value is the raw integer from /proc/sys/kernel/tainted. + Value uint64 + // Bits contains each known taint flag and whether it is currently set. + // Flags are listed in bit-position order (bit 0 first). + Bits []KernelTaintBit +} + +// kernelTaintBitDefs lists all known kernel taint flags in bit-position order. +// Reference: https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html +var kernelTaintBitDefs = []struct { + flag string + description string +}{ + {"P", "Proprietary module was loaded."}, + {"F", "Module was force loaded."}, + {"S", "SMP kernel oops on an officially SMP incapable processor."}, + {"R", "Module was force unloaded."}, + {"M", "Processor reported a Machine Check Exception (MCE)."}, + {"B", "Bad page referenced or some unexpected page flags."}, + {"U", "Taint requested by userspace application."}, + {"D", "Kernel died recently, i.e. there was an OOPS or BUG."}, + {"A", "An ACPI table was overridden by user."}, + {"W", "Kernel issued warning."}, + {"C", "Staging driver was loaded."}, + {"I", "Workaround for bug in platform firmware applied."}, + {"O", "Externally-built (out-of-tree) module was loaded."}, + {"E", "Unsigned module was loaded."}, + {"L", "Soft lockup occurred."}, + {"K", "Kernel has been live patched."}, + {"X", "Auxiliary taint, defined and used by distros."}, + {"T", "The kernel was built with the struct randomization plugin."}, + {"N", "An in-kernel test such as a KUnit test has been run."}, + {"J", "Userspace used a mutating debug operation in fwctl."}, +} + +// KernelTainted reads /proc/sys/kernel/tainted and returns the raw taint value +// along with each known flag parsed into a KernelTainted struct. +// See https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html +func (fs FS) KernelTainted() (KernelTainted, error) { + value, err := parsers.SysReadUintFromFile(fs.proc.Path("sys", "kernel", "tainted")) + if err != nil { + return KernelTainted{}, err + } + return parseTainted(value), nil +} + +// parseTainted builds a KernelTainted from the raw taint bitmask value. +func parseTainted(value uint64) KernelTainted { + bits := make([]KernelTaintBit, len(kernelTaintBitDefs)) + for i, def := range kernelTaintBitDefs { + bits[i] = KernelTaintBit{ + Index: i, + Flag: def.flag, + Description: def.description, + Set: value&(1</environ`. func (p Proc) Environ() ([]string, error) { environments := make([]string, 0) - data, err := util.ReadFileNoStat(p.path("environ")) + data, err := parsers.ReadFileNoStat(p.path("environ")) if err != nil { return environments, err } diff --git a/vendor/github.com/prometheus/procfs/proc_fdinfo.go b/vendor/github.com/prometheus/procfs/proc_fdinfo.go index fa57761dbe..9e3e313e14 100644 --- a/vendor/github.com/prometheus/procfs/proc_fdinfo.go +++ b/vendor/github.com/prometheus/procfs/proc_fdinfo.go @@ -19,7 +19,7 @@ import ( "fmt" "regexp" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) var ( @@ -49,7 +49,7 @@ type ProcFDInfo struct { // FDInfo constructor. On kernels older than 3.8, InotifyInfos will always be empty. func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) { - data, err := util.ReadFileNoStat(p.path("fdinfo", fd)) + data, err := parsers.ReadFileNoStat(p.path("fdinfo", fd)) if err != nil { return nil, err } diff --git a/vendor/github.com/prometheus/procfs/proc_interrupts.go b/vendor/github.com/prometheus/procfs/proc_interrupts.go index 643b500d5d..2a2412c4f8 100644 --- a/vendor/github.com/prometheus/procfs/proc_interrupts.go +++ b/vendor/github.com/prometheus/procfs/proc_interrupts.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // Interrupt represents a single interrupt line. @@ -42,7 +42,7 @@ type Interrupts map[string]Interrupt // Interrupts creates a new instance from a given Proc instance. func (p Proc) Interrupts() (Interrupts, error) { - data, err := util.ReadFileNoStat(p.fs.proc.Path("interrupts")) + data, err := parsers.ReadFileNoStat(p.fs.proc.Path("interrupts")) if err != nil { return nil, err } diff --git a/vendor/github.com/prometheus/procfs/proc_io.go b/vendor/github.com/prometheus/procfs/proc_io.go index dd8086ba2e..ca221bb656 100644 --- a/vendor/github.com/prometheus/procfs/proc_io.go +++ b/vendor/github.com/prometheus/procfs/proc_io.go @@ -16,7 +16,7 @@ package procfs import ( "fmt" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // ProcIO models the content of /proc//io. @@ -43,7 +43,7 @@ type ProcIO struct { func (p Proc) IO() (ProcIO, error) { pio := ProcIO{} - data, err := util.ReadFileNoStat(p.path("io")) + data, err := parsers.ReadFileNoStat(p.path("io")) if err != nil { return pio, err } diff --git a/vendor/github.com/prometheus/procfs/proc_netstat.go b/vendor/github.com/prometheus/procfs/proc_netstat.go index 7f94cc8914..6a118f58a7 100644 --- a/vendor/github.com/prometheus/procfs/proc_netstat.go +++ b/vendor/github.com/prometheus/procfs/proc_netstat.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // ProcNetstat models the content of /proc//net/netstat. @@ -146,6 +146,20 @@ type TcpExt struct { // nolint:revive TCPMTUPFail *float64 TCPMTUPSuccess *float64 TCPWqueueTooBig *float64 + + // Legacy TcpExt counters dropped from recent kernels' TcpExt table; + // modeled so consumers retain metric parity with older kernels that + // still print them in /proc/net/netstat. + TCPLoss *float64 + PAWSPassive *float64 + TCPForwardRetrans *float64 + TCPSchedulerFailed *float64 + TCPPrequeued *float64 + TCPDirectCopyFromBacklog *float64 + TCPDirectCopyFromPrequeue *float64 + TCPPrequeueDropped *float64 + TCPFACKReorder *float64 + TCPHPHitsToUser *float64 } type IpExt struct { // nolint:revive @@ -171,7 +185,7 @@ type IpExt struct { // nolint:revive func (p Proc) Netstat() (ProcNetstat, error) { filename := p.path("net/netstat") - data, err := util.ReadFileNoStat(filename) + data, err := parsers.ReadFileNoStat(filename) if err != nil { return ProcNetstat{PID: p.PID}, err } @@ -396,6 +410,26 @@ func parseProcNetstat(r io.Reader, fileName string) (ProcNetstat, error) { procNetstat.TCPMTUPSuccess = &value case "TCPWqueueTooBig": procNetstat.TCPWqueueTooBig = &value + case "TCPLoss": + procNetstat.TCPLoss = &value + case "PAWSPassive": + procNetstat.PAWSPassive = &value + case "TCPForwardRetrans": + procNetstat.TCPForwardRetrans = &value + case "TCPSchedulerFailed": + procNetstat.TCPSchedulerFailed = &value + case "TCPPrequeued": + procNetstat.TCPPrequeued = &value + case "TCPDirectCopyFromBacklog": + procNetstat.TCPDirectCopyFromBacklog = &value + case "TCPDirectCopyFromPrequeue": + procNetstat.TCPDirectCopyFromPrequeue = &value + case "TCPPrequeueDropped": + procNetstat.TCPPrequeueDropped = &value + case "TCPFACKReorder": + procNetstat.TCPFACKReorder = &value + case "TCPHPHitsToUser": + procNetstat.TCPHPHitsToUser = &value } case "IpExt": switch key { diff --git a/vendor/github.com/prometheus/procfs/proc_psi.go b/vendor/github.com/prometheus/procfs/proc_psi.go index cc2c5de873..5f0fbdffb5 100644 --- a/vendor/github.com/prometheus/procfs/proc_psi.go +++ b/vendor/github.com/prometheus/procfs/proc_psi.go @@ -30,7 +30,7 @@ import ( "io" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) const lineFormat = "avg10=%f avg60=%f avg300=%f total=%d" @@ -59,7 +59,7 @@ type PSIStats struct { // resource from /proc/pressure/. At time of writing this can be // either "cpu", "memory" or "io". func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) { - data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource))) + data, err := parsers.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource))) if err != nil { return PSIStats{}, fmt.Errorf("%w: psi_stats: unavailable for %q: %w", ErrFileRead, resource, err) } diff --git a/vendor/github.com/prometheus/procfs/proc_smaps.go b/vendor/github.com/prometheus/procfs/proc_smaps.go index f637309b3d..dff5cfb885 100644 --- a/vendor/github.com/prometheus/procfs/proc_smaps.go +++ b/vendor/github.com/prometheus/procfs/proc_smaps.go @@ -23,7 +23,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) var ( @@ -60,7 +60,7 @@ type ProcSMapsRollup struct { // If smaps_rollup does not exists (require kernel >= 4.15), the content of /proc/pid/smaps will // we read and summed. func (p Proc) ProcSMapsRollup() (ProcSMapsRollup, error) { - data, err := util.ReadFileNoStat(p.path("smaps_rollup")) + data, err := parsers.ReadFileNoStat(p.path("smaps_rollup")) if err != nil && os.IsNotExist(err) { return p.procSMapsRollupManual() } diff --git a/vendor/github.com/prometheus/procfs/proc_snmp.go b/vendor/github.com/prometheus/procfs/proc_snmp.go index 8d9a9bcd67..531bc8371c 100644 --- a/vendor/github.com/prometheus/procfs/proc_snmp.go +++ b/vendor/github.com/prometheus/procfs/proc_snmp.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // ProcSnmp models the content of /proc//net/snmp. @@ -135,7 +135,7 @@ type UdpLite struct { // nolint:revive func (p Proc) Snmp() (ProcSnmp, error) { filename := p.path("net/snmp") - data, err := util.ReadFileNoStat(filename) + data, err := parsers.ReadFileNoStat(filename) if err != nil { return ProcSnmp{PID: p.PID}, err } diff --git a/vendor/github.com/prometheus/procfs/proc_snmp6.go b/vendor/github.com/prometheus/procfs/proc_snmp6.go index 841fef4649..8296a4aed1 100644 --- a/vendor/github.com/prometheus/procfs/proc_snmp6.go +++ b/vendor/github.com/prometheus/procfs/proc_snmp6.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // ProcSnmp6 models the content of /proc//net/snmp6. @@ -140,7 +140,7 @@ type UdpLite6 struct { // nolint:revive func (p Proc) Snmp6() (ProcSnmp6, error) { filename := p.path("net/snmp6") - data, err := util.ReadFileNoStat(filename) + data, err := parsers.ReadFileNoStat(filename) if err != nil { // On systems with IPv6 disabled, this file won't exist. // Do nothing. diff --git a/vendor/github.com/prometheus/procfs/proc_stat.go b/vendor/github.com/prometheus/procfs/proc_stat.go index 02e3f9e316..d9e544bcc8 100644 --- a/vendor/github.com/prometheus/procfs/proc_stat.go +++ b/vendor/github.com/prometheus/procfs/proc_stat.go @@ -18,7 +18,7 @@ import ( "fmt" "os" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // Originally, this USER_HZ value was dynamically retrieved via a sysconf call @@ -134,7 +134,7 @@ func (p Proc) NewStat() (ProcStat, error) { // Stat returns the current status information of the process. func (p Proc) Stat() (ProcStat, error) { - data, err := util.ReadFileNoStat(p.path("stat")) + data, err := parsers.ReadFileNoStat(p.path("stat")) if err != nil { return ProcStat{}, err } diff --git a/vendor/github.com/prometheus/procfs/proc_statm.go b/vendor/github.com/prometheus/procfs/proc_statm.go index 6bcc97ec9c..5fbe27965f 100644 --- a/vendor/github.com/prometheus/procfs/proc_statm.go +++ b/vendor/github.com/prometheus/procfs/proc_statm.go @@ -18,7 +18,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // - https://man7.org/linux/man-pages/man5/proc_pid_statm.5.html @@ -53,7 +53,7 @@ func (p Proc) NewStatm() (ProcStatm, error) { // Statm returns the current memory usage information of the process. func (p Proc) Statm() (ProcStatm, error) { - data, err := util.ReadFileNoStat(p.path("statm")) + data, err := parsers.ReadFileNoStat(p.path("statm")) if err != nil { return ProcStatm{}, err } diff --git a/vendor/github.com/prometheus/procfs/proc_status.go b/vendor/github.com/prometheus/procfs/proc_status.go index 12d65581c8..8c1652e172 100644 --- a/vendor/github.com/prometheus/procfs/proc_status.go +++ b/vendor/github.com/prometheus/procfs/proc_status.go @@ -20,7 +20,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // ProcStatus provides status information about the process, @@ -100,7 +100,7 @@ type ProcStatus struct { // NewStatus returns the current status information of the process. func (p Proc) NewStatus() (ProcStatus, error) { - data, err := util.ReadFileNoStat(p.path("status")) + data, err := parsers.ReadFileNoStat(p.path("status")) if err != nil { return ProcStatus{}, err } diff --git a/vendor/github.com/prometheus/procfs/proc_sys.go b/vendor/github.com/prometheus/procfs/proc_sys.go index 52658a4d52..c465b6be02 100644 --- a/vendor/github.com/prometheus/procfs/proc_sys.go +++ b/vendor/github.com/prometheus/procfs/proc_sys.go @@ -17,7 +17,7 @@ import ( "fmt" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) func sysctlToPath(sysctl string) string { @@ -25,7 +25,7 @@ func sysctlToPath(sysctl string) string { } func (fs FS) SysctlStrings(sysctl string) ([]string, error) { - value, err := util.SysReadFile(fs.proc.Path("sys", sysctlToPath(sysctl))) + value, err := parsers.SysReadFile(fs.proc.Path("sys", sysctlToPath(sysctl))) if err != nil { return nil, err } @@ -41,7 +41,7 @@ func (fs FS) SysctlInts(sysctl string) ([]int, error) { values := make([]int, len(fields)) for i, f := range fields { - vp := util.NewValueParser(f) + vp := parsers.NewValueParser(f) values[i] = vp.Int() if err := vp.Err(); err != nil { return nil, fmt.Errorf("%w: field %d in sysctl %s is not a valid int: %w", ErrFileParse, i, sysctl, err) diff --git a/vendor/github.com/prometheus/procfs/slab.go b/vendor/github.com/prometheus/procfs/slab.go index 32a04678ad..b78bac6344 100644 --- a/vendor/github.com/prometheus/procfs/slab.go +++ b/vendor/github.com/prometheus/procfs/slab.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) var ( @@ -142,7 +142,7 @@ func (fs FS) SlabInfo() (SlabInfo, error) { // TODO: Consider passing options to allow for parsing different // slabinfo versions. However, slabinfo 2.1 has been stable since // kernel 2.6.10 and later. - data, err := util.ReadFileNoStat(fs.proc.Path("slabinfo")) + data, err := parsers.ReadFileNoStat(fs.proc.Path("slabinfo")) if err != nil { return SlabInfo{}, err } diff --git a/vendor/github.com/prometheus/procfs/softirqs.go b/vendor/github.com/prometheus/procfs/softirqs.go index 47b73a7297..dcd5859335 100644 --- a/vendor/github.com/prometheus/procfs/softirqs.go +++ b/vendor/github.com/prometheus/procfs/softirqs.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // Softirqs represents the softirq statistics. @@ -40,7 +40,7 @@ type Softirqs struct { func (fs FS) Softirqs() (Softirqs, error) { fileName := fs.proc.Path("softirqs") - data, err := util.ReadFileNoStat(fileName) + data, err := parsers.ReadFileNoStat(fileName) if err != nil { return Softirqs{}, err } diff --git a/vendor/github.com/prometheus/procfs/stat.go b/vendor/github.com/prometheus/procfs/stat.go index 593ad0f62f..781bd28ada 100644 --- a/vendor/github.com/prometheus/procfs/stat.go +++ b/vendor/github.com/prometheus/procfs/stat.go @@ -23,7 +23,7 @@ import ( "strings" "github.com/prometheus/procfs/internal/fs" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // CPUStat shows how much time the cpu spend in various stages. @@ -167,7 +167,7 @@ func (fs FS) NewStat() (Stat, error) { // See: https://www.kernel.org/doc/Documentation/filesystems/proc.txt func (fs FS) Stat() (Stat, error) { fileName := fs.proc.Path("stat") - data, err := util.ReadFileNoStat(fileName) + data, err := parsers.ReadFileNoStat(fileName) if err != nil { return Stat{}, err } diff --git a/vendor/github.com/prometheus/procfs/swaps.go b/vendor/github.com/prometheus/procfs/swaps.go index ee17bf4888..8f9bbfb5c4 100644 --- a/vendor/github.com/prometheus/procfs/swaps.go +++ b/vendor/github.com/prometheus/procfs/swaps.go @@ -20,7 +20,7 @@ import ( "strconv" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // Swap represents an entry in /proc/swaps. @@ -34,7 +34,7 @@ type Swap struct { // Swaps returns a slice of all configured swap devices on the system. func (fs FS) Swaps() ([]*Swap, error) { - data, err := util.ReadFileNoStat(fs.proc.Path("swaps")) + data, err := parsers.ReadFileNoStat(fs.proc.Path("swaps")) if err != nil { return nil, err } diff --git a/vendor/github.com/prometheus/procfs/vm.go b/vendor/github.com/prometheus/procfs/vm.go index 52180c03e2..62725b4207 100644 --- a/vendor/github.com/prometheus/procfs/vm.go +++ b/vendor/github.com/prometheus/procfs/vm.go @@ -21,7 +21,7 @@ import ( "path/filepath" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // The VM interface is described at @@ -102,11 +102,11 @@ func (fs FS) VM() (*VM, error) { name := filepath.Join(path, f.Name()) // ignore errors on read, as there are some write only // in /proc/sys/vm - value, err := util.SysReadFile(name) + value, err := parsers.SysReadFile(name) if err != nil { continue } - vp := util.NewValueParser(value) + vp := parsers.NewValueParser(value) switch f.Name() { case "admin_reserve_kbytes": @@ -143,7 +143,7 @@ func (fs FS) VM() (*VM, error) { stringSlice := strings.Fields(value) pint64Slice := make([]*int64, 0, len(stringSlice)) for _, value := range stringSlice { - vp := util.NewValueParser(value) + vp := parsers.NewValueParser(value) pint64Slice = append(pint64Slice, vp.PInt64()) } vm.LowmemReserveRatio = pint64Slice diff --git a/vendor/github.com/prometheus/procfs/zoneinfo.go b/vendor/github.com/prometheus/procfs/zoneinfo.go index 63d1898bc8..71b3c2b653 100644 --- a/vendor/github.com/prometheus/procfs/zoneinfo.go +++ b/vendor/github.com/prometheus/procfs/zoneinfo.go @@ -22,7 +22,7 @@ import ( "regexp" "strings" - "github.com/prometheus/procfs/internal/util" + "github.com/prometheus/procfs/internal/parsers" ) // Zoneinfo holds info parsed from /proc/zoneinfo. @@ -103,7 +103,7 @@ func parseZoneinfo(zoneinfoData []byte) ([]Zoneinfo, error) { if len(parts) < 2 { continue } - vp := util.NewValueParser(parts[1]) + vp := parsers.NewValueParser(parts[1]) switch parts[0] { case "nr_free_pages": zoneinfoElement.NrFreePages = vp.PInt64() @@ -179,7 +179,7 @@ func parseZoneinfo(zoneinfoData []byte) ([]Zoneinfo, error) { protectionValues = strings.Replace(protectionValues, ")", "", 1) protectionValues = strings.TrimSpace(protectionValues) protectionStringMap := strings.Split(protectionValues, ", ") - val, err := util.ParsePInt64s(protectionStringMap) + val, err := parsers.ParsePInt64s(protectionStringMap) if err == nil { zoneinfoElement.Protection = val } diff --git a/vendor/github.com/sirupsen/logrus/CHANGELOG.md b/vendor/github.com/sirupsen/logrus/CHANGELOG.md index 3e6675633d..683cec9088 100644 --- a/vendor/github.com/sirupsen/logrus/CHANGELOG.md +++ b/vendor/github.com/sirupsen/logrus/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## 1.10.2 + +Changed: + + * Update `github.com/stretchr/testify` to v1.12.1, removing the legacy + `gopkg.in/yaml.v3` dependency. + ## 1.10.1 Fixes: diff --git a/vendor/github.com/uudashr/iface/unexported/unexported.go b/vendor/github.com/uudashr/iface/unexported/unexported.go index c933d1b763..5e0c5c745d 100644 --- a/vendor/github.com/uudashr/iface/unexported/unexported.go +++ b/vendor/github.com/uudashr/iface/unexported/unexported.go @@ -5,7 +5,6 @@ import ( "go/ast" "go/types" "os" - "strings" "github.com/uudashr/iface/internal/directive" "golang.org/x/tools/go/analysis" @@ -55,19 +54,7 @@ func (r *runner) run(pass *analysis.Pass) (any, error) { var recvName string if recv := funcDecl.Recv; recv != nil { - recvType := recv.List[0].Type - - if r.debug { - infoType := pass.TypesInfo.TypeOf(recvType) - fmt.Fprintf(os.Stderr, " recvType: %v infoType: %v reflectType: %T\n", recvType, infoType, recvType) - } - - inner := recvType - if star, ok := inner.(*ast.StarExpr); ok { - inner = star.X - } - - recvName = typeName(inner) + recvName = r.recvName(pass, recv.List[0].Type) } if !funcDecl.Name.IsExported() { @@ -121,62 +108,36 @@ func findIdent(expr ast.Expr) ast.Expr { case *ast.Ident, *ast.SelectorExpr: return e default: + // should not happen return nil } } } -// typeName reconstructs the type string as written in source from an AST expression. -func typeName(expr ast.Expr) string { - switch e := expr.(type) { - case *ast.ArrayType: - if e.Len == nil { - return "[]" + typeName(e.Elt) +func formatType(pass *analysis.Pass, expr ast.Expr, infoType types.Type) string { + qualifier := func(p *types.Package) string { + if p == pass.Pkg { + return "" } - return "[" + typeName(e.Len) + "]" + typeName(e.Elt) - case *ast.BasicLit: - return e.Value - case *ast.Ident: - return e.Name - case *ast.StarExpr: - return "*" + typeName(e.X) - case *ast.Ellipsis: - return "..." + typeName(e.Elt) - case *ast.ChanType: - switch e.Dir { - case ast.SEND: - return "chan<- " + typeName(e.Value) - case ast.RECV: - return "<-chan " + typeName(e.Value) - default: - return "chan " + typeName(e.Value) - } - case *ast.MapType: - return "map[" + typeName(e.Key) + "]" + typeName(e.Value) - case *ast.SelectorExpr: - return typeName(e.X) + "." + e.Sel.Name - case *ast.IndexExpr: - return typeName(e.X) + "[" + typeName(e.Index) + "]" - case *ast.IndexListExpr: - var b strings.Builder - b.WriteString(typeName(e.X)) - b.WriteByte('[') - - for i, idx := range e.Indices { - if i > 0 { - b.WriteString(", ") - } - - b.WriteString(typeName(idx)) - } + return p.Name() + } - b.WriteByte(']') + if ellipsis, ok := expr.(*ast.Ellipsis); ok { + elemType := pass.TypesInfo.TypeOf(ellipsis.Elt) - return b.String() - default: - return fmt.Sprintf("%T", expr) + return "..." + types.TypeString(elemType, qualifier) } + + return types.TypeString(infoType, qualifier) +} + +func funcKindName(funcDecl *ast.FuncDecl, recvName string) (kind, name string) { + if recvName != "" { + return "method", recvName + "." + funcDecl.Name.Name + } + + return "function", funcDecl.Name.Name } func (r *runner) checkType(pass *analysis.Pass, expr ast.Expr, funcDecl *ast.FuncDecl, recvName, role string) { @@ -230,20 +191,30 @@ func (r *runner) checkType(pass *analysis.Pass, expr ast.Expr, funcDecl *ast.Fun r.debugln(" unexported") - funcMethod := "function" - funcMethodName := funcDecl.Name.Name - - if recvName != "" { - funcMethod = "method" - funcMethodName = recvName + "." + funcDecl.Name.Name - } + kind, name := funcKindName(funcDecl, recvName) + typeStr := formatType(pass, expr, infoType) pass.Report(analysis.Diagnostic{ Pos: typ.Pos(), - Message: fmt.Sprintf("unexported interface '%s' used as %s in exported %s '%s'", typeName(expr), role, funcMethod, funcMethodName), + Message: fmt.Sprintf("unexported interface '%s' used as %s in exported %s '%s'", typeStr, role, kind, name), }) } +func (r *runner) recvName(pass *analysis.Pass, recvType ast.Expr) string { + inner := recvType + + if star, ok := inner.(*ast.StarExpr); ok { + inner = star.X + } + + infoType := pass.TypesInfo.TypeOf(inner) + if infoType == nil { + return "" + } + + return formatType(pass, inner, infoType) +} + func (r *runner) debugln(a ...any) { if r.debug { fmt.Fprintln(os.Stderr, a...) diff --git a/vendor/github.com/uudashr/iface/unused/unused.go b/vendor/github.com/uudashr/iface/unused/unused.go index 743e29425a..a6ffb0572a 100644 --- a/vendor/github.com/uudashr/iface/unused/unused.go +++ b/vendor/github.com/uudashr/iface/unused/unused.go @@ -4,6 +4,7 @@ import ( "fmt" "go/ast" "go/token" + "go/types" "os" "slices" "strings" @@ -35,8 +36,9 @@ func newAnalyzer() *analysis.Analyzer { } type ifaceEntry struct { - ts *ast.TypeSpec - decl *ast.GenDecl + ifaceName string + ts *ast.TypeSpec + decl *ast.GenDecl } type runner struct { @@ -62,7 +64,7 @@ func (r *runner) run(pass *analysis.Pass) (any, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) // Collect all interface type declarations - ifaces := make(map[string]ifaceEntry) + ifaces := make(map[*types.TypeName]ifaceEntry) nodeFilter := []ast.Node{ (*ast.GenDecl)(nil), @@ -105,14 +107,25 @@ func (r *runner) run(pass *analysis.Pass) (any, error) { continue } - ifaces[ts.Name.Name] = ifaceEntry{ts: ts, decl: decl} + obj := pass.TypesInfo.Defs[ts.Name] + + typeName, ok := obj.(*types.TypeName) + if !ok { + continue + } + + ifaces[typeName] = ifaceEntry{ + ifaceName: ts.Name.Name, + ts: ts, + decl: decl, + } } }) if r.debug { var ifaceNames []string - for name := range ifaces { - ifaceNames = append(ifaceNames, name) + for tn := range ifaces { + ifaceNames = append(ifaceNames, tn.Name()) } fmt.Fprintln(os.Stderr, "Declared interfaces:", ifaceNames) @@ -129,23 +142,28 @@ func (r *runner) run(pass *analysis.Pass) (any, error) { return } - entry, ok := ifaces[ident.Name] + obj := pass.TypesInfo.Uses[ident] + + typeName, ok := obj.(*types.TypeName) if !ok { return } - if entry.ts.Pos() == ident.Pos() { + entry, ok := ifaces[typeName] + if !ok { return } - delete(ifaces, ident.Name) + r.debugln(" used:", entry.ifaceName) + + delete(ifaces, typeName) }) if r.debug { fmt.Fprintf(os.Stderr, "Package %s %s\n", pass.Pkg.Path(), pass.Pkg.Name()) } - for name, entry := range ifaces { + for typeName, entry := range ifaces { ts := entry.ts decl := entry.decl @@ -166,7 +184,7 @@ func (r *runner) run(pass *analysis.Pass) (any, error) { end = ts.End() } - msg := fmt.Sprintf("interface '%s' is declared but not used within the package", name) + msg := fmt.Sprintf("interface '%s' is declared but not used within the package", typeName.Name()) pass.Report(analysis.Diagnostic{ Pos: ts.Pos(), Message: msg, diff --git a/vendor/github.com/uudashr/iface/unusedmethod/doc.go b/vendor/github.com/uudashr/iface/unusedmethod/doc.go index cef63a7f77..af353eb2a6 100644 --- a/vendor/github.com/uudashr/iface/unusedmethod/doc.go +++ b/vendor/github.com/uudashr/iface/unusedmethod/doc.go @@ -1,3 +1,8 @@ // Package unusedmethod defines an Analyzer that detects interface methods which // are never used anywhere in the same package where they are defined. +// +// A method is considered used only when it is invoked or referenced through a +// value of the interface type. Merely implementing the interface — for example, +// assigning a concrete type to the interface, or calling the method directly on +// the concrete type — does not count as a use. package unusedmethod diff --git a/vendor/github.com/uudashr/iface/unusedmethod/unusedmethod.go b/vendor/github.com/uudashr/iface/unusedmethod/unusedmethod.go index 2f671465c4..240ac9726d 100644 --- a/vendor/github.com/uudashr/iface/unusedmethod/unusedmethod.go +++ b/vendor/github.com/uudashr/iface/unusedmethod/unusedmethod.go @@ -22,7 +22,7 @@ func newAnalyzer() *analysis.Analyzer { analyzer := &analysis.Analyzer{ Name: "unusedmethod", - Doc: "Detects interface methods that are never used anywhere in the same package where they are defined.", + Doc: "Detects interface methods that are never used anywhere in the same package where they are defined. A method is considered used only when invoked or referenced through a value of the interface type; merely implementing the interface does not count as a use.", URL: "https://pkg.go.dev/github.com/uudashr/iface/unusedmethod", Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: r.run, diff --git a/vendor/github.com/vishvananda/netlink/xfrm_policy_linux.go b/vendor/github.com/vishvananda/netlink/xfrm_policy_linux.go index 2227d2dbfe..bf143a1b13 100644 --- a/vendor/github.com/vishvananda/netlink/xfrm_policy_linux.go +++ b/vendor/github.com/vishvananda/netlink/xfrm_policy_linux.go @@ -170,14 +170,7 @@ func (h *Handle) xfrmPolicyAddOrUpdate(policy *XfrmPolicy, nlProto int) error { userTmpl := nl.DeserializeXfrmUserTmpl(tmplData[start : start+nl.SizeofXfrmUserTmpl]) userTmpl.XfrmId.Daddr.FromIP(tmpl.Dst) userTmpl.Saddr.FromIP(tmpl.Src) - // A template with no destination takes the policy selector's family. The - // test is on LENGTH, not on nil: GetIPFamily answers FAMILY_V4 for any - // address of four bytes or fewer, so a non-nil zero-length net.IP would - // put AF_INET on an IPv6 policy, which is the case this fixes. - userTmpl.Family = msg.Sel.Family - if len(tmpl.Dst) > 0 { - userTmpl.Family = uint16(nl.GetIPFamily(tmpl.Dst)) - } + userTmpl.Family = uint16(nl.GetIPFamily(tmpl.Dst)) userTmpl.XfrmId.Proto = uint8(tmpl.Proto) userTmpl.XfrmId.Spi = nl.Swap32(uint32(tmpl.Spi)) userTmpl.Mode = uint8(tmpl.Mode) diff --git a/vendor/github.com/vishvananda/netlink/xfrm_state_linux.go b/vendor/github.com/vishvananda/netlink/xfrm_state_linux.go index 85035e9dbe..092ffe97b9 100644 --- a/vendor/github.com/vishvananda/netlink/xfrm_state_linux.go +++ b/vendor/github.com/vishvananda/netlink/xfrm_state_linux.go @@ -205,10 +205,6 @@ func writeMark(m *XfrmMark) []byte { return mark.Serialize() } -// xfrm_usersa_info carries a 32-bit legacy replay bitmap. Larger windows use -// XFRMA_REPLAY_ESN_VAL; without XFRM_STATE_ESN, Linux selects bitmap mode. -const xfrmLegacyReplayWindow = 32 - func writeReplayEsn(replayWindow int) []byte { replayEsn := &nl.XfrmReplayStateEsn{ OSeq: 0, @@ -274,14 +270,11 @@ func (h *Handle) xfrmStateAddOrUpdate(state *XfrmState, nlProto int) error { msg := xfrmUsersaInfoFromXfrmState(state) - useReplayESN := state.ESN || state.ReplayWindow > xfrmLegacyReplayWindow if state.ESN { if state.ReplayWindow == 0 { return fmt.Errorf("ESN flag set without ReplayWindow") } msg.Flags |= nl.XFRM_STATE_ESN - } - if useReplayESN { msg.ReplayWindow = 0 } @@ -314,7 +307,7 @@ func (h *Handle) xfrmStateAddOrUpdate(state *XfrmState, nlProto int) error { out := nl.NewRtAttr(nl.XFRMA_MARK, writeMark(state.Mark)) req.AddData(out) } - if useReplayESN { + if state.ESN { out := nl.NewRtAttr(nl.XFRMA_REPLAY_ESN_VAL, writeReplayEsn(state.ReplayWindow)) req.AddData(out) } @@ -516,7 +509,6 @@ func xfrmStateFromXfrmUsersaInfo(msg *nl.XfrmUsersaInfo) *XfrmState { state.Spi = int(nl.Swap32(msg.Id.Spi)) state.Reqid = int(msg.Reqid) state.ReplayWindow = int(msg.ReplayWindow) - state.ESN = msg.Flags&nl.XFRM_STATE_ESN != 0 lftToLimits(&msg.Lft, &state.Limits) curToStats(&msg.Curlft, &msg.Stats, &state.Statistics) state.Selector = &XfrmPolicy{ @@ -613,16 +605,6 @@ func parseXfrmState(m []byte, family int) (*XfrmState, error) { case nl.XFRMA_SA_PCPU: pcpuNum := native.Uint32(attr.Value) state.Pcpunum = &pcpuNum - case nl.XFRMA_REPLAY_ESN_VAL: - // xfrm_replay_state_esn is {bmp_len, oseq, seq, oseq_hi, seq_hi, - // replay_window} u32s then bmp[]. Read the window at its offset - // rather than casting the buffer to the Go struct: that struct - // carries a slice header for bmp, so a pointer conversion over a - // SizeofXfrmReplayStateEsn buffer would build a slice out of - // whatever follows the attribute. - if len(attr.Value) >= nl.SizeofXfrmReplayStateEsn { - state.ReplayWindow = int(native.Uint32(attr.Value[20:24])) - } case nl.XFRMA_REPLAY_VAL: if state.Replay == nil { state.Replay = new(XfrmReplayState) diff --git a/vendor/golang.org/x/tools/gopls/internal/analysis/fillswitch/fillswitch.go b/vendor/golang.org/x/tools/gopls/internal/analysis/fillswitch/fillswitch.go index f72efed5c0..7b1a7e8cbe 100644 --- a/vendor/golang.org/x/tools/gopls/internal/analysis/fillswitch/fillswitch.go +++ b/vendor/golang.org/x/tools/gopls/internal/analysis/fillswitch/fillswitch.go @@ -12,7 +12,6 @@ import ( "go/types" "golang.org/x/tools/go/analysis" - "golang.org/x/tools/internal/refactor" "golang.org/x/tools/internal/typesinternal" ) @@ -22,7 +21,6 @@ import ( // If either start or end is invalid, the entire file is inspected. func Diagnose(f *ast.File, start, end token.Pos, pkg *types.Package, info *types.Info) []analysis.Diagnostic { var diags []analysis.Diagnostic - qual := typesinternal.FileQualifier(f, pkg) ast.Inspect(f, func(n ast.Node) bool { if n == nil { return true // pop @@ -34,9 +32,9 @@ func Diagnose(f *ast.File, start, end token.Pos, pkg *types.Package, info *types var fix *analysis.SuggestedFix switch n := n.(type) { case *ast.SwitchStmt: - fix = suggestedFixSwitch(f, n, pkg, info, qual) + fix = suggestedFixSwitch(n, pkg, info) case *ast.TypeSwitchStmt: - fix = suggestedFixTypeSwitch(f, n, pkg, info, qual) + fix = suggestedFixTypeSwitch(n, pkg, info) } if fix != nil { diags = append(diags, analysis.Diagnostic{ @@ -52,7 +50,7 @@ func Diagnose(f *ast.File, start, end token.Pos, pkg *types.Package, info *types return diags } -func suggestedFixTypeSwitch(f *ast.File, stmt *ast.TypeSwitchStmt, pkg *types.Package, info *types.Info, qual types.Qualifier) *analysis.SuggestedFix { +func suggestedFixTypeSwitch(stmt *ast.TypeSwitchStmt, pkg *types.Package, info *types.Info) *analysis.SuggestedFix { if hasDefaultCase(stmt.Body) { return nil } @@ -105,10 +103,9 @@ func suggestedFixTypeSwitch(f *ast.File, stmt *ast.TypeSwitchStmt, pkg *types.Pa } if p := key.named.Obj().Pkg(); p != pkg { - if name := qual(p); name != "" { // not a dot import - buf.WriteString(name) - buf.WriteByte('.') - } + // TODO: use the correct package name when the import is renamed + buf.WriteString(p.Name()) + buf.WriteByte('.') } buf.WriteString(key.named.Obj().Name()) buf.WriteString(":\n") @@ -119,29 +116,26 @@ func suggestedFixTypeSwitch(f *ast.File, stmt *ast.TypeSwitchStmt, pkg *types.Pa return nil } - rBracePos := stmt.Body.Rbrace - var edits []analysis.TextEdit switch assign := stmt.Assign.(type) { case *ast.AssignStmt: - edits = addDefaultCase(f, info, &buf, namedType, assign.Lhs[0], rBracePos) + addDefaultCase(&buf, namedType, assign.Lhs[0]) case *ast.ExprStmt: if assert, ok := assign.X.(*ast.TypeAssertExpr); ok { - edits = addDefaultCase(f, info, &buf, namedType, assert.X, rBracePos) + addDefaultCase(&buf, namedType, assert.X) } } - edits = append(edits, analysis.TextEdit{ - Pos: rBracePos, - End: rBracePos, - NewText: buf.Bytes(), - }) return &analysis.SuggestedFix{ - Message: "Add cases for " + types.TypeString(namedType, qual), - TextEdits: edits, + Message: "Add cases for " + types.TypeString(namedType, typesinternal.NameRelativeTo(pkg)), + TextEdits: []analysis.TextEdit{{ + Pos: stmt.End() - token.Pos(len("}")), + End: stmt.End() - token.Pos(len("}")), + NewText: buf.Bytes(), + }}, } } -func suggestedFixSwitch(f *ast.File, stmt *ast.SwitchStmt, pkg *types.Package, info *types.Info, qual types.Qualifier) *analysis.SuggestedFix { +func suggestedFixSwitch(stmt *ast.SwitchStmt, pkg *types.Package, info *types.Info) *analysis.SuggestedFix { if hasDefaultCase(stmt.Body) { return nil } @@ -168,10 +162,8 @@ func suggestedFixSwitch(f *ast.File, stmt *ast.SwitchStmt, pkg *types.Package, i buf.WriteString("case ") if c.Pkg() != pkg { - if name := qual(c.Pkg()); name != "" { // not a dot import - buf.WriteString(name) - buf.WriteByte('.') - } + buf.WriteString(c.Pkg().Name()) + buf.WriteByte('.') } buf.WriteString(c.Name()) buf.WriteString(":\n") @@ -182,23 +174,19 @@ func suggestedFixSwitch(f *ast.File, stmt *ast.SwitchStmt, pkg *types.Package, i return nil } - rBracePos := stmt.Body.Rbrace - edits := addDefaultCase(f, info, &buf, namedType, stmt.Tag, rBracePos) - edits = append(edits, analysis.TextEdit{ - Pos: rBracePos, - End: rBracePos, - NewText: buf.Bytes(), - }) + addDefaultCase(&buf, namedType, stmt.Tag) return &analysis.SuggestedFix{ - Message: "Add cases for " + types.TypeString(namedType, qual), - TextEdits: edits, + Message: "Add cases for " + types.TypeString(namedType, typesinternal.NameRelativeTo(pkg)), + TextEdits: []analysis.TextEdit{{ + Pos: stmt.End() - token.Pos(len("}")), + End: stmt.End() - token.Pos(len("}")), + NewText: buf.Bytes(), + }}, } } -// addDefaultCase writes a default switch case to buf containing an -// "unexpected" panic message. It returns edits for any added imports. -func addDefaultCase(f *ast.File, info *types.Info, buf *bytes.Buffer, named *types.Named, expr ast.Expr, rBracePos token.Pos) (importEdits []analysis.TextEdit) { +func addDefaultCase(buf *bytes.Buffer, named *types.Named, expr ast.Expr) { var dottedBuf bytes.Buffer // writeDotted emits a dotted path a.b.c. var writeDotted func(e ast.Expr) bool @@ -223,15 +211,11 @@ func addDefaultCase(f *ast.File, info *types.Info, buf *bytes.Buffer, named *typ if writeDotted(expr) { // Switch tag expression is a dotted path. // It is safe to re-evaluate it in the default case. - var fmtPrefix string - fmtPrefix, importEdits = refactor.AddImport(info, f, "fmt", "fmt", "Sprintf", rBracePos) format := fmt.Sprintf("unexpected %s: %%#v", typeName) - fmt.Fprintf(buf, "\t\tpanic(%sSprintf(%q, %s))\n\t", fmtPrefix, format, dottedBuf.String()) - return importEdits + fmt.Fprintf(buf, "\t\tpanic(fmt.Sprintf(%q, %s))\n\t", format, dottedBuf.String()) } else { // Emit simpler message, without re-evaluating tag expression. fmt.Fprintf(buf, "\t\tpanic(%q)\n\t", "unexpected "+typeName) - return nil } } diff --git a/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/conv.go b/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/conv.go deleted file mode 100644 index c3b1b9b021..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/conv.go +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright 2026 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 ptrtoerror - -import ( - "go/ast" - "go/types" - "iter" - - "golang.org/x/tools/go/ast/inspector" -) - -// A conversion represents a syntax node at which an assignment or explicit -// conversion occurs, along with the source and destination types. -type conversion struct { - tLHS, tRHS types.Type - expr ast.Expr -} - -// conversions returns an iterator over all (LHS, RHS) assignment and -// conversion pairs in the package, where LHS is the destination type -// (types.Type) and RHS is the expression (ast.Expr). Some of these -// may involve a widening. -// -// TODO(adonovan): eliminate when https://go.dev/issue/70638 is done. -func conversions(root inspector.Cursor, info *types.Info) iter.Seq[conversion] { - return func(yield func(conversion) bool) { - // nodes where assignability conversions occur - nodeFilter := []ast.Node{ - (*ast.AssignStmt)(nil), - (*ast.ValueSpec)(nil), - (*ast.CallExpr)(nil), - (*ast.ReturnStmt)(nil), - (*ast.CompositeLit)(nil), - (*ast.SendStmt)(nil), - (*ast.TypeAssertExpr)(nil), - (*ast.TypeSwitchStmt)(nil), - } - - for c := range root.Preorder(nodeFilter...) { - switch n := c.Node().(type) { - case *ast.AssignStmt: - if len(n.Lhs) == len(n.Rhs) { - // simple or tuple assignment - for i, lhs := range n.Lhs { - if tLHS := info.TypeOf(lhs); tLHS != nil && - !yield(conversion{tLHS, info.TypeOf(n.Rhs[i]), n.Rhs[i]}) { - return - } - } - } else if len(n.Lhs) > 1 && len(n.Rhs) == 1 { - // spread assignment - if tuple, ok := info.TypeOf(n.Rhs[0]).(*types.Tuple); ok && tuple.Len() == len(n.Lhs) { - for i, lhs := range n.Lhs { - if tLHS := info.TypeOf(lhs); tLHS != nil && - !yield(conversion{info.TypeOf(lhs), tuple.At(i).Type(), n.Rhs[0]}) { - return - } - } - } - } - case *ast.ValueSpec: - if len(n.Values) > 0 { - if len(n.Names) == len(n.Values) { - // simple or tuple initialization - for i := range n.Names { - if obj := info.ObjectOf(n.Names[i]); obj != nil { - if !yield(conversion{obj.Type(), info.TypeOf(n.Values[i]), n.Values[i]}) { - return - } - } - } - } else if len(n.Names) > 1 && len(n.Values) == 1 { - // spread initialization - if tuple, ok := info.TypeOf(n.Values[0]).(*types.Tuple); ok && tuple.Len() == len(n.Names) { - for i := range n.Names { - if obj := info.ObjectOf(n.Names[i]); obj != nil { - if !yield(conversion{obj.Type(), tuple.At(i).Type(), n.Values[0]}) { - return - } - } - } - } - } - } - case *ast.CallExpr: - tv := info.Types[n.Fun] - - // explicit conversion? - if tv.IsType() { - if !yield(conversion{tv.Type, info.TypeOf(n.Args[0]), n.Args[0]}) { - return - } - break - } - - sig, ok := tv.Type.Underlying().(*types.Signature) - if !ok { - break - } - - // spread call? - if len(n.Args) == 1 && sig.Params().Len() > 1 { - if tuple, ok := info.TypeOf(n.Args[0]).(*types.Tuple); ok { - for i := 0; i < sig.Params().Len() && i < tuple.Len(); i++ { - if !yield(conversion{sig.Params().At(i).Type(), tuple.At(i).Type(), n.Args[0]}) { - return - } - } - } - break - } - - // argument -> parameter assignment - last := sig.Params().Len() - 1 - for i, arg := range n.Args { - if sig.Variadic() && i >= last { - // variadic callee - if slice, ok := sig.Params().At(last).Type().(*types.Slice); ok { - var t types.Type = slice // f(args...) call of func(...T) - if !n.Ellipsis.IsValid() { - t = slice.Elem() // f(a, b, c) call of func(...T) - } - if !yield(conversion{t, info.TypeOf(arg), arg}) { - return - } - } - } else { - if !yield(conversion{sig.Params().At(i).Type(), info.TypeOf(arg), arg}) { - return - } - } - } - - case *ast.ReturnStmt: - // Handle return statements by matching results against enclosing function signatures. - var sig *types.Signature - for anc := range c.Enclosing((*ast.FuncDecl)(nil), (*ast.FuncLit)(nil)) { - if fd, ok := anc.Node().(*ast.FuncDecl); ok { - if obj := info.Defs[fd.Name]; obj != nil { - sig = obj.Type().Underlying().(*types.Signature) - } - break - } - if fl, ok := anc.Node().(*ast.FuncLit); ok { - sig = info.TypeOf(fl).Underlying().(*types.Signature) - break - } - } - if sig == nil { - break // can't happen? - } - - // spread return? - if len(n.Results) == 1 && sig.Results().Len() > 1 { - if tuple, ok := info.TypeOf(n.Results[0]).(*types.Tuple); ok { - for i := 0; i < sig.Results().Len() && i < tuple.Len(); i++ { - if !yield(conversion{sig.Results().At(i).Type(), tuple.At(i).Type(), n.Results[0]}) { - return - } - } - } - break - } - - // simple or tuple return - if len(n.Results) == sig.Results().Len() { - for i, res := range n.Results { - if !yield(conversion{sig.Results().At(i).Type(), info.TypeOf(res), res}) { - return - } - } - } - - case *ast.CompositeLit: - // element assignments in slice, array, map, and struct literals. - switch t := info.TypeOf(n).Underlying().(type) { - case *types.Slice, *types.Array: - for _, elt := range n.Elts { - if kv, ok := elt.(*ast.KeyValueExpr); ok { - elt = kv.Value - } - if !yield(conversion{t.(interface{ Elem() types.Type }).Elem(), info.TypeOf(elt), elt}) { - return - } - } - - case *types.Map: - for _, elt := range n.Elts { - kv := elt.(*ast.KeyValueExpr) - if !yield(conversion{t.Key(), info.TypeOf(kv.Key), kv.Key}) || - !yield(conversion{t.Elem(), info.TypeOf(kv.Value), kv.Value}) { - return - } - } - - case *types.Struct: - for i, elt := range n.Elts { - if kv, ok := elt.(*ast.KeyValueExpr); ok { - if id, ok := kv.Key.(*ast.Ident); ok { - var fieldType types.Type - if obj := info.Uses[id]; obj != nil { - fieldType = obj.Type() - } else { - for field := range t.Fields() { - if field.Name() == id.Name { - fieldType = field.Type() - break - } - } - } - if !yield(conversion{fieldType, info.TypeOf(kv.Value), kv.Value}) { - return - } - } - } else if i < t.NumFields() { - if !yield(conversion{t.Field(i).Type(), info.TypeOf(elt), elt}) { - return - } - } - } - } - - case *ast.SendStmt: - // channel send - if chanType, ok := info.TypeOf(n.Chan).Underlying().(*types.Chan); ok { - if !yield(conversion{chanType.Elem(), info.TypeOf(n.Value), n.Value}) { - return - } - } - - case *ast.TypeAssertExpr: - // I(x).(E) acts like a pseudoconversion from E to E. - if n.Type != nil && // (not beneath type switch) - !yield(conversion{info.TypeOf(n.X), info.TypeOf(n.Type), n.Type}) { - return - } - - case *ast.TypeSwitchStmt: - // switch I(x).(type) { case E: } depends on E being assignable to I. - // Report the (pseudo)conversion of type (not term) E to I. - var assert *ast.TypeAssertExpr - switch assign := n.Assign.(type) { - case *ast.ExprStmt: - assert = assign.X.(*ast.TypeAssertExpr) - case *ast.AssignStmt: - assert = assign.Rhs[0].(*ast.TypeAssertExpr) - } - for _, cc := range n.Body.List { - for _, typ := range cc.(*ast.CaseClause).List { - if !yield(conversion{info.TypeOf(assert.X), info.TypeOf(typ), typ}) { - return - } - } - } - } - } - - // Yield conversions from type parameter instantiations - // e.g. errors.AsType[*E](err) - for id, inst := range info.Instances { - t := info.ObjectOf(id).Type() - type hasTypeParams interface{ TypeParams() *types.TypeParamList } // = Signature, Named, Alias - if t, ok := t.(hasTypeParams); ok { - tparams := t.TypeParams() - for i := 0; i < tparams.Len(); i++ { - tparam := tparams.At(i) - targ := inst.TypeArgs.At(i) - if !yield(conversion{tparam.Constraint(), targ, id}) { - return - } - } - } - } - } -} diff --git a/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/doc.go b/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/doc.go deleted file mode 100644 index 85952f36b2..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/doc.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2026 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 ptrtoerror defines an analyzer that detects inconsistent -// conversions of concrete error types to the error interface. -// -// # Analyzer ptrtoerror -// -// ptrtoerror: detect inconsistent conversions of concrete types to error -// -// The ptrtoerror analyzer detects when a concrete type E is converted -// to the error interface inconsistently, both as a value of type E -// and as a pointer of type *E. Such inconsistency defeats attempts by -// client code to test for specific error types using type assertions -// or library functions such as [errors.As] and [errors.Is]. -// -// The analyzer also detects when both E and *E implement error but -// neither of those types is converted to error within the defining -// package, leaving the intended error form (E or *E) ambiguous. This -// diagnostic offers two alternative fixes to add declarations that -// make the intent explicit. -// -// # Examples -// -// In this example, both MyError and *MyError implement error, and -// both types are used as errors: -// -// type MyError struct{ Msg string } // error: type MyError is converted to error both as a value and as a pointer -// -// func (MyError) Error() string { return "error" } -// -// func foo() error { return MyError{"foo"} } // "conversion of MyError (value) to error" here -// func bar() error { return &MyError{"bar"} } // "conversion of *MyError (pointer) to error" here -// -// To fix the issue, adopt a single conversion form consistently: -// -// func foo() error { return &MyError{"foo"} } // pointer conversion (*E) -// func bar() error { return &MyError{"bar"} } // pointer conversion (*E) -// -// In this example, again both CustomError and *CustomError implement -// error, but neither type is used as an error: -// -// type CustomError struct{ error } // "both CustomError and *CustomError implement the error interface, making the intent ambiguous" -// -// func (e *CustomError) Unwrap() error ( return e.error } -// -// To resolve the ambiguity, apply one of the two suggested fixes to -// add a declaration that makes the intent explicit: -// -// var _ error = *new(CustomError) // (declares that CustomError is the intended form) -// -// or: -// -// var _ error = (*CustomError)(nil) // (declares that *CustomError is the intended form) -// -// In this example, the presence of the Unwrap method is a clue that -// *CustomError is the preferred form. An alternative fix would be to -// declare an explicit Error method so that CustomError is no longer -// assignable to error: -// -// func (err *CustomError) Error() string ( return err.error.Error() } -package ptrtoerror diff --git a/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/ptrtoerror.go b/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/ptrtoerror.go deleted file mode 100644 index 9dc7ba83cf..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/analysis/ptrtoerror/ptrtoerror.go +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2026 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 ptrtoerror - -import ( - _ "embed" - "fmt" - "go/ast" - "go/token" - "go/types" - "path/filepath" - - "golang.org/x/tools/go/analysis" - "golang.org/x/tools/go/analysis/passes/inspect" - "golang.org/x/tools/go/ast/inspector" - "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/internal/analysis/analyzerutil" -) - -//go:embed doc.go -var doc string - -// Analyzer detects inconsistent conversions of concrete types to error. -var Analyzer = &analysis.Analyzer{ - Name: "ptrtoerror", - Doc: analyzerutil.MustExtractDoc(doc, "ptrtoerror"), - URL: "https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/ptrtoerror", - Requires: []*analysis.Analyzer{inspect.Analyzer}, - FactTypes: []analysis.Fact{(*isErrorFact)(nil)}, - Run: run, -} - -// run executes the ptrtoerror analysis pass. -func run(pass *analysis.Pass) (any, error) { - var ( - inspect = pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) - info = pass.TypesInfo - ) - - type localType struct{ val, ptr []conversion } // all conversions from local type E, *E to error - var ( - localTypes = make(map[*types.TypeName]*localType) // error conversion info about types from this package - importedTypes = make(map[*types.TypeName]*isErrorFact) // error conversion info about imported types (nil => unknown) - ) - for conv := range conversions(inspect.Root(), info) { - if conv.tLHS == nil { - panic("nil LHS type") - } - if conv.tRHS == nil { - panic("nil RHS type") - } - if conv.expr == nil { - panic("nil Expr") - } - - if !types.IsInterface(conv.tLHS) || - !types.AssignableTo(conv.tLHS, builtinError.Type()) { - continue - } - - // E or *E? - t := conv.tRHS - ptr, isPtr := types.Unalias(t).(*types.Pointer) - if isPtr { - t = ptr.Elem() - } - named, ok := types.Unalias(t).(*types.Named) - if !ok || types.IsInterface(named) { - continue // not a concrete named type - } - tname := named.Obj() - - // local type? - if tname.Pkg() == pass.Pkg { - ltinfo, ok := localTypes[tname] - if !ok { - ltinfo = new(localType) - localTypes[tname] = ltinfo - } - // Save it for the second pass. - list := cond(isPtr, <info.ptr, <info.val) - *list = append(*list, conv) - continue - } - - // imported type - f, ok := importedTypes[tname] - if !ok { - var fact isErrorFact - if pass.ImportObjectFact(tname, &fact) { - f = &fact - } - importedTypes[tname] = f // memoize even if nil - } - if f != nil && f.Pointer != isPtr { - var message string - if isPtr { - message = fmt.Sprintf("conversion of *%s to error, but package %q uses %s (sans pointer) as an error (e.g. at %s)", - types.TypeString(named, (*types.Package).Name), - tname.Pkg().Path(), - tname.Name(), - f.Where) - } else { - message = fmt.Sprintf("conversion of %s to error, but package %q uses pointer *%s as an error (e.g. at %s)", - types.TypeString(named, (*types.Package).Name), - tname.Pkg().Path(), - tname.Name(), - f.Where) - } - pass.Report(analysis.Diagnostic{ - Pos: conv.expr.Pos(), - End: conv.expr.End(), - Message: message, - }) - } - } - - // Second pass over conversions of local types. - for tname, ltinfo := range localTypes { - isPtr := ltinfo.ptr != nil - - // If used as both E and *E, - // report all conversions as ambiguous. - if isPtr && ltinfo.val != nil { - conflicts := func(convs []conversion, other conversion, otherKind string) { - for _, conv := range convs { - pass.Report(analysis.Diagnostic{ - Pos: conv.expr.Pos(), - End: conv.expr.End(), - Message: fmt.Sprintf("%s is converted to error both as a value and as a pointer", tname.Name()), - Related: []analysis.RelatedInformation{{ - Pos: other.expr.Pos(), - End: other.expr.End(), - Message: fmt.Sprintf("converted as a %s here", otherKind), - }}, - }) - } - } - conflicts(ltinfo.ptr, ltinfo.val[0], "value") - conflicts(ltinfo.val, ltinfo.ptr[0], "pointer") - continue - } - - // E or *E is used consistently. - // Export a fact. - if tname.Exported() { - var first conversion - if isPtr { - first = ltinfo.ptr[0] - } else { - first = ltinfo.val[0] - } - posn := safetoken.StartPosition(pass.Fset, first.expr.Pos()) - where := fmt.Sprintf("%s:%d:%d", filepath.Base(posn.Filename), posn.Line, posn.Column) - pass.ExportObjectFact(tname, &isErrorFact{ - Pointer: isPtr, - Where: where, - }) - } - } - - // Report a diagnostic for each local named type E such that E - // and *E implement error yet neither type is converted to error - // (which would indicate intent). - for curTypeSpec := range inspect.Root().Preorder((*ast.TypeSpec)(nil)) { - tspec := curTypeSpec.Node().(*ast.TypeSpec) - if tspec.Assign.IsValid() { - continue // ignore aliases (need more thorough treatment) - } - tname := info.Defs[tspec.Name].(*types.TypeName) - if _, ok := localTypes[tname]; ok { - continue // E or *E was converted to error - } - if types.IsInterface(tname.Type()) || !types.AssignableTo(tname.Type(), builtinError.Type()) { - continue - } - - // Both E and (implicitly) *E implement error - // but neither conversion was used in this package. - - // Suggest a fix to insert 'var _ error = ...' after - // the enclosing type decl to declare the intent. - // No fix is offered for a generic type, as its type parameters - // are not in scope in a package-level declaration. - var fixes []analysis.SuggestedFix - if curIdent, ok := inspect.Root().FindByPos(tname.Pos(), tname.Pos()); ok && tspec.TypeParams == nil { - for curDecl := range curIdent.Enclosing((*ast.GenDecl)(nil)) { - pos := curDecl.Node().End() - fixes = []analysis.SuggestedFix{ - { - Message: fmt.Sprintf(`Declare that %s implements error`, tname.Name()), - TextEdits: []analysis.TextEdit{{ - Pos: pos, - End: pos, - NewText: fmt.Appendf(nil, "\n\nvar _ error = *new(%s)\n", tname.Name()), - }}, - }, - { - Message: fmt.Sprintf(`Declare that *%s implements error`, tname.Name()), - TextEdits: []analysis.TextEdit{{ - Pos: pos, - End: pos, - NewText: fmt.Appendf(nil, "\n\nvar _ error = (*%s)(nil)\n", tname.Name()), - }}, - }, - } - break - } - } - pass.Report(analysis.Diagnostic{ - Pos: tname.Pos(), - End: tname.Pos() + token.Pos(len(tname.Name())), - Message: fmt.Sprintf("both %[1]s and *%[1]s implement the error interface, making the intent ambiguous", tname.Name()), - SuggestedFixes: fixes, - }) - } - - return nil, nil -} - -// An isErrorFact associated with an exported type E indicates that -// either E or *E (depending on the value of Pointer) implements error. -type isErrorFact struct { - Pointer bool // the preferred error type is *E, not E - Where string // a hint to where the fact was established of the form "foo.go:123:45" -} - -func (f *isErrorFact) AFact() {} -func (f *isErrorFact) String() string { return cond(f.Pointer, "*E", "E") } - -// -- helpers -- - -var builtinError = types.Universe.Lookup("error") - -func cond[T any](cond bool, t, f T) T { - if cond { - return t - } else { - return f - } -} diff --git a/vendor/golang.org/x/tools/gopls/internal/analysis/simplifycompositelit/simplifycompositelit.go b/vendor/golang.org/x/tools/gopls/internal/analysis/simplifycompositelit/simplifycompositelit.go index 52d87ea425..db5012a1a1 100644 --- a/vendor/golang.org/x/tools/gopls/internal/analysis/simplifycompositelit/simplifycompositelit.go +++ b/vendor/golang.org/x/tools/gopls/internal/analysis/simplifycompositelit/simplifycompositelit.go @@ -8,17 +8,18 @@ package simplifycompositelit import ( + "bytes" _ "embed" "fmt" "go/ast" + "go/printer" "go/token" - "go/types" + "reflect" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" "golang.org/x/tools/internal/analysis/analyzerutil" - "golang.org/x/tools/internal/astutil" ) //go:embed doc.go @@ -42,113 +43,163 @@ func run(pass *analysis.Pass) (any, error) { } inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) - - // Find each CompositeLit with an explicit type. - // Then attempt to simplify each element that is - // itself a CompositeLit with an explicit type. - // - // TODO(adonovan): note that go1.28 will permit types to be - // omitted much more generally, so instead of starting with - // the "outer" CompositeLit, we'll need to look for "inner" - // literals appearing in a context that determines their type - // (assuming we want to take a maximal approach to - // simplification). We should also support named and alias - // types more thoroughly. - - for curLit := range inspect.Root().Preorder((*ast.CompositeLit)(nil)) { - lit := curLit.Node().(*ast.CompositeLit) - - // Skip generated code. - if _, ok := generated[pass.Fset.File(lit.Pos())]; ok { - continue + nodeFilter := []ast.Node{(*ast.CompositeLit)(nil)} + inspect.Preorder(nodeFilter, func(n ast.Node) { + if _, ok := generated[pass.Fset.File(n.Pos())]; ok { + return // skip checking if it's generated code } - var ( - kind string - keyType, eltType ast.Expr - ) - switch typ := lit.Type.(type) { + expr := n.(*ast.CompositeLit) + + outer := expr + var keyType, eltType ast.Expr + switch typ := outer.Type.(type) { case *ast.ArrayType: eltType = typ.Elt - if typ.Len != nil { - kind = "array" - } else { - kind = "slice" - } case *ast.MapType: keyType = typ.Key eltType = typ.Value - kind = "map" - default: - // e.g. struct, named, or nil (no explicit type) - continue } - for _, elt := range lit.Elts { - if kve, ok := elt.(*ast.KeyValueExpr); ok { - if keyType != nil { // map - simplifyLiteral(pass, keyType, kve.Key, kind) + if eltType == nil { + return + } + var ktyp reflect.Value + if keyType != nil { + ktyp = reflect.ValueOf(keyType) + } + typ := reflect.ValueOf(eltType) + for _, x := range outer.Elts { + // look at value of indexed/named elements + if t, ok := x.(*ast.KeyValueExpr); ok { + if keyType != nil { + simplifyLiteral(pass, ktyp, keyType, t.Key) } - elt = kve.Value + x = t.Value } - simplifyLiteral(pass, eltType, elt, kind) + simplifyLiteral(pass, typ, eltType, x) } - } + }) return nil, nil } -// simplifyLiteral reports a diagnostic if expr's is a T{...} or -// &T{...} literal whose type is identical to want and therefore -// redundant. -func simplifyLiteral(pass *analysis.Pass, want, expr ast.Expr, kind string) { - info := pass.TypesInfo - - report := func(ampPos token.Pos, innerType ast.Expr) { - var ( - start = innerType.Pos() - end = innerType.End() - amp string - edits []analysis.TextEdit - ) - if ampPos.IsValid() { - amp = "&" - edits = append(edits, analysis.TextEdit{ - Pos: ampPos, - End: ampPos + token.Pos(len("&")), - }) - start = ampPos +func simplifyLiteral(pass *analysis.Pass, typ reflect.Value, astType, x ast.Expr) { + // if the element is a composite literal and its literal type + // matches the outer literal's element type exactly, the inner + // literal type may be omitted + if inner, ok := x.(*ast.CompositeLit); ok && match(typ, reflect.ValueOf(inner.Type)) { + var b bytes.Buffer + printer.Fprint(&b, pass.Fset, inner.Type) // ignore error + createDiagnostic(pass, inner.Type.Pos(), inner.Type.End(), b.String()) + } + // if the outer literal's element type is a pointer type *T + // and the element is & of a composite literal of type T, + // the inner &T may be omitted. + if ptr, ok := astType.(*ast.StarExpr); ok { + if addr, ok := x.(*ast.UnaryExpr); ok && addr.Op == token.AND { + if inner, ok := addr.X.(*ast.CompositeLit); ok { + if match(reflect.ValueOf(ptr.X), reflect.ValueOf(inner.Type)) { + var b bytes.Buffer + printer.Fprint(&b, pass.Fset, inner.Type) // ignore error + // Account for the & by subtracting 1 from typ.Pos(). + createDiagnostic(pass, inner.Type.Pos()-1, inner.Type.End(), "&"+b.String()) + } + } } - edits = append(edits, analysis.TextEdit{Pos: innerType.Pos(), End: end}) - pass.Report(analysis.Diagnostic{ - Pos: start, - End: end, - Message: fmt.Sprintf("redundant type in %s literal", kind), - SuggestedFixes: []analysis.SuggestedFix{{ - Message: fmt.Sprintf("Remove '%s%s'", amp, astutil.Format(pass.Fset, innerType)), - TextEdits: edits, + } +} + +func createDiagnostic(pass *analysis.Pass, start, end token.Pos, typ string) { + pass.Report(analysis.Diagnostic{ + Pos: start, + End: end, + Message: "redundant type from array, slice, or map composite literal", + SuggestedFixes: []analysis.SuggestedFix{{ + Message: fmt.Sprintf("Remove '%s'", typ), + TextEdits: []analysis.TextEdit{{ + Pos: start, + End: end, + NewText: []byte{}, }}, - }) + }}, + }) +} + +// match reports whether pattern matches val, +// recording wildcard submatches in m. +// If m == nil, match checks whether pattern == val. +// from https://github.com/golang/go/blob/26154f31ad6c801d8bad5ef58df1e9263c6beec7/src/cmd/gofmt/rewrite.go#L160 +func match(pattern, val reflect.Value) bool { + // Otherwise, pattern and val must match recursively. + if !pattern.IsValid() || !val.IsValid() { + return !pattern.IsValid() && !val.IsValid() + } + if pattern.Type() != val.Type() { + return false } - // If the element is a composite literal whose explicit type - // is identical to the outer literal's element type, - // the inner literal's type may be omitted - if inner, ok := expr.(*ast.CompositeLit); ok && - inner.Type != nil && - types.Identical(info.TypeOf(want), info.TypeOf(inner.Type)) { - report(token.NoPos, inner.Type) + // Special cases. + switch pattern.Type() { + case identType: + // For identifiers, only the names need to match + // (and none of the other *ast.Object information). + // This is a common case, handle it all here instead + // of recursing down any further via reflection. + p := pattern.Interface().(*ast.Ident) + v := val.Interface().(*ast.Ident) + return p == nil && v == nil || p != nil && v != nil && p.Name == v.Name + case objectPtrType, positionType: + // object pointers and token positions always match + return true + case callExprType: + // For calls, the Ellipsis fields (token.Position) must + // match since that is how f(x) and f(x...) are different. + // Check them here but fall through for the remaining fields. + p := pattern.Interface().(*ast.CallExpr) + v := val.Interface().(*ast.CallExpr) + if p.Ellipsis.IsValid() != v.Ellipsis.IsValid() { + return false + } } - // if the outer literal's element type is a pointer type *T - // and the element is & of a composite literal of type T, - // the inner &T may be omitted. - if star, ok := want.(*ast.StarExpr); ok { - if addr, ok := expr.(*ast.UnaryExpr); ok && addr.Op == token.AND { - if inner, ok := addr.X.(*ast.CompositeLit); ok && - inner.Type != nil && - types.Identical(info.TypeOf(star.X), info.TypeOf(inner.Type)) { - report(addr.OpPos, inner.Type) + p := reflect.Indirect(pattern) + v := reflect.Indirect(val) + if !p.IsValid() || !v.IsValid() { + return !p.IsValid() && !v.IsValid() + } + + switch p.Kind() { + case reflect.Slice: + if p.Len() != v.Len() { + return false + } + for i := 0; i < p.Len(); i++ { + if !match(p.Index(i), v.Index(i)) { + return false + } + } + return true + + case reflect.Struct: + for i := 0; i < p.NumField(); i++ { + if !match(p.Field(i), v.Field(i)) { + return false } } + return true + + case reflect.Interface: + return match(p.Elem(), v.Elem()) } + + // Handle token integers, etc. + return p.Interface() == v.Interface() } + +// Values/types for special cases. +var ( + identType = reflect.TypeFor[*ast.Ident]() + objectPtrType = reflect.TypeFor[*ast.Object]() + positionType = reflect.TypeFor[token.Pos]() + callExprType = reflect.TypeFor[*ast.CallExpr]() +) diff --git a/vendor/golang.org/x/tools/gopls/internal/analysis/unusedfunc/unusedfunc.go b/vendor/golang.org/x/tools/gopls/internal/analysis/unusedfunc/unusedfunc.go index 7dcf1dbf47..48380c0773 100644 --- a/vendor/golang.org/x/tools/gopls/internal/analysis/unusedfunc/unusedfunc.go +++ b/vendor/golang.org/x/tools/gopls/internal/analysis/unusedfunc/unusedfunc.go @@ -19,8 +19,8 @@ import ( "golang.org/x/tools/internal/analysis/analyzerutil" typeindexanalyzer "golang.org/x/tools/internal/analysis/typeindex" "golang.org/x/tools/internal/astutil" + "golang.org/x/tools/internal/packagepath" "golang.org/x/tools/internal/refactor" - "golang.org/x/tools/internal/stdlib" "golang.org/x/tools/internal/typesinternal/typeindex" ) @@ -74,7 +74,7 @@ var Analyzer = &analysis.Analyzer{ func run(pass *analysis.Pass) (any, error) { // The standard library makes heavy use of intrinsics, linknames, etc, // that confuse this algorithm; so skip it (#74130). - if stdlib.HasPackage(pass.Pkg.Path()) { + if packagepath.IsStdPackage(pass.Pkg.Path()) { return nil, nil } diff --git a/vendor/golang.org/x/tools/gopls/internal/analysis/unusedparams/unusedparams.go b/vendor/golang.org/x/tools/gopls/internal/analysis/unusedparams/unusedparams.go index ca6a055774..5af2fa7b7f 100644 --- a/vendor/golang.org/x/tools/gopls/internal/analysis/unusedparams/unusedparams.go +++ b/vendor/golang.org/x/tools/gopls/internal/analysis/unusedparams/unusedparams.go @@ -14,9 +14,9 @@ import ( "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/edge" "golang.org/x/tools/go/ast/inspector" + "golang.org/x/tools/gopls/internal/util/moreslices" "golang.org/x/tools/internal/analysis/analyzerutil" "golang.org/x/tools/internal/astutil" - "golang.org/x/tools/internal/moreslices" "golang.org/x/tools/internal/typesinternal" ) diff --git a/vendor/golang.org/x/tools/gopls/internal/analysis/yield/yield.go b/vendor/golang.org/x/tools/gopls/internal/analysis/yield/yield.go index a8b5fbb99f..90300e51ee 100644 --- a/vendor/golang.org/x/tools/gopls/internal/analysis/yield/yield.go +++ b/vendor/golang.org/x/tools/gopls/internal/analysis/yield/yield.go @@ -35,10 +35,10 @@ import ( "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" "golang.org/x/tools/go/ssa" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/gopls/internal/util/safetoken" "golang.org/x/tools/internal/analysis/analyzerutil" "golang.org/x/tools/internal/flow" - "golang.org/x/tools/internal/moremaps" "golang.org/x/tools/internal/typesinternal" ) @@ -584,8 +584,8 @@ func (b *bitset) cmp(other *bitset) int { if d := cmp.Compare(len(b.limbs), len(other.limbs)); d != 0 { return d } - for i, v := range slices.Backward(b.limbs) { - if d := cmp.Compare(v, other.limbs[i]); d != 0 { + for i := len(b.limbs) - 1; i >= 0; i-- { + if d := cmp.Compare(b.limbs[i], other.limbs[i]); d != 0 { return d } } diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/analysis.go b/vendor/golang.org/x/tools/gopls/internal/cache/analysis.go index 8347b39609..f0270bed71 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/analysis.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/analysis.go @@ -7,6 +7,7 @@ package cache // This file defines gopls' driver for modular static analysis (go/analysis). import ( + "bytes" "context" "crypto/sha256" "encoding/gob" @@ -41,13 +42,13 @@ import ( "golang.org/x/tools/gopls/internal/settings" "golang.org/x/tools/gopls/internal/util/bug" "golang.org/x/tools/gopls/internal/util/frob" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/gopls/internal/util/persistent" "golang.org/x/tools/gopls/internal/util/safetoken" "golang.org/x/tools/internal/analysis/driverutil" "golang.org/x/tools/internal/astutil" "golang.org/x/tools/internal/event" "golang.org/x/tools/internal/facts" - "golang.org/x/tools/internal/moremaps" ) /* @@ -495,16 +496,53 @@ func (an *analysisNode) summaryHash() file.Hash { return an._summaryHash } -// analyzeSummary is a frob-serializable summary of successfully +// analyzeSummary is a gob-serializable summary of successfully // applying a list of analyzers to a package. type analyzeSummary struct { Compiles bool // transitively free of list/parse/type errors Actions actionMap // maps analyzer stablename to analysis results (*actionSummary) } +// actionMap defines a stable Gob encoding for a map. +// TODO(adonovan): generalize and move to a library when we can use generics. type actionMap map[string]*actionSummary -// actionSummary is a frob-serializable summary of one possibly failed analysis action. +var ( + _ gob.GobEncoder = (actionMap)(nil) + _ gob.GobDecoder = (*actionMap)(nil) +) + +type actionsMapEntry struct { + K string + V *actionSummary +} + +func (m actionMap) GobEncode() ([]byte, error) { + entries := make([]actionsMapEntry, 0, len(m)) + for k, v := range m { + entries = append(entries, actionsMapEntry{k, v}) + } + sort.Slice(entries, func(i, j int) bool { + return entries[i].K < entries[j].K + }) + var buf bytes.Buffer + err := gob.NewEncoder(&buf).Encode(entries) + return buf.Bytes(), err +} + +func (m *actionMap) GobDecode(data []byte) error { + var entries []actionsMapEntry + if err := gob.NewDecoder(bytes.NewReader(data)).Decode(&entries); err != nil { + return err + } + *m = make(actionMap, len(entries)) + for _, e := range entries { + (*m)[e.K] = e.V + } + return nil +} + +// actionSummary is a gob-serializable summary of one possibly failed analysis action. // If Err is non-empty, the other fields are undefined. type actionSummary struct { Facts []byte // the encoded facts.Set diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/check.go b/vendor/golang.org/x/tools/gopls/internal/cache/check.go index a66608a495..4bca59f1e8 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/check.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/check.go @@ -26,7 +26,6 @@ import ( "golang.org/x/mod/module" "golang.org/x/sync/errgroup" "golang.org/x/tools/go/ast/astutil" - "golang.org/x/tools/go/types/objectpath" "golang.org/x/tools/gopls/internal/bloom" "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/cache/parsego" @@ -36,11 +35,11 @@ import ( "golang.org/x/tools/gopls/internal/label" "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/util/bug" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/gopls/internal/util/safetoken" "golang.org/x/tools/gopls/internal/util/tokeninternal" "golang.org/x/tools/internal/event" "golang.org/x/tools/internal/gcimporter" - "golang.org/x/tools/internal/moremaps" "golang.org/x/tools/internal/packagesinternal" "golang.org/x/tools/internal/typesinternal" "golang.org/x/tools/internal/versions" @@ -71,7 +70,6 @@ type typeCheckBatch struct { syntaxPackages *futureCache[PackageID, *Package] // transient cache of in-progress syntax futures importPackages *futureCache[PackageID, *types.Package] // persistent cache of imports gopackagesdriver bool // for bug reporting: were packages loaded with a driver? - encoder objectpath.Encoder // to amortize encoding across the batch } // addHandles is called by each goroutine joining the type check batch, to @@ -418,7 +416,7 @@ func (b *typeCheckBatch) getPackage(ctx context.Context, ph *packageHandle) (*Pa } // Update caches. - go storePackageResults(ctx, ph, p, &b.encoder) // ...and write all packages to disk + go storePackageResults(ctx, ph, p) // ...and write all packages to disk return p, nil }) } @@ -426,10 +424,10 @@ func (b *typeCheckBatch) getPackage(ctx context.Context, ph *packageHandle) (*Pa // storePackageResults serializes and writes information derived from p to the // file cache. // The context is used only for logging; cancellation does not affect the operation. -func storePackageResults(ctx context.Context, ph *packageHandle, p *Package, enc *objectpath.Encoder) { +func storePackageResults(ctx context.Context, ph *packageHandle, p *Package) { toCache := map[string][]byte{ - xrefsKind: p.pkg.xrefs(enc).Encode(), - methodSetsKind: p.pkg.methodsets(enc).Encode(), + xrefsKind: p.pkg.xrefs().Encode(), + methodSetsKind: p.pkg.methodsets().Encode(), testsKind: p.pkg.tests().Encode(), diagnosticsKind: encodeDiagnostics(p.pkg.diagnostics), } @@ -1254,7 +1252,7 @@ func (b *packageHandleBuilder) evaluatePackageHandle(ctx context.Context, n *han ph.localInputs = inputs checkOpen: - for _, files := range [][]file.Handle{inputs.goFiles, inputs.compiledGoFiles, inputs.asmFiles} { + for _, files := range [][]file.Handle{inputs.goFiles, inputs.compiledGoFiles} { for _, fh := range files { if _, ok := fh.(*overlay); ok { ph.isOpen = true @@ -1466,12 +1464,12 @@ type typeCheckInputs struct { id PackageID // Used for type checking: - pkgPath PackagePath - name PackageName - goFiles, compiledGoFiles, asmFiles []file.Handle - sizes types.Sizes - depsByImpPath map[ImportPath]PackageID - goVersion string // packages.Module.GoVersion, e.g. "1.18" + pkgPath PackagePath + name PackageName + goFiles, compiledGoFiles []file.Handle + sizes types.Sizes + depsByImpPath map[ImportPath]PackageID + goVersion string // packages.Module.GoVersion, e.g. "1.18" // Used for type check diagnostics: // TODO(rfindley): consider storing less data in gobDiagnostics, and @@ -1501,10 +1499,6 @@ func (s *Snapshot) typeCheckInputs(ctx context.Context, mp *metadata.Package) (* if err != nil { return nil, err } - asmFiles, err := readFiles(ctx, s, mp.AsmFiles) - if err != nil { - return nil, err - } goVersion := "" if mp.Module != nil && mp.Module.GoVersion != "" { @@ -1520,7 +1514,6 @@ func (s *Snapshot) typeCheckInputs(ctx context.Context, mp *metadata.Package) (* name: mp.Name, goFiles: goFiles, compiledGoFiles: compiledGoFiles, - asmFiles: asmFiles, sizes: mp.TypesSizes, depsByImpPath: mp.DepsByImpPath, goVersion: goVersion, @@ -1573,10 +1566,6 @@ func localPackageKey(inputs *typeCheckInputs) file.Hash { for _, fh := range inputs.goFiles { fmt.Fprintln(hasher, fh.Identity()) } - fmt.Fprintf(hasher, "asmFiles: %d\n", len(inputs.asmFiles)) - for _, fh := range inputs.asmFiles { - fmt.Fprintln(hasher, fh.Identity()) - } // types sizes wordSize := inputs.sizes.Sizeof(types.Typ[types.Int]) @@ -1633,10 +1622,6 @@ func (b *typeCheckBatch) checkPackage(ctx context.Context, fset *token.FileSet, pkg.parseErrors = append(pkg.parseErrors, pgf.ParseErr) } } - pkg.asmFiles, err = parseAsmFiles(ctx, inputs.asmFiles...) - if err != nil { - return nil, err - } // Use the default type information for the unsafe package. if inputs.pkgPath == "unsafe" { diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/diagnostics.go b/vendor/golang.org/x/tools/gopls/internal/cache/diagnostics.go index 22b221f464..05ff75cc09 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/diagnostics.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/diagnostics.go @@ -103,10 +103,8 @@ func ToProtocolDiagnostics(diagnostics ...*Diagnostic) []protocol.Diagnostic { reports := []protocol.Diagnostic{} for _, diag := range diagnostics { pdiag := protocol.Diagnostic{ - Message: protocol.Or_Diagnostic_message{ - // diag.Message might start with \n or \t - Value: strings.TrimSpace(diag.Message), - }, + // diag.Message might start with \n or \t + Message: strings.TrimSpace(diag.Message), Range: diag.Range, Severity: diag.Severity, Source: string(diag.Source), diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/load.go b/vendor/golang.org/x/tools/gopls/internal/cache/load.go index d24809b79c..da8326125e 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/load.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/load.go @@ -243,7 +243,7 @@ func (s *Snapshot) load(ctx context.Context, allowNetwork AllowNetwork, scopes . continue } // Skip test main packages. - if isTestMain(pkg) { + if isTestMain(pkg, s.view.folder.Env.GOCACHE) { continue } // Skip filtered packages. They may be added anyway if they're @@ -453,13 +453,6 @@ func buildMetadata(updates map[PackageID]*metadata.Package, loadDir string, stan *dst = append(*dst, protocol.URIFromPath(filename)) } } - // Copy SFiles to AsmFiles. - for _, filename := range pkg.OtherFiles { - if !strings.HasSuffix(filename, ".s") { - continue - } - mp.AsmFiles = append(mp.AsmFiles, protocol.URIFromPath(filename)) - } copyURIs(&mp.CompiledGoFiles, pkg.CompiledGoFiles) copyURIs(&mp.GoFiles, pkg.GoFiles) copyURIs(&mp.IgnoredFiles, pkg.IgnoredFiles) @@ -808,31 +801,21 @@ checkURIs: return true } -func isTestMain(pkg *packages.Package) bool { +func isTestMain(pkg *packages.Package, gocache string) bool { // Test mains must have an import path that ends with ".test". if !strings.HasSuffix(pkg.PkgPath, ".test") { return false } - // Real package paths may also end in ".test", so keep checking the - // synthetic test main shape below. + // Test main packages are always named "main". if pkg.Name != "main" { return false } - if len(pkg.GoFiles) == 0 { + // Test mains always have exactly one GoFile that is in the build cache. + if len(pkg.GoFiles) > 1 { return false } - if pkg.Dir == "" { + if !pathutil.InDir(gocache, pkg.GoFiles[0]) { return false } - // A synthetic test main package has the Dir of the package under test, - // but its generated GoFiles live elsewhere. We avoid relying on the - // heuristic that test mains always have exactly one GoFile in GOCACHE, - // as that may not be the case for users of GOCACHEPROG, or for future - // implementations of go test. - for _, goFile := range pkg.GoFiles { - if pathutil.InDir(pkg.Dir, goFile) { - return false - } - } return true } diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/metadata/metadata.go b/vendor/golang.org/x/tools/gopls/internal/cache/metadata/metadata.go index d449adf0be..d68fed4aca 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/metadata/metadata.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/metadata/metadata.go @@ -51,8 +51,6 @@ type Package struct { IgnoredFiles []protocol.DocumentURI OtherFiles []protocol.DocumentURI - AsmFiles []protocol.DocumentURI // *.s subset of OtherFiles - ForTest PackagePath // q in a "p [q.test]" package, else "" TypesSizes types.Sizes Errors []packages.Error // must be set for packages in import cycles diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/methodsets/methodsets.go b/vendor/golang.org/x/tools/gopls/internal/cache/methodsets/methodsets.go index 0e569bdb0a..5936bd182e 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/methodsets/methodsets.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/methodsets/methodsets.go @@ -88,8 +88,8 @@ func (index *Index) Encode() []byte { // NewIndex returns a new index of method-set information for all // package-level types in the specified package. -func NewIndex(enc *objectpath.Encoder, fset *token.FileSet, pkg *types.Package) *Index { - return new(indexBuilder).build(enc, fset, pkg) +func NewIndex(fset *token.FileSet, pkg *types.Package) *Index { + return new(indexBuilder).build(fset, pkg) } // A Location records the extent of an identifier in byte-offset form. @@ -294,7 +294,7 @@ type indexBuilder struct { } // build adds to the index all package-level named types of the specified package. -func (b *indexBuilder) build(enc *objectpath.Encoder, fset *token.FileSet, pkg *types.Package) *Index { +func (b *indexBuilder) build(fset *token.FileSet, pkg *types.Package) *Index { _ = b.string("") // 0 => "" objectPos := func(obj types.Object) gobPosition { @@ -302,6 +302,8 @@ func (b *indexBuilder) build(enc *objectpath.Encoder, fset *token.FileSet, pkg * return gobPosition{b.string(posn.Filename), posn.Offset, len(obj.Name())} } + objectpathFor := new(objectpath.Encoder).For + // setindexInfo sets the (Posn, PkgPath, ObjectPath) fields for each method declaration. setIndexInfo := func(m *gobMethod, method *types.Func) { // error.Error has empty Position, PkgPath, and ObjectPath. @@ -311,7 +313,7 @@ func (b *indexBuilder) build(enc *objectpath.Encoder, fset *token.FileSet, pkg * // Instantiations of generic methods don't have an // object path, so we use the generic. - p, err := enc.For(method.Origin()) + p, err := objectpathFor(method.Origin()) if err != nil { // This should never happen for a method of a package-level type. // (It used to: see go.dev/issue70418.) @@ -393,8 +395,8 @@ func methodSetInfo(t types.Type, setIndexInfo func(*gobMethod, *types.Func)) *go // Preallocate capacity, but grow by append so that skipped // (generic) methods leave no nil holes in the slice. methods := make([]*gobMethod, 0, mset.Len()) - for method := range mset.Methods() { - m := method.Obj().(*types.Func) + for i := 0; i < mset.Len(); i++ { + m := mset.At(i).Obj().(*types.Func) // Generic methods do not participate in interface satisfaction. if m.Signature().TypeParams().Len() > 0 { continue diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/package.go b/vendor/golang.org/x/tools/gopls/internal/cache/package.go index 2f811bb084..d0d90bbc40 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/package.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/package.go @@ -13,14 +13,12 @@ import ( "slices" "sync" - "golang.org/x/tools/go/types/objectpath" "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/cache/methodsets" "golang.org/x/tools/gopls/internal/cache/parsego" "golang.org/x/tools/gopls/internal/cache/testfuncs" "golang.org/x/tools/gopls/internal/cache/xrefs" "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/asm" "golang.org/x/tools/gopls/internal/util/safetoken" ) @@ -52,7 +50,6 @@ type syntaxPackage struct { fset *token.FileSet // for now, same as the snapshot's FileSet goFiles []*parsego.File compiledGoFiles []*parsego.File - asmFiles []*asm.File diagnostics []*Diagnostic parseErrors []scanner.ErrorList typeErrors []types.Error @@ -71,16 +68,16 @@ type syntaxPackage struct { _tests *testfuncs.Index // only used by the tests method } -func (p *syntaxPackage) xrefs(enc *objectpath.Encoder) *xrefs.Index { +func (p *syntaxPackage) xrefs() *xrefs.Index { p.xrefsOnce.Do(func() { - p._xrefs = xrefs.NewIndex(enc, p.types, p.typesInfo, p.compiledGoFiles, p.asmFiles) + p._xrefs = xrefs.NewIndex(p.compiledGoFiles, p.types, p.typesInfo) }) return p._xrefs } -func (p *syntaxPackage) methodsets(enc *objectpath.Encoder) *methodsets.Index { +func (p *syntaxPackage) methodsets() *methodsets.Index { p.methodsetsOnce.Do(func() { - p._methodsets = methodsets.NewIndex(enc, p.fset, p.types) + p._methodsets = methodsets.NewIndex(p.fset, p.types) }) return p._methodsets } @@ -215,20 +212,3 @@ func (p *Package) ParseErrors() []scanner.ErrorList { func (p *Package) TypeErrors() []types.Error { return p.pkg.typeErrors } - -func (p *Package) AsmFiles() []*asm.File { - return p.pkg.asmFiles -} - -func (p *Package) AsmFile(uri protocol.DocumentURI) (*asm.File, error) { - return p.pkg.AsmFile(uri) -} - -func (pkg *syntaxPackage) AsmFile(uri protocol.DocumentURI) (*asm.File, error) { - for _, af := range pkg.asmFiles { - if af.Mapper.URI == uri { - return af, nil - } - } - return nil, fmt.Errorf("no parsed file for %s in %v", uri, pkg.id) -} diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/parse.go b/vendor/golang.org/x/tools/gopls/internal/cache/parse.go index ecfad74168..d733ca7679 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/parse.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/parse.go @@ -13,7 +13,6 @@ import ( "golang.org/x/tools/gopls/internal/cache/parsego" "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/util/asm" ) // ParseGo parses the file whose contents are provided by fh. @@ -44,20 +43,3 @@ func parseGoImpl(ctx context.Context, fset *token.FileSet, fh file.Handle, mode pgf, _ := parsego.Parse(ctx, fset, fh.URI(), content, mode, purgeFuncBodies) // ignore 'fixes' return pgf, nil } - -// parseAsmFiles parses the assembly files whose contents are provided by fhs. -func parseAsmFiles(ctx context.Context, fhs ...file.Handle) ([]*asm.File, error) { - pafs := make([]*asm.File, len(fhs)) - for i, fh := range fhs { - // Check for context cancellation before reading file content. - if ctx.Err() != nil { - return nil, ctx.Err() - } - content, err := fh.Content() - if err != nil { - return nil, err - } - pafs[i] = asm.Parse(fh.URI(), content) - } - return pafs, nil -} diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/parsego/parse.go b/vendor/golang.org/x/tools/gopls/internal/cache/parsego/parse.go index 1f4a9fcde8..857dfa08c6 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/parsego/parse.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/parsego/parse.go @@ -507,8 +507,6 @@ func fixInitStmt(bad *ast.BadExpr, parent ast.Node, tok *token.File, src []byte) return false } - fileEnd := token.Pos(tok.Base() + tok.Size()) - // If the parent statement doesn't already have an "init" statement, // move the extracted statement into the "init" field and insert a // dummy expression into the required "cond" field. @@ -520,7 +518,7 @@ func fixInitStmt(bad *ast.BadExpr, parent ast.Node, tok *token.File, src []byte) p.Init = stmt p.Cond = &ast.Ident{ Name: "_", - NamePos: min(stmt.End(), fileEnd), + NamePos: stmt.End(), } return true case *ast.ForStmt: @@ -530,7 +528,7 @@ func fixInitStmt(bad *ast.BadExpr, parent ast.Node, tok *token.File, src []byte) p.Init = stmt p.Cond = &ast.Ident{ Name: "_", - NamePos: min(stmt.End(), fileEnd), + NamePos: stmt.End(), } return true case *ast.SwitchStmt: @@ -868,12 +866,11 @@ func offsetPositions(tok *token.File, n ast.Node, offset token.Pos) { } // Clamp value to valid range; see #64335. - // We clamp the start position of the token so that its End() - // (start + size) does not exceed fileEnd + 1 (workaround EOF limit). - structField := v.Type().Field(i) - size := posSize(n, structField.Name) - maxPos := max(fileEnd+1-token.Pos(size), fileBase) - pos = min(max(pos+offset, fileBase), maxPos) + // + // TODO(golang/go#64335): this is a hack, because our fixes should not + // produce positions that overflow (but they do; see golang/go#64488, + // #73438, #66790, #66683, #67704). + pos = min(max(pos+offset, fileBase), fileEnd) f.SetInt(int64(pos)) } @@ -883,210 +880,6 @@ func offsetPositions(tok *token.File, n ast.Node, offset token.Pos) { }) } -func posSize(n ast.Node, fieldName string) int { - switch n := n.(type) { - case *ast.AssignStmt: - if fieldName == "TokPos" { - return len(n.Tok.String()) - } - case *ast.BadDecl: - if fieldName == "From" { - return int(n.To - n.From) - } - if fieldName == "To" { - return 0 - } - case *ast.BadExpr: - if fieldName == "From" { - return int(n.To - n.From) - } - if fieldName == "To" { - return 0 - } - case *ast.BadStmt: - if fieldName == "From" { - return int(n.To - n.From) - } - if fieldName == "To" { - return 0 - } - case *ast.BasicLit: - if fieldName == "ValuePos" { - return len(n.Value) - } - if fieldName == "ValueEnd" { - return 0 - } - case *ast.BinaryExpr: - if fieldName == "OpPos" { - return len(n.Op.String()) - } - case *ast.BlockStmt: - if fieldName == "Lbrace" || fieldName == "Rbrace" { - return 1 - } - case *ast.BranchStmt: - if fieldName == "TokPos" { - return len(n.Tok.String()) - } - case *ast.CallExpr: - if fieldName == "Lparen" || fieldName == "Rparen" { - return 1 - } - if fieldName == "Ellipsis" { - return 3 // "..." - } - case *ast.CaseClause: - if fieldName == "Case" { - if n.List == nil { - return 7 // "default" - } - return 4 // "case" - } - if fieldName == "Colon" { - return 1 - } - case *ast.ChanType: - if fieldName == "Begin" { - return 4 // "chan" - } - if fieldName == "Arrow" { - return 2 // "<-" - } - case *ast.CommClause: - if fieldName == "Case" { - if n.Comm == nil { - return 7 // "default" - } - return 4 // "case" - } - if fieldName == "Colon" { - return 1 - } - case *ast.Comment: - if fieldName == "Slash" { - return len(n.Text) - } - case *ast.CompositeLit: - if fieldName == "Lbrace" || fieldName == "Rbrace" { - return 1 - } - case *ast.DeferStmt: - if fieldName == "Defer" { - return 5 // "defer" - } - case *ast.Ellipsis: - if fieldName == "Ellipsis" { - return 3 // "..." - } - case *ast.EmptyStmt: - if fieldName == "Semicolon" { - return 1 - } - case *ast.File: - if fieldName == "Package" { - return 7 // "package" - } - if fieldName == "FileStart" || fieldName == "FileEnd" { - return 0 - } - case *ast.ForStmt: - if fieldName == "For" { - return 3 // "for" - } - case *ast.FuncType: - if fieldName == "Func" { - return 4 // "func" - } - case *ast.GenDecl: - if fieldName == "TokPos" { - return len(n.Tok.String()) - } - if fieldName == "Lparen" || fieldName == "Rparen" { - return 1 - } - case *ast.GoStmt: - if fieldName == "Go" { - return 2 // "go" - } - case *ast.Ident: - if fieldName == "NamePos" { - return len(n.Name) - } - case *ast.IfStmt: - if fieldName == "If" { - return 2 // "if" - } - case *ast.ImportSpec: - if fieldName == "EndPos" { - return 0 - } - case *ast.IncDecStmt: - if fieldName == "TokPos" { - return 2 // "++" or "--" - } - case *ast.InterfaceType: - if fieldName == "Interface" { - return 9 // "interface" - } - case *ast.KeyValueExpr: - if fieldName == "Colon" { - return 1 - } - case *ast.LabeledStmt: - if fieldName == "Colon" { - return 1 - } - case *ast.MapType: - if fieldName == "Map" { - return 3 // "map" - } - case *ast.RangeStmt: - if fieldName == "For" { - return 3 // "for" - } - if fieldName == "TokPos" { - return len(n.Tok.String()) - } - if fieldName == "Range" { - return 5 // "range" - } - case *ast.ReturnStmt: - if fieldName == "Return" { - return 6 // "return" - } - case *ast.SelectStmt: - if fieldName == "Select" { - return 6 // "select" - } - case *ast.SendStmt: - if fieldName == "Arrow" { - return 2 // "<-" - } - case *ast.StructType: - if fieldName == "Struct" { - return 6 // "struct" - } - case *ast.SwitchStmt: - if fieldName == "Switch" { - return 6 // "switch" - } - case *ast.TypeSpec: - if fieldName == "Assign" { - return 1 // "=" - } - case *ast.TypeSwitchStmt: - if fieldName == "Switch" { - return 6 // "switch" - } - case *ast.UnaryExpr: - if fieldName == "OpPos" { - return len(n.Op.String()) - } - } - return 1 // default fallback -} - // replaceNode updates parent's child oldChild to be newChild. It // returns whether it replaced successfully. func replaceNode(parent, oldChild, newChild ast.Node) bool { @@ -1117,7 +910,9 @@ func replaceNode(parent, oldChild, newChild ast.Node) bool { } // Loop over parent's struct fields. - for _, f := range parentVal.Fields() { + for i := 0; i < parentVal.NumField(); i++ { + f := parentVal.Field(i) + switch f.Kind() { // Check interface and pointer fields. case reflect.Interface, reflect.Pointer: diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/snapshot.go b/vendor/golang.org/x/tools/gopls/internal/cache/snapshot.go index 0fd4b604c4..a66133de9e 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/snapshot.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/snapshot.go @@ -39,13 +39,13 @@ import ( "golang.org/x/tools/gopls/internal/util/constraints" "golang.org/x/tools/gopls/internal/util/immutable" "golang.org/x/tools/gopls/internal/util/memoize" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/gopls/internal/util/pathutil" "golang.org/x/tools/gopls/internal/util/persistent" "golang.org/x/tools/gopls/internal/vulncheck" "golang.org/x/tools/internal/event" "golang.org/x/tools/internal/event/label" "golang.org/x/tools/internal/gocommand" - "golang.org/x/tools/internal/moremaps" ) // A Snapshot represents the current state for a given view. @@ -567,8 +567,6 @@ func (s *Snapshot) References(ctx context.Context, ids ...PackageID) ([]xrefInde ctx, done := event.Start(ctx, "cache.snapshot.References") defer done() - var enc objectpath.Encoder // amortize encoding across the batch - indexes := make([]xrefIndex, len(ids)) pre := func(i int, ph *packageHandle) bool { if idx, ok := filecache.GetOrFatal(xrefsKind, ph.key, xrefs.Decode); ok { @@ -578,7 +576,7 @@ func (s *Snapshot) References(ctx context.Context, ids ...PackageID) ([]xrefInde return true } post := func(i int, pkg *Package) { - indexes[i] = xrefIndex{mp: pkg.metadata, idx: pkg.pkg.xrefs(&enc)} + indexes[i] = xrefIndex{mp: pkg.metadata, idx: pkg.pkg.xrefs()} } return indexes, s.forEachPackage(ctx, ids, pre, post) } @@ -601,8 +599,6 @@ func (s *Snapshot) MethodSets(ctx context.Context, ids ...PackageID) ([]*methods ctx, done := event.Start(ctx, "cache.snapshot.MethodSets") defer done() - var enc objectpath.Encoder // amortize encoding across the batch - indexes := make([]*methodsets.Index, len(ids)) pre := func(i int, ph *packageHandle) bool { pkgPath := ph.mp.PkgPath // capture for decode closure @@ -615,7 +611,7 @@ func (s *Snapshot) MethodSets(ctx context.Context, ids ...PackageID) ([]*methods return true } post := func(i int, pkg *Package) { - indexes[i] = pkg.pkg.methodsets(&enc) + indexes[i] = pkg.pkg.methodsets() } return indexes, s.forEachPackage(ctx, ids, pre, post) } diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/source.go b/vendor/golang.org/x/tools/gopls/internal/cache/source.go index 5b7e1b2a3b..7db1384828 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/source.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/source.go @@ -13,8 +13,8 @@ import ( "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/cache/symbols" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/internal/imports" - "golang.org/x/tools/internal/moremaps" ) // goplsSource is an imports.Source that provides import information using diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/typerefs/packageset.go b/vendor/golang.org/x/tools/gopls/internal/cache/typerefs/packageset.go index 71bb469346..af495d1573 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/typerefs/packageset.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/typerefs/packageset.go @@ -11,7 +11,7 @@ import ( "sync" "golang.org/x/tools/gopls/internal/cache/metadata" - "golang.org/x/tools/internal/moremaps" + "golang.org/x/tools/gopls/internal/util/moremaps" ) // PackageIndex stores common data to enable efficient representation of diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/view.go b/vendor/golang.org/x/tools/gopls/internal/cache/view.go index 0e0e9b7c2e..6bfc7e1eb0 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/view.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/view.go @@ -30,13 +30,13 @@ import ( "golang.org/x/tools/gopls/internal/file" "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/settings" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/gopls/internal/util/pathutil" "golang.org/x/tools/gopls/internal/vulncheck" "golang.org/x/tools/internal/event" "golang.org/x/tools/internal/gocommand" "golang.org/x/tools/internal/imports" "golang.org/x/tools/internal/modindex" - "golang.org/x/tools/internal/moremaps" ) // A Folder represents an LSP workspace folder, together with its per-folder diff --git a/vendor/golang.org/x/tools/gopls/internal/cache/xrefs/xrefs.go b/vendor/golang.org/x/tools/gopls/internal/cache/xrefs/xrefs.go index b613c1e9a7..bc15c04ed9 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cache/xrefs/xrefs.go +++ b/vendor/golang.org/x/tools/gopls/internal/cache/xrefs/xrefs.go @@ -12,24 +12,18 @@ import ( "go/ast" "go/types" "sort" - "strings" "golang.org/x/tools/go/types/objectpath" "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/cache/parsego" "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/asm" "golang.org/x/tools/gopls/internal/util/bug" "golang.org/x/tools/gopls/internal/util/frob" ) // NewIndex constructs an index of outbound cross-references for the // specified type-checked package. -// -// Callers indexing many packages should share one objectpath Encoder -// so that a heavily referenced package's object paths are encoded -// once rather than once per referencing package. -func NewIndex(enc *objectpath.Encoder, pkg *types.Package, info *types.Info, files []*parsego.File, asmFiles []*asm.File) *Index { +func NewIndex(files []*parsego.File, pkg *types.Package, info *types.Info) *Index { // pkgObjects maps each referenced package Q to a mapping: // from each referenced symbol in Q to the ordered list // of references to that symbol from this package. @@ -47,6 +41,8 @@ func NewIndex(enc *objectpath.Encoder, pkg *types.Package, info *types.Info, fil return objects } + objectpathFor := new(objectpath.Encoder).For + for fileIndex, pgf := range files { // Avoid pgf.Cursor() here to prevent materialization // of an Inspector during workspace reindexing, which @@ -71,7 +67,7 @@ func NewIndex(enc *objectpath.Encoder, pkg *types.Package, info *types.Info, fil objects := getObjects(obj.Pkg()) gobObj, ok := objects[obj] if !ok { - path, err := enc.For(obj) + path, err := objectpathFor(obj) if err != nil { // Capitalized but not exported // (e.g. local const/var/type). @@ -119,67 +115,6 @@ func NewIndex(enc *objectpath.Encoder, pkg *types.Package, info *types.Info, fil } } - // For each asm file, record cross-package references. - // Within-package asm references are found by localReferences - // scanning syntax, not by the xrefs index. - - // Build a mapping from import path to package, so that each - // cross-package identifier can be resolved without a linear - // scan of pkg.Imports() for every identifier. - importsByPath := make(map[string]*types.Package, len(pkg.Imports())) - for _, imp := range pkg.Imports() { - importsByPath[imp.Path()] = imp - } - for fileIndex, file := range asmFiles { - for _, id := range file.Idents { - if id.Kind != asm.Data && id.Kind != asm.Ref { - continue - } - pkgpath, name, ok := strings.CutLast(id.Name, ".") - if !ok { - continue - } - if pkgpath == "" || pkgpath == pkg.Path() { - // Within-package reference; skip (handled by localReferences). - continue - } - // Cross-package reference: find the dependency package. - // - // TODO(Groot Guo): assembly may legally reference - // non-dependencies (e.g. sync/atomic calls internal/runtime/atomic). - // Currently we only search direct imports; see goasm.Definition - // which searches the full metadata graph. - depPkg, ok := importsByPath[pkgpath] - if !ok { - continue - } - obj := depPkg.Scope().Lookup(name) - if obj == nil { - continue - } - objects := getObjects(depPkg) - gobObj, ok := objects[obj] - if !ok { - path, err := enc.For(obj) - if err != nil { - continue - } - gobObj = &gobObject{Path: path} - objects[obj] = gobObj - } - if rng, err := file.IdentRange(id); err == nil { - gobObj.Refs = append(gobObj.Refs, gobRef{ - // FileIndex for asm files is offset by len(files) - // (i.e. the number of compiledGoFiles). - // Lookup reverses this by comparing against - // len(mp.CompiledGoFiles); the two counts must be equal. - FileIndex: len(files) + fileIndex, - Range: rng, - }) - } - } - } - // Flatten the maps into slices, and sort for determinism. var packages []*gobPackage for p := range pkgObjects { @@ -229,15 +164,7 @@ func (idx *Index) Lookup(mp *metadata.Package, targets map[metadata.PackagePath] for _, gobObj := range gp.Objects { if _, ok := objectSet[gobObj.Path]; ok { for _, ref := range gobObj.Refs { - var uri protocol.DocumentURI - if asmIndex := ref.FileIndex - len(mp.CompiledGoFiles); asmIndex < 0 { - // CompiledGoFile reference. - // Invariant: len(files) passed to NewIndex - // equals len(mp.CompiledGoFiles). - uri = mp.CompiledGoFiles[ref.FileIndex] - } else { - uri = mp.AsmFiles[asmIndex] - } + uri := mp.CompiledGoFiles[ref.FileIndex] locs = append(locs, protocol.Location{ URI: uri, Range: ref.Range, @@ -279,6 +206,6 @@ type gobObject struct { } type gobRef struct { - FileIndex int // index of enclosing file within P's CompiledGoFiles + AsmFiles + FileIndex int // index of enclosing file within P's CompiledGoFiles Range protocol.Range // source range of reference } diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/call_hierarchy.go b/vendor/golang.org/x/tools/gopls/internal/cmd/call_hierarchy.go index 906e0ba583..890b21f180 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/call_hierarchy.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/call_hierarchy.go @@ -11,11 +11,12 @@ import ( "strings" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // callHierarchy implements the callHierarchy verb for gopls. type callHierarchy struct { - app *application + app *Application } func (c *callHierarchy) Name() string { return "call_hierarchy" } @@ -35,7 +36,7 @@ Example: func (c *callHierarchy) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("call_hierarchy expects 1 argument (position)") + return tool.CommandLineErrorf("call_hierarchy expects 1 argument (position)") } cli, _, err := c.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/check.go b/vendor/golang.org/x/tools/gopls/internal/cmd/check.go index 83e72911d1..68cf6882a6 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/check.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/check.go @@ -16,7 +16,7 @@ import ( // check implements the check verb for gopls. type check struct { - app *application + app *Application Severity string `flag:"severity" help:"minimum diagnostic severity (hint, info, warning, or error)"` } @@ -113,7 +113,7 @@ func (c *check) Run(ctx context.Context, args ...string) error { if diag.Severity > severityCutoff { // lower severity value => greater severity, counterintuitively continue } - if err := print(file.uri, diag.Range, diag.MessageString()); err != nil { + if err := print(file.uri, diag.Range, diag.Message); err != nil { return err } for _, rel := range diag.RelatedInformation { diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/cmd.go b/vendor/golang.org/x/tools/gopls/internal/cmd/cmd.go index b8acdf34bc..314e20e971 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/cmd.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/cmd.go @@ -22,36 +22,40 @@ import ( "time" "golang.org/x/tools/gopls/internal/cache" + "golang.org/x/tools/gopls/internal/debug" + "golang.org/x/tools/gopls/internal/filecache" "golang.org/x/tools/gopls/internal/lsprpc" "golang.org/x/tools/gopls/internal/protocol" - protocolcommand "golang.org/x/tools/gopls/internal/protocol/command" + "golang.org/x/tools/gopls/internal/protocol/command" "golang.org/x/tools/gopls/internal/protocol/semtok" "golang.org/x/tools/gopls/internal/server" "golang.org/x/tools/gopls/internal/settings" + "golang.org/x/tools/gopls/internal/tool" "golang.org/x/tools/gopls/internal/util/browser" "golang.org/x/tools/gopls/internal/util/bug" + "golang.org/x/tools/gopls/internal/util/moreslices" "golang.org/x/tools/internal/diff" "golang.org/x/tools/internal/jsonrpc2" - "golang.org/x/tools/internal/moreslices" ) -// application represents the root gopls command and coordinates subcommand dispatch. -type application struct { +// Application is the main application as passed to tool.Main +// It handles the main command line parsing and dispatch to the sub commands. +type Application struct { // Core application flags // Embed the basic profiling flags supported by the tool package - ProfileFlags + tool.Profile // We include the server configuration directly for now, so the flags work // even without the verb. // TODO: Remove this when we stop allowing the serve verb by default. - serve serve + Serve Serve // the options configuring function to invoke when building a server options func(*settings.Options) - // Remote LSP client connection flags. - RemoteFlags + // Support for remote LSP server. + Remote string `flag:"remote" help:"forward all commands to a remote lsp specified by this flag. With no special prefix, this is assumed to be a TCP address. If prefixed by 'unix;', the subsequent address is assumed to be a unix domain socket. If 'auto', or prefixed by 'auto;', the remote address is automatically resolved based on the executing environment."` // Verbose enables verbose logging. Verbose bool `flag:"v,verbose" help:"verbose output"` @@ -87,63 +91,35 @@ type EditFlags struct { List bool `flag:"l,list" help:"display names of edited files"` } -// RemoteFlags defines the set of flags for the forward mode. -type RemoteFlags struct { - Remote string `flag:"remote" help:"forward all commands to a remote lsp specified by this flag. With no special prefix, this is assumed to be a TCP address. If prefixed by 'unix;', the subsequent address is assumed to be a unix domain socket. If 'auto', or prefixed by 'auto;', the remote address is automatically resolved based on the executing environment."` - - // The following flags are used with -remote=auto mode. - RemoteDebug string `flag:"remote.debug" help:"when used with -remote=auto, the -debug value used to start the daemon"` - RemoteListenTimeout time.Duration `flag:"remote.listen.timeout" help:"when used with -remote=auto, the -listen.timeout value used to start the daemon"` - - RemoteLogfile string `flag:"remote.logfile" help:"when used with -remote=auto, the -logfile value used to start the daemon"` -} - -func (r *RemoteFlags) remoteArgs(network, address string) []string { - args := []string{ - "serve", - "-listen", fmt.Sprintf(`%s;%s`, network, address), - } - if r.RemoteDebug != "" { - args = append(args, "-debug", r.RemoteDebug) - } - timeout := r.RemoteListenTimeout - if timeout == 0 { - timeout = 1 * time.Minute - } - args = append(args, "-listen.timeout", timeout.String()) - if r.RemoteLogfile != "" { - args = append(args, "-logfile", r.RemoteLogfile) - } - return args -} - -func (app *application) verbose() bool { +func (app *Application) verbose() bool { return app.Verbose || app.VeryVerbose } -// newApplication returns a new application ready to run. -func newApplication() *application { - app := &application{ - RemoteListenTimeout: 1 * time.Minute, +// New returns a new Application ready to run. +func New() *Application { + app := &Application{ + Serve: Serve{ + RemoteListenTimeout: 1 * time.Minute, + }, } - app.serve.app = app + app.Serve.app = app return app } -// Name implements command returning the binary name. -func (app *application) Name() string { return "gopls" } +// Name implements tool.Application returning the binary name. +func (app *Application) Name() string { return "gopls" } -// Usage implements command returning empty extra argument usage. -func (app *application) Usage() string { return "" } +// Usage implements tool.Application returning empty extra argument usage. +func (app *Application) Usage() string { return "" } -// ShortHelp implements command returning the main binary help. -func (app *application) ShortHelp() string { +// ShortHelp implements tool.Application returning the main binary help. +func (app *Application) ShortHelp() string { return "" } -// DetailedHelp implements command returning the main binary help. +// DetailedHelp implements tool.Application returning the main binary help. // This includes the short help for all the sub commands. -func (app *application) DetailedHelp(f *flag.FlagSet) { +func (app *Application) DetailedHelp(f *flag.FlagSet) { w := tabwriter.NewWriter(f.Output(), 0, 0, 2, ' ', 0) defer w.Flush() @@ -151,10 +127,8 @@ func (app *application) DetailedHelp(f *flag.FlagSet) { gopls is a Go language server. It is typically used with an editor to provide language features. When no -command is specified, gopls will default to the 'serve' command. To see flags -for the 'serve' command, run 'gopls help serve'. - -The language features can also be accessed via the gopls command-line interface. +command is specified, gopls will default to the 'serve' command. The language +features can also be accessed via the gopls command-line interface. For documentation of all its features, see: @@ -181,7 +155,6 @@ Command: } fmt.Fprint(w, "\nflags:\n") printFlagDefaults(f) - fmt.Fprint(w, "\nFor flags specific to running the language server (such as -listen, -logfile, or -debug), run 'gopls help serve'.\n") } // this is a slightly modified version of flag.PrintDefaults to give us control @@ -253,26 +226,45 @@ func isZeroValue(f *flag.Flag, value string) bool { return value == z.Interface().(flag.Value).String() } -// Run implements command, but should never be invoked directly. -// Main coordinates normalization and subcommand dispatching. -func (app *application) Run(ctx context.Context, args ...string) error { - panic("unreachable: application.Run should never be called directly") +// Run takes the args after top level flag processing, and invokes the correct +// sub command as specified by the first argument. +// If no arguments are passed it will invoke the server sub command, as a +// temporary measure for compatibility. +func (app *Application) Run(ctx context.Context, args ...string) error { + // In the category of "things we can do while waiting for the Go command": + // Pre-initialize the filecache, which takes ~50ms to hash the gopls + // executable, and immediately runs a gc. + filecache.Start() + + ctx = debug.WithInstance(ctx, app.OTel) + if len(args) == 0 { + s := flag.NewFlagSet(app.Name(), flag.ExitOnError) + return tool.Run(ctx, s, &app.Serve, args) + } + command, args := args[0], args[1:] + for _, c := range app.Commands() { + if c.Name() == command { + s := flag.NewFlagSet(app.Name(), flag.ExitOnError) + return tool.Run(ctx, s, c, args) + } + } + return tool.CommandLineErrorf("Unknown command %v", command) } // Commands returns the set of commands supported by the gopls tool on the // command line. // The command is specified by the first non flag argument. -func (app *application) Commands() []command { - var commands []command +func (app *Application) Commands() []tool.Application { + var commands []tool.Application commands = append(commands, app.mainCommands()...) commands = append(commands, app.featureCommands()...) commands = append(commands, app.internalCommands()...) return commands } -func (app *application) mainCommands() []command { - return []command{ - &app.serve, +func (app *Application) mainCommands() []tool.Application { + return []tool.Application{ + &app.Serve, &version{app: app}, &help{app: app}, &apiJSON{app: app}, @@ -280,14 +272,14 @@ func (app *application) mainCommands() []command { } } -func (app *application) internalCommands() []command { - return []command{ +func (app *Application) internalCommands() []tool.Application { + return []tool.Application{ &vulncheck{app: app}, } } -func (app *application) featureCommands() []command { - return []command{ +func (app *Application) featureCommands() []tool.Application { + return []tool.Application{ &callHierarchy{app: app}, &check{app: app, Severity: "warning"}, &codeaction{app: app}, @@ -315,8 +307,7 @@ func (app *application) featureCommands() []command { } // connect creates and initializes a new in-process gopls LSP session. -func (app *application) connect(ctx context.Context) (*client, *cache.Session, error) { - +func (app *Application) connect(ctx context.Context) (*client, *cache.Session, error) { root, err := os.Getwd() if err != nil { return nil, nil, fmt.Errorf("finding workdir: %v", err) @@ -408,7 +399,7 @@ func (cli *client) initialize(ctx context.Context, server protocol.Server, param // connection; it conceptually corresponds to a single call to // connect(2). type client struct { - app *application + app *Application server protocol.Server initializeResult *protocol.InitializeResult // includes server capabilities @@ -430,7 +421,7 @@ type cmdFile struct { diagnostics []protocol.Diagnostic } -func newClient(app *application) *client { +func newClient(app *Application) *client { return &client{ app: app, files: make(map[protocol.DocumentURI]*cmdFile), @@ -474,10 +465,6 @@ func (cli *client) LogMessage(ctx context.Context, p *protocol.LogMessageParams) if cli.app.verbose() { log.Print("Log:", p.Message) } - case protocol.Debug: - if cli.app.verbose() { - log.Print("Debug:", p.Message) - } default: if cli.app.verbose() { log.Print(p.Message) @@ -687,7 +674,7 @@ func (cli *client) PublishDiagnostics(ctx context.Context, p *protocol.PublishDi if desc := d.CodeDescription; desc != nil { codeHref = desc.Href } - k := key{d.Range, d.Severity, d.Code, codeHref, d.Source, d.MessageString()} + k := key{d.Range, d.Severity, d.Code, codeHref, d.Source, d.Message} if !seen[k] { seen[k] = true out = append(out, d) @@ -826,7 +813,7 @@ func (cli *client) openFile(ctx context.Context, uri protocol.DocumentURI) (*cmd } func diagnoseFiles(ctx context.Context, server protocol.Server, files []protocol.DocumentURI) error { - cmd := protocolcommand.NewDiagnoseFilesCommand("Diagnose files", protocolcommand.DiagnoseFilesArgs{ + cmd := command.NewDiagnoseFilesCommand("Diagnose files", command.DiagnoseFilesArgs{ Files: files, }) _, err := executeCommand(ctx, server, cmd) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/codeaction.go b/vendor/golang.org/x/tools/gopls/internal/cmd/codeaction.go index aa36ba1f2f..974b499f8c 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/codeaction.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/codeaction.go @@ -13,6 +13,7 @@ import ( "strings" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // codeaction implements the codeaction verb for gopls. @@ -22,7 +23,7 @@ type codeaction struct { Title string `flag:"title" help:"regular expression to match title"` Exec bool `flag:"exec" help:"execute the first matching code action"` - app *application + app *Application } func (cmd *codeaction) Name() string { return "codeaction" } @@ -57,7 +58,6 @@ Valid kinds include: refactor.extract.variable refactor.inline refactor.inline.call - refactor.inline.variable refactor.rewrite refactor.rewrite.changeQuote refactor.rewrite.fillStruct @@ -105,7 +105,7 @@ codeaction-flags: func (cmd *codeaction) Run(ctx context.Context, args ...string) error { if len(args) < 1 { - return commandLineErrorf("codeaction expects at least 1 argument") + return tool.CommandLineErrorf("codeaction expects at least 1 argument") } cmd.app.editFlags = &cmd.EditFlags cli, _, err := cmd.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/codelens.go b/vendor/golang.org/x/tools/gopls/internal/cmd/codelens.go index e48462a180..1d324934c6 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/codelens.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/codelens.go @@ -11,12 +11,13 @@ import ( "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/settings" + "golang.org/x/tools/gopls/internal/tool" ) // codelens implements the codelens verb for gopls. type codelens struct { EditFlags - app *application + app *Application Exec bool `flag:"exec" help:"execute the first matching code lens"` } @@ -55,14 +56,14 @@ func (r *codelens) Run(ctx context.Context, args ...string) error { var filename, title string switch len(args) { case 0: - return commandLineErrorf("codelens requires a file name") + return tool.CommandLineErrorf("codelens requires a file name") case 2: title = args[1] fallthrough case 1: filename = args[0] default: - return commandLineErrorf("codelens expects at most two arguments") + return tool.CommandLineErrorf("codelens expects at most two arguments") } r.app.editFlags = &r.EditFlags // in case a codelens perform an edit diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/definition.go b/vendor/golang.org/x/tools/gopls/internal/cmd/definition.go index 99fe5dc597..26dd86f7e0 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/definition.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/definition.go @@ -14,10 +14,11 @@ import ( "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/settings" + "golang.org/x/tools/gopls/internal/tool" ) -// A definitionJSON is the result of a 'definition' query. -type definitionJSON struct { +// A Definition is the result of a 'definition' query. +type Definition struct { Span span `json:"span"` // span of the definition Description string `json:"description"` // description of the denoted object } @@ -33,7 +34,7 @@ const ( // definition implements the definition verb for gopls. type definition struct { - app *application + app *Application JSON bool `flag:"json" help:"emit output in JSON format"` MarkdownSupported bool `flag:"markdown" help:"support markdown in responses"` @@ -59,7 +60,7 @@ definition-flags: // results to stdout. func (d *definition) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("definition expects 1 argument") + return tool.CommandLineErrorf("definition expects 1 argument") } // Plaintext makes more sense for the command line. opts := d.app.options @@ -118,7 +119,7 @@ func (d *definition) Run(ctx context.Context, args ...string) error { description = strings.TrimSpace(hover.Contents.Value) } - result := &definitionJSON{ + result := &Definition{ Span: definition, Description: description, } diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/execute.go b/vendor/golang.org/x/tools/gopls/internal/cmd/execute.go index c139635d64..0c40e59c03 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/execute.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/execute.go @@ -15,14 +15,15 @@ import ( "golang.org/x/tools/gopls/internal/filecache" "golang.org/x/tools/gopls/internal/protocol" - protocolcommand "golang.org/x/tools/gopls/internal/protocol/command" + "golang.org/x/tools/gopls/internal/protocol/command" + "golang.org/x/tools/gopls/internal/tool" "golang.org/x/tools/gopls/internal/util/bug" ) // execute implements the LSP ExecuteCommand verb for gopls. type execute struct { EditFlags - app *application + app *Application } func (e *execute) Name() string { return "execute" } @@ -47,7 +48,6 @@ Examples: execute-flags: `) - printFlagDefaults(f) } @@ -62,11 +62,11 @@ func (e *execute) Run(ctx context.Context, args ...string) error { } if len(args) == 0 { - return commandLineErrorf("execute requires a command name") + return tool.CommandLineErrorf("execute requires a command name") } cmd := args[0] - if !slices.Contains(protocolcommand.Commands, protocolcommand.Command(cmd)) { - return commandLineErrorf("unrecognized command: %s", cmd) + if !slices.Contains(command.Commands, command.Command(cmd)) { + return tool.CommandLineErrorf("unrecognized command: %s", cmd) } // A command may have multiple arguments, though the only one diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/folding_range.go b/vendor/golang.org/x/tools/gopls/internal/cmd/folding_range.go index 37c96177e5..e2c2f4bf31 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/folding_range.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/folding_range.go @@ -10,11 +10,12 @@ import ( "fmt" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // foldingRanges implements the folding_ranges verb for gopls type foldingRanges struct { - app *application + app *Application } func (r *foldingRanges) Name() string { return "folding_ranges" } @@ -32,7 +33,7 @@ Example: func (r *foldingRanges) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("folding_ranges expects 1 argument (file)") + return tool.CommandLineErrorf("folding_ranges expects 1 argument (file)") } cli, _, err := r.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/format.go b/vendor/golang.org/x/tools/gopls/internal/cmd/format.go index 16da4ff98d..8766d9c0a5 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/format.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/format.go @@ -15,7 +15,7 @@ import ( // format implements the format verb for gopls. type format struct { EditFlags - app *application + app *Application } func (c *format) Name() string { return "format" } diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/harness.go b/vendor/golang.org/x/tools/gopls/internal/cmd/harness.go deleted file mode 100644 index 57ceccf009..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/harness.go +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright 2018 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 cmd - -import ( - "context" - "flag" - "fmt" - "io" - "log" - "os" - "reflect" - "runtime" - "runtime/pprof" - "runtime/trace" - "slices" - "strings" - "time" - - "golang.org/x/tools/gopls/internal/debug" - "golang.org/x/tools/gopls/internal/filecache" -) - -// This file defines common flags and helper functions -// that coordinate flag registration via reflection. - -// ProfileFlags can be embedded in your application struct to automatically -// add command line arguments and handling for common profiling methods. -type ProfileFlags struct { - CPU string `flag:"profile.cpu" help:"write CPU profile to this file"` - Memory string `flag:"profile.mem" help:"write memory profile to this file"` - Alloc string `flag:"profile.alloc" help:"write alloc profile to this file"` - Trace string `flag:"profile.trace" help:"write trace log to this file"` - Block string `flag:"profile.block" help:"write block profile to this file"` -} - -// command represents an executable CLI command or subcommand within gopls. -type command interface { - // Name returns the command's name. It is used in help and error messages. - Name() string - // Most of the help usage is automatically generated, this string should only - // describe the contents of non flag arguments. - Usage() string - // ShortHelp returns the one line overview of the command. - ShortHelp() string - // DetailedHelp should print a detailed help message. It will only ever be shown - // when the ShortHelp is also printed, so there is no need to duplicate - // anything from there. - // It is passed the flag set so it can print the default values of the flags. - // It should use the flag sets configured Output to write the help to. - DetailedHelp(*flag.FlagSet) - // Run is invoked after all flag processing, and inside the profiling and - // error handling harness. - Run(ctx context.Context, args ...string) error -} - -type subcommand interface { - // TODO(hyangah): merge with command. It is unclear why we need - // to keep command and subcommand separate. - - command - Parent() string -} - -// This is the type returned by commandLineErrorf, which causes the outer main -// to trigger printing of the command line help. -type commandLineError string - -func (e commandLineError) Error() string { return string(e) } - -// commandLineErrorf is like fmt.Errorf except that it returns a value that -// triggers printing of the command line help. -// In general you should use this when generating command line validation errors. -func commandLineErrorf(message string, args ...any) error { - return commandLineError(fmt.Sprintf(message, args...)) -} - -// Main is the main entry point for the gopls application, called by gopls main. -// It never returns. -func Main() { - ctx := context.Background() - args := os.Args[1:] - app := newApplication() - cmd, globalArgs, cmdArgs, err := normalize(app, args) - if err != nil { - if cmd == nil { - cmd = app - } - fmt.Fprintf(os.Stderr, "%s: %v\n", cmdPath(cmd), err) - if isCommandLineError(err) { - printCommandHelp(os.Stderr, cmd) - } - os.Exit(2) - } - - parseFlags(app, globalArgs) - cmdFlags := parseFlags(cmd, cmdArgs) - - err = runWithProfile(&app.ProfileFlags, func() error { - // In the category of "things we can do while waiting for the - // Go command": - - // Pre-initialize the filecache as early as possible. - // The work (hashing the executable, starting GC, and checking cache access) - // is done in a separate goroutine, so it doesn't block startup of short-lived - // commands (like help/version) which will exit before the goroutine finishes. - // Concurrent gopls processes (e.g. CLI and daemon) won't conflict because - // GC is delayed and concurrent writes to the shared cache are handled safely. - filecache.Start() - - ctx = debug.WithInstance(ctx, app.OTel) - - return cmd.Run(ctx, cmdFlags.Args()...) - }) - if err != nil { - fmt.Fprintf(os.Stderr, "gopls: %v\n", err) - if isCommandLineError(err) { - printCommandHelp(os.Stderr, cmd) - } - os.Exit(2) - } - os.Exit(0) -} - -// isCommandLineError reports whether the error was created by [commandLineErrorf]. -func isCommandLineError(err error) bool { - _, ok := err.(commandLineError) - return ok -} - -// cmdPath returns the full command path (e.g. "gopls remote debug") for target. -func cmdPath(target command) string { - if sub, ok := target.(subcommand); ok && sub.Parent() != "" { - return sub.Parent() + " " + target.Name() - } - return target.Name() -} - -// printHelp prints the usage and detailed help for any command to s.Output(). -func printHelp(s *flag.FlagSet, cmd command) { - if _, ok := cmd.(*application); !ok { - printCommandHelp(s.Output(), cmd) - } - cmd.DetailedHelp(s) -} - -// printCommandHelp prints a concise usage summary for cmd to w. -func printCommandHelp(w io.Writer, cmd command) { - if _, ok := cmd.(*application); ok { - fmt.Fprintln(w, "Usage:\n gopls help []") - return - } - if short := cmd.ShortHelp(); short != "" { - fmt.Fprintf(w, "%s\n\n", short) - } - fmt.Fprintf(w, "Usage:\n gopls [flags] %s", strings.TrimPrefix(cmdPath(cmd), "gopls ")) - if usage := cmd.Usage(); usage != "" { - fmt.Fprintf(w, " %s", usage) - } - fmt.Fprintln(w) -} - -// runWithProfile executes fn with active CPU, trace, memory, alloc, or block profiling -// if requested in p. -func runWithProfile(p *ProfileFlags, fn func() error) (resultErr error) { - if p.CPU != "" { - f, err := os.Create(p.CPU) - if err != nil { - return err - } - if err := pprof.StartCPUProfile(f); err != nil { - f.Close() // ignore error - return err - } - defer func() { - pprof.StopCPUProfile() - if closeErr := f.Close(); resultErr == nil { - resultErr = closeErr - } - }() - } - - if p.Trace != "" { - f, err := os.Create(p.Trace) - if err != nil { - return err - } - if err := trace.Start(f); err != nil { - f.Close() // ignore error - return err - } - defer func() { - trace.Stop() - if closeErr := f.Close(); resultErr == nil { - resultErr = closeErr - } - log.Printf("To view the trace, run:\n$ go tool trace view %s", p.Trace) - }() - } - - if p.Memory != "" { - f, err := os.Create(p.Memory) - if err != nil { - return err - } - defer func() { - runtime.GC() // get up-to-date statistics - if err := pprof.WriteHeapProfile(f); err != nil { - log.Printf("Writing memory profile: %v", err) - } - if err := f.Close(); err != nil { - log.Printf("Closing memory profile: %v", err) - } - }() - } - - if p.Alloc != "" { - f, err := os.Create(p.Alloc) - if err != nil { - return err - } - defer func() { - if err := pprof.Lookup("allocs").WriteTo(f, 0); err != nil { - log.Printf("Writing alloc profile: %v", err) - } - if err := f.Close(); err != nil { - log.Printf("Closing alloc profile: %v", err) - } - }() - } - - if p.Block != "" { - f, err := os.Create(p.Block) - if err != nil { - return err - } - runtime.SetBlockProfileRate(1) // record all blocking events - defer func() { - if err := pprof.Lookup("block").WriteTo(f, 0); err != nil { - log.Printf("Writing block profile: %v", err) - } - if err := f.Close(); err != nil { - log.Printf("Closing block profile: %v", err) - } - }() - } - return fn() -} - -// addFlags scans fields of structs recursively to find things with flag tags -// and add them to the flag set. -func addFlags(f *flag.FlagSet, field reflect.StructField, value reflect.Value) *ProfileFlags { - // is it a field we are allowed to reflect on? - if field.PkgPath != "" { - return nil - } - // now see if is actually a flag - flagNames, isFlag := field.Tag.Lookup("flag") - help := field.Tag.Get("help") - if isFlag { - nameList := strings.Split(flagNames, ",") - // add the main flag - addFlag(f, value, nameList[0], help) - if len(nameList) > 1 { - // and now add any aliases using the same flag value - fv := f.Lookup(nameList[0]).Value - for _, flagName := range nameList[1:] { - f.Var(fv, flagName, help) - } - } - return nil - } - // not a flag, but it might be a struct with flags in it - value = resolve(value.Elem()) - if value.Kind() != reflect.Struct { - return nil - } - - // TODO(adonovan): there's no need for this special treatment of Profile: - // The caller can use f.Lookup("profile.cpu") etc instead. - p, _ := reflect.TypeAssert[*ProfileFlags](value.Addr()) - // go through all the fields of the struct - for i := 0; i < value.Type().NumField(); i++ { - child := value.Type().Field(i) - v := value.Field(i) - // make sure we have a pointer - if v.Kind() != reflect.Pointer { - v = v.Addr() - } - // check if that field is a flag or contains flags - if fp := addFlags(f, child, v); fp != nil { - p = fp - } - } - return p -} - -func addFlag(f *flag.FlagSet, value reflect.Value, flagName string, help string) { - switch v := value.Interface().(type) { - case flag.Value: - f.Var(v, flagName, help) - case *bool: - f.BoolVar(v, flagName, *v, help) - case *time.Duration: - f.DurationVar(v, flagName, *v, help) - case *float64: - f.Float64Var(v, flagName, *v, help) - case *int64: - f.Int64Var(v, flagName, *v, help) - case *int: - f.IntVar(v, flagName, *v, help) - case *string: - f.StringVar(v, flagName, *v, help) - case *uint: - f.UintVar(v, flagName, *v, help) - case *uint64: - f.Uint64Var(v, flagName, *v, help) - default: - log.Fatalf("field %q of type %T is not assignable to flag.Value", flagName, v) - } -} - -func resolve(v reflect.Value) reflect.Value { - for { - switch v.Kind() { - case reflect.Interface, reflect.Pointer: - v = v.Elem() - default: - return v - } - } -} - -// parseFlags creates, configures, and parses a FlagSet for cmd using args. -// If parsing fails or help is requested, it prints contextual help and exits. -func parseFlags(cmd command, args []string) *flag.FlagSet { - // We use ContinueOnError and discard initial error output so we can intercept flag errors - // and produce contextual, user-friendly diagnostic messages rather than standard Go flag usage. - fs := flag.NewFlagSet(cmd.Name(), flag.ContinueOnError) - fs.SetOutput(io.Discard) - addCommandFlags(fs, cmd) - err := fs.Parse(args) - if err == nil { - return fs - } - - if err == flag.ErrHelp { - // POSIX convention requires writing explicit help requests - // (-h/-help) to stdout on exit 0. - fs.SetOutput(os.Stdout) - printHelp(fs, cmd) - os.Exit(0) - } - - fs.SetOutput(os.Stderr) - // When standard flag parsing fails due to an undefined flag, - // inspect command hierarchy so we can guide the user - // if they misplaced a flag before or after a subcommand. - if prefix := "flag provided but not defined: -"; strings.HasPrefix(err.Error(), prefix) { - checkMisplacedFlag(fs, cmd, strings.TrimPrefix(err.Error(), prefix)) - } - - // Fallback diagnostic for general flag syntax errors - // or truly unknown flags. - fmt.Fprintf(os.Stderr, "%s: %v\n", cmdPath(cmd), err) - printCommandHelp(os.Stderr, cmd) - os.Exit(2) - return nil -} - -// findCommandByName searches the command tree starting from root for a command named name. -func findCommandByName(root command, name string) command { - if root.Name() == name { - return root - } - for _, sub := range getSubcommands(root) { - if sub.Name() == name { - return sub - } - if found := findCommandByName(sub, name); found != nil { - return found - } - } - return nil -} - -// checkMisplacedFlag inspects ancestors and descendants to diagnose undefined flag errors. -// If a misplaced flag is found, it prints where the flag belongs and exits with code 2. -func checkMisplacedFlag(fs *flag.FlagSet, cmd command, name string) { - // Check descendants: e.g. placing a subcommand flag before specifying the subcommand. - if sub := findSubcommandWithFlag(cmd, name); sub != nil { - fmt.Fprintf(os.Stderr, "%s: flag -%s belongs to subcommand %s\n", cmdPath(cmd), name, sub.Name()) - printCommandHelp(fs.Output(), cmd) - os.Exit(2) - } - - // Walk up ancestors via lineage string: e.g. placing a global application flag after the subcommand name. - // Strict flag ordering requires parent/global flags to precede subcommands. - if sub, ok := cmd.(subcommand); ok && sub.Parent() != "" { - root := newApplication() - for _, currName := range slices.Backward(strings.Fields(sub.Parent())) { - curr := findCommandByName(root, currName) - if curr != nil && hasFlag(curr, name) { - fmt.Fprintf(os.Stderr, "%s: flag -%s must be placed before subcommand %s (after %s)\n", cmdPath(cmd), name, cmd.Name(), currName) - printCommandHelp(fs.Output(), cmd) - os.Exit(2) - } - } - } -} - -// findSubcommandWithFlag recursively searches getSubcommands(target) to check -// if flagName is registered on any child or descendant subcommand. -func findSubcommandWithFlag(target command, flagName string) command { - for _, sub := range getSubcommands(target) { - if hasFlag(sub, flagName) { - return sub - } - if found := findSubcommandWithFlag(sub, flagName); found != nil { - return found - } - } - return nil -} - -// hasFlag reports whether flagName is registered on cmd. -func hasFlag(cmd command, flagName string) bool { - fs := flag.NewFlagSet(cmd.Name(), flag.ContinueOnError) - fs.SetOutput(io.Discard) - addCommandFlags(fs, cmd) - return fs.Lookup(flagName) != nil -} - -// addCommandFlags registers the flags defined in the app struct onto the FlagSet. -func addCommandFlags(f *flag.FlagSet, app command) *ProfileFlags { - return addFlags(f, reflect.StructField{}, reflect.ValueOf(app)) -} diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/highlight.go b/vendor/golang.org/x/tools/gopls/internal/cmd/highlight.go index 6675336d8b..26c7fe6dee 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/highlight.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/highlight.go @@ -10,11 +10,12 @@ import ( "fmt" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // highlight implements the highlight verb for gopls. type highlight struct { - app *application + app *Application } func (r *highlight) Name() string { return "highlight" } @@ -34,7 +35,7 @@ Example: func (r *highlight) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("highlight expects 1 argument (position)") + return tool.CommandLineErrorf("highlight expects 1 argument (position)") } cli, _, err := r.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/implementation.go b/vendor/golang.org/x/tools/gopls/internal/cmd/implementation.go index 8332603470..0c845f474a 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/implementation.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/implementation.go @@ -11,11 +11,12 @@ import ( "sort" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // implementation implements the implementation verb for gopls type implementation struct { - app *application + app *Application } func (i *implementation) Name() string { return "implementation" } @@ -35,7 +36,7 @@ Example: func (i *implementation) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("implementation expects 1 argument (position)") + return tool.CommandLineErrorf("implementation expects 1 argument (position)") } cli, _, err := i.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/imports.go b/vendor/golang.org/x/tools/gopls/internal/cmd/imports.go index 8a29976ab7..0b8f143b02 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/imports.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/imports.go @@ -10,12 +10,13 @@ import ( "fmt" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // imports implements the import verb for gopls. type imports struct { EditFlags - app *application + app *Application } func (t *imports) Name() string { return "imports" } @@ -39,7 +40,7 @@ imports-flags: // - otherwise, prints the new versions to stdout. func (t *imports) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("imports expects 1 argument") + return tool.CommandLineErrorf("imports expects 1 argument") } t.app.editFlags = &t.EditFlags cli, _, err := t.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/info.go b/vendor/golang.org/x/tools/gopls/internal/cmd/info.go index 1f3a244dd3..b0990468f5 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/info.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/info.go @@ -18,11 +18,12 @@ import ( "golang.org/x/tools/gopls/internal/debug" "golang.org/x/tools/gopls/internal/doc" licensespkg "golang.org/x/tools/gopls/internal/licenses" + "golang.org/x/tools/gopls/internal/tool" ) // help implements the help command. type help struct { - app *application + app *Application } func (h *help) Name() string { return "help" } @@ -42,7 +43,7 @@ $ gopls help remote sessions # help on 'remote sessions' subcommand // Run prints help information about a subcommand. func (h *help) Run(ctx context.Context, args ...string) error { - find := func(cmds []command, name string) command { + find := func(cmds []tool.Application, name string) tool.Application { for _, cmd := range cmds { if cmd.Name() == name { return cmd @@ -52,31 +53,27 @@ func (h *help) Run(ctx context.Context, args ...string) error { } // Find the subcommand denoted by args (empty => h.app). - var cmd command = h.app + var cmd tool.Application = h.app for i, arg := range args { cmd = find(getSubcommands(cmd), arg) if cmd == nil { - return commandLineErrorf( + return tool.CommandLineErrorf( "no such subcommand: %s", strings.Join(args[:i+1], " ")) } } // 'gopls help cmd subcmd' is equivalent to 'gopls cmd subcmd -h'. - // parseFlags prints the usage information when it sees the -h flag. - // - // TODO(hyangah): should we treat `gopls help cmd` and `gopls cmd -h` - // differently? For example, `gopls help cmd` can give a long help - // that explains a lot more details (DetailedHelp) than - // `gopls cmd -h` outputs (ShortHelp). - parseFlags(cmd, []string{"-h"}) - return nil + // The flag package prints the usage information (defined by tool.Run) + // when it sees the -h flag. + fs := flag.NewFlagSet(cmd.Name(), flag.ExitOnError) + return tool.Run(ctx, fs, h.app, append(args[:len(args):len(args)], "-h")) } // version implements the version command. type version struct { JSON bool `flag:"json" help:"outputs in json format."` - app *application + app *Application } func (v *version) Name() string { return "version" } @@ -101,7 +98,7 @@ func (v *version) Run(ctx context.Context, args ...string) error { } type apiJSON struct { - app *application + app *Application } func (j *apiJSON) Name() string { return "api-json" } @@ -124,7 +121,7 @@ func (j *apiJSON) Run(ctx context.Context, args ...string) error { } type licenses struct { - app *application + app *Application } func (l *licenses) Name() string { return "licenses" } diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/links.go b/vendor/golang.org/x/tools/gopls/internal/cmd/links.go index 468179303d..3b088681a2 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/links.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/links.go @@ -12,13 +12,14 @@ import ( "os" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // links implements the links verb for gopls. type links struct { JSON bool `flag:"json" help:"emit document links in JSON format"` - app *application + app *Application } func (l *links) Name() string { return "links" } @@ -41,7 +42,7 @@ links-flags: // - otherwise, prints the a list of unique links func (l *links) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("links expects 1 argument") + return tool.CommandLineErrorf("links expects 1 argument") } cli, _, err := l.app.connect(ctx) if err != nil { diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/mcp.go b/vendor/golang.org/x/tools/gopls/internal/cmd/mcp.go index 1175ae059b..a35f049981 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/mcp.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/mcp.go @@ -21,7 +21,7 @@ import ( ) type headlessMCP struct { - app *application + app *Application Address string `flag:"listen" help:"the address on which to run the mcp server"` Logfile string `flag:"logfile" help:"filename to log to; if unset, logs to stderr"` @@ -47,12 +47,7 @@ Examples: } func (m *headlessMCP) Run(ctx context.Context, args ...string) error { - // TODO(hxjiang): properly support remote mode (https://github.com/golang/go/issues/78668). - if m.app.Remote != "" { - return commandLineErrorf("mcp does not currently support remote mode") - } if m.Instructions { - fmt.Println(internalmcp.Instructions) return nil } diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/normalize.go b/vendor/golang.org/x/tools/gopls/internal/cmd/normalize.go deleted file mode 100644 index 892c3404d3..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/normalize.go +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright 2026 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 cmd - -import ( - "flag" - "io" - "strings" -) - -// normalize scans command-line arguments to find the top-level subcommand, -// separating global application flags from subcommand arguments without executing FlagSet.Parse. -// -// Returns: -// - cmd: the resolved target subcommand (or &app.serve if none is specified). -// If flag validation errors, cmd is returned populated so callers can display contextual command help. -// - globalArgs: flags belonging to global application scope. -// - cmdArgs: arguments and flags belonging to cmd. -func normalize(app *application, args []string) (cmd command, globalArgs, cmdArgs []string, err error) { - silentFlagSet := func(name string, cmds ...command) *flag.FlagSet { - fs := flag.NewFlagSet(name, flag.ContinueOnError) - fs.SetOutput(io.Discard) - for _, c := range cmds { - addCommandFlags(fs, c) - } - return fs - } - - findSubcommand := func(curr command, name string) command { - for _, c := range getSubcommands(curr) { - if c.Name() == name { - return c - } - } - return nil - } - - // Flag sets to be used for flag name/type lookup. - appFlagSet := silentFlagSet(app.Name(), app) - serveFlagSet := silentFlagSet("serve", &app.serve) - - var preServeArgs []string - - i := 0 - for i < len(args) { - arg := args[i] - - if arg == "--" { - // e.g. gopls -v -- check file.go - // gopls vulncheck -- -mode=... - if i+1 < len(args) { - if matched := findSubcommand(app, args[i+1]); matched != nil { - cmd = matched - i++ // skip "--" - cmdArgs = append(cmdArgs, args[i+1:]...) - break - } - } - i++ - cmd = &app.serve - cmdArgs = append(cmdArgs, args[i:]...) - break - } - - // expect a valid subcommand if not a flag. - if arg == "-" || !strings.HasPrefix(arg, "-") { - if matched := findSubcommand(app, arg); matched != nil { - cmd = matched - i++ - cmdArgs = append(cmdArgs, args[i:]...) - break - } - break - } - - // below: arg is a string that has "-" as the prefix. - cleanArg := strings.TrimPrefix(strings.TrimPrefix(arg, "-"), "-") - name, _, hasValue := strings.Cut(cleanArg, "=") - - if name == "h" || name == "help" { // -h or -help - globalArgs = append(globalArgs, arg) - i++ - continue - } - - if appFlag := appFlagSet.Lookup(name); appFlag != nil { - consumed, err := consume(args, i, appFlag, name, hasValue) - if err != nil { - return nil, nil, nil, err - } - globalArgs = append(globalArgs, consumed...) - i += len(consumed) - continue - } - if serveFlag := serveFlagSet.Lookup(name); serveFlag != nil { - consumed, err := consume(args, i, serveFlag, name, hasValue) - if err != nil { - return nil, nil, nil, err - } - preServeArgs = append(preServeArgs, consumed...) - i += len(consumed) - continue - } - return nil, nil, nil, commandLineErrorf("unknown flag: %s", arg) - } - - if cmd == nil { - if i < len(args) { - return nil, nil, nil, commandLineErrorf("unknown command %q", args[i]) - } - cmd = &app.serve - cmdArgs = preServeArgs - } else if cmd.Name() == "serve" { - // For backwards compatibility, allow flags to be placed after serve. - cmdArgs = append(preServeArgs, cmdArgs...) - } else if len(preServeArgs) > 0 { - // All explicitly specified subcommands other than serve must - // follow strict flag ordering. - arg := preServeArgs[0] - cleanArg := strings.TrimPrefix(strings.TrimPrefix(arg, "-"), "-") - name, _, _ := strings.Cut(cleanArg, "=") - if hasFlag(cmd, name) { - return cmd, nil, nil, commandLineErrorf("flag -%s must be placed after the command %s", name, cmd.Name()) - } - if sub := findSubcommandWithFlag(app, name); sub != nil { - return cmd, nil, nil, commandLineErrorf("flag -%s belongs to subcommand %s", name, sub.Name()) - } - - return cmd, nil, nil, commandLineErrorf("flag provided but not defined: -%s", name) - } - - return cmd, globalArgs, cmdArgs, nil -} - -// consume returns the token(s) corresponding to flag f from args starting at index i. -func consume(args []string, i int, f *flag.Flag, name string, hasValue bool) ([]string, error) { - if hasValue || isBoolFlag(f) { - return args[i : i+1], nil - } - if i+1 >= len(args) { - return nil, commandLineErrorf("flag needs an argument: -%s", name) - } - return args[i : i+2], nil -} - -// isBoolFlag reports whether f is a boolean flag. -func isBoolFlag(f *flag.Flag) bool { - bf, ok := f.Value.(interface{ IsBoolFlag() bool }) - return ok && bf.IsBoolFlag() -} diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/prepare_rename.go b/vendor/golang.org/x/tools/gopls/internal/cmd/prepare_rename.go index 715f1fd5de..72f42afb97 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/prepare_rename.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/prepare_rename.go @@ -11,11 +11,12 @@ import ( "fmt" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // prepareRename implements the prepare_rename verb for gopls. type prepareRename struct { - app *application + app *Application } func (r *prepareRename) Name() string { return "prepare_rename" } @@ -33,13 +34,13 @@ Example: printFlagDefaults(f) } -// errInvalidRenamePosition is returned when prepareRename is run at a position that +// ErrInvalidRenamePosition is returned when prepareRename is run at a position that // is not a candidate for renaming. -var errInvalidRenamePosition = errors.New("request is not valid at the given position") +var ErrInvalidRenamePosition = errors.New("request is not valid at the given position") func (r *prepareRename) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("prepare_rename expects 1 argument (file)") + return tool.CommandLineErrorf("prepare_rename expects 1 argument (file)") } cli, _, err := r.app.connect(ctx) @@ -65,7 +66,7 @@ func (r *prepareRename) Run(ctx context.Context, args ...string) error { return fmt.Errorf("prepare_rename failed: %w", err) } if result == nil { - return errInvalidRenamePosition + return ErrInvalidRenamePosition } s, err := file.rangeSpan(result.Range) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/references.go b/vendor/golang.org/x/tools/gopls/internal/cmd/references.go index def3f0bb71..a91925faa5 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/references.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/references.go @@ -11,13 +11,14 @@ import ( "sort" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // references implements the references verb for gopls type references struct { IncludeDeclaration bool `flag:"d,declaration" help:"include the declaration of the specified identifier in the results"` - app *application + app *Application } func (r *references) Name() string { return "references" } @@ -39,7 +40,7 @@ references-flags: func (r *references) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("references expects 1 argument (position)") + return tool.CommandLineErrorf("references expects 1 argument (position)") } cli, _, err := r.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/remote.go b/vendor/golang.org/x/tools/gopls/internal/cmd/remote.go index 8cb6f24fc2..c100164fc2 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/remote.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/remote.go @@ -14,15 +14,15 @@ import ( "os" "golang.org/x/tools/gopls/internal/lsprpc" - protocolcommand "golang.org/x/tools/gopls/internal/protocol/command" + "golang.org/x/tools/gopls/internal/protocol/command" ) type remote struct { - app *application + app *Application subcommands } -func newRemote(app *application) *remote { +func newRemote(app *Application) *remote { return &remote{ app: app, subcommands: subcommands{ @@ -44,11 +44,11 @@ func (r *remote) ShortHelp() string { // listSessions is an inspect subcommand to list current sessions. type listSessions struct { - app *application + app *Application } func (c *listSessions) Name() string { return "sessions" } -func (c *listSessions) Parent() string { return "gopls remote" } +func (c *listSessions) Parent() string { return c.app.Name() } func (c *listSessions) Usage() string { return "" } func (c *listSessions) ShortHelp() string { return "print information about current gopls sessions" @@ -91,12 +91,11 @@ func (c *listSessions) Run(ctx context.Context, args ...string) error { } type startDebugging struct { - app *application + app *Application } -func (c *startDebugging) Name() string { return "debug" } -func (c *startDebugging) Parent() string { return "gopls remote" } -func (c *startDebugging) Usage() string { return "[host:port]" } +func (c *startDebugging) Name() string { return "debug" } +func (c *startDebugging) Usage() string { return "[host:port]" } func (c *startDebugging) ShortHelp() string { return "start the debug server" } @@ -133,11 +132,11 @@ func (c *startDebugging) Run(ctx context.Context, args ...string) error { if len(args) > 0 { debugAddr = args[0] } - debugArgs := protocolcommand.DebuggingArgs{ + debugArgs := command.DebuggingArgs{ Addr: debugAddr, } - var result protocolcommand.DebuggingResult - if err := lsprpc.ExecuteCommand(ctx, remote, protocolcommand.StartDebugging.String(), debugArgs, &result); err != nil { + var result command.DebuggingResult + if err := lsprpc.ExecuteCommand(ctx, remote, command.StartDebugging.String(), debugArgs, &result); err != nil { return err } if len(result.URLs) == 0 { diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/rename.go b/vendor/golang.org/x/tools/gopls/internal/cmd/rename.go index 6afdeddeec..1922f406da 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/rename.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/rename.go @@ -10,12 +10,13 @@ import ( "fmt" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // rename implements the rename verb for gopls. type rename struct { EditFlags - app *application + app *Application } func (r *rename) Name() string { return "rename" } @@ -41,7 +42,7 @@ rename-flags: // - otherwise, prints the new versions to stdout. func (r *rename) Run(ctx context.Context, args ...string) error { if len(args) != 2 { - return commandLineErrorf("rename expects 2 arguments (position, new name)") + return tool.CommandLineErrorf("rename expects 2 arguments (position, new name)") } r.app.editFlags = &r.EditFlags cli, _, err := r.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/semantictokens.go b/vendor/golang.org/x/tools/gopls/internal/cmd/semantictokens.go index c971945761..6dd0052f35 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/semantictokens.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/semantictokens.go @@ -43,7 +43,7 @@ import ( // the gopls coordinate system type semanticToken struct { - app *application + app *Application } func (c *semanticToken) Name() string { return "semtok" } @@ -114,8 +114,8 @@ type mark struct { // prefixes for semantic token comments const ( - semanticLeft = "/*⇐" - semanticRight = "/*⇒" + SemanticLeft = "/*⇐" + SemanticRight = "/*⇒" ) func markLine(m mark, lines [][]byte) { @@ -126,7 +126,7 @@ func markLine(m mark, lines [][]byte) { if m.typ == "namespace" && m.offset-1+m.len < len(l) && l[m.offset-1+m.len] == '"' { // it is the last component of an import spec // cannot put a comment inside a string - insert = fmt.Sprintf("%s%d,namespace,[]*/", semanticLeft, length) + insert = fmt.Sprintf("%s%d,namespace,[]*/", SemanticLeft, length) splitAt = m.offset + m.len } else { // be careful not to generate //* @@ -134,7 +134,7 @@ func markLine(m mark, lines [][]byte) { if splitAt-1 >= 0 && l[splitAt-1] == '/' { spacer = " " } - insert = fmt.Sprintf("%s%s%d,%s,%v*/", spacer, semanticRight, length, m.typ, m.mods) + insert = fmt.Sprintf("%s%s%d,%s,%v*/", spacer, SemanticRight, length, m.typ, m.mods) } x := append([]byte(insert), l[splitAt:]...) l = append(l[:splitAt], x...) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/serve.go b/vendor/golang.org/x/tools/gopls/internal/cmd/serve.go index 2ffe26978e..b87abdaf10 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/serve.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/serve.go @@ -21,12 +21,14 @@ import ( "golang.org/x/tools/gopls/internal/lsprpc" "golang.org/x/tools/gopls/internal/mcp" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" "golang.org/x/tools/gopls/internal/util/fakenet" "golang.org/x/tools/internal/jsonrpc2" ) -// serve defines the flags and working state of the gopls serve command. -type serve struct { +// Serve is a struct that exposes the configurable parts of the LSP and MCP +// server as flags, in the right form for tool.Main to consume. +type Serve struct { Logfile string `flag:"logfile" help:"filename to log to. if value is \"auto\", then logging to a default output file is enabled"` Mode string `flag:"mode" help:"no effect"` Address string `flag:"listen" help:"address on which to listen for remote connections. If prefixed by 'unix;', the subsequent address is assumed to be a unix domain socket. Otherwise, TCP is used."` @@ -34,19 +36,23 @@ type serve struct { Trace bool `flag:"rpc.trace" help:"print the full rpc trace in lsp inspector format"` Debug string `flag:"debug" help:"serve debug information on the supplied address"` + RemoteListenTimeout time.Duration `flag:"remote.listen.timeout" help:"when used with -remote=auto, the -listen.timeout value used to start the daemon"` + RemoteDebug string `flag:"remote.debug" help:"when used with -remote=auto, the -debug value used to start the daemon"` + RemoteLogfile string `flag:"remote.logfile" help:"when used with -remote=auto, the -logfile value used to start the daemon"` + // MCP Server related configurations. MCPAddress string `flag:"mcp.listen" help:"experimental: address on which to listen for model context protocol connections. If port is localhost:0, pick a random port in localhost instead."` - app *application + app *Application } -func (s *serve) Name() string { return "serve" } -func (s *serve) Parent() string { return s.app.Name() } -func (s *serve) Usage() string { return "[server-flags]" } -func (s *serve) ShortHelp() string { +func (s *Serve) Name() string { return "serve" } +func (s *Serve) Parent() string { return s.app.Name() } +func (s *Serve) Usage() string { return "[server-flags]" } +func (s *Serve) ShortHelp() string { return "run a server for Go code using the Language Server Protocol" } -func (s *serve) DetailedHelp(f *flag.FlagSet) { +func (s *Serve) DetailedHelp(f *flag.FlagSet) { fmt.Fprint(f.Output(), ` gopls [flags] [server-flags] The server communicates using JSONRPC2 on stdin and stdout, and is intended to be run directly as @@ -57,11 +63,27 @@ server-flags: printFlagDefaults(f) } +func (s *Serve) remoteArgs(network, address string) []string { + args := []string{"serve", + "-listen", fmt.Sprintf(`%s;%s`, network, address), + } + if s.RemoteDebug != "" { + args = append(args, "-debug", s.RemoteDebug) + } + if s.RemoteListenTimeout != 0 { + args = append(args, "-listen.timeout", s.RemoteListenTimeout.String()) + } + if s.RemoteLogfile != "" { + args = append(args, "-logfile", s.RemoteLogfile) + } + return args +} + // Run configures a server based on the flags, and then runs it. // It blocks until the server shuts down. -func (s *serve) Run(ctx context.Context, args ...string) error { +func (s *Serve) Run(ctx context.Context, args ...string) error { if len(args) > 0 { - return commandLineErrorf("server does not take arguments, got %v", args) + return tool.CommandLineErrorf("server does not take arguments, got %v", args) } di := debug.GetInstance(ctx) @@ -82,7 +104,7 @@ func (s *serve) Run(ctx context.Context, args ...string) error { ) if s.app.Remote != "" { var err error - ss, err = lsprpc.NewForwarder(s.app.Remote, s.app.remoteArgs) + ss, err = lsprpc.NewForwarder(s.app.Remote, s.remoteArgs) if err != nil { return fmt.Errorf("creating forwarder: %w", err) } diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/signature.go b/vendor/golang.org/x/tools/gopls/internal/cmd/signature.go index 9f62afd89b..e1c53725b0 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/signature.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/signature.go @@ -10,11 +10,12 @@ import ( "fmt" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // signature implements the signature verb for gopls type signature struct { - app *application + app *Application } func (r *signature) Name() string { return "signature" } @@ -34,7 +35,7 @@ Example: func (r *signature) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("signature expects 1 argument (position)") + return tool.CommandLineErrorf("signature expects 1 argument (position)") } cli, _, err := r.app.connect(ctx) @@ -64,7 +65,7 @@ func (r *signature) Run(ctx context.Context, args ...string) error { } if s == nil || len(s.Signatures) == 0 { - return commandLineErrorf("%v: not a function", from) + return tool.CommandLineErrorf("%v: not a function", from) } // there is only ever one possible signature, diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/stats.go b/vendor/golang.org/x/tools/gopls/internal/cmd/stats.go index 78f692c558..2fad301984 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/stats.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/stats.go @@ -20,7 +20,7 @@ import ( "golang.org/x/tools/gopls/internal/filecache" "golang.org/x/tools/gopls/internal/protocol" - protocolcommand "golang.org/x/tools/gopls/internal/protocol/command" + "golang.org/x/tools/gopls/internal/protocol/command" "golang.org/x/tools/gopls/internal/settings" "golang.org/x/tools/gopls/internal/util/bug" versionpkg "golang.org/x/tools/gopls/internal/version" @@ -28,7 +28,7 @@ import ( ) type stats struct { - app *application + app *Application Anon bool `flag:"anon" help:"hide any fields that may contain user names, file names, or source code"` } @@ -55,21 +55,19 @@ Example: } func (s *stats) Run(ctx context.Context, args ...string) error { - // stats does not work with -remote yet. - // Other sessions on the daemon may interfere with results. - // Additionally, the type assertions in below only work if progress - // notifications bypass jsonrpc2 serialization. - // TODO(hyangah): support remote mode by fetching server-side - // statistics and avoiding hangs during InitialWorkspaceLoad. if s.app.Remote != "" { - return commandLineErrorf("stats does not currently support remote mode") + // stats does not work with -remote. + // Other sessions on the daemon may interfere with results. + // Additionally, the type assertions in below only work if progress + // notifications bypass jsonrpc2 serialization. + return fmt.Errorf("the stats subcommand does not work with -remote") } if !s.app.Verbose { event.SetExporter(nil) // don't log errors to stderr } - stats := statsJSON{ + stats := GoplsStats{ GOOS: runtime.GOOS, GOARCH: runtime.GOARCH, GOPLSCACHE: os.Getenv("GOPLSCACHE"), @@ -87,7 +85,6 @@ func (s *stats) Run(ctx context.Context, args ...string) error { } // do executes a timed section of the stats command. - do := func(name string, f func() error) (time.Duration, error) { start := time.Now() fmt.Fprintf(os.Stderr, "%-30s", name+"...") @@ -131,12 +128,12 @@ func (s *stats) Run(ctx context.Context, args ...string) error { if _, err := do("Querying memstats", func() error { memStats, err := executeCommand(ctx, cli.server, &protocol.Command{ - Command: protocolcommand.MemStats.String(), + Command: command.MemStats.String(), }) if err != nil { return err } - stats.MemStats = memStats.(protocolcommand.MemStatsResult) + stats.MemStats = memStats.(command.MemStatsResult) return nil }); err != nil { return err @@ -144,12 +141,12 @@ func (s *stats) Run(ctx context.Context, args ...string) error { if _, err := do("Querying workspace stats", func() error { wsStats, err := executeCommand(ctx, cli.server, &protocol.Command{ - Command: protocolcommand.WorkspaceStats.String(), + Command: command.WorkspaceStats.String(), }) if err != nil { return err } - stats.WorkspaceStats = wsStats.(protocolcommand.WorkspaceStatsResult) + stats.WorkspaceStats = wsStats.(command.WorkspaceStatsResult) return nil }); err != nil { return err @@ -171,7 +168,8 @@ func (s *stats) Run(ctx context.Context, args ...string) error { { v := reflect.ValueOf(stats) t := v.Type() - for f := range t.Fields() { + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) if !token.IsExported(f.Name) { continue } @@ -194,13 +192,13 @@ func (s *stats) Run(ctx context.Context, args ...string) error { return nil } -// statsJSON holds information extracted from a gopls session in the current +// GoplsStats holds information extracted from a gopls session in the current // workspace. // // Fields that should be printed with the -anon flag should be explicitly // marked as `anon:"ok"`. Only fields that cannot refer to user files or code // should be marked as such. -type statsJSON struct { +type GoplsStats struct { GOOS, GOARCH string `anon:"ok"` GOPLSCACHE string GoVersion string `anon:"ok"` @@ -209,9 +207,9 @@ type statsJSON struct { InitialWorkspaceLoadDuration string `anon:"ok"` // in time.Duration string form CacheDir string BugReports []bug.Bug - MemStats protocolcommand.MemStatsResult `anon:"ok"` - WorkspaceStats protocolcommand.WorkspaceStatsResult `anon:"ok"` - DirStats dirStats `anon:"ok"` + MemStats command.MemStatsResult `anon:"ok"` + WorkspaceStats command.WorkspaceStatsResult `anon:"ok"` + DirStats dirStats `anon:"ok"` } type dirStats struct { diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/subcommands.go b/vendor/golang.org/x/tools/gopls/internal/cmd/subcommands.go index cc934bf61d..47d577b649 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/subcommands.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/subcommands.go @@ -9,11 +9,13 @@ import ( "flag" "fmt" "text/tabwriter" + + "golang.org/x/tools/gopls/internal/tool" ) // subcommands is a helper that may be embedded for commands that delegate to // subcommands. -type subcommands []command +type subcommands []tool.Application func (s subcommands) DetailedHelp(f *flag.FlagSet) { w := tabwriter.NewWriter(f.Output(), 0, 0, 2, ' ', 0) @@ -29,26 +31,26 @@ func (s subcommands) Usage() string { return " [arg]..." } func (s subcommands) Run(ctx context.Context, args ...string) error { if len(args) == 0 { - return commandLineErrorf("must provide subcommand") + return tool.CommandLineErrorf("must provide subcommand") } command, args := args[0], args[1:] for _, c := range s { if c.Name() == command { - fs := parseFlags(c, args) - return c.Run(ctx, fs.Args()...) + s := flag.NewFlagSet(c.Name(), flag.ExitOnError) + return tool.Run(ctx, s, c, args) } } - return commandLineErrorf("unknown subcommand %v", command) + return tool.CommandLineErrorf("unknown subcommand %v", command) } -func (s subcommands) Commands() []command { return s } +func (s subcommands) Commands() []tool.Application { return s } -// getSubcommands returns the subcommands of a given command. -func getSubcommands(a command) []command { - // This interface is satisfied both by commands - // that embed subcommands, and by *cmd.application. +// getSubcommands returns the subcommands of a given Application. +func getSubcommands(a tool.Application) []tool.Application { + // This interface is satisfied both by tool.Applications + // that embed subcommands, and by *cmd.Application. type hasCommands interface { - Commands() []command + Commands() []tool.Application } if sub, ok := a.(hasCommands); ok { return sub.Commands() diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/symbols.go b/vendor/golang.org/x/tools/gopls/internal/cmd/symbols.go index 36fc208eaf..4641b6a1f5 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/symbols.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/symbols.go @@ -12,11 +12,12 @@ import ( "sort" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/tool" ) // symbols implements the symbols verb for gopls type symbols struct { - app *application + app *Application } func (r *symbols) Name() string { return "symbols" } @@ -32,7 +33,7 @@ Example: } func (r *symbols) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("symbols expects 1 argument (position)") + return tool.CommandLineErrorf("symbols expects 1 argument (position)") } cli, _, err := r.app.connect(ctx) diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/vulncheck.go b/vendor/golang.org/x/tools/gopls/internal/cmd/vulncheck.go index 97d1aa26c3..7babf0d14d 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/vulncheck.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/vulncheck.go @@ -16,7 +16,7 @@ import ( // vulncheck implements the vulncheck command. // TODO(hakim): hide from the public. type vulncheck struct { - app *application + app *Application } func (v *vulncheck) Name() string { return "vulncheck" } diff --git a/vendor/golang.org/x/tools/gopls/internal/cmd/workspace_symbol.go b/vendor/golang.org/x/tools/gopls/internal/cmd/workspace_symbol.go index 07cac18573..cd4ebc6307 100644 --- a/vendor/golang.org/x/tools/gopls/internal/cmd/workspace_symbol.go +++ b/vendor/golang.org/x/tools/gopls/internal/cmd/workspace_symbol.go @@ -12,13 +12,14 @@ import ( "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/settings" + "golang.org/x/tools/gopls/internal/tool" ) // workspaceSymbol implements the workspace_symbol verb for gopls. type workspaceSymbol struct { Matcher string `flag:"matcher" help:"specifies the type of matcher: fuzzy, fastfuzzy, casesensitive, or caseinsensitive.\nThe default is caseinsensitive."` - app *application + app *Application } func (r *workspaceSymbol) Name() string { return "workspace_symbol" } @@ -38,7 +39,7 @@ workspace_symbol-flags: func (r *workspaceSymbol) Run(ctx context.Context, args ...string) error { if len(args) != 1 { - return commandLineErrorf("workspace_symbol expects 1 argument") + return tool.CommandLineErrorf("workspace_symbol expects 1 argument") } opts := r.app.options diff --git a/vendor/golang.org/x/tools/gopls/internal/debug/serve.go b/vendor/golang.org/x/tools/gopls/internal/debug/serve.go index 4d39ee122b..bec1cef558 100644 --- a/vendor/golang.org/x/tools/gopls/internal/debug/serve.go +++ b/vendor/golang.org/x/tools/gopls/internal/debug/serve.go @@ -9,7 +9,6 @@ import ( "context" "errors" "fmt" - "go/types" "html/template" "io" stdlog "log" @@ -636,12 +635,9 @@ func messageType(l log.Level) protocol.MessageType { case log.Warning: return protocol.Warning case log.Debug: - return protocol.Debug - case log.Info: - return protocol.Info - default: - return protocol.Info + return protocol.Log } + return protocol.Info } func makeInstanceExporter(i *Instance) event.Exporter { @@ -804,18 +800,6 @@ Unknown page } return s }, - "objectString": func(obj types.Object) string { - // Assume we're printing objects from the package of interest. - this := obj.Pkg() - qual := func(pkg *types.Package) string { - if this == pkg { - return "" // same package; unqualified - } - return pkg.Name() - } - return types.ObjectString(obj, qual) - }, - // TODO(rfindley): re-enable option inspection. // "options": func(s *cache.Session) []sessionOption { // return showOptions(s.Options()) @@ -1053,21 +1037,11 @@ var PackageTmpl = template.Must(template.Must(BaseTemplate.Clone()).Parse(` {{end}} -

Package-level symbols

-
    - {{with $scope := .Package.Types.Scope}} - {{range $name := $scope.Names}} - {{with $obj := $scope.Lookup $name}} -
  • {{objectString .}}
    - {{end}} - {{end}} - {{end}} -
- {{end}} {{/* TODO: - link to godoc (tricky: in server package) + - show Object inventory of types.Package.Scope - show index info (xrefs, methodsets, tests) - call DiagnoseFile on each file? */}} diff --git a/vendor/golang.org/x/tools/gopls/internal/doc/api.json b/vendor/golang.org/x/tools/gopls/internal/doc/api.json index e7f2896dfc..b9cf154ccb 100644 --- a/vendor/golang.org/x/tools/gopls/internal/doc/api.json +++ b/vendor/golang.org/x/tools/gopls/internal/doc/api.json @@ -1526,12 +1526,6 @@ "Default": "true", "Status": "" }, - { - "Name": "\"importcomment\"", - "Doc": "remove obsolete comments specifying canonical import path\n\nThe importcomment analyzer removes comments specifying the canonical\nimport path, such as\n\n\tpackage foo // import \"example.com/foo\"\n\nThe go command enforced these comments in GOPATH mode via \"go get\", but\nignores them in module mode, so they are obsolete once the package\nbelongs to a module. The fix removes the comment.", - "Default": "true", - "Status": "" - }, { "Name": "\"infertypeargs\"", "Doc": "check for unnecessary type arguments in call expressions\n\nExplicit type arguments may be omitted from call expressions if they can be\ninferred from function arguments, or from other type arguments:\n\n\tfunc f[T any](T) {}\n\t\n\tfunc _() {\n\t\tf[string](\"foo\") // string could be inferred\n\t}\n", @@ -1622,12 +1616,6 @@ "Default": "true", "Status": "" }, - { - "Name": "\"ptrtoerror\"", - "Doc": "detect inconsistent conversions of concrete types to error\n\nThe ptrtoerror analyzer detects when a concrete type E is converted\nto the error interface inconsistently, both as a value of type E\nand as a pointer of type *E. Such inconsistency defeats attempts by\nclient code to test for specific error types using type assertions\nor library functions such as [errors.As] and [errors.Is].\n\nThe analyzer also detects when both E and *E implement error but\nneither of those types is converted to error within the defining\npackage, leaving the intended error form (E or *E) ambiguous. This\ndiagnostic offers two alternative fixes to add declarations that\nmake the intent explicit.", - "Default": "true", - "Status": "" - }, { "Name": "\"rangeint\"", "Doc": "replace 3-clause for loops with for-range over integers\n\nThe rangeint analyzer suggests replacing traditional for loops such\nas\n\n\tfor i := 0; i \u003c n; i++ { ... }\n\nwith the more idiomatic Go 1.22 style:\n\n\tfor i := range n { ... }\n\nThis transformation is applied only if (a) the loop variable is not\nmodified within the loop body and (b) the loop's limit expression\nis not modified within the loop, as `for range` evaluates its\noperand only once.", @@ -1640,12 +1628,6 @@ "Default": "true", "Status": "" }, - { - "Name": "\"reflecttypeassert\"", - "Doc": "replace v.Interface().(T) with reflect.TypeAssert[T](v)\n\nThis analyzer suggests fixes to replace two-valued type assertions on\nthe result of (reflect.Value).Interface with reflect.TypeAssert,\nintroduced in go1.25, which avoids the intermediate allocation of an\ninterface value, for example:\n\n\tx, ok := v.Interface().(string) -\u003e x, ok := reflect.TypeAssert[string](v)\n\nNo fix is offered for single-valued assertions, since they panic when\nthe assertion fails whereas reflect.TypeAssert does not. Nor is a fix\noffered for a type switch.", - "Default": "true", - "Status": "" - }, { "Name": "\"reflecttypefor\"", "Doc": "replace reflect.TypeOf(x) with TypeFor[T]()\n\nThis analyzer suggests fixes to replace uses of reflect.TypeOf(x) with\nreflect.TypeFor, introduced in go1.22, when the desired runtime type\nis known at compile time, for example:\n\n\treflect.TypeOf(uint32(0)) -\u003e reflect.TypeFor[uint32]()\n\treflect.TypeOf((*ast.File)(nil)) -\u003e reflect.TypeFor[*ast.File]()\n\nIt also offers a fix to simplify the constructions below, which use\nreflect.TypeOf to return the runtime type for an interface type,\n\n\treflect.TypeOf((*io.Reader)(nil)).Elem()\n\nor:\n\n\treflect.TypeOf([]io.Reader(nil)).Elem()\n\nto:\n\n\treflect.TypeFor[io.Reader]()\n\nNo fix is offered in cases when the runtime type is dynamic, such as:\n\n\tvar r io.Reader = ...\n\treflect.TypeOf(r)\n\nor when the operand has potential side effects.", @@ -1700,12 +1682,6 @@ "Default": "true", "Status": "" }, - { - "Name": "\"slicesclip\"", - "Doc": "replace three-index slice expressions with slices.Clip\n\nThe slicesclip analyzer suggests replacing a full slice expression of\nthe form\n\n\tx[:len(x):len(x)]\n\nwhich clips the capacity of a slice to its length, with the simpler\nand more readable\n\n\tslices.Clip(x)\n\nadded in Go 1.21.", - "Default": "true", - "Status": "" - }, { "Name": "\"slicescontains\"", "Doc": "replace loops with slices.Contains or slices.ContainsFunc\n\nThe slicescontains analyzer simplifies loops that check for the existence of\nan element in a slice. It replaces them with calls to `slices.Contains` or\n`slices.ContainsFunc`, which were added in Go 1.21.\n\nIf the expression for the target element has side effects, this\ntransformation will cause those effects to occur only once, not\nonce per tested slice element.", @@ -1744,7 +1720,7 @@ }, { "Name": "\"stditerators\"", - "Doc": "use iterators instead of Len/At-style APIs\n\nThis analyzer suggests a fix to replace each loop of the form:\n\n\tfor i := 0; i \u003c x.Len(); i++ {\n\t\tuse(x.At(i))\n\t}\n\nor its \"for elem := range x.Len()\" equivalent by a range loop over an\niterator offered by the same data type:\n\n\tfor elem := range x.All() {\n\t\tuse(elem)\n\t}\n\nwhere x is one of various well-known types in the standard library.", + "Doc": "use iterators instead of Len/At-style APIs\n\nThis analyzer suggests a fix to replace each loop of the form:\n\n\tfor i := 0; i \u003c x.Len(); i++ {\n\t\tuse(x.At(i))\n\t}\n\nor its \"for elem := range x.Len()\" equivalent by a range loop over an\niterator offered by the same data type:\n\n\tfor elem := range x.All() {\n\t\tuse(x.At(i)\n\t}\n\nwhere x is one of various well-known types in the standard library.", "Default": "true", "Status": "" }, @@ -2095,7 +2071,7 @@ }, { "Name": "\"ignoredError\"", - "Doc": "`\"ignoredError\"` inlay hints for implicitly discarded errors:\n```go\n\tf.Close()« // ignore error»\n```\nThis check inserts an `// ignore error` hint following any\nstatement that is a function call whose error result is\nimplicitly ignored.\n\nTo suppress the hint, write an actual comment containing\none of the following strings:\n```\nignore error\ndiscard error\ncan't fail\ncannot fail\n```\nfollowing the call statement, or explicitly assign the\nresult to a blank variable.\n\nA handful of common functions such as `fmt.Println` are\nexcluded from the check.\n", + "Doc": "`\"ignoredError\"` inlay hints for implicitly discarded errors:\n```go\n\tf.Close()« // ignore error»\n```\nThis check inserts an `// ignore error` hint following any\nstatement that is a function call whose error result is\nimplicitly ignored.\n\nTo suppress the hint, write an actual comment containing\n\"ignore error\" following the call statement, or explicitly\nassign the result to a blank variable. A handful of common\nfunctions such as `fmt.Println` are excluded from the\ncheck.\n", "Default": "false", "Status": "" }, @@ -2294,20 +2270,6 @@ "Hierarchy": "ui", "DeprecationMessage": "" }, - { - "Name": "moveDeclaration", - "Type": "bool", - "Doc": "moveDeclaration enables producing Move Declaration codeactions. The implementation\nis unfinished so we use this setting to gate its use.\n", - "EnumKeys": { - "ValueType": "", - "Keys": null - }, - "EnumValues": null, - "Default": "false", - "Status": "experimental", - "Hierarchy": "ui", - "DeprecationMessage": "" - }, { "Name": "local", "Type": "string", @@ -2380,20 +2342,6 @@ "Hierarchy": "", "DeprecationMessage": "" }, - { - "Name": "memoryLimit", - "Type": "int64", - "Doc": "memoryLimit sets a soft memory limit (in bytes) for the gopls process, via\nruntime/debug.SetMemoryLimit. If non-positive (the default), no limit is set.\n\nOn large workspaces, a single edit that invalidates many\npackages (for example a syntax error in a widely-imported\npackage) can make the heap briefly grow well above the\nsteady-state working set before the garbage collector\ncatches up, spiking memory and, on memory-constrained\nmachines, causing swapping. A soft limit makes the GC work\nharder to stay near the limit, trading some CPU for a lower\nmemory peak.\n\nThe limit is soft and may be exceeded. Set it comfortably above the\nsteady-state working set, as too low a value causes excessive GC.\n\nUnlike the GOMEMLIMIT environment variable, this setting is\nstrictly numeric; SI suffixes are not permitted.\n", - "EnumKeys": { - "ValueType": "", - "Keys": null - }, - "EnumValues": null, - "Default": "0", - "Status": "experimental", - "Hierarchy": "", - "DeprecationMessage": "" - }, { "Name": "verboseOutput", "Type": "bool", @@ -3410,13 +3358,13 @@ { "Name": "any", "Doc": "replace interface{} with any\n\nThe any analyzer suggests replacing uses of the empty interface type,\n`interface{}`, with the `any` alias, which was introduced in Go 1.18.\nThis is a purely stylistic change that makes code more readable.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_any", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#any", "Default": true }, { "Name": "appendclipped", "Doc": "simplify append chains using slices.Concat\n\nThe appendclipped analyzer suggests replacing chains of append calls with a\nsingle call to slices.Concat, which was added in Go 1.21. For example,\nappend(append(s, s1...), s2...) would be simplified to slices.Concat(s, s1, s2).\n\nIn the simple case of appending to a newly allocated slice, such as\nappend([]T(nil), s...), the analyzer suggests the more concise slices.Clone(s).\nFor byte slices, it will prefer bytes.Clone if the \"bytes\" package is\nalready imported.\n\nThis fix is only applied when the base of the append tower is a\n\"clipped\" slice, meaning its length and capacity are equal (e.g.\nx[:0:0] or []T{}). This is to avoid changing program behavior by\neliminating intended side effects on the base slice's underlying\narray.\n\nThis analyzer is currently disabled by default as the\ntransformation does not preserve the nilness of the base slice in\nall cases; see https://go.dev/issue/73557.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_appendclipped", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#appendclipped", "Default": false }, { @@ -3452,13 +3400,13 @@ { "Name": "atomictypes", "Doc": "replace basic types in sync/atomic calls with atomic types\n\nThe atomictypes analyzer suggests replacing the primitive sync/atomic functions with\nthe strongly typed atomic wrapper types introduced in Go1.19 (e.g.\natomic.Int32). For example,\n\n\tvar x int32\n\tatomic.AddInt32(\u0026x, 1)\n\nwould become\n\n\tvar x atomic.Int32\n\tx.Add(1)\n\nThe atomic types are safer because they don't allow non-atomic access, which is\na common source of bugs. These types also resolve memory alignment issues that\nplagued the old atomic functions on 32-bit architectures.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_atomictypes", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#atomictypes", "Default": true }, { "Name": "bloop", "Doc": "replace for-range over b.N with b.Loop\n\nThe bloop analyzer suggests replacing benchmark loops of the form\n`for i := 0; i \u003c b.N; i++` or `for range b.N` with the more modern\n`for b.Loop()`, which was added in Go 1.24.\n\nThis change makes benchmark code more readable and also removes the need for\nmanual timer control, so any preceding calls to b.StartTimer, b.StopTimer,\nor b.ResetTimer within the same function will also be removed.\n\nCaveats: The b.Loop() method is designed to prevent the compiler from\noptimizing away the benchmark loop, which can occasionally result in\nslower execution due to increased allocations in some specific cases.\nSince its fix may change the performance of nanosecond-scale benchmarks,\nbloop is disabled by default in the `go fix` analyzer suite; see golang/go#74967.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_bloop", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#bloop", "Default": true }, { @@ -3524,7 +3472,7 @@ { "Name": "embedlit", "Doc": "simplify references to embedded fields in composite literals\n\nThe embedlit analyzer suggests removing redundant embedded field type specifiers\nfrom composite literals. Go1.27 introduced the ability to directly initialize\nfields promoted from embedded struct types without a nested literal. For\nexample, given the following structs:\n\n\ttype T struct {\n\t\tU\n\t}\n\n\ttype U struct {\n\t\tx int\n\t}\n\nA composite literal such as\n\n\tt := T{U: U{x: 1}}\n\nwould become\n\n\tt := T{x: 1}", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_embedlit", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#embedlit", "Default": true }, { @@ -3536,7 +3484,7 @@ { "Name": "errorsastype", "Doc": "replace errors.As with errors.AsType[T]\n\nThis analyzer suggests fixes to simplify uses of [errors.As] of\nthis form:\n\n\tvar myerr *MyErr\n\tif errors.As(err, \u0026myerr) {\n\t\thandle(myerr)\n\t}\n\nby using the less error-prone generic [errors.AsType] function,\nintroduced in Go 1.26:\n\n\tif myerr, ok := errors.AsType[*MyErr](err); ok {\n\t\thandle(myerr)\n\t}\n\nThe fix is only offered if the var declaration has the form shown and\nthere are no uses of myerr outside the if statement.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_errorsastype", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#errorsastype", "Default": true }, { @@ -3560,13 +3508,13 @@ { "Name": "fmtappendf", "Doc": "replace []byte(fmt.Sprintf) with fmt.Appendf\n\nThe fmtappendf analyzer suggests replacing `[]byte(fmt.Sprintf(...))` with\n`fmt.Appendf(nil, ...)`. This avoids the intermediate allocation of a string\nby Sprintf, making the code more efficient. The suggestion also applies to\nfmt.Sprint and fmt.Sprintln.\n\nSince its fix is not a Pareto improvement, fmtappendf is disabled by default in\nthe `go fix` analyzer suite; see golang/go#77581.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_fmtappendf", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#fmtappendf", "Default": true }, { "Name": "forvar", "Doc": "remove redundant re-declaration of loop variables\n\nThe forvar analyzer removes unnecessary shadowing of loop variables.\nBefore Go 1.22, it was common to write `for _, x := range s { x := x ... }`\nto create a fresh variable for each iteration. Go 1.22 changed the semantics\nof `for` loops, making this pattern redundant. This analyzer removes the\nunnecessary `x := x` statement.\n\nThis fix only applies to `range` loops.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_forvar", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#forvar", "Default": true }, { @@ -3593,12 +3541,6 @@ "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/ifaceassert", "Default": true }, - { - "Name": "importcomment", - "Doc": "remove obsolete comments specifying canonical import path\n\nThe importcomment analyzer removes comments specifying the canonical\nimport path, such as\n\n\tpackage foo // import \"example.com/foo\"\n\nThe go command enforced these comments in GOPATH mode via \"go get\", but\nignores them in module mode, so they are obsolete once the package\nbelongs to a module. The fix removes the comment.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_importcomment", - "Default": true - }, { "Name": "infertypeargs", "Doc": "check for unnecessary type arguments in call expressions\n\nExplicit type arguments may be omitted from call expressions if they can be\ninferred from function arguments, or from other type arguments:\n\n\tfunc f[T any](T) {}\n\t\n\tfunc _() {\n\t\tf[string](\"foo\") // string could be inferred\n\t}\n", @@ -3632,19 +3574,19 @@ { "Name": "mapsloop", "Doc": "replace explicit loops over maps with calls to maps package\n\nThe mapsloop analyzer replaces loops of the form\n\n\tfor k, v := range x { m[k] = v }\n\nwith a single call to a function from the `maps` package, added in Go 1.23.\nDepending on the context, this could be `maps.Copy`, `maps.Insert`,\n`maps.Clone`, or `maps.Collect`.\n\nThe transformation to `maps.Clone` is applied conservatively, as it\npreserves the nilness of the source map, which may be a subtle change in\nbehavior if the original code did not handle a nil map in the same way.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_mapsloop", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#mapsloop", "Default": true }, { "Name": "minmax", "Doc": "replace if/else statements with calls to min or max\n\nThe minmax analyzer simplifies conditional assignments by suggesting the use\nof the built-in `min` and `max` functions, introduced in Go 1.21. For example,\n\n\tif a \u003c b { x = a } else { x = b }\n\nis replaced by\n\n\tx = min(a, b).\n\nThis analyzer avoids making suggestions for floating-point types,\nas the behavior of `min` and `max` with NaN values can differ from\nthe original if/else statement.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_minmax", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#minmax", "Default": true }, { "Name": "newexpr", "Doc": "simplify code by using go1.26's new(expr)\n\nThis analyzer finds declarations of functions of this form:\n\n\tfunc varOf(x int) *int { return \u0026x }\n\nand suggests a fix to turn them into inlinable wrappers around\ngo1.26's built-in new(expr) function:\n\n\t//go:fix inline\n\tfunc varOf(x int) *int { return new(x) }\n\n(The directive comment causes the 'inline' analyzer to suggest\nthat calls to such functions are inlined.)\n\nIn addition, this analyzer suggests a fix for each call\nto one of the functions before it is transformed, so that\n\n\tuse(varOf(123))\n\nis replaced by:\n\n\tuse(new(123))\n\nWrapper functions such as varOf are common when working with Go\nserialization packages such as for JSON or protobuf, where pointers\nare often used to express optionality.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_newexpr", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#newexpr", "Default": true }, { @@ -3674,13 +3616,13 @@ { "Name": "omitzero", "Doc": "suggest replacing omitempty with omitzero for struct fields\n\nThe omitzero analyzer identifies uses of the `omitempty` JSON struct\ntag on fields that are themselves structs. For struct-typed fields,\nthe `omitempty` tag has no effect on the behavior of json.Marshal and\njson.Unmarshal. The analyzer offers two suggestions: either remove the\ntag, or replace it with `omitzero` (added in Go 1.24), which correctly\nomits the field if the struct value is zero.\n\nHowever, some other serialization packages (notably kubebuilder, see\nhttps://book.kubebuilder.io/reference/markers.html) may have their own\ninterpretation of the `json:\",omitzero\"` tag, so removing it may affect\nprogram behavior. For this reason, the omitzero modernizer will not\nmake changes in any package that contains +kubebuilder annotations.\n\nReplacing `omitempty` with `omitzero` is a change in behavior. The\noriginal code would always encode the struct field, whereas the\nmodified code will omit it if it is a zero-value.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_omitzero", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#omitzero", "Default": true }, { "Name": "plusbuild", "Doc": "remove obsolete //+build comments\n\nThe plusbuild analyzer suggests a fix to remove obsolete build tags\nof the form:\n\n\t//+build linux,amd64\n\nin files that also contain a Go 1.18-style tag such as:\n\n\t//go:build linux \u0026\u0026 amd64\n\n(It does not check that the old and new tags are consistent;\nthat is the job of the 'buildtag' analyzer in the vet suite.)", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_plusbuild", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#plusbuild", "Default": true }, { @@ -3689,16 +3631,10 @@ "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/printf", "Default": true }, - { - "Name": "ptrtoerror", - "Doc": "detect inconsistent conversions of concrete types to error\n\nThe ptrtoerror analyzer detects when a concrete type E is converted\nto the error interface inconsistently, both as a value of type E\nand as a pointer of type *E. Such inconsistency defeats attempts by\nclient code to test for specific error types using type assertions\nor library functions such as [errors.As] and [errors.Is].\n\nThe analyzer also detects when both E and *E implement error but\nneither of those types is converted to error within the defining\npackage, leaving the intended error form (E or *E) ambiguous. This\ndiagnostic offers two alternative fixes to add declarations that\nmake the intent explicit.", - "URL": "https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/ptrtoerror", - "Default": true - }, { "Name": "rangeint", "Doc": "replace 3-clause for loops with for-range over integers\n\nThe rangeint analyzer suggests replacing traditional for loops such\nas\n\n\tfor i := 0; i \u003c n; i++ { ... }\n\nwith the more idiomatic Go 1.22 style:\n\n\tfor i := range n { ... }\n\nThis transformation is applied only if (a) the loop variable is not\nmodified within the loop body and (b) the loop's limit expression\nis not modified within the loop, as `for range` evaluates its\noperand only once.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_rangeint", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#rangeint", "Default": true }, { @@ -3707,16 +3643,10 @@ "URL": "https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/recursiveiter", "Default": true }, - { - "Name": "reflecttypeassert", - "Doc": "replace v.Interface().(T) with reflect.TypeAssert[T](v)\n\nThis analyzer suggests fixes to replace two-valued type assertions on\nthe result of (reflect.Value).Interface with reflect.TypeAssert,\nintroduced in go1.25, which avoids the intermediate allocation of an\ninterface value, for example:\n\n\tx, ok := v.Interface().(string) -\u003e x, ok := reflect.TypeAssert[string](v)\n\nNo fix is offered for single-valued assertions, since they panic when\nthe assertion fails whereas reflect.TypeAssert does not. Nor is a fix\noffered for a type switch.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_reflecttypeassert", - "Default": true - }, { "Name": "reflecttypefor", "Doc": "replace reflect.TypeOf(x) with TypeFor[T]()\n\nThis analyzer suggests fixes to replace uses of reflect.TypeOf(x) with\nreflect.TypeFor, introduced in go1.22, when the desired runtime type\nis known at compile time, for example:\n\n\treflect.TypeOf(uint32(0)) -\u003e reflect.TypeFor[uint32]()\n\treflect.TypeOf((*ast.File)(nil)) -\u003e reflect.TypeFor[*ast.File]()\n\nIt also offers a fix to simplify the constructions below, which use\nreflect.TypeOf to return the runtime type for an interface type,\n\n\treflect.TypeOf((*io.Reader)(nil)).Elem()\n\nor:\n\n\treflect.TypeOf([]io.Reader(nil)).Elem()\n\nto:\n\n\treflect.TypeFor[io.Reader]()\n\nNo fix is offered in cases when the runtime type is dynamic, such as:\n\n\tvar r io.Reader = ...\n\treflect.TypeOf(r)\n\nor when the operand has potential side effects.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_reflecttypefor", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#reflecttypefor", "Default": true }, { @@ -3764,31 +3694,25 @@ { "Name": "slicesbackward", "Doc": "replace backward loops over slices with slices.Backward\n\nThe slicesbackward analyzer suggests replacing manually-written backward\nloops of the form\n\n\tfor i := len(s) - 1; i \u003e= 0; i-- {\n\t use(s[i])\n\t}\n\nwith the more readable Go 1.23 style using slices.Backward:\n\n\tfor _, v := range slices.Backward(s) {\n\t use(v)\n\t}\n\nIf the loop index is needed beyond just indexing into the slice, both\nthe index and value variables are kept:\n\n\tfor i, v := range slices.Backward(s) { ... }", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicesbackward", - "Default": true - }, - { - "Name": "slicesclip", - "Doc": "replace three-index slice expressions with slices.Clip\n\nThe slicesclip analyzer suggests replacing a full slice expression of\nthe form\n\n\tx[:len(x):len(x)]\n\nwhich clips the capacity of a slice to its length, with the simpler\nand more readable\n\n\tslices.Clip(x)\n\nadded in Go 1.21.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicesclip", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#slicesbackward", "Default": true }, { "Name": "slicescontains", "Doc": "replace loops with slices.Contains or slices.ContainsFunc\n\nThe slicescontains analyzer simplifies loops that check for the existence of\nan element in a slice. It replaces them with calls to `slices.Contains` or\n`slices.ContainsFunc`, which were added in Go 1.21.\n\nIf the expression for the target element has side effects, this\ntransformation will cause those effects to occur only once, not\nonce per tested slice element.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicescontains", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#slicescontains", "Default": true }, { "Name": "slicesdelete", "Doc": "replace append-based slice deletion with slices.Delete\n\nThe slicesdelete analyzer suggests replacing the idiom\n\n\ts = append(s[:i], s[j:]...)\n\nwith the more explicit\n\n\ts = slices.Delete(s, i, j)\n\nintroduced in Go 1.21.\n\nThis analyzer is disabled by default. The `slices.Delete` function\nzeros the elements between the new length and the old length of the\nslice to prevent memory leaks, which is a subtle difference in\nbehavior compared to the append-based idiom; see https://go.dev/issue/73686.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicesdelete", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#slicesdelete", "Default": false }, { "Name": "slicessort", "Doc": "replace sort.Slice with slices.Sort for basic types\n\nThe slicessort analyzer simplifies sorting slices of basic ordered\ntypes. It replaces\n\n\tsort.Slice(s, func(i, j int) bool { return s[i] \u003c s[j] })\n\nwith the simpler `slices.Sort(s)`, which was added in Go 1.21.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_slicessort", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#slicessort", "Default": true }, { @@ -3811,8 +3735,8 @@ }, { "Name": "stditerators", - "Doc": "use iterators instead of Len/At-style APIs\n\nThis analyzer suggests a fix to replace each loop of the form:\n\n\tfor i := 0; i \u003c x.Len(); i++ {\n\t\tuse(x.At(i))\n\t}\n\nor its \"for elem := range x.Len()\" equivalent by a range loop over an\niterator offered by the same data type:\n\n\tfor elem := range x.All() {\n\t\tuse(elem)\n\t}\n\nwhere x is one of various well-known types in the standard library.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stditerators", + "Doc": "use iterators instead of Len/At-style APIs\n\nThis analyzer suggests a fix to replace each loop of the form:\n\n\tfor i := 0; i \u003c x.Len(); i++ {\n\t\tuse(x.At(i))\n\t}\n\nor its \"for elem := range x.Len()\" equivalent by a range loop over an\niterator offered by the same data type:\n\n\tfor elem := range x.All() {\n\t\tuse(x.At(i)\n\t}\n\nwhere x is one of various well-known types in the standard library.", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stditerators", "Default": true }, { @@ -3836,25 +3760,25 @@ { "Name": "stringsbuilder", "Doc": "replace += with strings.Builder\n\nThis analyzer replaces repeated string += string concatenation\noperations with calls to Go 1.10's strings.Builder.\n\nFor example:\n\n\tvar s = \"[\"\n\tfor x := range seq {\n\t\ts += x\n\t\ts += \".\"\n\t}\n\ts += \"]\"\n\tuse(s)\n\nis replaced by:\n\n\tvar s strings.Builder\n\ts.WriteString(\"[\")\n\tfor x := range seq {\n\t\ts.WriteString(x)\n\t\ts.WriteString(\".\")\n\t}\n\ts.WriteString(\"]\")\n\tuse(s.String())\n\nThis avoids quadratic memory allocation and improves performance.\n\nNo diagnostics are issued in tests, where data sizes are often\nsmall and asymptotic performance is not a security concern.\n\nThe analyzer requires that all references to s before the final uses\nare += operations. To avoid warning about trivial cases, at least one\nmust appear within a loop. The variable s must be a local\nvariable, not a global or parameter.\n\nAll uses of the finished string must come after the last += operation.\nEach such use will be replaced by a call to strings.Builder's String method.\n(These may appear within an intervening loop or function literal, since even\nif s.String() is called repeatedly, it does not allocate memory.)\n\nOften the addend is a call to fmt.Sprintf, as in this example:\n\n\tvar s string\n\tfor x := range seq {\n\t\ts += fmt.Sprintf(\"%v\", x)\n\t}\n\nwhich, once the suggested fix is applied, becomes:\n\n\tvar s strings.Builder\n\tfor x := range seq {\n\t\ts.WriteString(fmt.Sprintf(\"%v\", x))\n\t}\n\nThe WriteString call can be further simplified to the more efficient\nfmt.Fprintf(\u0026s, \"%v\", x), avoiding the allocation of an intermediary.\nHowever, stringsbuilder does not perform this simplification;\nit requires staticcheck analyzer QF1012. (See https://go.dev/issue/76918.)", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stringsbuilder", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stringbuilder", "Default": true }, { "Name": "stringscut", "Doc": "replace strings.Index etc. with strings.Cut\n\nThis analyzer replaces certain patterns of use of [strings.Index] and string slicing by [strings.Cut], added in go1.18.\n\nFor example:\n\n\tidx := strings.Index(s, substr)\n\tif idx \u003e= 0 {\n\t return s[:idx]\n\t}\n\nis replaced by:\n\n\tbefore, _, ok := strings.Cut(s, substr)\n\tif ok {\n\t return before\n\t}\n\nAnd:\n\n\tidx := strings.Index(s, substr)\n\tif idx \u003e= 0 {\n\t return\n\t}\n\nis replaced by:\n\n\tfound := strings.Contains(s, substr)\n\tif found {\n\t return\n\t}\n\nIt also handles variants using [strings.IndexByte] instead of Index, or the bytes package instead of strings.\n\nFixes are offered only in cases in which there are no potential modifications of the idx, s, or substr expressions between their definition and use.\n\nIt also replaces [strings.SplitN](s, sep, 2)[0] and [strings.Split](s, sep)[0] with the \"before\" result of strings.Cut, when sep is a non-empty string constant:\n\n\tx := strings.SplitN(s, sep, 2)[0]\n\nis replaced by:\n\n\tx, _, _ := strings.Cut(s, sep)\n\nThe fix is only offered when sep is a non-empty string literal. When sep is a variable or the empty string, the semantics differ (strings.Split(s, \"\")[0] returns the first character of s, but strings.Cut(s, \"\").before is \"\"), so no fix is suggested.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stringscut", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stringscut", "Default": true }, { "Name": "stringscutprefix", "Doc": "replace HasPrefix/TrimPrefix with CutPrefix\n\nThe stringscutprefix analyzer simplifies a common pattern where code first\nchecks for a prefix with `strings.HasPrefix` and then removes it with\n`strings.TrimPrefix`. It replaces this two-step process with a single call\nto `strings.CutPrefix`, introduced in Go 1.20. The analyzer also handles\nthe equivalent functions in the `bytes` package.\n\nFor example, this input:\n\n\tif strings.HasPrefix(s, prefix) {\n\t use(strings.TrimPrefix(s, prefix))\n\t}\n\nis fixed to:\n\n\tif after, ok := strings.CutPrefix(s, prefix); ok {\n\t use(after)\n\t}\n\nThe analyzer also offers fixes to use CutSuffix in a similar way.\nThis input:\n\n\tif strings.HasSuffix(s, suffix) {\n\t use(strings.TrimSuffix(s, suffix))\n\t}\n\nis fixed to:\n\n\tif before, ok := strings.CutSuffix(s, suffix); ok {\n\t use(before)\n\t}", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stringscutprefix", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stringscutprefix", "Default": true }, { "Name": "stringsseq", "Doc": "replace ranging over Split/Fields with SplitSeq/FieldsSeq\n\nThe stringsseq analyzer improves the efficiency of iterating over substrings.\nIt replaces\n\n\tfor range strings.Split(...)\n\nwith the more efficient\n\n\tfor range strings.SplitSeq(...)\n\nwhich was added in Go 1.24 and avoids allocating a slice for the\nsubstrings. The analyzer also handles strings.Fields and the\nequivalent functions in the bytes package.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_stringsseq", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#stringsseq", "Default": true }, { @@ -3866,7 +3790,7 @@ { "Name": "testingcontext", "Doc": "replace context.WithCancel with t.Context in tests\n\nThe testingcontext analyzer simplifies context management in tests. It\nreplaces the manual creation of a cancellable context,\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\nwith a single call to t.Context(), which was added in Go 1.24.\n\nThis change is only suggested if the `cancel` function is not used\nfor any other purpose.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_testingcontext", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#testingcontext", "Default": true }, { @@ -3902,7 +3826,7 @@ { "Name": "unsafefuncs", "Doc": "replace unsafe pointer arithmetic with function calls\n\nThe unsafefuncs analyzer simplifies pointer arithmetic expressions by\nreplacing them with calls to helper functions such as unsafe.Add,\nadded in Go 1.17.\n\nExample:\n\n\tunsafe.Pointer(uintptr(ptr) + uintptr(n))\n\nwhere ptr is an unsafe.Pointer, is replaced by:\n\n\tunsafe.Add(ptr, n)", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_unsafefuncs", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#unsafefuncs", "Default": true }, { @@ -3950,7 +3874,7 @@ { "Name": "waitgroupgo", "Doc": "replace wg.Add(1)/go/wg.Done() with wg.Go\n\nThe waitgroupgo analyzer simplifies goroutine management with `sync.WaitGroup`.\nIt replaces the common pattern\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\t...\n\t}()\n\nwith a single call to\n\n\twg.Go(func(){ ... })\n\nwhich was added in Go 1.25.", - "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#hdr-Analyzer_waitgroupgo", + "URL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize#waitgroupgo", "Default": true }, { @@ -3999,7 +3923,7 @@ }, { "Name": "ignoredError", - "Doc": "`\"ignoredError\"` inlay hints for implicitly discarded errors:\n```go\n\tf.Close()« // ignore error»\n```\nThis check inserts an `// ignore error` hint following any\nstatement that is a function call whose error result is\nimplicitly ignored.\n\nTo suppress the hint, write an actual comment containing\none of the following strings:\n```\nignore error\ndiscard error\ncan't fail\ncannot fail\n```\nfollowing the call statement, or explicitly assign the\nresult to a blank variable.\n\nA handful of common functions such as `fmt.Println` are\nexcluded from the check.\n", + "Doc": "`\"ignoredError\"` inlay hints for implicitly discarded errors:\n```go\n\tf.Close()« // ignore error»\n```\nThis check inserts an `// ignore error` hint following any\nstatement that is a function call whose error result is\nimplicitly ignored.\n\nTo suppress the hint, write an actual comment containing\n\"ignore error\" following the call statement, or explicitly\nassign the result to a blank variable. A handful of common\nfunctions such as `fmt.Println` are excluded from the\ncheck.\n", "Default": false, "Status": "" }, diff --git a/vendor/golang.org/x/tools/gopls/internal/filecache/filecache.go b/vendor/golang.org/x/tools/gopls/internal/filecache/filecache.go index 44db48e153..c668a3a55c 100644 --- a/vendor/golang.org/x/tools/gopls/internal/filecache/filecache.go +++ b/vendor/golang.org/x/tools/gopls/internal/filecache/filecache.go @@ -38,35 +38,16 @@ import ( "sync/atomic" "time" - "golang.org/x/telemetry/counter" "golang.org/x/tools/gopls/internal/util/bug" "golang.org/x/tools/gopls/internal/util/lru" ) -// Start causes the filecache to initialize and start garbage collection. +// Start causes the filecache to initialize and start garbage gollection. // // Start is automatically called by the first call to Get, but may be called // explicitly to pre-initialize the cache. func Start() { - go func() { - // Force early creation of the filecache and refuse to start - // if there were unexpected errors such as ENOSPC. This - // minimizes the window of exposure to deletion of the - // executable, and ensures that all subsequent calls to - // filecache.Get cannot fail for these two reasons; - // see issue #67433. - // - // This leaves only one likely cause for later failures: - // deletion of the cache while gopls is running. If the - // problem continues, we could periodically stat the cache - // directory (for example at the start of every RPC) and - // either re-create it or just fail the RPC with an - // informative error and terminate the process. - if _, err := Get("nonesuch", [32]byte{}, Bytes); err != nil && err != ErrNotFound { - counter.Inc("gopls/nocache") - log.Fatalf("gopls cannot access its persistent index (disk full?): %v", err) - } - }() + go getCacheDir() // ignore error } // memCache is a 100MB in-memory LRU cache in front of filecache @@ -425,59 +406,56 @@ func filename(kind string, key [32]byte) (string, error) { // It must incorporate the hash of the executable so that we needn't // worry about incompatible changes to the file format or changes to // the algorithm that produced the index. -var getCacheDir = sync.OnceValues(func() (string, error) { - // Use user's preferred cache directory. - userDir := os.Getenv("GOPLSCACHE") - if userDir == "" { - var err error - userDir, err = os.UserCacheDir() - if err != nil { - userDir = os.TempDir() +func getCacheDir() (string, error) { + cacheDirOnce.Do(func() { + // Use user's preferred cache directory. + userDir := os.Getenv("GOPLSCACHE") + if userDir == "" { + var err error + userDir, err = os.UserCacheDir() + if err != nil { + userDir = os.TempDir() + } + } + goplsDir := filepath.Join(userDir, "gopls") + + // UserCacheDir may return a nonexistent directory + // (in which case we must create it, which may fail), + // or it may return a non-writable directory, in + // which case we should ideally respect the user's express + // wishes (e.g. XDG_CACHE_HOME) and not write somewhere else. + // Sadly UserCacheDir doesn't currently let us distinguish + // such intent from accidental misconfiguraton such as HOME=/ + // in a CI builder. So, we check whether the gopls subdirectory + // can be created (or already exists) and not fall back to /tmp. + // See also https://github.com/golang/go/issues/57638. + if os.MkdirAll(goplsDir, 0700) != nil { + goplsDir = filepath.Join(os.TempDir(), "gopls") } - } - goplsDir := filepath.Join(userDir, "gopls") - - // UserCacheDir may return a nonexistent directory - // (in which case we must create it, which may fail), - // or it may return a non-writable directory, in - // which case we should ideally respect the user's express - // wishes (e.g. XDG_CACHE_HOME) and not write somewhere else. - // Sadly UserCacheDir doesn't currently let us distinguish - // such intent from accidental misconfiguraton such as HOME=/ - // in a CI builder. So, we check whether the gopls subdirectory - // can be created (or already exists) and not fall back to /tmp. - // See also https://github.com/golang/go/issues/57638. - if os.MkdirAll(goplsDir, 0700) != nil { - goplsDir = filepath.Join(os.TempDir(), "gopls") - } - // Start the garbage collector. - go gc(goplsDir) + // Start the garbage collector. + go gc(goplsDir) - // Compute the hash of this executable (~20ms) and create a subdirectory. - hash, err := hashExecutable() - if err != nil { - return "", ErrNoCache{fmt.Errorf("can't hash gopls executable: %w", err)} - } - // Use only 32 bits of the digest to avoid unwieldy filenames. - // It's not an adversarial situation. - cacheDir := filepath.Join(goplsDir, fmt.Sprintf("%x", hash[:4])) - if err := os.MkdirAll(cacheDir, 0700); err != nil { - return "", ErrNoCache{fmt.Errorf("can't create cache: %w", err)} - } - // ...but record the full digest to detect collisions. - // The birthday paradox P(k) = 1 - exp(-k^2 / (2N)), where N = 1<<32, - // gives 50% odds of a 32-bit collision even with >77K different executables. - shaFile := filepath.Join(cacheDir, "exe.sha256") - if prev, err := os.ReadFile(shaFile); err == nil && !bytes.Equal(prev, hash[:]) { - return "", ErrNoCache{fmt.Errorf("gopls cache directory %s hash collision (%x vs %x)", cacheDir, prev, hash[:])} - } - if err := writeFileNoTrunc(shaFile, hash[:], 0600); err != nil { - return "", ErrNoCache{fmt.Errorf("can't write executable hash: %w", err)} - } + // Compute the hash of this executable (~20ms) and create a subdirectory. + hash, err := hashExecutable() + if err != nil { + cacheDirErr = ErrNoCache{fmt.Errorf("can't hash gopls executable: %w", err)} + } + // Use only 32 bits of the digest to avoid unwieldy filenames. + // It's not an adversarial situation. + cacheDir = filepath.Join(goplsDir, fmt.Sprintf("%x", hash[:4])) + if err := os.MkdirAll(cacheDir, 0700); err != nil { + cacheDirErr = ErrNoCache{fmt.Errorf("can't create cache: %w", err)} + } + }) + return cacheDir, cacheDirErr +} - return cacheDir, nil -}) +var ( + cacheDirOnce sync.Once + cacheDir string + cacheDirErr error +) func hashExecutable() (hash [32]byte, err error) { exe, err := os.Executable() diff --git a/vendor/golang.org/x/tools/gopls/internal/filewatcher/poll_watcher.go b/vendor/golang.org/x/tools/gopls/internal/filewatcher/poll_watcher.go index de3f962433..a48b8c358e 100644 --- a/vendor/golang.org/x/tools/gopls/internal/filewatcher/poll_watcher.go +++ b/vendor/golang.org/x/tools/gopls/internal/filewatcher/poll_watcher.go @@ -19,8 +19,8 @@ import ( "golang.org/x/tools/gopls/internal/settings" "golang.org/x/tools/gopls/internal/util/bug" "golang.org/x/tools/gopls/internal/util/frob" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/moremaps" ) /* diff --git a/vendor/golang.org/x/tools/gopls/internal/goasm/definition.go b/vendor/golang.org/x/tools/gopls/internal/goasm/definition.go index 632986db09..74a27ce064 100644 --- a/vendor/golang.org/x/tools/gopls/internal/goasm/definition.go +++ b/vendor/golang.org/x/tools/gopls/internal/goasm/definition.go @@ -2,15 +2,21 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// Package goasm provides language-server features for files in Go +// assembly language (https://go.dev/doc/asm). package goasm import ( "context" + "fmt" "go/token" "golang.org/x/tools/gopls/internal/cache" + "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/file" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/util/asm" + "golang.org/x/tools/gopls/internal/util/morestrings" "golang.org/x/tools/internal/event" ) @@ -19,32 +25,102 @@ func Definition(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, r ctx, done := event.Start(ctx, "goasm.Definition") defer done() - res, err := resolve(ctx, snapshot, fh, rng) + mp, err := snapshot.NarrowestMetadataForFile(ctx, fh.URI()) if err != nil { return nil, err } - // Package-qualified symbol: jump to its Go declaration. - if res.obj != nil { - pos := res.obj.Pos() - pgf, err := res.pkg.FileEnclosing(pos) + // Read the file. + content, err := fh.Content() + if err != nil { + return nil, err + } + mapper := protocol.NewMapper(fh.URI(), content) + start, end, err := mapper.RangeOffsets(rng) + if err != nil { + return nil, err + } + + // Parse the assembly. + // + // TODO(adonovan): make this just another + // attribute of the type-checked cache.Package. + file := asm.Parse(content) + + // Figure out the selected symbol. + // For now, just find the identifier around the cursor. + var found *asm.Ident + for _, id := range file.Idents { + if id.Offset <= start && end <= id.End() { + found = &id + break + } + } + if found == nil { + return nil, fmt.Errorf("not an identifier") + } + + // Resolve a symbol with a "." prefix to the current package. + sym := found.Name + if sym != "" && sym[0] == '.' { + sym = string(mp.PkgPath) + sym + } + + // package-qualified symbol? + if pkgpath, name, ok := morestrings.CutLast(sym, "."); ok { + // Find declaring package among dependencies. + // + // TODO(adonovan): assembly may legally reference + // non-dependencies. For example, sync/atomic calls + // internal/runtime/atomic. Perhaps we should search + // the entire metadata graph, but that's path-dependent. + var declaring *metadata.Package + for pkg := range snapshot.MetadataGraph().ForwardReflexiveTransitiveClosure(mp.ID) { + if pkg.PkgPath == metadata.PackagePath(pkgpath) { + declaring = pkg + break + } + } + if declaring == nil { + return nil, fmt.Errorf("package %q is not a dependency", pkgpath) + } + + // Find declared symbol in syntax package. + pkgs, err := snapshot.TypeCheck(ctx, declaring.ID) if err != nil { return nil, err } - loc, err := pgf.PosLocation(pos, pos+token.Pos(len(res.obj.Name()))) + pkg := pkgs[0] + def := pkg.Types().Scope().Lookup(name) + if def == nil { + return nil, fmt.Errorf("no symbol %q in package %q", name, pkgpath) + } + + // Map position. + pos := def.Pos() + pgf, err := pkg.FileEnclosing(pos) if err != nil { return nil, err } - return []protocol.Location{loc}, nil - } - - // Local symbol: jump to its definition in the assembly file. - if res.localDef != nil { - loc, err := res.file.Mapper.OffsetLocation(res.localDef.Offset, res.localDef.End()) + loc, err := pgf.PosLocation(pos, pos+token.Pos(len(name))) if err != nil { return nil, err } return []protocol.Location{loc}, nil + + } else { + // local symbols (funcs, vars, labels) + for _, id := range file.Idents { + if id.Name == found.Name && + (id.Kind == asm.Text || id.Kind == asm.Global || id.Kind == asm.Label) { + + loc, err := mapper.OffsetLocation(id.Offset, id.End()) + if err != nil { + return nil, err + } + return []protocol.Location{loc}, nil + } + } } return nil, nil diff --git a/vendor/golang.org/x/tools/gopls/internal/goasm/highlight.go b/vendor/golang.org/x/tools/gopls/internal/goasm/highlight.go deleted file mode 100644 index ad0b7c51af..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/goasm/highlight.go +++ /dev/null @@ -1,483 +0,0 @@ -// Copyright 2025 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 goasm - -import ( - "bytes" - "context" - "strings" - - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/asm" - "golang.org/x/tools/internal/event" -) - -// Highlight handles the textDocument/documentHighlight request for Go -// assembly files. -// -// If the cursor is on a symbol identifier, all occurrences of the same -// name in the file are highlighted: definitions (TEXT, GLOBL) as Write, -// references as Read. Control labels are function-scoped, so for a label -// only occurrences within the enclosing TEXT function are highlighted. -// -// If the cursor is on a machine register, all occurrences of that -// register within the enclosing TEXT function are highlighted, -// approximating its def/use chain: occurrences classified as -// definitions are Write, uses are Read. Register highlighting requires -// a GOARCH file name suffix (e.g. *_amd64.s, *_arm64.s). -func Highlight(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, rng protocol.Range) ([]protocol.DocumentHighlight, error) { - ctx, done := event.Start(ctx, "goasm.Highlight") - defer done() - - content, err := fh.Content() - if err != nil { - return nil, err - } - - asmFile := asm.Parse(fh.URI(), content) - - start, end, err := asmFile.Mapper.RangeOffsets(rng) - if err != nil { - return nil, err - } - - // Identifier (symbol or label) under the cursor? - if found := asmFile.IdentAt(start, end); found != nil { - return highlightIdents(asmFile, found) - } - - // Register under the cursor? - return highlightRegister(asmFile, start) -} - -// highlightIdents highlights every identifier with the same name as -// found. Definitions are Write; references are Read. If the name denotes -// a control label (it has a label definition in the file), only -// occurrences within the enclosing TEXT function are highlighted, since -// labels are function-scoped and the same label name may be reused in -// different functions. -func highlightIdents(file *asm.File, found *asm.Ident) ([]protocol.DocumentHighlight, error) { - // Heuristic: if the name is used as a label anywhere in the file, - // assume every occurrence is a label. A label and a global symbol - // sharing a name is implausible in practice, so per-occurrence - // disambiguation is not worth the cost. - lo, hi := 0, len(file.Mapper.Content) - for _, id := range file.Idents { - if id.Kind == asm.Label && id.Name == found.Name { - lo, hi = file.FunctionRange(found.Offset) - break - } - } - - var highlights []protocol.DocumentHighlight - for _, id := range file.Idents { - if id.Name != found.Name || !(lo <= id.Offset && id.Offset < hi) { - continue - } - idRange, err := file.IdentRange(id) - if err != nil { - return nil, err - } - kind := protocol.Read - if id.Kind == asm.Text || id.Kind == asm.Global || id.Kind == asm.Label { - kind = protocol.Write - } - highlights = append(highlights, protocol.DocumentHighlight{ - Range: idRange, - Kind: kind, - }) - } - return highlights, nil -} - -// highlightRegister highlights all occurrences of the register under the -// cursor within the enclosing TEXT function. -func highlightRegister(file *asm.File, offset int) ([]protocol.DocumentHighlight, error) { - content := file.Mapper.Content - arch := fileArch(file.Mapper.URI.Base()) - if arch == "" { - return nil, nil - } - word, wordStart := wordAt(content, offset) - if word == "" || !isRegisterWord(word) || inComment(content, offset) { - return nil, nil - } - // The first word on a line is the mnemonic, not a register. - if isLineStart(content, wordStart) { - return nil, nil - } - - funcStart, funcEnd := file.FunctionRange(offset) - var highlights []protocol.DocumentHighlight - pos := funcStart - for pos < funcEnd { - i := bytes.Index(content[pos:funcEnd], []byte(word)) - if i < 0 { - break - } - absOff := pos + i - pos = absOff + len(word) - // Skip occurrences inside comments, within a larger word - // (e.g. "AX" in "MAX"), or at the start of a line (mnemonic). - if inComment(content, absOff) || - !isWordBoundary(content, absOff, absOff+len(word)) || - isLineStart(content, absOff) { - continue - } - rng, err := file.Mapper.OffsetRange(absOff, absOff+len(word)) - if err != nil { - return nil, err - } - highlights = append(highlights, protocol.DocumentHighlight{ - Range: rng, - Kind: registerKind(content, absOff, arch), - }) - } - return highlights, nil -} - -// fileArch returns the GOARCH suffix of an assembly file's base name. It -// returns "" for unsupported architectures and for file names without a -// GOARCH suffix (which select their architecture using build constraints); -// register highlighting is not yet supported for those files. -func fileArch(base string) string { - name, ok := strings.CutSuffix(base, ".s") - if !ok { - return "" - } - if i := strings.LastIndexByte(name, '_'); i >= 0 { - arch := name[i+1:] - switch arch { - case "386", "amd64", "arm64": - return arch - } - } - return "" -} - -// registerKind classifies the register occurrence at offset (a byte -// offset within content) as Read or Write, where arch is the file's -// GOARCH ("386", "amd64", or "arm64"). It follows the Plan 9 -// assembly convention that the destination operand is the last -// operand: a register in the last operand is a definition (Write), and a -// register in any earlier operand is a use (Read), with three exceptions: -// -// - A register inside parentheses is part of a memory address operand -// (as in (AX) or 8(AX)(BX*4)) and is always Read, even in the -// destination operand of a store. A parenthesized register pair, -// such as the (R4, R5) of arm64 LDP/STP, is not a memory address -// but a single operand in its own right, and is classified by its -// position like any other operand; see enclosingGroup. -// - Comparison and test instructions (x86: CMP, TEST, COMIS*, UCOMIS*, -// BT*; arm64: CMP, CMN, TST) have no destination, so all their -// operands are Read. -// - Single-operand instructions write their operand only in a few -// cases, all x86-specific: POP stores into it, INC/DEC/NEG/NOT/BSWAP -// update it in place, and SETcc sets it to 0 or 1. For all others -// (PUSH, MUL/DIV, ...) the operand is a source and is Read. -// -// Implicit register operands are not modeled — for example MUL/DIV -// clobber DX:AX, CALL may clobber CX, and the post-increment forms such -// as arm64 LDP.P update their base register — so occurrences in such -// instructions may be misclassified. -// -// TODO(golang/go#71754): model implicit operands. -// -// TODO(golang/go#71754): consider linking instruction mnemonics to -// their CPU documentation (e.g. https://www.felixcloutier.com/x86/movzx). -func registerKind(content []byte, offset int, arch string) protocol.DocumentHighlightKind { - // Find the line containing offset. - lineStart := offset - for lineStart > 0 && content[lineStart-1] != '\n' { - lineStart-- - } - lineEnd := offset - for lineEnd < len(content) && content[lineEnd] != '\n' { - lineEnd++ - } - line := content[lineStart:lineEnd] - // Strip a trailing comment so its commas and parentheses are not - // mistaken for operand syntax. - if i := bytes.Index(line, []byte("//")); i >= 0 { - line = line[:i] - } - - // A register inside parentheses is a memory address: always Read, - // unless the parentheses enclose a register pair, in which case the - // pair is classified by its position as a whole. - rel := offset - lineStart - if open, isPair := enclosingGroup(line, rel); open >= 0 { - if !isPair { - return protocol.Read - } - rel = open // classify the pair by the position of its '(' - } - - // Identify the mnemonic: the first non-space token on the line. - i := 0 - for i < len(line) && (line[i] == ' ' || line[i] == '\t') { - i++ - } - mnStart := i - for i < len(line) && line[i] != ' ' && line[i] != '\t' && line[i] != ',' { - i++ - } - mnemonic := string(line[mnStart:i]) - - if isCompareMnemonic(arch, mnemonic) { - return protocol.Read - } - - // The operand list starts after the mnemonic. Count top-level commas to - // determine which operand the occurrence is in; the last operand is the - // destination. - operandArea := line[i:] - relMatch := min(max(rel-i, 0), len(operandArea)) - commaBefore := topLevelCommas(operandArea[:relMatch]) - totalCommas := topLevelCommas(operandArea) - if totalCommas == 0 { - // Single-operand instruction. The write cases below are - // all x86-specific; on other architectures the operand is - // always a source. - if arch != "386" && arch != "amd64" { - return protocol.Read - } - m := strings.ToUpper(mnemonic) - if strings.HasPrefix(m, "SET") { // SETcc; also avoids trimSizeSuffix("SETEQ") = "SETE" - return protocol.Write - } - switch trimSizeSuffix(m) { - case "POP", "INC", "DEC", "NEG", "NOT", "BSWAP": - return protocol.Write - } - return protocol.Read - } - if commaBefore >= totalCommas { - return protocol.Write - } - return protocol.Read -} - -// enclosingGroup reports whether index rel of line is inside a -// parenthesized group, returning the index of the group's '(', or -1 if -// there is none, and whether the group is a register pair such as the -// (R4, R5) of arm64 LDP/STP. -// -// A group is taken to be a register pair if it contains a comma at its -// own nesting level and its '(' does not immediately follow an -// identifier. Memory address operands contain no comma at that level (as -// in (AX) or 8(AX)(BX*4)), and in a macro invocation the '(' is glued to -// the macro name (as in QR(V0, V4, V8, V12)). -func enclosingGroup(line []byte, rel int) (int, bool) { - // Find the innermost unclosed '(' before rel. - open := -1 - for depth, j := 0, rel-1; j >= 0 && open < 0; j-- { - switch line[j] { - case ')': - depth++ - case '(': - if depth == 0 { - open = j - } else { - depth-- - } - } - } - if open < 0 { - return -1, false - } - if open > 0 && isWordByte(line[open-1]) { - return open, false // macro invocation - } - depth := 0 - for j := open; j < len(line); j++ { - switch line[j] { - case '(': - depth++ - case ')': - if depth--; depth == 0 { - return open, false // closed with no comma of its own - } - case ',': - if depth == 1 { - return open, true - } - } - } - return open, false // unterminated -} - -// topLevelCommas counts the commas of s that are not nested within -// parentheses, that is, the operand separators of an instruction. -func topLevelCommas(s []byte) int { - n, depth := 0, 0 - for _, b := range s { - switch b { - case '(': - depth++ - case ')': - if depth > 0 { - depth-- - } - case ',': - if depth == 0 { - n++ - } - } - } - return n -} - -// isCompareMnemonic reports whether mnemonic is a comparison or test -// instruction on arch, whose operands are all reads (no destination). -// On arm64 these are CMP/CMN/TST (the prefixes cover the W width -// variants). On x86, BT (bit test) only reads its destination operand -// to set flags, so it is a comparison; BTS/BTR/BTC are read-modify- -// write and are not — their destination is classified as Write by the -// default rule. CMPXCHG/CMPXCHG8B/CMPXCHG16B are read-modify-write and -// are excluded from CMP prefix matching for the same reason. -// -// The x86 predicate comparisons CMPPD/CMPPS/CMPSD/CMPSS do have a -// destination, and it is their second operand rather than their last -// (as in CMPPD X1, X2, $7), so both this function and the default rule -// misclassify it as Read. Their mnemonics are also ambiguous: CMPSD and -// CMPSS name both these instructions and the operand-free string -// comparisons. -func isCompareMnemonic(arch, mnemonic string) bool { - m := strings.ToUpper(mnemonic) - switch arch { - case "arm64": - return strings.HasPrefix(m, "CMP") || - strings.HasPrefix(m, "CMN") || - strings.HasPrefix(m, "TST") - case "386", "amd64": - // Continue below with the x86 cases. - default: - return false - } - if trimSizeSuffix(m) == "BT" { - return true - } - // CMPXCHG has CMP prefix but is read-modify-write, not a compare. - if strings.HasPrefix(m, "CMPXCHG") { - return false - } - switch { - case strings.HasPrefix(m, "CMP"), - strings.HasPrefix(m, "TEST"), - strings.HasPrefix(m, "COM"), - strings.HasPrefix(m, "UCOM"): - return true - } - return false -} - -// trimSizeSuffix strips a single trailing size suffix (B/W/L/Q) from an -// instruction mnemonic, e.g. "CMPQ" -> "CMP", "BTB" -> "BT", "BTS" -> "BTS". -func trimSizeSuffix(m string) string { - if len(m) > 0 { - switch m[len(m)-1] { - case 'B', 'W', 'L', 'Q': - return m[:len(m)-1] - } - } - return m -} - -// inComment reports whether offset falls within a // line comment. -// Like [asm.Parse], it does not recognize /* */ block comments. -func inComment(content []byte, offset int) bool { - lineStart := offset - for lineStart > 0 && content[lineStart-1] != '\n' { - lineStart-- - } - return bytes.Contains(content[lineStart:offset], []byte("//")) -} - -// isWordBoundary reports whether content[start:end], which contains -// only word bytes and is nonempty, is a whole word: the bytes -// immediately before start and after end are not word bytes. -func isWordBoundary(content []byte, start, end int) bool { - if start > 0 && isWordByte(content[start-1]) { - return false - } - if end < len(content) && isWordByte(content[end]) { - return false - } - return true -} - -// wordAt returns the maximal run of ASCII word bytes ([A-Za-z0-9]) -// containing pos, together with its start offset. If the run is empty -// (pos is on a non-word byte whose left neighbor is also a non-word -// byte), wordAt returns ("", pos). -// -// Precondition: 0 <= pos <= len(content). -func wordAt(content []byte, pos int) (string, int) { - start := pos - for start > 0 && isWordByte(content[start-1]) { - start-- - } - end := pos - for end < len(content) && isWordByte(content[end]) { - end++ - } - return string(content[start:end]), start -} - -func isWordByte(b byte) bool { - return (b >= 'A' && b <= 'Z') || - (b >= 'a' && b <= 'z') || - (b >= '0' && b <= '9') || - b == '_' -} - -// isRegisterWord reports whether word looks like a machine register name: -// 2-3 ASCII uppercase letters/digits with at least one letter. (Requiring -// a letter excludes numeric immediates such as "123".) The pseudo- -// registers SB, SP, FP, and PC are excluded because they appear in almost -// every operand, so highlighting them would be noise rather than signal. -func isRegisterWord(word string) bool { - if len(word) < 2 || len(word) > 3 { - return false - } - switch word { - case "SB", "SP", "FP", "PC": - return false - } - hasLetter := false - for i := 0; i < len(word); i++ { - c := word[i] - switch { - case 'A' <= c && c <= 'Z': - hasLetter = true - case !('0' <= c && c <= '9'): - return false - } - } - return hasLetter -} - -// isLineStart reports whether offset begins a line, i.e. it is preceded -// only by whitespace or the start of the file. Callers use it to reject -// instruction mnemonics, which assumes each line holds at most one -// instruction and that it is not preceded by a label; neither holds for -// "label: RET" or for instructions separated by ';', though no such line -// appears in GOROOT for the architectures supported by fileArch. -func isLineStart(content []byte, offset int) bool { - for i := offset - 1; i >= 0; i-- { - switch content[i] { - case '\n': - return true - case ' ', '\t': - continue - default: - return false - } - } - return true // beginning of file -} diff --git a/vendor/golang.org/x/tools/gopls/internal/goasm/hover.go b/vendor/golang.org/x/tools/gopls/internal/goasm/hover.go deleted file mode 100644 index 2669581ae2..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/goasm/hover.go +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2025 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 goasm - -import ( - "context" - "fmt" - "go/ast" - "go/doc/comment" - "go/token" - "go/types" - "strings" - - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/typesinternal" -) - -// Hover handles the textDocument/hover request for Go assembly files. -func Hover(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, rng protocol.Range) (*protocol.Hover, error) { - ctx, done := event.Start(ctx, "goasm.Hover") - defer done() - - res, err := resolve(ctx, snapshot, fh, rng) - if err != nil { - return nil, err - } - if res.obj == nil { - // The cursor is not on an identifier, or the symbol has no Go - // declaration (a label or asm-only TEXT/GLOBL): there is no - // non-obvious information to report. - return nil, nil - } - - identRange, err := res.file.IdentRange(*res.found) - if err != nil { - return nil, err - } - - format := snapshot.Options().PreferredContentFormat - - return &protocol.Hover{ - Contents: protocol.MarkupContent{ - Kind: format, - Value: hoverObject(res.obj, res.pkg, format), - }, - Range: identRange, - }, nil -} - -// hoverObject formats hover text for a resolved Go object: its signature -// (in a fenced Go code block when markdown is preferred), followed by its -// doc comment. -func hoverObject(obj types.Object, pkg *cache.Package, format protocol.MarkupKind) string { - // Qualify other packages by name, not path: the full package path is - // almost always excessively verbose in hover text. - qual := typesinternal.NameRelativeTo(pkg.Types()) - signature := types.ObjectString(obj, qual) - - var b strings.Builder - if format == protocol.Markdown { - fmt.Fprintf(&b, "```go\n%s\n```", signature) - } else { - b.WriteString(signature) - } - - if doc := docCommentForObj(pkg, obj); doc != "" { - if format == protocol.Markdown { - b.WriteString("\n\n") - doctree := new(comment.Parser).Parse(doc) - printer := &comment.Printer{HeadingLevel: 3} - // Suppress the default {#Hdr-...} heading anchors, which - // clients display (as in golang.DocCommentToMarkdown). - printer.HeadingID = func(*comment.Heading) string { return "" } - b.Write(printer.Markdown(doctree)) - } else { - b.WriteByte('\n') - b.WriteString(doc) - } - } - return b.String() -} - -// docCommentForObj returns the text of the doc comment associated with the -// declaration of obj in pkg, or "" if there is none. -// -// Assembly symbols resolve to package-level Go declarations (functions, -// variables, constants, and types), so only those are handled here. -func docCommentForObj(pkg *cache.Package, obj types.Object) string { - pos := obj.Pos() - if pos == token.NoPos { - return "" - } - pgf, err := pkg.FileEnclosing(pos) - if err != nil { - return "" - } - for _, decl := range pgf.File.Decls { - switch d := decl.(type) { - case *ast.FuncDecl: - if d.Name != nil && d.Name.Pos() == pos { - return d.Doc.Text() - } - case *ast.GenDecl: - for _, spec := range d.Specs { - switch s := spec.(type) { - case *ast.TypeSpec: - if s.Name.Pos() == pos { - if t := s.Doc.Text(); t != "" { - return t - } - return d.Doc.Text() - } - case *ast.ValueSpec: - for _, name := range s.Names { - if name.Pos() == pos { - if t := s.Doc.Text(); t != "" { - return t - } - return d.Doc.Text() - } - } - } - } - } - } - return "" -} diff --git a/vendor/golang.org/x/tools/gopls/internal/goasm/references.go b/vendor/golang.org/x/tools/gopls/internal/goasm/references.go deleted file mode 100644 index abbfaa7454..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/goasm/references.go +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2025 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 goasm provides language-server features for files in Go -// assembly language (https://go.dev/doc/asm). -package goasm - -import ( - "context" - "fmt" - "go/ast" - "go/types" - "slices" - "sort" - "strings" - - "golang.org/x/tools/go/types/objectpath" - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/cache/metadata" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/asm" - - "golang.org/x/tools/internal/event" -) - -// References returns a list of locations (file and position) where the symbol under the cursor in an assembly file is referenced, -// including both Go source files and assembly files within the same package. -func References(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, position protocol.Position, includeDeclaration bool) ([]protocol.Location, error) { - ctx, done := event.Start(ctx, "goasm.References") - defer done() - - mps, err := snapshot.MetadataForFile(ctx, fh.URI(), false) - if err != nil { - return nil, err - } - metadata.RemoveIntermediateTestVariants(&mps) - if len(mps) == 0 { - return nil, fmt.Errorf("no package metadata for file %s", fh.URI()) - } - mp := mps[0] - pkgs, err := snapshot.TypeCheck(ctx, mp.ID) - if err != nil { - return nil, err - } - pkg := pkgs[0] - asmFile, err := pkg.AsmFile(fh.URI()) - if err != nil { - return nil, err // "can't happen" - } - - offset, err := asmFile.Mapper.PositionOffset(position) - if err != nil { - return nil, err - } - - // Figure out the selected symbol. - // For now, just find the identifier around the cursor. - var found *asm.Ident - for _, id := range asmFile.Idents { - if id.Offset <= offset && offset <= id.End() { - found = &id - break - } - } - if found == nil { - return nil, fmt.Errorf("not an identifier") - } - - var locations []protocol.Location - - pkgpath, name, ok := strings.CutLast(found.Name, ".") - if !ok { - return nil, fmt.Errorf("not found") - } - - // Determine the declaring package for this symbol. - var ( - declPkg = pkg - declMP = mp - symbolObj types.Object - ) - if pkgpath == "" || pkgpath == string(mp.PkgPath) { - // Same-package reference: look up in the current package. - symbolObj = pkg.Types().Scope().Lookup(name) - } else { - // Cross-package reference: find the declaring package. - // See goasm.Definition for the same approach. - var declaring *metadata.Package - for dep := range snapshot.MetadataGraph().ForwardReflexiveTransitiveClosure(mp.ID) { - if dep.PkgPath == metadata.PackagePath(pkgpath) { - declaring = dep - break - } - } - if declaring == nil { - return nil, fmt.Errorf("package %q is not a dependency", pkgpath) - } - pkgs, err = snapshot.TypeCheck(ctx, declaring.ID) - if err != nil { - return nil, err - } - declPkg = pkgs[0] - declMP = declaring - symbolObj = declPkg.Types().Scope().Lookup(name) - } - if symbolObj == nil { - return nil, fmt.Errorf("symbol %q not found in package %q", name, pkgpath) - } - - // Scan Go files in the declaring package for references to the symbol. - for _, pgf := range declPkg.CompiledGoFiles() { - for curId := range pgf.Cursor().Preorder((*ast.Ident)(nil)) { - id := curId.Node().(*ast.Ident) - curObj := declPkg.TypesInfo().ObjectOf(id) - if curObj != symbolObj { - continue - } - if !includeDeclaration && declPkg.TypesInfo().Defs[id] != nil { - // For cross-package references from assembly, - // the Go declaration is the canonical declaration - // and should be excluded when not including declarations. - // For same-package references, the asm TEXT line - // is the declaration, so Go Defs are reference targets. - if pkgpath != "" && pkgpath != string(mp.PkgPath) { - continue - } - } - loc, err := pgf.NodeLocation(id) - if err != nil { - return nil, err - } - locations = append(locations, loc) - } - } - - // For cross-package references, also scan assembly files - // in the declaring package. - if pkgpath != "" && pkgpath != string(mp.PkgPath) { - for _, asmFile := range declPkg.AsmFiles() { - for _, id := range asmFile.Idents { - if id.Name == found.Name { - if id.Kind == asm.Label { - continue - } - if !includeDeclaration && (id.Kind == asm.Text || id.Kind == asm.Global) { - continue - } - if loc, err := asmFile.IdentLocation(id); err == nil { - locations = append(locations, loc) - } - } - } - } - } - - // Scan asm files in the current package for matching identifiers. - for _, asmFile := range pkg.AsmFiles() { - for _, id := range asmFile.Idents { - if id.Name == found.Name { - if id.Kind == asm.Label { - continue - } - if !includeDeclaration && (id.Kind == asm.Text || id.Kind == asm.Global) { - continue - } - if loc, err := asmFile.IdentLocation(id); err == nil { - locations = append(locations, loc) - } - } - } - } - - // Global workspace search via xrefs index for exported symbols. - // Skip if the symbol cannot be objectpath-encoded (rare edge case); - // golang.References handles this the same way. - if symbolObj.Exported() { - if path, err := objectpath.For(symbolObj); err == nil { - - // Compute the scope: all reverse dependencies of the - // declaring package, restricted to the workspace. - workspace, err := snapshot.WorkspaceMetadata(ctx) - if err != nil { - return nil, err - } - workspaceMap := make(map[metadata.PackageID]*metadata.Package, len(workspace)) - for _, wmp := range workspace { - workspaceMap[wmp.ID] = wmp - } - - rdeps, err := snapshot.ReverseDependencies(ctx, declMP.ID, false) - if err != nil { - return nil, err - } - - var globalIDs []metadata.PackageID - for id := range rdeps { - if _, ok := workspaceMap[id]; ok { - globalIDs = append(globalIDs, id) - } - } - - if len(globalIDs) > 0 { - targets := map[metadata.PackagePath]map[objectpath.Path]struct{}{ - declMP.PkgPath: {path: {}}, - } - indexes, err := snapshot.References(ctx, globalIDs...) - if err != nil { - return nil, err - } - for _, index := range indexes { - for _, loc := range index.Lookup(targets) { - locations = append(locations, loc) - } - } - } - } - } - - // Deduplicate by location. - sort.Slice(locations, func(i, j int) bool { - return protocol.CompareLocation(locations[i], locations[j]) < 0 - }) - locations = slices.Compact(locations) - - return locations, nil -} diff --git a/vendor/golang.org/x/tools/gopls/internal/goasm/resolve.go b/vendor/golang.org/x/tools/gopls/internal/goasm/resolve.go deleted file mode 100644 index a6ee940c0a..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/goasm/resolve.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2025 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 goasm - -import ( - "context" - "go/types" - "strings" - - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/cache/metadata" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/asm" -) - -// A resolution is the result of resolving an assembly identifier to its -// definition, shared by Definition and Hover. -type resolution struct { - // file is the parsed assembly file. - file *asm.File - - // found is the identifier under the cursor, or nil if the cursor is - // not on an identifier. - found *asm.Ident - - // obj is the Go object for a package-qualified symbol (including a - // current-package symbol such as ·foo), or nil if the symbol has no - // Go declaration. - obj types.Object - // pkg is the type-checked package that declares obj, or nil. - pkg *cache.Package - - // localDef is the defining identifier in the assembly file for a local - // symbol — a label, a bare TEXT/GLOBL symbol, or a current-package - // symbol without a Go declaration. It is nil if none was found. For a - // label, only the enclosing TEXT function is searched. - localDef *asm.Ident -} - -// resolve resolves the assembly identifier at rng to its definition. -// -// For a package-qualified symbol (including a current-package symbol such -// as ·foo, which is rewritten to pkgpath.foo), resolve type-checks the -// declaring package and returns the Go object in res.obj. For a local -// symbol, resolve returns the defining identifier in the assembly file in -// res.localDef. -// -// res.found is nil if the cursor is not on an identifier. -func resolve(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, rng protocol.Range) (res resolution, err error) { - // Package metadata is needed only to resolve package-qualified symbols - // to Go declarations. An assembly-only file with no Go package has - // none; tolerate the error and fall back to local assembly definitions. - mp, err := snapshot.NarrowestMetadataForFile(ctx, fh.URI()) - if err != nil { - mp = nil - } - - content, err := fh.Content() - if err != nil { - return res, err - } - // TODO(adonovan): make this just another - // attribute of the type-checked cache.Package. - res.file = asm.Parse(fh.URI(), content) - - start, end, err := res.file.Mapper.RangeOffsets(rng) - if err != nil { - return res, err - } - - // Find the identifier under the cursor. - // Use the selection range so that haphazard selections that - // happen to start in an identifier don't produce spurious matches. - res.found = res.file.IdentAt(start, end) - if res.found == nil { - return res, nil - } - - // Resolve a package-qualified symbol (including a current-package - // symbol such as ·foo) to its Go declaration. - if mp != nil { - sym := res.found.Name - if sym != "" && sym[0] == '.' { - sym = string(mp.PkgPath) + sym - } - if pkgpath, name, ok := strings.CutLast(sym, "."); ok { - // Find declaring package among dependencies. - // - // TODO(adonovan): assembly may legally reference - // non-dependencies. For example, sync/atomic calls - // internal/runtime/atomic. Perhaps we should search - // the entire metadata graph, but that's path-dependent. - var declaring *metadata.Package - for pkg := range snapshot.MetadataGraph().ForwardReflexiveTransitiveClosure(mp.ID) { - if pkg.PkgPath == metadata.PackagePath(pkgpath) { - declaring = pkg - break - } - } - if declaring != nil { - pkgs, err := snapshot.TypeCheck(ctx, declaring.ID) - if err != nil { - return res, err - } - res.pkg = pkgs[0] - res.obj = res.pkg.Types().Scope().Lookup(name) - } - // If obj is nil (no Go declaration, e.g. an asm-only - // symbol), fall through to the local-definition search. - } - } - - // Find the definition of a local symbol — a label, a bare TEXT/GLOBL - // symbol, or a package-qualified symbol without a Go declaration — in - // the assembly file. - if res.obj == nil { - // Labels are function-scoped: a label definition matches only - // within the enclosing TEXT function, so that a jump doesn't land - // on a same-named label in another function. - lo, hi := res.file.FunctionRange(res.found.Offset) - for _, id := range res.file.Idents { - if id.Name != res.found.Name { - continue - } - switch id.Kind { - case asm.Text, asm.Global: - res.localDef = &id - case asm.Label: - if lo <= id.Offset && id.Offset < hi { - res.localDef = &id - } - } - if res.localDef != nil { - break - } - } - } - - return res, nil -} diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/addtest.go b/vendor/golang.org/x/tools/gopls/internal/golang/addtest.go index 502cb04dbe..cef26a4333 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/addtest.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/addtest.go @@ -26,9 +26,9 @@ import ( "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/cache/parsego" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/internal/astutil" "golang.org/x/tools/internal/imports" - "golang.org/x/tools/internal/moremaps" "golang.org/x/tools/internal/typesinternal" "golang.org/x/tools/internal/versions" ) diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/assembly.go b/vendor/golang.org/x/tools/gopls/internal/golang/assembly.go index 91dd89e954..00f62a9ece 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/assembly.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/assembly.go @@ -26,6 +26,7 @@ import ( "strings" "golang.org/x/tools/gopls/internal/cache" + "golang.org/x/tools/gopls/internal/util/morestrings" ) // AssemblyHTML returns an HTML document containing an assembly listing of the selected function. @@ -115,15 +116,14 @@ func AssemblyHTML(ctx context.Context, snapshot *cache.Snapshot, w http.Response // replace the "(/file.go:123)" portion with an "L0123" source link. // Skip filenames of the form "". if parts := insnRx.FindStringSubmatch(line); parts != nil { - linkHTML := template.HTML(" ") // if unknown - if file, linenum, ok := strings.CutLast(parts[2], ":"); ok && !strings.HasPrefix(file, "<") { + link := " " // if unknown + if file, linenum, ok := morestrings.CutLast(parts[2], ":"); ok && !strings.HasPrefix(file, "<") { if linenum, err := strconv.Atoi(linenum); err == nil { - linkHTML = sourceLinkHTML( - template.HTML(fmt.Sprintf("L%04d", linenum)), - web.SrcURL(file, linenum, 1)) + text := fmt.Sprintf("L%04d", linenum) + link = sourceLink(text, web.SrcURL(file, linenum, 1)) } } - fmt.Fprintf(&buf, "%s\t%s\t%s", escape(parts[1]), linkHTML, escape(parts[3])) + fmt.Fprintf(&buf, "%s\t%s\t%s", escape(parts[1]), link, escape(parts[3])) } else { buf.WriteString(escape(line)) } diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/call_hierarchy.go b/vendor/golang.org/x/tools/gopls/internal/golang/call_hierarchy.go index adb17c88c0..9378438a99 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/call_hierarchy.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/call_hierarchy.go @@ -17,9 +17,9 @@ import ( "golang.org/x/tools/gopls/internal/cache/parsego" "golang.org/x/tools/gopls/internal/file" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/internal/astutil" "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/moremaps" "golang.org/x/tools/internal/typesinternal" ) diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/codeaction.go b/vendor/golang.org/x/tools/gopls/internal/golang/codeaction.go index 60fee8c137..9e9c79b26c 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/codeaction.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/codeaction.go @@ -208,10 +208,12 @@ func (req *codeActionsRequest) resolveEdits() bool { // lazyInit[*T](ctx, req) returns a pointer to an instance of T, // calling new(T).init(ctx.req) on the first request. -func (req *codeActionsRequest) lazyInit[P interface { +// +// It is conceptually a (generic) method of req. +func lazyInit[P interface { init(ctx context.Context, req *codeActionsRequest) *T -}, T any](ctx context.Context) P { +}, T any](ctx context.Context, req *codeActionsRequest) P { t := reflect.TypeFor[T]() v, ok := req.lazy[t].(P) if !ok { @@ -255,7 +257,6 @@ var codeActionProducers = [...]codeActionProducer{ {kind: settings.RefactorInlineCall, fn: refactorInlineCall, needPkg: true}, {kind: settings.RefactorInlineVariable, fn: refactorInlineVariable, needPkg: true}, {kind: settings.RefactorMoveType, fn: refactorMoveType, needPkg: true}, - {kind: settings.RefactorMoveDeclaration, fn: refactorMoveDeclaration, needPkg: true}, {kind: settings.RefactorRewriteChangeQuote, fn: refactorRewriteChangeQuote}, {kind: settings.RefactorRewriteFillStruct, fn: refactorRewriteFillStruct, needPkg: true}, {kind: settings.RefactorRewriteFillSwitch, fn: refactorRewriteFillSwitch, needPkg: true}, @@ -278,7 +279,7 @@ var codeActionProducers = [...]codeActionProducer{ // sourceOrganizeImports produces "Organize Imports" code actions. func sourceOrganizeImports(ctx context.Context, req *codeActionsRequest) error { - res := req.lazyInit[*allImportsFixesResult](ctx) + res := lazyInit[*allImportsFixesResult](ctx, req) // Send all of the import edits as one code action // if the file is being organized. @@ -299,7 +300,7 @@ func quickFix(ctx context.Context, req *codeActionsRequest) error { } // Process any missing imports and pair them with the diagnostics they fix. - res := req.lazyInit[*allImportsFixesResult](ctx) + res := lazyInit[*allImportsFixesResult](ctx, req) if res.err != nil { return nil } @@ -402,30 +403,30 @@ func importFixTitle(fix *imports.ImportFix) string { func fixedByImportFix(fix *imports.ImportFix, diagnostics []protocol.Diagnostic) []protocol.Diagnostic { var results []protocol.Diagnostic for _, diagnostic := range diagnostics { - msg := diagnostic.MessageString() switch { // "undeclared name: X" may be an unresolved import. - case strings.HasPrefix(msg, "undeclared name: "): - ident := strings.TrimPrefix(msg, "undeclared name: ") + case strings.HasPrefix(diagnostic.Message, "undeclared name: "): + ident := strings.TrimPrefix(diagnostic.Message, "undeclared name: ") if ident == fix.IdentName { results = append(results, diagnostic) } // "undefined: X" may be an unresolved import at Go 1.20+. - case strings.HasPrefix(msg, "undefined: "): - ident := strings.TrimPrefix(msg, "undefined: ") + case strings.HasPrefix(diagnostic.Message, "undefined: "): + ident := strings.TrimPrefix(diagnostic.Message, "undefined: ") if ident == fix.IdentName { results = append(results, diagnostic) } // "could not import: X" may be an invalid import. - case strings.HasPrefix(msg, "could not import: "): - ident := strings.TrimPrefix(msg, "could not import: ") + case strings.HasPrefix(diagnostic.Message, "could not import: "): + ident := strings.TrimPrefix(diagnostic.Message, "could not import: ") if ident == fix.IdentName { results = append(results, diagnostic) } // "X imported but not used" is an unused import. // "X imported but not used as Y" is an unused import. - case strings.Contains(msg, " imported but not used"): - importPath, _, _ := strings.Cut(msg, " imported but not used") + case strings.Contains(diagnostic.Message, " imported but not used"): + idx := strings.Index(diagnostic.Message, " imported but not used") + importPath := diagnostic.Message[:idx] if importPath == fmt.Sprintf("%q", fix.StmtInfo.ImportPath) { results = append(results, diagnostic) } @@ -1257,18 +1258,3 @@ func refactorMoveType(_ context.Context, req *codeActionsRequest) error { } return nil } - -func refactorMoveDeclaration(_ context.Context, req *codeActionsRequest) error { - if !req.snapshot.Options().MoveDeclaration { - return nil - } - if !supportsDialog(req.snapshot.Options().ClientOptions, moveDeclarationFormFile, moveDeclarationFormString) { - return nil - } - curSel, _ := req.pgf.Cursor().FindByPos(req.start, req.end) - if cur, name := moveDeclTarget(curSel); cur.Valid() { - cmd := command.NewMoveDeclarationCommand(fmt.Sprintf("Move declaration %s", name), command.MoveDeclarationArgs{Location: req.loc}) - req.addCommandAction(cmd, false) - } - return nil -} diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/compileropt.go b/vendor/golang.org/x/tools/gopls/internal/golang/compileropt.go index 13a928b2b3..859b4489d4 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/compileropt.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/compileropt.go @@ -122,7 +122,7 @@ func parseDetailsFile(filename string, options *settings.Options) (protocol.Docu d.Tags = []protocol.DiagnosticTag{} // must be an actual slice msg := d.Code.(string) if msg != "" { - msg = fmt.Sprintf("%s(%s)", msg, d.MessageString()) + msg = fmt.Sprintf("%s(%s)", msg, d.Message) } if !showDiagnostic(msg, d.Source, options) { continue diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/completion/builtin.go b/vendor/golang.org/x/tools/gopls/internal/golang/completion/builtin.go index d465b840bb..68f773e09a 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/completion/builtin.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/completion/builtin.go @@ -91,11 +91,10 @@ func (c *completer) builtinArgType(obj types.Object, call *ast.CallExpr, parentI break } - if !call.Ellipsis.IsValid() { - inf.objType = deslice(inf.objType) - // Check if we are completing the variadic append() param. (TestIssue74564) - inf.variadic = exprIdx == 1 && len(call.Args) <= 2 - } + inf.objType = deslice(inf.objType) + + // Check if we are completing the variadic append() param. + inf.variadic = exprIdx == 1 && len(call.Args) <= 2 // Penalize the first append() argument as a candidate. You // don't normally append a slice to itself. diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/completion/completion.go b/vendor/golang.org/x/tools/gopls/internal/golang/completion/completion.go index 1ac0acb1c9..411e708693 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/completion/completion.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/completion/completion.go @@ -40,7 +40,6 @@ import ( "golang.org/x/tools/internal/astutil" "golang.org/x/tools/internal/event" "golang.org/x/tools/internal/imports" - "golang.org/x/tools/internal/stdlib" "golang.org/x/tools/internal/typeparams" "golang.org/x/tools/internal/typesinternal" "golang.org/x/tools/internal/versions" @@ -275,7 +274,8 @@ type completer struct { // [typesinternal.TooNewStdSymbols], recording for each std // package which of its exported symbols are too new for // the version of Go in force in the completion file. - tooNewSymbolsCache map[*types.Package]map[types.Object]stdlib.Symbol + // (The value is the minimum version in the form "go1.%d".) + tooNewSymbolsCache map[*types.Package]map[types.Object]string // mapper converts the positions in the file from which the completion originated. mapper *protocol.Mapper @@ -313,7 +313,7 @@ func (c *completer) tooNew(obj types.Object) bool { disallowed = typesinternal.TooNewStdSymbols(pkg, c.goversion) c.tooNewSymbolsCache[pkg] = disallowed } - return disallowed[obj] != stdlib.Symbol{} + return disallowed[obj] != "" } // funcInfo holds info about a function object. @@ -645,7 +645,7 @@ func Completion(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, p // default to a matcher that always matches matcher: prefixMatcher(""), methodSetCache: make(map[methodSetKey]*types.MethodSet), - tooNewSymbolsCache: make(map[*types.Package]map[types.Object]stdlib.Symbol), + tooNewSymbolsCache: make(map[*types.Package]map[types.Object]string), mapper: pgf.Mapper, startTime: startTime, scopes: scopes, @@ -1379,11 +1379,14 @@ func (c *completer) selector(ctx context.Context, sel *ast.SelectorExpr) error { prefix := sel.Sel.Name if c.surrounding != nil { if c.surrounding.content != sel.Sel.Name { - if sel.Sel.Name != "_" && sel.Sel.Name != "" { + // the bug reports do not include the Reportf strings just the line numbers + if len(c.surrounding.content) == 0 { + bug.Reportf("surrounding is empty, should be %q", sel.Sel.Name) + } else if len(sel.Sel.Name) == 0 { + bug.Reportf("sel.Sel.Name is empty, should be %q", c.surrounding.content) + } else { bug.Reportf("unexpected surrounding: %q != %q", c.surrounding.content, sel.Sel.Name) - } - prefix = c.surrounding.Prefix() } else { prefix = sel.Sel.Name[:c.surrounding.cursor-c.surrounding.start] } @@ -1998,15 +2001,14 @@ func enclosingFunction(path []ast.Node, info *types.Info) *funcInfo { } case *ast.FuncLit: if typ, ok := info.Types[t]; ok { - sig, ok := typ.Type.(*types.Signature) - if !ok { + if sig, _ := typ.Type.(*types.Signature); sig == nil { // golang/go#49397: it should not be possible, but we somehow arrived // here with a non-signature type, most likely due to AST mangling // such that node.Type is not a FuncType. return nil } return &funcInfo{ - sig: sig, + sig: typ.Type.(*types.Signature), body: t.Body, } } @@ -2724,7 +2726,7 @@ func (c *completer) expectedCallParamType(inf candidateInference, node *ast.Call inf.objType = sig.Params().At(exprIdx).Type() } - if sig.Variadic() && exprIdx >= (numParams-1) && !node.Ellipsis.IsValid() { + if sig.Variadic() && exprIdx >= (numParams-1) { // If we are completing a variadic param, deslice the variadic type. inf.objType = deslice(inf.objType) // Record whether we are completing the initial variadic param. @@ -2748,7 +2750,7 @@ func expectedConstraint(t types.Type, idx int) types.Type { var tp *types.TypeParamList if pnt, ok := t.(typesinternal.NamedOrAlias); ok { tp = pnt.TypeParams() - } else if sig, ok := t.Underlying().(*types.Signature); ok { + } else if sig, _ := t.Underlying().(*types.Signature); sig != nil { tp = sig.TypeParams() } if tp == nil || idx >= tp.Len() { @@ -3572,8 +3574,8 @@ func rangeFuncParamCount(sig *types.Signature) int { return -1 } - yieldSig, ok := sig.Params().At(0).Type().Underlying().(*types.Signature) - if !ok { + yieldSig, _ := sig.Params().At(0).Type().Underlying().(*types.Signature) + if yieldSig == nil { return -1 } diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/completion/deep_completion.go b/vendor/golang.org/x/tools/gopls/internal/golang/completion/deep_completion.go index 1d6ad7fa63..6987fd7cbe 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/completion/deep_completion.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/completion/deep_completion.go @@ -12,7 +12,6 @@ import ( "golang.org/x/tools/gopls/internal/util/typesutil" "golang.org/x/tools/internal/packagepath" - "golang.org/x/tools/internal/typesinternal" ) // MaxDeepCompletions limits deep completion results because in most cases @@ -270,9 +269,8 @@ func (c *completer) addCandidate(ctx context.Context, cand *candidate) { // If obj is a *types.TypeName that didn't otherwise match, check // if a literal object of this type makes a good candidate. - // We only care about named or alias types without unspecified type - // params: instantiated generic types are already handled by injectType. - if pnt, ok := obj.Type().(typesinternal.NamedOrAlias); ok && pnt.TypeParams().Len() == 0 { + // We only care about named types (i.e. don't want builtin types). + if _, isNamed := obj.Type().(*types.Named); isNamed { c.literal(ctx, obj.Type(), cand.imp) } } diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/completion/format.go b/vendor/golang.org/x/tools/gopls/internal/golang/completion/format.go index 583cfe6e79..ba50c4a21c 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/completion/format.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/completion/format.go @@ -198,15 +198,10 @@ Suffixes: } } - // replacing suffix with conv.suffix was wrong (Issue 80268) - // That produced `(*[10]int)(array)` for passing an - // array to a function expecting an array pointer. But - // `(*[10]int)(array[:])` is what is wanted. - // (conv.suffix is always ")" or empty) if cand.convertTo != nil { conv := c.formatConversion(cand.convertTo) prefix = conv.prefix + prefix - suffix = suffix + conv.suffix + suffix = conv.suffix } if prefix != "" { diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/completion/fuzz.go b/vendor/golang.org/x/tools/gopls/internal/golang/completion/fuzz.go index e7d8ca08de..34c6d5049d 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/completion/fuzz.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/completion/fuzz.go @@ -106,19 +106,18 @@ Loop: return false } - var lbl strings.Builder - lbl.WriteString("Fuzz(func(t *testing.T") + lbl := "Fuzz(func(t *testing.T" for i, a := range add.Args { info := c.pkg.TypesInfo().TypeOf(a) if info == nil { return false // How could this happen, but better safe than panic. } - fmt.Fprintf(&lbl, ", %c %s", 'a'+i, info) + lbl += fmt.Sprintf(", %c %s", 'a'+i, info) } - lbl.WriteString(")") + lbl += ")" xx := CompletionItem{ - Label: lbl.String(), - InsertText: lbl.String(), + Label: lbl, + InsertText: lbl, Kind: protocol.FunctionCompletion, Depth: 0, Score: 10, // pretty confident the user should see this diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/completion/printf.go b/vendor/golang.org/x/tools/gopls/internal/golang/completion/printf.go index 66d60a9b16..c9db1de014 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/completion/printf.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/completion/printf.go @@ -23,8 +23,8 @@ func printfArgKind(info *types.Info, call *ast.CallExpr, argIdx int) objKind { return kindAny } - sig, ok := fn.Type().Underlying().(*types.Signature) - if !ok { + sig, _ := fn.Type().Underlying().(*types.Signature) + if sig == nil { return kindAny } diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/definition.go b/vendor/golang.org/x/tools/gopls/internal/golang/definition.go index 0c6d899400..f28fa9b282 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/definition.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/definition.go @@ -266,18 +266,16 @@ func builtinDecl(ctx context.Context, snapshot *cache.Snapshot, obj types.Object if obj.Pkg() == types.Unsafe { // package "unsafe": // parse $GOROOT/src/unsafe/unsafe.go - var unsafe *metadata.Package - if mps := snapshot.MetadataGraph().ForPackagePath[metadata.PackagePath("unsafe")]; len(mps) > 0 { - unsafe = mps[0] - } + // + // (Strictly, we shouldn't assume that the ID of a std + // package is its PkgPath, but no Bazel+gopackagesdriver + // users have complained about this yet.) + unsafe := snapshot.Metadata("unsafe") if unsafe == nil { // If the type checker somehow resolved 'unsafe', we must have metadata // for it. return nil, nil, bug.Errorf("no metadata for package 'unsafe'") } - if len(unsafe.GoFiles) == 0 { - return nil, nil, bug.Errorf("no files for package 'unsafe'") - } uri := unsafe.GoFiles[0] fh, err := snapshot.ReadFile(ctx, uri) if err != nil { diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/diagnostics.go b/vendor/golang.org/x/tools/gopls/internal/golang/diagnostics.go index b49c96ec4f..6708d32fcb 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/diagnostics.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/diagnostics.go @@ -11,7 +11,7 @@ import ( "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/progress" "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/moremaps" + "golang.org/x/tools/gopls/internal/util/moremaps" ) // DiagnoseFile returns pull-based diagnostics for the given file. diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/extracttofile.go b/vendor/golang.org/x/tools/gopls/internal/golang/extracttofile.go index 054220f0ae..9bd3d5bc6e 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/extracttofile.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/extracttofile.go @@ -98,6 +98,8 @@ func ExtractToNewFile(ctx context.Context, snapshot *cache.Snapshot, fh file.Han if !ok { return nil, fmt.Errorf("invalid selection") } + pgf.CheckPos(start) // #70553 + // Inv: start is valid wrt pgf.Tok. // select trailing empty lines offset, err := safetoken.Offset(pgf.Tok, end) @@ -107,10 +109,21 @@ func ExtractToNewFile(ctx context.Context, snapshot *cache.Snapshot, fh file.Han rest := pgf.Src[offset:] spaces := len(rest) - len(bytes.TrimLeft(rest, " \t\n")) end += token.Pos(spaces) - src, err := pgf.PosText(start, end) - if err != nil { - return nil, err + pgf.CheckPos(end) // #70553 + if !(start <= end) { + bug.Reportf("start: not before end") + } + // Inv: end is valid wrt pgf.Tok; env >= start. + fileStart := pgf.File.FileStart + pgf.CheckPos(fileStart) // #70553 + if !(0 <= start-fileStart) { + bug.Reportf("start: out of bounds") } + if !(int(end-fileStart) <= len(pgf.Src)) { + bug.Reportf("end: out of bounds") + } + // Inv: 0 <= start-fileStart <= end-fileStart <= len(Src). + src := pgf.Src[start-fileStart : end-fileStart] replaceRange, err := pgf.PosRange(start, end) if err != nil { @@ -167,7 +180,7 @@ func ExtractToNewFile(ctx context.Context, snapshot *cache.Snapshot, fh file.Han newFileContent, err := format.Source(buf.Bytes()) if err != nil { - return nil, fmt.Errorf("failed to format extracted source: %w", err) + return nil, err } return []protocol.DocumentChange{ diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/folding_range.go b/vendor/golang.org/x/tools/gopls/internal/golang/folding_range.go index a167fccb9e..b4e5e927fe 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/folding_range.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/folding_range.go @@ -216,10 +216,13 @@ func foldingRange(kind protocol.FoldingRangeKind, rng protocol.Range) protocol.F return protocol.FoldingRange{ // (I guess LSP doesn't use a protocol.Range here // because missing means something different from zero.) - StartLine: new(rng.Start.Line), - StartCharacter: new(rng.Start.Character), - EndLine: new(rng.End.Line), - EndCharacter: new(rng.End.Character), + StartLine: varOf(rng.Start.Line), + StartCharacter: varOf(rng.Start.Character), + EndLine: varOf(rng.End.Line), + EndCharacter: varOf(rng.End.Character), Kind: string(kind), } } + +// varOf returns a new variable whose value is x. +func varOf[T any](x T) *T { return &x } diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/freesymbols.go b/vendor/golang.org/x/tools/gopls/internal/golang/freesymbols.go index 8e3ad2d71d..336025367f 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/freesymbols.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/freesymbols.go @@ -12,17 +12,17 @@ import ( "go/ast" "go/token" "go/types" - "html/template" - "log" + "html" "slices" "sort" "strings" "golang.org/x/tools/go/ast/astutil" "golang.org/x/tools/gopls/internal/cache" + "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/cache/parsego" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/internal/moremaps" "golang.org/x/tools/internal/typesinternal" ) @@ -36,21 +36,18 @@ func FreeSymbolsHTML(viewID string, pkg *cache.Package, pgf *parsego.File, start // -- model -- type Import struct { - URL string - Path PackagePath - Symbols string + Path metadata.PackagePath + Symbols []string } type Symbol struct { Kind string - Name template.HTML Type string + Refs []types.Object } - // model is [freeSymbolsTmpl]'s operand. var model struct { Imported []Import PkgLevel []Symbol Local []Symbol - Code template.HTML } qualifier := typesinternal.NameRelativeTo(pkg.Types()) @@ -63,8 +60,8 @@ func FreeSymbolsHTML(viewID string, pkg *cache.Package, pgf *parsego.File, start }) // Inspect the references. - imported := make(map[PackagePath][]*freeRef) // refs to imported symbols - seen := make(map[string]bool) // to de-dup dotted paths + imported := make(map[string][]*freeRef) // refs to imported symbols, by package path + seen := make(map[string]bool) // to de-dup dotted paths for _, ref := range refs { if seen[ref.dotted] { continue // de-dup @@ -76,7 +73,7 @@ func FreeSymbolsHTML(viewID string, pkg *cache.Package, pgf *parsego.File, start case "file": // imported symbol: group by package if pkgname, ok := ref.objects[0].(*types.PkgName); ok { - path := PackagePath(pkgname.Imported().Path()) + path := pkgname.Imported().Path() imported[path] = append(imported[path], ref) } continue @@ -113,23 +110,10 @@ func FreeSymbolsHTML(viewID string, pkg *cache.Package, pgf *parsego.File, start typestr = "" // avoid "label L L" } - // Join name with dots. - var nameHTML template.HTML - { - var buf strings.Builder - for i, obj := range ref.objects { - if i > 0 { - buf.WriteByte('.') - } - buf.WriteString(string(objHTML(pkg.FileSet(), web, obj))) - } - nameHTML = template.HTML(buf.String()) - } - *symbols = append(*symbols, Symbol{ Kind: kind, - Name: nameHTML, Type: typestr, + Refs: ref.objects, }) } @@ -147,20 +131,83 @@ func FreeSymbolsHTML(viewID string, pkg *cache.Package, pgf *parsego.File, start syms[max-1] = fmt.Sprintf("... (%d)", len(syms)) syms = syms[:max] } - symbols := strings.Join(syms, ", ") model.Imported = append(model.Imported, Import{ - URL: web.PkgURL(viewID, pkgPath, ""), - Path: pkgPath, - Symbols: symbols, + Path: PackagePath(pkgPath), + Symbols: syms, }) } } + // -- presentation -- + + var buf bytes.Buffer + buf.WriteString(` + + + + + + + +

Free symbols

+

+ The selected code contains references to these free* symbols: +

+`) + + // Present the refs in three sections: imported, same package, local. + + // -- imported symbols -- + + // Show one item per package, with a list of symbols. + fmt.Fprintf(&buf, "

Imported symbols

\n") + fmt.Fprintf(&buf, "
    \n") + for _, imp := range model.Imported { + fmt.Fprintf(&buf, "
  • import \"%s\" // for %s
  • \n", + web.PkgURL(viewID, imp.Path, ""), + html.EscapeString(string(imp.Path)), + strings.Join(imp.Symbols, ", ")) + } + if len(model.Imported) == 0 { + fmt.Fprintf(&buf, "
  • (none)
  • \n") + } + buf.WriteString("
\n") + + // -- package and local symbols -- + + showSymbols := func(scope, title string, symbols []Symbol) { + fmt.Fprintf(&buf, "

%s

\n", scope, title) + fmt.Fprintf(&buf, "
    \n") + pre := buf.Len() + for _, sym := range symbols { + fmt.Fprintf(&buf, "
  • %s ", sym.Kind) // of rightmost symbol in dotted path + for i, obj := range sym.Refs { + if i > 0 { + buf.WriteByte('.') + } + buf.WriteString(objHTML(pkg.FileSet(), web, obj)) + } + fmt.Fprintf(&buf, " %s
  • \n", html.EscapeString(sym.Type)) + } + if buf.Len() == pre { + fmt.Fprintf(&buf, "
  • (none)
  • \n") + } + buf.WriteString("
\n") + } + showSymbols("pkg", "Package-level symbols", model.PkgLevel) + showSymbols("local", "Local symbols", model.Local) + // -- code selection -- - // Highlight references to free symbols in the selection. - var code strings.Builder // (valid HTML) + // Print the selection, highlighting references to free symbols. + buf.WriteString("
\n") sort.Slice(refs, func(i, j int) bool { return refs[i].expr.Pos() < refs[j].expr.Pos() }) @@ -169,25 +216,46 @@ func FreeSymbolsHTML(viewID string, pkg *cache.Package, pgf *parsego.File, start if pos < end { fileStart := pgf.File.FileStart text := pgf.Mapper.Content[pos-fileStart : end-fileStart] - code.WriteString(template.HTMLEscapeString(string(text))) + buf.WriteString(html.EscapeString(string(text))) pos = end } } + buf.WriteString(`
`)
 	for _, ref := range refs {
 		emitTo(ref.expr.Pos())
-		fmt.Fprintf(&code, ``, ref.scope) // no escaping needed
+		fmt.Fprintf(&buf, ``, ref.scope)
 		emitTo(ref.expr.End())
-		code.WriteString(``)
+		buf.WriteString(``)
 	}
 	emitTo(end)
-	model.Code = template.HTML(code.String())
+	buf.WriteString(`
+
+

+ *A symbol is "free" if it is referenced within the selection but declared + outside of it. - // -- presentation -- + The free variables are approximately the set of parameters that + would be needed if the block were extracted into its own function in + the same package. - var buf bytes.Buffer - if err := freeSymbolsTmpl.Execute(&buf, model); err != nil { - log.Fatal(err) - } + Free identifiers may include local types and control labels as well. + + Even when you don't intend to extract a block into a new function, + this information can help you to tell at a glance what names a block + of code depends on. +

+

+ Each dotted path of identifiers (such as file.Name.Pos) is reported + as a separate item, so that you can see which parts of a complex + type are actually needed. + + The free symbols referenced by the body of a function may + reveal that only a small part (a single field of a struct, say) of + one of the function's parameters is used, allowing you to simplify + and generalize the function by choosing a different type for that + parameter. +

+`) return buf.Bytes() } @@ -331,103 +399,22 @@ func freeRefs(pkg *types.Package, info *types.Info, file *ast.File, start, end t // objHTML returns HTML for obj.Name(), possibly marked up as a link // to the web server that, when visited, opens the declaration in the // client editor. -func objHTML(fset *token.FileSet, web Web, obj types.Object) template.HTML { - // Go symbol names don't need escaping, but be conservative. - html := template.HTML(template.HTMLEscapeString(obj.Name())) +func objHTML(fset *token.FileSet, web Web, obj types.Object) string { + text := obj.Name() if posn := safetoken.StartPosition(fset, obj.Pos()); posn.IsValid() { - return sourceLinkHTML(html, web.SrcURL(posn.Filename, posn.Line, posn.Column)) - } - return html -} - -// sourceLinkHTML returns HTML for a link to open a file in the client editor. -func sourceLinkHTML(body template.HTML, url string) template.HTML { - var buf strings.Builder - if err := sourceLinkTmpl.Execute(&buf, sourceLinkData{URL: url, Body: body}); err != nil { - panic(err) + url := web.SrcURL(posn.Filename, posn.Line, posn.Column) + return sourceLink(text, url) } - return template.HTML(buf.String()) -} - -type sourceLinkData struct { - URL string - Body template.HTML + return text } -var sourceLinkTmpl = template.Must(template.New("sourcelink").Parse( +// sourceLink returns HTML for a link to open a file in the client editor. +func sourceLink(text, url string) string { // The /src URL returns nothing but has the side effect // of causing the LSP client to open the requested file. // So we use onclick to prevent the browser from navigating. // We keep the href attribute as it causes the to render // as a link: blue, underlined, with URL hover information. - `{{.Body}}`)) - -var freeSymbolsTmpl = template.Must(template.New("freesymbols").Parse(` - - - - - - - -

Free symbols

-

- The selected code contains references to these free* symbols: -

- -

Imported symbols

-
    -{{range .Imported}}
  • import "{{.Path}}" // for {{.Symbols}}
  • -{{else}}
  • (none)
  • -{{end}}
- -

Package-level symbols

-
    -{{range .PkgLevel}}
  • {{.Kind}} {{.Name}} {{.Type}}
  • -{{else}}
  • (none)
  • -{{end}}
- -

Local symbols

-
    -{{range .Local}}
  • {{.Kind}} {{.Name}} {{.Type}}
  • -{{else}}
  • (none)
  • -{{end}} -
- -
-
{{.Code}}
-
-

- * A symbol is "free" if it is referenced within the selection but declared - outside of it. - - The free variables are approximately the set of parameters that - would be needed if the block were extracted into its own function in - the same package. - - Free identifiers may include local types and control labels as well. - - Even when you don't intend to extract a block into a new function, - this information can help you to tell at a glance what names a block - of code depends on. -

-

- Each dotted path of identifiers (such as file.Name.Pos) is reported - as a separate item, so that you can see which parts of a complex - type are actually needed. - - The free symbols referenced by the body of a function may - reveal that only a small part (a single field of a struct, say) of - one of the function's parameters is used, allowing you to simplify - and generalize the function by choosing a different type for that - parameter. -

- - -`)) + return fmt.Sprintf(`%[2]s`, + html.EscapeString(url), text) +} diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/inlay_hint.go b/vendor/golang.org/x/tools/gopls/internal/golang/inlay_hint.go index 74a6634f9f..a9e7027905 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/inlay_hint.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/inlay_hint.go @@ -140,13 +140,6 @@ func parameterNames(info *types.Info, pgf *parsego.File, qual types.Qualifier, c } func ignoredError(info *types.Info, pgf *parsego.File, qual types.Qualifier, cur inspector.Cursor, add func(protocol.InlayHint)) { - ignoreSubstrings := []string{ - "ignore error", - "discard error", - "can't fail", - "cannot fail", - } - outer: for curCall := range cur.Preorder((*ast.ExprStmt)(nil)) { stmt := curCall.Node().(*ast.ExprStmt) @@ -178,7 +171,7 @@ outer: continue } - // Suppress if comment on same line contains "ignore error" (etc). + // Suppress if comment on same line contains "// ignore error". line := func(pos token.Pos) int { return safetoken.Line(pgf.Tok, pos) } comments := pgf.File.Comments compare := func(cg *ast.CommentGroup, pos token.Pos) int { @@ -187,12 +180,8 @@ outer: i, _ := slices.BinarySearchFunc(comments, stmt.End(), compare) if i >= 0 && i < len(comments) { cg := comments[i] - if line(cg.Pos()) == line(stmt.End()) { - for _, sub := range ignoreSubstrings { - if strings.Contains(cg.Text(), sub) { - continue outer // suppress - } - } + if line(cg.Pos()) == line(stmt.End()) && strings.Contains(cg.Text(), "ignore error") { + continue outer // suppress } } diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/inline.go b/vendor/golang.org/x/tools/gopls/internal/golang/inline.go index 5d4f990104..d88bce2757 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/inline.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/inline.go @@ -23,9 +23,7 @@ import ( "golang.org/x/tools/gopls/internal/util/safetoken" "golang.org/x/tools/internal/astutil" "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/moreiters" "golang.org/x/tools/internal/refactor/inline" - "golang.org/x/tools/internal/typesinternal" ) // enclosingStaticCall returns the innermost function call enclosing @@ -142,55 +140,75 @@ func logger(ctx context.Context, name string, verbose bool) func(format string, // canInlineVariable reports whether the selection is within an // identifier that is a use of a variable that has an initializer -// expression and is not reassigned or address-taken. If so, it returns -// cursors for the identifier and the initializer expression. -func canInlineVariable(info *types.Info, curFile inspector.Cursor, start, end token.Pos) (curUse, curRHS inspector.Cursor, ok bool) { - curUse, found := curFile.FindByPos(start, end) - if !found { - return inspector.Cursor{}, inspector.Cursor{}, false - } - id, ok := curUse.Node().(*ast.Ident) - if !ok || typesinternal.IsAssignedOrAddressTaken(info, curUse) { - return inspector.Cursor{}, inspector.Cursor{}, false - } - v, ok := info.Uses[id].(*types.Var) - if !ok || v.Kind() != types.LocalVar { - return inspector.Cursor{}, inspector.Cursor{}, false - } - curIdent, found := curFile.FindByPos(v.Pos(), v.Pos()) - if !found { - return inspector.Cursor{}, inspector.Cursor{}, false - } - // Reject modified or address-taken variables; inlining would require - // dataflow analysis to prove the initial definition reaches this use. - root, found := moreiters.First(curIdent.Enclosing((*ast.FuncDecl)(nil), (*ast.FuncLit)(nil))) - if !found { - root = curFile - } - for cur := range root.Preorder((*ast.Ident)(nil)) { - id := cur.Node().(*ast.Ident) - if info.Uses[id] == v && typesinternal.IsAssignedOrAddressTaken(info, cur) { - return inspector.Cursor{}, inspector.Cursor{}, false +// expression. If so, it returns cursors for the identifier and the +// initializer expression. +func canInlineVariable(info *types.Info, curFile inspector.Cursor, start, end token.Pos) (_, _ inspector.Cursor, ok bool) { + if curUse, ok := curFile.FindByPos(start, end); ok { + if id, ok := curUse.Node().(*ast.Ident); ok && !isLvalueUse(curUse, info) { + if v, ok := info.Uses[id].(*types.Var); ok && v.Kind() == types.LocalVar { + if curIdent, ok := curFile.FindByPos(v.Pos(), v.Pos()); ok { + curParent := curIdent.Parent() + kind, index := curIdent.ParentEdge() + switch kind { + case edge.ValueSpec_Names: + // var v = expr + spec := curParent.Node().(*ast.ValueSpec) + if len(spec.Names) == len(spec.Values) { + return curUse, curParent.ChildAt(edge.ValueSpec_Values, index), true + } + case edge.AssignStmt_Lhs: + // v := expr + stmt := curParent.Node().(*ast.AssignStmt) + if len(stmt.Lhs) == len(stmt.Rhs) { + return curUse, curParent.ChildAt(edge.AssignStmt_Rhs, index), true + } + } + } + } } } + return +} + +// isLvalueUse reports whether the "use" identifier represented by cur +// appears in an l-value context such as: +// +// - v=... +// - v++ +// - &v +// - v.f(), when this implicitly takes the address of v. +func isLvalueUse(cur inspector.Cursor, info *types.Info) bool { + cur = unparenEnclosing(cur) + + switch cur.ParentEdgeKind() { + case edge.AssignStmt_Lhs, edge.IncDecStmt_X: + return true // v=..., v++ + + case edge.UnaryExpr_X: + return cur.Parent().Node().(*ast.UnaryExpr).Op == token.AND // &v - curParent := curIdent.Parent() - kind, index := curIdent.ParentEdge() - switch kind { - case edge.ValueSpec_Names: - // var v = expr - spec := curParent.Node().(*ast.ValueSpec) - if len(spec.Names) == len(spec.Values) { - return curUse, curParent.ChildAt(edge.ValueSpec_Values, index), true + case edge.SelectorExpr_X: + sel := cur.Parent().Node().(*ast.SelectorExpr) + isPointer := func(t types.Type) bool { + return is[*types.Pointer](t) } - case edge.AssignStmt_Lhs: - // v := expr - stmt := curParent.Node().(*ast.AssignStmt) - if len(stmt.Lhs) == len(stmt.Rhs) { - return curUse, curParent.ChildAt(edge.AssignStmt_Rhs, index), true + if seln, ok := info.Selections[sel]; ok && seln.Kind() == types.MethodVal { + // Have: recv.f() method call + methodRecv := seln.Obj().(*types.Func).Signature().Recv().Type() + return !seln.Indirect() && isPointer(methodRecv) && !isPointer(info.TypeOf(sel.X)) } } - return inspector.Cursor{}, inspector.Cursor{}, false + + return false +} + +// unparenEnclosing removes enclosing parens from cur in +// preparation for a call to [Cursor.ParentEdge]. +func unparenEnclosing(cur inspector.Cursor) inspector.Cursor { + for cur.ParentEdgeKind() == edge.ParenExpr_X { + cur = cur.Parent() + } + return cur } // inlineVariableOne computes a fix to replace the selected variable by @@ -232,6 +250,8 @@ func inlineVariableOne(pkg *cache.Package, pgf *parsego.File, start, end token.P } } + // TODO(adonovan): also reject variables that are updated by assignments? + // Add parens to 'new' as needed by the 'use' context. rhs = astutil.MaybeParenthesize(curUse.Parent().Node(), use, rhs) diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/inline_all.go b/vendor/golang.org/x/tools/gopls/internal/golang/inline_all.go index a22c05213c..c7a1dbbccb 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/inline_all.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/inline_all.go @@ -17,9 +17,9 @@ import ( "golang.org/x/tools/gopls/internal/cache/parsego" "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/util/bug" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/internal/analysis/driverutil" "golang.org/x/tools/internal/diff" - "golang.org/x/tools/internal/moremaps" "golang.org/x/tools/internal/refactor" "golang.org/x/tools/internal/refactor/inline" ) diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/move_decl.go b/vendor/golang.org/x/tools/gopls/internal/golang/move_decl.go deleted file mode 100644 index c9a18d279c..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/golang/move_decl.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2026 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 golang - -import ( - "context" - "go/ast" - - "golang.org/x/tools/go/ast/edge" - "golang.org/x/tools/go/ast/inspector" - "golang.org/x/tools/gopls/internal/cache" - "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/internal/moreiters" -) - -// TODO(mkalil): Find a way to notify users which additional declarations will need to be moved. -func MoveDeclaration(ctx context.Context, fh file.Handle, snapshot *cache.Snapshot) ([]protocol.DocumentChange, protocol.Location, error) { - return nil, protocol.Location{}, nil -} - -// moveDeclTarget returns the cursor of the declaration to be moved, based on -// curSel. The moving declaration is the innermost TypeSpec, ValueSpec, or -// FuncDecl enclosing curSel, if any. If the cursor is within a multi-value -// ValueSpec, we return the first enclosing identifier, if any. -func moveDeclTarget(curSel inspector.Cursor) (inspector.Cursor, string) { - if cur, ok := moreiters.First(curSel.Enclosing( - (*ast.FuncDecl)(nil), (*ast.TypeSpec)(nil), (*ast.ValueSpec)(nil))); ok { - switch n := cur.Node().(type) { - case *ast.FuncDecl: - return cur, n.Name.Name - case *ast.TypeSpec: - // Only support moving package-level decls. - if cur.Parent().ParentEdgeKind() == edge.File_Decls { - return cur, n.Name.Name - } - case *ast.ValueSpec: - // Only support moving package-level decls. - if cur.Parent().ParentEdgeKind() == edge.File_Decls { - if len(n.Names) == 1 { - return cur, n.Names[0].Name - } - // For a multi-value ValueSpec, only match if the cursor is directly - // on one of the declared names (not in the type or value expressions). - // var a, b = foo, bar <- cursor in foo/bar is ambiguous - // var a, b MyType <- cursor in MyType is ambiguous - if curSel.ParentEdgeKind() == edge.ValueSpec_Names { - return cur, curSel.Node().(*ast.Ident).Name - } - } - } - } - return inspector.Cursor{}, "" -} diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/pkgdoc.go b/vendor/golang.org/x/tools/gopls/internal/golang/pkgdoc.go index 1394b1532e..9781a263e4 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/pkgdoc.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/pkgdoc.go @@ -11,7 +11,8 @@ package golang // placeholder for a more sophisticated one. // // TODO(adonovan): -// - rewrite using html/template. No, really, let's do this. +// - rewrite using html/template. +// Or factor with golang.org/x/pkgsite/internal/godoc/dochtml. // - emit breadcrumbs for parent + sibling packages. // - list promoted methods---we have type information! (golang/go#67158) // - gather Example tests, following go/doc and pkgsite. @@ -37,7 +38,7 @@ import ( "go/format" "go/token" "go/types" - "html/template" + "html" "path/filepath" "slices" "strings" @@ -356,7 +357,7 @@ func PackageDocHTML(viewID string, pkg *cache.Package, web Web) ([]byte, error) } scope := pkg.Types().Scope() - escape := template.HTMLEscapeString + escape := html.EscapeString title := fmt.Sprintf("%s package - %s - Gopls packages", pkg.Types().Name(), escape(pkg.Types().Path())) @@ -573,7 +574,7 @@ window.addEventListener('load', function() { emit(n.Pos()) pos = n.End() if url := linkify(n); url != "" { - fmt.Fprintf(&buf, "%s", escape(url), escape(n.Name)) + fmt.Fprintf(&buf, "%s", url, escape(n.Name)) } else { buf.WriteString(escape(n.Name)) // plain } @@ -830,9 +831,7 @@ window.addEventListener('load', function() { fmt.Fprintf(&buf, "

Source files

\n") for _, filename := range docpkg.Filenames { fmt.Fprintf(&buf, "
%s
\n", - sourceLinkHTML( - template.HTML(template.HTMLEscapeString(filepath.Base(filename))), - web.SrcURL(filename, 1, 1))) + sourceLink(filepath.Base(filename), web.SrcURL(filename, 1, 1))) } fmt.Fprintf(&buf, "\n") diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/references.go b/vendor/golang.org/x/tools/gopls/internal/golang/references.go index 792dd0832e..91e992a2aa 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/references.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/references.go @@ -33,9 +33,7 @@ import ( "golang.org/x/tools/gopls/internal/cache/parsego" "golang.org/x/tools/gopls/internal/file" "golang.org/x/tools/gopls/internal/protocol" - "golang.org/x/tools/gopls/internal/util/asm" "golang.org/x/tools/gopls/internal/util/cursorutil" - "golang.org/x/tools/gopls/internal/util/safetoken" "golang.org/x/tools/internal/event" @@ -620,35 +618,6 @@ func localReferences(pkg *cache.Package, targets map[types.Object]bool, correspo } } } - - // Scan assembly files for references to the target objects. - for _, af := range pkg.AsmFiles() { - for _, id := range af.Idents { - if id.Kind != asm.Data && id.Kind != asm.Ref { - continue - } - pkgpath, name, ok := strings.CutLast(id.Name, ".") - if !ok { - continue - } - if pkgpath != "" && pkgpath != pkg.Types().Path() { - continue - } - obj := pkg.Types().Scope().Lookup(name) - if obj == nil { - continue - } - if !matches(obj) { - continue - } - if rng, err := af.IdentRange(id); err == nil { - report(protocol.Location{ - URI: af.Mapper.URI, - Range: rng, - }, false) - } - } - } return nil } diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/rename.go b/vendor/golang.org/x/tools/gopls/internal/golang/rename.go index b093326500..9e04f8dffb 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/rename.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/rename.go @@ -611,15 +611,6 @@ func renameOrdinary(ctx context.Context, snapshot *cache.Snapshot, uri protocol. targets = []objectAt{{obj, cur}} } - // A field selected from an instantiated generic type is represented by a - // synthetic *types.Var. Normalize it to the declared field so that a rename - // initiated at the selection updates the declaration too (golang/go#80542). - for i := range targets { - if field, ok := targets[i].obj.(*types.Var); ok && field.IsField() { - targets[i].obj = field.Origin() - } - } - // Pick a representative object arbitrarily. // (All share the same name, pos, and kind.) obj, node := targets[0].obj, targets[0].cur.Node() @@ -663,6 +654,8 @@ func renameOrdinary(ctx context.Context, snapshot *cache.Snapshot, uri protocol. case *types.Func: obj = obj0.Origin() case *types.Var: + // TODO(adonovan): do vars need the origin treatment too? (issue #58462) + // Function parameter and result vars that are (unusually) // capitalized are technically exported, even though they // cannot be referenced, because they may affect downstream diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/resolve.go b/vendor/golang.org/x/tools/gopls/internal/golang/resolve.go index b689da2e8a..c4ad48ccbb 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/resolve.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/resolve.go @@ -17,6 +17,7 @@ import ( "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/protocol/command" "golang.org/x/tools/gopls/internal/settings" + "golang.org/x/tools/gopls/internal/util/morestrings" ) // Ths file contains the code to mediate user dialogs in the client @@ -49,7 +50,7 @@ var addTagsForm = []protocol.FormField{ { ID: "tags", Description: `comma-separated list of tags to add; e.g.. "json,xml"`, - Type: protocol.FormFieldTypeString{Kind: protocol.FormFieldKindString}, + Type: protocol.FormFieldTypeString{Kind: "string"}, Required: true, Default: "json", }, @@ -57,7 +58,7 @@ var addTagsForm = []protocol.FormField{ ID: "transform", Description: `transform rule for added tags, e.g., "camelcase' or 'snakecase"`, Type: protocol.FormFieldTypeEnum{ - Kind: protocol.FormFieldKindEnum, + Kind: "enum", Entries: []protocol.FormEnumEntry{ { Value: "camelcase", @@ -90,7 +91,7 @@ var removeTagsForm = []protocol.FormField{ { ID: "tags", Description: `comma-separated list of tags to remove; e.g., "json,xml"`, - Type: protocol.FormFieldTypeString{Kind: protocol.FormFieldKindString}, + Type: protocol.FormFieldTypeString{Kind: "string"}, Required: true, Default: "json", // TODO(?): put the existing tags here? }, @@ -114,10 +115,6 @@ func ResolveCommand(ctx context.Context, params *protocol.ExecuteCommandParams, if err := resolveImplementInterface(options, params); err != nil { return nil, err } - case "gopls.move_declaration": - if err := resolveMoveDeclaration(options, params); err != nil { - return nil, err - } } return params, nil } @@ -201,7 +198,7 @@ var implementInterfaceFormLazyEnum = []protocol.FormField{ ID: "interface", Description: `fully qualified interface identifier path/to/pkg.interface; e.g., "net.Error"`, Type: protocol.FormFieldTypeLazyEnum{ - Kind: protocol.FormFieldKindLazyEnum, + Kind: "lazyEnum", Source: "workspaceSymbol", Config: mustMarshal(InteractiveWorkspaceSymbolEnumConfig{ Kinds: []protocol.SymbolKind{protocol.Interface}, @@ -217,32 +214,10 @@ var implementInterfaceFormString = []protocol.FormField{ ID: "interface", Description: `fully qualified interface identifier path/to/pkg.interface; e.g., "net.Error"`, Type: protocol.FormFieldTypeString{ - Kind: protocol.FormFieldKindString, - }, - Required: true, - Default: "error", - }, -} - -var moveDeclarationFormString = []protocol.FormField{ - { - ID: "file", - Description: "destination file uri for the moved declaration, e.g. file:///path/to/file.go", - Type: protocol.FormFieldTypeFile{ Kind: "string", }, Required: true, - }, -} - -var moveDeclarationFormFile = []protocol.FormField{ - { - ID: "file", - Description: "destination file for the moved declaration", - Type: protocol.FormFieldTypeFile{ - Kind: "file", - }, - Required: true, + Default: "error", }, } @@ -280,7 +255,7 @@ func resolveImplementInterface(options settings.ClientOptions, param *protocol.E if ifaceStr == "error" { return nil } - pkgPath, ifaceName, ok := strings.CutLast(ifaceStr, ".") + pkgPath, ifaceName, ok := morestrings.CutLast(ifaceStr, ".") if !ok { return fmt.Errorf(`invalid interface type name: want string of form "example.com/pkg.Type", got %q`, ifaceStr) } @@ -310,39 +285,6 @@ func resolveImplementInterface(options settings.ClientOptions, param *protocol.E return nil } -func resolveMoveDeclaration(options settings.ClientOptions, param *protocol.ExecuteCommandParams) error { - var a0 command.MoveDeclarationArgs - if err := command.UnmarshalArgs(param.Arguments, &a0); err != nil { - return err - } - var form []protocol.FormField - if ok := options.SupportedInteractiveInputTypes[settings.InteractiveInputTypeFile]; ok { - form = moveDeclarationFormFile - } else if ok := options.SupportedInteractiveInputTypes[settings.InteractiveInputTypeString]; ok { - form = moveDeclarationFormString - } else { - // This should not happen because gopls should not offer this code action if the - // language client does not support any kind above. - return fmt.Errorf("internal error: unsupported interactive input types: %v", options.SupportedInteractiveInputTypes) - } - - // First call, return the empty form. - if len(param.FormAnswers) == 0 { - param.FormFields = form - return nil - } - - file, err := FormAnswer[string](¶m.InteractiveParams, "file") - if err != nil { - return err - } - if _, err := protocol.ParseDocumentURI(file); err != nil { - return err - } - param.FormFields = nil - return nil -} - // FormAnswer finds, validates, and returns the unique answer for id. // // It uses a linear scan since the number of answers is small (usually < 5). diff --git a/vendor/golang.org/x/tools/gopls/internal/golang/splitpkg/splitpkg.go b/vendor/golang.org/x/tools/gopls/internal/golang/splitpkg/splitpkg.go index 747cecfaa6..32371ddb23 100644 --- a/vendor/golang.org/x/tools/gopls/internal/golang/splitpkg/splitpkg.go +++ b/vendor/golang.org/x/tools/gopls/internal/golang/splitpkg/splitpkg.go @@ -66,8 +66,8 @@ import ( "golang.org/x/tools/gopls/internal/cache/metadata" "golang.org/x/tools/gopls/internal/filecache" "golang.org/x/tools/gopls/internal/protocol" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/gopls/internal/util/safetoken" - "golang.org/x/tools/internal/moremaps" "golang.org/x/tools/internal/typesinternal" ) diff --git a/vendor/golang.org/x/tools/gopls/internal/licenses/gen-licenses.sh b/vendor/golang.org/x/tools/gopls/internal/licenses/gen-licenses.sh index ab62cce654..b615e56632 100644 --- a/vendor/golang.org/x/tools/gopls/internal/licenses/gen-licenses.sh +++ b/vendor/golang.org/x/tools/gopls/internal/licenses/gen-licenses.sh @@ -10,6 +10,17 @@ output=$1 tempfile=$(mktemp) cd $(dirname $0) +cat > $tempfile <> $tempfile done +echo "\`" >> $tempfile mv $tempfile $output diff --git a/vendor/golang.org/x/tools/gopls/internal/licenses/licenses.go b/vendor/golang.org/x/tools/gopls/internal/licenses/licenses.go index fef2009181..f57856de4e 100644 --- a/vendor/golang.org/x/tools/gopls/internal/licenses/licenses.go +++ b/vendor/golang.org/x/tools/gopls/internal/licenses/licenses.go @@ -2,10 +2,573 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:generate ./gen-licenses.sh licenses.txt +//go:generate ./gen-licenses.sh licenses.go package licenses -import _ "embed" +const Text = ` +-- github.com/BurntSushi/toml COPYING -- -//go:embed licenses.txt -var Text string +The MIT License (MIT) + +Copyright (c) 2013 TOML authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-- github.com/fatih/camelcase LICENSE.md -- + +The MIT License (MIT) + +Copyright (c) 2015 Fatih Arslan + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-- github.com/fatih/gomodifytags LICENSE -- + +Copyright (c) 2017, Fatih Arslan +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 gomodifytags 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 HOLDER 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. + +-- github.com/fatih/structtag LICENSE -- + +Copyright (c) 2017, Fatih Arslan +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 structtag 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 HOLDER 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. + +This software includes some portions from Go. Go is used under the terms of the +BSD like license. + +Copyright (c) 2012 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. + +The Go gopher was designed by Renee French. http://reneefrench.blogspot.com/ The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: https://blog.golang.org/gopher + +-- github.com/fsnotify/fsnotify LICENSE -- + +Copyright © 2012 The Go Authors. All rights reserved. +Copyright © fsnotify 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. + +-- github.com/google/jsonschema-go LICENSE -- + +MIT License + +Copyright (c) 2025 JSON Schema Go Project Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-- github.com/modelcontextprotocol/go-sdk LICENSE -- + +The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0. + +Contributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License. + +No rights beyond those granted by the applicable original license are conveyed for such contributions. + +--- + + 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 + +--- + +MIT License + +Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- + +Creative Commons Attribution 4.0 International (CC-BY-4.0) + +Documentation in this project (excluding specifications) is licensed under +CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for +the full license text. + +-- github.com/segmentio/asm LICENSE -- + +MIT No Attribution + +Copyright 2023 Segment + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-- github.com/segmentio/encoding LICENSE -- + +MIT License + +Copyright (c) 2019 Segment.io, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-- github.com/yosida95/uritemplate/v3 LICENSE -- + +Copyright (C) 2016, Kohei YOSHIDA . 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 the copyright holder 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 +HOLDER 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. + +-- honnef.co/go/tools LICENSE -- + +Copyright (c) 2016 Dominik Honnef + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-- mvdan.cc/gofumpt LICENSE -- + +Copyright (c) 2019, Daniel Martí. 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 the copyright holder 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. + +-- mvdan.cc/xurls/v2 LICENSE -- + +Copyright (c) 2015, Daniel Martí. 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 the copyright holder 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/tools/gopls/internal/licenses/licenses.txt b/vendor/golang.org/x/tools/gopls/internal/licenses/licenses.txt deleted file mode 100644 index 19970f21e7..0000000000 --- a/vendor/golang.org/x/tools/gopls/internal/licenses/licenses.txt +++ /dev/null @@ -1,565 +0,0 @@ --- github.com/BurntSushi/toml COPYING -- - -The MIT License (MIT) - -Copyright (c) 2013 TOML authors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - --- github.com/fatih/camelcase LICENSE.md -- - -The MIT License (MIT) - -Copyright (c) 2015 Fatih Arslan - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - --- github.com/fatih/gomodifytags LICENSE -- - -Copyright (c) 2017, Fatih Arslan -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 gomodifytags 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 HOLDER 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. - --- github.com/fatih/structtag LICENSE -- - -Copyright (c) 2017, Fatih Arslan -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 structtag 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 HOLDER 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. - -This software includes some portions from Go. Go is used under the terms of the -BSD like license. - -Copyright (c) 2012 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. - -The Go gopher was designed by Renee French. http://reneefrench.blogspot.com/ The design is licensed under the Creative Commons 3.0 Attributions license. Read this article for more details: https://blog.golang.org/gopher - --- github.com/fsnotify/fsnotify LICENSE -- - -Copyright © 2012 The Go Authors. All rights reserved. -Copyright © fsnotify 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. - --- github.com/google/jsonschema-go LICENSE -- - -MIT License - -Copyright (c) 2025 JSON Schema Go Project Authors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - --- github.com/modelcontextprotocol/go-sdk LICENSE -- - -The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0. - -Contributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License. - -No rights beyond those granted by the applicable original license are conveyed for such contributions. - ---- - - 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 - ---- - -MIT License - -Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - ---- - -Creative Commons Attribution 4.0 International (CC-BY-4.0) - -Documentation in this project (excluding specifications) is licensed under -CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for -the full license text. - --- github.com/segmentio/asm LICENSE -- - -MIT No Attribution - -Copyright 2023 Segment - -Permission is hereby granted, free of charge, to any person obtaining a copy of this -software and associated documentation files (the "Software"), to deal in the Software -without restriction, including without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - --- github.com/segmentio/encoding LICENSE -- - -MIT License - -Copyright (c) 2019 Segment.io, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - --- github.com/yosida95/uritemplate/v3 LICENSE -- - -Copyright (C) 2016, Kohei YOSHIDA . 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 the copyright holder 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 -HOLDER 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. - --- honnef.co/go/tools LICENSE -- - -Copyright (c) 2016 Dominik Honnef - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - --- mvdan.cc/gofumpt LICENSE -- - -Copyright (c) 2019, Daniel Martí. 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 the copyright holder 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. - --- mvdan.cc/xurls/v2 LICENSE -- - -Copyright (c) 2015, Daniel Martí. 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 the copyright holder 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/tools/gopls/internal/lsprpc/lsprpc.go b/vendor/golang.org/x/tools/gopls/internal/lsprpc/lsprpc.go index 95554249f9..c3228c516c 100644 --- a/vendor/golang.org/x/tools/gopls/internal/lsprpc/lsprpc.go +++ b/vendor/golang.org/x/tools/gopls/internal/lsprpc/lsprpc.go @@ -33,7 +33,7 @@ import ( ) // Unique identifiers for client/server. -var serverIndex atomic.Int64 +var serverIndex int64 // The streamServer type is a jsonrpc2.streamServer that handles incoming // streams as a new LSP session, using a shared cache. @@ -267,7 +267,7 @@ func (f *forwarder) ServeStream(ctx context.Context, clientConn jsonrpc2.Conn) e // processing any client messages. // Do a handshake with the server instance to exchange debug information. - index := serverIndex.Add(1) + index := atomic.AddInt64(&serverIndex, 1) f.mu.Lock() f.serverConn = serverConn f.serverID = strconv.FormatInt(index, 10) diff --git a/vendor/golang.org/x/tools/gopls/internal/mcp/context.go b/vendor/golang.org/x/tools/gopls/internal/mcp/context.go index 13b665d219..f7ec8ff2fb 100644 --- a/vendor/golang.org/x/tools/gopls/internal/mcp/context.go +++ b/vendor/golang.org/x/tools/gopls/internal/mcp/context.go @@ -108,7 +108,7 @@ func (h *handler) contextHandler(ctx context.Context, req *mcp.CallToolRequest, // Skip the standard library to reduce token usage, operating on // the assumption that the LLM is already familiar with its // symbols and documentation. - if packagepath.MaybeStdPackage(spec.Path.Value) { + if packagepath.IsStdPackage(spec.Path.Value) { continue } toSummarize = append(toSummarize, spec) diff --git a/vendor/golang.org/x/tools/gopls/internal/mcp/file_diagnostics.go b/vendor/golang.org/x/tools/gopls/internal/mcp/file_diagnostics.go index 429bcda6fe..da2cd5c6ec 100644 --- a/vendor/golang.org/x/tools/gopls/internal/mcp/file_diagnostics.go +++ b/vendor/golang.org/x/tools/gopls/internal/mcp/file_diagnostics.go @@ -86,7 +86,7 @@ func (h *handler) diagnoseFile(ctx context.Context, snapshot *cache.Snapshot, ur actionMap := make(map[key]*protocol.CodeAction) for _, action := range actions { for _, d := range action.Diagnostics { - k := key{d.MessageString(), d.Range} + k := key{d.Message, d.Range} if alt, ok := actionMap[k]; !ok || !alt.IsPreferred && action.IsPreferred { actionMap[k] = &action } diff --git a/vendor/golang.org/x/tools/gopls/internal/mcp/mcp.go b/vendor/golang.org/x/tools/gopls/internal/mcp/mcp.go index e00e92ce93..988e206565 100644 --- a/vendor/golang.org/x/tools/gopls/internal/mcp/mcp.go +++ b/vendor/golang.org/x/tools/gopls/internal/mcp/mcp.go @@ -23,7 +23,7 @@ import ( "golang.org/x/tools/gopls/internal/file" "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/settings" - "golang.org/x/tools/internal/moremaps" + "golang.org/x/tools/gopls/internal/util/moremaps" ) //go:embed instructions.md @@ -56,22 +56,18 @@ func Serve(ctx context.Context, address string, sessions Sessions, isDaemon bool if strings.HasPrefix(address, ":") { return fmt.Errorf("address %s implicitly binds all network interfaces; please use an explicit host such as 0.0.0.0 (all interfaces) or localhost (safer)", address) } - + log.Printf("Gopls MCP server: starting up on http") listener, err := net.Listen("tcp", address) if err != nil { return err } defer listener.Close() - { - kind := "server" - if isDaemon { - kind = "daemon" - } - - log.Printf("Gopls MCP %s: listening on %s", kind, listener.Addr()) - defer log.Printf("Gopls MCP %s: exiting", kind) + // TODO(hxjiang): expose the MCP server address to the LSP client. + if isDaemon { + log.Printf("Gopls MCP daemon: listening on address %s...", listener.Addr()) } + defer log.Printf("Gopls MCP server: exiting") svr := http.Server{ Handler: HTTPHandler(sessions, isDaemon, rootsHandler), @@ -85,6 +81,7 @@ func Serve(ctx context.Context, address string, sessions Sessions, isDaemon bool <-ctx.Done() svr.Close() // ignore error }() + log.Printf("mcp http server listening") return svr.Serve(listener) } diff --git a/vendor/golang.org/x/tools/gopls/internal/mcp/references.go b/vendor/golang.org/x/tools/gopls/internal/mcp/references.go index 2e82a428ca..d49bce1bab 100644 --- a/vendor/golang.org/x/tools/gopls/internal/mcp/references.go +++ b/vendor/golang.org/x/tools/gopls/internal/mcp/references.go @@ -62,7 +62,7 @@ func formatReferences(ctx context.Context, snapshot *cache.Snapshot, refs []prot } else { continue } - fmt.Fprintf(&builder, "The reference is located on line %v, which has content `%s`\n", r.Range.Start.Line+1, lineContent) + fmt.Fprintf(&builder, "The reference is located on line %v, which has content `%s`\n", r.Range.Start.Line, lineContent) builder.WriteString("\n") } return textResult(builder.String()), nil diff --git a/vendor/golang.org/x/tools/gopls/internal/mod/code_lens.go b/vendor/golang.org/x/tools/gopls/internal/mod/code_lens.go index 45ebb2e851..038fd20c43 100644 --- a/vendor/golang.org/x/tools/gopls/internal/mod/code_lens.go +++ b/vendor/golang.org/x/tools/gopls/internal/mod/code_lens.go @@ -35,7 +35,7 @@ func upgradeLenses(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle return nil, err } uri := fh.URI() - reset := command.NewResetGoModDiagnosticsCommand("Reset go.mod diagnostics", command.ResetGoModDiagnosticsArgs{URI: uri}) + reset := command.NewResetGoModDiagnosticsCommand("Reset go.mod diagnostics", command.ResetGoModDiagnosticsArgs{URIArg: command.URIArg{URI: uri}}) // Put the `Reset go.mod diagnostics` codelens on the module statement. modrng, err := moduleStmtRange(fh, pm) if err != nil { diff --git a/vendor/golang.org/x/tools/gopls/internal/mod/diagnostics.go b/vendor/golang.org/x/tools/gopls/internal/mod/diagnostics.go index f8ef7c3ce5..52f3704ed0 100644 --- a/vendor/golang.org/x/tools/gopls/internal/mod/diagnostics.go +++ b/vendor/golang.org/x/tools/gopls/internal/mod/diagnostics.go @@ -24,7 +24,6 @@ import ( "golang.org/x/tools/gopls/internal/settings" "golang.org/x/tools/gopls/internal/vulncheck/govulncheck" "golang.org/x/tools/internal/event" - "golang.org/x/tools/internal/moremaps" ) // ParseDiagnostics returns diagnostics from parsing the go.mod files in the workspace. @@ -422,9 +421,12 @@ func foundVuln(finding *govulncheck.Finding) (*govulncheck.Frame, vulnFindingTyp } func sortedKeys(m map[string]bool) []string { - keys := moremaps.KeySlice(m) - sort.Strings(keys) - return keys + ret := make([]string, 0, len(m)) + for k := range m { + ret = append(ret, k) + } + sort.Strings(ret) + return ret } // suggestGovulncheckAction returns a code action that suggests either run govulncheck @@ -434,7 +436,7 @@ func sortedKeys(m map[string]bool) []string { func suggestGovulncheckAction(fromGovulncheck bool, uri protocol.DocumentURI) (cache.SuggestedFix, error) { if fromGovulncheck { resetVulncheck := command.NewResetGoModDiagnosticsCommand("Reset govulncheck result", command.ResetGoModDiagnosticsArgs{ - URI: uri, + URIArg: command.URIArg{URI: uri}, DiagnosticSource: string(cache.Govulncheck), }) return cache.SuggestedFixFromCommand(resetVulncheck, protocol.QuickFix), nil diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/command/command_gen.go b/vendor/golang.org/x/tools/gopls/internal/protocol/command/command_gen.go index 16b5a40e8c..7d8c47c3f2 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/command/command_gen.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/command/command_gen.go @@ -50,7 +50,6 @@ const ( MemStats Command = "gopls.mem_stats" ModifyTags Command = "gopls.modify_tags" Modules Command = "gopls.modules" - MoveDeclaration Command = "gopls.move_declaration" MoveType Command = "gopls.move_type" PackageSymbols Command = "gopls.package_symbols" Packages Command = "gopls.packages" @@ -101,7 +100,6 @@ var Commands = []Command{ MemStats, ModifyTags, Modules, - MoveDeclaration, MoveType, PackageSymbols, Packages, @@ -278,12 +276,6 @@ func Dispatch(ctx context.Context, params *protocol.ExecuteCommandParams, s Inte return nil, err } return s.Modules(ctx, a0) - case MoveDeclaration: - var a0 MoveDeclarationArgs - if err := UnmarshalArgs(params.Arguments, &a0); err != nil { - return nil, err - } - return nil, s.MoveDeclaration(ctx, a0, ¶ms.InteractiveParams) case MoveType: var a0 MoveTypeArgs if err := UnmarshalArgs(params.Arguments, &a0); err != nil { @@ -611,14 +603,6 @@ func NewModulesCommand(title string, a0 ModulesArgs) *protocol.Command { } } -func NewMoveDeclarationCommand(title string, a0 MoveDeclarationArgs) *protocol.Command { - return &protocol.Command{ - Title: title, - Command: MoveDeclaration.String(), - Arguments: MustMarshalArgs(a0), - } -} - func NewMoveTypeCommand(title string, a0 MoveTypeArgs) *protocol.Command { return &protocol.Command{ Title: title, diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/command/interface.go b/vendor/golang.org/x/tools/gopls/internal/protocol/command/interface.go index 80ece52589..d1757ae214 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/command/interface.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/command/interface.go @@ -204,7 +204,7 @@ type Interface interface { // runner. StopProfile(context.Context, StopProfileArgs) (StopProfileResult, error) - // Vulncheck: run vulncheck synchronously. + // GoVulncheck: run vulncheck synchronously. // // Run vulnerability check (`govulncheck`). // @@ -336,9 +336,6 @@ type Interface interface { // ImplementInterface: Add methods to a type to implement an interface. ImplementInterface(context.Context, ImplementInterfaceArgs, *protocol.InteractiveParams) error - - // MoveDeclaration: Move a declaration to a different file. - MoveDeclaration(context.Context, MoveDeclarationArgs, *protocol.InteractiveParams) error } type RunTestsArgs struct { @@ -917,9 +914,3 @@ type MoveTypeArgs struct { // TODO(mkalil): Determine format of the parameter that specifies where to // move the type to. } - -// MoveDeclarationArgs specifies a "move declaration" refactoring to perform. -type MoveDeclarationArgs struct { - // The location of the declaration to move. - Location protocol.Location -} diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/enums.go b/vendor/golang.org/x/tools/gopls/internal/protocol/enums.go index b78c6b8582..74a8a31677 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/enums.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/enums.go @@ -15,7 +15,7 @@ const CodeActionUnknownTrigger CodeActionTriggerKind = 0 var ( namesTextDocumentSyncKind [int(Incremental) + 1]string - namesMessageType [int(Debug) + 1]string + namesMessageType [int(Log) + 1]string namesFileChangeType [int(Deleted) + 1]string namesWatchKind [int(WatchDelete) + 1]string namesCompletionTriggerKind [int(TriggerForIncompleteCompletions) + 1]string @@ -37,7 +37,6 @@ func init() { namesMessageType[int(Warning)] = "Warning" namesMessageType[int(Info)] = "Info" namesMessageType[int(Log)] = "Log" - namesMessageType[int(Debug)] = "Debug" namesFileChangeType[int(Created)] = "Created" namesFileChangeType[int(Changed)] = "Changed" diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/form.go b/vendor/golang.org/x/tools/gopls/internal/protocol/form.go index da959ef32b..d4871f2b0b 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/form.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/form.go @@ -20,25 +20,12 @@ type InteractiveResolveOptions struct { Kinds []string `json:"kinds"` } -// FormFieldKind represents the supported input kinds for form fields. -type FormFieldKind string - -const ( - FormFieldKindString FormFieldKind = "string" - FormFieldKindFile FormFieldKind = "file" - FormFieldKindBool FormFieldKind = "bool" - FormFieldKindNumber FormFieldKind = "number" - FormFieldKindEnum FormFieldKind = "enum" - FormFieldKindLazyEnum FormFieldKind = "lazyEnum" - FormFieldKindList FormFieldKind = "list" -) - // InteractiveResolveClientCapabilities represents the client capabilities for // interactive resolve. type InteractiveResolveClientCapabilities struct { // The input types the client supports for interactive dialogs. // The presence of this field implies support for interactive refactoring. - InputTypes []FormFieldKind `json:"inputTypes"` + InputTypes []string `json:"inputTypes"` } // FormFieldTypeString defines a text input. @@ -47,7 +34,7 @@ type InteractiveResolveClientCapabilities struct { // adding regex validation or file URI constraints. type FormFieldTypeString struct { // Kind must be "string". - Kind FormFieldKind `json:"kind"` + Kind string `json:"kind"` } // FileExistence whether the file denoted by a DocumentURI exists. @@ -86,7 +73,7 @@ const ( // https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentUri type FormFieldTypeFile struct { // Kind must be "file". - Kind FormFieldKind `json:"kind"` + Kind string `json:"kind"` // Existence constraint. Existence FileExistence `json:"existence"` @@ -106,7 +93,7 @@ type FormFieldTypeFile struct { // FormFieldTypeBool defines a boolean input. type FormFieldTypeBool struct { // Kind must be "bool". - Kind FormFieldKind `json:"kind"` + Kind string `json:"kind"` } // FormFieldTypeNumber defines a numeric input. @@ -115,7 +102,7 @@ type FormFieldTypeBool struct { // adding range constraints (min/max) or precision requirements. type FormFieldTypeNumber struct { // Kind must be "number". - Kind FormFieldKind `json:"kind"` + Kind string `json:"kind"` } // FormEnumEntry represents a single option in an enumeration. @@ -137,7 +124,7 @@ type FormEnumEntry struct { // - All options are known at the time the form is created. type FormFieldTypeEnum struct { // Kind must be "enum". - Kind FormFieldKind `json:"kind"` + Kind string `json:"kind"` // Entries is the list of allowable options. Entries []FormEnumEntry `json:"entries"` @@ -155,7 +142,7 @@ type FormFieldTypeEnum struct { // a text input) and query the server via 'interactive/listEnum' as the user types. type FormFieldTypeLazyEnum struct { // Kind must be "lazyEnum". - Kind FormFieldKind `json:"kind"` + Kind string `json:"kind"` // TODO(hxjiang): consider make debounce configurable since fetching // cloud resources could be expensive and slow. @@ -174,7 +161,7 @@ type FormFieldTypeLazyEnum struct { // FormFieldTypeList defines a homogeneous list of items. type FormFieldTypeList struct { // Kind must be "list". - Kind FormFieldKind `json:"kind"` + Kind string `json:"kind"` // ElementType specifies the type of the items in the list. // It must be one of the FormFieldType* structs (e.g., FormFieldTypeString). diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/protocol.go b/vendor/golang.org/x/tools/gopls/internal/protocol/protocol.go index 2cb56d7768..91bab44feb 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/protocol.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/protocol.go @@ -294,8 +294,3 @@ func NonNilSlice[T comparable](x []T) []T { } return x } - -// MessageString returns the string value of diag.Message. -func (diag Diagnostic) MessageString() string { - return diag.Message.Value.(string) // gopls only produces strings -} diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/semtok/semtok.go b/vendor/golang.org/x/tools/gopls/internal/protocol/semtok/semtok.go index f384f36baa..1ed078528e 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/semtok/semtok.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/semtok/semtok.go @@ -44,9 +44,6 @@ const ( // // If you move types to above, document it in // gopls/doc/features/passive.md#semantic-tokens. - // - // Sync any changes below with the vscode-go custom token type list. - // See: extension/src/language/goSemanticTokens.ts // TokClass Type = "class" // TokDecorator Type = "decorator" // TokEnum Type = "enum" @@ -106,9 +103,6 @@ const ( // Since the type of a symbol is orthogonal to its kind, // (e.g. a variable can have function type), // we use modifiers for the top-level type constructor. - // - // Sync any changes below with the vscode-go custom token modifier list. - // See: extension/src/language/goSemanticTokens.ts ModArray Modifier = "array" ModBool Modifier = "bool" ModChan Modifier = "chan" @@ -149,8 +143,8 @@ var Modifiers = []Modifier{ // Encode returns the LSP encoding of a sequence of tokens. // encodeType and encodeModifier maps control which types and modifiers are -// included in the response. A type or modifier must exist in the map and map -// to true to be included in the output. +// excluded in the response. If a type or modifier maps to false, it will be +// omitted from the output. func Encode( tokens []Token, encodeType map[Type]bool, @@ -166,16 +160,18 @@ func Encode( typeMap := make(map[Type]uint32) for i, t := range Types { - if enable, ok := encodeType[t]; ok && enable { - typeMap[Type(t)] = uint32(i) + if enable, ok := encodeType[t]; ok && !enable { + continue } + typeMap[Type(t)] = uint32(i) } modMap := make(map[Modifier]uint32) for i, m := range Modifiers { - if enable, ok := encodeModifier[m]; ok && enable { - modMap[Modifier(m)] = 1 << i + if enable, ok := encodeModifier[m]; ok && !enable { + continue } + modMap[Modifier(m)] = 1 << i } // Each semantic token needs five values but some tokens might be skipped. diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/tsclient.go b/vendor/golang.org/x/tools/gopls/internal/protocol/tsclient.go index 29e7b8ce92..b33271e777 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/tsclient.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/tsclient.go @@ -6,9 +6,9 @@ package protocol -// Code generated from protocol/metaModel.json at ref release/protocol/3.18.2 (hash 20969f3e75cb3cd35c2bb794b1d15cc2dfbe4abb). -// https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.18.2/protocol/metaModel.json -// LSP metaData.version = 3.18.0. +// Code generated from protocol/metaModel.json at ref release/protocol/3.17.6-next.14 (hash 66a087310eea0d60495ba3578d78f70409c403d9). +// https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.17.6-next.14/protocol/metaModel.json +// LSP metaData.version = 3.17.0. import ( "context" @@ -19,47 +19,47 @@ import ( ) type Client interface { - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#logTrace + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#logTrace LogTrace(context.Context, *LogTraceParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#progress + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progress Progress(context.Context, *ProgressParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#client_registerCapability + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#client_registerCapability RegisterCapability(context.Context, *RegistrationParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#client_unregisterCapability + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#client_unregisterCapability UnregisterCapability(context.Context, *UnregistrationParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#telemetry_event + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#telemetry_event Event(context.Context, *any) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_publishDiagnostics + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_publishDiagnostics PublishDiagnostics(context.Context, *PublishDiagnosticsParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#window_logMessage + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_logMessage LogMessage(context.Context, *LogMessageParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#window_showDocument + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_showDocument ShowDocument(context.Context, *ShowDocumentParams) (*ShowDocumentResult, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#window_showMessage + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_showMessage ShowMessage(context.Context, *ShowMessageParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#window_showMessageRequest + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_showMessageRequest ShowMessageRequest(context.Context, *ShowMessageRequestParams) (*MessageActionItem, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#window_workDoneProgress_create + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_workDoneProgress_create WorkDoneProgressCreate(context.Context, *WorkDoneProgressCreateParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_applyEdit + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_applyEdit ApplyEdit(context.Context, *ApplyWorkspaceEditParams) (*ApplyWorkspaceEditResult, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_codeLens_refresh + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_codeLens_refresh CodeLensRefresh(context.Context) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_configuration + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_configuration Configuration(context.Context, *ParamConfiguration) ([]LSPAny, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_diagnostic_refresh + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_diagnostic_refresh DiagnosticRefresh(context.Context) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_foldingRange_refresh + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_foldingRange_refresh FoldingRangeRefresh(context.Context) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_inlayHint_refresh + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_inlayHint_refresh InlayHintRefresh(context.Context) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_inlineValue_refresh + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_inlineValue_refresh InlineValueRefresh(context.Context) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_semanticTokens_refresh + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_semanticTokens_refresh SemanticTokensRefresh(context.Context) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_textDocumentContent_refresh + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_textDocumentContent_refresh TextDocumentContentRefresh(context.Context, *TextDocumentContentRefreshParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_workspaceFolders + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_workspaceFolders WorkspaceFolders(context.Context) ([]WorkspaceFolder, error) } diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/tsjson.go b/vendor/golang.org/x/tools/gopls/internal/protocol/tsjson.go index c3d25e081a..9e26ae06cb 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/tsjson.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/tsjson.go @@ -6,14 +6,13 @@ package protocol -// Code generated from protocol/metaModel.json at ref release/protocol/3.18.2 (hash 20969f3e75cb3cd35c2bb794b1d15cc2dfbe4abb). -// https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.18.2/protocol/metaModel.json -// LSP metaData.version = 3.18.0. +// Code generated from protocol/metaModel.json at ref release/protocol/3.17.6-next.14 (hash 66a087310eea0d60495ba3578d78f70409c403d9). +// https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.17.6-next.14/protocol/metaModel.json +// LSP metaData.version = 3.17.0. -import ( - "encoding/json" - "fmt" -) +import "encoding/json" + +import "fmt" // UnmarshalError indicates that a JSON value did not conform to // one of the expected cases of an LSP union type. @@ -21,7 +20,7 @@ type UnmarshalError struct { msg string } -func (e *UnmarshalError) Error() string { +func (e UnmarshalError) Error() string { return e.msg } func (t OrPLocation_workspace_symbol) MarshalJSON() ([]byte, error) { @@ -384,36 +383,6 @@ func (t *Or_Diagnostic_code) UnmarshalJSON(x []byte) error { return &UnmarshalError{"unmarshal failed to match one of [int32 string]"} } -func (t Or_Diagnostic_message) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { - case MarkupContent: - return json.Marshal(x) - case string: - return json.Marshal(x) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("type %T not one of [MarkupContent string]", t) -} - -func (t *Or_Diagnostic_message) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil - return nil - } - var h0 MarkupContent - if err := json.Unmarshal(x, &h0); err == nil { - t.Value = h0 - return nil - } - var h1 string - if err := json.Unmarshal(x, &h1); err == nil { - t.Value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [MarkupContent string]"} -} - func (t Or_DocumentDiagnosticReport) MarshalJSON() ([]byte, error) { switch x := t.Value.(type) { case RelatedFullDocumentDiagnosticReport: @@ -474,36 +443,6 @@ func (t *Or_DocumentDiagnosticReportPartialResult_relatedDocuments_Value) Unmars return &UnmarshalError{"unmarshal failed to match one of [FullDocumentDiagnosticReport UnchangedDocumentDiagnosticReport]"} } -func (t Or_DocumentDiagnosticReportProgress) MarshalJSON() ([]byte, error) { - switch x := t.Value.(type) { - case DocumentDiagnosticReport: - return json.Marshal(x) - case DocumentDiagnosticReportPartialResult: - return json.Marshal(x) - case nil: - return []byte("null"), nil - } - return nil, fmt.Errorf("type %T not one of [DocumentDiagnosticReport DocumentDiagnosticReportPartialResult]", t) -} - -func (t *Or_DocumentDiagnosticReportProgress) UnmarshalJSON(x []byte) error { - if string(x) == "null" { - t.Value = nil - return nil - } - var h0 DocumentDiagnosticReport - if err := json.Unmarshal(x, &h0); err == nil { - t.Value = h0 - return nil - } - var h1 DocumentDiagnosticReportPartialResult - if err := json.Unmarshal(x, &h1); err == nil { - t.Value = h1 - return nil - } - return &UnmarshalError{"unmarshal failed to match one of [DocumentDiagnosticReport DocumentDiagnosticReportPartialResult]"} -} - func (t Or_DocumentFilter) MarshalJSON() ([]byte, error) { switch x := t.Value.(type) { case NotebookCellTextDocumentFilter: diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/tsprotocol.go b/vendor/golang.org/x/tools/gopls/internal/protocol/tsprotocol.go index ed00878edd..023883ea04 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/tsprotocol.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/tsprotocol.go @@ -6,9 +6,9 @@ package protocol -// Code generated from protocol/metaModel.json at ref release/protocol/3.18.2 (hash 20969f3e75cb3cd35c2bb794b1d15cc2dfbe4abb). -// https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.18.2/protocol/metaModel.json -// LSP metaData.version = 3.18.0. +// Code generated from protocol/metaModel.json at ref release/protocol/3.17.6-next.14 (hash 66a087310eea0d60495ba3578d78f70409c403d9). +// https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.17.6-next.14/protocol/metaModel.json +// LSP metaData.version = 3.17.0. import "encoding/json" @@ -16,7 +16,7 @@ import "encoding/json" // // @since 3.16.0. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#annotatedTextEdit +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#annotatedTextEdit type AnnotatedTextEdit struct { // The actual identifier of the change annotation AnnotationID *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` @@ -31,7 +31,7 @@ type ApplyKind uint32 // The parameters passed via an apply workspace edit request. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#applyWorkspaceEditParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#applyWorkspaceEditParams type ApplyWorkspaceEditParams struct { // An optional label of the workspace edit. This label is // presented in the user interface for example on an undo @@ -42,6 +42,7 @@ type ApplyWorkspaceEditParams struct { // Additional data about the edit. // // @since 3.18.0 + // @proposed Metadata *WorkspaceEditMetadata `json:"metadata,omitempty"` } @@ -49,7 +50,7 @@ type ApplyWorkspaceEditParams struct { // // @since 3.17 renamed from ApplyWorkspaceEditResponse // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#applyWorkspaceEditResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#applyWorkspaceEditResult type ApplyWorkspaceEditResult struct { // Indicates whether the edit was applied or not. Applied bool `json:"applied"` @@ -65,7 +66,7 @@ type ApplyWorkspaceEditResult struct { // A base for all symbol information. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#baseSymbolInformation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#baseSymbolInformation type BaseSymbolInformation struct { // The name of this symbol. Name string `json:"name"` @@ -84,7 +85,7 @@ type BaseSymbolInformation struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyClientCapabilities type CallHierarchyClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to `true` // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -96,7 +97,7 @@ type CallHierarchyClientCapabilities struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyIncomingCall +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyIncomingCall type CallHierarchyIncomingCall struct { // The item that makes the call. From CallHierarchyItem `json:"from"` @@ -109,7 +110,7 @@ type CallHierarchyIncomingCall struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyIncomingCallsParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyIncomingCallsParams type CallHierarchyIncomingCallsParams struct { Item CallHierarchyItem `json:"item"` WorkDoneProgressParams @@ -121,7 +122,7 @@ type CallHierarchyIncomingCallsParams struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyItem +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyItem type CallHierarchyItem struct { // The name of this item. Name string `json:"name"` @@ -147,7 +148,7 @@ type CallHierarchyItem struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyOptions type CallHierarchyOptions struct { WorkDoneProgressOptions } @@ -156,7 +157,7 @@ type CallHierarchyOptions struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyOutgoingCall +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyOutgoingCall type CallHierarchyOutgoingCall struct { // The item that is called. To CallHierarchyItem `json:"to"` @@ -170,7 +171,7 @@ type CallHierarchyOutgoingCall struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyOutgoingCallsParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyOutgoingCallsParams type CallHierarchyOutgoingCallsParams struct { Item CallHierarchyItem `json:"item"` WorkDoneProgressParams @@ -181,7 +182,7 @@ type CallHierarchyOutgoingCallsParams struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyPrepareParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyPrepareParams type CallHierarchyPrepareParams struct { TextDocumentPositionParams WorkDoneProgressParams @@ -191,14 +192,14 @@ type CallHierarchyPrepareParams struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchyRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchyRegistrationOptions type CallHierarchyRegistrationOptions struct { TextDocumentRegistrationOptions CallHierarchyOptions StaticRegistrationOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#cancelParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#cancelParams type CancelParams struct { // The request id to cancel. ID any `json:"id"` @@ -208,7 +209,7 @@ type CancelParams struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#changeAnnotation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotation type ChangeAnnotation struct { // A human-readable string describing the actual change. The string // is rendered prominent in the user interface. @@ -223,11 +224,11 @@ type ChangeAnnotation struct { // An identifier to refer to a change annotation stored with a workspace edit. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#changeAnnotationIdentifier +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotationIdentifier type ChangeAnnotationIdentifier = string // (alias) // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#changeAnnotationsSupportOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#changeAnnotationsSupportOptions type ChangeAnnotationsSupportOptions struct { // Whether the client groups edits with equal labels into tree nodes, // for instance all edits labelled with "Changes in Strings" would @@ -237,7 +238,7 @@ type ChangeAnnotationsSupportOptions struct { // Defines the capabilities provided by the client. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCapabilities type ClientCapabilities struct { // Workspace specific client capabilities. Workspace WorkspaceClientCapabilities `json:"workspace,omitempty"` @@ -259,7 +260,7 @@ type ClientCapabilities struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCodeActionKindOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCodeActionKindOptions type ClientCodeActionKindOptions struct { // The code action kind values the client supports. When this // property exists the client also guarantees that it will @@ -270,7 +271,7 @@ type ClientCodeActionKindOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCodeActionLiteralOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCodeActionLiteralOptions type ClientCodeActionLiteralOptions struct { // The code action kind is support with the following value // set. @@ -279,7 +280,7 @@ type ClientCodeActionLiteralOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCodeActionResolveOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCodeActionResolveOptions type ClientCodeActionResolveOptions struct { // The properties that a client can resolve lazily. Properties []string `json:"properties"` @@ -287,7 +288,7 @@ type ClientCodeActionResolveOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCodeLensResolveOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCodeLensResolveOptions type ClientCodeLensResolveOptions struct { // The properties that a client can resolve lazily. Properties []string `json:"properties"` @@ -295,14 +296,14 @@ type ClientCodeLensResolveOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCompletionItemInsertTextModeOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCompletionItemInsertTextModeOptions type ClientCompletionItemInsertTextModeOptions struct { ValueSet []InsertTextMode `json:"valueSet"` } // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCompletionItemOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCompletionItemOptions type ClientCompletionItemOptions struct { // Client supports snippets as insert text. // @@ -353,7 +354,7 @@ type ClientCompletionItemOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCompletionItemOptionsKind +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCompletionItemOptionsKind type ClientCompletionItemOptionsKind struct { // The completion item kind values the client supports. When this // property exists the client also guarantees that it will @@ -368,7 +369,7 @@ type ClientCompletionItemOptionsKind struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientCompletionItemResolveOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientCompletionItemResolveOptions type ClientCompletionItemResolveOptions struct { // The properties that a client can resolve lazily. Properties []string `json:"properties"` @@ -376,7 +377,7 @@ type ClientCompletionItemResolveOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientDiagnosticsTagOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientDiagnosticsTagOptions type ClientDiagnosticsTagOptions struct { // The tags supported by the client. ValueSet []DiagnosticTag `json:"valueSet"` @@ -384,7 +385,7 @@ type ClientDiagnosticsTagOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientFoldingRangeKindOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientFoldingRangeKindOptions type ClientFoldingRangeKindOptions struct { // The folding range kind values the client supports. When this // property exists the client also guarantees that it will @@ -395,7 +396,7 @@ type ClientFoldingRangeKindOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientFoldingRangeOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientFoldingRangeOptions type ClientFoldingRangeOptions struct { // If set, the client signals that it supports setting collapsedText on // folding ranges to display custom labels instead of the default text. @@ -409,7 +410,7 @@ type ClientFoldingRangeOptions struct { // @since 3.15.0 // @since 3.18.0 ClientInfo type name added. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientInfo +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientInfo type ClientInfo struct { // The name of the client as defined by the client. Name string `json:"name"` @@ -419,7 +420,7 @@ type ClientInfo struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientInlayHintResolveOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientInlayHintResolveOptions type ClientInlayHintResolveOptions struct { // The properties that a client can resolve lazily. Properties []string `json:"properties"` @@ -427,7 +428,7 @@ type ClientInlayHintResolveOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientSemanticTokensRequestFullDelta +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSemanticTokensRequestFullDelta type ClientSemanticTokensRequestFullDelta struct { // The client will send the `textDocument/semanticTokens/full/delta` request if // the server provides a corresponding handler. @@ -436,7 +437,7 @@ type ClientSemanticTokensRequestFullDelta struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientSemanticTokensRequestOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSemanticTokensRequestOptions type ClientSemanticTokensRequestOptions struct { // The client will send the `textDocument/semanticTokens/range` request if // the server provides a corresponding handler. @@ -448,7 +449,7 @@ type ClientSemanticTokensRequestOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientShowMessageActionItemOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientShowMessageActionItemOptions type ClientShowMessageActionItemOptions struct { // Whether the client supports additional attributes which // are preserved and send back to the server in the @@ -458,7 +459,7 @@ type ClientShowMessageActionItemOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientSignatureInformationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSignatureInformationOptions type ClientSignatureInformationOptions struct { // Client supports the following content formats for the documentation // property. The order describes the preferred format of the client. @@ -475,12 +476,13 @@ type ClientSignatureInformationOptions struct { // indicate that no parameter should be active. // // @since 3.18.0 + // @proposed NoActiveParameterSupport bool `json:"noActiveParameterSupport,omitempty"` } // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientSignatureParameterInformationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSignatureParameterInformationOptions type ClientSignatureParameterInformationOptions struct { // The client supports processing label offsets instead of a // simple label string. @@ -491,7 +493,7 @@ type ClientSignatureParameterInformationOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientSymbolKindOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSymbolKindOptions type ClientSymbolKindOptions struct { // The symbol kind values the client supports. When this // property exists the client also guarantees that it will @@ -506,7 +508,7 @@ type ClientSymbolKindOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientSymbolResolveOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSymbolResolveOptions type ClientSymbolResolveOptions struct { // The properties that a client can resolve lazily. Usually // `location.range` @@ -515,7 +517,7 @@ type ClientSymbolResolveOptions struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#clientSymbolTagOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#clientSymbolTagOptions type ClientSymbolTagOptions struct { // The tags supported by the client. ValueSet []SymbolTag `json:"valueSet"` @@ -526,7 +528,7 @@ type ClientSymbolTagOptions struct { // // A CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeAction +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeAction type CodeAction struct { // A short, human-readable, title for this code action. Title string `json:"title"` @@ -579,7 +581,7 @@ type CodeAction struct { // The Client Capabilities of a {@link CodeActionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeActionClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionClientCapabilities type CodeActionClientCapabilities struct { // Whether code action supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -620,6 +622,7 @@ type CodeActionClientCapabilities struct { // code actions. // // @since 3.18.0 + // @proposed DocumentationSupport bool `json:"documentationSupport,omitempty"` // Client supports the tag property on a code action. Clients // supporting tags have to handle unknown tags gracefully. @@ -631,7 +634,7 @@ type CodeActionClientCapabilities struct { // Contains additional diagnostic information about the context in which // a {@link CodeActionProvider.provideCodeActions code action} is run. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeActionContext +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionContext type CodeActionContext struct { // An array of diagnostics known on the client side overlapping the range provided to the // `textDocument/codeAction` request. They are provided so that the server knows which @@ -654,7 +657,7 @@ type CodeActionContext struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeActionDisabled +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionDisabled type CodeActionDisabled struct { // Human readable description of why the code action is currently disabled. // @@ -668,8 +671,9 @@ type CodeActionKind string // Documentation for a class of code actions. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeActionKindDocumentation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionKindDocumentation type CodeActionKindDocumentation struct { // The kind of the code action being documented. // @@ -685,7 +689,7 @@ type CodeActionKindDocumentation struct { // Provider options for a {@link CodeActionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeActionOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionOptions type CodeActionOptions struct { // CodeActionKinds that this server may return. // @@ -708,6 +712,7 @@ type CodeActionOptions struct { // At most one documentation entry should be shown per provider. // // @since 3.18.0 + // @proposed Documentation []CodeActionKindDocumentation `json:"documentation,omitempty"` // The server provides support to resolve additional // information for a code action. @@ -719,7 +724,7 @@ type CodeActionOptions struct { // The parameters of a {@link CodeActionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeActionParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionParams type CodeActionParams struct { // The document in which the command was invoked. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -733,7 +738,7 @@ type CodeActionParams struct { // Registration options for a {@link CodeActionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeActionRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionRegistrationOptions type CodeActionRegistrationOptions struct { TextDocumentRegistrationOptions CodeActionOptions @@ -746,7 +751,7 @@ type CodeActionTag uint32 // @since 3.18.0 - proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeActionTagOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeActionTagOptions type CodeActionTagOptions struct { // The tags supported by the client. ValueSet []CodeActionTag `json:"valueSet"` @@ -761,7 +766,7 @@ type CodeActionTriggerKind uint32 // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeDescription +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeDescription type CodeDescription struct { // An URI to open with more information about the diagnostic error. Href URI `json:"href"` @@ -773,7 +778,7 @@ type CodeDescription struct { // A code lens is _unresolved_ when no command is associated to it. For performance // reasons the creation of a code lens and resolving should be done in two stages. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeLens +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLens type CodeLens struct { // The range in which this code lens is valid. Should only span a single line. Range Range `json:"range"` @@ -786,7 +791,7 @@ type CodeLens struct { // The client capabilities of a {@link CodeLensRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeLensClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensClientCapabilities type CodeLensClientCapabilities struct { // Whether code lens supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -799,7 +804,7 @@ type CodeLensClientCapabilities struct { // Code Lens provider options of a {@link CodeLensRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeLensOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensOptions type CodeLensOptions struct { // Code lens has a resolve provider as well. ResolveProvider bool `json:"resolveProvider,omitempty"` @@ -808,7 +813,7 @@ type CodeLensOptions struct { // The parameters of a {@link CodeLensRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeLensParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensParams type CodeLensParams struct { // The document to request code lens for. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -818,7 +823,7 @@ type CodeLensParams struct { // Registration options for a {@link CodeLensRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeLensRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensRegistrationOptions type CodeLensRegistrationOptions struct { TextDocumentRegistrationOptions CodeLensOptions @@ -826,7 +831,7 @@ type CodeLensRegistrationOptions struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeLensWorkspaceClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLensWorkspaceClientCapabilities type CodeLensWorkspaceClientCapabilities struct { // Whether the client implementation supports a refresh request sent from the // server to the client. @@ -840,7 +845,7 @@ type CodeLensWorkspaceClientCapabilities struct { // Represents a color in RGBA space. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#color +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#color type Color struct { // The red component of this color in the range [0-1]. Red float64 `json:"red"` @@ -854,7 +859,7 @@ type Color struct { // Represents a color range from a document. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#colorInformation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#colorInformation type ColorInformation struct { // The range in the document where this color appears. Range Range `json:"range"` @@ -862,7 +867,7 @@ type ColorInformation struct { Color Color `json:"color"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#colorPresentation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#colorPresentation type ColorPresentation struct { // The label of this color presentation. It will be shown on the color // picker header. By default this is also the text that is inserted when selecting @@ -879,7 +884,7 @@ type ColorPresentation struct { // Parameters for a {@link ColorPresentationRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#colorPresentationParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#colorPresentationParams type ColorPresentationParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -896,13 +901,14 @@ type ColorPresentationParams struct { // an array of arguments which will be passed to the command handler // function when invoked. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#command +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#command type Command struct { // Title of the command, like `save`. Title string `json:"title"` // An optional tooltip. // // @since 3.18.0 + // @proposed Tooltip string `json:"tooltip,omitempty"` // The identifier of the actual command handler. Command string `json:"command"` @@ -913,14 +919,13 @@ type Command struct { // Completion client capabilities // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionClientCapabilities type CompletionClientCapabilities struct { // Whether completion supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports the following `CompletionItem` specific // capabilities. - CompletionItem ClientCompletionItemOptions `json:"completionItem,omitempty"` - // The client supports the following completion item kinds. + CompletionItem ClientCompletionItemOptions `json:"completionItem,omitempty"` CompletionItemKind *ClientCompletionItemOptionsKind `json:"completionItemKind,omitempty"` // Defines how the client handles whitespace and indentation // when accepting a completion item that uses multi line @@ -940,7 +945,7 @@ type CompletionClientCapabilities struct { // Contains additional information about the context in which a completion request is triggered. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionContext +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionContext type CompletionContext struct { // How the completion was triggered. TriggerKind CompletionTriggerKind `json:"triggerKind"` @@ -952,7 +957,7 @@ type CompletionContext struct { // A completion item represents a text snippet that is // proposed to complete text that is being typed. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionItem +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItem type CompletionItem struct { // The label of this completion item. // @@ -1091,7 +1096,7 @@ type CompletionItem struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionItemApplyKinds +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItemApplyKinds type CompletionItemApplyKinds struct { // Specifies whether commitCharacters on a completion will replace or be // merged with those in `completionList.itemDefaults.commitCharacters`. @@ -1151,7 +1156,7 @@ type CompletionItemApplyKinds struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionItemDefaults +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItemDefaults type CompletionItemDefaults struct { // A default commit character set. // @@ -1182,7 +1187,7 @@ type CompletionItemKind uint32 // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionItemLabelDetails +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItemLabelDetails type CompletionItemLabelDetails struct { // An optional string which is rendered less prominently directly after {@link CompletionItem.label label}, // without any spacing. Should be used for function signatures and type annotations. @@ -1200,7 +1205,7 @@ type CompletionItemTag uint32 // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionItemTagOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItemTagOptions type CompletionItemTagOptions struct { // The tags supported by the client. ValueSet []CompletionItemTag `json:"valueSet"` @@ -1209,7 +1214,7 @@ type CompletionItemTagOptions struct { // Represents a collection of {@link CompletionItem completion items} to be presented // in the editor. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionList +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionList type CompletionList struct { // This list it not complete. Further typing results in recomputing this list. // @@ -1259,7 +1264,7 @@ type CompletionList struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionListCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionListCapabilities type CompletionListCapabilities struct { // The client supports the following itemDefaults on // a completion list. @@ -1286,7 +1291,7 @@ type CompletionListCapabilities struct { // Completion options. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionOptions type CompletionOptions struct { // Most tools trigger completion request automatically without explicitly requesting // it using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user @@ -1319,7 +1324,7 @@ type CompletionOptions struct { // Completion parameters // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionParams type CompletionParams struct { // The completion context. This is only available it the client specifies // to send this using the client capability `textDocument.completion.contextSupport === true` @@ -1331,7 +1336,7 @@ type CompletionParams struct { // Registration options for a {@link CompletionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionRegistrationOptions type CompletionRegistrationOptions struct { TextDocumentRegistrationOptions CompletionOptions @@ -1340,7 +1345,7 @@ type CompletionRegistrationOptions struct { // How a completion was triggered type CompletionTriggerKind uint32 -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#configurationItem +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#configurationItem type ConfigurationItem struct { // The scope to get the configuration section for. ScopeURI *URI `json:"scopeUri,omitempty"` @@ -1350,14 +1355,14 @@ type ConfigurationItem struct { // The parameters of a configuration request. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#configurationParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#configurationParams type ConfigurationParams struct { Items []ConfigurationItem `json:"items"` } // Create file operation. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#createFile +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#createFile type CreateFile struct { // A create Kind string `json:"kind"` @@ -1370,7 +1375,7 @@ type CreateFile struct { // Options to create a file. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#createFileOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#createFileOptions type CreateFileOptions struct { // Overwrite existing file. Overwrite wins over `ignoreIfExists` Overwrite bool `json:"overwrite,omitempty"` @@ -1383,7 +1388,7 @@ type CreateFileOptions struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#createFilesParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#createFilesParams type CreateFilesParams struct { // An array of all files/folders created in this operation. Files []FileCreate `json:"files"` @@ -1391,11 +1396,11 @@ type CreateFilesParams struct { // The declaration of a symbol representation as one or many {@link Location locations}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#declaration +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declaration type Declaration = []Location // (alias) // @since 3.14.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#declarationClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationClientCapabilities type DeclarationClientCapabilities struct { // Whether declaration supports dynamic registration. If this is set to `true` // the client supports the new `DeclarationRegistrationOptions` return value @@ -1413,21 +1418,21 @@ type DeclarationClientCapabilities struct { // Servers should prefer returning `DeclarationLink` over `Declaration` if supported // by the client. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#declarationLink +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationLink type DeclarationLink = LocationLink // (alias) -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#declarationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationOptions type DeclarationOptions struct { WorkDoneProgressOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#declarationParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationParams type DeclarationParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#declarationRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#declarationRegistrationOptions type DeclarationRegistrationOptions struct { DeclarationOptions TextDocumentRegistrationOptions @@ -1441,11 +1446,11 @@ type DeclarationRegistrationOptions struct { // Servers should prefer returning `DefinitionLink` over `Definition` if supported // by the client. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#definition +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definition type Definition = Or_Definition // (alias) // Client Capabilities for a {@link DefinitionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#definitionClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionClientCapabilities type DefinitionClientCapabilities struct { // Whether definition supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -1460,18 +1465,18 @@ type DefinitionClientCapabilities struct { // Provides additional metadata over normal {@link Location location} definitions, including the range of // the defining symbol // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#definitionLink +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionLink type DefinitionLink = LocationLink // (alias) // Server Capabilities for a {@link DefinitionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#definitionOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionOptions type DefinitionOptions struct { WorkDoneProgressOptions } // Parameters for a {@link DefinitionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#definitionParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionParams type DefinitionParams struct { TextDocumentPositionParams WorkDoneProgressParams @@ -1480,7 +1485,7 @@ type DefinitionParams struct { // Registration options for a {@link DefinitionRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#definitionRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#definitionRegistrationOptions type DefinitionRegistrationOptions struct { TextDocumentRegistrationOptions DefinitionOptions @@ -1488,7 +1493,7 @@ type DefinitionRegistrationOptions struct { // Delete file operation // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#deleteFile +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#deleteFile type DeleteFile struct { // A delete Kind string `json:"kind"` @@ -1501,7 +1506,7 @@ type DeleteFile struct { // Delete file options // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#deleteFileOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#deleteFileOptions type DeleteFileOptions struct { // Delete the content recursively if a folder is denoted. Recursive bool `json:"recursive,omitempty"` @@ -1514,7 +1519,7 @@ type DeleteFileOptions struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#deleteFilesParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#deleteFilesParams type DeleteFilesParams struct { // An array of all files/folders deleted in this operation. Files []FileDelete `json:"files"` @@ -1523,7 +1528,7 @@ type DeleteFilesParams struct { // Represents a diagnostic, such as a compiler error or warning. Diagnostic objects // are only valid in the scope of a resource. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#diagnostic +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnostic type Diagnostic struct { // The range at which the message applies Range Range `json:"range"` @@ -1542,11 +1547,8 @@ type Diagnostic struct { // diagnostic, e.g. 'typescript' or 'super lint'. It usually // appears in the user interface. Source string `json:"source,omitempty"` - // The diagnostic's message. It usually appears in the user interface. - // - // @since 3.18.0 - support for MarkupContent. This is guarded by the client - // capability `textDocument.diagnostic.markupMessageSupport`. - Message Or_Diagnostic_message `json:"message"` + // The diagnostic's message. It usually appears in the user interface + Message string `json:"message"` // Additional metadata about the diagnostic. // // @since 3.15.0 @@ -1565,7 +1567,7 @@ type Diagnostic struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#diagnosticClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticClientCapabilities type DiagnosticClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to `true` // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -1573,10 +1575,6 @@ type DiagnosticClientCapabilities struct { DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // Whether the clients supports related documents for document diagnostic pulls. RelatedDocumentSupport bool `json:"relatedDocumentSupport,omitempty"` - // Whether the client supports `MarkupContent` in diagnostic messages. - // - // @since 3.18.0 - MarkupMessageSupport bool `json:"markupMessageSupport,omitempty"` DiagnosticsCapabilities } @@ -1584,7 +1582,7 @@ type DiagnosticClientCapabilities struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#diagnosticOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticOptions type DiagnosticOptions struct { // An optional identifier under which the diagnostics are // managed by the client. @@ -1603,7 +1601,7 @@ type DiagnosticOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#diagnosticRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticRegistrationOptions type DiagnosticRegistrationOptions struct { TextDocumentRegistrationOptions DiagnosticOptions @@ -1614,7 +1612,7 @@ type DiagnosticRegistrationOptions struct { // used to point to code locations that cause or related to a diagnostics, e.g when duplicating // a symbol in a scope. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#diagnosticRelatedInformation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticRelatedInformation type DiagnosticRelatedInformation struct { // The location of this related diagnostic information. Location Location `json:"location"` @@ -1626,7 +1624,7 @@ type DiagnosticRelatedInformation struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#diagnosticServerCancellationData +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticServerCancellationData type DiagnosticServerCancellationData struct { RetriggerRequest bool `json:"retriggerRequest"` } @@ -1643,7 +1641,7 @@ type DiagnosticTag uint32 // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#diagnosticWorkspaceClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticWorkspaceClientCapabilities type DiagnosticWorkspaceClientCapabilities struct { // Whether the client implementation supports a refresh request sent from // the server to the client. @@ -1657,7 +1655,7 @@ type DiagnosticWorkspaceClientCapabilities struct { // General diagnostics capabilities for pull and push model. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#diagnosticsCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#diagnosticsCapabilities type DiagnosticsCapabilities struct { // Whether the clients accepts diagnostics with related information. RelatedInformation bool `json:"relatedInformation,omitempty"` @@ -1678,7 +1676,7 @@ type DiagnosticsCapabilities struct { DataSupport bool `json:"dataSupport,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeConfigurationClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeConfigurationClientCapabilities type DidChangeConfigurationClientCapabilities struct { // Did change configuration notification supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -1686,13 +1684,13 @@ type DidChangeConfigurationClientCapabilities struct { // The parameters of a change configuration notification. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeConfigurationParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeConfigurationParams type DidChangeConfigurationParams struct { // The actual changed settings Settings any `json:"settings"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeConfigurationRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeConfigurationRegistrationOptions type DidChangeConfigurationRegistrationOptions struct { Section *OrPSection_workspace_didChangeConfiguration `json:"section,omitempty"` } @@ -1701,7 +1699,7 @@ type DidChangeConfigurationRegistrationOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeNotebookDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeNotebookDocumentParams type DidChangeNotebookDocumentParams struct { // The notebook document that did change. The version number points // to the version after all provided changes have been applied. If @@ -1727,7 +1725,7 @@ type DidChangeNotebookDocumentParams struct { // The change text document notification's parameters. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeTextDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeTextDocumentParams type DidChangeTextDocumentParams struct { // The document that did change. The version number points // to the version after all provided content changes have @@ -1748,7 +1746,7 @@ type DidChangeTextDocumentParams struct { ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeWatchedFilesClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeWatchedFilesClientCapabilities type DidChangeWatchedFilesClientCapabilities struct { // Did change watched files notification supports dynamic registration. Please note // that the current protocol doesn't support static configuration for file changes @@ -1763,7 +1761,7 @@ type DidChangeWatchedFilesClientCapabilities struct { // The watched files change notification's parameters. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeWatchedFilesParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeWatchedFilesParams type DidChangeWatchedFilesParams struct { // The actual file events. Changes []FileEvent `json:"changes"` @@ -1771,7 +1769,7 @@ type DidChangeWatchedFilesParams struct { // Describe options to be used when registered for text document change events. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeWatchedFilesRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeWatchedFilesRegistrationOptions type DidChangeWatchedFilesRegistrationOptions struct { // The watchers to register. Watchers []FileSystemWatcher `json:"watchers"` @@ -1779,7 +1777,7 @@ type DidChangeWatchedFilesRegistrationOptions struct { // The parameters of a `workspace/didChangeWorkspaceFolders` notification. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didChangeWorkspaceFoldersParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didChangeWorkspaceFoldersParams type DidChangeWorkspaceFoldersParams struct { // The actual workspace folder change event. Event WorkspaceFoldersChangeEvent `json:"event"` @@ -1789,7 +1787,7 @@ type DidChangeWorkspaceFoldersParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didCloseNotebookDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didCloseNotebookDocumentParams type DidCloseNotebookDocumentParams struct { // The notebook document that got closed. NotebookDocument NotebookDocumentIdentifier `json:"notebookDocument"` @@ -1800,7 +1798,7 @@ type DidCloseNotebookDocumentParams struct { // The parameters sent in a close text document notification // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didCloseTextDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didCloseTextDocumentParams type DidCloseTextDocumentParams struct { // The document that was closed. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -1810,7 +1808,7 @@ type DidCloseTextDocumentParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didOpenNotebookDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didOpenNotebookDocumentParams type DidOpenNotebookDocumentParams struct { // The notebook document that got opened. NotebookDocument NotebookDocument `json:"notebookDocument"` @@ -1821,7 +1819,7 @@ type DidOpenNotebookDocumentParams struct { // The parameters sent in an open text document notification // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didOpenTextDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didOpenTextDocumentParams type DidOpenTextDocumentParams struct { // The document that was opened. TextDocument TextDocumentItem `json:"textDocument"` @@ -1831,7 +1829,7 @@ type DidOpenTextDocumentParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didSaveNotebookDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didSaveNotebookDocumentParams type DidSaveNotebookDocumentParams struct { // The notebook document that got saved. NotebookDocument NotebookDocumentIdentifier `json:"notebookDocument"` @@ -1839,7 +1837,7 @@ type DidSaveNotebookDocumentParams struct { // The parameters sent in a save text document notification // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#didSaveTextDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#didSaveTextDocumentParams type DidSaveTextDocumentParams struct { // The document that was saved. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -1848,7 +1846,7 @@ type DidSaveTextDocumentParams struct { Text *string `json:"text,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentColorClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentColorClientCapabilities type DocumentColorClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to `true` // the client supports the new `DocumentColorRegistrationOptions` return value @@ -1856,14 +1854,14 @@ type DocumentColorClientCapabilities struct { DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentColorOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentColorOptions type DocumentColorOptions struct { WorkDoneProgressOptions } // Parameters for a {@link DocumentColorRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentColorParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentColorParams type DocumentColorParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -1871,7 +1869,7 @@ type DocumentColorParams struct { PartialResultParams } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentColorRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentColorRegistrationOptions type DocumentColorRegistrationOptions struct { TextDocumentRegistrationOptions DocumentColorOptions @@ -1882,7 +1880,7 @@ type DocumentColorRegistrationOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentDiagnosticParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentDiagnosticParams type DocumentDiagnosticParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -1902,7 +1900,7 @@ type DocumentDiagnosticParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentDiagnosticReport type DocumentDiagnosticReport = Or_DocumentDiagnosticReport // (alias) // The document diagnostic report kinds. // @@ -1913,39 +1911,21 @@ type DocumentDiagnosticReportKind string // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentDiagnosticReportPartialResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentDiagnosticReportPartialResult type DocumentDiagnosticReportPartialResult struct { RelatedDocuments map[DocumentURI]any `json:"relatedDocuments"` } -// The document diagnostic report used when reporting partial result. -// -// When using partial results, the first literal sent needs to be a -// DocumentDiagnosticReport providing the diagnostics on the document -// followed by n DocumentDiagnosticReportPartialResult literals providing -// the diagnostics for related documents. -// -// ``` -// DocumentDiagnosticReport -// DocumentDiagnosticReportPartialResult -// DocumentDiagnosticReportPartialResult -// ... -// ``` -// -// @since 3.18.1 -// -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentDiagnosticReportProgress -type DocumentDiagnosticReportProgress = Or_DocumentDiagnosticReportProgress // (alias) // A document filter describes a top level text document or // a notebook cell document. // // @since 3.17.0 - support for NotebookCellTextDocumentFilter. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentFilter +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFilter type DocumentFilter = Or_DocumentFilter // (alias) // Client capabilities of a {@link DocumentFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentFormattingClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingClientCapabilities type DocumentFormattingClientCapabilities struct { // Whether formatting supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -1953,14 +1933,14 @@ type DocumentFormattingClientCapabilities struct { // Provider options for a {@link DocumentFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentFormattingOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingOptions type DocumentFormattingOptions struct { WorkDoneProgressOptions } // The parameters of a {@link DocumentFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentFormattingParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingParams type DocumentFormattingParams struct { // The document to format. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -1971,7 +1951,7 @@ type DocumentFormattingParams struct { // Registration options for a {@link DocumentFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentFormattingRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentFormattingRegistrationOptions type DocumentFormattingRegistrationOptions struct { TextDocumentRegistrationOptions DocumentFormattingOptions @@ -1981,7 +1961,7 @@ type DocumentFormattingRegistrationOptions struct { // special attention. Usually a document highlight is visualized by changing // the background color of its range. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentHighlight +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlight type DocumentHighlight struct { // The range this highlight applies to. Range Range `json:"range"` @@ -1991,7 +1971,7 @@ type DocumentHighlight struct { // Client Capabilities for a {@link DocumentHighlightRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentHighlightClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlightClientCapabilities type DocumentHighlightClientCapabilities struct { // Whether document highlight supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2002,14 +1982,14 @@ type DocumentHighlightKind uint32 // Provider options for a {@link DocumentHighlightRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentHighlightOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlightOptions type DocumentHighlightOptions struct { WorkDoneProgressOptions } // Parameters for a {@link DocumentHighlightRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentHighlightParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlightParams type DocumentHighlightParams struct { TextDocumentPositionParams WorkDoneProgressParams @@ -2018,7 +1998,7 @@ type DocumentHighlightParams struct { // Registration options for a {@link DocumentHighlightRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentHighlightRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentHighlightRegistrationOptions type DocumentHighlightRegistrationOptions struct { TextDocumentRegistrationOptions DocumentHighlightOptions @@ -2027,7 +2007,7 @@ type DocumentHighlightRegistrationOptions struct { // A document link is a range in a text document that links to an internal or external resource, like another // text document or a web site. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentLink +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLink type DocumentLink struct { // The range this link applies to. Range Range `json:"range"` @@ -2048,7 +2028,7 @@ type DocumentLink struct { // The client capabilities of a {@link DocumentLinkRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentLinkClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLinkClientCapabilities type DocumentLinkClientCapabilities struct { // Whether document link supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2060,7 +2040,7 @@ type DocumentLinkClientCapabilities struct { // Provider options for a {@link DocumentLinkRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentLinkOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLinkOptions type DocumentLinkOptions struct { // Document links have a resolve provider as well. ResolveProvider bool `json:"resolveProvider,omitempty"` @@ -2069,7 +2049,7 @@ type DocumentLinkOptions struct { // The parameters of a {@link DocumentLinkRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentLinkParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLinkParams type DocumentLinkParams struct { // The document to provide document links for. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -2079,7 +2059,7 @@ type DocumentLinkParams struct { // Registration options for a {@link DocumentLinkRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentLinkRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLinkRegistrationOptions type DocumentLinkRegistrationOptions struct { TextDocumentRegistrationOptions DocumentLinkOptions @@ -2087,7 +2067,7 @@ type DocumentLinkRegistrationOptions struct { // Client capabilities of a {@link DocumentOnTypeFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentOnTypeFormattingClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentOnTypeFormattingClientCapabilities type DocumentOnTypeFormattingClientCapabilities struct { // Whether on type formatting supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2095,7 +2075,7 @@ type DocumentOnTypeFormattingClientCapabilities struct { // Provider options for a {@link DocumentOnTypeFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentOnTypeFormattingOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentOnTypeFormattingOptions type DocumentOnTypeFormattingOptions struct { // A character on which formatting should be triggered, like `{`. FirstTriggerCharacter string `json:"firstTriggerCharacter"` @@ -2105,7 +2085,7 @@ type DocumentOnTypeFormattingOptions struct { // The parameters of a {@link DocumentOnTypeFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentOnTypeFormattingParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentOnTypeFormattingParams type DocumentOnTypeFormattingParams struct { // The document to format. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -2124,7 +2104,7 @@ type DocumentOnTypeFormattingParams struct { // Registration options for a {@link DocumentOnTypeFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentOnTypeFormattingRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentOnTypeFormattingRegistrationOptions type DocumentOnTypeFormattingRegistrationOptions struct { TextDocumentRegistrationOptions DocumentOnTypeFormattingOptions @@ -2132,30 +2112,32 @@ type DocumentOnTypeFormattingRegistrationOptions struct { // Client capabilities of a {@link DocumentRangeFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentRangeFormattingClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangeFormattingClientCapabilities type DocumentRangeFormattingClientCapabilities struct { // Whether range formatting supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // Whether the client supports formatting multiple ranges at once. // // @since 3.18.0 + // @proposed RangesSupport bool `json:"rangesSupport,omitempty"` } // Provider options for a {@link DocumentRangeFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentRangeFormattingOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangeFormattingOptions type DocumentRangeFormattingOptions struct { // Whether the server supports formatting multiple ranges at once. // // @since 3.18.0 + // @proposed RangesSupport bool `json:"rangesSupport,omitempty"` WorkDoneProgressOptions } // The parameters of a {@link DocumentRangeFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentRangeFormattingParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangeFormattingParams type DocumentRangeFormattingParams struct { // The document to format. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -2168,7 +2150,7 @@ type DocumentRangeFormattingParams struct { // Registration options for a {@link DocumentRangeFormattingRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentRangeFormattingRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangeFormattingRegistrationOptions type DocumentRangeFormattingRegistrationOptions struct { TextDocumentRegistrationOptions DocumentRangeFormattingOptions @@ -2177,8 +2159,9 @@ type DocumentRangeFormattingRegistrationOptions struct { // The parameters of a {@link DocumentRangesFormattingRequest}. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentRangesFormattingParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentRangesFormattingParams type DocumentRangesFormattingParams struct { // The document to format. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -2195,14 +2178,14 @@ type DocumentRangesFormattingParams struct { // // The use of a string as a document filter is deprecated @since 3.16.0. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentSelector +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSelector type DocumentSelector = []DocumentFilter // (alias) // Represents programming constructs like variables, classes, interfaces etc. // that appear in a document. Document symbols can be hierarchical and they // have two ranges: one that encloses its definition and one that points to // its most interesting range, e.g. the range of an identifier. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentSymbol +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbol type DocumentSymbol struct { // The name of this symbol. Will be displayed in the user interface and therefore must not be // an empty string or a string only consisting of white spaces. @@ -2232,7 +2215,7 @@ type DocumentSymbol struct { // Client Capabilities for a {@link DocumentSymbolRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentSymbolClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbolClientCapabilities type DocumentSymbolClientCapabilities struct { // Whether document symbol supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2256,7 +2239,7 @@ type DocumentSymbolClientCapabilities struct { // Provider options for a {@link DocumentSymbolRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentSymbolOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbolOptions type DocumentSymbolOptions struct { // A human-readable string that is shown when multiple outlines trees // are shown for the same document. @@ -2268,7 +2251,7 @@ type DocumentSymbolOptions struct { // Parameters for a {@link DocumentSymbolRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentSymbolParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbolParams type DocumentSymbolParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -2278,7 +2261,7 @@ type DocumentSymbolParams struct { // Registration options for a {@link DocumentSymbolRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentSymbolRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentSymbolRegistrationOptions type DocumentSymbolRegistrationOptions struct { TextDocumentRegistrationOptions DocumentSymbolOptions @@ -2288,7 +2271,7 @@ type DocumentSymbolRegistrationOptions struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#editRangeWithInsertReplace +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#editRangeWithInsertReplace type EditRangeWithInsertReplace struct { Insert Range `json:"insert"` Replace Range `json:"replace"` @@ -2299,7 +2282,7 @@ type ErrorCodes int32 // The client capabilities of a {@link ExecuteCommandRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#executeCommandClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executeCommandClientCapabilities type ExecuteCommandClientCapabilities struct { // Execute command supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2307,7 +2290,7 @@ type ExecuteCommandClientCapabilities struct { // The server capabilities of a {@link ExecuteCommandRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#executeCommandOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executeCommandOptions type ExecuteCommandOptions struct { // The commands to be executed on the server Commands []string `json:"commands"` @@ -2316,7 +2299,7 @@ type ExecuteCommandOptions struct { // The parameters of a {@link ExecuteCommandRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#executeCommandParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executeCommandParams type ExecuteCommandParams struct { // The identifier of the actual command handler. Command string `json:"command"` @@ -2332,12 +2315,12 @@ type ExecuteCommandParams struct { // Registration options for a {@link ExecuteCommandRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#executeCommandRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executeCommandRegistrationOptions type ExecuteCommandRegistrationOptions struct { ExecuteCommandOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#executionSummary +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#executionSummary type ExecutionSummary struct { // A strict monotonically increasing value // indicating the execution order of a cell @@ -2356,7 +2339,7 @@ type FileChangeType uint32 // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileCreate +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileCreate type FileCreate struct { // A file:// URI for the location of the file/folder being created. URI DocumentURI `json:"uri"` @@ -2366,7 +2349,7 @@ type FileCreate struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileDelete +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileDelete type FileDelete struct { // A file:// URI for the location of the file/folder being deleted. URI DocumentURI `json:"uri"` @@ -2374,7 +2357,7 @@ type FileDelete struct { // An event describing a file change. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileEvent +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileEvent type FileEvent struct { // The file's uri. URI DocumentURI `json:"uri"` @@ -2389,7 +2372,7 @@ type FileEvent struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileOperationClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationClientCapabilities type FileOperationClientCapabilities struct { // Whether the client supports dynamic registration for file requests/notifications. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2412,7 +2395,7 @@ type FileOperationClientCapabilities struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileOperationFilter +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationFilter type FileOperationFilter struct { // A Uri scheme like `file` or `untitled`. Scheme string `json:"scheme,omitempty"` @@ -2424,7 +2407,7 @@ type FileOperationFilter struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileOperationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationOptions type FileOperationOptions struct { // The server is interested in receiving didCreateFiles notifications. DidCreate *FileOperationRegistrationOptions `json:"didCreate,omitempty"` @@ -2445,11 +2428,11 @@ type FileOperationOptions struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileOperationPattern +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationPattern type FileOperationPattern struct { // The glob pattern to match. Glob patterns can have the following syntax: // - // - `*` to match zero or more characters in a path segment + // - `*` to match one or more characters in a path segment // - `?` to match on one character in a path segment // - `**` to match any number of path segments, including none // - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) @@ -2474,7 +2457,7 @@ type FileOperationPatternKind string // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileOperationPatternOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationPatternOptions type FileOperationPatternOptions struct { // The pattern should be matched ignoring casing. IgnoreCase bool `json:"ignoreCase,omitempty"` @@ -2484,7 +2467,7 @@ type FileOperationPatternOptions struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileOperationRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileOperationRegistrationOptions type FileOperationRegistrationOptions struct { // The actual filters. Filters []FileOperationFilter `json:"filters"` @@ -2494,7 +2477,7 @@ type FileOperationRegistrationOptions struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileRename +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileRename type FileRename struct { // A file:// URI for the original location of the file/folder being renamed. OldURI DocumentURI `json:"oldUri"` @@ -2502,7 +2485,7 @@ type FileRename struct { NewURI DocumentURI `json:"newUri"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fileSystemWatcher +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fileSystemWatcher type FileSystemWatcher struct { // The glob pattern to watch. See {@link GlobPattern glob pattern} for more detail. // @@ -2517,7 +2500,7 @@ type FileSystemWatcher struct { // Represents a folding range. To be valid, start and end line must be bigger than zero and smaller // than the number of lines in the document. Clients are free to ignore invalid ranges. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#foldingRange +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRange type FoldingRange struct { // The zero-based start line of the range to fold. The folded area starts after the line's last character. // To be valid, the end must be zero or larger and smaller than the number of lines in the document. @@ -2541,7 +2524,7 @@ type FoldingRange struct { CollapsedText string `json:"collapsedText,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#foldingRangeClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeClientCapabilities type FoldingRangeClientCapabilities struct { // Whether implementation supports dynamic registration for folding range // providers. If this is set to `true` the client supports the new @@ -2569,14 +2552,14 @@ type FoldingRangeClientCapabilities struct { // A set of predefined range kinds. type FoldingRangeKind string -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#foldingRangeOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeOptions type FoldingRangeOptions struct { WorkDoneProgressOptions } // Parameters for a {@link FoldingRangeRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#foldingRangeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeParams type FoldingRangeParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -2584,7 +2567,7 @@ type FoldingRangeParams struct { PartialResultParams } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#foldingRangeRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeRegistrationOptions type FoldingRangeRegistrationOptions struct { TextDocumentRegistrationOptions FoldingRangeOptions @@ -2594,8 +2577,9 @@ type FoldingRangeRegistrationOptions struct { // Client workspace capabilities specific to folding ranges // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#foldingRangeWorkspaceClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#foldingRangeWorkspaceClientCapabilities type FoldingRangeWorkspaceClientCapabilities struct { // Whether the client implementation supports a refresh request sent from the // server to the client. @@ -2606,12 +2590,13 @@ type FoldingRangeWorkspaceClientCapabilities struct { // change that requires such a calculation. // // @since 3.18.0 + // @proposed RefreshSupport bool `json:"refreshSupport,omitempty"` } // Value-object describing what options formatting should use. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#formattingOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#formattingOptions type FormattingOptions struct { // Size of a tab in spaces. TabSize uint32 `json:"tabSize"` @@ -2635,7 +2620,7 @@ type FormattingOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#fullDocumentDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#fullDocumentDiagnosticReport type FullDocumentDiagnosticReport struct { // A full document diagnostic report. Kind string `json:"kind"` @@ -2651,7 +2636,7 @@ type FullDocumentDiagnosticReport struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#generalClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#generalClientCapabilities type GeneralClientCapabilities struct { // Client capability that signals how the client // handles stale requests (e.g. a request @@ -2693,11 +2678,11 @@ type GeneralClientCapabilities struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#globPattern +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#globPattern type GlobPattern = Or_GlobPattern // (alias) // The result of a hover request. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#hover +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hover type Hover struct { // The hover's content Contents MarkupContent `json:"contents"` @@ -2706,7 +2691,7 @@ type Hover struct { Range Range `json:"range,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#hoverClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverClientCapabilities type HoverClientCapabilities struct { // Whether hover supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2717,14 +2702,14 @@ type HoverClientCapabilities struct { // Hover options. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#hoverOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverOptions type HoverOptions struct { WorkDoneProgressOptions } // Parameters for a {@link HoverRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#hoverParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverParams type HoverParams struct { TextDocumentPositionParams WorkDoneProgressParams @@ -2732,7 +2717,7 @@ type HoverParams struct { // Registration options for a {@link HoverRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#hoverRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#hoverRegistrationOptions type HoverRegistrationOptions struct { TextDocumentRegistrationOptions HoverOptions @@ -2740,7 +2725,7 @@ type HoverRegistrationOptions struct { // @since 3.6.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#implementationClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#implementationClientCapabilities type ImplementationClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to `true` // the client supports the new `ImplementationRegistrationOptions` return value @@ -2752,19 +2737,19 @@ type ImplementationClientCapabilities struct { LinkSupport bool `json:"linkSupport,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#implementationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#implementationOptions type ImplementationOptions struct { WorkDoneProgressOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#implementationParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#implementationParams type ImplementationParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#implementationRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#implementationRegistrationOptions type ImplementationRegistrationOptions struct { TextDocumentRegistrationOptions ImplementationOptions @@ -2774,7 +2759,7 @@ type ImplementationRegistrationOptions struct { // The data type of the ResponseError if the // initialize request fails. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#initializeError +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializeError type InitializeError struct { // Indicates whether the client execute the following retry logic: // (1) show the message provided by the ResponseError to the user @@ -2783,7 +2768,7 @@ type InitializeError struct { Retry bool `json:"retry"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#initializeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializeParams type InitializeParams struct { XInitializeParams WorkspaceFoldersInitializeParams @@ -2791,7 +2776,7 @@ type InitializeParams struct { // The result returned from an initialize request. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#initializeResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializeResult type InitializeResult struct { // The capabilities the language server provides. Capabilities ServerCapabilities `json:"capabilities"` @@ -2801,7 +2786,7 @@ type InitializeResult struct { ServerInfo *ServerInfo `json:"serverInfo,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#initializedParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializedParams type InitializedParams struct { } @@ -2809,7 +2794,7 @@ type InitializedParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlayHint +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHint type InlayHint struct { // The position of this hint. // @@ -2853,7 +2838,7 @@ type InlayHint struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlayHintClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintClientCapabilities type InlayHintClientCapabilities struct { // Whether inlay hints support dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2872,7 +2857,7 @@ type InlayHintKind uint32 // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlayHintLabelPart +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintLabelPart type InlayHintLabelPart struct { // The value of this label part. Value string `json:"value"` @@ -2903,7 +2888,7 @@ type InlayHintLabelPart struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlayHintOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintOptions type InlayHintOptions struct { // The server provides support to resolve additional // information for an inlay hint item. @@ -2915,7 +2900,7 @@ type InlayHintOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlayHintParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintParams type InlayHintParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -2928,7 +2913,7 @@ type InlayHintParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlayHintRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintRegistrationOptions type InlayHintRegistrationOptions struct { InlayHintOptions TextDocumentRegistrationOptions @@ -2939,7 +2924,7 @@ type InlayHintRegistrationOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlayHintWorkspaceClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHintWorkspaceClientCapabilities type InlayHintWorkspaceClientCapabilities struct { // Whether the client implementation supports a refresh request sent from // the server to the client. @@ -2954,8 +2939,9 @@ type InlayHintWorkspaceClientCapabilities struct { // Client capabilities specific to inline completions. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineCompletionClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionClientCapabilities type InlineCompletionClientCapabilities struct { // Whether implementation supports dynamic registration for inline completion providers. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -2964,8 +2950,9 @@ type InlineCompletionClientCapabilities struct { // Provides information about the context in which an inline completion was requested. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineCompletionContext +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionContext type InlineCompletionContext struct { // Describes how the inline completion was triggered. TriggerKind InlineCompletionTriggerKind `json:"triggerKind"` @@ -2976,8 +2963,9 @@ type InlineCompletionContext struct { // An inline completion item represents a text snippet that is proposed inline to complete text that is being typed. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineCompletionItem +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionItem type InlineCompletionItem struct { // The text to replace the range with. Must be set. InsertText Or_InlineCompletionItem_insertText `json:"insertText"` @@ -2992,8 +2980,9 @@ type InlineCompletionItem struct { // Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineCompletionList +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionList type InlineCompletionList struct { // The inline completion items Items []InlineCompletionItem `json:"items"` @@ -3002,8 +2991,9 @@ type InlineCompletionList struct { // Inline completion options used during static registration. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineCompletionOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionOptions type InlineCompletionOptions struct { WorkDoneProgressOptions } @@ -3011,8 +3001,9 @@ type InlineCompletionOptions struct { // A parameter literal used in inline completion requests. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineCompletionParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionParams type InlineCompletionParams struct { // Additional information about the context in which inline completions were // requested. @@ -3024,8 +3015,9 @@ type InlineCompletionParams struct { // Inline completion options used during static or dynamic registration. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineCompletionRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineCompletionRegistrationOptions type InlineCompletionRegistrationOptions struct { InlineCompletionOptions TextDocumentRegistrationOptions @@ -3035,6 +3027,7 @@ type InlineCompletionRegistrationOptions struct { // Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered. // // @since 3.18.0 +// @proposed type InlineCompletionTriggerKind uint32 // Inline value information can be provided by different means: @@ -3047,13 +3040,13 @@ type InlineCompletionTriggerKind uint32 // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValue +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValue type InlineValue = Or_InlineValue // (alias) // Client capabilities specific to inline values. // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueClientCapabilities type InlineValueClientCapabilities struct { // Whether implementation supports dynamic registration for inline value providers. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -3061,7 +3054,7 @@ type InlineValueClientCapabilities struct { // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueContext +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueContext type InlineValueContext struct { // The stack frame (as a DAP Id) where the execution has stopped. FrameID int32 `json:"frameId"` @@ -3070,24 +3063,18 @@ type InlineValueContext struct { StoppedLocation Range `json:"stoppedLocation"` } -// To compute an inline value through an expression evaluation. -// -// If only a range is specified, the expression should be -// extracted from the underlying document. -// -// An optional expression could be evaluated instead of -// the extracted expression. +// Provide an inline value through an expression evaluation. +// If only a range is specified, the expression will be extracted from the underlying document. +// An optional expression can be used to override the extracted expression. // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueEvaluatableExpression +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueEvaluatableExpression type InlineValueEvaluatableExpression struct { // The document range for which the inline value applies. - // - // The range could be used to extract the evaluatable expression - // from the underlying document. + // The range is used to extract the evaluatable expression from the underlying document. Range Range `json:"range"` - // If specified the expression could be evaluated instead. + // If specified the expression overrides the extracted expression. Expression string `json:"expression,omitempty"` } @@ -3095,7 +3082,7 @@ type InlineValueEvaluatableExpression struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueOptions type InlineValueOptions struct { WorkDoneProgressOptions } @@ -3104,13 +3091,13 @@ type InlineValueOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueParams type InlineValueParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` - // The document range for which inline values information will be returned. + // The document range for which inline values should be computed. Range Range `json:"range"` - // Additional information about the context in which inline values information was + // Additional information about the context in which inline values were // requested. Context InlineValueContext `json:"context"` WorkDoneProgressParams @@ -3120,18 +3107,18 @@ type InlineValueParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueRegistrationOptions type InlineValueRegistrationOptions struct { InlineValueOptions TextDocumentRegistrationOptions StaticRegistrationOptions } -// Returns inline value information as the complete text to be shown. +// Provide inline value as text. // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueText +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueText type InlineValueText struct { // The document range for which the inline value applies. Range Range `json:"range"` @@ -3139,22 +3126,16 @@ type InlineValueText struct { Text string `json:"text"` } -// To compute inline value through a variable lookup. -// -// If only a range is specified, the variable name should -// be extracted from the underlying document. -// -// An optional variable name could be used to lookup instead -// of the extracted name. +// Provide inline value through a variable lookup. +// If only a range is specified, the variable name will be extracted from the underlying document. +// An optional variable name can be used to override the extracted name. // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueVariableLookup +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueVariableLookup type InlineValueVariableLookup struct { // The document range for which the inline value applies. - // - // The range could be used to extract the variable name - // from the underlying document. + // The range is used to extract the variable name from the underlying document. Range Range `json:"range"` // If specified the name of the variable to look up. VariableName string `json:"variableName,omitempty"` @@ -3166,7 +3147,7 @@ type InlineValueVariableLookup struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlineValueWorkspaceClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlineValueWorkspaceClientCapabilities type InlineValueWorkspaceClientCapabilities struct { // Whether the client implementation supports a refresh request sent from the // server to the client. @@ -3182,7 +3163,7 @@ type InlineValueWorkspaceClientCapabilities struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#insertReplaceEdit +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#insertReplaceEdit type InsertReplaceEdit struct { // The string to be inserted. NewText string `json:"newText"` @@ -3206,14 +3187,14 @@ type LSPAny = any // LSP arrays. // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#lSPArray +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#lSPArray type LSPArray = []any // (alias) type LSPErrorCodes int32 // LSP object definition. // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#lSPObject +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#lSPObject type LSPObject = map[string]LSPAny // (alias) // Predefined Language kinds // @since 3.18.0 @@ -3223,7 +3204,7 @@ type LanguageKind string // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#linkedEditingRangeClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRangeClientCapabilities type LinkedEditingRangeClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to `true` // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -3231,18 +3212,18 @@ type LinkedEditingRangeClientCapabilities struct { DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#linkedEditingRangeOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRangeOptions type LinkedEditingRangeOptions struct { WorkDoneProgressOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#linkedEditingRangeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRangeParams type LinkedEditingRangeParams struct { TextDocumentPositionParams WorkDoneProgressParams } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#linkedEditingRangeRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRangeRegistrationOptions type LinkedEditingRangeRegistrationOptions struct { TextDocumentRegistrationOptions LinkedEditingRangeOptions @@ -3253,7 +3234,7 @@ type LinkedEditingRangeRegistrationOptions struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#linkedEditingRanges +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#linkedEditingRanges type LinkedEditingRanges struct { // A list of ranges that can be edited together. The ranges must have // identical length and contain identical text content. The ranges cannot overlap. @@ -3271,7 +3252,7 @@ type Lit_ClientSemanticTokensRequestOptions_range_Item1 struct { // Represents a location inside a resource, such as a line // inside a text file. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#location +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#location type Location struct { URI DocumentURI `json:"uri"` Range Range `json:"range"` @@ -3280,7 +3261,7 @@ type Location struct { // Represents the connection of two locations. Provides additional metadata over normal {@link Location locations}, // including an origin range. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#locationLink +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#locationLink type LocationLink struct { // Span of the origin of this link. // @@ -3302,14 +3283,14 @@ type LocationLink struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#locationUriOnly +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#locationUriOnly type LocationUriOnly struct { URI DocumentURI `json:"uri"` } // The log message parameters. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#logMessageParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#logMessageParams type LogMessageParams struct { // The message type. See {@link MessageType} Type MessageType `json:"type"` @@ -3317,7 +3298,7 @@ type LogMessageParams struct { Message string `json:"message"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#logTraceParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#logTraceParams type LogTraceParams struct { Message string `json:"message"` Verbose string `json:"verbose,omitempty"` @@ -3327,7 +3308,7 @@ type LogTraceParams struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#markdownClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markdownClientCapabilities type MarkdownClientCapabilities struct { // The name of the parser. Parser string `json:"parser"` @@ -3353,12 +3334,12 @@ type MarkdownClientCapabilities struct { // Note that markdown strings will be sanitized - that means html will be escaped. // @deprecated use MarkupContent instead. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#markedString +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markedString type MarkedString = Or_MarkedString // (alias) // @since 3.18.0 // @deprecated use MarkupContent instead. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#markedStringWithLanguage +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markedStringWithLanguage type MarkedStringWithLanguage struct { Language string `json:"language"` Value string `json:"value"` @@ -3389,7 +3370,7 @@ type MarkedStringWithLanguage struct { // *Please Note* that clients might sanitize the return markdown. A client could decide to // remove HTML from the markdown to avoid script execution. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#markupContent +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#markupContent type MarkupContent struct { // The type of the Markup Kind MarkupKind `json:"kind"` @@ -3404,7 +3385,7 @@ type MarkupContent struct { // are reserved for internal usage. type MarkupKind string -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#messageActionItem +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#messageActionItem type MessageActionItem struct { // A short title like 'Retry', 'Open Log' etc. Title string `json:"title"` @@ -3417,7 +3398,7 @@ type MessageType uint32 // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#moniker +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#moniker type Moniker struct { // The scheme of the moniker. For example tsc or .Net Scheme string `json:"scheme"` @@ -3434,7 +3415,7 @@ type Moniker struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#monikerClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#monikerClientCapabilities type MonikerClientCapabilities struct { // Whether moniker supports dynamic registration. If this is set to `true` // the client supports the new `MonikerRegistrationOptions` return value @@ -3447,19 +3428,19 @@ type MonikerClientCapabilities struct { // @since 3.16.0 type MonikerKind string -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#monikerOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#monikerOptions type MonikerOptions struct { WorkDoneProgressOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#monikerParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#monikerParams type MonikerParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#monikerRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#monikerRegistrationOptions type MonikerRegistrationOptions struct { TextDocumentRegistrationOptions MonikerOptions @@ -3473,7 +3454,7 @@ type MonikerRegistrationOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookCell +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookCell type NotebookCell struct { // The cell's kind Kind NotebookCellKind `json:"kind"` @@ -3494,7 +3475,7 @@ type NotebookCell struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookCellArrayChange +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookCellArrayChange type NotebookCellArrayChange struct { // The start oftest of the cell that changed. Start uint32 `json:"start"` @@ -3511,7 +3492,7 @@ type NotebookCellKind uint32 // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookCellLanguage +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookCellLanguage type NotebookCellLanguage struct { Language string `json:"language"` } @@ -3521,7 +3502,7 @@ type NotebookCellLanguage struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookCellTextDocumentFilter +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookCellTextDocumentFilter type NotebookCellTextDocumentFilter struct { // A filter that matches against the notebook // containing the notebook cell. If a string @@ -3539,7 +3520,7 @@ type NotebookCellTextDocumentFilter struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocument +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument type NotebookDocument struct { // The notebook document's uri. URI URI `json:"uri"` @@ -3561,7 +3542,7 @@ type NotebookDocument struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentCellChangeStructure +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentCellChangeStructure type NotebookDocumentCellChangeStructure struct { // The change to the cell array. Array NotebookCellArrayChange `json:"array"` @@ -3575,7 +3556,7 @@ type NotebookDocumentCellChangeStructure struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentCellChanges +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentCellChanges type NotebookDocumentCellChanges struct { // Changes to the cell structure to add or // remove cells. @@ -3591,7 +3572,7 @@ type NotebookDocumentCellChanges struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentCellContentChanges +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentCellContentChanges type NotebookDocumentCellContentChanges struct { Document VersionedTextDocumentIdentifier `json:"document"` Changes []TextDocumentContentChangeEvent `json:"changes"` @@ -3601,7 +3582,7 @@ type NotebookDocumentCellContentChanges struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentChangeEvent +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentChangeEvent type NotebookDocumentChangeEvent struct { // The changed meta data if any. // @@ -3615,7 +3596,7 @@ type NotebookDocumentChangeEvent struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentClientCapabilities type NotebookDocumentClientCapabilities struct { // Capabilities specific to notebook document synchronization // @@ -3629,13 +3610,13 @@ type NotebookDocumentClientCapabilities struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentFilter +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilter type NotebookDocumentFilter = Or_NotebookDocumentFilter // (alias) // A notebook document filter where `notebookType` is required field. // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentFilterNotebookType +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterNotebookType type NotebookDocumentFilterNotebookType struct { // The type of the enclosing notebook. NotebookType string `json:"notebookType"` @@ -3649,7 +3630,7 @@ type NotebookDocumentFilterNotebookType struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentFilterPattern +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterPattern type NotebookDocumentFilterPattern struct { // The type of the enclosing notebook. NotebookType string `json:"notebookType,omitempty"` @@ -3663,7 +3644,7 @@ type NotebookDocumentFilterPattern struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentFilterScheme +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterScheme type NotebookDocumentFilterScheme struct { // The type of the enclosing notebook. NotebookType string `json:"notebookType,omitempty"` @@ -3675,7 +3656,7 @@ type NotebookDocumentFilterScheme struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentFilterWithCells +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterWithCells type NotebookDocumentFilterWithCells struct { // The notebook to be synced If a string // value is provided it matches against the @@ -3687,7 +3668,7 @@ type NotebookDocumentFilterWithCells struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentFilterWithNotebook +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentFilterWithNotebook type NotebookDocumentFilterWithNotebook struct { // The notebook to be synced If a string // value is provided it matches against the @@ -3701,7 +3682,7 @@ type NotebookDocumentFilterWithNotebook struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentIdentifier +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentIdentifier type NotebookDocumentIdentifier struct { // The notebook document's uri. URI URI `json:"uri"` @@ -3711,7 +3692,7 @@ type NotebookDocumentIdentifier struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentSyncClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentSyncClientCapabilities type NotebookDocumentSyncClientCapabilities struct { // Whether implementation supports dynamic registration. If this is // set to `true` the client supports the new @@ -3736,7 +3717,7 @@ type NotebookDocumentSyncClientCapabilities struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentSyncOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentSyncOptions type NotebookDocumentSyncOptions struct { // The notebooks to be synced NotebookSelector []Or_NotebookDocumentSyncOptions_notebookSelector_Elem `json:"notebookSelector"` @@ -3749,7 +3730,7 @@ type NotebookDocumentSyncOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocumentSyncRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocumentSyncRegistrationOptions type NotebookDocumentSyncRegistrationOptions struct { NotebookDocumentSyncOptions StaticRegistrationOptions @@ -3757,7 +3738,7 @@ type NotebookDocumentSyncRegistrationOptions struct { // A text document identifier to optionally denote a specific version of a text document. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#optionalVersionedTextDocumentIdentifier +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#optionalVersionedTextDocumentIdentifier type OptionalVersionedTextDocumentIdentifier struct { // The version number of this document. If a versioned text document identifier // is sent from the server to the client and the file is not open in the editor @@ -3828,11 +3809,6 @@ type Or_Diagnostic_code struct { Value any `json:"value"` } -// created for Or [MarkupContent string] -type Or_Diagnostic_message struct { - Value any `json:"value"` -} - // created for Or [RelatedFullDocumentDiagnosticReport RelatedUnchangedDocumentDiagnosticReport] type Or_DocumentDiagnosticReport struct { Value any `json:"value"` @@ -3843,11 +3819,6 @@ type Or_DocumentDiagnosticReportPartialResult_relatedDocuments_Value struct { Value any `json:"value"` } -// created for Or [DocumentDiagnosticReport DocumentDiagnosticReportPartialResult] -type Or_DocumentDiagnosticReportProgress struct { - Value any `json:"value"` -} - // created for Or [NotebookCellTextDocumentFilter TextDocumentFilter] type Or_DocumentFilter struct { Value any `json:"value"` @@ -4119,12 +4090,12 @@ type PRangeESemanticTokensOptions struct { // The parameters of a configuration request. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#configurationParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#configurationParams type ParamConfiguration struct { Items []ConfigurationItem `json:"items"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#initializeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initializeParams type ParamInitialize struct { XInitializeParams WorkspaceFoldersInitializeParams @@ -4133,7 +4104,7 @@ type ParamInitialize struct { // Represents a parameter of a callable-signature. A parameter can // have a label and a doc-comment. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#parameterInformation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#parameterInformation type ParameterInformation struct { // The label of this parameter information. // @@ -4153,7 +4124,7 @@ type ParameterInformation struct { Documentation string `json:"documentation,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#partialResultParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#partialResultParams type PartialResultParams struct { // An optional token that a server can use to report partial results (e.g. streaming) to // the client. @@ -4162,7 +4133,7 @@ type PartialResultParams struct { // The glob pattern to watch relative to the base path. Glob patterns can have the following syntax: // -// - `*` to match zero or more characters in a path segment +// - `*` to match one or more characters in a path segment // - `?` to match on one character in a path segment // - `**` to match any number of path segments, including none // - `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) @@ -4171,7 +4142,7 @@ type PartialResultParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#pattern +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#pattern type Pattern = string // (alias) // Position in a text document expressed as zero-based line and character // offset. Prior to 3.17 the offsets were always based on a UTF-16 string @@ -4201,7 +4172,7 @@ type Pattern = string // (alias) // // @since 3.17.0 - support for negotiated position encoding. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#position +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#position type Position struct { // Line position in a document (zero-based). Line uint32 `json:"line"` @@ -4219,12 +4190,12 @@ type PositionEncodingKind string // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#prepareRenameDefaultBehavior +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenameDefaultBehavior type PrepareRenameDefaultBehavior struct { DefaultBehavior bool `json:"defaultBehavior"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#prepareRenameParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenameParams type PrepareRenameParams struct { TextDocumentPositionParams WorkDoneProgressParams @@ -4232,13 +4203,13 @@ type PrepareRenameParams struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#prepareRenamePlaceholder +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenamePlaceholder type PrepareRenamePlaceholder struct { Range Range `json:"range"` Placeholder string `json:"placeholder"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#prepareRenameResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#prepareRenameResult type PrepareRenameResult = PrepareRenamePlaceholder // (alias) type PrepareSupportDefaultBehavior uint32 @@ -4246,7 +4217,7 @@ type PrepareSupportDefaultBehavior uint32 // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#previousResultId +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#previousResultId type PreviousResultID struct { // The URI for which the client knowns a // result id. @@ -4259,7 +4230,7 @@ type PreviousResultID struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#previousResultId +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#previousResultId type PreviousResultId struct { // The URI for which the client knowns a // result id. @@ -4268,7 +4239,7 @@ type PreviousResultId struct { Value string `json:"value"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#progressParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progressParams type ProgressParams struct { // The progress token provided by the client or server. Token ProgressToken `json:"token"` @@ -4276,11 +4247,11 @@ type ProgressParams struct { Value any `json:"value"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#progressToken +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progressToken type ProgressToken = any // (alias) // The publish diagnostic client capabilities. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#publishDiagnosticsClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#publishDiagnosticsClientCapabilities type PublishDiagnosticsClientCapabilities struct { // Whether the client interprets the version property of the // `textDocument/publishDiagnostics` notification's parameter. @@ -4292,7 +4263,7 @@ type PublishDiagnosticsClientCapabilities struct { // The publish diagnostic notification's parameters. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#publishDiagnosticsParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#publishDiagnosticsParams type PublishDiagnosticsParams struct { // The URI for which diagnostic information is reported. URI DocumentURI `json:"uri"` @@ -4318,7 +4289,7 @@ type PublishDiagnosticsParams struct { // // ``` // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#range +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#range type Range struct { // The range's start position. Start Position `json:"start"` @@ -4328,7 +4299,7 @@ type Range struct { // Client Capabilities for a {@link ReferencesRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#referenceClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceClientCapabilities type ReferenceClientCapabilities struct { // Whether references supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -4337,7 +4308,7 @@ type ReferenceClientCapabilities struct { // Value-object that contains additional information when // requesting references. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#referenceContext +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceContext type ReferenceContext struct { // Include the declaration of the current symbol. IncludeDeclaration bool `json:"includeDeclaration"` @@ -4345,14 +4316,14 @@ type ReferenceContext struct { // Reference options. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#referenceOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceOptions type ReferenceOptions struct { WorkDoneProgressOptions } // Parameters for a {@link ReferencesRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#referenceParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceParams type ReferenceParams struct { Context ReferenceContext `json:"context"` TextDocumentPositionParams @@ -4362,7 +4333,7 @@ type ReferenceParams struct { // Registration options for a {@link ReferencesRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#referenceRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#referenceRegistrationOptions type ReferenceRegistrationOptions struct { TextDocumentRegistrationOptions ReferenceOptions @@ -4370,7 +4341,7 @@ type ReferenceRegistrationOptions struct { // General parameters to register for a notification or to register a provider. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#registration +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#registration type Registration struct { // The id used to register the request. The id can be used to deregister // the request again. @@ -4381,18 +4352,18 @@ type Registration struct { RegisterOptions any `json:"registerOptions,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#registrationParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#registrationParams type RegistrationParams struct { Registrations []Registration `json:"registrations"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#regularExpressionEngineKind +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#regularExpressionEngineKind type RegularExpressionEngineKind = string // (alias) // Client capabilities specific to regular expressions. // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#regularExpressionsClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#regularExpressionsClientCapabilities type RegularExpressionsClientCapabilities struct { // The engine's name. Engine RegularExpressionEngineKind `json:"engine"` @@ -4404,7 +4375,7 @@ type RegularExpressionsClientCapabilities struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#relatedFullDocumentDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#relatedFullDocumentDiagnosticReport type RelatedFullDocumentDiagnosticReport struct { // Diagnostics of related documents. This information is useful // in programming languages where code in a file A can generate @@ -4421,7 +4392,7 @@ type RelatedFullDocumentDiagnosticReport struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#relatedUnchangedDocumentDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#relatedUnchangedDocumentDiagnosticReport type RelatedUnchangedDocumentDiagnosticReport struct { // Diagnostics of related documents. This information is useful // in programming languages where code in a file A can generate @@ -4440,7 +4411,7 @@ type RelatedUnchangedDocumentDiagnosticReport struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#relativePattern +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#relativePattern type RelativePattern struct { // A workspace folder or a base URI to which this pattern will be matched // against relatively. @@ -4449,7 +4420,7 @@ type RelativePattern struct { Pattern Pattern `json:"pattern"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#renameClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameClientCapabilities type RenameClientCapabilities struct { // Whether rename supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -4477,7 +4448,7 @@ type RenameClientCapabilities struct { // Rename file operation // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#renameFile +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameFile type RenameFile struct { // A rename Kind string `json:"kind"` @@ -4492,7 +4463,7 @@ type RenameFile struct { // Rename file options // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#renameFileOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameFileOptions type RenameFileOptions struct { // Overwrite target if existing. Overwrite wins over `ignoreIfExists` Overwrite bool `json:"overwrite,omitempty"` @@ -4505,7 +4476,7 @@ type RenameFileOptions struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#renameFilesParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameFilesParams type RenameFilesParams struct { // An array of all files/folders renamed in this operation. When a folder is renamed, only // the folder will be included, and not its children. @@ -4514,7 +4485,7 @@ type RenameFilesParams struct { // Provider options for a {@link RenameRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#renameOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameOptions type RenameOptions struct { // Renames should be checked and tested before being executed. // @@ -4525,7 +4496,7 @@ type RenameOptions struct { // The parameters of a {@link RenameRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#renameParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameParams type RenameParams struct { // The new name of the symbol. If the given name is not valid the // request must return a {@link ResponseError} with an @@ -4537,7 +4508,7 @@ type RenameParams struct { // Registration options for a {@link RenameRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#renameRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#renameRegistrationOptions type RenameRegistrationOptions struct { TextDocumentRegistrationOptions RenameOptions @@ -4545,7 +4516,7 @@ type RenameRegistrationOptions struct { // A generic resource operation. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#resourceOperation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#resourceOperation type ResourceOperation struct { // The resource operation kind. Kind string `json:"kind"` @@ -4558,7 +4529,7 @@ type ResourceOperationKind string // Save options. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#saveOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#saveOptions type SaveOptions struct { // The client is supposed to include the content on save. IncludeText bool `json:"includeText,omitempty"` @@ -4567,8 +4538,9 @@ type SaveOptions struct { // Describes the currently selected completion item. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#selectedCompletionInfo +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectedCompletionInfo type SelectedCompletionInfo struct { // The range that will be replaced if this completion item is accepted. Range Range `json:"range"` @@ -4579,7 +4551,7 @@ type SelectedCompletionInfo struct { // A selection range represents a part of a selection hierarchy. A selection range // may have a parent selection range that contains it. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#selectionRange +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRange type SelectionRange struct { // The {@link Range range} of this selection range. Range Range `json:"range"` @@ -4587,7 +4559,7 @@ type SelectionRange struct { Parent *SelectionRange `json:"parent,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#selectionRangeClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRangeClientCapabilities type SelectionRangeClientCapabilities struct { // Whether implementation supports dynamic registration for selection range providers. If this is set to `true` // the client supports the new `SelectionRangeRegistrationOptions` return value for the corresponding server @@ -4595,14 +4567,14 @@ type SelectionRangeClientCapabilities struct { DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#selectionRangeOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRangeOptions type SelectionRangeOptions struct { WorkDoneProgressOptions } // A parameter literal used in selection range requests. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#selectionRangeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRangeParams type SelectionRangeParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -4612,7 +4584,7 @@ type SelectionRangeParams struct { PartialResultParams } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#selectionRangeRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#selectionRangeRegistrationOptions type SelectionRangeRegistrationOptions struct { SelectionRangeOptions TextDocumentRegistrationOptions @@ -4635,7 +4607,7 @@ type SemanticTokenTypes string // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokens +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokens type SemanticTokens struct { // An optional result id. If provided and clients support delta updating // the client will include the result id in the next semantic token request. @@ -4648,7 +4620,7 @@ type SemanticTokens struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensClientCapabilities type SemanticTokensClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to `true` // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -4695,7 +4667,7 @@ type SemanticTokensClientCapabilities struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensDelta +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensDelta type SemanticTokensDelta struct { ResultID string `json:"resultId,omitempty"` // The semantic token edits to transform a previous result into a new result. @@ -4704,7 +4676,7 @@ type SemanticTokensDelta struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensDeltaParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensDeltaParams type SemanticTokensDeltaParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -4717,14 +4689,14 @@ type SemanticTokensDeltaParams struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensDeltaPartialResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensDeltaPartialResult type SemanticTokensDeltaPartialResult struct { Edits []SemanticTokensEdit `json:"edits"` } // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensEdit +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensEdit type SemanticTokensEdit struct { // The start offset of the edit. Start uint32 `json:"start"` @@ -4738,7 +4710,7 @@ type SemanticTokensEdit struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensFullDelta +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensFullDelta type SemanticTokensFullDelta struct { // The server supports deltas for full documents. Delta bool `json:"delta,omitempty"` @@ -4746,7 +4718,7 @@ type SemanticTokensFullDelta struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensLegend +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensLegend type SemanticTokensLegend struct { // The token types a server uses. TokenTypes []string `json:"tokenTypes"` @@ -4756,7 +4728,7 @@ type SemanticTokensLegend struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensOptions type SemanticTokensOptions struct { // The legend used by the server Legend SemanticTokensLegend `json:"legend"` @@ -4770,7 +4742,7 @@ type SemanticTokensOptions struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensParams type SemanticTokensParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -4780,14 +4752,14 @@ type SemanticTokensParams struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensPartialResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensPartialResult type SemanticTokensPartialResult struct { Data []uint32 `json:"data"` } // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensRangeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensRangeParams type SemanticTokensRangeParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -4799,7 +4771,7 @@ type SemanticTokensRangeParams struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensRegistrationOptions type SemanticTokensRegistrationOptions struct { TextDocumentRegistrationOptions SemanticTokensOptions @@ -4808,7 +4780,7 @@ type SemanticTokensRegistrationOptions struct { // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#semanticTokensWorkspaceClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#semanticTokensWorkspaceClientCapabilities type SemanticTokensWorkspaceClientCapabilities struct { // Whether the client implementation supports a refresh request sent from // the server to the client. @@ -4823,7 +4795,7 @@ type SemanticTokensWorkspaceClientCapabilities struct { // Defines the capabilities provided by a language // server. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#serverCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#serverCapabilities type ServerCapabilities struct { // The position encoding the server picked from the encodings offered // by the client via the client capability `general.positionEncodings`. @@ -4926,6 +4898,7 @@ type ServerCapabilities struct { // Inline completion options used during static registration. // // @since 3.18.0 + // @proposed InlineCompletionProvider *Or_ServerCapabilities_inlineCompletionProvider `json:"inlineCompletionProvider,omitempty"` // Workspace specific server capabilities. Workspace *WorkspaceOptions `json:"workspace,omitempty"` @@ -4935,7 +4908,7 @@ type ServerCapabilities struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#serverCompletionItemOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#serverCompletionItemOptions type ServerCompletionItemOptions struct { // The server has support for completion item label // details (see also `CompletionItemLabelDetails`) when @@ -4950,7 +4923,7 @@ type ServerCompletionItemOptions struct { // @since 3.15.0 // @since 3.18.0 ServerInfo type name added. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#serverInfo +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#serverInfo type ServerInfo struct { // The name of the server as defined by the server. Name string `json:"name"` @@ -4958,7 +4931,7 @@ type ServerInfo struct { Version string `json:"version,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#setTraceParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#setTraceParams type SetTraceParams struct { Value TraceValue `json:"value"` } @@ -4967,7 +4940,7 @@ type SetTraceParams struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#showDocumentClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showDocumentClientCapabilities type ShowDocumentClientCapabilities struct { // The client has support for the showDocument // request. @@ -4978,7 +4951,7 @@ type ShowDocumentClientCapabilities struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#showDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showDocumentParams type ShowDocumentParams struct { // The uri to show. URI URI `json:"uri"` @@ -5002,7 +4975,7 @@ type ShowDocumentParams struct { // // @since 3.16.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#showDocumentResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showDocumentResult type ShowDocumentResult struct { // A boolean indicating if the show was successful. Success bool `json:"success"` @@ -5010,7 +4983,7 @@ type ShowDocumentResult struct { // The parameters of a notification message. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#showMessageParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showMessageParams type ShowMessageParams struct { // The message type. See {@link MessageType} Type MessageType `json:"type"` @@ -5020,13 +4993,13 @@ type ShowMessageParams struct { // Show message request client capabilities // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#showMessageRequestClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showMessageRequestClientCapabilities type ShowMessageRequestClientCapabilities struct { // Capabilities specific to the `MessageActionItem` type. MessageActionItem *ClientShowMessageActionItemOptions `json:"messageActionItem,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#showMessageRequestParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#showMessageRequestParams type ShowMessageRequestParams struct { // The message type. See {@link MessageType} Type MessageType `json:"type"` @@ -5040,7 +5013,7 @@ type ShowMessageRequestParams struct { // callable. There can be multiple signature but only one // active and only one active parameter. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#signatureHelp +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelp type SignatureHelp struct { // One or more signatures. Signatures []SignatureInformation `json:"signatures"` @@ -5070,15 +5043,12 @@ type SignatureHelp struct { // In future version of the protocol this property might become // mandatory (but still nullable) to better express the active parameter if // the active signature does have any. - // - // Since version 3.16.0 the `SignatureInformation` itself provides a - // `activeParameter` property and it should be used instead of this one. ActiveParameter *uint32 `json:"activeParameter,omitempty"` } // Client Capabilities for a {@link SignatureHelpRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#signatureHelpClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpClientCapabilities type SignatureHelpClientCapabilities struct { // Whether signature help supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -5098,7 +5068,7 @@ type SignatureHelpClientCapabilities struct { // // @since 3.15.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#signatureHelpContext +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpContext type SignatureHelpContext struct { // Action that caused signature help to be triggered. TriggerKind SignatureHelpTriggerKind `json:"triggerKind"` @@ -5120,7 +5090,7 @@ type SignatureHelpContext struct { // Server Capabilities for a {@link SignatureHelpRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#signatureHelpOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpOptions type SignatureHelpOptions struct { // List of characters that trigger signature help automatically. TriggerCharacters []string `json:"triggerCharacters,omitempty"` @@ -5136,7 +5106,7 @@ type SignatureHelpOptions struct { // Parameters for a {@link SignatureHelpRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#signatureHelpParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpParams type SignatureHelpParams struct { // The signature help context. This is only available if the client specifies // to send this using the client capability `textDocument.signatureHelp.contextSupport === true` @@ -5149,7 +5119,7 @@ type SignatureHelpParams struct { // Registration options for a {@link SignatureHelpRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#signatureHelpRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureHelpRegistrationOptions type SignatureHelpRegistrationOptions struct { TextDocumentRegistrationOptions SignatureHelpOptions @@ -5164,7 +5134,7 @@ type SignatureHelpTriggerKind uint32 // can have a label, like a function-name, a doc-comment, and // a set of parameters. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#signatureInformation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#signatureInformation type SignatureInformation struct { // The label of this signature. Will be shown in // the UI. @@ -5191,8 +5161,9 @@ type SignatureInformation struct { // An interactive text edit. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#snippetTextEdit +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#snippetTextEdit type SnippetTextEdit struct { // The range of the text document to be manipulated. Range Range `json:"range"` @@ -5204,7 +5175,7 @@ type SnippetTextEdit struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#staleRequestSupportOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#staleRequestSupportOptions type StaleRequestSupportOptions struct { // The client will actively cancel the request. Cancel bool `json:"cancel"` @@ -5217,7 +5188,7 @@ type StaleRequestSupportOptions struct { // Static registration options to be returned in the initialize // request. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#staticRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#staticRegistrationOptions type StaticRegistrationOptions struct { // The id used to register the request. The id can be used to deregister // the request again. See also Registration#id. @@ -5233,8 +5204,9 @@ type StaticRegistrationOptions struct { // `${name:default value}`. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#stringValue +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#stringValue type StringValue struct { // The kind of string value. Kind string `json:"kind"` @@ -5245,7 +5217,7 @@ type StringValue struct { // Represents information about programming constructs like variables, classes, // interfaces etc. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#symbolInformation +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#symbolInformation type SymbolInformation struct { // extends BaseSymbolInformation // Indicates if this symbol is deprecated. @@ -5287,7 +5259,7 @@ type SymbolTag uint32 // Describe options to be used when registered for text document change events. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentChangeRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentChangeRegistrationOptions type TextDocumentChangeRegistrationOptions struct { // How documents are synced to the server. SyncKind TextDocumentSyncKind `json:"syncKind"` @@ -5296,7 +5268,7 @@ type TextDocumentChangeRegistrationOptions struct { // Text document specific client capabilities. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentClientCapabilities type TextDocumentClientCapabilities struct { // Defines which synchronization capabilities the client supports. Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"` @@ -5394,17 +5366,18 @@ type TextDocumentClientCapabilities struct { // Client capabilities specific to inline completions. // // @since 3.18.0 + // @proposed InlineCompletion *InlineCompletionClientCapabilities `json:"inlineCompletion,omitempty"` } // An event describing a change to a text document. If only a text is provided // it is considered to be the full content of the document. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentChangeEvent +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangeEvent type TextDocumentContentChangeEvent = TextDocumentContentChangePartial // (alias) // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentChangePartial +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangePartial type TextDocumentContentChangePartial struct { // The range of the document that changed. Range *Range `json:"range,omitempty"` @@ -5418,7 +5391,7 @@ type TextDocumentContentChangePartial struct { // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentChangeWholeDocument +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentChangeWholeDocument type TextDocumentContentChangeWholeDocument struct { // The new text of the whole document. Text string `json:"text"` @@ -5427,8 +5400,9 @@ type TextDocumentContentChangeWholeDocument struct { // Client capabilities for a text document content provider. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentClientCapabilities type TextDocumentContentClientCapabilities struct { // Text document content provider supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -5437,8 +5411,9 @@ type TextDocumentContentClientCapabilities struct { // Text document content provider options. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentOptions type TextDocumentContentOptions struct { // The schemes for which the server provides content. Schemes []string `json:"schemes"` @@ -5447,8 +5422,9 @@ type TextDocumentContentOptions struct { // Parameters for the `workspace/textDocumentContent` request. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentParams type TextDocumentContentParams struct { // The uri of the text document. URI DocumentURI `json:"uri"` @@ -5457,8 +5433,9 @@ type TextDocumentContentParams struct { // Parameters for the `workspace/textDocumentContent/refresh` request. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentRefreshParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentRefreshParams type TextDocumentContentRefreshParams struct { // The uri of the text document to refresh. URI DocumentURI `json:"uri"` @@ -5467,8 +5444,9 @@ type TextDocumentContentRefreshParams struct { // Text document content provider registration options. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentRegistrationOptions type TextDocumentContentRegistrationOptions struct { TextDocumentContentOptions StaticRegistrationOptions @@ -5477,8 +5455,9 @@ type TextDocumentContentRegistrationOptions struct { // Result of the `workspace/textDocumentContent` request. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentContentResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentContentResult type TextDocumentContentResult struct { // The text content of the text document. Please note, that the content of // any subsequent open notifications for the text document might differ @@ -5492,7 +5471,7 @@ type TextDocumentContentResult struct { // So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any // kind of ordering. However the edits must be non overlapping. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentEdit +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentEdit type TextDocumentEdit struct { // The text document to change. TextDocument OptionalVersionedTextDocumentIdentifier `json:"textDocument"` @@ -5512,7 +5491,7 @@ type TextDocumentEdit struct { // // Glob patterns can have the following syntax: // -// - `*` to match zero or more characters in a path segment +// - `*` to match one or more characters in a path segment // - `?` to match on one character in a path segment // - `**` to match any number of path segments, including none // - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) @@ -5524,9 +5503,9 @@ type TextDocumentEdit struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentFilter +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilter type TextDocumentFilter = Or_TextDocumentFilter // (alias) -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentFilterClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterClientCapabilities type TextDocumentFilterClientCapabilities struct { // The client supports Relative Patterns. // @@ -5538,7 +5517,7 @@ type TextDocumentFilterClientCapabilities struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentFilterLanguage +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterLanguage type TextDocumentFilterLanguage struct { // A language id, like `typescript`. Language string `json:"language"` @@ -5556,7 +5535,7 @@ type TextDocumentFilterLanguage struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentFilterPattern +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterPattern type TextDocumentFilterPattern struct { // A language id, like `typescript`. Language string `json:"language,omitempty"` @@ -5574,7 +5553,7 @@ type TextDocumentFilterPattern struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentFilterScheme +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentFilterScheme type TextDocumentFilterScheme struct { // A language id, like `typescript`. Language string `json:"language,omitempty"` @@ -5590,7 +5569,7 @@ type TextDocumentFilterScheme struct { // A literal to identify a text document in the client. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentIdentifier +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentIdentifier type TextDocumentIdentifier struct { // The text document's uri. URI DocumentURI `json:"uri"` @@ -5599,7 +5578,7 @@ type TextDocumentIdentifier struct { // An item to transfer a text document from the client to the // server. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentItem +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentItem type TextDocumentItem struct { // The text document's uri. URI DocumentURI `json:"uri"` @@ -5615,7 +5594,7 @@ type TextDocumentItem struct { // A parameter literal used in requests to pass a text document and a position inside that // document. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentPositionParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentPositionParams type TextDocumentPositionParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -5632,7 +5611,7 @@ type TextDocumentPositionParams struct { // General text document registration options. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentRegistrationOptions type TextDocumentRegistrationOptions struct { // A document selector to identify the scope of the registration. If set to null // the document selector provided on the client side will be used. @@ -5644,13 +5623,13 @@ type TextDocumentSaveReason uint32 // Save registration options. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentSaveRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentSaveRegistrationOptions type TextDocumentSaveRegistrationOptions struct { TextDocumentRegistrationOptions SaveOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentSyncClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentSyncClientCapabilities type TextDocumentSyncClientCapabilities struct { // Whether text document synchronization supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -5668,7 +5647,7 @@ type TextDocumentSyncClientCapabilities struct { // document changes to the language server. type TextDocumentSyncKind uint32 -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocumentSyncOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocumentSyncOptions type TextDocumentSyncOptions struct { // Open and close notifications are sent to the server. If omitted open close notification should not // be sent. @@ -5689,7 +5668,7 @@ type TextDocumentSyncOptions struct { // A text edit applicable to a text document. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textEdit +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textEdit type TextEdit struct { // The range of the text document to be manipulated. To insert // text into a document create a range where start === end. @@ -5703,7 +5682,7 @@ type TraceValue string // Since 3.6.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeDefinitionClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeDefinitionClientCapabilities type TypeDefinitionClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to `true` // the client supports the new `TypeDefinitionRegistrationOptions` return value @@ -5715,19 +5694,19 @@ type TypeDefinitionClientCapabilities struct { LinkSupport bool `json:"linkSupport,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeDefinitionOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeDefinitionOptions type TypeDefinitionOptions struct { WorkDoneProgressOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeDefinitionParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeDefinitionParams type TypeDefinitionParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeDefinitionRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeDefinitionRegistrationOptions type TypeDefinitionRegistrationOptions struct { TextDocumentRegistrationOptions TypeDefinitionOptions @@ -5736,7 +5715,7 @@ type TypeDefinitionRegistrationOptions struct { // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchyClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyClientCapabilities type TypeHierarchyClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to `true` // the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` @@ -5746,7 +5725,7 @@ type TypeHierarchyClientCapabilities struct { // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchyItem +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyItem type TypeHierarchyItem struct { // The name of this item. Name string `json:"name"` @@ -5776,7 +5755,7 @@ type TypeHierarchyItem struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchyOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyOptions type TypeHierarchyOptions struct { WorkDoneProgressOptions } @@ -5785,7 +5764,7 @@ type TypeHierarchyOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchyPrepareParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyPrepareParams type TypeHierarchyPrepareParams struct { TextDocumentPositionParams WorkDoneProgressParams @@ -5795,7 +5774,7 @@ type TypeHierarchyPrepareParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchyRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchyRegistrationOptions type TypeHierarchyRegistrationOptions struct { TextDocumentRegistrationOptions TypeHierarchyOptions @@ -5806,7 +5785,7 @@ type TypeHierarchyRegistrationOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchySubtypesParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchySubtypesParams type TypeHierarchySubtypesParams struct { Item TypeHierarchyItem `json:"item"` WorkDoneProgressParams @@ -5817,7 +5796,7 @@ type TypeHierarchySubtypesParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchySupertypesParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchySupertypesParams type TypeHierarchySupertypesParams struct { Item TypeHierarchyItem `json:"item"` WorkDoneProgressParams @@ -5835,7 +5814,7 @@ type UIntCommaUInt struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#unchangedDocumentDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#unchangedDocumentDiagnosticReport type UnchangedDocumentDiagnosticReport struct { // A document diagnostic report indicating // no changes to the last result. A server can @@ -5854,7 +5833,7 @@ type UniquenessLevel string // General parameters to unregister a request or notification. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#unregistration +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#unregistration type Unregistration struct { // The id used to unregister the request or notification. Usually an id // provided during the register request. @@ -5863,7 +5842,7 @@ type Unregistration struct { Method string `json:"method"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#unregistrationParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#unregistrationParams type UnregistrationParams struct { Unregisterations []Unregistration `json:"unregisterations"` } @@ -5872,7 +5851,7 @@ type UnregistrationParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#versionedNotebookDocumentIdentifier +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#versionedNotebookDocumentIdentifier type VersionedNotebookDocumentIdentifier struct { // The version number of this notebook document. Version int32 `json:"version"` @@ -5882,14 +5861,14 @@ type VersionedNotebookDocumentIdentifier struct { // A text document identifier to denote a specific version of a text document. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#versionedTextDocumentIdentifier +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#versionedTextDocumentIdentifier type VersionedTextDocumentIdentifier struct { // The version number of this document. Version int32 `json:"version"` TextDocumentIdentifier } type WatchKind = uint32 // The parameters sent in a will save text document notification. -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#willSaveTextDocumentParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#willSaveTextDocumentParams type WillSaveTextDocumentParams struct { // The document that will be saved. TextDocument TextDocumentIdentifier `json:"textDocument"` @@ -5897,7 +5876,7 @@ type WillSaveTextDocumentParams struct { Reason TextDocumentSaveReason `json:"reason"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#windowClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#windowClientCapabilities type WindowClientCapabilities struct { // It indicates whether the client supports server initiated // progress using the `window/workDoneProgress/create` request. @@ -5919,7 +5898,7 @@ type WindowClientCapabilities struct { ShowDocument *ShowDocumentClientCapabilities `json:"showDocument,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workDoneProgressBegin +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressBegin type WorkDoneProgressBegin struct { Kind string `json:"kind"` // Mandatory title of the progress operation. Used to briefly inform about @@ -5946,19 +5925,19 @@ type WorkDoneProgressBegin struct { Percentage *uint32 `json:"percentage,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workDoneProgressCancelParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressCancelParams type WorkDoneProgressCancelParams struct { // The token to be used to report progress. Token ProgressToken `json:"token"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workDoneProgressCreateParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressCreateParams type WorkDoneProgressCreateParams struct { // The token to be used to report progress. Token ProgressToken `json:"token"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workDoneProgressEnd +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressEnd type WorkDoneProgressEnd struct { Kind string `json:"kind"` // Optional, a final message indicating to for example indicate the outcome @@ -5966,7 +5945,7 @@ type WorkDoneProgressEnd struct { Message string `json:"message,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workDoneProgressOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressOptions type WorkDoneProgressOptions struct { WorkDoneProgress bool `json:"workDoneProgress,omitempty"` } @@ -5977,13 +5956,13 @@ type WorkDoneProgressOptionsAndTextDocumentRegistrationOptions struct { TextDocumentRegistrationOptions } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workDoneProgressParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressParams type WorkDoneProgressParams struct { // An optional token that a server can use to report work done progress. WorkDoneToken ProgressToken `json:"workDoneToken,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workDoneProgressReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workDoneProgressReport type WorkDoneProgressReport struct { Kind string `json:"kind"` // Controls enablement state of a cancel button. @@ -6008,7 +5987,7 @@ type WorkDoneProgressReport struct { // Workspace specific client capabilities. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceClientCapabilities type WorkspaceClientCapabilities struct { // The client supports applying batch edits // to the workspace by supporting the request @@ -6064,10 +6043,12 @@ type WorkspaceClientCapabilities struct { // Capabilities specific to the folding range requests scoped to the workspace. // // @since 3.18.0 + // @proposed FoldingRange *FoldingRangeWorkspaceClientCapabilities `json:"foldingRange,omitempty"` // Capabilities specific to the `workspace/textDocumentContent` request. // // @since 3.18.0 + // @proposed TextDocumentContent *TextDocumentContentClientCapabilities `json:"textDocumentContent,omitempty"` } @@ -6075,7 +6056,7 @@ type WorkspaceClientCapabilities struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceDiagnosticParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDiagnosticParams type WorkspaceDiagnosticParams struct { // The additional identifier provided during registration. Identifier string `json:"identifier,omitempty"` @@ -6090,7 +6071,7 @@ type WorkspaceDiagnosticParams struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDiagnosticReport type WorkspaceDiagnosticReport struct { Items []WorkspaceDocumentDiagnosticReport `json:"items"` } @@ -6099,7 +6080,7 @@ type WorkspaceDiagnosticReport struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceDiagnosticReportPartialResult +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDiagnosticReportPartialResult type WorkspaceDiagnosticReportPartialResult struct { Items []WorkspaceDocumentDiagnosticReport `json:"items"` } @@ -6108,7 +6089,7 @@ type WorkspaceDiagnosticReportPartialResult struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceDocumentDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceDocumentDiagnosticReport type WorkspaceDocumentDiagnosticReport = Or_WorkspaceDocumentDiagnosticReport // (alias) // A workspace edit represents changes to many resources managed in the workspace. The edit // should either provide `changes` or `documentChanges`. If documentChanges are present @@ -6123,7 +6104,7 @@ type WorkspaceDocumentDiagnosticReport = Or_WorkspaceDocumentDiagnosticReport // // cause failure of the operation. How the client recovers from the failure is described by // the client capability: `workspace.workspaceEdit.failureHandling` // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceEdit +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceEdit type WorkspaceEdit struct { // Holds changes to existing resources. Changes map[DocumentURI][]TextEdit `json:"changes,omitempty"` @@ -6147,7 +6128,7 @@ type WorkspaceEdit struct { ChangeAnnotations map[ChangeAnnotationIdentifier]ChangeAnnotation `json:"changeAnnotations,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceEditClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceEditClientCapabilities type WorkspaceEditClientCapabilities struct { // The client supports versioned document changes in `WorkspaceEdit`s DocumentChanges bool `json:"documentChanges,omitempty"` @@ -6177,18 +6158,21 @@ type WorkspaceEditClientCapabilities struct { // Whether the client supports `WorkspaceEditMetadata` in `WorkspaceEdit`s. // // @since 3.18.0 + // @proposed MetadataSupport bool `json:"metadataSupport,omitempty"` // Whether the client supports snippets as text edits. // // @since 3.18.0 + // @proposed SnippetEditSupport bool `json:"snippetEditSupport,omitempty"` } // Additional data about a workspace edit. // // @since 3.18.0 +// @proposed // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceEditMetadata +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceEditMetadata type WorkspaceEditMetadata struct { // Signal to the editor that this edit is a refactoring. IsRefactoring bool `json:"isRefactoring,omitempty"` @@ -6196,7 +6180,7 @@ type WorkspaceEditMetadata struct { // A workspace folder inside a client. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceFolder +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFolder type WorkspaceFolder struct { // The associated URI for this workspace folder. URI URI `json:"uri"` @@ -6205,7 +6189,7 @@ type WorkspaceFolder struct { Name string `json:"name"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceFoldersServerCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFoldersServerCapabilities type WorkspaceFolders5Gn struct { // The server has support for workspace folders Supported bool `json:"supported,omitempty"` @@ -6221,7 +6205,7 @@ type WorkspaceFolders5Gn struct { // The workspace folder change event. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceFoldersChangeEvent +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFoldersChangeEvent type WorkspaceFoldersChangeEvent struct { // The array of added workspace folders Added []WorkspaceFolder `json:"added"` @@ -6229,7 +6213,7 @@ type WorkspaceFoldersChangeEvent struct { Removed []WorkspaceFolder `json:"removed"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceFoldersInitializeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFoldersInitializeParams type WorkspaceFoldersInitializeParams struct { // The workspace folders configured in the client when the server starts. // @@ -6241,7 +6225,7 @@ type WorkspaceFoldersInitializeParams struct { WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders,omitempty"` } -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceFoldersServerCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFoldersServerCapabilities type WorkspaceFoldersServerCapabilities struct { // The server has support for workspace folders Supported bool `json:"supported,omitempty"` @@ -6259,7 +6243,7 @@ type WorkspaceFoldersServerCapabilities struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceFullDocumentDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceFullDocumentDiagnosticReport type WorkspaceFullDocumentDiagnosticReport struct { // The URI for which diagnostic information is reported. URI DocumentURI `json:"uri"` @@ -6273,7 +6257,7 @@ type WorkspaceFullDocumentDiagnosticReport struct { // // @since 3.18.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceOptions type WorkspaceOptions struct { // The server supports workspace folder. // @@ -6286,6 +6270,7 @@ type WorkspaceOptions struct { // The server supports the `workspace/textDocumentContent` request. // // @since 3.18.0 + // @proposed TextDocumentContent *Or_WorkspaceOptions_textDocumentContent `json:"textDocumentContent,omitempty"` } @@ -6295,7 +6280,7 @@ type WorkspaceOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceSymbol +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbol type WorkspaceSymbol struct { // The location of the symbol. Whether a server is allowed to // return a location without a range depends on the client @@ -6311,7 +6296,7 @@ type WorkspaceSymbol struct { // Client capabilities for a {@link WorkspaceSymbolRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceSymbolClientCapabilities +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbolClientCapabilities type WorkspaceSymbolClientCapabilities struct { // Symbol request supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` @@ -6332,7 +6317,7 @@ type WorkspaceSymbolClientCapabilities struct { // Server capabilities for a {@link WorkspaceSymbolRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceSymbolOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbolOptions type WorkspaceSymbolOptions struct { // The server provides support to resolve additional // information for a workspace symbol. @@ -6344,7 +6329,7 @@ type WorkspaceSymbolOptions struct { // The parameters of a {@link WorkspaceSymbolRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceSymbolParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbolParams type WorkspaceSymbolParams struct { // A query string to filter symbols by. Clients may send an empty // string here to request all symbols. @@ -6361,7 +6346,7 @@ type WorkspaceSymbolParams struct { // Registration options for a {@link WorkspaceSymbolRequest}. // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceSymbolRegistrationOptions +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbolRegistrationOptions type WorkspaceSymbolRegistrationOptions struct { WorkspaceSymbolOptions } @@ -6370,7 +6355,7 @@ type WorkspaceSymbolRegistrationOptions struct { // // @since 3.17.0 // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceUnchangedDocumentDiagnosticReport +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceUnchangedDocumentDiagnosticReport type WorkspaceUnchangedDocumentDiagnosticReport struct { // The URI for which diagnostic information is reported. URI DocumentURI `json:"uri"` @@ -6382,7 +6367,7 @@ type WorkspaceUnchangedDocumentDiagnosticReport struct { // The initialize parameters // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#_InitializeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#_InitializeParams type XInitializeParams struct { // The process Id of the parent process that started // the server. @@ -6425,7 +6410,7 @@ type XInitializeParams struct { // The initialize parameters // -// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#_InitializeParams +// See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#_InitializeParams type _InitializeParams struct { // The process Id of the parent process that started // the server. @@ -6518,6 +6503,7 @@ const ( // - ... // // @since 3.18.0 + // @proposed RefactorMove CodeActionKind = "refactor.move" // Base kind for refactoring rewrite actions: 'refactor.rewrite' // @@ -6697,6 +6683,7 @@ const ( // Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered. // // @since 3.18.0 + // @proposed // Completion was triggered explicitly by a user gesture. InlineInvoked InlineCompletionTriggerKind = 1 // Completion was triggered automatically while editing. @@ -6769,8 +6756,10 @@ const ( LangCSharp LanguageKind = "csharp" LangCSS LanguageKind = "css" // @since 3.18.0 + // @proposed LangD LanguageKind = "d" // @since 3.18.0 + // @proposed LangDelphi LanguageKind = "pascal" LangDiff LanguageKind = "diff" LangDart LanguageKind = "dart" @@ -6779,7 +6768,7 @@ const ( LangErlang LanguageKind = "erlang" LangFSharp LanguageKind = "fsharp" LangGitCommit LanguageKind = "git-commit" - LangGitRebase LanguageKind = "git-rebase" + LangGitRebase LanguageKind = "rebase" LangGo LanguageKind = "go" LangGroovy LanguageKind = "groovy" LangHandlebars LanguageKind = "handlebars" @@ -6798,11 +6787,11 @@ const ( LangObjectiveC LanguageKind = "objective-c" LangObjectiveCPP LanguageKind = "objective-cpp" // @since 3.18.0 + // @proposed LangPascal LanguageKind = "pascal" LangPerl LanguageKind = "perl" LangPerl6 LanguageKind = "perl6" LangPHP LanguageKind = "php" - LangPlaintext LanguageKind = "plaintext" LangPowershell LanguageKind = "powershell" LangPug LanguageKind = "jade" LangPython LanguageKind = "python" @@ -6845,6 +6834,7 @@ const ( // A debug message. // // @since 3.18.0 + // @proposed Debug MessageType = 5 // The moniker kind. // diff --git a/vendor/golang.org/x/tools/gopls/internal/protocol/tsserver.go b/vendor/golang.org/x/tools/gopls/internal/protocol/tsserver.go index e6e4ff78ae..83319162a7 100644 --- a/vendor/golang.org/x/tools/gopls/internal/protocol/tsserver.go +++ b/vendor/golang.org/x/tools/gopls/internal/protocol/tsserver.go @@ -6,9 +6,9 @@ package protocol -// Code generated from protocol/metaModel.json at ref release/protocol/3.18.2 (hash 20969f3e75cb3cd35c2bb794b1d15cc2dfbe4abb). -// https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.18.2/protocol/metaModel.json -// LSP metaData.version = 3.18.0. +// Code generated from protocol/metaModel.json at ref release/protocol/3.17.6-next.14 (hash 66a087310eea0d60495ba3578d78f70409c403d9). +// https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.17.6-next.14/protocol/metaModel.json +// LSP metaData.version = 3.17.0. import ( "context" @@ -19,17 +19,17 @@ import ( ) type Server interface { - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#progress + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#progress Progress(context.Context, *ProgressParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#setTrace + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#setTrace SetTrace(context.Context, *SetTraceParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchy_incomingCalls + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchy_incomingCalls IncomingCalls(context.Context, *CallHierarchyIncomingCallsParams) ([]CallHierarchyIncomingCall, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#callHierarchy_outgoingCalls + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#callHierarchy_outgoingCalls OutgoingCalls(context.Context, *CallHierarchyOutgoingCallsParams) ([]CallHierarchyOutgoingCall, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeAction_resolve + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeAction_resolve ResolveCodeAction(context.Context, *CodeAction) (*CodeAction, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#codeLens_resolve + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#codeLens_resolve ResolveCodeLens(context.Context, *CodeLens) (*CodeLens, error) // ResolveCommand handles the interactive resolution of a command prior to // its execution. @@ -50,17 +50,17 @@ type Server interface { // // Note: This is a non-standard protocol extension. ResolveCommand(context.Context, *ExecuteCommandParams) (*ExecuteCommandParams, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#completionItem_resolve + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#completionItem_resolve ResolveCompletionItem(context.Context, *CompletionItem) (*CompletionItem, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#documentLink_resolve + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#documentLink_resolve ResolveDocumentLink(context.Context, *DocumentLink) (*DocumentLink, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#exit + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#exit Exit(context.Context) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#initialize + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initialize Initialize(context.Context, *ParamInitialize) (*InitializeResult, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#initialized + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#initialized Initialized(context.Context, *InitializedParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#inlayHint_resolve + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#inlayHint_resolve Resolve(context.Context, *InlayHint) (*InlayHint, error) // InteractiveListEnum is the request handler for fetching dynamic enum options. // @@ -72,129 +72,129 @@ type Server interface { // // Note: This is a non-standard protocol extension. InteractiveListEnum(context.Context, *InteractiveListEnumParams) ([]FormEnumEntry, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocument_didChange + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument_didChange DidChangeNotebookDocument(context.Context, *DidChangeNotebookDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocument_didClose + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument_didClose DidCloseNotebookDocument(context.Context, *DidCloseNotebookDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocument_didOpen + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument_didOpen DidOpenNotebookDocument(context.Context, *DidOpenNotebookDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#notebookDocument_didSave + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#notebookDocument_didSave DidSaveNotebookDocument(context.Context, *DidSaveNotebookDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#shutdown + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#shutdown Shutdown(context.Context) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_codeAction + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_codeAction CodeAction(context.Context, *CodeActionParams) ([]CodeAction, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_codeLens + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_codeLens CodeLens(context.Context, *CodeLensParams) ([]CodeLens, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_colorPresentation + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_colorPresentation ColorPresentation(context.Context, *ColorPresentationParams) ([]ColorPresentation, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_completion + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_completion Completion(context.Context, *CompletionParams) (*CompletionList, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_declaration + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_declaration Declaration(context.Context, *DeclarationParams) (*Or_textDocument_declaration, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_definition + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_definition Definition(context.Context, *DefinitionParams) ([]Location, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_diagnostic + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_diagnostic Diagnostic(context.Context, *DocumentDiagnosticParams) (*DocumentDiagnosticReport, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_didChange + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_didChange DidChange(context.Context, *DidChangeTextDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_didClose + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_didClose DidClose(context.Context, *DidCloseTextDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_didOpen + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_didOpen DidOpen(context.Context, *DidOpenTextDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_didSave + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_didSave DidSave(context.Context, *DidSaveTextDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_documentColor + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_documentColor DocumentColor(context.Context, *DocumentColorParams) ([]ColorInformation, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_documentHighlight + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_documentHighlight DocumentHighlight(context.Context, *DocumentHighlightParams) ([]DocumentHighlight, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_documentLink + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_documentLink DocumentLink(context.Context, *DocumentLinkParams) ([]DocumentLink, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_documentSymbol + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_documentSymbol DocumentSymbol(context.Context, *DocumentSymbolParams) ([]any, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_foldingRange + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_foldingRange FoldingRange(context.Context, *FoldingRangeParams) ([]FoldingRange, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_formatting + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_formatting Formatting(context.Context, *DocumentFormattingParams) ([]TextEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_hover + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_hover Hover(context.Context, *HoverParams) (*Hover, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_implementation + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_implementation Implementation(context.Context, *ImplementationParams) ([]Location, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_inlayHint + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_inlayHint InlayHint(context.Context, *InlayHintParams) ([]InlayHint, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_inlineCompletion + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_inlineCompletion InlineCompletion(context.Context, *InlineCompletionParams) (*Or_Result_textDocument_inlineCompletion, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_inlineValue + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_inlineValue InlineValue(context.Context, *InlineValueParams) ([]InlineValue, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_linkedEditingRange + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_linkedEditingRange LinkedEditingRange(context.Context, *LinkedEditingRangeParams) (*LinkedEditingRanges, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_moniker + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_moniker Moniker(context.Context, *MonikerParams) ([]Moniker, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_onTypeFormatting + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_onTypeFormatting OnTypeFormatting(context.Context, *DocumentOnTypeFormattingParams) ([]TextEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_prepareCallHierarchy + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_prepareCallHierarchy PrepareCallHierarchy(context.Context, *CallHierarchyPrepareParams) ([]CallHierarchyItem, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_prepareRename + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_prepareRename PrepareRename(context.Context, *PrepareRenameParams) (*PrepareRenameResult, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_prepareTypeHierarchy + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_prepareTypeHierarchy PrepareTypeHierarchy(context.Context, *TypeHierarchyPrepareParams) ([]TypeHierarchyItem, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_rangeFormatting + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_rangeFormatting RangeFormatting(context.Context, *DocumentRangeFormattingParams) ([]TextEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_rangesFormatting + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_rangesFormatting RangesFormatting(context.Context, *DocumentRangesFormattingParams) ([]TextEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_references + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_references References(context.Context, *ReferenceParams) ([]Location, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_rename + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_rename Rename(context.Context, *RenameParams) (*WorkspaceEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_selectionRange + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_selectionRange SelectionRange(context.Context, *SelectionRangeParams) ([]SelectionRange, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_semanticTokens_full + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_semanticTokens_full SemanticTokensFull(context.Context, *SemanticTokensParams) (*SemanticTokens, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_semanticTokens_full_delta + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_semanticTokens_full_delta SemanticTokensFullDelta(context.Context, *SemanticTokensDeltaParams) (any, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_semanticTokens_range + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_semanticTokens_range SemanticTokensRange(context.Context, *SemanticTokensRangeParams) (*SemanticTokens, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_signatureHelp + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_signatureHelp SignatureHelp(context.Context, *SignatureHelpParams) (*SignatureHelp, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_typeDefinition + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_typeDefinition TypeDefinition(context.Context, *TypeDefinitionParams) ([]Location, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_willSave + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_willSave WillSave(context.Context, *WillSaveTextDocumentParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#textDocument_willSaveWaitUntil + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#textDocument_willSaveWaitUntil WillSaveWaitUntil(context.Context, *WillSaveTextDocumentParams) ([]TextEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchy_subtypes + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchy_subtypes Subtypes(context.Context, *TypeHierarchySubtypesParams) ([]TypeHierarchyItem, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#typeHierarchy_supertypes + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#typeHierarchy_supertypes Supertypes(context.Context, *TypeHierarchySupertypesParams) ([]TypeHierarchyItem, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#window_workDoneProgress_cancel + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#window_workDoneProgress_cancel WorkDoneProgressCancel(context.Context, *WorkDoneProgressCancelParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_diagnostic + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_diagnostic DiagnosticWorkspace(context.Context, *WorkspaceDiagnosticParams) (*WorkspaceDiagnosticReport, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_didChangeConfiguration + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didChangeConfiguration DidChangeConfiguration(context.Context, *DidChangeConfigurationParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_didChangeWatchedFiles + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didChangeWatchedFiles DidChangeWatchedFiles(context.Context, *DidChangeWatchedFilesParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_didChangeWorkspaceFolders + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didChangeWorkspaceFolders DidChangeWorkspaceFolders(context.Context, *DidChangeWorkspaceFoldersParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_didCreateFiles + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didCreateFiles DidCreateFiles(context.Context, *CreateFilesParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_didDeleteFiles + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didDeleteFiles DidDeleteFiles(context.Context, *DeleteFilesParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_didRenameFiles + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_didRenameFiles DidRenameFiles(context.Context, *RenameFilesParams) error - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_executeCommand + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_executeCommand ExecuteCommand(context.Context, *ExecuteCommandParams) (any, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_symbol + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_symbol Symbol(context.Context, *WorkspaceSymbolParams) ([]SymbolInformation, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_textDocumentContent + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_textDocumentContent TextDocumentContent(context.Context, *TextDocumentContentParams) (*TextDocumentContentResult, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_willCreateFiles + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_willCreateFiles WillCreateFiles(context.Context, *CreateFilesParams) (*WorkspaceEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_willDeleteFiles + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_willDeleteFiles WillDeleteFiles(context.Context, *DeleteFilesParams) (*WorkspaceEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspace_willRenameFiles + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspace_willRenameFiles WillRenameFiles(context.Context, *RenameFilesParams) (*WorkspaceEdit, error) - // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification#workspaceSymbol_resolve + // See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification#workspaceSymbol_resolve ResolveWorkspaceSymbol(context.Context, *WorkspaceSymbol) (*WorkspaceSymbol, error) } diff --git a/vendor/golang.org/x/tools/gopls/internal/server/code_action.go b/vendor/golang.org/x/tools/gopls/internal/server/code_action.go index 93cf92532b..0d0a111046 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/code_action.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/code_action.go @@ -351,7 +351,7 @@ func (s *server) findMatchingDiagnostics(uri protocol.DocumentURI, pd protocol.D for _, sd := range viewDiags.diagnostics { // extra space may have been trimmed when // converting to protocol.Diagnostic - sameDiagnostic := pd.MessageString() == strings.TrimSpace(sd.Message) && + sameDiagnostic := pd.Message == strings.TrimSpace(sd.Message) && protocol.CompareRange(pd.Range, sd.Range) == 0 && pd.Source == string(sd.Source) diff --git a/vendor/golang.org/x/tools/gopls/internal/server/command.go b/vendor/golang.org/x/tools/gopls/internal/server/command.go index 94fe90cecd..d858f1779d 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/command.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/command.go @@ -1954,15 +1954,3 @@ func (c *commandHandler) MoveType(ctx context.Context, args command.MoveTypeArgs }) return err } - -func (c *commandHandler) MoveDeclaration(ctx context.Context, args command.MoveDeclarationArgs, params *protocol.InteractiveParams) error { - return c.run(ctx, commandConfig{ - forURI: args.Location.URI, - }, func(ctx context.Context, deps commandDeps) error { - changes, _, err := golang.MoveDeclaration(ctx, deps.fh, deps.snapshot) - if err != nil { - return err - } - return applyChanges(ctx, c.s.client, changes) - }) -} diff --git a/vendor/golang.org/x/tools/gopls/internal/server/diagnostics.go b/vendor/golang.org/x/tools/gopls/internal/server/diagnostics.go index 198bb95089..1eae797d7f 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/diagnostics.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/diagnostics.go @@ -26,11 +26,11 @@ import ( "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/settings" "golang.org/x/tools/gopls/internal/template" + "golang.org/x/tools/gopls/internal/util/moremaps" "golang.org/x/tools/gopls/internal/work" "golang.org/x/tools/internal/event" "golang.org/x/tools/internal/event/keys" "golang.org/x/tools/internal/jsonrpc2" - "golang.org/x/tools/internal/moremaps" ) // Diagnostic implements the textDocument/diagnostic LSP request, reporting diff --git a/vendor/golang.org/x/tools/gopls/internal/server/general.go b/vendor/golang.org/x/tools/gopls/internal/server/general.go index 296e9c4f9f..420a70287a 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/general.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/general.go @@ -16,7 +16,6 @@ import ( "os" "path" "path/filepath" - runtimedebug "runtime/debug" "slices" "sort" "strings" @@ -35,10 +34,10 @@ import ( "golang.org/x/tools/gopls/internal/telemetry" "golang.org/x/tools/gopls/internal/util/bug" "golang.org/x/tools/gopls/internal/util/goversion" + "golang.org/x/tools/gopls/internal/util/moremaps" + "golang.org/x/tools/gopls/internal/util/moreslices" "golang.org/x/tools/internal/event" "golang.org/x/tools/internal/jsonrpc2" - "golang.org/x/tools/internal/moremaps" - "golang.org/x/tools/internal/moreslices" ) func (s *server) Initialize(ctx context.Context, params *protocol.ParamInitialize) (*protocol.InitializeResult, error) { @@ -72,7 +71,9 @@ func (s *server) Initialize(ctx context.Context, params *protocol.ParamInitializ } options.ForClientCapabilities(params.ClientInfo, params.Capabilities) - updateGlobalOptions(options) + if options.MaxFileCacheBytes > 0 { + filecache.SetBudget(options.MaxFileCacheBytes) + } if options.ShowBugReports { // Report the next bug that occurs on the server. @@ -276,17 +277,6 @@ func (s *server) Initialize(ctx context.Context, params *protocol.ParamInitializ }, nil } -// updateGlobalOptions updates process-wide settings -// received by a DidChangeConfiguration or Initialize request. -func updateGlobalOptions(options *settings.Options) { - if options.MaxFileCacheBytes > 0 { - filecache.SetBudget(options.MaxFileCacheBytes) - } - if options.MemoryLimit > 0 { - runtimedebug.SetMemoryLimit(options.MemoryLimit) - } -} - func (s *server) Initialized(ctx context.Context, params *protocol.InitializedParams) error { ctx, done := event.Start(ctx, "server.Initialized") defer done() diff --git a/vendor/golang.org/x/tools/gopls/internal/server/highlight.go b/vendor/golang.org/x/tools/gopls/internal/server/highlight.go index b5aa4bcaef..83b2660d72 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/highlight.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/highlight.go @@ -8,7 +8,6 @@ import ( "context" "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/goasm" "golang.org/x/tools/gopls/internal/golang" "golang.org/x/tools/gopls/internal/label" "golang.org/x/tools/gopls/internal/protocol" @@ -27,8 +26,6 @@ func (s *server) DocumentHighlight(ctx context.Context, params *protocol.Documen defer release() switch snapshot.FileKind(fh) { - case file.Asm: - return goasm.Highlight(ctx, snapshot, fh, params.Range) case file.Tmpl: return template.Highlight(ctx, snapshot, fh, params.Range) case file.Go: diff --git a/vendor/golang.org/x/tools/gopls/internal/server/hover.go b/vendor/golang.org/x/tools/gopls/internal/server/hover.go index 7c3284dbc3..d0c2c833d9 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/hover.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/hover.go @@ -8,7 +8,6 @@ import ( "context" "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/goasm" "golang.org/x/tools/gopls/internal/golang" "golang.org/x/tools/gopls/internal/label" "golang.org/x/tools/gopls/internal/mod" @@ -36,8 +35,6 @@ func (s *server) Hover(ctx context.Context, params *protocol.HoverParams) (_ *pr defer release() switch snapshot.FileKind(fh) { - case file.Asm: - return goasm.Hover(ctx, snapshot, fh, params.Range) case file.Mod: return mod.Hover(ctx, snapshot, fh, params.Range) case file.Go: diff --git a/vendor/golang.org/x/tools/gopls/internal/server/references.go b/vendor/golang.org/x/tools/gopls/internal/server/references.go index 05eeb6e1fe..ac3efa1711 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/references.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/references.go @@ -8,7 +8,6 @@ import ( "context" "golang.org/x/tools/gopls/internal/file" - "golang.org/x/tools/gopls/internal/goasm" "golang.org/x/tools/gopls/internal/golang" "golang.org/x/tools/gopls/internal/label" "golang.org/x/tools/gopls/internal/mod" @@ -39,8 +38,6 @@ func (s *server) References(ctx context.Context, params *protocol.ReferenceParam return golang.References(ctx, snapshot, fh, params.Range, params.Context.IncludeDeclaration) case file.Mod: return mod.References(ctx, snapshot, fh, params) - case file.Asm: - return goasm.References(ctx, snapshot, fh, params.Position, params.Context.IncludeDeclaration) } return nil, nil // empty result } diff --git a/vendor/golang.org/x/tools/gopls/internal/server/vulncheck_prompt.go b/vendor/golang.org/x/tools/gopls/internal/server/vulncheck_prompt.go index cd71c73224..3c21a04c1e 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/vulncheck_prompt.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/vulncheck_prompt.go @@ -410,14 +410,14 @@ func parseVulnupgradeAction(s string) (vulnupgradeAction, bool) { // parseAction parses s against the list of allowed actions case-insensitively. // It returns the matching action and true if a match is found. -// Otherwise, it returns "" and false. +// Otherwise, it returns the zero value of T and false. func parseAction[T ~string](s string, actions []T) (T, bool) { for _, a := range actions { if strings.EqualFold(string(a), s) { return a, true } } - return "", false + return *new(T), false } func getVulncheckPreference() (vulncheckAction, error) { diff --git a/vendor/golang.org/x/tools/gopls/internal/server/workspace.go b/vendor/golang.org/x/tools/gopls/internal/server/workspace.go index 7e6a7dc842..66d682abfd 100644 --- a/vendor/golang.org/x/tools/gopls/internal/server/workspace.go +++ b/vendor/golang.org/x/tools/gopls/internal/server/workspace.go @@ -13,6 +13,7 @@ import ( "golang.org/x/tools/gopls/internal/cache" "golang.org/x/tools/gopls/internal/file" + "golang.org/x/tools/gopls/internal/filecache" "golang.org/x/tools/gopls/internal/golang/completion" "golang.org/x/tools/gopls/internal/protocol" "golang.org/x/tools/gopls/internal/settings" @@ -143,7 +144,9 @@ func (s *server) DidChangeConfiguration(ctx context.Context, _ *protocol.DidChan // An options change may have affected the detected Go version. s.checkViewGoVersions() - updateGlobalOptions(options) + if options.MaxFileCacheBytes > 0 { + filecache.SetBudget(options.MaxFileCacheBytes) + } return nil } diff --git a/vendor/golang.org/x/tools/gopls/internal/settings/analysis.go b/vendor/golang.org/x/tools/gopls/internal/settings/analysis.go index 326776bf75..247d7b70a8 100644 --- a/vendor/golang.org/x/tools/gopls/internal/settings/analysis.go +++ b/vendor/golang.org/x/tools/gopls/internal/settings/analysis.go @@ -14,8 +14,10 @@ import ( "golang.org/x/tools/go/analysis/passes/inline" "golang.org/x/tools/go/analysis/passes/modernize" "golang.org/x/tools/go/analysis/passes/nilness" + "golang.org/x/tools/go/analysis/passes/scannererr" "golang.org/x/tools/go/analysis/passes/shadow" "golang.org/x/tools/go/analysis/passes/sortslice" + "golang.org/x/tools/go/analysis/passes/sqlrowserr" "golang.org/x/tools/go/analysis/passes/unusedwrite" "golang.org/x/tools/go/analysis/suite/fix" "golang.org/x/tools/go/analysis/suite/vet" @@ -27,7 +29,6 @@ import ( "golang.org/x/tools/gopls/internal/analysis/maprange" "golang.org/x/tools/gopls/internal/analysis/nonewvars" "golang.org/x/tools/gopls/internal/analysis/noresultvalues" - "golang.org/x/tools/gopls/internal/analysis/ptrtoerror" "golang.org/x/tools/gopls/internal/analysis/recursiveiter" "golang.org/x/tools/gopls/internal/analysis/simplifycompositelit" "golang.org/x/tools/gopls/internal/analysis/simplifyrange" @@ -169,10 +170,11 @@ func initAnalyzers() (res []*Analyzer) { {analyzer: yield.Analyzer}, // uses go/ssa {analyzer: sortslice.Analyzer}, {analyzer: embeddirective.Analyzer}, + {analyzer: scannererr.Analyzer}, // to appear in cmd/vet@go1.28 + {analyzer: sqlrowserr.Analyzer}, // to appear in cmd/vet@go1.28 {analyzer: recursiveiter.Analyzer}, // under evaluation {analyzer: errorsastypeshadow.Analyzer}, // under evaluation {analyzer: writestring.Analyzer}, // under evaluation - {analyzer: ptrtoerror.Analyzer}, // under evaluation // disabled due to high false positives {analyzer: shadow.Analyzer, severity: protocol.SeverityHint, nonDefault: true}, // very noisy diff --git a/vendor/golang.org/x/tools/gopls/internal/settings/codeactionkind.go b/vendor/golang.org/x/tools/gopls/internal/settings/codeactionkind.go index ba62211110..dea15f9618 100644 --- a/vendor/golang.org/x/tools/gopls/internal/settings/codeactionkind.go +++ b/vendor/golang.org/x/tools/gopls/internal/settings/codeactionkind.go @@ -116,8 +116,7 @@ const ( RefactorExtractToNewFile protocol.CodeActionKind = "refactor.extract.toNewFile" // refactor.move - RefactorMoveType protocol.CodeActionKind = "refactor.move.moveType" - RefactorMoveDeclaration protocol.CodeActionKind = "refactor.move.moveDeclaration" + RefactorMoveType protocol.CodeActionKind = "refactor.move.moveType" // Note: add new kinds to: // - the SupportedCodeActions map in default.go diff --git a/vendor/golang.org/x/tools/gopls/internal/settings/default.go b/vendor/golang.org/x/tools/gopls/internal/settings/default.go index bb5cdf3405..fa9e44f5cf 100644 --- a/vendor/golang.org/x/tools/gopls/internal/settings/default.go +++ b/vendor/golang.org/x/tools/gopls/internal/settings/default.go @@ -30,105 +30,126 @@ func DefaultOptions(overrides ...func(*Options)) *Options { commands = append(commands, c.String()) } defaultOptions = &Options{ - InsertTextFormat: protocol.PlainTextTextFormat, - PreferredContentFormat: protocol.Markdown, - ConfigurationSupported: true, - DynamicConfigurationSupported: true, - DynamicRegistrationSemanticTokensSupported: true, - DynamicWatchedFilesSupported: true, - LineFoldingOnly: false, - HierarchicalDocumentSymbolSupport: true, - ImportsSource: ImportsSourceGopls, - SupportedCodeActions: map[file.Kind]map[protocol.CodeActionKind]bool{ - file.Go: { - // This should include specific leaves in the tree, - // (e.g. refactor.inline.call) not generic branches - // (e.g. refactor.inline or refactor). - protocol.SourceFixAll: true, - protocol.SourceOrganizeImports: true, - protocol.QuickFix: true, - GoAssembly: true, - GoDoc: true, - GoFreeSymbols: true, - GoSplitPackage: true, - GoplsDocFeatures: true, - RefactorRewriteChangeQuote: true, - RefactorRewriteFillStruct: true, - RefactorRewriteFillSwitch: true, - RefactorRewriteImplementInterface: true, - RefactorRewriteInvertIf: true, - RefactorRewriteJoinLines: true, - RefactorRewriteRemoveUnusedParam: true, - RefactorRewriteSplitLines: true, - RefactorInlineCall: true, - RefactorInlineVariable: true, - RefactorExtractConstant: true, - RefactorExtractConstantAll: true, - RefactorExtractFunction: true, - RefactorExtractMethod: true, - RefactorExtractVariable: true, - RefactorExtractVariableAll: true, - RefactorExtractToNewFile: true, - RefactorMoveType: true, // gated by MoveType setting, which is off by default - RefactorMoveDeclaration: true, // gated by MoveDeclaration setting, which is off by default - // Not GoTest: it must be explicit in CodeActionParams.Context.Only - }, - file.Mod: { - protocol.SourceOrganizeImports: true, - protocol.QuickFix: true, + ClientOptions: ClientOptions{ + InsertTextFormat: protocol.PlainTextTextFormat, + PreferredContentFormat: protocol.Markdown, + ConfigurationSupported: true, + DynamicConfigurationSupported: true, + DynamicRegistrationSemanticTokensSupported: true, + DynamicWatchedFilesSupported: true, + LineFoldingOnly: false, + HierarchicalDocumentSymbolSupport: true, + ImportsSource: ImportsSourceGopls, + }, + ServerOptions: ServerOptions{ + SupportedCodeActions: map[file.Kind]map[protocol.CodeActionKind]bool{ + file.Go: { + // This should include specific leaves in the tree, + // (e.g. refactor.inline.call) not generic branches + // (e.g. refactor.inline or refactor). + protocol.SourceFixAll: true, + protocol.SourceOrganizeImports: true, + protocol.QuickFix: true, + GoAssembly: true, + GoDoc: true, + GoFreeSymbols: true, + GoSplitPackage: true, + GoplsDocFeatures: true, + RefactorRewriteChangeQuote: true, + RefactorRewriteFillStruct: true, + RefactorRewriteFillSwitch: true, + RefactorRewriteImplementInterface: true, + RefactorRewriteInvertIf: true, + RefactorRewriteJoinLines: true, + RefactorRewriteRemoveUnusedParam: true, + RefactorRewriteSplitLines: true, + RefactorInlineCall: true, + RefactorInlineVariable: true, + RefactorExtractConstant: true, + RefactorExtractConstantAll: true, + RefactorExtractFunction: true, + RefactorExtractMethod: true, + RefactorExtractVariable: true, + RefactorExtractVariableAll: true, + RefactorExtractToNewFile: true, + RefactorMoveType: true, // gated by MoveType setting, which is off by default + // Not GoTest: it must be explicit in CodeActionParams.Context.Only + }, + file.Mod: { + protocol.SourceOrganizeImports: true, + protocol.QuickFix: true, + }, + file.Work: {}, + file.Sum: {}, + file.Tmpl: {}, }, - file.Work: {}, - file.Sum: {}, - file.Tmpl: {}, + SupportedCommands: commands, }, - SupportedCommands: commands, - ExpandWorkspaceToModule: true, - DirectoryFilters: []string{"-**/node_modules"}, - TemplateExtensions: []string{}, - StandaloneTags: []string{"ignore"}, - WorkspaceFiles: []string{}, - Annotations: map[Annotation]bool{ - Bounds: true, - Escape: true, - Inline: true, - Nil: true, + UserOptions: UserOptions{ + BuildOptions: BuildOptions{ + ExpandWorkspaceToModule: true, + DirectoryFilters: []string{"-**/node_modules"}, + TemplateExtensions: []string{}, + StandaloneTags: []string{"ignore"}, + WorkspaceFiles: []string{}, + }, + UIOptions: UIOptions{ + DiagnosticOptions: DiagnosticOptions{ + Annotations: map[Annotation]bool{ + Bounds: true, + Escape: true, + Inline: true, + Nil: true, + }, + Vulncheck: ModeVulncheckPrompt, + DiagnosticsDelay: 1 * time.Second, + DiagnosticsTrigger: DiagnosticsOnEdit, + AnalysisProgressReporting: true, + }, + InlayHintOptions: InlayHintOptions{ + Hints: map[InlayHint]bool{}, + }, + DocumentationOptions: DocumentationOptions{ + HoverKind: FullDocumentation, + LinkTarget: "pkg.go.dev", + LinksInHover: LinksInHover_LinkTarget, + }, + NavigationOptions: NavigationOptions{ + ImportShortcut: BothShortcuts, + SymbolMatcher: SymbolFastFuzzy, + SymbolStyle: DynamicSymbols, + SymbolScope: AllSymbolScope, + }, + CompletionOptions: CompletionOptions{ + Matcher: Fuzzy, + CompletionBudget: 100 * time.Millisecond, + ExperimentalPostfixCompletions: true, + CompleteFunctionCalls: true, + }, + Codelenses: map[CodeLensSource]bool{ + CodeLensGenerate: true, + CodeLensRegenerateCgo: true, + CodeLensTidy: true, + CodeLensUpgradeDependency: true, + CodeLensVendor: true, + CodeLensRunGovulncheck: true, + }, + NewGoFileHeader: true, + RenameMovesSubpackages: false, + }, + FileWatcher: FileWatcherOff, }, - Vulncheck: ModeVulncheckPrompt, - DiagnosticsDelay: 1 * time.Second, - DiagnosticsTrigger: DiagnosticsOnEdit, - AnalysisProgressReporting: true, - Hints: map[InlayHint]bool{}, - HoverKind: FullDocumentation, - LinkTarget: "pkg.go.dev", - LinksInHover: LinksInHover_LinkTarget, - ImportShortcut: BothShortcuts, - SymbolMatcher: SymbolFastFuzzy, - SymbolStyle: DynamicSymbols, - SymbolScope: AllSymbolScope, - Matcher: Fuzzy, - CompletionBudget: 100 * time.Millisecond, - ExperimentalPostfixCompletions: true, - CompleteFunctionCalls: true, - Codelenses: map[CodeLensSource]bool{ - CodeLensGenerate: true, - CodeLensRegenerateCgo: true, - CodeLensTidy: true, - CodeLensUpgradeDependency: true, - CodeLensVendor: true, - CodeLensRunGovulncheck: true, + InternalOptions: InternalOptions{ + CompleteUnimported: true, + CompletionDocumentation: true, + DeepCompletion: true, + SubdirWatchPatterns: SubdirWatchPatternsAuto, + ReportAnalysisProgressAfter: 5 * time.Second, + TelemetryPrompt: false, + LinkifyShowMessage: false, + IncludeReplaceInWorkspace: false, + ZeroConfig: true, }, - NewGoFileHeader: true, - RenameMovesSubpackages: false, - FileWatcher: FileWatcherOff, - CompleteUnimported: true, - CompletionDocumentation: true, - DeepCompletion: true, - SubdirWatchPatterns: SubdirWatchPatternsAuto, - ReportAnalysisProgressAfter: 5 * time.Second, - TelemetryPrompt: false, - LinkifyShowMessage: false, - IncludeReplaceInWorkspace: false, - ZeroConfig: true, } }) options := defaultOptions.Clone() diff --git a/vendor/golang.org/x/tools/gopls/internal/settings/settings.go b/vendor/golang.org/x/tools/gopls/internal/settings/settings.go index 987223a496..b0a6477391 100644 --- a/vendor/golang.org/x/tools/gopls/internal/settings/settings.go +++ b/vendor/golang.org/x/tools/gopls/internal/settings/settings.go @@ -274,10 +274,6 @@ type UIOptions struct { // MoveType enables producing Move Type codeactions. The implementation // is unfinished so we use this setting to gate its use. MoveType bool `status:"experimental"` - - // MoveDeclaration enables producing Move Declaration codeactions. The implementation - // is unfinished so we use this setting to gate its use. - MoveDeclaration bool `status:"experimental"` } // A CodeLensSource identifies an (algorithmic) source of code lenses. @@ -640,18 +636,10 @@ const ( // implicitly ignored. // // To suppress the hint, write an actual comment containing - // one of the following strings: - // ``` - // ignore error - // discard error - // can't fail - // cannot fail - // ``` - // following the call statement, or explicitly assign the - // result to a blank variable. - // - // A handful of common functions such as `fmt.Println` are - // excluded from the check. + // "ignore error" following the call statement, or explicitly + // assign the result to a blank variable. A handful of common + // functions such as `fmt.Println` are excluded from the + // check. IgnoredError InlayHint = "ignoredError" ) @@ -711,25 +699,6 @@ type UserOptions struct { // as measured by du(1) may be significantly higher. MaxFileCacheBytes int64 `status:"experimental"` - // MemoryLimit sets a soft memory limit (in bytes) for the gopls process, via - // runtime/debug.SetMemoryLimit. If non-positive (the default), no limit is set. - // - // On large workspaces, a single edit that invalidates many - // packages (for example a syntax error in a widely-imported - // package) can make the heap briefly grow well above the - // steady-state working set before the garbage collector - // catches up, spiking memory and, on memory-constrained - // machines, causing swapping. A soft limit makes the GC work - // harder to stay near the limit, trading some CPU for a lower - // memory peak. - // - // The limit is soft and may be exceeded. Set it comfortably above the - // steady-state working set, as too low a value causes excessive GC. - // - // Unlike the GOMEMLIMIT environment variable, this setting is - // strictly numeric; SI suffixes are not permitted. - MemoryLimit int64 `status:"experimental"` - // VerboseOutput enables additional debug logging. VerboseOutput bool `status:"debug"` } @@ -1367,9 +1336,6 @@ func (o *Options) setOne(name string, value any) (applied []CounterPath, _ error case "maxFileCacheBytes": return setInt64(&o.MaxFileCacheBytes, value) - case "memoryLimit": - return setInt64(&o.MemoryLimit, value) - case "verboseOutput": return setBool(&o.VerboseOutput, value) @@ -1482,9 +1448,6 @@ func (o *Options) setOne(name string, value any) (applied []CounterPath, _ error case "moveType": return setBool(&o.MoveType, value) - case "moveDeclaration": - return setBool(&o.MoveDeclaration, value) - // deprecated and renamed settings // // These should never be deleted: there is essentially no cost @@ -1576,30 +1539,18 @@ func (o *Options) setOne(name string, value any) (applied []CounterPath, _ error // EnabledSemanticTokenModifiers returns a map of modifiers to boolean. func (o *Options) EnabledSemanticTokenModifiers() map[semtok.Modifier]bool { - copy := make(map[semtok.Modifier]bool, len(o.SemanticMods)) - // Enable the modifiers defined in client capabilities - for _, m := range o.SemanticMods { - if enabled, found := o.SemanticTokenModifiers[m]; found && !enabled { - // If the client capabilities enables a semantic mod, but the - // user's UI settings disables it, keep it disabled. - continue - } - copy[semtok.Modifier(m)] = true + copy := make(map[semtok.Modifier]bool, len(o.SemanticTokenModifiers)) + for k, v := range o.SemanticTokenModifiers { + copy[semtok.Modifier(k)] = v } return copy } // EnabledSemanticTokenTypes returns a map of types to boolean. func (o *Options) EnabledSemanticTokenTypes() map[semtok.Type]bool { - copy := make(map[semtok.Type]bool, len(o.SemanticTypes)) - // Enable the tokens defined in client capabilities - for _, t := range o.SemanticTypes { - if enabled, found := o.SemanticTokenTypes[t]; found && !enabled { - // If the client capabilities enables a semantic type, but the - // user's UI settings disables it, keep it disabled. - continue - } - copy[semtok.Type(t)] = true + copy := make(map[semtok.Type]bool, len(o.SemanticTokenTypes)) + for k, v := range o.SemanticTokenTypes { + copy[semtok.Type(k)] = v } if o.NoSemanticString { copy[semtok.TokString] = false diff --git a/vendor/golang.org/x/tools/gopls/internal/template/implementations.go b/vendor/golang.org/x/tools/gopls/internal/template/implementations.go index e82f80b84e..1a01979fe3 100644 --- a/vendor/golang.org/x/tools/gopls/internal/template/implementations.go +++ b/vendor/golang.org/x/tools/gopls/internal/template/implementations.go @@ -224,7 +224,7 @@ func SemanticTokens(ctx context.Context, snapshot *cache.Snapshot, spn protocol. }) } return &protocol.SemanticTokens{ - Data: semtok.Encode(items, snapshot.Options().EnabledSemanticTokenTypes(), snapshot.Options().EnabledSemanticTokenModifiers()), + Data: semtok.Encode(items, nil, nil), // for small cache, some day. for now, the LSP client ignores this // (that is, when the LSP client starts returning these, we can cache) ResultID: fmt.Sprintf("%v", time.Now()), diff --git a/vendor/golang.org/x/tools/gopls/internal/tool/tool.go b/vendor/golang.org/x/tools/gopls/internal/tool/tool.go new file mode 100644 index 0000000000..70a6291b70 --- /dev/null +++ b/vendor/golang.org/x/tools/gopls/internal/tool/tool.go @@ -0,0 +1,297 @@ +// Copyright 2018 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 tool is a harness for writing Go tools. +package tool + +import ( + "context" + "flag" + "fmt" + "log" + "os" + "reflect" + "runtime" + "runtime/pprof" + "runtime/trace" + "strings" + "time" +) + +// This file is a harness for writing your main function. +// +// It adds a method to the Application type +// Main(name, usage string, args []string) +// which should normally be invoked from a true main as follows: +// func main() { +// (&Application{}).Main("myapp", "non-flag-command-line-arg-help", os.Args[1:]) +// } +// It recursively scans the application object for fields with a tag containing +// `flag:"flagnames" help:"short help text"` +// uses all those fields to build command line flags. It will split flagnames on +// commas and add a flag per name. +// It expects the Application type to have a method +// Run(context.Context, args...string) error +// which it invokes only after all command line flag processing has been finished. +// If Run returns an error, the error will be printed to stderr and the +// application will quit with a non zero exit status. + +// Profile can be embedded in your application struct to automatically +// add command line arguments and handling for the common profiling methods. +type Profile struct { + CPU string `flag:"profile.cpu" help:"write CPU profile to this file"` + Memory string `flag:"profile.mem" help:"write memory profile to this file"` + Alloc string `flag:"profile.alloc" help:"write alloc profile to this file"` + Trace string `flag:"profile.trace" help:"write trace log to this file"` + Block string `flag:"profile.block" help:"write block profile to this file"` +} + +// Application is the interface that must be satisfied by an object passed to Main. +type Application interface { + // Name returns the application's name. It is used in help and error messages. + Name() string + // Most of the help usage is automatically generated, this string should only + // describe the contents of non flag arguments. + Usage() string + // ShortHelp returns the one line overview of the command. + ShortHelp() string + // DetailedHelp should print a detailed help message. It will only ever be shown + // when the ShortHelp is also printed, so there is no need to duplicate + // anything from there. + // It is passed the flag set so it can print the default values of the flags. + // It should use the flag sets configured Output to write the help to. + DetailedHelp(*flag.FlagSet) + // Run is invoked after all flag processing, and inside the profiling and + // error handling harness. + Run(ctx context.Context, args ...string) error +} + +type SubCommand interface { + Parent() string +} + +// This is the type returned by CommandLineErrorf, which causes the outer main +// to trigger printing of the command line help. +type commandLineError string + +func (e commandLineError) Error() string { return string(e) } + +// CommandLineErrorf is like fmt.Errorf except that it returns a value that +// triggers printing of the command line help. +// In general you should use this when generating command line validation errors. +func CommandLineErrorf(message string, args ...any) error { + return commandLineError(fmt.Sprintf(message, args...)) +} + +// Main should be invoked directly by main function. +// It will only return if there was no error. If an error +// was encountered it is printed to standard error and the +// application exits with an exit code of 2. +func Main(ctx context.Context, app Application, args []string) { + s := flag.NewFlagSet(app.Name(), flag.ExitOnError) + if err := Run(ctx, s, app, args); err != nil { + fmt.Fprintf(s.Output(), "%s: %v\n", app.Name(), err) + if _, printHelp := err.(commandLineError); printHelp { + // TODO(adonovan): refine this. It causes + // any command-line error to result in the full + // usage message, which typically obscures + // the actual error. + s.Usage() + } + os.Exit(2) + } +} + +// Run is the inner loop for Main; invoked by Main, recursively by +// Run, and by various tests. It runs the application and returns an +// error. +func Run(ctx context.Context, s *flag.FlagSet, app Application, args []string) (resultErr error) { + s.Usage = func() { + if app.ShortHelp() != "" { + fmt.Fprintf(s.Output(), "%s\n\nUsage:\n ", app.ShortHelp()) + if sub, ok := app.(SubCommand); ok && sub.Parent() != "" { + fmt.Fprintf(s.Output(), "%s [flags] %s", sub.Parent(), app.Name()) + } else { + fmt.Fprintf(s.Output(), "%s [flags]", app.Name()) + } + if usage := app.Usage(); usage != "" { + fmt.Fprintf(s.Output(), " %s", usage) + } + fmt.Fprint(s.Output(), "\n") + } + app.DetailedHelp(s) + } + p := addFlags(s, reflect.StructField{}, reflect.ValueOf(app)) + if err := s.Parse(args); err != nil { + return err + } + + if p != nil && p.CPU != "" { + f, err := os.Create(p.CPU) + if err != nil { + return err + } + if err := pprof.StartCPUProfile(f); err != nil { + f.Close() // ignore error + return err + } + defer func() { + pprof.StopCPUProfile() + if closeErr := f.Close(); resultErr == nil { + resultErr = closeErr + } + }() + } + + if p != nil && p.Trace != "" { + f, err := os.Create(p.Trace) + if err != nil { + return err + } + if err := trace.Start(f); err != nil { + f.Close() // ignore error + return err + } + defer func() { + trace.Stop() + if closeErr := f.Close(); resultErr == nil { + resultErr = closeErr + } + log.Printf("To view the trace, run:\n$ go tool trace view %s", p.Trace) + }() + } + + if p != nil && p.Memory != "" { + f, err := os.Create(p.Memory) + if err != nil { + return err + } + defer func() { + runtime.GC() // get up-to-date statistics + if err := pprof.WriteHeapProfile(f); err != nil { + log.Printf("Writing memory profile: %v", err) + } + if err := f.Close(); err != nil { + log.Printf("Closing memory profile: %v", err) + } + }() + } + + if p != nil && p.Alloc != "" { + f, err := os.Create(p.Alloc) + if err != nil { + return err + } + defer func() { + if err := pprof.Lookup("allocs").WriteTo(f, 0); err != nil { + log.Printf("Writing alloc profile: %v", err) + } + if err := f.Close(); err != nil { + log.Printf("Closing alloc profile: %v", err) + } + }() + } + + if p != nil && p.Block != "" { + f, err := os.Create(p.Block) + if err != nil { + return err + } + runtime.SetBlockProfileRate(1) // record all blocking events + defer func() { + if err := pprof.Lookup("block").WriteTo(f, 0); err != nil { + log.Printf("Writing block profile: %v", err) + } + if err := f.Close(); err != nil { + log.Printf("Closing block profile: %v", err) + } + }() + } + + return app.Run(ctx, s.Args()...) +} + +// addFlags scans fields of structs recursively to find things with flag tags +// and add them to the flag set. +func addFlags(f *flag.FlagSet, field reflect.StructField, value reflect.Value) *Profile { + // is it a field we are allowed to reflect on? + if field.PkgPath != "" { + return nil + } + // now see if is actually a flag + flagNames, isFlag := field.Tag.Lookup("flag") + help := field.Tag.Get("help") + if isFlag { + nameList := strings.Split(flagNames, ",") + // add the main flag + addFlag(f, value, nameList[0], help) + if len(nameList) > 1 { + // and now add any aliases using the same flag value + fv := f.Lookup(nameList[0]).Value + for _, flagName := range nameList[1:] { + f.Var(fv, flagName, help) + } + } + return nil + } + // not a flag, but it might be a struct with flags in it + value = resolve(value.Elem()) + if value.Kind() != reflect.Struct { + return nil + } + + // TODO(adonovan): there's no need for this special treatment of Profile: + // The caller can use f.Lookup("profile.cpu") etc instead. + p, _ := value.Addr().Interface().(*Profile) + // go through all the fields of the struct + for i := 0; i < value.Type().NumField(); i++ { + child := value.Type().Field(i) + v := value.Field(i) + // make sure we have a pointer + if v.Kind() != reflect.Pointer { + v = v.Addr() + } + // check if that field is a flag or contains flags + if fp := addFlags(f, child, v); fp != nil { + p = fp + } + } + return p +} + +func addFlag(f *flag.FlagSet, value reflect.Value, flagName string, help string) { + switch v := value.Interface().(type) { + case flag.Value: + f.Var(v, flagName, help) + case *bool: + f.BoolVar(v, flagName, *v, help) + case *time.Duration: + f.DurationVar(v, flagName, *v, help) + case *float64: + f.Float64Var(v, flagName, *v, help) + case *int64: + f.Int64Var(v, flagName, *v, help) + case *int: + f.IntVar(v, flagName, *v, help) + case *string: + f.StringVar(v, flagName, *v, help) + case *uint: + f.UintVar(v, flagName, *v, help) + case *uint64: + f.Uint64Var(v, flagName, *v, help) + default: + log.Fatalf("field %q of type %T is not assignable to flag.Value", flagName, v) + } +} + +func resolve(v reflect.Value) reflect.Value { + for { + switch v.Kind() { + case reflect.Interface, reflect.Pointer: + v = v.Elem() + default: + return v + } + } +} diff --git a/vendor/golang.org/x/tools/gopls/internal/util/asm/parse.go b/vendor/golang.org/x/tools/gopls/internal/util/asm/parse.go index 3f0771d3c5..11c59a7cc3 100644 --- a/vendor/golang.org/x/tools/gopls/internal/util/asm/parse.go +++ b/vendor/golang.org/x/tools/gopls/internal/util/asm/parse.go @@ -6,13 +6,11 @@ package asm import ( + "bufio" "bytes" "fmt" - "sort" "strings" "unicode" - - "golang.org/x/tools/gopls/internal/protocol" ) // Kind describes the nature of an identifier in an assembly file. @@ -45,101 +43,33 @@ var kindString = [...]string{ // A file represents a parsed file of Go assembly language. type File struct { - // Idents holds the identifiers of the file, ordered by Offset; - // [File.IdentAt] relies on that order for its binary search. Idents []Ident - Mapper *protocol.Mapper - // TODO(adonovan): use token.File? This may be important in a // future in which analyzers can report diagnostics in .s files. } -// IdentRange returns the protocol.Range for the identifier in this file. -func (f *File) IdentRange(ident Ident) (protocol.Range, error) { - return f.Mapper.OffsetRange(ident.Offset, ident.Offset+ident.OrigLen) -} - -// IdentLocation returns a protocol Location for the identifier in this file. -func (f *File) IdentLocation(ident Ident) (protocol.Location, error) { - return f.Mapper.OffsetLocation(ident.Offset, ident.Offset+ident.OrigLen) -} - -// IdentAt returns the identifier containing the byte range [start, end), -// or nil if none. Because [File.Idents] are ordered by Offset, the -// lookup uses a binary search. -func (f *File) IdentAt(start, end int) *Ident { - // Find the last identifier whose Offset <= start. - idx := sort.Search(len(f.Idents), func(i int) bool { - return f.Idents[i].Offset > start - }) - if idx == 0 { - return nil - } - id := &f.Idents[idx-1] - if end <= id.End() { - return id - } - return nil -} - -// FunctionRange returns the byte range [start, end) of the TEXT function -// enclosing offset: start is the beginning of the line containing the -// enclosing TEXT directive, end is the beginning of the line containing -// the next TEXT directive, or len(content) if there is none. If offset -// precedes the first TEXT directive, the range covers from 0 to the -// first TEXT directive. -// -// TEXT directives are taken from the parsed file rather than re-detected -// here, so that scoping stays consistent with the identifiers the parser -// reports (e.g. a bare "TEXT" line with no symbol is not a boundary). -func (f *File) FunctionRange(offset int) (int, int) { - content := f.Mapper.Content - funcStart, funcEnd := 0, len(content) - for i := range f.Idents { - id := &f.Idents[i] - if id.Kind != Text { - continue - } - lineStart := id.Offset - for lineStart > 0 && content[lineStart-1] != '\n' { - lineStart-- - } - if lineStart > offset { - funcEnd = lineStart - break - } - funcStart = lineStart - } - return funcStart, funcEnd -} - // Ident represents an identifier in an assembly file. type Ident struct { - Name string // symbol name (after correcting [·∕]); Name[0]='.' => current package - Offset int // zero-based byte offset - OrigLen int // original length of the symbol name (before cleanup) - Kind Kind + Name string // symbol name (after correcting [·∕]); Name[0]='.' => current package + Offset int // zero-based byte offset + Kind Kind } // End returns the identifier's end offset. -func (id Ident) End() int { return id.Offset + id.OrigLen } +func (id Ident) End() int { return id.Offset + len(id.Name) } // Parse extracts identifiers from Go assembly files. // Since it is a best-effort parser, it never returns an error. -func Parse(uri protocol.DocumentURI, content []byte) *File { +func Parse(content []byte) *File { var idents []Ident - offset := 0 // byte offset of next raw line + offset := 0 // byte offset of start of current line // TODO(adonovan) use a proper tokenizer that respects // comments, string literals, line continuations, etc. - for rawLine := range bytes.SplitSeq(content, []byte("\n")) { - lineOffset := offset - offset += len(rawLine) - if offset < len(content) { - offset++ // skip '\n' - } - line := strings.TrimSuffix(string(rawLine), "\r") + scan := bufio.NewScanner(bytes.NewReader(content)) + for ; scan.Scan(); offset += len(scan.Bytes()) + len("\n") { + line := scan.Text() // Strip comments. if idx := strings.Index(line, "//"); idx >= 0 { @@ -156,10 +86,9 @@ func Parse(uri protocol.DocumentURI, content []byte) *File { label := strings.TrimSpace(line[:colon]) if isIdent(label) { idents = append(idents, Ident{ - Name: label, - Offset: lineOffset + strings.Index(line, label), - OrigLen: len(label), - Kind: Label, + Name: label, + Offset: offset + strings.Index(line, label), + Kind: Label, }) continue } @@ -193,10 +122,9 @@ func Parse(uri protocol.DocumentURI, content []byte) *File { if isIdent(sym) { // (The Index call assumes sym is not itself "TEXT" etc.) idents = append(idents, Ident{ - Name: cleanup(sym), - Kind: kind, - Offset: lineOffset + strings.Index(line, sym), - OrigLen: len(sym), + Name: cleanup(sym), + Kind: kind, + Offset: offset + strings.Index(line, sym), }) } continue @@ -254,16 +182,17 @@ func Parse(uri protocol.DocumentURI, content []byte) *File { sym = cutBefore(sym, "<") // "sym" =>> "sym" if isIdent(sym) { idents = append(idents, Ident{ - Name: cleanup(sym), - Kind: Ref, - Offset: lineOffset + tokenPos, - OrigLen: len(sym), + Name: cleanup(sym), + Kind: Ref, + Offset: offset + tokenPos, }) } } } - return &File{Idents: idents, Mapper: protocol.NewMapper(uri, content)} + _ = scan.Err() // ignore scan errors + + return &File{Idents: idents} } // isIdent reports whether s is a valid Go assembly identifier. diff --git a/vendor/golang.org/x/tools/gopls/internal/util/frob/frob.go b/vendor/golang.org/x/tools/gopls/internal/util/frob/frob.go index 9fe4bfe106..357198c077 100644 --- a/vendor/golang.org/x/tools/gopls/internal/util/frob/frob.go +++ b/vendor/golang.org/x/tools/gopls/internal/util/frob/frob.go @@ -106,7 +106,8 @@ func frobFor(t reflect.Type) *frob { fr.addElem(fr.t.Elem()) case reflect.Struct: - for field := range fr.t.Fields() { + for i := 0; i < fr.t.NumField(); i++ { + field := fr.t.Field(i) if field.PkgPath != "" { continue // skip unexported field } @@ -211,16 +212,11 @@ func (fr *frob) encode(out *writer, v reflect.Value) { len := v.Len() out.uint32(uint32(len)) if len > 0 { - n := 0 kfrob, vfrob := fr.elems[0], fr.elems[1] - for iter := v.MapRange(); iter.Next(); n++ { + for iter := v.MapRange(); iter.Next(); { kfrob.encode(out, iter.Key()) vfrob.encode(out, iter.Value()) } - if n != len { - // Better to be defensive than emit a malformed record. - panic("concurrent map modification") - } } case reflect.Pointer: diff --git a/vendor/golang.org/x/tools/gopls/internal/util/memoize/memoize.go b/vendor/golang.org/x/tools/gopls/internal/util/memoize/memoize.go index 9ec341abff..bacb1cee40 100644 --- a/vendor/golang.org/x/tools/gopls/internal/util/memoize/memoize.go +++ b/vendor/golang.org/x/tools/gopls/internal/util/memoize/memoize.go @@ -287,9 +287,9 @@ func (store *Store) Promise(key any, function Function) (*Promise, func()) { p.refcount++ store.promisesMu.Unlock() - var released atomic.Int32 + var released int32 release := func() { - if !released.CompareAndSwap(0, 1) { + if !atomic.CompareAndSwapInt32(&released, 0, 1) { panic("release called more than once") } store.promisesMu.Lock() diff --git a/vendor/golang.org/x/tools/gopls/internal/util/moremaps/maps.go b/vendor/golang.org/x/tools/gopls/internal/util/moremaps/maps.go new file mode 100644 index 0000000000..79ac2ce46d --- /dev/null +++ b/vendor/golang.org/x/tools/gopls/internal/util/moremaps/maps.go @@ -0,0 +1,91 @@ +// Copyright 2023 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 moremaps + +import ( + "cmp" + "iter" + "maps" + "slices" +) + +// Arbitrary returns an arbitrary (key, value) entry from the map and ok is true, if +// the map is not empty. Otherwise, it returns zero values for K and V, and false. +func Arbitrary[K comparable, V any](m map[K]V) (_ K, _ V, ok bool) { + for k, v := range m { + return k, v, true + } + return +} + +// Group returns a new non-nil map containing the elements of s grouped by the +// keys returned from the key func. +func Group[K comparable, V any](s []V, key func(V) K) map[K][]V { + m := make(map[K][]V) + for _, v := range s { + k := key(v) + m[k] = append(m[k], v) + } + return m +} + +// KeySlice returns the keys of the map M, like slices.Collect(maps.Keys(m)). +func KeySlice[M ~map[K]V, K comparable, V any](m M) []K { + r := make([]K, 0, len(m)) + for k := range m { + r = append(r, k) + } + return r +} + +// ValueSlice returns the values of the map M, like slices.Collect(maps.Values(m)). +func ValueSlice[M ~map[K]V, K comparable, V any](m M) []V { + r := make([]V, 0, len(m)) + for _, v := range m { + r = append(r, v) + } + return r +} + +// SameKeys reports whether x and y have equal sets of keys. +func SameKeys[K comparable, V1, V2 any](x map[K]V1, y map[K]V2) bool { + ignoreValues := func(V1, V2) bool { return true } + return maps.EqualFunc(x, y, ignoreValues) +} + +// Sorted returns an iterator over the entries of m in key order. +func Sorted[M ~map[K]V, K cmp.Ordered, V any](m M) iter.Seq2[K, V] { + // TODO(adonovan): use maps.Sorted if proposal #68598 is accepted. + return func(yield func(K, V) bool) { + keys := KeySlice(m) + slices.Sort(keys) + for _, k := range keys { + if !yield(k, m[k]) { + break + } + } + } +} + +// SortedFunc returns an iterator over the entries of m in the key order determined by cmp. +func SortedFunc[M ~map[K]V, K comparable, V any](m M, cmp func(x, y K) int) iter.Seq2[K, V] { + // TODO(adonovan): use maps.SortedFunc if proposal #68598 is accepted. + return func(yield func(K, V) bool) { + keys := KeySlice(m) + slices.SortFunc(keys, cmp) + for _, k := range keys { + if !yield(k, m[k]) { + break + } + } + } +} + +// Delete is like delete(m, k) but reports whether deletion occurred. +func Delete[M ~map[K]V, K comparable, V any](m M, k K) bool { + pre := len(m) + delete(m, k) + return pre != len(m) +} diff --git a/vendor/golang.org/x/tools/internal/moreslices/slices.go b/vendor/golang.org/x/tools/gopls/internal/util/moreslices/slices.go similarity index 91% rename from vendor/golang.org/x/tools/internal/moreslices/slices.go rename to vendor/golang.org/x/tools/gopls/internal/util/moreslices/slices.go index bee74d8f43..7658cd8b53 100644 --- a/vendor/golang.org/x/tools/internal/moreslices/slices.go +++ b/vendor/golang.org/x/tools/gopls/internal/util/moreslices/slices.go @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package moreslices contains more functions for working with slices. package moreslices // Remove removes all values equal to elem from slice. diff --git a/vendor/golang.org/x/tools/gopls/internal/util/morestrings/strings.go b/vendor/golang.org/x/tools/gopls/internal/util/morestrings/strings.go new file mode 100644 index 0000000000..5632006a40 --- /dev/null +++ b/vendor/golang.org/x/tools/gopls/internal/util/morestrings/strings.go @@ -0,0 +1,15 @@ +// Copyright 2025 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 morestrings + +import "strings" + +// CutLast is the "last" analogue of [strings.Cut]. +func CutLast(s, sep string) (before, after string, ok bool) { + if i := strings.LastIndex(s, sep); i >= 0 { + return s[:i], s[i+len(sep):], true + } + return s, "", false +} diff --git a/vendor/golang.org/x/tools/gopls/main.go b/vendor/golang.org/x/tools/gopls/main.go index 4343652f71..0a79d27b92 100644 --- a/vendor/golang.org/x/tools/gopls/main.go +++ b/vendor/golang.org/x/tools/gopls/main.go @@ -11,8 +11,15 @@ package main import ( + "context" + "log" + "os" + "golang.org/x/telemetry" + "golang.org/x/telemetry/counter" "golang.org/x/tools/gopls/internal/cmd" + "golang.org/x/tools/gopls/internal/filecache" + "golang.org/x/tools/gopls/internal/tool" versionpkg "golang.org/x/tools/gopls/internal/version" ) @@ -26,5 +33,24 @@ func main() { Upload: true, }) - cmd.Main() + // Force early creation of the filecache and refuse to start + // if there were unexpected errors such as ENOSPC. This + // minimizes the window of exposure to deletion of the + // executable, and ensures that all subsequent calls to + // filecache.Get cannot fail for these two reasons; + // see issue #67433. + // + // This leaves only one likely cause for later failures: + // deletion of the cache while gopls is running. If the + // problem continues, we could periodically stat the cache + // directory (for example at the start of every RPC) and + // either re-create it or just fail the RPC with an + // informative error and terminate the process. + if _, err := filecache.Get("nonesuch", [32]byte{}, filecache.Bytes); err != nil && err != filecache.ErrNotFound { + counter.Inc("gopls/nocache") + log.Fatalf("gopls cannot access its persistent index (disk full?): %v", err) + } + + ctx := context.Background() + tool.Main(ctx, cmd.New(), os.Args[1:]) } diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_server.go b/vendor/google.golang.org/grpc/internal/transport/http2_server.go index 63c6539a3d..82e13e64aa 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_server.go @@ -522,6 +522,12 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade delete(mdata, "host") } + // If :authority is still missing, i.e. no host or :authority header is + // present, reject the request as invalid. + if len(mdata[":authority"]) == 0 { + t.writeEarlyAbort(streamID, s.contentSubtype, status.New(codes.Internal, "no host or :authority header present"), http.StatusBadRequest, !frame.StreamEnded()) + return nil + } if frame.StreamEnded() { // s is just created by the caller. No lock needed. s.state = streamReadDone diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go index 64ec3b3cfd..835dc07fdc 100644 --- a/vendor/google.golang.org/grpc/version.go +++ b/vendor/google.golang.org/grpc/version.go @@ -19,4 +19,4 @@ package grpc // Version is the current grpc version. -const Version = "1.83.1" +const Version = "1.83.2" diff --git a/vendor/modules.txt b/vendor/modules.txt index ab4060a536..d50976732d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,14 +4,14 @@ # 4d63.com/gochecknoglobals v0.2.2 ## explicit; go 1.18 4d63.com/gochecknoglobals/checknoglobals -# charm.land/bubbles/v2 v2.1.1 +# charm.land/bubbles/v2 v2.2.1 ## explicit; go 1.25.0 charm.land/bubbles/v2/cursor charm.land/bubbles/v2/internal/runeutil charm.land/bubbles/v2/key charm.land/bubbles/v2/textinput charm.land/bubbles/v2/viewport -# charm.land/bubbletea/v2 v2.0.8 +# charm.land/bubbletea/v2 v2.0.9 ## explicit; go 1.25.0 charm.land/bubbletea/v2 # charm.land/lipgloss/v2 v2.0.6 @@ -497,6 +497,9 @@ github.com/gokrazy/updater # github.com/golangci/asciicheck v0.5.0 ## explicit; go 1.23.0 github.com/golangci/asciicheck +# github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6 +## explicit; go 1.25.0 +github.com/golangci/canonicalheader # github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 ## explicit; go 1.22.0 github.com/golangci/dupl/job @@ -512,7 +515,7 @@ github.com/golangci/go-printf-func-name/pkg/analyzer ## explicit; go 1.26.0 github.com/golangci/gofmt github.com/golangci/gofmt/internal -# github.com/golangci/golangci-lint/v2 v2.13.1 +# github.com/golangci/golangci-lint/v2 v2.13.2 ## explicit; go 1.26.0 github.com/golangci/golangci-lint/v2/cmd/golangci-lint github.com/golangci/golangci-lint/v2/internal/cache @@ -823,9 +826,6 @@ github.com/kulti/thelper/pkg/analyzer # github.com/kunwardeep/paralleltest v1.0.15 ## explicit; go 1.23.0 github.com/kunwardeep/paralleltest/pkg/paralleltest -# github.com/lasiar/canonicalheader v1.1.2 -## explicit; go 1.22.0 -github.com/lasiar/canonicalheader # github.com/ldez/exptostd v0.4.5 ## explicit; go 1.24.0 github.com/ldez/exptostd @@ -888,8 +888,8 @@ github.com/mattn/go-colorable # github.com/mattn/go-isatty v0.0.22 ## explicit; go 1.21 github.com/mattn/go-isatty -# github.com/mattn/go-runewidth v0.0.24 -## explicit; go 1.20 +# github.com/mattn/go-runewidth v0.0.27 +## explicit; go 1.23 github.com/mattn/go-runewidth # github.com/mdlayher/genetlink v1.4.0 ## explicit; go 1.25.0 @@ -917,8 +917,8 @@ github.com/mgechev/revive/internal/typeparams github.com/mgechev/revive/lint github.com/mgechev/revive/logging github.com/mgechev/revive/rule -# github.com/miekg/dns v1.1.72 -## explicit; go 1.24.0 +# github.com/miekg/dns v1.1.73 +## explicit; go 1.25.0 github.com/miekg/dns # github.com/mitchellh/go-homedir v1.1.0 ## explicit @@ -1031,11 +1031,11 @@ github.com/prometheus/client_model/go ## explicit; go 1.25.0 github.com/prometheus/common/expfmt github.com/prometheus/common/model -# github.com/prometheus/procfs v0.21.1 +# github.com/prometheus/procfs v0.22.0 ## explicit; go 1.25.0 github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs -github.com/prometheus/procfs/internal/util +github.com/prometheus/procfs/internal/parsers # github.com/quasilyte/go-ruleguard v0.4.5 ## explicit; go 1.22.0 github.com/quasilyte/go-ruleguard/internal/goenv @@ -1130,7 +1130,7 @@ github.com/segmentio/asm/keyset github.com/segmentio/encoding/ascii github.com/segmentio/encoding/iso8601 github.com/segmentio/encoding/json -# github.com/sirupsen/logrus v1.10.1 +# github.com/sirupsen/logrus v1.10.2 ## explicit; go 1.23 github.com/sirupsen/logrus # github.com/sivchari/containedctx v1.0.3 @@ -1236,8 +1236,8 @@ github.com/ultraware/whitespace # github.com/uudashr/gocognit v1.2.1 ## explicit; go 1.24.0 github.com/uudashr/gocognit -# github.com/uudashr/iface v1.5.0 -## explicit; go 1.23.0 +# github.com/uudashr/iface v1.5.1 +## explicit; go 1.25.0 github.com/uudashr/iface/identical github.com/uudashr/iface/internal/directive github.com/uudashr/iface/opaque @@ -1563,7 +1563,6 @@ golang.org/x/tools/internal/jsonrpc2_v2 golang.org/x/tools/internal/modindex golang.org/x/tools/internal/moreiters golang.org/x/tools/internal/moremaps -golang.org/x/tools/internal/moreslices golang.org/x/tools/internal/packagepath golang.org/x/tools/internal/packagesinternal golang.org/x/tools/internal/pkgbits @@ -1576,8 +1575,8 @@ golang.org/x/tools/internal/typesinternal golang.org/x/tools/internal/typesinternal/typeindex golang.org/x/tools/internal/versions golang.org/x/tools/refactor/satisfy -# golang.org/x/tools/gopls v0.0.0-20260827201838-8471f958f05f -## explicit; go 1.27.0 +# golang.org/x/tools/gopls v0.23.0 +## explicit; go 1.26.0 golang.org/x/tools/gopls golang.org/x/tools/gopls/internal/analysis/deprecated golang.org/x/tools/gopls/internal/analysis/embeddirective @@ -1589,7 +1588,6 @@ golang.org/x/tools/gopls/internal/analysis/infertypeargs golang.org/x/tools/gopls/internal/analysis/maprange golang.org/x/tools/gopls/internal/analysis/nonewvars golang.org/x/tools/gopls/internal/analysis/noresultvalues -golang.org/x/tools/gopls/internal/analysis/ptrtoerror golang.org/x/tools/gopls/internal/analysis/recursiveiter golang.org/x/tools/gopls/internal/analysis/simplifycompositelit golang.org/x/tools/gopls/internal/analysis/simplifyrange @@ -1636,6 +1634,7 @@ golang.org/x/tools/gopls/internal/settings golang.org/x/tools/gopls/internal/telemetry golang.org/x/tools/gopls/internal/template golang.org/x/tools/gopls/internal/test/integration/fake/glob +golang.org/x/tools/gopls/internal/tool golang.org/x/tools/gopls/internal/util/asm golang.org/x/tools/gopls/internal/util/browser golang.org/x/tools/gopls/internal/util/bug @@ -1648,6 +1647,9 @@ golang.org/x/tools/gopls/internal/util/goversion golang.org/x/tools/gopls/internal/util/immutable golang.org/x/tools/gopls/internal/util/lru golang.org/x/tools/gopls/internal/util/memoize +golang.org/x/tools/gopls/internal/util/moremaps +golang.org/x/tools/gopls/internal/util/moreslices +golang.org/x/tools/gopls/internal/util/morestrings golang.org/x/tools/gopls/internal/util/pathutil golang.org/x/tools/gopls/internal/util/persistent golang.org/x/tools/gopls/internal/util/safetoken @@ -1660,7 +1662,7 @@ golang.org/x/tools/gopls/internal/vulncheck/osv golang.org/x/tools/gopls/internal/vulncheck/scan golang.org/x/tools/gopls/internal/vulncheck/semver golang.org/x/tools/gopls/internal/work -# golang.org/x/vuln v1.6.0 +# golang.org/x/vuln v1.7.0 ## explicit; go 1.25.0 golang.org/x/vuln/cmd/govulncheck golang.org/x/vuln/internal @@ -1699,7 +1701,7 @@ golang.zx2c4.com/wireguard/wgctrl/wgtypes # google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 ## explicit; go 1.25.0 google.golang.org/genproto/googleapis/rpc/status -# google.golang.org/grpc v1.83.1 +# google.golang.org/grpc v1.83.2 ## explicit; go 1.25.0 google.golang.org/grpc google.golang.org/grpc/attributes @@ -2052,8 +2054,8 @@ mvdan.cc/gofumpt/internal/govendor/go/doc/comment mvdan.cc/gofumpt/internal/govendor/go/format mvdan.cc/gofumpt/internal/govendor/go/printer mvdan.cc/gofumpt/internal/version -# mvdan.cc/unparam v0.0.0-20260818115549-3f964bcb5673 -## explicit; go 1.25.0 +# mvdan.cc/unparam v0.0.0-20260823230713-2fa3d841b0c8 +## explicit; go 1.26.0 mvdan.cc/unparam/check # mvdan.cc/xurls/v2 v2.6.0 ## explicit; go 1.22.0 diff --git a/vendor/mvdan.cc/unparam/check/check.go b/vendor/mvdan.cc/unparam/check/check.go index 6bd6fdb6ed..8015b78ae1 100644 --- a/vendor/mvdan.cc/unparam/check/check.go +++ b/vendor/mvdan.cc/unparam/check/check.go @@ -650,8 +650,6 @@ resLoop: c.addIssue(fn, res.Pos(), "result %s is never used", name) } - fnIsGeneric := fn.TypeParams().Len() > 0 - for i, par := range fn.Params { if paramsBy != "" { continue // we can't change the params @@ -666,13 +664,9 @@ resLoop: } t := par.Type() // asking for the size of a type param would panic, as it is unknowable - if !fnIsGeneric || !containsTypeParam(t) { - if stdSizes.Sizeof(par.Type()) == 0 { - c.debug(" skip - zero size\n") - continue - } - } else { - c.debug(" examine - type parameter\n") + if !containsTypeParam(t) && stdSizes.Sizeof(t) == 0 { + c.debug(" skip - zero size\n") + continue } reason := "is unused" constStr := c.alwaysReceivedConst(callSites, par, i) @@ -686,6 +680,9 @@ resLoop: } } +// containsTypeParam reports whether computing the size of t requires knowing +// the size of a type parameter. It only follows the types that [types.Sizes] +// descends into; the rest have a fixed size. func containsTypeParam(t types.Type) bool { switch t := types.Unalias(t).(type) { case *types.TypeParam, *types.Union: @@ -700,12 +697,7 @@ func containsTypeParam(t types.Type) bool { case *types.Array: return containsTypeParam(t.Elem()) case *types.Named: - args := t.TypeArgs() - for t0 := range args.Types() { - if containsTypeParam(t0) { - return true - } - } + return containsTypeParam(t.Underlying()) } return false }