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

Function CopySourceInfo

common/ast/ast.go:222–249  ·  view source on GitHub ↗

CopySourceInfo creates a deep copy of the MacroCalls within the input SourceInfo. Copies of macro Expr values are generated using an internal default ExprFactory.

(info *SourceInfo)

Source from the content-addressed store, hash-verified

220//
221// Copies of macro Expr values are generated using an internal default ExprFactory.
222func CopySourceInfo(info *SourceInfo) *SourceInfo {
223 if info == nil {
224 return nil
225 }
226 rangesCopy := make(map[int64]OffsetRange, len(info.offsetRanges))
227 for id, off := range info.offsetRanges {
228 rangesCopy[id] = off
229 }
230 callsCopy := make(map[int64]Expr, len(info.macroCalls))
231 for id, call := range info.macroCalls {
232 callsCopy[id] = defaultFactory.CopyExpr(call)
233 }
234 var extCopy []Extension
235 if len(info.extensions) > 0 {
236 extCopy = make([]Extension, len(info.extensions))
237 copy(extCopy, info.extensions)
238 }
239 return &SourceInfo{
240 syntax: info.syntax,
241 desc: info.desc,
242 lines: info.lines,
243 baseLine: info.baseLine,
244 baseCol: info.baseCol,
245 offsetRanges: rangesCopy,
246 macroCalls: callsCopy,
247 extensions: extCopy,
248 }
249}
250
251// SourceInfo records basic information about the expression as a textual input and
252// as a parsed expression value.

Callers 2

CopyASTMethod · 0.92
CopyFunction · 0.85

Calls 1

CopyExprMethod · 0.65

Tested by

no test coverage detected