mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Use single lookup for leading, dangling, and trailing comments (#6589)
This commit is contained in:
parent
81b1176f99
commit
29c0b9f91c
39 changed files with 319 additions and 387 deletions
|
@ -106,7 +106,7 @@ use ruff_python_index::CommentRanges;
|
|||
use ruff_python_trivia::PythonWhitespace;
|
||||
|
||||
use crate::comments::debug::{DebugComment, DebugComments};
|
||||
use crate::comments::map::MultiMap;
|
||||
use crate::comments::map::{LeadingDanglingTrailing, MultiMap};
|
||||
use crate::comments::node_key::NodeRefEqualityKey;
|
||||
use crate::comments::visitor::CommentsVisitor;
|
||||
|
||||
|
@ -405,13 +405,13 @@ impl<'a> Comments<'a> {
|
|||
pub(crate) fn leading_dangling_trailing_comments<T>(
|
||||
&self,
|
||||
node: T,
|
||||
) -> impl Iterator<Item = &SourceComment>
|
||||
) -> LeadingDanglingTrailingComments
|
||||
where
|
||||
T: Into<AnyNodeRef<'a>>,
|
||||
{
|
||||
self.data
|
||||
.comments
|
||||
.parts(&NodeRefEqualityKey::from_ref(node.into()))
|
||||
.leading_dangling_trailing(&NodeRefEqualityKey::from_ref(node.into()))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -464,6 +464,8 @@ impl<'a> Comments<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) type LeadingDanglingTrailingComments<'a> = LeadingDanglingTrailing<'a, SourceComment>;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct CommentsData<'a> {
|
||||
comments: CommentsMap<'a>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue