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

Function WrapOnOperators

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

692//
693// This will replace any previously supplied operators instead of merging them.
694func WrapOnOperators(symbols ...string) UnparserOption {
695 return func(opt *unparserOption) (*unparserOption, error) {
696 opt.operatorsToWrapOn = make(map[string]bool)
697 for _, symbol := range symbols {
698 _, found := operators.FindReverse(symbol)
699 if !found {
700 return nil, fmt.Errorf("Invalid unparser option. Unsupported operator: %s", symbol)
701 }
702 arity := operators.Arity(symbol)
703 if arity < 2 {
704 return nil, fmt.Errorf("Invalid unparser option. Unary operators are unsupported: %s", symbol)
705 }
706
707 opt.operatorsToWrapOn[symbol] = true
708 }
709
710 return opt, nil
711 }
712}
713
714// WrapAfterColumnLimit dictates whether to insert a newline before or after the specified operator
715// 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