@@ -101,13 +101,12 @@ func Diagnostics(ctx context.Context, v View, uri span.URI) (map[span.URI][]Diag
101
101
return reports , nil
102
102
}
103
103
// Type checking and parsing succeeded. Run analyses.
104
- runAnalyses (ctx , v , pkg , func (a * analysis.Analyzer , diag analysis.Diagnostic ) {
104
+ runAnalyses (ctx , v , pkg , func (a * analysis.Analyzer , diag analysis.Diagnostic ) error {
105
105
r := span .NewRange (v .FileSet (), diag .Pos , 0 )
106
106
s , err := r .Span ()
107
107
if err != nil {
108
- //TODO: we could not process the diag.Pos, and thus have no valid span
109
- //we don't have anywhere to put this error though
110
- v .Logger ().Errorf (ctx , "%v" , err )
108
+ // The diagnostic has an invalid position, so we don't have a valid span.
109
+ return err
111
110
}
112
111
category := a .Name
113
112
if diag .Category != "" {
@@ -119,6 +118,7 @@ func Diagnostics(ctx context.Context, v View, uri span.URI) (map[span.URI][]Diag
119
118
Message : diag .Message ,
120
119
Severity : SeverityWarning ,
121
120
})
121
+ return nil
122
122
})
123
123
124
124
return reports , nil
@@ -168,8 +168,8 @@ func singleDiagnostic(uri span.URI, format string, a ...interface{}) map[span.UR
168
168
}
169
169
}
170
170
171
- func runAnalyses (ctx context.Context , v View , pkg Package , report func (a * analysis.Analyzer , diag analysis.Diagnostic )) error {
172
- // the traditional vet suite:
171
+ func runAnalyses (ctx context.Context , v View , pkg Package , report func (a * analysis.Analyzer , diag analysis.Diagnostic ) error ) error {
172
+ // The traditional vet suite:
173
173
analyzers := []* analysis.Analyzer {
174
174
asmdecl .Analyzer ,
175
175
assign .Analyzer ,
@@ -195,7 +195,10 @@ func runAnalyses(ctx context.Context, v View, pkg Package, report func(a *analys
195
195
unusedresult .Analyzer ,
196
196
}
197
197
198
- roots := analyze (ctx , v , []Package {pkg }, analyzers )
198
+ roots , err := analyze (ctx , v , []Package {pkg }, analyzers )
199
+ if err != nil {
200
+ return err
201
+ }
199
202
200
203
// Report diagnostics and errors from root analyzers.
201
204
for _ , r := range roots {
@@ -205,9 +208,10 @@ func runAnalyses(ctx context.Context, v View, pkg Package, report func(a *analys
205
208
// which isn't super useful...
206
209
return r .err
207
210
}
208
- report (r .Analyzer , diag )
211
+ if err := report (r .Analyzer , diag ); err != nil {
212
+ return err
213
+ }
209
214
}
210
215
}
211
-
212
216
return nil
213
217
}
0 commit comments