(ctx any)
| 149 | } |
| 150 | |
| 151 | func (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 | |
| 176 | func (p *parserHelper) deleteID(id int64) { |
| 177 | p.sourceInfo.ClearOffsetRange(id) |
no test coverage detected