mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:53 +00:00
Formatter: Show preceding, following and enclosing nodes of comments, Attempt 2 (#6813)
This commit is contained in:
parent
e3114a144c
commit
447b7cb0e2
3 changed files with 90 additions and 32 deletions
|
@ -108,7 +108,8 @@ use ruff_python_trivia::PythonWhitespace;
|
|||
use crate::comments::debug::{DebugComment, DebugComments};
|
||||
use crate::comments::map::{LeadingDanglingTrailing, MultiMap};
|
||||
use crate::comments::node_key::NodeRefEqualityKey;
|
||||
use crate::comments::visitor::CommentsVisitor;
|
||||
use crate::comments::visitor::{CommentsMapBuilder, CommentsVisitor};
|
||||
pub(crate) use visitor::collect_comments;
|
||||
|
||||
mod debug;
|
||||
pub(crate) mod format;
|
||||
|
@ -324,7 +325,9 @@ impl<'a> Comments<'a> {
|
|||
let map = if comment_ranges.is_empty() {
|
||||
CommentsMap::new()
|
||||
} else {
|
||||
CommentsVisitor::new(source_code, comment_ranges).visit(root)
|
||||
let mut builder = CommentsMapBuilder::default();
|
||||
CommentsVisitor::new(source_code, comment_ranges, &mut builder).visit(root);
|
||||
builder.finish()
|
||||
};
|
||||
|
||||
Self::new(map)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue