MCPcopy Create free account
hub / github.com/brimdata/super / formatTypeValue

Method formatTypeValue

sup/formatter.go:193–371  ·  view source on GitHub ↗
(indent int, tv scode.Bytes, isComponentType bool)

Source from the content-addressed store, hash-verified

191}
192
193func (f *Formatter) formatTypeValue(indent int, tv scode.Bytes, isComponentType bool) scode.Bytes {
194 n, tv := super.DecodeLength(tv)
195 if tv == nil {
196 f.truncTypeValueErr()
197 return nil
198 }
199 switch n {
200 default:
201 typ, err := super.LookupPrimitiveByID(n)
202 if err != nil {
203 f.buildf("<ERR bad type ID in type value: %s>", err)
204 return nil
205 }
206
207 f.startColor(color.Gray(160))
208 f.build(super.PrimitiveName(typ))
209 f.endColor()
210 case super.TypeValueNameDef:
211 var name string
212 name, tv = super.DecodeName(tv)
213 if tv == nil {
214 f.truncTypeValueErr()
215 return nil
216 }
217 if isComponentType {
218 f.build("(")
219 }
220 f.build(QuotedName(name))
221 f.build("=")
222 tv = f.formatTypeValue(indent, tv, false)
223 if isComponentType {
224 f.build(")")
225 }
226 case super.TypeValueNameRef:
227 var name string
228 name, tv = super.DecodeName(tv)
229 if tv == nil {
230 f.truncTypeValueErr()
231 return nil
232 }
233 f.build(QuotedName(name))
234 case super.TypeValueRecord:
235 f.build("{")
236 var n int
237 n, tv = super.DecodeLength(tv)
238 if tv == nil {
239 f.truncTypeValueErr()
240 return nil
241 }
242 if n == 0 {
243 f.build("}")
244 return tv
245 }
246 sep := f.newline
247 indent += f.tab
248 optlen := (n + 7) >> 3
249 if optlen > len(tv) {
250 f.truncTypeValueErr()

Callers 3

formatValueMethod · 0.95
formatVectorTypeValueMethod · 0.95
FormatTypeValueFunction · 0.95

Calls 14

truncTypeValueErrMethod · 0.95
buildfMethod · 0.95
startColorMethod · 0.95
buildMethod · 0.95
endColorMethod · 0.95
indentMethod · 0.95
formatVectorTypeValueMethod · 0.95
DecodeLengthFunction · 0.92
LookupPrimitiveByIDFunction · 0.92
GrayFunction · 0.92
PrimitiveNameFunction · 0.92
DecodeNameFunction · 0.92

Tested by

no test coverage detected