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

Function WrapOnOperators

parser/unparser.go:622–640  ·  view source on GitHub ↗

WrapOnOperators specifies which operators to perform word wrapping on an output expression when its string length exceeds the column limit set by WrapOnColumn function. Word wrapping is supported on non-unary symbolic operators. Refer to operators.go for the full list This will replace any previou

(symbols ...string)

Source from the content-addressed store, hash-verified

620//
621// This will replace any previously supplied operators instead of merging them.
622func WrapOnOperators(symbols ...string) UnparserOption {
623 return func(opt *unparserOption) (*unparserOption, error) {
624 opt.operatorsToWrapOn = make(map[string]bool)
625 for _, symbol := range symbols {
626 _, found := operators.FindReverse(symbol)
627 if !found {
628 return nil, fmt.Errorf("Invalid unparser option. Unsupported operator: %s", symbol)
629 }
630 arity := operators.Arity(symbol)
631 if arity < 2 {
632 return nil, fmt.Errorf("Invalid unparser option. Unary operators are unsupported: %s", symbol)
633 }
634
635 opt.operatorsToWrapOn[symbol] = true
636 }
637
638 return opt, nil
639 }
640}
641
642// WrapAfterColumnLimit dictates whether to insert a newline before or after the specified operator
643// when word wrapping is performed.

Callers 2

TestUnparseFunction · 0.85
TestUnparseErrorsFunction · 0.85

Calls 2

FindReverseFunction · 0.92
ArityFunction · 0.92

Tested by 2

TestUnparseFunction · 0.68
TestUnparseErrorsFunction · 0.68