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

Method id

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

Source from the content-addressed store, hash-verified

165}
166
167func (p *parserHelper) id(ctx any) int64 {
168 var offset ast.OffsetRange
169 switch c := ctx.(type) {
170 case antlr.ParserRuleContext:
171 start := c.GetStart()
172 offset.Start = p.sourceInfo.ComputeOffset(int32(start.GetLine()), int32(start.GetColumn()))
173 offset.Stop = offset.Start + int32(len(c.GetText()))
174 case antlr.Token:
175 offset.Start = p.sourceInfo.ComputeOffset(int32(c.GetLine()), int32(c.GetColumn()))
176 offset.Stop = offset.Start + int32(len(c.GetText()))
177 case token:
178 offset.Start = p.computeOffset(c.start)
179 offset.Stop = p.computeOffset(c.end)
180 case common.Location:
181 offset.Start = p.sourceInfo.ComputeOffsetAbsolute(int32(c.Line()), int32(c.Column()))
182 offset.Stop = offset.Start
183 case ast.OffsetRange:
184 offset = c
185 default:
186 // This should only happen if the ctx is nil
187 return -1
188 }
189 id := p.nextID
190 p.sourceInfo.SetOffsetRange(id, offset)
191 p.nextID++
192 return id
193}
194
195func (p *parserHelper) idFromOffsets(start, stop int32) int64 {
196 id := p.nextID

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 7

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

Tested by

no test coverage detected