(delta: number)
| 21 | } |
| 22 | |
| 23 | moveBy(delta: number): ParseLocation { |
| 24 | const source = this.file.content; |
| 25 | const len = source.length; |
| 26 | let offset = this.offset; |
| 27 | let line = this.line; |
| 28 | let col = this.col; |
| 29 | while (offset > 0 && delta < 0) { |
| 30 | offset--; |
| 31 | delta++; |
| 32 | const ch = source.charCodeAt(offset); |
| 33 | if (ch == chars.$LF) { |
| 34 | line--; |
| 35 | const priorLine = source |
| 36 | .substring(0, offset - 1) |
| 37 | .lastIndexOf(String.fromCharCode(chars.$LF)); |
| 38 | col = priorLine > 0 ? offset - priorLine : offset; |
| 39 | } else { |
| 40 | col--; |
| 41 | } |
| 42 | } |
| 43 | while (offset < len && delta > 0) { |
| 44 | const ch = source.charCodeAt(offset); |
| 45 | offset++; |
| 46 | delta--; |
| 47 | if (ch == chars.$LF) { |
| 48 | line++; |
| 49 | col = 0; |
| 50 | } else { |
| 51 | col++; |
| 52 | } |
| 53 | } |
| 54 | return new ParseLocation(this.file, offset, line, col); |
| 55 | } |
| 56 | |
| 57 | // Return the source around the location |
| 58 | // Up to `maxChars` or `maxLines` on each side of the location |
no outgoing calls
no test coverage detected