next() — tailwindcss Function Reference
Architecture documentation for the next() function in candidate_machine.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 3a4f9c94_8c04_4b8f_7b31_82d7f825ed05["next()"] 16b5fabd_92d2_8602_e43a_c1d04ce5e265["candidate_machine.rs"] 3a4f9c94_8c04_4b8f_7b31_82d7f825ed05 -->|defined in| 16b5fabd_92d2_8602_e43a_c1d04ce5e265 cc46bd42_2721_0ab7_2db5_ce71669a5b33["reset()"] 3a4f9c94_8c04_4b8f_7b31_82d7f825ed05 -->|calls| cc46bd42_2721_0ab7_2db5_ce71669a5b33 77014ac8_b6be_c3e8_b133_31e4643fa431["done_span()"] 3a4f9c94_8c04_4b8f_7b31_82d7f825ed05 -->|calls| 77014ac8_b6be_c3e8_b133_31e4643fa431 style 3a4f9c94_8c04_4b8f_7b31_82d7f825ed05 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
crates/oxide/src/extractor/candidate_machine.rs lines 29–169
fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState {
let len = cursor.input.len();
while cursor.pos < len {
// Skip ahead for known characters that will never be part of a candidate. No need to
// run any sub-machines.
if cursor.curr.is_ascii_whitespace() {
self.reset();
cursor.advance();
continue;
}
// Candidates don't start with these characters, so we can skip ahead.
if matches!(cursor.curr, b':' | b'"' | b'\'' | b'`') {
self.reset();
cursor.advance();
continue;
}
// Jump ahead if the character is known to be an invalid boundary and we should start
// at the next boundary even though "valid" candidates can exist.
//
// E.g.: `<div class="">`
// ^^^ Valid candidate
// ^ But this character makes it invalid
// ^ Therefore we jump here
//
// E.g.: `Some Class`
// ^ ^ Invalid, we can jump ahead to the next boundary
//
if matches!(cursor.curr, b'<' | b'A'..=b'Z') {
if let Some(offset) = cursor.input[cursor.pos..]
.iter()
.position(|&c| is_valid_before_boundary(&c))
{
self.reset();
cursor.advance_by(offset + 1);
} else {
return self.restart();
}
continue;
}
let mut variant_cursor = cursor.clone();
let variant_machine_state = self.variant_machine.next(&mut variant_cursor);
let mut utility_cursor = cursor.clone();
let utility_machine_state = self.utility_machine.next(&mut utility_cursor);
match (variant_machine_state, utility_machine_state) {
// No variant, but the utility machine completed
(MachineState::Idle, MachineState::Done(utility_span)) => {
cursor.move_to(utility_cursor.pos + 1);
let span = match self.last_variant_end_pos {
Some(end_pos) => {
// Verify that the utility is touching the last variant
if end_pos + 1 != utility_span.start {
return self.restart();
}
Span::new(self.start_pos, utility_span.end)
}
None => utility_span,
};
// Ensure the span has valid boundary characters before and after
if !has_valid_boundaries(&span, cursor.input) {
return self.restart();
}
return self.done_span(span);
}
// Both variant and utility machines are done
// E.g.: `hover:flex`
// ^^^^^^ Variant
// ^^^^^ Utility
//
(MachineState::Done(variant_span), MachineState::Done(utility_span)) => {
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does next() do?
next() is a function in the tailwindcss codebase, defined in crates/oxide/src/extractor/candidate_machine.rs.
Where is next() defined?
next() is defined in crates/oxide/src/extractor/candidate_machine.rs at line 29.
What does next() call?
next() calls 2 function(s): done_span, reset.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free