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

Method CollectMetadata

policy/parser.go:724–738  ·  view source on GitHub ↗

CollectMetadata records the source position information of a given YAML node, and returns the id associated with the source metadata which is returned in the Policy SourceInfo object.

(node *yaml.Node)

Source from the content-addressed store, hash-verified

722// CollectMetadata records the source position information of a given YAML node, and returns
723// the id associated with the source metadata which is returned in the Policy SourceInfo object.
724func (p *parserImpl) CollectMetadata(node *yaml.Node) int64 {
725 id := p.NextID()
726 line := node.Line
727 col := int32(node.Column)
728 switch node.Style {
729 case yaml.DoubleQuotedStyle, yaml.SingleQuotedStyle:
730 col++
731 }
732 offsetStart := int32(0)
733 if line > 1 {
734 offsetStart = p.info.LineOffsets()[line-2]
735 }
736 p.info.SetOffsetRange(id, ast.OffsetRange{Start: offsetStart + col - 1, Stop: offsetStart + col - 1})
737 return id
738}
739
740// ParsePolicy will parse the target yaml node as though it is the top-level policy.
741func (p *parserImpl) ParsePolicy(ctx ParserContext, node *yaml.Node) *Policy {

Callers 7

NewPolicyMethod · 0.95
NewRuleMethod · 0.95
NewVariableMethod · 0.95
NewMatchMethod · 0.95
NewStringMethod · 0.95
newStrictStringMethod · 0.95
ParsePolicyMethod · 0.95

Calls 3

NextIDMethod · 0.95
SetOffsetRangeMethod · 0.80
LineOffsetsMethod · 0.65

Tested by

no test coverage detected