Format implements the NodeFormatter interface.
(ctx *FmtCtx)
| 1622 | |
| 1623 | // Format implements the NodeFormatter interface. |
| 1624 | func (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. |
| 1648 | func (node *AnnotateTypeExpr) TypedInnerExpr() TypedExpr { |
nothing calls this directly
no test coverage detected