package progress
import "golang.org/x/tools/internal/lsp/progress"
Index ¶
- type EventWriter
- func NewEventWriter(ctx context.Context, operation string) *EventWriter
- func (ew *EventWriter) Write(p []byte) (n int, err error)
- type Tracker
- func NewTracker(client protocol.Client) *Tracker
- func (t *Tracker) Cancel(ctx context.Context, token protocol.ProgressToken) error
- func (tracker *Tracker) SetSupportsWorkDoneProgress(b bool)
- func (t *Tracker) Start(ctx context.Context, title, message string, token protocol.ProgressToken, cancel func()) *WorkDone
- type WorkDone
- func (wd *WorkDone) End(message string)
- func (wd *WorkDone) Report(message string, percentage float64)
- func (wd *WorkDone) Token() protocol.ProgressToken
- type WorkDoneWriter
Types ¶
type EventWriter ¶
type EventWriter struct {
// contains filtered or unexported fields
}
EventWriter writes every incoming []byte to event.Print with the operation=generate tag to distinguish its logs from others.
func NewEventWriter ¶
func NewEventWriter(ctx context.Context, operation string) *EventWriter
func (*EventWriter) Write ¶
func (ew *EventWriter) Write(p []byte) (n int, err error)
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
func NewTracker ¶
func (*Tracker) Cancel ¶
func (*Tracker) SetSupportsWorkDoneProgress ¶
func (*Tracker) Start ¶
func (t *Tracker) Start(ctx context.Context, title, message string, token protocol.ProgressToken, cancel func()) *WorkDone
Start notifies the client of work being done on the server. It uses either ShowMessage RPCs or $/progress messages, depending on the capabilities of the client. The returned WorkDone handle may be used to report incremental progress, and to report work completion. In particular, it is an error to call start and not call end(...) on the returned WorkDone handle.
If token is empty, a token will be randomly generated.
The progress item is considered cancellable if the given cancel func is non-nil. In this case, cancel is called when the work done
Example:
func Generate(ctx) (err error) { ctx, cancel := context.WithCancel(ctx) defer cancel() work := s.progress.start(ctx, "generate", "running go generate", cancel) defer func() { if err != nil { work.end(ctx, fmt.Sprintf("generate failed: %v", err)) } else { work.end(ctx, "done") } }() // Do the work... }
type WorkDone ¶
type WorkDone struct {
// contains filtered or unexported fields
}
WorkDone represents a unit of work that is reported to the client via the progress API.
func (*WorkDone) End ¶
end reports a workdone completion back to the client.
func (*WorkDone) Report ¶
report reports an update on WorkDone report back to the client.
func (*WorkDone) Token ¶
func (wd *WorkDone) Token() protocol.ProgressToken
type WorkDoneWriter ¶
type WorkDoneWriter struct {
// contains filtered or unexported fields
}
WorkDoneWriter wraps a workDone handle to provide a Writer interface, so that workDone reporting can more easily be hooked into commands.
func NewWorkDoneWriter ¶
func NewWorkDoneWriter(wd *WorkDone) *WorkDoneWriter
func (WorkDoneWriter) Write ¶
func (wdw WorkDoneWriter) Write(p []byte) (n int, err error)
Source Files ¶
progress.go
- Version
- v0.1.10
- Published
- Mar 15, 2022
- Platform
- js/wasm
- Imports
- 10 packages
- Last checked
- 6 hours ago –
Tools for package owners.