MCPcopy Index your code
hub / github.com/microsoft/typescript-go / run

Method run

internal/lsp/progress.go:110–196  ·  view source on GitHub ↗

run is the persistent goroutine that processes all progress events. It owns all mutable state: no external synchronization needed.

()

Source from the content-addressed store, hash-verified

108// run is the persistent goroutine that processes all progress events.
109// It owns all mutable state: no external synchronization needed.
110func (p *projectLoadingProgress) run() {
111 var (
112 loading collections.OrderedMap[string, int]
113 token string // current token; empty if no progress active
114 tokenID int
115 begun bool // whether "begin" has been sent for the current token
116 )
117
118 var delay *time.Timer
119 delayC := func() <-chan time.Time {
120 if delay == nil {
121 return nil
122 }
123 return delay.C
124 }
125 stopDelay := func() {
126 if delay != nil {
127 delay.Stop()
128 delay = nil
129 }
130 }
131 delayFired := false // true after the delay timer fires
132
133 for {
134 select {
135 case ev := <-p.ch:
136 text := p.reporter.localize(ev.message, ev.args...)
137 if !ev.finish {
138 count := loading.GetOrZero(text)
139 loading.Set(text, count+1)
140 if token == "" {
141 tokenID++
142 token = fmt.Sprintf("tsgo-loading-%d", tokenID)
143 begun = false
144 if p.delay <= 0 {
145 delayFired = true
146 p.reporter.createWorkDoneProgress(token)
147 } else {
148 delayFired = false
149 delay = time.NewTimer(p.delay)
150 }
151 }
152 if delayFired {
153 begun = p.beginOrReport(token, text, begun)
154 }
155 } else {
156 count := loading.GetOrZero(text)
157 if count <= 1 {
158 loading.Delete(text)
159 } else {
160 loading.Set(text, count-1)
161 }
162 if token == "" {
163 continue
164 }
165 if loading.Size() == 0 {
166 if begun {
167 p.reporter.sendProgress(token, lsproto.WorkDoneProgressBeginOrReportOrEnd{

Callers 1

Calls 12

beginOrReportMethod · 0.95
FirstOrNilSeqFunction · 0.92
StopMethod · 0.80
GetOrZeroMethod · 0.80
localizeMethod · 0.65
SetMethod · 0.65
DeleteMethod · 0.65
sendProgressMethod · 0.65
doneMethod · 0.65
SizeMethod · 0.45
KeysMethod · 0.45

Tested by

no test coverage detected