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

Method CollectMetadata

policy/parser.go:682–696  ·  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

680// CollectMetadata records the source position information of a given YAML node, and returns
681// the id associated with the source metadata which is returned in the Policy SourceInfo object.
682func (p *parserImpl) CollectMetadata(node *yaml.Node) int64 {
683 id := p.NextID()
684 line := node.Line
685 col := int32(node.Column)
686 switch node.Style {
687 case yaml.DoubleQuotedStyle, yaml.SingleQuotedStyle:
688 col++
689 }
690 offsetStart := int32(0)
691 if line > 1 {
692 offsetStart = p.info.LineOffsets()[line-2]
693 }
694 p.info.SetOffsetRange(id, ast.OffsetRange{Start: offsetStart + col - 1, Stop: offsetStart + col - 1})
695 return id
696}
697
698// ParsePolicy will parse the target yaml node as though it is the top-level policy.
699func (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