MCPcopy Create free account
hub / github.com/cel-expr/cel-go / writeOperatorWithWrapping

Method writeOperatorWithWrapping

parser/unparser.go:603–630  ·  view source on GitHub ↗

writeOperatorWithWrapping outputs the operator and inserts a newline for operators configured in the unparser options.

(fun string, unmangled string)

Source from the content-addressed store, hash-verified

601// writeOperatorWithWrapping outputs the operator and inserts a newline for operators configured
602// in the unparser options.
603func (un *unparser) writeOperatorWithWrapping(fun string, unmangled string) bool {
604 _, wrapOperatorExists := un.options.operatorsToWrapOn[fun]
605 lineLength := un.str.Len() - un.lastWrappedIndex + len(fun)
606
607 if wrapOperatorExists && lineLength >= un.options.wrapOnColumn {
608 un.lastWrappedIndex = un.str.Len()
609 // wrapAfterColumnLimit flag dictates whether the newline is placed
610 // before or after the operator
611 if un.options.wrapAfterColumnLimit {
612 // Input: a && b
613 // Output: a &&\nb
614 un.str.WriteString(" ")
615 un.str.WriteString(unmangled)
616 un.str.WriteString("\n")
617 } else {
618 // Input: a && b
619 // Output: a\n&& b
620 un.str.WriteString("\n")
621 un.str.WriteString(unmangled)
622 un.str.WriteString(" ")
623 }
624 return true
625 }
626 un.str.WriteString(" ")
627 un.str.WriteString(unmangled)
628 un.str.WriteString(" ")
629 return false
630}
631
632// Defined defaults for the unparser options
633var (

Callers 2

visitCallBinaryMethod · 0.95
visitCallConditionalMethod · 0.95

Calls 1

LenMethod · 0.65

Tested by

no test coverage detected