Skip to content

Commit

Permalink
Merge branch 'main' into feat/format-comment-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hirasawayuki authored Oct 25, 2024
2 parents f2b2019 + d5bf43c commit 18a54b8
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 33 deletions.
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ go 1.22.0
toolchain go1.23.2

require (
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.34.2-20240928190436-5e8abcfd7a7e.2
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240920164238-5a7b106cbb87.2
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.35.1-20241023225133-42bdb4b67625.1
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241007185750-f2282fe532fe.1
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20241007185750-f2282fe532fe.2
buf.build/go/bufplugin v0.5.0
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241007185750-f2282fe532fe.1
buf.build/go/bufplugin v0.6.0
buf.build/go/protoyaml v0.2.0
buf.build/go/spdx v0.2.0
connectrpc.com/connect v1.17.0
connectrpc.com/otelconnect v0.7.1
github.com/bufbuild/protocompile v0.14.1
github.com/bufbuild/protoplugin v0.0.0-20240911180120-7bb73e41a54a
github.com/bufbuild/protovalidate-go v0.7.2
github.com/bufbuild/protovalidate-go v0.7.3-0.20241015162221-1446f1e1d576
github.com/docker/docker v27.3.1+incompatible
github.com/go-chi/chi/v5 v5.1.0
github.com/gofrs/flock v0.12.1
Expand All @@ -41,15 +41,15 @@ require (
go.uber.org/atomic v1.11.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
go.uber.org/zap/exp v0.1.1-0.20240913022758-ede8e1888f83
go.uber.org/zap/exp v0.3.0
golang.org/x/crypto v0.28.0
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
golang.org/x/mod v0.21.0
golang.org/x/net v0.30.0
golang.org/x/sync v0.8.0
golang.org/x/term v0.25.0
golang.org/x/tools v0.26.0
google.golang.org/protobuf v1.34.3-0.20240906163944-03df6c145d96
google.golang.org/protobuf v1.35.1
gopkg.in/yaml.v3 v3.0.1
pluginrpc.com/pluginrpc v0.5.0
)
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.34.2-20240928190436-5e8abcfd7a7e.2 h1:BQVQ0fcYgqpe6F/2ZPJUR1rTN+nwdrj2z7IAbAu9XAQ=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.34.2-20240928190436-5e8abcfd7a7e.2/go.mod h1:B+9TKHRYqoAUW57pLjhkLOnBCu0DQYMV+f7imQ9nXwI=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240920164238-5a7b106cbb87.2 h1:hl0FrmGlNpQZIGvU1/jDz0lsPDd0BhCE0QDRwPfLZcA=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240920164238-5a7b106cbb87.2/go.mod h1:ylS4c28ACSI59oJrOdW4pHS4n0Hw4TgSPHn8rpHl4Yw=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.35.1-20241023225133-42bdb4b67625.1 h1:O31Hu5Oho5suEWOD7FuMU9vfzeQT07ukTu4YuBVjLbw=
buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.35.1-20241023225133-42bdb4b67625.1/go.mod h1:rYPnjsUZ2lGpoQ/T322HWZQil9/MIZF2njP+/u/0GKg=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1 h1:9wP6ZZYWnF2Z0TxmII7m3XNykxnP4/w8oXeth6ekcRI=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1/go.mod h1:Duw/9JoXkXIydyASnLYIiufkzySThoqavOsF+IihqvM=
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241007185750-f2282fe532fe.1 h1:tVBsEQVsOz3Xsoy90GOefAgn6siKtfFZxsst39/hJNU=
buf.build/gen/go/bufbuild/registry/connectrpc/go v1.17.0-20241007185750-f2282fe532fe.1/go.mod h1:of6bEOQJUQbBMVsPiLQiyD+yPRze0FClQv2u1CmgDdQ=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20241007185750-f2282fe532fe.2 h1:B9EMC8wt++YwOuvFnn12zqlfj7ceJoiUHYfCaAj3IIc=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20241007185750-f2282fe532fe.2/go.mod h1:psseUmlKRo9v5LZJtR/aTpdTLuyp9o3X7rnLT87SZEo=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241007185750-f2282fe532fe.1 h1:jvB3uNDZnP89xIFy8WHeYgCz86vv7mWRyv2Wgp+8hoI=
buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.35.1-20241007185750-f2282fe532fe.1/go.mod h1:wDNiJdkMLOTfEL3o1lBgh+9EVhwGORcz+Aoq6hGk33Y=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.34.2-20241007202033-cf42259fcbfc.2 h1:QPJpr4Jtj5AN+LXVz+r+pT8dvPkznkRPotxYSN4zXYE=
buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.34.2-20241007202033-cf42259fcbfc.2/go.mod h1:GjH0gjlY/ns16X8d6eaXV2W+6IFwsO5Ly9WVnzyd1E0=
buf.build/go/bufplugin v0.5.0 h1:pmK1AloAMp+4woH5hEisK9qVmDdLySzIKexUUVZLJ2Q=
buf.build/go/bufplugin v0.5.0/go.mod h1:r7Y8tpqpErLtUXUecEgwAHnjihY03YbN0IaBFNJF/x0=
buf.build/go/bufplugin v0.6.0 h1:3lhoh+0z+IUPS3ZajTPn/27LaLIkero2BDVnV7yXD1s=
buf.build/go/bufplugin v0.6.0/go.mod h1:hWCjxxv24xdR6F5pNlQavZV2oo0J3uF4Ff1XEoyV6vU=
buf.build/go/protoyaml v0.2.0 h1:2g3OHjtLDqXBREIOjpZGHmQ+U/4mkN1YiQjxNB68Ip8=
buf.build/go/protoyaml v0.2.0/go.mod h1:L/9QvTDkTWcDTzAL6HMfN+mYC6CmZRm2KnsUA054iL0=
buf.build/go/spdx v0.2.0 h1:IItqM0/cMxvFJJumcBuP8NrsIzMs/UYjp/6WSpq8LTw=
Expand All @@ -34,8 +34,8 @@ github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
github.com/bufbuild/protoplugin v0.0.0-20240911180120-7bb73e41a54a h1:l3RhVoG0RtC61h6TVWnkniGj4TgBebuyPQRdleFAmTg=
github.com/bufbuild/protoplugin v0.0.0-20240911180120-7bb73e41a54a/go.mod h1:c5D8gWRIZ2HLWO3gXYTtUfw/hbJyD8xikv2ooPxnklQ=
github.com/bufbuild/protovalidate-go v0.7.2 h1:UuvKyZHl5p7u3ztEjtRtqtDxOjRKX5VUOgKFq6p6ETk=
github.com/bufbuild/protovalidate-go v0.7.2/go.mod h1:PHV5pFuWlRzdDW02/cmVyNzdiQ+RNNwo7idGxdzS7o4=
github.com/bufbuild/protovalidate-go v0.7.3-0.20241015162221-1446f1e1d576 h1:A4TfjZJqApnAvGKDgxHqA1rG6BK1OswyNcTcnSrDbJc=
github.com/bufbuild/protovalidate-go v0.7.3-0.20241015162221-1446f1e1d576/go.mod h1:R/UFeIPyFAh0eH7Ic/JJbO2ABdkxFuZZKDbzsI5UiwM=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -296,8 +296,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.uber.org/zap/exp v0.1.1-0.20240913022758-ede8e1888f83 h1:wpjRiPjppWaUIH+GC0bRvsdaH2K4Dw49dEJa7MX01Mk=
go.uber.org/zap/exp v0.1.1-0.20240913022758-ede8e1888f83/go.mod h1:5I384qq7XGxYyByIhHm6jg5CHkGY0nsTfbDLgDDlgJQ=
go.uber.org/zap/exp v0.3.0 h1:6JYzdifzYkGmTdRR59oYH+Ng7k49H9qVpWwNSsGJj3U=
go.uber.org/zap/exp v0.3.0/go.mod h1:5I384qq7XGxYyByIhHm6jg5CHkGY0nsTfbDLgDDlgJQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
Expand Down Expand Up @@ -391,8 +391,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.34.3-0.20240906163944-03df6c145d96 h1:gqpvySYmKe3qf25lfA3WIEMTXBU+lfISbNkPH2BA844=
google.golang.org/protobuf v1.34.3-0.20240906163944-03df6c145d96/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
28 changes: 25 additions & 3 deletions private/buf/buflsp/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ func (f *file) Close(ctx context.Context) {
f.lsp.fileManager.Close(ctx, f.uri)
}

// IsOpenInEditor returns whether this file was opened in the LSP client's
// editor.
//
// Some files may be opened as dependencies, so we want to avoid doing extra
// work like sending progress notifications.
func (f *file) IsOpenInEditor() bool {
return f.version != -1 // See [file.ReadFromDisk].
}

// ReadFromDisk reads this file from disk if it has never had data loaded into it before.
//
// If it has been read from disk before, or has received updates from the LSP client, this
Expand Down Expand Up @@ -165,7 +174,12 @@ func (f *file) Update(ctx context.Context, version int32, text string) {
//
// If deep is set, this will also load imports and refresh those, too.
func (f *file) Refresh(ctx context.Context) {
progress := newProgress(f.lsp)
var progress *progress
if f.IsOpenInEditor() {
// NOTE: Nil progress does nothing when methods are called. This helps
// minimize RPC spam from the client when indexing lots of files.
progress = newProgress(f.lsp)
}
progress.Begin(ctx, "Indexing")

progress.Report(ctx, "Parsing AST", 1.0/6)
Expand Down Expand Up @@ -232,6 +246,14 @@ func (f *file) RefreshAST(ctx context.Context) bool {

// PublishDiagnostics publishes all of this file's diagnostics to the LSP client.
func (f *file) PublishDiagnostics(ctx context.Context) {
if !f.IsOpenInEditor() {
// If the file does get opened by the editor, the server will call
// Refresh() and this function will retry sending diagnostics. Which is
// to say: returning here does not result in stale diagnostics on the
// client.
return
}

defer slogext.DebugProfile(f.lsp.logger, slog.String("uri", string(f.uri)))()

// NOTE: We need to avoid sending a JSON null here, so we replace it with
Expand Down Expand Up @@ -605,7 +627,8 @@ func (f *file) IndexSymbols(ctx context.Context) {
defer slogext.DebugProfile(f.lsp.logger, slog.String("uri", string(f.uri)))()

// Throw away all the old symbols. Unlike other indexing functions, we rebuild
// symbols unconditionally.
// symbols unconditionally. This is because if this file depends on a file
// that has since been modified, we may need to update references.
f.symbols = nil

// Generate new symbols.
Expand All @@ -622,7 +645,6 @@ func (f *file) IndexSymbols(ctx context.Context) {
return diff
})

// Now we can drop the lock and search for cross-file references.
symbols := f.symbols
for _, symbol := range symbols {
symbol.ResolveCrossFile(ctx)
Expand Down
11 changes: 11 additions & 0 deletions private/buf/buflsp/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func newProgressFromClient(lsp *lsp, params *protocol.WorkDoneProgressParams) *p
}
}

// Begin informs the client that this progress has begun. Must be called before
// Report or Done are called.
//
// If p is nil, does nothing.
func (p *progress) Begin(ctx context.Context, title string) {
if p == nil {
return
Expand All @@ -69,6 +73,9 @@ func (p *progress) Begin(ctx context.Context, title string) {
})
}

// Report updates the progress on the client.
//
// If p is nil, does nothing.
func (p *progress) Report(ctx context.Context, message string, percent float64) {
if p == nil {
return
Expand All @@ -85,6 +92,10 @@ func (p *progress) Report(ctx context.Context, message string, percent float64)
})
}

// Done completes the progress on the client, informing the client that it can
// stop showing a progress bar.
//
// If p is nil, does nothing.
func (p *progress) Done(ctx context.Context) {
if p == nil {
return
Expand Down
5 changes: 0 additions & 5 deletions private/buf/buflsp/symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ func (s *symbol) ResolveCrossFile(ctx context.Context) {
return
}

// Fully index the file this reference is in, if different from the current.
if s.file != ref.file {
ref.file.Refresh(ctx)
}

// Find the definition that contains the type we want.
def, node := kind.seeTypeOf.Definition(ctx)
if def == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func inner(
}
// We don't want to use the default error from wrapError here if the error
// an unauthenticated error.
return errors.New("invalid token provided")
return fmt.Errorf("invalid token provided for %s", remote)
}
user := resp.Msg.User
if user == nil {
Expand Down
1 change: 0 additions & 1 deletion private/bufpkg/bufcobra/bufcobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func run(
if err != nil {
return err
}

excludes := slicesext.ToStructMap(config.ExcludeCommands)
for _, command := range cobraCommand.Commands() {
if _, ok := excludes[command.CommandPath()]; ok {
Expand Down
4 changes: 2 additions & 2 deletions private/bufpkg/bufcobra/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ type config struct {
}

func readConfigFromFile(path string) (*config, error) {
var webpagesConfig config
if path == "" {
return nil, nil
return &webpagesConfig, nil
}
file, err := os.Open(path)
if err != nil {
Expand All @@ -57,7 +58,6 @@ func readConfigFromFile(path string) (*config, error) {
if err != nil {
return nil, err
}
var webpagesConfig config
if err := yaml.Unmarshal(data, &webpagesConfig); err != nil {
return nil, err
}
Expand Down

0 comments on commit 18a54b8

Please sign in to comment.