Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/trivia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn is_inside_comment(comments: &[Comment], pos: u32) -> bool {
/// Get the comment containing a position, if any
///
/// Returns a reference to the comment if the specified position is inside any
/// comment's span. The start position is included, but the end position is excluded. this is some
/// comment's span. The start position is included, but the end position is excluded.
///
/// Uses binary search for efficient lookup in O(log n) time.
///
Expand Down
7 changes: 6 additions & 1 deletion crates/oxc_semantic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use std::ops::RangeBounds;

use oxc_ast::{
AstKind, Comment, CommentsRange, ast::IdentifierReference, comments_range,
AstKind, Comment, CommentsRange, ast::IdentifierReference, comments_range, get_comment_at,
has_comments_between, is_inside_comment,
};
#[cfg(feature = "cfg")]
Expand Down Expand Up @@ -163,6 +163,11 @@ impl<'a> Semantic<'a> {
is_inside_comment(self.comments, pos)
}

/// Get the comment containing a position, if any.
pub fn get_comment_at(&self, pos: u32) -> Option<&Comment> {
get_comment_at(self.comments, pos)
}

pub fn irregular_whitespaces(&self) -> &[Span] {
&self.irregular_whitespaces
}
Expand Down
Loading