| 23 | } |
| 24 | |
| 25 | func (l *LanguageService) ProvideDiagnostics(ctx context.Context, uri lsproto.DocumentUri) (lsproto.DocumentDiagnosticResponse, error) { |
| 26 | program, file := l.getProgramAndFile(uri) |
| 27 | |
| 28 | if l.UserPreferences().EnableValidation.IsFalse() { |
| 29 | diagnostics := []*lsproto.Diagnostic{} |
| 30 | return lsproto.RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{ |
| 31 | FullDocumentDiagnosticReport: &lsproto.RelatedFullDocumentDiagnosticReport{ |
| 32 | Items: diagnostics, |
| 33 | }, |
| 34 | }, nil |
| 35 | } |
| 36 | |
| 37 | diagnostics := getAllDiagnostics(ctx, program, file) |
| 38 | |
| 39 | return lsproto.RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{ |
| 40 | FullDocumentDiagnosticReport: &lsproto.RelatedFullDocumentDiagnosticReport{ |
| 41 | Items: l.toLSPDiagnostics(ctx, diagnostics), |
| 42 | }, |
| 43 | }, nil |
| 44 | } |
| 45 | |
| 46 | func (l *LanguageService) toLSPDiagnostics(ctx context.Context, diagnostics ...[]*ast.Diagnostic) []*lsproto.Diagnostic { |
| 47 | size := 0 |