lineToByteOffsets extract the line number into raw file offset. Inserts a dummy 0 at offset 0 so line offsets can be 1 based.
(src []byte)
| 93 | // |
| 94 | // Inserts a dummy 0 at offset 0 so line offsets can be 1 based. |
| 95 | func lineToByteOffsets(src []byte) []int { |
| 96 | offsets := []int{0, 0} |
| 97 | for offset := 0; offset < len(src); { |
| 98 | n := bytes.IndexByte(src[offset:], '\n') |
| 99 | if n == -1 { |
| 100 | break |
| 101 | } |
| 102 | offset += n + 1 |
| 103 | offsets = append(offsets, offset) |
| 104 | } |
| 105 | return offsets |
| 106 | } |
| 107 | |
| 108 | // parsedFile is a processed Go source file. |
| 109 | type parsedFile struct { |
no outgoing calls
searching dependent graphs…