Skip to content

Commit 6fe2e10

Browse files
Remove progress notifications (#4129)
After removing breaking checks in #4109, we should have no operations that are not effectively instantaneous: all of looking up definitions, symbols, and processing semantic tokens should take trivial amounts of time. We should skip reporting progress to simplify the code.
1 parent 9707c25 commit 6fe2e10

File tree

2 files changed

+7
-133
lines changed

2 files changed

+7
-133
lines changed

private/buf/buflsp/progress.go

Lines changed: 0 additions & 100 deletions
This file was deleted.

private/buf/buflsp/server.go

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ func (s *server) Initialize(
102102
TokenModifiers []string `json:"tokenModifiers"`
103103
}
104104
type SemanticTokensOptions struct {
105-
protocol.WorkDoneProgressOptions
106-
107105
Legend SemanticTokensLegend `json:"legend"`
108106
Full bool `json:"full"`
109107
}
@@ -126,19 +124,12 @@ func (s *server) Initialize(
126124
ResolveProvider: true,
127125
TriggerCharacters: []string{" ", ".", "(", "\"", "/"},
128126
},
129-
DefinitionProvider: &protocol.DefinitionOptions{
130-
WorkDoneProgressOptions: protocol.WorkDoneProgressOptions{WorkDoneProgress: true},
131-
},
132-
TypeDefinitionProvider: &protocol.TypeDefinitionOptions{
133-
WorkDoneProgressOptions: protocol.WorkDoneProgressOptions{WorkDoneProgress: true},
134-
},
127+
DefinitionProvider: &protocol.DefinitionOptions{},
128+
TypeDefinitionProvider: &protocol.TypeDefinitionOptions{},
135129
DocumentFormattingProvider: true,
136130
HoverProvider: true,
137-
ReferencesProvider: &protocol.ReferenceOptions{
138-
WorkDoneProgressOptions: protocol.WorkDoneProgressOptions{WorkDoneProgress: true},
139-
},
131+
ReferencesProvider: &protocol.ReferenceOptions{},
140132
SemanticTokensProvider: &SemanticTokensOptions{
141-
WorkDoneProgressOptions: protocol.WorkDoneProgressOptions{WorkDoneProgress: true},
142133
Legend: SemanticTokensLegend{
143134
TokenTypes: semanticTypeLegend,
144135
TokenModifiers: semanticModifierLegend,
@@ -356,34 +347,25 @@ func (s *server) Definition(
356347
ctx context.Context,
357348
params *protocol.DefinitionParams,
358349
) ([]protocol.Location, error) {
359-
return s.definition(ctx, params.TextDocument.URI, &params.WorkDoneProgressParams, params.Position)
350+
return s.definition(ctx, params.TextDocument.URI, params.Position)
360351
}
361352

362353
// TypeDefinition is the entry point for go-to-type-definition.
363354
func (s *server) TypeDefinition(
364355
ctx context.Context,
365356
params *protocol.TypeDefinitionParams,
366357
) ([]protocol.Location, error) {
367-
return s.definition(ctx, params.TextDocument.URI, &params.WorkDoneProgressParams, params.Position)
358+
return s.definition(ctx, params.TextDocument.URI, params.Position)
368359
}
369360

370361
// definition powers [server.Definition] and [server.TypeDefinition], as they are not meaningfully
371362
// different in protobuf, but users may be used to using either.
372-
func (s *server) definition(
373-
ctx context.Context,
374-
uri protocol.URI,
375-
workDoneProgressParams *protocol.WorkDoneProgressParams,
376-
position protocol.Position,
377-
) ([]protocol.Location, error) {
363+
func (s *server) definition(ctx context.Context, uri protocol.URI, position protocol.Position) ([]protocol.Location, error) {
378364
file := s.fileManager.Get(uri)
379365
if file == nil {
380366
return nil, nil
381367
}
382368

383-
progress := newProgressFromClient(s.lsp, workDoneProgressParams)
384-
progress.Begin(ctx, "Searching")
385-
defer progress.Done(ctx)
386-
387369
symbol := file.SymbolAt(ctx, position)
388370
if symbol == nil {
389371
return nil, nil
@@ -403,10 +385,6 @@ func (s *server) References(
403385
if file == nil {
404386
return nil, nil
405387
}
406-
progress := newProgressFromClient(s.lsp, &params.WorkDoneProgressParams)
407-
progress.Begin(ctx, "Searching")
408-
defer progress.Done(ctx)
409-
410388
symbol := file.SymbolAt(ctx, params.Position)
411389
if symbol == nil {
412390
return nil, nil
@@ -449,9 +427,6 @@ func (s *server) SemanticTokensFull(
449427
if file == nil {
450428
return nil, nil
451429
}
452-
progress := newProgressFromClient(s.lsp, &params.WorkDoneProgressParams)
453-
progress.Begin(ctx, "Processing Tokens")
454-
defer progress.Done(ctx)
455430
// In the case where there are no symbols for the file, we return nil for SemanticTokensFull.
456431
// This is based on the specification for the method textDocument/semanticTokens/full,
457432
// the expected response is the union type `SemanticTokens | null`.
@@ -465,8 +440,7 @@ func (s *server) SemanticTokensFull(
465440
encoded []uint32
466441
prevLine, prevCol uint32
467442
)
468-
for i, symbol := range file.symbols {
469-
progress.Report(ctx, fmt.Sprintf("%d/%d", i+1, len(file.symbols)), float64(i)/float64(len(file.symbols)))
443+
for _, symbol := range file.symbols {
470444
var semanticType uint32
471445
if symbol.isOption {
472446
semanticType = semanticTypeDecorator

0 commit comments

Comments
 (0)