(ctx any)
| 165 | } |
| 166 | |
| 167 | func (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 | |
| 195 | func (p *parserHelper) idFromOffsets(start, stop int32) int64 { |
| 196 | id := p.nextID |
no test coverage detected