ruff/crates/ruff_python_parser/src
Dhruv Manilawala 9c1b6ec411
Use correct range to highlight line continuation error (#12016)
## Summary

This PR fixes the range highlighted for the line continuation error.

Previously, it would highlight an incorrect range:
```
1 | call(a, b, \\\
  |           ^^ Syntax Error: unexpected character after line continuation character
2 | 
3 | def bar():
  |
```

And now:
```
  |
1 | call(a, b, \\\
  |             ^ Syntax Error: unexpected character after line continuation character
2 | 
3 | def bar():
  |
```

This is implemented by avoiding to update the token range for the
`Unknown` token which is emitted when there's a lexical error. Instead,
the `push_error` helper method will be responsible to update the range
to the error location.

This actually becomes a requirement which can be seen in follow-up PRs.

## Test Plan

Update and validate the snapshot.
2024-06-25 13:35:24 +05:30
..
lexer Maintain synchronicity between the lexer and the parser (#11457) 2024-06-03 18:23:50 +05:30
parser Update Rust crate rustc-hash to v2 (#12001) 2024-06-23 20:46:42 -04:00
snapshots Lexer should consider BOM for the start offset (#11732) 2024-06-04 08:45:46 +00:00
error.rs Move token and error structs into related modules (#11957) 2024-06-21 10:07:19 +00:00
lexer.rs Use correct range to highlight line continuation error (#12016) 2024-06-25 13:35:24 +05:30
lib.rs Move token and error structs into related modules (#11957) 2024-06-21 10:07:19 +00:00
string.rs Move token and error structs into related modules (#11957) 2024-06-21 10:07:19 +00:00
token.rs Manual impl of `Debug` on `Token` (#11958) 2024-06-22 04:18:24 +00:00
token_set.rs Replace LALRPOP parser with hand-written parser (#10036) 2024-04-18 17:57:39 +05:30
token_source.rs Move token and error structs into related modules (#11957) 2024-06-21 10:07:19 +00:00
typing.rs Update type annotation parsing API to return `Parsed` (#11739) 2024-06-05 12:59:43 +05:30