validateDocument parses the SQL and publishes diagnostics
(uri, content string, version int)
| 396 | |
| 397 | // validateDocument parses the SQL and publishes diagnostics |
| 398 | func (h *Handler) validateDocument(uri, content string, version int) { |
| 399 | var diagnostics []Diagnostic |
| 400 | |
| 401 | // Use ParseWithRecovery for multi-error diagnostics so the user sees |
| 402 | // every problem at once instead of fixing them one-by-one. |
| 403 | _, errs := gosqlx.ParseWithRecovery(content) |
| 404 | for i, err := range errs { |
| 405 | diag := h.createDiagnosticFromError(content, err, i) |
| 406 | diagnostics = append(diagnostics, diag) |
| 407 | } |
| 408 | |
| 409 | // Publish diagnostics |
| 410 | h.server.SendNotification("textDocument/publishDiagnostics", PublishDiagnosticsParams{ |
| 411 | URI: uri, |
| 412 | Version: version, |
| 413 | Diagnostics: diagnostics, |
| 414 | }) |
| 415 | |
| 416 | h.server.Logger().Printf("Published %d diagnostics for %s", len(diagnostics), uri) |
| 417 | } |
| 418 | |
| 419 | // sendParseError sends an error message to the client when notification parsing fails |
| 420 | func (h *Handler) sendParseError(method string, err error) { |
no test coverage detected