mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-22 19:39:58 +00:00
Implement basic rendering of remaining AST nodes (#3233)
This commit is contained in:
parent
51bca19c1d
commit
1c75071136
8 changed files with 527 additions and 48 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::core::visitor;
|
||||
use crate::core::visitor::Visitor;
|
||||
use crate::cst::{Alias, Excepthandler, Expr, SliceIndex, Stmt};
|
||||
use crate::cst::{Alias, Excepthandler, Expr, Pattern, SliceIndex, Stmt};
|
||||
use crate::trivia::{decorate_trivia, TriviaIndex, TriviaToken};
|
||||
|
||||
struct AttachmentVisitor {
|
||||
|
@ -47,6 +47,14 @@ impl<'a> Visitor<'a> for AttachmentVisitor {
|
|||
}
|
||||
visitor::walk_slice_index(self, slice_index);
|
||||
}
|
||||
|
||||
fn visit_pattern(&mut self, pattern: &'a mut Pattern) {
|
||||
let trivia = self.index.pattern.remove(&pattern.id());
|
||||
if let Some(comments) = trivia {
|
||||
pattern.trivia.extend(comments);
|
||||
}
|
||||
visitor::walk_pattern(self, pattern);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn attach(python_cst: &mut [Stmt], trivia: Vec<TriviaToken>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue