mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-22 11:25:26 +00:00
Make BoolOp its own located token (#3265)
This commit is contained in:
parent
470e1c1754
commit
061495a9eb
19 changed files with 355 additions and 301 deletions
|
@ -1,6 +1,8 @@
|
|||
use crate::core::visitor;
|
||||
use crate::core::visitor::Visitor;
|
||||
use crate::cst::{Alias, Arg, Body, Excepthandler, Expr, Pattern, SliceIndex, Stmt};
|
||||
use crate::cst::{
|
||||
Alias, Arg, Body, BoolOp, Excepthandler, Expr, Keyword, Pattern, SliceIndex, Stmt,
|
||||
};
|
||||
use crate::trivia::{decorate_trivia, TriviaIndex, TriviaToken};
|
||||
|
||||
struct AttachmentVisitor {
|
||||
|
@ -56,6 +58,22 @@ impl<'a> Visitor<'a> for AttachmentVisitor {
|
|||
visitor::walk_excepthandler(self, excepthandler);
|
||||
}
|
||||
|
||||
fn visit_keyword(&mut self, keyword: &'a mut Keyword) {
|
||||
let trivia = self.index.keyword.remove(&keyword.id());
|
||||
if let Some(comments) = trivia {
|
||||
keyword.trivia.extend(comments);
|
||||
}
|
||||
visitor::walk_keyword(self, keyword);
|
||||
}
|
||||
|
||||
fn visit_bool_op(&mut self, bool_op: &'a mut BoolOp) {
|
||||
let trivia = self.index.bool_op.remove(&bool_op.id());
|
||||
if let Some(comments) = trivia {
|
||||
bool_op.trivia.extend(comments);
|
||||
}
|
||||
visitor::walk_bool_op(self, bool_op);
|
||||
}
|
||||
|
||||
fn visit_slice_index(&mut self, slice_index: &'a mut SliceIndex) {
|
||||
let trivia = self.index.slice_index.remove(&slice_index.id());
|
||||
if let Some(comments) = trivia {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue