MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / Format

Method Format

pkg/sql/sem/tree/expr.go:1624–1645  ·  view source on GitHub ↗

Format implements the NodeFormatter interface.

(ctx *FmtCtx)

Source from the content-addressed store, hash-verified

1622
1623// Format implements the NodeFormatter interface.
1624func (node *AnnotateTypeExpr) Format(ctx *FmtCtx) {
1625 switch node.SyntaxMode {
1626 case AnnotateShort:
1627 exprFmtWithParen(ctx, node.Expr)
1628 // The Array format function handles adding type annotations for this case.
1629 // We short circuit here to prevent double type annotation.
1630 if arrayExpr, ok := node.Expr.(*Array); ok {
1631 if ctx.HasFlags(FmtParsable) && arrayExpr.typ != nil {
1632 return
1633 }
1634 }
1635 ctx.WriteString(":::")
1636 ctx.FormatTypeReference(node.Type)
1637
1638 default:
1639 ctx.WriteString("ANNOTATE_TYPE(")
1640 ctx.FormatNode(node.Expr)
1641 ctx.WriteString(", ")
1642 ctx.FormatTypeReference(node.Type)
1643 ctx.WriteByte(')')
1644 }
1645}
1646
1647// TypedInnerExpr returns the AnnotateTypeExpr's inner expression as a TypedExpr.
1648func (node *AnnotateTypeExpr) TypedInnerExpr() TypedExpr {

Callers

nothing calls this directly

Calls 4

exprFmtWithParenFunction · 0.85
FormatTypeReferenceMethod · 0.80
FormatNodeMethod · 0.80
HasFlagsMethod · 0.45

Tested by

no test coverage detected