Skip to content

Commit

Permalink
chore: add utility function for relative span positions
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed Mar 16, 2022
1 parent 5696e38 commit 1bb85bd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/parse/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ impl ParseSess {
self.parse_sess.source_map().lookup_char_pos(pos).line
}

// TODO(calebcartwright): Preemptive, currently unused addition
// that will be used to support formatting scenarios that take original
// positions into account
/// Determines whether two byte positions are in the same source line.
#[allow(dead_code)]
pub(crate) fn byte_pos_same_line(&self, a: BytePos, b: BytePos) -> bool {
self.line_of_byte_pos(a) == self.line_of_byte_pos(b)
}

pub(crate) fn span_to_debug_info(&self, span: Span) -> String {
self.parse_sess.source_map().span_to_diagnostic_string(span)
}
Expand Down

0 comments on commit 1bb85bd

Please sign in to comment.