computeOffset converts a 0-based character offset from the local source content to the corresponding absolute character offset in the parent SourceInfo (e.g. for RelativeSource). If the location cannot be resolved or the source is nil, the original offset is returned.
(offset int32)
| 156 | // the corresponding absolute character offset in the parent SourceInfo (e.g. for RelativeSource). |
| 157 | // If the location cannot be resolved or the source is nil, the original offset is returned. |
| 158 | func (p *parserHelper) computeOffset(offset int32) int32 { |
| 159 | if p.source != nil { |
| 160 | if loc, found := p.source.OffsetLocation(offset); found { |
| 161 | return p.sourceInfo.ComputeOffsetAbsolute(int32(loc.Line()), int32(loc.Column())) |
| 162 | } |
| 163 | } |
| 164 | return offset |
| 165 | } |
| 166 | |
| 167 | func (p *parserHelper) id(ctx any) int64 { |
| 168 | var offset ast.OffsetRange |
no test coverage detected