MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / doc

Method doc

pkg/sql/sem/tree/pretty.go:1256–1297  ·  view source on GitHub ↗
(p *PrettyCfg)

Source from the content-addressed store, hash-verified

1254}
1255
1256func (node *TableDefs) doc(p *PrettyCfg) pretty.Doc {
1257 // This groups column definitions using a table to get alignment of
1258 // column names, and separately comma-joins groups of column definitions
1259 // with constraint definitions.
1260
1261 defs := *node
1262 colDefRows := make([]pretty.TableRow, 0, len(defs))
1263 items := make([]pretty.Doc, 0, len(defs))
1264
1265 for i := 0; i < len(defs); i++ {
1266 if _, ok := defs[i].(*ColumnTableDef); ok {
1267 // Group all the subsequent column definitions into a table.
1268 j := i
1269 colDefRows = colDefRows[:0]
1270 for ; j < len(defs); j++ {
1271 cdef, ok := defs[j].(*ColumnTableDef)
1272 if !ok {
1273 break
1274 }
1275 colDefRows = append(colDefRows, cdef.docRow(p))
1276 }
1277 // Let the outer loop pick up where we left.
1278 i = j - 1
1279
1280 // At this point the column definitions form a table, but the comma
1281 // is missing from each row. We need to add it here. However we
1282 // need to be careful. Since we're going to add a comma between the
1283 // set of all column definitions and the other table definitions
1284 // below (via commaSeparated), we need to ensure the last row does
1285 // not get a comma.
1286 for j = 0; j < len(colDefRows)-1; j++ {
1287 colDefRows[j].Doc = pretty.Concat(colDefRows[j].Doc, pretty.Text(","))
1288 }
1289 items = append(items, p.llTable(pretty.Text, colDefRows...))
1290 } else {
1291 // Not a column definition, just process normally.
1292 items = append(items, p.Doc(defs[i]))
1293 }
1294 }
1295
1296 return p.commaSeparated(items...)
1297}
1298
1299func (node *CaseExpr) doc(p *PrettyCfg) pretty.Doc {
1300 d := make([]pretty.Doc, 0, len(node.Whens)+3)

Callers

nothing calls this directly

Calls 6

ConcatFunction · 0.92
TextFunction · 0.92
llTableMethod · 0.80
DocMethod · 0.80
commaSeparatedMethod · 0.80
docRowMethod · 0.45

Tested by

no test coverage detected