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

Method writeOperatorWithWrapping

parser/unparser.go:541–568  ·  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

539// writeOperatorWithWrapping outputs the operator and inserts a newline for operators configured
540// in the unparser options.
541func (un *unparser) writeOperatorWithWrapping(fun string, unmangled string) bool {
542 _, wrapOperatorExists := un.options.operatorsToWrapOn[fun]
543 lineLength := un.str.Len() - un.lastWrappedIndex + len(fun)
544
545 if wrapOperatorExists && lineLength >= un.options.wrapOnColumn {
546 un.lastWrappedIndex = un.str.Len()
547 // wrapAfterColumnLimit flag dictates whether the newline is placed
548 // before or after the operator
549 if un.options.wrapAfterColumnLimit {
550 // Input: a && b
551 // Output: a &&\nb
552 un.str.WriteString(" ")
553 un.str.WriteString(unmangled)
554 un.str.WriteString("\n")
555 } else {
556 // Input: a && b
557 // Output: a\n&& b
558 un.str.WriteString("\n")
559 un.str.WriteString(unmangled)
560 un.str.WriteString(" ")
561 }
562 return true
563 }
564 un.str.WriteString(" ")
565 un.str.WriteString(unmangled)
566 un.str.WriteString(" ")
567 return false
568}
569
570// Defined defaults for the unparser options
571var (

Callers 2

visitCallBinaryMethod · 0.95
visitCallConditionalMethod · 0.95

Calls 1

LenMethod · 0.65

Tested by

no test coverage detected