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

Function Table

pkg/util/pretty/util.go:231–247  ·  view source on GitHub ↗

Table defines a document that formats a list of pairs of items either: - as a 2-column table, with the two columns aligned for example: SELECT aaa bbb FROM ccc - as sections, for example: SELECT aaa bbb FROM ccc We restrict the left value in each list item to be a one-line string to make the width

(alignment TableAlignment, docFn func(string) Doc, rows ...TableRow)

Source from the content-addressed store, hash-verified

229// docFn should be set to Text or Keyword and will be used when converting
230// TableRow label's to Docs.
231func Table(alignment TableAlignment, docFn func(string) Doc, rows ...TableRow) Doc {
232 // Compute the nested formatting in "sections". It's simple.
233 // Note that we do not use NestUnder() because we are not grouping
234 // at this level (the group is done for the final form below).
235 items := makeTableNestedSections(docFn, rows)
236 nestedSections := Stack(items...)
237
238 finalDoc := nestedSections
239
240 if alignment != TableNoAlign {
241 items = makeAlignedTableItems(alignment == TableRightAlignFirstColumn /* leftPad */, docFn, rows, items)
242 alignedTable := Stack(items...)
243 finalDoc = &union{alignedTable, nestedSections}
244 }
245
246 return Group(finalDoc)
247}
248
249func computeLeftColumnWidth(rows []TableRow) int {
250 leftwidth := 0

Callers 3

rlTableMethod · 0.92
llTableMethod · 0.92
joinNestedOuterMethod · 0.92

Calls 4

makeTableNestedSectionsFunction · 0.85
StackFunction · 0.85
makeAlignedTableItemsFunction · 0.85
GroupFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…