mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 01:20:40 +00:00
Build CommentRanges
outside the parser (#11792)
## Summary This PR updates the parser to remove building the `CommentRanges` and instead it'll be built by the linter and the formatter when it's required. For the linter, it'll be built and owned by the `Indexer` while for the formatter it'll be built from the `Tokens` struct and passed as an argument. ## Test Plan `cargo insta test`
This commit is contained in:
parent
7509a48eab
commit
549cc1e437
28 changed files with 151 additions and 102 deletions
|
@ -147,7 +147,7 @@ impl<'src> Parser<'src> {
|
|||
|
||||
// TODO consider re-integrating lexical error handling into the parser?
|
||||
let parse_errors = self.errors;
|
||||
let (tokens, comment_ranges, lex_errors) = self.tokens.finish();
|
||||
let (tokens, lex_errors) = self.tokens.finish();
|
||||
|
||||
// Fast path for when there are no lex errors.
|
||||
// There's no fast path for when there are no parse errors because a lex error
|
||||
|
@ -156,7 +156,6 @@ impl<'src> Parser<'src> {
|
|||
return Parsed {
|
||||
syntax,
|
||||
tokens: Tokens::new(tokens),
|
||||
comment_ranges,
|
||||
errors: parse_errors,
|
||||
};
|
||||
}
|
||||
|
@ -188,7 +187,6 @@ impl<'src> Parser<'src> {
|
|||
Parsed {
|
||||
syntax,
|
||||
tokens: Tokens::new(tokens),
|
||||
comment_ranges,
|
||||
errors: merged,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue