mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 20:42:10 +00:00
Cache comment lookups in suite.rs
(#7092)
This commit is contained in:
parent
5ec73a6137
commit
7be28a38c5
2 changed files with 36 additions and 8 deletions
|
@ -481,6 +481,28 @@ impl<'a> Comments<'a> {
|
|||
|
||||
pub(crate) type LeadingDanglingTrailingComments<'a> = LeadingDanglingTrailing<'a, SourceComment>;
|
||||
|
||||
impl LeadingDanglingTrailingComments<'_> {
|
||||
/// Returns `true` if the struct has any [leading comments](self#leading-comments).
|
||||
#[inline]
|
||||
pub(crate) fn has_leading(&self) -> bool {
|
||||
!self.leading.is_empty()
|
||||
}
|
||||
|
||||
/// Returns `true` if the struct has any [trailing comments](self#trailing-comments).
|
||||
#[inline]
|
||||
pub(crate) fn has_trailing(&self) -> bool {
|
||||
!self.trailing.is_empty()
|
||||
}
|
||||
|
||||
/// Returns `true` if the struct has any [trailing own line comments](self#trailing-comments).
|
||||
#[inline]
|
||||
pub(crate) fn has_trailing_own_line(&self) -> bool {
|
||||
self.trailing
|
||||
.iter()
|
||||
.any(|comment| comment.line_position().is_own_line())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct CommentsData<'a> {
|
||||
comments: CommentsMap<'a>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue