Expose hidden lexer token metadata accessors (#28443)

This commit is contained in:
Micha Reiser authored and GitHub committed 2026-09-09 09:02:54 +02:00
1 parent 55df129251
commit a99b96b9ac
2 files changed
+21 -2

No files matched your search

+5 -2
View File
@@ -119,12 +119,14 @@ impl<'src> Lexer<'src> {
}
/// Returns the range of the current token.
pub(crate) const fn current_range(&self) -> TextRange {
#[doc(hidden)]
pub const fn current_range(&self) -> TextRange {
self.current_range
}
/// Returns the flags for the current token.
pub(crate) const fn current_flags(&self) -> TokenFlags {
#[doc(hidden)]
pub const fn current_flags(&self) -> TokenFlags {
self.current_flags
}
@@ -1617,6 +1619,7 @@ fn is_identifier_continuation(c: char, identifier_is_ascii_only: &mut bool) -> b
}
/// Create a new [`Lexer`] for the given source code and [`Mode`].
#[doc(hidden)]
pub fn lex(source: &str, mode: Mode) -> Lexer<'_> {
Lexer::new(source, mode, TextSize::default())
}
+16
View File
@@ -134,6 +134,22 @@ kind = "inherent_method"
level = "expect"
reason = "preserves the public syntax-validity predicate API"
[[override]]
lint = "hawk::unnecessary_public"
crate = "ruff_python_parser"
item = "lexer::Lexer::<'src>::current_range"
kind = "inherent_method"
level = "expect"
reason = "lets downstream lexer callers inspect the current token range"
[[override]]
lint = "hawk::unnecessary_public"
crate = "ruff_python_parser"
item = "lexer::Lexer::<'src>::current_flags"
kind = "inherent_method"
level = "expect"
reason = "lets downstream lexer callers inspect the current token flags"
[[override]]
lint = "hawk::unnecessary_public"
crate = "ruff_workspace"