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

Method id

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

Source from the content-addressed store, hash-verified

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