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

Method id

parser/helper.go:151–174  ·  view source on GitHub ↗
(ctx any)

Source from the content-addressed store, hash-verified

149}
150
151func (p *parserHelper) id(ctx any) int64 {
152 var offset ast.OffsetRange
153 switch c := ctx.(type) {
154 case antlr.ParserRuleContext:
155 start := c.GetStart()
156 offset.Start = p.sourceInfo.ComputeOffset(int32(start.GetLine()), int32(start.GetColumn()))
157 offset.Stop = offset.Start + int32(len(c.GetText()))
158 case antlr.Token:
159 offset.Start = p.sourceInfo.ComputeOffset(int32(c.GetLine()), int32(c.GetColumn()))
160 offset.Stop = offset.Start + int32(len(c.GetText()))
161 case common.Location:
162 offset.Start = p.sourceInfo.ComputeOffsetAbsolute(int32(c.Line()), int32(c.Column()))
163 offset.Stop = offset.Start
164 case ast.OffsetRange:
165 offset = c
166 default:
167 // This should only happen if the ctx is nil
168 return -1
169 }
170 id := p.nextID
171 p.sourceInfo.SetOffsetRange(id, offset)
172 p.nextID++
173 return id
174}
175
176func (p *parserHelper) deleteID(id int64) {
177 p.sourceInfo.ClearOffsetRange(id)

Callers 15

newIDMethod · 0.95
nextMacroIDMethod · 0.80
VisitExprMethod · 0.80
VisitConditionalOrMethod · 0.80
VisitConditionalAndMethod · 0.80
VisitRelationMethod · 0.80
VisitCalcMethod · 0.80
VisitLogicalNotMethod · 0.80
VisitNegateMethod · 0.80
VisitMemberCallMethod · 0.80
VisitIndexMethod · 0.80
VisitCreateMessageMethod · 0.80

Calls 6

ComputeOffsetMethod · 0.80
GetTextMethod · 0.80
ComputeOffsetAbsoluteMethod · 0.80
SetOffsetRangeMethod · 0.80
LineMethod · 0.65
ColumnMethod · 0.65

Tested by

no test coverage detected