@@ -14,16 +14,24 @@ import (
14
14
)
15
15
16
16
func (s * Server ) cacheAndDiagnose (ctx context.Context , uri span.URI , content string ) error {
17
+ s .log .Debugf (ctx , "cacheAndDiagnose: %s" , uri )
18
+
17
19
view := s .findView (ctx , uri )
18
20
if err := view .SetContent (ctx , uri , []byte (content )); err != nil {
19
21
return err
20
22
}
23
+
24
+ s .log .Debugf (ctx , "cacheAndDiagnose: set content for %s" , uri )
25
+
21
26
go func () {
22
27
ctx := view .BackgroundContext ()
23
28
if ctx .Err () != nil {
24
29
s .log .Errorf (ctx , "canceling diagnostics for %s: %v" , uri , ctx .Err ())
25
30
return
26
31
}
32
+
33
+ s .log .Debugf (ctx , "cacheAndDiagnose: going to get diagnostics for %s" , uri )
34
+
27
35
reports , err := source .Diagnostics (ctx , view , uri )
28
36
if err != nil {
29
37
s .log .Errorf (ctx , "failed to compute diagnostics for %s: %v" , uri , err )
@@ -33,6 +41,8 @@ func (s *Server) cacheAndDiagnose(ctx context.Context, uri span.URI, content str
33
41
s .undeliveredMu .Lock ()
34
42
defer s .undeliveredMu .Unlock ()
35
43
44
+ s .log .Debugf (ctx , "cacheAndDiagnose: publishing diagnostics" )
45
+
36
46
for uri , diagnostics := range reports {
37
47
if err := s .publishDiagnostics (ctx , view , uri , diagnostics ); err != nil {
38
48
if s .undelivered == nil {
@@ -44,6 +54,9 @@ func (s *Server) cacheAndDiagnose(ctx context.Context, uri span.URI, content str
44
54
// In case we had old, undelivered diagnostics.
45
55
delete (s .undelivered , uri )
46
56
}
57
+
58
+ s .log .Debugf (ctx , "cacheAndDiagnose: publishing undelivered diagnostics" )
59
+
47
60
// Anytime we compute diagnostics, make sure to also send along any
48
61
// undelivered ones (only for remaining URIs).
49
62
for uri , diagnostics := range s .undelivered {
@@ -53,6 +66,9 @@ func (s *Server) cacheAndDiagnose(ctx context.Context, uri span.URI, content str
53
66
delete (s .undelivered , uri )
54
67
}
55
68
}()
69
+
70
+ s .log .Debugf (ctx , "cacheAndDiagnose: done computing diagnostics for %s" , uri )
71
+
56
72
return nil
57
73
}
58
74
0 commit comments