(ctx any)
| 153 | } |
| 154 | |
| 155 | func (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 | |
| 180 | func (p *parserHelper) deleteID(id int64) { |
| 181 | p.sourceInfo.ClearOffsetRange(id) |
no test coverage detected