handleCodeAction provides code actions (quick fixes) for diagnostics. This handler suggests automatic fixes for common SQL syntax errors and style issues. Code actions appear in the editor as lightbulb suggestions that users can apply with a single click. Supported Quick Fixes: - Add missing semic
(params json.RawMessage)
| 1609 | // - Empty array if no fixes available |
| 1610 | // - Error if params invalid |
| 1611 | func (h *Handler) handleCodeAction(params json.RawMessage) ([]CodeAction, error) { |
| 1612 | var p CodeActionParams |
| 1613 | if err := json.Unmarshal(params, &p); err != nil { |
| 1614 | return nil, err |
| 1615 | } |
| 1616 | |
| 1617 | actions := []CodeAction{} |
| 1618 | |
| 1619 | // Generate quick fixes based on diagnostics |
| 1620 | for _, diag := range p.Context.Diagnostics { |
| 1621 | codeActions := h.getCodeActionsForDiagnostic(p.TextDocument.URI, diag) |
| 1622 | actions = append(actions, codeActions...) |
| 1623 | } |
| 1624 | |
| 1625 | return actions, nil |
| 1626 | } |
| 1627 | |
| 1628 | // getCodeActionsForDiagnostic generates code actions for a specific diagnostic |
| 1629 | func (h *Handler) getCodeActionsForDiagnostic(uri string, diag Diagnostic) []CodeAction { |
no test coverage detected