feat(lsp): add textDocument/rangeFormatting support
Advertise DocumentRangeFormattingProvider in server capabilities and implement rangeFormat: formats the complete document, then returns an edit covering only the minimal changed-line region that overlaps the client's selection. Also includes gofmt alignment fixes across lint and format packages.
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
// break callers silently. Enumerate the columns you need explicitly.
|
||||
type ruleCOR001 struct{}
|
||||
|
||||
func (ruleCOR001) ID() string { return "COR001" }
|
||||
func (ruleCOR001) ID() string { return "COR001" }
|
||||
func (ruleCOR001) Severity() diagnostics.Severity { return diagnostics.SeverityHint }
|
||||
|
||||
func (ruleCOR001) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
@@ -71,7 +71,7 @@ func checkSelectStmt(s *pg_query.SelectStmt, src string, out *[]diagnostics.Diag
|
||||
// An UPDATE with no WHERE clause modifies every row in the table.
|
||||
type ruleCOR002 struct{}
|
||||
|
||||
func (ruleCOR002) ID() string { return "COR002" }
|
||||
func (ruleCOR002) ID() string { return "COR002" }
|
||||
func (ruleCOR002) Severity() diagnostics.Severity { return diagnostics.SeverityWarning }
|
||||
|
||||
func (ruleCOR002) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
@@ -101,7 +101,7 @@ func (ruleCOR002) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Dia
|
||||
// Use TRUNCATE if you intend a full wipe; it is faster and explicit.
|
||||
type ruleCOR003 struct{}
|
||||
|
||||
func (ruleCOR003) ID() string { return "COR003" }
|
||||
func (ruleCOR003) ID() string { return "COR003" }
|
||||
func (ruleCOR003) Severity() diagnostics.Severity { return diagnostics.SeverityWarning }
|
||||
|
||||
func (ruleCOR003) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
// CREATE INDEX CONCURRENTLY instead.
|
||||
type ruleMIG001 struct{}
|
||||
|
||||
func (ruleMIG001) ID() string { return "MIG001" }
|
||||
func (ruleMIG001) ID() string { return "MIG001" }
|
||||
func (ruleMIG001) Severity() diagnostics.Severity { return diagnostics.SeverityWarning }
|
||||
|
||||
func (ruleMIG001) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
@@ -52,7 +52,7 @@ func (ruleMIG001) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Dia
|
||||
// supplied. Use a nullable column first, backfill, then add the constraint.
|
||||
type ruleMIG002 struct{}
|
||||
|
||||
func (ruleMIG002) ID() string { return "MIG002" }
|
||||
func (ruleMIG002) ID() string { return "MIG002" }
|
||||
func (ruleMIG002) Severity() diagnostics.Severity { return diagnostics.SeverityWarning }
|
||||
|
||||
func (ruleMIG002) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
@@ -97,7 +97,7 @@ func (ruleMIG002) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Dia
|
||||
// VALIDATE CONSTRAINT to spread the lock window.
|
||||
type ruleMIG003 struct{}
|
||||
|
||||
func (ruleMIG003) ID() string { return "MIG003" }
|
||||
func (ruleMIG003) ID() string { return "MIG003" }
|
||||
func (ruleMIG003) Severity() diagnostics.Severity { return diagnostics.SeverityWarning }
|
||||
|
||||
func (ruleMIG003) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
|
||||
@@ -22,7 +22,7 @@ func isSnakeCase(s string) bool {
|
||||
// NAM001 — table names must be snake_case.
|
||||
type ruleNAM001 struct{}
|
||||
|
||||
func (ruleNAM001) ID() string { return "NAM001" }
|
||||
func (ruleNAM001) ID() string { return "NAM001" }
|
||||
func (ruleNAM001) Severity() diagnostics.Severity { return diagnostics.SeverityHint }
|
||||
|
||||
func (ruleNAM001) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
@@ -51,7 +51,7 @@ func (ruleNAM001) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Dia
|
||||
// NAM002 — column names in CREATE TABLE must be snake_case.
|
||||
type ruleNAM002 struct{}
|
||||
|
||||
func (ruleNAM002) ID() string { return "NAM002" }
|
||||
func (ruleNAM002) ID() string { return "NAM002" }
|
||||
func (ruleNAM002) Severity() diagnostics.Severity { return diagnostics.SeverityHint }
|
||||
|
||||
func (ruleNAM002) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
@@ -86,7 +86,7 @@ func (ruleNAM002) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Dia
|
||||
// NAM003 — function/procedure names must be snake_case.
|
||||
type ruleNAM003 struct{}
|
||||
|
||||
func (ruleNAM003) ID() string { return "NAM003" }
|
||||
func (ruleNAM003) ID() string { return "NAM003" }
|
||||
func (ruleNAM003) Severity() diagnostics.Severity { return diagnostics.SeverityHint }
|
||||
|
||||
func (ruleNAM003) Check(stmts []*pg_query.RawStmt, src string) []diagnostics.Diagnostic {
|
||||
|
||||
Reference in New Issue
Block a user